From eb37789f6f5fc4c37e93c612d9959fdaf65d1247 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 21 Feb 2009 19:33:01 +0000 Subject: SCI: Renamed include/gfx_*.h to gfx/gfx_*.h and likewise for sfx header files svn-id: r38735 --- engines/sci/engine/kernel.cpp | 2 +- engines/sci/engine/kgraphics.cpp | 2 +- engines/sci/engine/ksound.cpp | 2 +- engines/sci/engine/savegame.cfsml | 4 +- engines/sci/engine/savegame.cpp | 4 +- engines/sci/engine/vm.cpp | 2 +- engines/sci/gfx/antialias.cpp | 4 +- engines/sci/gfx/font-5x8.cpp | 2 +- engines/sci/gfx/font-6x10.cpp | 2 +- engines/sci/gfx/font.cpp | 6 +- engines/sci/gfx/gfx_driver.cpp | 4 +- engines/sci/gfx/gfx_driver.h | 322 +++++++++++++ engines/sci/gfx/gfx_operations.h | 684 ++++++++++++++++++++++++++++ engines/sci/gfx/gfx_options.h | 87 ++++ engines/sci/gfx/gfx_res_options.cpp | 6 +- engines/sci/gfx/gfx_res_options.h | 110 +++++ engines/sci/gfx/gfx_resmgr.h | 338 ++++++++++++++ engines/sci/gfx/gfx_resource.cpp | 6 +- engines/sci/gfx/gfx_resource.h | 414 +++++++++++++++++ engines/sci/gfx/gfx_state_internal.h | 239 ++++++++++ engines/sci/gfx/gfx_support.cpp | 4 +- engines/sci/gfx/gfx_system.h | 395 ++++++++++++++++ engines/sci/gfx/gfx_tools.cpp | 2 +- engines/sci/gfx/gfx_tools.h | 257 +++++++++++ engines/sci/gfx/gfx_widgets.h | 520 +++++++++++++++++++++ engines/sci/gfx/operations.cpp | 2 +- engines/sci/gfx/resmgr.cpp | 10 +- engines/sci/gfx/resource/sci_cursor_0.cpp | 6 +- engines/sci/gfx/resource/sci_font.cpp | 6 +- engines/sci/gfx/resource/sci_pal_1.cpp | 4 +- engines/sci/gfx/resource/sci_pic_0.cpp | 4 +- engines/sci/gfx/resource/sci_picfill.cpp | 2 +- engines/sci/gfx/resource/sci_resmgr.cpp | 6 +- engines/sci/gfx/resource/sci_view_0.cpp | 6 +- engines/sci/gfx/resource/sci_view_1.cpp | 6 +- engines/sci/gfx/sbtree.cpp | 4 +- engines/sci/gfx/sbtree.h | 110 +++++ engines/sci/gfx/sci_widgets.cpp | 4 +- engines/sci/gfx/widgets.cpp | 2 +- engines/sci/include/engine.h | 4 +- engines/sci/include/gfx_driver.h | 322 ------------- engines/sci/include/gfx_operations.h | 684 ---------------------------- engines/sci/include/gfx_options.h | 87 ---- engines/sci/include/gfx_res_options.h | 110 ----- engines/sci/include/gfx_resmgr.h | 338 -------------- engines/sci/include/gfx_resource.h | 414 ----------------- engines/sci/include/gfx_state_internal.h | 239 ---------- engines/sci/include/gfx_system.h | 395 ---------------- engines/sci/include/gfx_tools.h | 257 ----------- engines/sci/include/gfx_widgets.h | 520 --------------------- engines/sci/include/menubar.h | 4 +- engines/sci/include/sbtree.h | 110 ----- engines/sci/include/sciconsole.h | 2 +- engines/sci/include/sfx_core.h | 40 -- engines/sci/include/sfx_engine.h | 166 ------- engines/sci/include/sfx_iterator.h | 350 -------------- engines/sci/include/sfx_iterator_internal.h | 236 ---------- engines/sci/include/sfx_pcm.h | 184 -------- engines/sci/include/sfx_player.h | 154 ------- engines/sci/include/sfx_songlib.h | 191 -------- engines/sci/include/sfx_time.h | 85 ---- engines/sci/include/sfx_timer.h | 56 --- engines/sci/scicore/resource.cpp | 9 - engines/sci/sfx/core.cpp | 6 +- engines/sci/sfx/iterator.cpp | 4 +- engines/sci/sfx/mixer.h | 2 +- engines/sci/sfx/pcm-iterator.cpp | 2 +- engines/sci/sfx/pcm_device.cpp | 4 +- engines/sci/sfx/player/players.cpp | 2 +- engines/sci/sfx/player/polled.cpp | 2 +- engines/sci/sfx/player/realtime.cpp | 2 +- engines/sci/sfx/sequencer.h | 2 +- engines/sci/sfx/sfx_core.h | 40 ++ engines/sci/sfx/sfx_engine.h | 166 +++++++ engines/sci/sfx/sfx_iterator.h | 350 ++++++++++++++ engines/sci/sfx/sfx_iterator_internal.h | 236 ++++++++++ engines/sci/sfx/sfx_pcm.h | 184 ++++++++ engines/sci/sfx/sfx_player.h | 154 +++++++ engines/sci/sfx/sfx_songlib.h | 191 ++++++++ engines/sci/sfx/sfx_time.h | 85 ++++ engines/sci/sfx/sfx_timer.h | 56 +++ engines/sci/sfx/softseq.h | 4 +- engines/sci/sfx/softseq/opl2.cpp | 2 +- engines/sci/sfx/songlib.cpp | 2 +- engines/sci/sfx/time.cpp | 2 +- engines/sci/sfx/timer.cpp | 2 +- 86 files changed, 5018 insertions(+), 5029 deletions(-) create mode 100644 engines/sci/gfx/gfx_driver.h create mode 100644 engines/sci/gfx/gfx_operations.h create mode 100644 engines/sci/gfx/gfx_options.h create mode 100644 engines/sci/gfx/gfx_res_options.h create mode 100644 engines/sci/gfx/gfx_resmgr.h create mode 100644 engines/sci/gfx/gfx_resource.h create mode 100644 engines/sci/gfx/gfx_state_internal.h create mode 100644 engines/sci/gfx/gfx_system.h create mode 100644 engines/sci/gfx/gfx_tools.h create mode 100644 engines/sci/gfx/gfx_widgets.h create mode 100644 engines/sci/gfx/sbtree.h delete mode 100644 engines/sci/include/gfx_driver.h delete mode 100644 engines/sci/include/gfx_operations.h delete mode 100644 engines/sci/include/gfx_options.h delete mode 100644 engines/sci/include/gfx_res_options.h delete mode 100644 engines/sci/include/gfx_resmgr.h delete mode 100644 engines/sci/include/gfx_resource.h delete mode 100644 engines/sci/include/gfx_state_internal.h delete mode 100644 engines/sci/include/gfx_system.h delete mode 100644 engines/sci/include/gfx_tools.h delete mode 100644 engines/sci/include/gfx_widgets.h delete mode 100644 engines/sci/include/sbtree.h delete mode 100644 engines/sci/include/sfx_core.h delete mode 100644 engines/sci/include/sfx_engine.h delete mode 100644 engines/sci/include/sfx_iterator.h delete mode 100644 engines/sci/include/sfx_iterator_internal.h delete mode 100644 engines/sci/include/sfx_pcm.h delete mode 100644 engines/sci/include/sfx_player.h delete mode 100644 engines/sci/include/sfx_songlib.h delete mode 100644 engines/sci/include/sfx_time.h delete mode 100644 engines/sci/include/sfx_timer.h create mode 100644 engines/sci/sfx/sfx_core.h create mode 100644 engines/sci/sfx/sfx_engine.h create mode 100644 engines/sci/sfx/sfx_iterator.h create mode 100644 engines/sci/sfx/sfx_iterator_internal.h create mode 100644 engines/sci/sfx/sfx_pcm.h create mode 100644 engines/sci/sfx/sfx_player.h create mode 100644 engines/sci/sfx/sfx_songlib.h create mode 100644 engines/sci/sfx/sfx_time.h create mode 100644 engines/sci/sfx/sfx_timer.h (limited to 'engines') diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 54ff61dab7..c932a1fe93 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -38,7 +38,7 @@ #include "sci/engine/gc.h" #include "sci/include/sciresource.h" #include "sci/include/engine.h" -#include "sci/include/gfx_operations.h" +#include "sci/gfx/gfx_operations.h" #include "sci/engine/kernel_types.h" namespace Sci { diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index ef90bc3231..540dfd3cf2 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -27,7 +27,7 @@ #include "sci/include/sciresource.h" #include "sci/include/engine.h" -#include "sci/include/gfx_widgets.h" +#include "sci/gfx/gfx_widgets.h" #include "sci/engine/sci_graphics.h" #include "sci/include/sci_widgets.h" diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 46ef7d03d1..02b3a21dca 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -24,7 +24,7 @@ */ #include "sci/include/engine.h" -#include "sci/include/sfx_player.h" +#include "sci/sfx/sfx_player.h" namespace Sci { diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml index 97083e5625..275eb43bf5 100644 --- a/engines/sci/engine/savegame.cfsml +++ b/engines/sci/engine/savegame.cfsml @@ -32,8 +32,8 @@ #include #include // FIXME: For struct tm #include "sci/include/sci_memory.h" -#include "sci/include/gfx_operations.h" -#include "sci/include/sfx_engine.h" +#include "sci/gfx/gfx_operations.h" +#include "sci/sfx/sfx_engine.h" #include "sci/include/engine.h" #include "sci/engine/heap.h" #include "common/stream.h" diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index bc77dfb9d9..dd546145bc 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -32,8 +32,8 @@ #include #include // FIXME: For struct tm #include "sci/include/sci_memory.h" -#include "sci/include/gfx_operations.h" -#include "sci/include/sfx_engine.h" +#include "sci/gfx/gfx_operations.h" +#include "sci/sfx/sfx_engine.h" #include "sci/include/engine.h" #include "sci/engine/heap.h" #include "common/stream.h" diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 886a1f5d37..b92335cb8b 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -32,7 +32,7 @@ #include "sci/engine/kernel_types.h" #include "sci/engine/seg_manager.h" #include "sci/engine/gc.h" -#include "sci/include/sfx_player.h" +#include "sci/sfx/sfx_player.h" #ifdef HAVE_SETJMP_H #include diff --git a/engines/sci/gfx/antialias.cpp b/engines/sci/gfx/antialias.cpp index e7bf190d23..fac1aa3a5e 100644 --- a/engines/sci/gfx/antialias.cpp +++ b/engines/sci/gfx/antialias.cpp @@ -25,8 +25,8 @@ /** Antialiasing code **/ -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/font-5x8.cpp b/engines/sci/gfx/font-5x8.cpp index 7e446b8363..10ee35db06 100644 --- a/engines/sci/gfx/font-5x8.cpp +++ b/engines/sci/gfx/font-5x8.cpp @@ -1,6 +1,6 @@ /* Auto-generated by bdftofont.c */ -#include "sci/include/gfx_system.h" +#include "sci/gfx/gfx_system.h" namespace Sci { diff --git a/engines/sci/gfx/font-6x10.cpp b/engines/sci/gfx/font-6x10.cpp index 390bc5c7fa..1cb5cb6c4b 100644 --- a/engines/sci/gfx/font-6x10.cpp +++ b/engines/sci/gfx/font-6x10.cpp @@ -1,6 +1,6 @@ /* Auto-generated by bdftofont.c */ -#include "sci/include/gfx_system.h" +#include "sci/gfx/gfx_system.h" namespace Sci { diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp index c0326c749d..dcc140b948 100644 --- a/engines/sci/gfx/font.cpp +++ b/engines/sci/gfx/font.cpp @@ -24,9 +24,9 @@ */ -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index 6304abfd5e..6881f79e71 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -27,8 +27,8 @@ #include "common/system.h" #include "common/events.h" -#include "sci/include/gfx_driver.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_driver.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h new file mode 100644 index 0000000000..cb361a21bc --- /dev/null +++ b/engines/sci/gfx/gfx_driver.h @@ -0,0 +1,322 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _SCI_GFX_DRIVER_H_ +#define _SCI_GFX_DRIVER_H_ + +#include "sci/gfx/gfx_system.h" +#include "sci/include/uinput.h" + +namespace Sci { + +typedef enum { + GFX_BUFFER_FRONT = 0, + GFX_BUFFER_BACK = 1, + GFX_BUFFER_STATIC = 2 +} gfx_buffer_t; + + +/* graphics driver hints */ +#define GFX_CAPABILITY_SHADING (1<<0) +#define GFX_CAPABILITY_STIPPLED_LINES (1<<6) + +#define GFX_DEBUG_POINTER (1<<0) +#define GFX_DEBUG_UPDATES (1<<1) +#define GFX_DEBUG_PIXMAPS (1<<2) +#define GFX_DEBUG_BASIC (1<<3) /* Basic geometric ops (lines, boxes, etc) */ + +/* Principial graphics driver architecture +** --------------------------------------- +** +** All graphics drivers must provide +** - One visual front buffer (the actually visible thing) +** - Two dynamic back buffers: +** + visual +** + priority +** - Two static buffers (containing the background image and picviews): +** + visual +** + priority +** +** The control buffer is handled outside the graphics driver architecture. +** Graphics are drawn by first setting the static buffers, then updating +** the back buffers (from the static buffers), adding all picviews and other +** widgets, and finally updating the front buffer. +** +** All coordinates refer to the scaled coordinate system. +** Invalid parameters should produce an error message. +** Support for some valid parameter values is optional (like different line +** modes). If an unsupported but valid parameter is specified, the function +** must use a reasonable default value. +*/ + +typedef struct _gfx_driver { /* Graphics driver */ + + gfx_mode_t *mode; /* Currently active mode, NULL if no mode is active */ + + int pointer_x, pointer_y; /* Mouse pointer position */ + + int capabilities; /* The driver's capabilities: A list of flags that may + ** be pre-defined or set after a successful initialization. + */ + /* Capability flags: + ** + ** The words MUST, SHOULD and MAY are to be interpreted as described in + ** the IETF RFC 1123. + ** + ** GFX_CAPABILITY_SHADING: draw_filled_rect() supports drawing shaded + ** rectangles. + ** GFX_CAPABILITY_STIPPLED_LINES: The driver is able to draw stippled lines + ** horizontally and vertically (xl = 0 or yl = 0). + */ + + unsigned int debug_flags; /* Driver debug flags */ + + + /*** Initialization ***/ + + int (*set_parameter)(struct _gfx_driver *drv, char *attribute, char *value); + /* Sets a driver-specific parameter + ** Parameters: (gfx_driver_t *) drv: Pointer to the affected driver + ** (char *) attribute: Name of the attribute/parameter to set + ** (char *) value: The value to set, or NULL to query the value + ** Returns : (int) GFX_OK or GFX_FATAL, which signals a fatal error + ** condition. + ** This function should make extensive use of sciprintf() to signal invalid + ** values or unapplicable attributes. + ** Note that it may be called either before initialization (to interpret + ** config file or command line parameters) or afterwars (from the command + ** console). + */ + + int (*init_specific)(struct _gfx_driver *drv, int xres, int yres, + int bytespp); + /* Attempts to initialize a specific graphics mode + ** Parameters: (gfx_driver_t *) drv: The affected driver + ** (int x int) xres, yres: Horizontal and vertical scaling + ** factors + ** (int) bytespp: Any of GFX_COLOR_MODE_*. GFX_COLOR_MODE_INDEX + ** implies color index mode. + ** Returns : (int) GFX_OK on success, GFX_ERROR if the mode could not be + ** set, or GFX_FATAL if the graphics target is unuseable. + ** The scaling factors apply to the standard SCI resolution of 320x200 pixels + ** and is used for internal representation of graphical data. The physical + ** resolution set by the graphics driver may be different for practical + ** reasons. + ** Must also set drv->mode, preferably with the gfx_new_mode() function + ** specified in gfx_tools.h. + */ + + int (*init)(struct _gfx_driver *drv); + /* Initialize any graphics mode + ** Parameters: (gfx_driver_t *) drv: The affected driver + ** Returns : (int) GFX_OK on success, GFX_FATAL otherwise. + ** This function attempts to set /any/ graphics mode, starting with the one + ** most 'natural' to the graphics target. Target implementors have relatively + ** free reign in choosing the heuristics used to determine the resulting + ** mode. + ** Must also set drv->mode, preferably with the gfx_new_mode() function + ** specified in gfx_tools.h. + */ + + void (*exit)(struct _gfx_driver *drv); + /* Uninitializes the current graphics mode + ** Paramters: (gfx_driver_t *) drv: The driver to uninitialize + ** Return : (void) + ** This function frees all memory allocated by the graphics driver, + ** including mode and palette information, uninstalls all console commands + ** introduced by preceeding init() or init_specific() commands, and does any + ** clean-up work (like closing visuals or returning to text mode) required by + ** the graphics infrastructure used. + */ + + + /*** Drawing operations ***/ + + int (*draw_line)(struct _gfx_driver *drv, + Common::Point start, Common::Point end, + gfx_color_t color, + gfx_line_mode_t line_mode, gfx_line_style_t line_style); + /* Draws a single line to the back buffer. + ** Parameters: (gfx_driver_t *) drv: The driver affected + ** (Common::Point) start: Starting point of the line to draw + ** (Common::Point) end: End point of the line to draw + ** (gfx_color_t *) color: The color to draw with + ** (int) line_mode: Any of the line modes + ** (int) line_style: Any of the line styles + ** Returns : (int) GFX_OK or GFX_FATAL + ** Note that color.priority is relevant and must be drawn if + ** (color.mask & GFX_MASK_PRIORITY). + ** Support for line modes other than GFX_LINE_MODE_FAST is optional. + ** For non-fine lines, the coordinates provided describe the upper left + ** corner of the pixels of the line to draw. + ** line_style support is optional, if GFX_CAPABILITY_STIPPLED_LINES is not + ** set. + */ + + int (*draw_filled_rect)(struct _gfx_driver *drv, rect_t rect, + gfx_color_t color1, gfx_color_t color2, + gfx_rectangle_fill_t shade_mode); + /* Draws a single filled and possibly shaded rectangle to the back buffer. + ** Parameters: (gfx_driver_t *) drv: The driver affected + ** (rect_t *) rect: The rectangle to draw + ** (gfx_color_t *) color1, color2: The colors to draw with + ** (int) shade_mode: Any of GFX_SHADE_*. + ** Returns : (int) GFX_OK or GFX_FATAL + ** Note that color.priority is relevant and must be drawn if + ** (color.mask & GFX_MASK_PRIORITY). + ** color2 is relevant only if shade_mode is not GFX_SHADE_FLAT. + ** Support for shade modes other than GFX_SHADE_FLAT is optional. + */ + + /*** Pixmap operations ***/ + + int (*draw_pixmap)(struct _gfx_driver *drv, gfx_pixmap_t *pxm, int priority, + rect_t src, rect_t dest, gfx_buffer_t buffer); + /* Draws part of a pixmap to the static or back buffer + ** Parameters: (gfx_driver_t *) drv: The affected driver + ** (gfx_pixmap_t *) pxm: The pixmap to draw + ** (int) priority: The priority to draw with, or GFX_NO_PRIORITY + ** to draw on top of everything without setting the + ** priority back buffer + ** (rect_t) src: The pixmap-relative source rectangle + ** (rect_t) dest: The destination rectangle + ** (int) buffer: One of GFX_BUFFER_STATIC and GFX_BUFFER_BACK + ** Returns : (int) GFX_OK or GFX_FATAL, or GFX_ERROR if pxm was not + ** (but should have been) registered. + */ + + int (*grab_pixmap)(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm, + gfx_map_mask_t map); + /* Grabs an image from the visual or priority back buffer + ** Parameters: (gfx_driver_t *) drv: The affected driver + ** (rect_t) src: The rectangle to grab + ** (gfx_pixmap_t *) pxm: The pixmap structure the data is to + ** be written to + ** (int) map: GFX_MASK_VISUAL or GFX_MASK_PRIORITY + ** Returns : (int) GFX_OK, GFX_FATAL, or GFX_ERROR for invalid map values + ** pxm may be assumed to be empty and pre-allocated with an appropriate + ** memory size. + ** This function is now mandatory. + */ + + + /*** Buffer operations ***/ + + int (*update)(struct _gfx_driver *drv, rect_t src, Common::Point dest, + gfx_buffer_t buffer); + /* Updates the front buffer or the back buffers + ** Parameters: (gfx_driver_t *) drv: The affected driver + ** (rect_t) src: Source rectangle + ** (Common::Point) dest: Destination point + ** (int) buffer: One of GFX_BUFFER_FRONT or GFX_BUFFER_BACK + ** Returns : (int) GFX_OK, GFX_ERROR or GFX_FATAL + ** This function updates either the visual front buffer, or the two back + ** buffers, by copying the specified source region to the destination + ** region. + ** For heuristical reasons, it may be assumed that the x and y fields of + ** src and dest will be identical in /most/ cases. + ** If they aren't, the priority map will not be required to be copied. + */ + + int (*set_static_buffer)(struct _gfx_driver *drv, gfx_pixmap_t *pic, + gfx_pixmap_t *priority); + /* Sets the contents of the static visual and priority buffers + ** Parameters: (gfx_driver_t *) drv: The affected driver + ** (gfx_pixmap_t *) pic: The image defining the new content + ** of the visual back buffer + ** (gfx_pixmap_t *) priority: The priority map containing + ** the new content of the priority back buffer + ** in the index buffer + ** Returns : (int) GFX_OK or GFX_FATAL + ** pic and priority may be modified or written to freely. They may also be + ** used as the actual static buffers, since they are not freed and re- + ** allocated between calls to set_static_buffer() and update(), unless + ** exit() was called in between. + ** Note that later version of the driver interface may disallow modifying + ** pic and priority. + ** pic and priority are always scaled to the appropriate resolution + */ + + + /*** Mouse pointer operations ***/ + + int (*set_pointer)(struct _gfx_driver *drv, gfx_pixmap_t *pointer); + /* Sets a new mouse pointer. + ** Parameters: (gfx_driver_t *) drv: The driver to modify + ** (gfx_pixmap_t *) pointer: The pointer to set, or NULL to set + ** no pointer + ** Returns : (int) GFX_OK or GFX_FATAL + ** If pointer is not NULL, it will have been scaled to the appropriate + ** size and registered as a pixmap (if neccessary) beforehand. + ** If this function is called for a target that supports only two-color + ** pointers, the image is a color index image, where only color index values + ** 0, 1, and GFX_COLOR_INDEX_TRANSPARENT are used. + */ + + + /*** Palette operations ***/ + + int (*set_palette)(struct _gfx_driver *drv, int index, byte red, byte green, + byte blue); + /* Manipulates a palette index in the hardware palette + ** Parameters: (gfx_driver_t *) drv: The driver affected + ** (int) index: The index of the palette entry to modify + ** (int x int x int) red, green, blue: The RGB intensities to + ** set for the specified index. The minimum + ** intensity is 0, maximum is 0xff. + ** Returns : (int) GFX_OK, GFX_ERROR or GFX_FATAL + ** This function does not need to update mode->palette, as this is done + ** by the calling code. + ** set_palette() is only required for targets supporting color index mode. + */ + + + /*** Event management ***/ + + sci_event_t (*get_event)(struct _gfx_driver *drv); + /* Returns the next event in the event queue for this driver + ** Parameters: (gfx_driver_t *) drv: The driver to query + ** Returns : (sci_event_t) The oldest event still in the driver's event + ** queue, or the null event if there is none. + */ + + int (*usec_sleep)(struct _gfx_driver *drv, long usecs); + /* Sleeps the specified amount of microseconds, or until the mouse moves + ** Parameters: (gfx_driver_t *) drv: The relevant driver + ** (long) usecs: Amount of microseconds to sleep + ** Returns : (int) GFX_OK or GFX_FATAL + ** This function returns when the specified amount of microseconds has + ** elapsed, or when the mouse pointer has been moved and needs to be redrawn. + ** Only targets that can handle colored mouse pointers may choose to handle + ** all mouse management internally. + */ + + void *state; /* Reserved for internal use */ + +} gfx_driver_t; + +} // End of namespace Sci + +#endif // !_SCI_GFX_DRIVER_H_ diff --git a/engines/sci/gfx/gfx_operations.h b/engines/sci/gfx/gfx_operations.h new file mode 100644 index 0000000000..15090d22da --- /dev/null +++ b/engines/sci/gfx/gfx_operations.h @@ -0,0 +1,684 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Graphical operations, called from the widget state manager */ + +#ifndef _GFX_OPERATIONS_H_ +#define _GFX_OPERATIONS_H_ + +#include "sci/gfx/gfx_resmgr.h" +#include "sci/gfx/gfx_tools.h" +#include "sci/gfx/gfx_options.h" +#include "sci/gfx/gfx_system.h" +#include "sci/include/uinput.h" + +namespace Sci { + +#define GFXOP_NO_POINTER -1 + +/* Threshold in color index mode to differentiate between visible and non-visible stuff. +** GFXOP_ALPHA_THRESHOLD itself should be treated as non-visible. +*/ +#define GFXOP_ALPHA_THRESHOLD 0xff + +typedef struct { + char *text; /* Copy of the actual text */ + + int lines_nr; + int line_height; + text_fragment_t *lines; /* Text offsets */ + gfx_bitmap_font_t *font; + gfx_pixmap_t **text_pixmaps; + + int width, height; + + int priority, control; + gfx_alignment_t halign, valign; +} gfx_text_handle_t; + +/* Unless individually stated otherwise, the following applies: +** All operations herein apply to the standard 320x200 coordinate system. +** All operations perform clipping relative to state->clip_zone. +*/ + +typedef enum { + GFX_BOX_SHADE_FLAT, + GFX_BOX_SHADE_RIGHT, + GFX_BOX_SHADE_LEFT, + GFX_BOX_SHADE_DOWN, + GFX_BOX_SHADE_UP +#if 0 + /* possible with alphaing, but there is no way to check for + ** alpha capability of gfx_driver->draw_filled_rect() yet + */ + , GFX_BOX_SHADE_RIGHT_DOWN, + GFX_BOX_SHADE_LEFT_DOWN, + GFX_BOX_SHADE_RIGHT_UP, + GFX_BOX_SHADE_LEFT_UP +#endif +} gfx_box_shade_t; + + +typedef struct _dirty_rect { + rect_t rect; + struct _dirty_rect *next; +} gfx_dirty_rect_t; + + +typedef struct _gfx_event { + sci_event_t event; + struct _gfx_event *next; +} gfx_input_event_t; + +typedef struct { + int version; /* Interpreter version */ + + gfx_options_t *options; + + Common::Point pointer_pos; /* Mouse pointer coordinates */ + + rect_t clip_zone_unscaled; /* The current UNSCALED clipping zone */ + rect_t clip_zone; /* The current SCALED clipping zone; a cached scaled version of clip_zone_unscaled */ + + gfx_driver_t *driver; + gfx_pixmap_color_t *static_palette; /* Null for dynamic palettes */ + int static_palette_entries; + + int visible_map; + + gfx_resstate_t *resstate; /* Resource state */ + + gfx_pixmap_t *priority_map; /* back buffer priority map (unscaled) */ + gfx_pixmap_t *static_priority_map; /* static buffer priority map (unscaled) */ + gfx_pixmap_t *control_map; /* back buffer control map (only exists unscaled in the first place) */ + + + int mouse_pointer_visible; /* Whether the pointer is drawn right now */ + Common::Point old_pointer_draw_pos; /* Mouse pointer draw coordinates */ + rect_t pointer_bg_zone; /* old-pointer-draw-pos relative zone inside the pointer + ** pixmap that was drawn */ + + int mouse_pointer_in_hw; /* Current pointer is being handled in hardware */ + + gfx_pixmap_t *mouse_pointer; /* Only set when drawing the mouse manually */ + gfx_pixmap_t *mouse_pointer_bg; /* Background under the pointer */ + + int tag_mode; /* Set to 1 after a new pic is drawn and the resource manager + ** has tagged all resources. Reset after the next front buffer + ** update is done, when all resources that are still tagged are + ** flushed. */ + + int disable_dirty; /* Set to 1 to disable dirty rect accounting */ + + int pic_nr; /* Number of the current pic */ + int palette_nr; /* Palette number of the current pic */ + + gfx_input_event_t *events; + + gfx_pixmap_t *fullscreen_override; /* An optional override picture which must have unscaled + ** full-screen size, which overrides all other visibility, and + ** which is generally slow */ + + gfxr_pic_t *pic, *pic_unscaled; /* The background picture and its unscaled equivalent */ + + struct _dirty_rect *dirty_rects; /* Dirty rectangles */ + + void *internal_state; /* Internal interpreter information */ + +} gfx_state_t; + + +/**************************/ +/* Fundamental operations */ +/**************************/ + +int gfxop_init_default(gfx_state_t *state, gfx_options_t *options, void *misc_info); +/* Initializes a graphics mode suggested by the graphics driver +** Parameters: (gfx_state_ t *) state: The state to initialize in that mode +** (gfx_options_t *) options: Rendering options +** (void *) misc_info: Additional information for the interpreter +** part of the resource loader +** Returns : (int) GFX_OK on success, GFX_FATAL otherwise +*/ + +int gfxop_init(gfx_state_t *state, int xfact, int yfact, gfx_color_mode_t bpp, + gfx_options_t *options, void *misc_info); +/* Initializes a custom graphics mode +** Parameters: (gfx_state_t *) state: The state to initialize +** (int x int) xfact, yfact: Horizontal and vertical scale factors +** (gfx_color_mode_t) bpp: Bytes per pixel to initialize with, or +** 0 (GFX_COLOR_MODE_AUTO) to auto-detect +** (gfx_options_t *) options: Rendering options +** (void *) misc_info: Additional information for the interpreter +** part of the resource loader +** Returns : (int) GFX_OK on success, GFX_ERROR if that particular mode is +** unavailable, or GFX_FATAL if the graphics driver is unable +** to provide any useful graphics support +*/ + +int gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value); +/* Sets a driver-specific parameter +** Parameters: (gfx_state_t *) state: The state, encapsulating the driver object to manipulate +** (char *) attribute: The attribute to set +** (char *) value: The value the attribute should be set to +** Returns : (int) GFX_OK on success, GFX_FATAL on fatal error conditions triggered +** by the command +*/ + +int gfxop_exit(gfx_state_t *state); +/* Deinitializes a currently active driver +** Parameters: (gfx_state_t *) state: The state encapsulating the driver in question +** Returns : (int) GFX_OK +*/ + +int gfxop_scan_bitmask(gfx_state_t *state, rect_t area, gfx_map_mask_t map); +/* Calculates a bit mask calculated from some pixels on the specified map +** Parameters: (gfx_state_t *) state: The state containing the pixels to scan +** (rect_t) area: The area to check +** (gfx_map_mask_t) map: The GFX_MASKed map(s) to test +** Returns : (int) An integer value where, for each 0<=i<=15, bit #i is set +** iff there exists a map for which the corresponding bit was set +** in the 'map' parameter and for which there exists a pixel within +** the specified area so that the pixel's lower 4 bits, interpreted +** as an integer value, equal i. +** (Short version: This is an implementation of "on_control()"). +*/ + +int gfxop_set_visible_map(gfx_state_t *state, gfx_map_mask_t map); +/* Sets the currently visible map +** Parameters: (gfx_state_t *) state: The state to modify +** (gfx_map_mask_t) map: The GFX_MASK to set +** Returns : (int) GFX_OK, or GFX_ERROR if map was invalid +** 'visible_map' can be any of GFX_MASK_VISUAL, GFX_MASK_PRIORITY and GFX_MASK_CONTROL; the appropriate +** map (as far as its contents are known to the graphics subsystem) is then subsequently drawn to the +** screen at each update. If this is set to anything other than GFX_MASK_VISUAL, slow full-screen updates +** are performed. Mostly useful for debugging. +** The screen needs to be updated for the changes to take effect. +*/ + +int gfxop_set_clip_zone(gfx_state_t *state, rect_t zone); +/* Sets a new clipping zone +** Parameters: (gfx_state_t *) state: The affected state +** (rect_t) zone: The new clipping zone +** Returns : (int) GFX_OK +*/ + +/******************************/ +/* Generic drawing operations */ +/******************************/ + +int gfxop_draw_line(gfx_state_t *state, + Common::Point start, Common::Point end, + gfx_color_t color, gfx_line_mode_t line_mode, + gfx_line_style_t line_style); +/* Renders a clipped line to the back buffer +** Parameters: (gfx_state_t *) state: The state affected +** (Common::Point) start: Starting point of the line +** (Common::Point) end: End point of the line +** (gfx_color_t) color: The color to use for drawing +** (gfx_line_mode_t) line_mode: Any valid line mode to use +** (gfx_line_style_t) line_style: The line style to use +** Returns : (int) GFX_OK or GFX_FATAL +*/ + +int gfxop_draw_rectangle(gfx_state_t *state, rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, + gfx_line_style_t line_style); +/* Draws a non-filled rectangular box to the back buffer +** Parameters: (gfx_state_t *) state: The affected state +** (rect_t) rect: The rectangular area the box is drawn to +** (gfx_color_t) color: The color the box is to be drawn in +** (gfx_line_mode_t) line_mode: The line mode to use +** (gfx_line_style_t) line_style: The line style to use for the box +** Returns : (int) GFX_OK or GFX_FATAL +** Boxes drawn in thin lines will surround the minimal area described by rect. +*/ + +int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t color2, + gfx_box_shade_t shade_type); +/* Draws a filled box to the back buffer +** Parameters: (gfx_state_t *) state: The affected state +** (rect_t) box: The area to draw to +** (gfx_color_t) color1: The primary color to use for drawing +** (gfx_color_t) color2: The secondary color to draw in +** (gfx_box_shade_t) shade_type: The shading system to use +** (e.g. GFX_BOX_SHADE_FLAT) +** Returns : (int) GFX_OK or GFX_FATAL +** The draw mask, control, and priority values are derived from color1. +*/ + +int gfxop_fill_box(gfx_state_t *state, rect_t box, gfx_color_t color); +/* Fills a box in the back buffer with a specific color +** Parameters: (gfx_state_t *) state: The state to draw to +** (rect_t) box: The box to fill +** (gfx_color_t) color: The color to use for filling +** Returns : (int) GFX_OK or GFX_FATAL +** This is a simple wrapper function for gfxop_draw_box +*/ + +int gfxop_clear_box(gfx_state_t *state, rect_t box); +/* Copies a box from the static buffer to the back buffer +** Parameters: (gfx_state_t *) state: The affected state +** (rect_t) box: The box to propagate from the static buffer +** Returns : (int) GFX_OK or GFX_FATAL +*/ + + +int gfxop_update(gfx_state_t *state); +/* Updates all dirty rectangles +** Parameters: (gfx_state_t) *state: The relevant state +** Returns : (int) GFX_OK or GFX_FATAL if reported by the driver +** In order to track dirty rectangles, they must be enabled in the options. +** This function instructs the resource manager to free all tagged data +** on certain occasions (see gfxop_new_pic). +*/ + + +int gfxop_update_box(gfx_state_t *state, rect_t box); +/* Propagates a box from the back buffer to the front (visible) buffer +** Parameters: (gfx_state_t *) state: The affected state +** (rect_t) box: The box to propagate to the front buffer +** Returns : (int) GFX_OK or GFX_FATAL +** This function instructs the resource manager to free all tagged data +** on certain occasions (see gfxop_new_pic). +** When called with dirty rectangle management enabled, it will automatically +** propagate all dirty rectangles as well, UNLESS dirty frame accounting has +** been disabled explicitly. +*/ + +int gfxop_enable_dirty_frames(gfx_state_t *state); +/* Enables dirty frame accounting +** Parameters: (gfx_state_t *) state: The state dirty frame accounting is to be enabled in +** Returns : (int) GFX_OK or GFX_ERROR if state was invalid +** Dirty frame accounting is enabled by default. +*/ + +int gfxop_disable_dirty_frames(gfx_state_t *state); +/* Disables dirty frame accounting +** Parameters: (gfx_state_t *) state: The state dirty frame accounting is to be disabled in +** Returns : (int) GFX_OK or GFX_ERROR if state was invalid +*/ + + +/********************/ +/* Color operations */ +/********************/ + +int gfxop_set_color(gfx_state_t *state, gfx_color_t *color, int r, int g, int b, int a, + int priority, int control); +/* Maps an r/g/b value to a color and sets a gfx_color_t structure +** Parameters: (gfx_state_t *) state: The current state +** (gfx_color_t *) color: Pointer to the structure to write to +** (int x int x int) r,g,b: The red/green/blue color intensity values +** of the result color (0x00 (minimum) to 0xff (max)) +** If any of these values is less than zero, the +** resulting color will not affect the visual map when +** used for drawing +** (int) a: The alpha (transparency) value, with 0x00 meaning absolutely +** opaque and 0xff meaning fully transparent. Alpha blending support +** is optional for drivers, so these are the only two values that +** are guaranteed to work as intended. Any value in between them +** must guarantee the following opaqueness: +** opaqueness(x-1) >= opaqueness(x) >= opaqueness (x+1) +** (i.e. ([0,255], less-transparent-than) must define a partial order) +** (int) priority: The priority to use for drawing, or -1 for none +** (int) control: The control to use for drawing, or -1 to disable drawing to the +** control map +** Returns : (int) GFX_OK or GFX_ERROR if state is invalid +** In palette mode, this may allocate a new color. Use gfxop_free_color() described below to +** free that color. +*/ + +int gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color); +/* Designates a color as a 'system color' +** Parameters: (gfx_state_t *) state: The affected state +** (gfx_color_t *) color: The color to designate as a system color +** Returns : (int) GFX_OK or GFX_ERROR if state is invalid +** System colors are permanent colors that cannot be deallocated. As such, they must be used +** with caution. +*/ + +int gfxop_free_color(gfx_state_t *state, gfx_color_t *color); +/* Frees a color allocated by gfxop_set_color() +** Parmaeters: (gfx_state_t *) state: The state affected +** (gfx_color_t *) color: The color to de-allocate +** Returns : (int) GFX_OK or GFX_ERROR if state is invalid +** This function is a no-op in non-index mode, or if color is a system color. +*/ + + +/**********************/ +/* Pointer and IO ops */ +/**********************/ + +int gfxop_usleep(gfx_state_t *state, long usecs); +/* Suspends program execution for the specified amount of microseconds +** Parameters: (gfx_state_t *) state: The state affected +** (long) usecs: The amount of microseconds to wait +** Returns : (int) GFX_OK or GFX_ERROR +** The mouse pointer will be redrawn continually, if applicable +*/ + +int gfxop_set_pointer_cursor(gfx_state_t *state, int nr); +/* Sets the mouse pointer to a cursor resource +** Parameters: (gfx_state_t *) state: The affected state +** (int) nr: Number of the cursor resource to use +** Returns : (int) GFX_OK, GFX_ERROR if the resource did not +** exist and was not GFXOP_NO_POINTER, or GFX_FATAL on +** fatal error conditions. +** Use nr = GFX_NO_POINTER to disable the mouse pointer (default). +*/ + +int gfxop_set_pointer_view(gfx_state_t *state, int nr, int loop, int cel, Common::Point *hotspot); +/* Sets the mouse pointer to a view resource +** Parameters: (gfx_state_t *) state: The affected state +** (int) nr: Number of the view resource to use +** (int) loop: View loop to use +** (int) cel: View cel to use +** (Common::Point *) hotspot: Manually set hotspot to use, or NULL for default. +** Returns : (int) GFX_OK or GFX_FATAL +** Use gfxop_set_pointer_cursor(state, GFXOP_NO_POINTER) to disable the +** pointer. +*/ + +int gfxop_set_pointer_position(gfx_state_t *state, Common::Point pos); +/* Teleports the mouse pointer to a specific position +** Parameters: (gfx_state_t *) state: The state the pointer is in +** (Common::Point) pos: The position to teleport it to +** Returns : (int) Any error code or GFX_OK +** Depending on the graphics driver, this operation may be without +** any effect +*/ + +sci_event_t gfxop_get_event(gfx_state_t *state, unsigned int mask); +/* Retreives the next input event from the driver +** Parameters: (gfx_state_t *) state: The affected state +** (int) mask: The event mask to poll from (see uinput.h) +** Returns : (sci_event_t) The next event in the driver's event queue, or +** a NONE event if no event matching the mask was found. +*/ + + +/*******************/ +/* View operations */ +/*******************/ + +int gfxop_lookup_view_get_loops(gfx_state_t *state, int nr); +/* Determines the number of loops associated with a view +** Parameters: (gfx_state_t *) state: The state to use +** (int) nr: Number of the view to investigate +** Returns : (int) The number of loops, or GFX_ERROR if the view didn't exist +*/ + +int gfxop_lookup_view_get_cels(gfx_state_t *state, int nr, int loop); +/* Determines the number of cels associated stored in a loop +** Parameters: (gfx_state_t *) state: The state to look up in +** (int) nr: Number of the view to look up in +** (int) loop: Number of the loop the number of cels of +** are to be investigated +** Returns : (int) The number of cels in that loop, or GFX_ERROR if either +** the view or the loop didn't exist +*/ + +int gfxop_check_cel(gfx_state_t *state, int nr, int *loop, int *cel); +/* Clips the view/loop/cel position of a cel +** Parameters: (gfx_state_t *) state: The state to use +** (int) nr: Number of the view to use +** (int *) loop: Pointer to the variable storing the loop +** number to verify +** (int *) cel: Pointer to the variable storing the cel +** number to check +** Returns : (int) GFX_OK or GFX_ERROR if the view didn't exist +** *loop is clipped first, then *cel. The resulting setup will be a valid +** view configuration. +*/ + +int gfxop_overflow_cel(gfx_state_t *state, int nr, int *loop, int *cel); +/* Resets loop/cel values to zero if they have become invalid +** Parameters: (gfx_state_t *) state: The state to use +** (int) nr: Number of the view to use +** (int *) loop: Pointer to the variable storing the loop +** number to verify +** (int *) cel: Pointer to the variable storing the cel +** number to check +** Returns : (int) GFX_OK or GFX_ERROR if the view didn't exist +** *loop is clipped first, then *cel. The resulting setup will be a valid +** view configuration. +*/ + +int gfxop_get_cel_parameters(gfx_state_t *state, int nr, int loop, int cel, + int *width, int *height, Common::Point *offset); +/* Retreives the width and height of a cel +** Parameters: (gfx_state_t *) state: The state to use +** (int) nr: Number of the view +** (int) loop: Loop number to examine +** (int) cel: The cel (inside the loop) to look up +** (int *) width: The variable the width will be stored in +** (int *) height: The variable the height will be stored in +** (Common::Point *) offset: The variable the cel's x/y offset will be stored in +** Returns : (int) GFX_OK if the lookup succeeded, GFX_ERROR if the nr/loop/cel +** combination was invalid +*/ + +int gfxop_draw_cel(gfx_state_t *state, int nr, int loop, int cel, Common::Point pos, + gfx_color_t color, int palette); +/* Draws (part of) a cel to the back buffer +** Parameters: (gfx_state_t *) state: The state encapsulating the driver to draw with +** (int) nr: Number of the view to draw +** (int) loop: Loop of the cel to draw +** (int) cel: The cel number of the cel to draw +** (Common::Point) pos: The positino the cel is to be drawn to +** (gfx_color_t color): The priority and control values to use for drawing +** (int) palette: The palette to use +** Returns : (int) GFX_OK or GFX_FATAL +*/ + + +int gfxop_draw_cel_static(gfx_state_t *state, int nr, int loop, int cel, Common::Point pos, + gfx_color_t color, int palette); +/* Draws a cel to the static buffer; no clipping is performed +** Parameters: (gfx_state_t *) state: The state encapsulating the driver to draw with +** (int) nr: Number of the view to draw +** (int) loop: Loop of the cel to draw +** (int) cel: The cel number of the cel to draw +** (Common::Point) pos: The positino the cel is to be drawn to +** (gfx_color_t color): The priority and control values to use for drawing +** (int) palette: The palette to use +** Returns : (int) GFX_OK or GFX_FATAL +** Let me repeat, no clipping (except for the display borders) is performed. +*/ + + +int gfxop_draw_cel_static_clipped(gfx_state_t *state, int nr, int loop, int cel, Common::Point pos, + gfx_color_t color, int palette); +/* Draws (part of) a clipped cel to the static buffer +** Parameters: (gfx_state_t *) state: The state encapsulating the driver to draw with +** (int) nr: Number of the view to draw +** (int) loop: Loop of the cel to draw +** (int) cel: The cel number of the cel to draw +** (Common::Point) pos: The positino the cel is to be drawn to +** (gfx_color_t color): The priority and control values to use for drawing +** (int) palette: The palette to use +** Returns : (int) GFX_OK or GFX_FATAL +** This function does clip. +*/ + + +/******************/ +/* Pic operations */ +/******************/ +/* These operations are exempt from clipping */ + +int gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette); +/* Draws a pic and writes it over the static buffer +** Parameters: (gfx_state_t *) state: The state affected +** (int) nr: Number of the pic to draw +** (int) flags: Interpreter-dependant flags to use for drawing +** (int) default_palette: The default palette for drawing +** Returns : (int) GFX_OK or GFX_FATAL +** This function instructs the resource manager to tag all data as "unused". +** See the resource manager tag functions for a full description. +*/ + +void *gfxop_get_pic_metainfo(gfx_state_t *state); +/* Retreives all meta-information assigned to the current pic +** Parameters: (gfx_state_t *) state: The state affected +** Returns : (void *) NULL if the pic doesn't exist or has no meta-information, +** the meta-info otherwise +** This meta-information is referred to as 'internal data' in the pic code +*/ + +int gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette); +/* Adds a pic to the static buffer +** Parameters: (gfx_state_t *) state: The state affected +** (int) nr: Number of the pic to add +** (int) flags: Interpreter-dependant flags to use for drawing +** (int) default_palette: The default palette for drawing +** Returns : (int) GFX_OK or GFX_FATAL +*/ + + + + +/*******************/ +/* Text operations */ +/*******************/ + + +int gfxop_get_font_height(gfx_state_t *state, int font_nr); +/* Returns the fixed line height for one specified font +** Parameters: (gfx_state_t *) state: The state to work on +** (int) font_nr: Number of the font to inspect +** Returns : (int) GFX_ERROR, GFX_FATAL, or the font line height +*/ + +int gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, + int maxwidth, int *width, int *height, int flags, + int *lines_nr, int *lineheight, int *lastline_width); +/* Calculates the width and height of a specified text in a specified font +** Parameters: (gfx_state_t *) state: The state to use +** (int) font_nr: Font number to use for the calculation +** (const char *) text: The text to examine +** (int) flags: ORred GFXR_FONT_FLAGs +** (int) maxwidth: The maximum pixel width to allow for the text +** Returns : (int) GFX_OK or GFX_ERROR if the font didn't exist +** (int) *width: The resulting width +** (int) *height: The resulting height +** (int) *lines_nr: Number of lines used in the text +** (int) *lineheight: Pixel height (SCI scale) of each text line +** (int) *lastline_wdith: Pixel offset (SCI scale) of the space +** after the last character in the last line +*/ + +gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, + gfx_alignment_t halign, gfx_alignment_t valign, + gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, + int flags); +/* Generates a new text handle that can be used to draw any text +** Parameters: (gfx_state_t *) state: The state to use +** (int) font_nr: Font number to use for the calculation +** (char *) text: The text to examine +** (int) maxwidth: The maximum pixel width to allow for the text +** (gfx_alignment_t) halign: The horizontal text alignment +** (gfx_alignment_t) valign: The vertical text alignment +** (gfx_color_t x gfx_color_t) color1, color2: The text's foreground colors +** (the function will dither between those two) +** (gfx_color_t) bg_color: The background color +** (int) flags: ORred GFXR_FONT_FLAGs +** Returns : (gfx_text_handle_t *) A newly allocated gfx_text_handle_t, or +** NULL if font_nr was invalid +** The control and priority values for the text will be extracted from color1. +** Note that the colors must have been allocated properly, or the text may display in +** incorrect colors. +*/ + +int gfxop_free_text(gfx_state_t *state, gfx_text_handle_t *handle); +/* Frees a previously allocated text handle and all related resources +** Parameters: (gfx_state_t *) state: The state to use +** (gfx_text_handle_t *) handle: The handle to free +** Returns : (int) GFX_OK +*/ + +int gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone); +/* Draws text stored in a text handle +** Parameters: (gfx_state_t *) state: The target state +** (gfx_text_handle_t *) handle: The text handle to use for drawing +** (rect_t) zone: The rectangular box to draw to. In combination with +** halign and valign, this defines where the text is +** drawn to. +** Returns : (int) GFX_OK or GFX_FATAL +*/ + + +/****************************/ +/* Manual pixmap operations */ +/****************************/ + +gfx_pixmap_t *gfxop_grab_pixmap(gfx_state_t *state, rect_t area); +/* Grabs a screen section from the back buffer and stores it in a pixmap +** Parameters: (gfx_state_t *) state: The affected state +** (rect_t) area: The area to grab +** Returns : (gfx_pixmap_t *) A result pixmap, or NULL on error +** Obviously, this only affects the visual map +*/ + +int gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos); +/* Draws part of a pixmap to the screen +** Parameters: (gfx_state_t *) state: The affected state +** (gfx_pixmap_t *) pxm: The pixmap to draw +** (rect_t) zone: The segment of the pixmap to draw +** (Common::Point) pos: The position the pixmap should be drawn to +** Returns : (int) GFX_OK or any error code +*/ + +int gfxop_free_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm); +/* Frees a pixmap returned by gfxop_grab_pixmap() +** Parameters: (gfx_state_t *) state: The affected state +** (gfx_pixmap_t *) pxm: The pixmap to free +** Returns : (int) GFX_OK, or GFX_ERROR if the state was invalid +*/ + +/******************************/ +/* Dirty rectangle operations */ +/******************************/ + +gfx_dirty_rect_t *gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy); +/* Adds a dirty rectangle to 'base' according to a strategy +** Parameters: (gfx_dirty_rect_t *) base: The base rectangle to add to, or NULL +** (rect_t) box: The dirty frame to add +** (int) strategy: The dirty frame heuristic to use (see gfx_options.h) +** Returns : (gfx_dirty_rect_t *) an appropriate singly-linked dirty rectangle +** result cluster +*/ + +int _gfxop_clip(rect_t *rect, rect_t clipzone); +/* Clips a rectangle against another one +** Parameters: (rect_t *) rect: The rectangle to clip +** (rect_t) clipzone: The outer bounds rect must be in +** Reuturns : (int) 1 if rect is empty now, 0 otherwise +*/ + +} // End of namespace Sci + +#endif // !_GFX_OPERATIONS_H_ diff --git a/engines/sci/gfx/gfx_options.h b/engines/sci/gfx/gfx_options.h new file mode 100644 index 0000000000..d9abcbbfb2 --- /dev/null +++ b/engines/sci/gfx/gfx_options.h @@ -0,0 +1,87 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + + +#ifndef _GFX_OPTIONS_H_ +#define _GFX_OPTIONS_H_ + +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" +#include "sci/gfx/gfx_res_options.h" + +namespace Sci { + +/* Dirty rectangle heuristics: */ + +/* One: Redraw one rectangle surrounding the dirty area (insert is O(1)) */ +#define GFXOP_DIRTY_FRAMES_ONE 1 + +/* Clusters: Accumulate dirty rects, merging those that overlap (insert is O(n)) */ +#define GFXOP_DIRTY_FRAMES_CLUSTERS 2 + + +typedef struct _gfx_options { + /* gfx_options_t: Contains all user options to the rendering pipeline */ + /* See note in sci_conf.h for config_entry_t before changing types of + ** variables */ + + int buffer_pics_nr; /* Number of unused pics to buffer */ + + int correct_rendering; /* Whether to render slow, but correct (rather than + ** fast and almost correct) */ + + /* SCI0 pic resource options */ + int pic0_unscaled; /* Don't draw scaled SCI0 pics */ + + int pic0_dither_mode; /* Defined in gfx_resource.h */ + int pic0_dither_pattern; /* Defined in gfx_resource.h */ + + gfx_brush_mode_t pic0_brush_mode; + gfx_line_mode_t pic0_line_mode; + + gfx_xlate_filter_t cursor_xlate_filter; + gfx_xlate_filter_t view_xlate_filter; + gfx_xlate_filter_t pic_xlate_filter; /* Only relevant if (pic0_unscaled) */ + gfx_xlate_filter_t text_xlate_filter; + gfxr_font_scale_filter_t fixed_font_xlate_filter; /* Scale filter for systems that provide font support which isn't scaled */ + + gfxr_antialiasing_t pic0_antialiasing; + + gfx_res_fullconf_t res_conf; /* Resource customisation: Per-resource palettes etc. */ + + int dirty_frames; + + int workarounds; /* Workaround flags- see below */ + + rect_t pic_port_bounds; +} gfx_options_t; + +/* SQ3 counts whitespaces towards the total text size, as does gfxop_get_text_params() if this is set: */ +#define GFX_WORKAROUND_WHITESPACE_COUNT (1 << 0) + +} // End of namespace Sci + +#endif // !_GFX_OPTIONS_H_ + diff --git a/engines/sci/gfx/gfx_res_options.cpp b/engines/sci/gfx/gfx_res_options.cpp index 76f488f45e..f665b50141 100644 --- a/engines/sci/gfx/gfx_res_options.cpp +++ b/engines/sci/gfx/gfx_res_options.cpp @@ -23,9 +23,9 @@ * */ -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_options.h" -#include "sci/include/gfx_resmgr.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_options.h" +#include "sci/gfx/gfx_resmgr.h" #include diff --git a/engines/sci/gfx/gfx_res_options.h b/engines/sci/gfx/gfx_res_options.h new file mode 100644 index 0000000000..6532cb456f --- /dev/null +++ b/engines/sci/gfx/gfx_res_options.h @@ -0,0 +1,110 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Configuration options for per-resource customisations */ + +#ifndef _GFX_RES_OPTIONS_H_ +#define _GFX_RES_OPTIONS_H_ + +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_resmgr.h" + +namespace Sci { + +struct gfx_res_pattern_t { + int min, max; +}; + +/* GFX resource assignments */ + +typedef struct { + short type; /* GFX_RES_ASSIGN_TYPE_* */ + + union { + struct { + int colors_nr; + gfx_pixmap_color_t *colors; + } palette; + } assign; +} gfx_res_assign_t; + + +/* GFX resource modifications */ + +#define GFX_RES_MULTIPLY_FIXED 0 /* Linear palette update */ + +typedef struct { + short type; /* GFX_RES_ASSIGN_TYPE_* */ + + union { + byte factor[3]; /* divide by 16 to retrieve factor */ + } mod; +} gfx_res_mod_t; + + +typedef struct _gfx_res_conf { + int type; /* Resource type-- only one allowed */ + + /* If any of the following is 0, it means that there is no restriction. + ** Otherwise, one of the patterns associated with them must match. */ + int patterns_nr; /* Number of patterns (only 'view' patterns for views) */ + int loops_nr, cels_nr; /* Number of loop/cel patterns, for views only. + ** For pics, loops_nr identifies the palette. */ + + gfx_res_pattern_t *patterns; + + union { + gfx_res_assign_t assign; + gfx_res_mod_t mod; + } conf; /* The actual configuration */ + + struct _gfx_res_conf *next; +} gfx_res_conf_t; + + +typedef gfx_res_conf_t *gfx_res_conf_p_t; + +typedef struct { + gfx_res_conf_p_t assign[GFX_RESOURCE_TYPES_NR]; + gfx_res_conf_p_t mod[GFX_RESOURCE_TYPES_NR]; +} gfx_res_fullconf_t; + + +struct _gfx_options; + +int gfx_get_res_config(struct _gfx_options *options, + gfx_pixmap_t *pxm); +/* Configures a graphical pixmap according to config options +** Parameters: (gfx_options_t *) options: The options according to which +** configuration should be performed +** (gfx_resource_type_t) pxm: The pixmap to configure +** Returns : (int) 0 on success, non-zero otherwise +** Modifies pxm as considered appropriate by configuration options. Does +** not do anything in colour index mode. +*/ + +} // End of namespace Sci + +#endif /* !_GFX_RES_OPTIONS_H_ */ diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h new file mode 100644 index 0000000000..04455451f9 --- /dev/null +++ b/engines/sci/gfx/gfx_resmgr.h @@ -0,0 +1,338 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _GFX_RESMGR_H_ +#define _GFX_RESMGR_H_ + +// FIXME/TODO: The name "(Graphics) resource manager", and the associated +// filenames, are misleading. This should be renamed to "Graphics manager" +// or something like that. + +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/sbtree.h" + +namespace Sci { + +typedef enum { + GFX_RESOURCE_TYPE_VIEW = 0, + GFX_RESOURCE_TYPE_PIC, + GFX_RESOURCE_TYPE_FONT, + GFX_RESOURCE_TYPE_CURSOR, + GFX_RESOURCE_TYPE_PALETTE, + /* FIXME: Add PAL resource */ + + GFX_RESOURCE_TYPES_NR /* Number of resource types that are to be supported */ +} gfx_resource_type_t; + +#define GFX_RESOURCE_TYPE_0 GFX_RESOURCE_TYPE_VIEW + +#define GFXR_RES_ID(type, index) ((type) << 16 | (index)) +#define GFXR_RES_TYPE(id) (id >> 16) +#define GFXR_RES_NR(id) (id & 0xffff) + + +struct gfx_resource_t { + int ID; /* Resource ID */ + int lock_sequence_nr; /* See description of lock_counter in gfx_resstate_t */ + int mode; /* A mode type hash */ + + union { + gfx_pixmap_t *pointer; + gfxr_view_t *view; + gfx_bitmap_font_t *font; + gfxr_pic_t *pic; + } scaled_data; + + union { + gfx_pixmap_t *pointer; + gfxr_view_t *view; + gfx_bitmap_font_t *font; + gfxr_pic_t *pic; + } unscaled_data; + +}; + + +struct _gfx_options; + +typedef struct { + int version; /* Interpreter version */ + struct _gfx_options *options; + gfx_driver_t *driver; + gfx_pixmap_color_t *static_palette; + int static_palette_entries; + int lock_counter; /* Global lock counter; increased for each new resource allocated. + ** The newly allocated resource will then be assigned the new value + ** of the lock_counter, as will any resources referenced afterwards. + */ + int tag_lock_counter; /* lock counter value at tag time */ + + sbtree_t *resource_trees[GFX_RESOURCE_TYPES_NR]; + void *misc_payload; +} gfx_resstate_t; + + + +gfx_resstate_t *gfxr_new_resource_manager(int version, struct _gfx_options *options, + gfx_driver_t *driver, void *misc_payload); +/* Allocates and initializes a new resource manager +** Parameters: (int) version: Interpreter version +** (gfx_options_t *): Pointer to all relevant drawing options +** (gfx_driver_t *): The graphics driver (needed for capability flags and the mode +** structure) +** (void *) misc_payload: Additional information for the interpreter's +** resource loaders +** Returns : (gfx_resstate_t *): A newly allocated resource manager +** The options are considered to be read-only, as they belong to the overlying state object. +*/ + +void gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state); +/* Frees a previously allocated resource manager, and all allocated resources. +** Parameters: (gfx_driver_t *) driver: The graphics driver; used to free pixmaps that +** are installed in a driver-specific registry +** (gfx_resstate_t *) state: The state manager to free +** Return : (void) +*/ + +void gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state); +/* Frees all resources currently allocated +** Parameter: (gfx_driver_t *) driver: The driver to free with +** (gfx_resstate_t *) state: The state to do this on +** Returns : (void) +** This function is intended to be used primarily for debugging. +*/ + +void gfxr_tag_resources(gfx_resstate_t *state); +/* 'Tags' all resources for deletion +** Paramters: (gfx_resstate_t *) state: The resource state to modify +** Returns : (void) +** Tagged resources are untagged if they are referenced. +*/ + +void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state); +/* Frees all tagged resources. +** Parameters: (gfx_driver_t *) driver: The graphics driver the pixmaps are potentially +** registered in +** (gfx_resstate_t *) state: The state to alter +** Returns : (void) +** Resources are tagged by calling gfx_tag_resources(), and untagged by calling the +** approprate dereferenciation function. +** Note that this function currently only affects view resources, as pic resources are +** treated differently, while font and cursor resources are relatively rare. +*/ + + +gfxr_pic_t *gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, + int default_palette, int scaled); +/* Retreives a displayable (translated) pic resource +** Parameters: (gfx_resstate_t *) state: The resource state +** (int) nr: Number of the pic resource +** (int) maps: The maps to translate (ORred GFX_MASK_*) +** (int) flags: Interpreter-dependant pic flags +** (int) default_palette: The default palette to use for drawing (if applicable) +** (int) scaled: Whether to return the scaled maps, or the unscaled +** ones (which may be identical) for some special operations. +** Returns : (gfx_pic_t *) The appropriate pic resource with all maps as index (but not +** neccessarily translated) data. +*/ + +gfxr_pic_t *gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int maps, int flags, + int old_default_palette, int default_palette, int scaled); +/* Retreives a displayable (translated) pic resource written ontop of an existing pic +** Parameters: (gfx_resstate_t *) state: The resource state +** (int) old_nr: Number of the pic resource to write on +** (int) new_nr: Number of the pic resource that is to be added +** (int) maps: The maps to translate (ORred GFX_MASK_*) +** (int) flags: Interpreter-dependant pic flags +** (int) default_palette: The default palette to use for drawing (if applicable) +** (int) scaled: Whether to return the scaled maps, or the unscaled +** ones (which may be identical) for some special operations. +** Returns : (gfx_pic_t *) The appropriate pic resource with all maps as index (but not +** neccessarily translated) data. +** This function invalidates the cached pic pointed to by old_nr in the cache. While subsequent +** gfxr_add_to_pic() writes will still modify the 'invalidated' pic, gfxr_get_pic() operations will +** cause it to be removed from the cache and to be replaced by a clean version. +*/ + +gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, int palette); +/* Retreives a translated view cel +** Parameters: (gfx_resstate_t *) state: The resource state +** (int) nr: The view number +** (int *) loop: Pointer to a variable containing the loop number +** (int *) cel: Pointer to a variable containing the cel number +** (int) palette: The palette to use +** Returns : (gfx_view_t *) The relevant view, or NULL if nr was invalid +** loop and cel are given as pointers in order to allow the underlying variables to be +** modified if they are invalid (this is relevant for SCI version 0, where invalid +** loop and cel numbers have to be interpreted as 'maximum' or 'minimum' by the interpreter) +*/ + +gfx_bitmap_font_t *gfxr_get_font(gfx_resstate_t *state, int nr, int scaled); +/* Retreives a font +** Parameters: (gfx_resstate_t *) state: The relevant resource state +** (int) nr: The font number +** (int) scaled: Whether the font should be font-scaled +** Returns : (gfx_font_t *) The appropriate font, or NULL on error +*/ + +gfx_pixmap_t *gfxr_get_cursor(gfx_resstate_t *state, int nr); +/* Retreives an SCI0/SCI01 mouse cursor +** Parameters: (gfx_resstate_t *) state: The resource state +** (int) nr: The cursour number +** Returns : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error +*/ + +gfx_pixmap_color_t *gfxr_get_palette(gfx_resstate_t *state, int nr); +/* Retreives a palette +** Parameters: (gfx_resstate_t *) state: The resource state +** (int) nr: The cursour number +** Returns : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error +*/ + + +/* =========================== */ +/* Interpreter-dependant stuff */ +/* =========================== */ + + +int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, + struct _gfx_options *options, void *internal, int palette); +/* Calculates a unique hash value for the specified options/type setup +** Parameters: (gfx_resource_type_t) type: The type the hash is to be generated for +** (int) version: The interpreter type and version +** (gfx_options_t *) options: The options to hashify +** (void *) internal: Internal information provided by the interpreter +** (int) palette: The palette to use (FIXME: should this be here?) +** Returns : (int) A hash over the values of the options entries, covering entries iff +** they are relevant for the specified type +** Covering more entries than relevant may slow down the system when options are changed, +** while covering less may result in invalid cached data being used. +** Only positive values may be returned, as negative values are used internally by the generic +** resource manager code. +** Also, only the lower 20 bits are available to the interpreter. +** (Yes, this isn't really a "hash" in the traditional sense...) +*/ + +int *gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, + int version, int *entries_nr, void *internal); +/* Retreives all resources of a specified type that are available from the interpreter +** Parameters: (gfx_resstate_t *) state: The relevant resource state +** (gfx_respirce_type_t) type: The resource type to query +** (int) version: The interpreter type and version +** (int *) entries_nr: The variable the number of entries will eventually be stored in +** (void *) internal: Internal information provided by the interpreter +** Returns : (int *) An array of resource numbers +** Unsupported/non-existing resources should return NULL here; this is equivalent to supported +** resources of which zero are available. +** The returned structure (if non-zero) must be freed by the querying code (the resource manager). +*/ + +gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal); +/* Initializes a pic +** Parameters: (int) version: Interpreter version to use +** (gfx_mode_t *) mode: The graphics mode the pic will be using +** (int) ID: The ID to assign to the gfxr_pic_t structure +** (void *) internal: Internal information provided by the interpreter +** Returns : (gfxr_pic_t *) A newly allocated pic +** This function is typically called befode gfxr_interpreter_clear_pic(). +** Must remember to initialize 'internal' to NULL or a malloc()'d area. +*/ + +void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal); +/* Clears a previously allocated pic +** Parameters: (int) version: Interpreter version +** (gfxr_pic_t *) pic: The pic to clear +** (void *) internal: Internal information provided by the interpreter +** Returns : (void) +** This function is called in preparation for the pic to be drawn with gfxr_interpreter_calculate_pic. +*/ + +int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, + int flags, int default_palette, int nr, void *internal); +/* Instructs the interpreter-specific code to calculate a picture +** Parameters: (gfx_resstate_t *) state: The resource state, containing options and version information +** (gfxr_pic_t *) scaled_pic: The pic structure that is to be written to +** (gfxr_pic_t *) unscaled_pic: The pic structure the unscaled pic is to be written to, +** or NULL if it isn't needed. +** (int) flags: Pic drawing flags (interpreter dependant) +** (int) default_palette: The default palette to use for pic drawing (interpreter dependant) +** (int) nr: pic resource number +** (void *) internal: Internal information provided by the interpreter +** Returns : (int) GFX_ERROR if the resource could not be found, GFX_OK otherwise +*/ + +gfxr_view_t *gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette); +/* Instructs the interpreter-specific code to calculate a view +** Parameters: (gfx_resstate_t *) state: The resource manager state +** (int) nr: The view resource number +** (void *) internal: Internal information provided by the interpreter +** Returns : (gfx_view_t *) The appropriate view, or NULL on error +*/ + +gfx_bitmap_font_t *gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal); +/* Instructs the interpreter-specific code to calculate a font +** Parameters: (gfx_resstate_t *) state: The resource manager state +** (int) nr: The font resource number +** (void *) internal: Internal information provided by the interpreter +** Returns : (gfx_font_t *) The newly calculated font, or NULL on error +*/ + +gfx_pixmap_t *gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal); +/* Instructs the interpreter-specific code to calculate a cursor +** Paramaters: (gfx_resstate_t *) state: The resource manager state +** (int nr): The cursor resource number +** (void *) internal: Internal information provided by the interpreter +** Returns : (gfx_pixmap_t *) The cursor pixmap, or NULL on error +*/ + +gfx_pixmap_color_t *gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal); +/* Retreives the static palette from the interpreter-specific code +** Parameters: (int) version: Interpreter version to use +** (int *) colors_nr: Number of colors to use +** (void *) internal: Internal information provided by the interpreter +** Returns : (gfx_pixmap_color_t *) *colors_nr static color entries +** if a static palette must be used, NULL otherwise +*/ + +gfx_pixmap_color_t *gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr); +/* Retreives the static palette from the interpreter-specific code +** Parameters: (int) version: Interpreter version to use +** (int *) colors_nr: Number of colors to use +** (void *) internal: Internal information provided by the interpreter +** Returns : (gfx_pixmap_color_t *) *colors_nr static color entries +** if a static palette must be used, NULL otherwise +*/ + +int gfxr_interpreter_needs_multicolored_pointers(int version, void *internal); +/* Determines whether support for pointers with more than two colors is required +** Parameters: (int) version: Interpreter version to test for +** (void *) internal: Internal information provided by the interpreter +** Returns : (int) 0 if no support for multi-colored pointers is required, non-0 +** otherwise +*/ + +} // End of namespace Sci + +#endif /* !_GFX_RSMGR_H_ */ diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp index 74c8f905f2..678f74ce83 100644 --- a/engines/sci/gfx/gfx_resource.cpp +++ b/engines/sci/gfx/gfx_resource.cpp @@ -23,9 +23,9 @@ * */ -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h new file mode 100644 index 0000000000..2ad69b821d --- /dev/null +++ b/engines/sci/gfx/gfx_resource.h @@ -0,0 +1,414 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* SCI Resource library */ + +#ifndef _GFX_RESOURCE_H_ +#define _GFX_RESOURCE_H_ + +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_driver.h" + +namespace Sci { + +/*** Styles for pic0 drawing ***/ +/* Dithering modes */ +#define GFXR_DITHER_MODE_D16 0 /* Sierra SCI style */ +#define GFXR_DITHER_MODE_F256 1 /* Flat color interpolation */ +#define GFXR_DITHER_MODE_D256 2 /* 256 color dithering */ +/* Dithering patterns */ +#define GFXR_DITHER_PATTERN_SCALED 0 /* Dither per pixel on the 320x200 grid */ +#define GFXR_DITHER_PATTERN_1 1 /* Dither per pixel on the target */ + +#define SCI_TITLEBAR_SIZE 10 + +#define DRAWPIC01_FLAG_FILL_NORMALLY 1 +#define DRAWPIC01_FLAG_OVERLAID_PIC 2 + +#define GFXR_AUX_MAP_SIZE (320*200) + + +#define GFX_SCI0_IMAGE_COLORS_NR 16 +#define GFX_SCI0_PIC_COLORS_NR 256 + +#define GFX_SCI1_AMIGA_COLORS_NR 32 + +extern int sci0_palette; + +/* (gfx_pic_0.c) The 16 EGA base colors */ +extern gfx_pixmap_color_t gfx_sci0_image_colors[][16]; + +/* (gfx_pic_0.c) The 256 interpolated colors (initialized when +** gfxr_init_pic() is called for the first time, or when gfxr_init_static_palette() is called) +*/ +extern gfx_pixmap_color_t gfx_sci0_pic_colors[]; + + +typedef struct { + gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */ + gfx_brush_mode_t brush_mode; + rect_t pic_port_bounds; +} gfxr_pic0_params_t; + +typedef struct { + int ID; /* pic number (NOT resource ID, just number) */ + gfx_mode_t *mode; + gfx_pixmap_t *visual_map; + gfx_pixmap_t *priority_map; + gfx_pixmap_t *control_map; + + byte aux_map[GFXR_AUX_MAP_SIZE]; + + /* Auxiliary map details: + ** Bit 0: Vis + ** Bit 1: Pri + ** Bit 2: Ctrl + ** Bit 3-5: 'filled' (all three bits are set to 1) + */ + + rect_t bounds; + + void *undithered_buffer; /* copies visual_map->index_data before dithering */ + int undithered_buffer_size; + + void *internal; /* Interpreter information, or NULL. Will be freed + ** automatically when the pic is freed! */ + +} gfxr_pic_t; + + +typedef struct { + int cels_nr; + gfx_pixmap_t **cels; +} gfxr_loop_t; + + +typedef struct { + int ID; + + int flags; + int colors_nr; + gfx_pixmap_color_t *colors; + + int loops_nr; + gfxr_loop_t *loops; + + int translation[GFX_SCI0_IMAGE_COLORS_NR]; +} gfxr_view_t; + + +typedef enum { + GFXR_FONT_SCALE_FILTER_NONE +} gfxr_font_scale_filter_t; + + +typedef struct { + const char *offset; + int length; +} text_fragment_t; + +/* unscaled color index mode: Used in addition to a scaled mode +** to render the pic resource twice. See gfxr_remove_artifacts_pic0(). +*/ +extern gfx_mode_t mode_1x1_color_index; + +void gfxr_init_static_palette(); +/* Initializes the static 256 color palette +** Parameters: (void) +** Returns : (void) +*/ + +gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1); +/* Initializes a gfxr_pic_t for a specific mode +** Parameters: (gfx_mode_t *) mode: The specific graphics mode +** (int) ID: The ID to assign to the resulting pixmaps +** Returns : (gfxr_pic_t *) The allocated pic resource, or NULL on error. +** This function allocates memory for use by resource drawer functions. +*/ + +void gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic); +/* Uninitializes a pic resource +** Parameters: (gfx_driver_t *) driver: The driver the pic should be removed from +** (gfxr_pic_t *) pic: The pic to free +** Returns : (void) +*/ + +void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view); +/* Frees all memory associated with a view +** Paremeters: (gfx_driver_t *) driver: The driver the view should be removed from +** (gfxr_view_t *) view: The view to free +** Returns : (void) +*/ + + +/*******************/ +/* Font operations */ +/*******************/ +/* SCI0, SCI01 and SCI1 all use the same font format. */ + +/* SQ3 uses a somewhat different scheme for calculating text sizes: it counts +** whitespace while calculating the text size. */ +#define GFXR_FONT_FLAG_COUNT_WHITESPACE (1<<0) +/* Don't give newline characters special semantics */ +#define GFXR_FONT_FLAG_NO_NEWLINES (1<<1) +/* Interpret CR LF sequences as a single newline, rather than two of them */ +#define GFXR_FONT_FLAG_EAT_TRAILING_LF (1<<2) + + +gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size); +/* Geneartes a bitmap font data structure from a resource +** Parameters: (int) id: Resource ID of the resulting font +** (byte *) resource: Pointer to the resource data +** (int) size: Size of the resource block +** Returns : (gfx_bitmap_font_t *) The resulting font structure, or +** NULL on error +*/ + +void gfxr_free_font(gfx_bitmap_font_t *font); +/* Frees a previously allocated font structure +** Parameters: (gfx_bitmap_font_t *) font: The font to free +** Returns : (void) +*/ + +gfx_bitmap_font_t *gfxr_scale_font(gfx_bitmap_font_t *font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter); +/* Scales a font resource +** Parameters: (gfx_bitmap_font_t *) font: The font to scale +** (gfx_mode_t *) mode: The graphics mode to scale it for +** (gfxr_font_scale_filter_t) filter: A filter to use +** Returns : (gfx_bitmap_font_t *) A scaled font, or NULL on error +*/ + +text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text, + int *width, int *height, + int *lines, int *line_height, int *last_offset, + int flags); +/* Calculates the size that would be occupied by drawing a specified text +** Parameters: (gfx_bitmap_font_t *) font: The font to calculate with +** (int) max_width: Maximum pixel width allowed for the output +** (const char *) text: The text to calculate for +** (int) flags: Any text formatting flags +** Returns : (text_fragment *) a newly allocated array of text_fragments, +** containing the start and size of each string +** segment +** (int) *width: The resulting width +** (int) *height: The resulting height +** (int) *lines: Number of lines used +** (int) *line_height: Pixel height of a single line of text +** (int) *last_offset: Pixel offset after the last drawn line +** This function assumes 320x200 mode. +*/ + +gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *text, int characters, + gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg); +/* Draws text in a specific font to a pixmap +** Parameters: (gfx_bitmap_font_t *) font: The font to use for drawing +** (char *) text: The start of the text to draw +** (int) characters: The number of characters to draw +** (gfx_pixmap_color_t *) fg0: The first foreground color +** (gfx_pixmap_color_t *) fg1: The second foreground color +** (gfx_pixmap_color_t *) bg: The background color +** Returns : (gfx_pixmap_t *) The result pixmap, or NULL on error +** The results are written to the pixmap's index buffer. Contents of the +** foreground and background fields are copied into a newly allocated font +** structure, so that the pixmap may be translated directly. +** If any of the colors is null, it will be assumed to be transparent. +** In color index mode, the specified colors have to be preallocated. +*/ + + +/*********************/ +/* SCI0 operations */ +/*********************/ + + +void gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size); +/* Clears all pic buffers of one pic +** Parameters: (gfxr_pic_t) pic: The picture to clear +** (int) sci_titlebar_size: How much space to reserve for the title bar +** Returns : (void) +** This function should be called before gfxr_draw_pic0, unless cumulative +** drawing is intended +*/ + + +void gfxr_draw_pic01(gfxr_pic_t *pic, int fill_normally, int default_palette, + int size, byte *resource, gfxr_pic0_params_t *style, int resid, int sci1, + gfx_pixmap_color_t *static_pal, int static_pal_nr); +/* Draws a pic resource (all formats prior to SCI1.1) +** Parameters: (gfxr_pic_t *) pic: The pic to draw to +** (int) fill_normally: If 1, the pic is drawn normally; if 0, all +** fill operations will fill with black +** (int) default_palette: The default palette to use for drawing +** (int) size: Resource size +** (byte *) resource: Pointer to the resource data +** (gfxr_pic0_params_t *) style: The drawing style +** (int) resid: The resource ID +** (int) sci1: Nonzero if SCI1 +** (gfx_pixmap_color_t *) static_pal: The static palette +** (int) static_pal_nr: Number of entries in static palette +** Returns : (void) +** The result is stored in gfxr_visual_map, gfxr_priority_map, and gfxr_control_map. +** The palette entry of gfxr_visual_map is never used. +** Note that the picture will not be drawn dithered; use gfxr_dither_pic0 for that. +*/ + +void gfxr_draw_pic11(gfxr_pic_t *pic, int fill_normally, int default_palette, + int size, byte *resource, gfxr_pic0_params_t *style, int resid, + gfx_pixmap_color_t *static_pal, int static_pal_nr); +/* Draws a pic resource (SCI1.1) +** Parameters: (gfxr_pic_t *) pic: The pic to draw to +** (int) fill_normally: If 1, the pic is drawn normally; if 0, all +** fill operations will fill with black +** (int) default_palette: The default palette to use for drawing +** (int) size: Resource size +** (byte *) resource: Pointer to the resource data +** (gfxr_pic0_params_t *) style: The drawing style +** (int) resid: The resource ID +** (gfx_pixmap_color_t *) static_pal: The static palette +** (int) static_pal_nr: Number of entries in static palette +** Returns : (void) +** The result is stored in gfxr_visual_map, gfxr_priority_map, and gfxr_control_map. +** The palette entry of gfxr_visual_map is never used. +** Note that the picture will not be drawn dithered; use gfxr_dither_pic0 for that. +*/ + +void gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src); +/* Removes artifacts from a scaled pic +** Parameters: (gfxr_pic_t *) dest: The scaled pic +** (gfxr_pic_t *) src: An unscaled pic +** Returns : (void) +** Using information from the (correctly rendered) src pic, this function implements +** some heuristics to remove artifacts from dest. Must be used before dither_pic0 is +** called, because it operates on the index buffer. +*/ + +void gfxr_dither_pic0(gfxr_pic_t *pic, int mode, int pattern); +/* Dithers a gfxr_visual_map +** Parameters: (gfxr_pic_t *) pic: The pic to dither +** (int) mode: One of GFXR_DITHER_MODE +** (int) pattern: One of GFXR_DITHER_PATTERN +** Returns : (void) +*/ + +gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette); +/* Calculates an SCI0 view +** Parameters: (int) id: Resource ID of the view +** (byte *) resource: Pointer to the resource to read +** (int) size: Size of the resource +** (int) palette: The palette to use +** Returns : (gfxr_view_t *) The resulting view +*/ + +gfx_pixmap_t *gfxr_draw_cursor0(int id, byte *resource, int size); +/* Calculates an SCI0 cursor +** Parameters: (int) id: The cursor's resource ID +** (byte *) resource: Pointer to the resource data +** (int) size: Resource size +** Returns : (gfx_pixmap_t *) A newly allocated pixmap storing the cursor +*/ + +/**********************/ +/* SCI01 operations */ +/**********************/ + +gfx_pixmap_t *gfxr_draw_cursor01(int id, byte *resource, int size); +/* Calculates an SCI01 cursor +** Parameters: (int) id: The cursor's resource ID +** (byte *) resource: Pointer to the resource data +** (int) size: Resource size +** Returns : (gfx_pixmap_t *) A newly allocated pixmap containing an index +** color representation of the cursor +*/ + + +/*********************/ +/* SCI1 operations */ +/*********************/ + +gfx_pixmap_color_t *gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size); +/* Reads an SCI1 palette +** Parameters: (int) id: Resource ID for the palette (or the view it was found in) +** (int *) colors_nr: Pointer to the variable the number of colors +** will be stored in +** (byte *) resource: Source data +** (int) size: Size of the memory block pointed to by resource +** Returns : (gfx_pixmap_color_t *) *colors_nr color_t entries with the colors +*/ + +gfx_pixmap_color_t *gfxr_read_pal1_amiga(int *colors_nr, FILE *f); +/* Reads an SCI1 palette +** Parameters: (int *) colors_nr: Pointer to the variable the number of colors +** will be stored in +** (FILE *) f: Palette file +** Returns : (gfx_pixmap_color_t *) *colors_nr color_t entries with the colors +*/ + +gfx_pixmap_color_t *gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size); +/* Reads an SCI1.1 palette +** Parameters: (int) id: Resource ID for the palette (or the view it was found in) +** (int *) colors_nr: Pointer to the variable the number of colors +** will be stored in +** (byte *) resource: Source data +** (int) size: Size of the memory block pointed to by resource +** Returns : (gfx_pixmap_color_t *) *colors_nr color_t entries with the colors +*/ + +gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal, + int static_pal_nr); +/* Calculates an SCI1 view +** Parameters: (int) id: Resource ID of the view +** (byte *) resource: Pointer to the resource to read +** (int) size: Size of the resource +** (gfx_pixmap_color_t *) static_pal: The static palette +** (int) static_pal_nr: Number of entries in static palette +** Returns : (gfxr_view_t *) The resulting view +*/ + +gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view); + + +gfx_pixmap_t *gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode); +/* Endianness-adjusts a pixmap, if neccessary +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to adjust +** (gfx_mode_t *) mode: The mode to adjust it for +** Returns : (gfx_pixmap_t *) pixmap, or NULL on error +** The pixmap is adjusted iff the mode signals that this is +** required (by means of setting the appropriate flag), and +** the mode has a byte depth of more than 1. +*/ + + +static inline int get_uint_16(const byte *offset) { + return ((unsigned int) offset[0] | (((unsigned int) offset[1]) << 8)); +} + +static inline int get_int_16(const byte *offset) { + return ((int) offset[0] | (((int) offset[1]) << 8)); +} + +} // End of namespace Sci + +#endif /* !_GFX_RESOURCE_H_ */ + diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h new file mode 100644 index 0000000000..871a618303 --- /dev/null +++ b/engines/sci/gfx/gfx_state_internal.h @@ -0,0 +1,239 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _GFX_STATE_INTERNAL_H_ +#define _GFX_STATE_INTERNAL_H_ + +#include "sci/gfx/gfx_tools.h" +#include "sci/gfx/gfx_options.h" +#include "sci/gfx/gfx_operations.h" +#include "sci/gfx/gfx_resmgr.h" +#include "sci/gfx/gfx_system.h" + +namespace Sci { + +#define GFXW_FLAG_VISIBLE (1<<0) +#define GFXW_FLAG_OPAQUE (1<<1) +#define GFXW_FLAG_CONTAINER (1<<2) +#define GFXW_FLAG_DIRTY (1<<3) +#define GFXW_FLAG_TAGGED (1<<4) +#define GFXW_FLAG_MULTI_ID (1<<5) /* Means that the ID used herein may be used more than once, i.e. is not unique */ +#define GFXW_FLAG_IMMUNE_TO_SNAPSHOTS (1<<6) /* Snapshot restoring doesn't kill this widget, and +5 bonus to saving throws vs. Death Magic */ +#define GFXW_FLAG_NO_IMPLICIT_SWITCH (1<<7) /* Ports: Don't implicitly switch to this port when disposing windows */ + +typedef struct { + int serial; /* The first serial number to kill */ + rect_t area; +} gfxw_snapshot_t; + +typedef enum { + GFXW_, /* Base widget */ + + GFXW_BOX, + GFXW_RECT, + GFXW_LINE, /* For lines, the bounding rectangle's xl, yl determine the line's expansion: + ** (x2, y2) = (x+xl, y+yl) */ + GFXW_INVERSE_LINE, + GFXW_VIEW, + GFXW_STATIC_VIEW, + GFXW_DYN_VIEW, + GFXW_PIC_VIEW, + GFXW_TEXT, + + GFXW_CONTAINER, + + GFXW_LIST, + GFXW_SORTED_LIST, + GFXW_VISUAL, + GFXW_PORT + +} gfxw_widget_type_t; + + +#define GFXW_MAGIC_VALID 0xC001 +#define GFXW_MAGIC_INVALID 0xbad + +#define GFXW_NO_ID -1 + +struct _gfxw_widget; +struct _gfxw_container_widget; +struct _gfxw_visual; + +typedef int gfxw_point_op(struct _gfxw_widget *, Common::Point); +typedef int gfxw_visual_op(struct _gfxw_widget *, struct _gfxw_visual *); +typedef int gfxw_op(struct _gfxw_widget *); +typedef int gfxw_op_int(struct _gfxw_widget *, int); +typedef int gfxw_bin_op(struct _gfxw_widget *, struct _gfxw_widget *); + +#define WIDGET_COMMON \ + int magic; /* Extra check after typecasting */ \ + int serial; /* Serial number */ \ + int flags; /* Widget flags */ \ + gfxw_widget_type_t type; \ + rect_t bounds; /* Boundaries */ \ + struct _gfxw_widget *next; /* Next widget in widget list */ \ + int ID; /* Unique ID or GFXW_NO_ID */ \ + int subID; /* A 'sub-ID', or GFXW_NO_ID */ \ + struct _gfxw_container_widget *parent; /* The parent widget, or NULL if not owned */ \ + struct _gfxw_visual *visual; /* The owner visual */ \ + int widget_priority; /* Drawing priority, or -1 */ \ + gfxw_point_op *draw; /* Draw widget (if dirty) and anything else required for the display to be consistant */ \ + gfxw_op *widfree; /* Remove widget (and any sub-widgets it may contain) */ \ + gfxw_op *tag; /* Tag the specified widget */ \ + gfxw_op_int *print; /* Prints the widget's contents, using sciprintf. Second parameter is indentation. */ \ + gfxw_bin_op *compare_to; /* a.compare_to(a, b) returns <0 if a0 if a>b */ \ + gfxw_bin_op *equals; /* a equals b if both cause the same data to be displayed */ \ + gfxw_bin_op *should_replace; /* (only if a equals b) Whether b should replace a even though they are equivalent */ \ + gfxw_bin_op *superarea_of; /* a superarea_of b <=> for each pixel of b there exists an opaque pixel in a at the same location */ \ + gfxw_visual_op *set_visual /* Sets the visual the widget belongs to */ + +typedef struct _gfxw_widget { + WIDGET_COMMON; +} gfxw_widget_t; + + +#define GFXW_IS_BOX(widget) ((widget)->type == GFXW_BOX) +typedef struct { + WIDGET_COMMON; + gfx_color_t color1, color2; + gfx_box_shade_t shade_type; +} gfxw_box_t; + + +#define GFXW_IS_PRIMITIVE(widget) ((widget)->type == GFXW_RECT || (widget)->type == GFXW_LINE || (widget->type == GFXW_INVERSE_LINE)) +typedef struct { + WIDGET_COMMON; + gfx_color_t color; + gfx_line_mode_t line_mode; + gfx_line_style_t line_style; +} gfxw_primitive_t; + + + +#define VIEW_COMMON \ + WIDGET_COMMON; \ + Common::Point pos; /* Implies the value of 'bounds' in WIDGET_COMMON */ \ + gfx_color_t color; \ + int view, loop, cel; \ + int palette + +#define GFXW_IS_VIEW(widget) ((widget)->type == GFXW_VIEW || (widget)->type == GFXW_STATIC_VIEW \ + || (widget)->type == GFXW_DYN_VIEW || (widget)->type == GFXW_PIC_VIEW) +typedef struct { + VIEW_COMMON; +} gfxw_view_t; + +#define GFXW_IS_DYN_VIEW(widget) ((widget)->type == GFXW_DYN_VIEW || (widget)->type == GFXW_PIC_VIEW) +typedef struct { + VIEW_COMMON; + /* fixme: This code is specific to SCI */ + rect_t draw_bounds; /* The correct position to draw to */ + void *under_bitsp, *signalp; + int under_bits, signal; + int z; /* The z coordinate: Added to y, but used for sorting */ + int sequence; /* Sequence number: For sorting */ + int force_precedence; /* Precedence enforcement variable for sorting- defaults to 0 */ +} gfxw_dyn_view_t; + + + +#define GFXW_IS_TEXT(widget) ((widget)->type == GFXW_TEXT) +typedef struct { + WIDGET_COMMON; + int font_nr; + int lines_nr, lineheight, lastline_width; + char *text; + gfx_alignment_t halign, valign; + gfx_color_t color1, color2, bgcolor; + int text_flags; + int width, height; /* Real text width and height */ + gfx_text_handle_t *text_handle; +} gfxw_text_t; + + +/* Container widgets */ + +typedef int gfxw_unary_container_op(struct _gfxw_container_widget *); +typedef int gfxw_container_op(struct _gfxw_container_widget *, gfxw_widget_t *); +typedef int gfxw_rect_op(struct _gfxw_container_widget *, rect_t, int); + +#define WIDGET_CONTAINER \ + WIDGET_COMMON; \ + rect_t zone; /* The writeable zone (absolute) for contained objects */ \ + gfx_dirty_rect_t *dirty; /* List of dirty rectangles */ \ + gfxw_widget_t *contents; \ + gfxw_widget_t **nextpp; /* Pointer to the 'next' pointer in the last entry in contents */ \ + gfxw_unary_container_op *free_tagged; /* Free all tagged contained widgets */ \ + gfxw_unary_container_op *free_contents; /* Free all contained widgets */ \ + gfxw_rect_op *add_dirty_abs; /* Add an absolute dirty rectangle */ \ + gfxw_rect_op *add_dirty_rel; /* Add a relative dirty rectangle */ \ + gfxw_container_op *add /* Append widget to an appropriate position (for view and control lists) */ + + +typedef struct _gfxw_container_widget { + WIDGET_CONTAINER; +} gfxw_container_t; + + +#define GFXW_IS_CONTAINER(widget) ((widget)->type == GFXW_PORT || (widget)->type == GFXW_VISUAL || \ + (widget)->type == GFXW_SORTED_LIST || (widget)->type == GFXW_LIST) + +#define GFXW_IS_LIST(widget) ((widget)->type == GFXW_LIST || (widget)->type == GFXW_SORTED_LIST) +#define GFXW_IS_SORTED_LIST(widget) ((widget)->type == GFXW_SORTED_LIST) +typedef gfxw_container_t gfxw_list_t; + +#define GFXW_IS_VISUAL(widget) ((widget)->type == GFXW_VISUAL) +typedef struct _gfxw_visual { + WIDGET_CONTAINER; + struct _gfxw_port **port_refs; /* References to ports */ + int port_refs_nr; + int font_nr; /* Default font */ + gfx_state_t *gfx_state; +} gfxw_visual_t; + +#define GFXW_IS_PORT(widget) ((widget)->type == GFXW_PORT) +typedef struct _gfxw_port { + WIDGET_CONTAINER; + + gfxw_list_t *decorations; /* optional window decorations- drawn before the contents */ + gfxw_widget_t *port_bg; /* Port background widget or NULL */ + gfx_color_t color, bgcolor; + int chrono_port; + int font_nr; + Common::Point draw_pos; /* Drawing position */ + gfxw_snapshot_t *restore_snap; /* Snapshot to be restored automagically, + experimental feature used in the PQ3 interpreter */ + int port_flags; /* interpreter-dependant flags */ + const char *title_text; + byte gray_text; /* Whether text is 'grayed out' (dithered) */ +} gfxw_port_t; + +#undef WIDGET_COMMON +#undef WIDGET_CONTAINER + +} // End of namespace Sci + +#endif /* !_GFX_STATE_INTERNAL_H_ */ + diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index e1b8004907..26acf988f5 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -27,8 +27,8 @@ ** for use with the graphical state manager */ -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_tools.h" #define DRAWLINE_FUNC _gfx_draw_line_buffer_1 #define PIXELWIDTH 1 diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h new file mode 100644 index 0000000000..6aa2b98d2b --- /dev/null +++ b/engines/sci/gfx/gfx_system.h @@ -0,0 +1,395 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _SCI_GFX_SYSTEM_ +#define _SCI_GFX_SYSTEM_ + +#include "common/scummsys.h" +#include "common/rect.h" +#include "sci/include/sci_memory.h" +#include "sci/tools.h" + +namespace Sci { + +#define GFX_DEBUG + +/* General output macros */ +# define GFXERROR gfxprintf("GFX Error: %s, L%d:", __FILE__, __LINE__); sciprintf +# define GFXWARN gfxprintf("GFX Warning: %s, L%d:", __FILE__, __LINE__); sciprintf +# ifdef GFX_DEBUG +# define GFXDEBUG gfxprintf("GFX-debug: %s, L%d:", __FILE__, __LINE__); sciprintf +# else /* !GFX_DEBUG */ +# define GFXDEBUG if (0) printf +# endif /* !GFX_DEBUG */ + +/***********************/ +/*** Data structures ***/ +/***********************/ + +#define GFX_COLOR_SYSTEM -1 + + +/** Palette color description */ +struct gfx_palette_color_t { + + int lockers; /* Number of pixmaps holding a lock on that color. + ** 0 means that the color is unused, -1 means that it is + ** "system allocated" and may not be freed. */ + byte r, g, b; /* Red, green, blue; intensity varies from 0 (min) to 255 (max) */ + +}; + +/** Palette description for color index modes */ +struct gfx_palette_t{ + + int max_colors_nr; /* Maximum number of allocated colors */ + gfx_palette_color_t *colors; /* Actual colors, malloc()d as a block */ +}; + + + +#define GFX_MODE_IS_UNSCALED(mode) (((mode)->xfact == 1) && ((mode)->yfact == 1)) + +/* Reverse-endian: Target display has non-native endianness +** (BE if local is LE or the other way 'round */ +#define GFX_MODE_FLAG_REVERSE_ENDIAN (1<<0) +/* Reverse Alpha: Alpha values 0 mean "transparent" if this is +** enabled */ +#define GFX_MODE_FLAG_REVERSE_ALPHA (1<<1) + +/** Graphics mode description */ +struct gfx_mode_t { + + int xfact, yfact; /* Horizontal and vertical scaling factors */ + int bytespp; /* Bytes per pixel */ + + unsigned int flags; /* GFX_MODE_FLAG_* Flags- see above */ + + + gfx_palette_t *palette; /* Palette or NULL to indicate non-palette mode. + ** Palette (color-index) mode is only supported + ** for bytespp=1. */ + + /* Color masks */ + unsigned int red_mask, green_mask, blue_mask, alpha_mask; + short red_shift, green_shift, blue_shift, alpha_shift; + + /* Each of the mask/shift pairs describe where the corresponding color + ** values are stored for the described mode. Internally, color + ** calculations are done by using 32 bit values for r, g, b, a. After + ** the internal values have been calculated, they are shifted RIGHT + ** by the xxx_shift amount described above, then ANDed with the + ** corresponding color mask; finally, all three results are ORred to- + ** gether. The alpha values are used as appropriate; if alpha_mask is + ** zero, then images use a special alpha map. */ + +}; + + + +#define GFX_COLOR_INDEX_UNMAPPED -1 + +/** Pixmap-specific color entries */ +struct gfx_pixmap_color_t{ + int global_index; /* Global index color or GFX_COLOR_INDEX_UNMAPPED. */ + guint8 r, g, b; /* Real color */ +}; + +/** Full color */ +struct gfx_color_t { + gfx_pixmap_color_t visual; + guint8 alpha; /* transparency = (1-opacity) */ + signed char priority, control; + byte mask; /* see mask values below */ +}; + + +/** Rectangle description */ +struct rect_t{ + int x, y; + int xl, yl; /* width, height: (x,y,xl,yl)=(5,5,1,1) occupies 1 pixel */ +}; + + +/* Generates a rect_t from index data +** Parameters: (int x int) x,y: Upper left point of the rectangle +** (int x int) xl, yl: Horizontal and vertical extension of the rectangle +** Returns : (rect_t) A rectangle matching the supplied parameters +*/ +static inline rect_t gfx_rect(int x, int y, int xl, int yl) { + rect_t rect; + + rect.x = x; + rect.y = y; + rect.xl = xl; + rect.yl = yl; + + return rect; +} + +#define GFX_PRINT_RECT(rect) (rect).x, (rect).y, (rect).xl, (rect).yl + +#define OVERLAP(a, b, z, zl) (a.z >= b.z && a.z < (b.z + b.zl)) + +/* Determines whether two rects overlap +** Parameters: (rect_t x rect_t) a,b: The two rect_ts to check for overlap +** Returns : (int) 1 if they overlap, 0 otherwise +*/ +static inline int gfx_rects_overlap(rect_t a, rect_t b) { + return (OVERLAP(a, b, x, xl) || OVERLAP(b, a, x, xl)) && (OVERLAP(a, b, y, yl) || OVERLAP(b, a, y, yl)); +} + +#undef OVERLAP + +#define MERGE_PARTIAL(z, zl) \ +if (a.z < b.z) SUBMERGE_PARTIAL(a, b, z, zl) \ +else SUBMERGE_PARTIAL(b, a, z, zl) + +#define SUBMERGE_PARTIAL(a, b, z, zl) \ +{ \ + retval.z = a.z; \ + retval.zl = a.zl; \ + if (b.z + b.zl > a.z + a.zl) \ + retval.zl = (b.z + b.zl - a.z); \ +} + + + +#define RECT(a) a.x, a.y, a.xl, a.yl + +/* Merges two rects +** Parameters: (rect_t x rect_t) a,b: The two rects to merge +** Returns : (rect_t) The smallest rect containing both a and b +*/ +static inline rect_t gfx_rects_merge(rect_t a, rect_t b) { + rect_t retval; + MERGE_PARTIAL(x, xl); + MERGE_PARTIAL(y, yl); + return retval; +} +#undef MERGE_PARTIAL +#undef SUBMERGE_PARTIAL + + +/* Subset predicate for rectangles +** Parameters: (rect_t) a, b: The two rects to compare +** Returns : non-zero iff for each pixel p in a the following holds: p is in b. +*/ +static inline int gfx_rect_subset(rect_t a, rect_t b) { + return ((a.x >= b.x) && (a.y >= b.y) && ((a.x + a.xl) <= (b.x + b.xl)) && ((a.y + a.yl) <= (b.y + b.yl))); +} + + +/* Equality predicate for rects +** Parameters: (rect_t) a, b +** Returns : (int) gfx_rect_subset(a,b) AND gfx_rect_subset(b,a) +*/ +static inline int gfx_rect_equals(rect_t a, rect_t b) { + return (a.x == b.x && a.xl == b.xl && a.y == b.y && a.yl == b.yl); +} + + +/* gfx_rect_fullscreen is declared in gfx/gfx_tools.c */ +extern rect_t gfx_rect_fullscreen; + +/* Translation operation for rects +** Parameters: (rect_t) rect: The rect to translate +** (Common::Point) offset: The offset to translate it by +** Returns : (rect_t) The translated rect +*/ +static inline rect_t gfx_rect_translate(rect_t rect, Common::Point offset) { + rect.x += offset.x; + rect.y += offset.y; + + return rect; +} + +#define GFX_RESID_NONE -1 + +#define GFX_PIC_COLORS 256 + +#define GFX_PIXMAP_FLAG_SCALED_INDEX (1<<0) /* Index data is scaled already */ +#define GFX_PIXMAP_FLAG_EXTERNAL_PALETTE (1<<1) /* The colors pointer points to an external palette */ +#define GFX_PIXMAP_FLAG_INSTALLED (1<<2) /* Pixmap has been registered */ +#define GFX_PIXMAP_FLAG_PALETTE_ALLOCATED (1<<3) /* Palette has been allocated */ +#define GFX_PIXMAP_FLAG_PALETTE_SET (1<<4) /* Palette has been propagated to the driver */ +#define GFX_PIXMAP_FLAG_DONT_UNALLOCATE_PALETTE (1<<5) /* Used by text, which uses preallocated colors */ +#define GFX_PIXMAP_FLAG_PALETTIZED (1<<6) /* Indicates a palettized view */ + +#define GFX_PIXMAP_COLOR_KEY_NONE -1 /* No transpacency colour key */ + +typedef struct { /* gfx_pixmap_t: Pixel map */ + + /*** Meta information ***/ + int ID; /* Resource ID, or GFX_RESID_NONE for anonymous graphical data */ + short loop, cel; /* loop and cel number for views */ + + + /*** Color map ***/ + int colors_nr; + gfx_pixmap_color_t *colors; /* colors_nr color entries, or NULL if the + ** default palette is to be used. + ** A maximum of 255 colors is allowed; color + ** index 0xff is reserved for transparency. + ** As a special exception, 256 colors are + ** allowed for background pictures (which do + ** not use transparency) + */ + unsigned int flags; + + /*** Hot spot ***/ + int xoffset, yoffset; /* x and y coordinates of the 'hot spot' (unscaled) */ + + /*** Index data ***/ + int index_xl, index_yl; /* width and height of the indexed original image */ + byte *index_data; /* Color-index data, or NULL if read from an + ** external source + */ + + /*** Drawable data ***/ + int xl, yl; /* width and height of the actual image */ + int data_size; /* Amount of allocated memory */ + byte *data; /* Drawable data, or NULL if not converted. */ + + byte *alpha_map; /* Byte map with alpha values. It is used only if the + ** graphics mode's alpha_mask is zero. + */ + + int color_key; + + /*** Data reserved for gfx_driver use ***/ + struct pixmap_internal { /* Internal state management data for use by drivers */ + int handle; /* initialized to 0 */ + void *info; /* initialized to NULL */ + } internal; + +} gfx_pixmap_t; + + +#define GFX_FONT_BUILTIN_5x8 -1 +#define GFX_FONT_BUILTIN_6x10 -2 + +typedef struct { /* gfx_bitmap_font_t: Bitmap font information */ + int ID; /* Unique resource ID */ + + int chars_nr; /* Numer of available characters */ + + int *widths; /* chars_nr character widths, in pixels */ + + int row_size; /* Byte size of each pixel row. For unscaled fonts, this is + ** always 1, 2, or 4. Otherwise, it's a multiple of 4. + */ + + int line_height; /* Height of each text line (usually identical to height) */ + int height; /* Height for all characters, in pixel rows */ + int char_size; /* Amount of memory occupied by one character in data */ + + byte *data; /* Font data, consisting of 'chars_nr' entries of 'height' rows + ** of 'row_size' bytes. For each character ch, its first byte + ** (the topmost row) is located at (data + (charsize * ch)), and + ** its pixel width is widths[ch], provided that (ch < chars_nr). + */ + +} gfx_bitmap_font_t; + + + +/***********************/ +/*** Constant values ***/ +/***********************/ + +/* Default palettes */ +extern gfx_pixmap_color_t gfx_sci0_image_colors[][16]; +extern gfx_pixmap_color_t gfx_sci0_pic_colors[256]; + +/* Return values */ +enum gfx_return_value_t { + GFX_OK = 0, /* Indicates "operation successful" */ + GFX_ERROR = -1, /* Indicates "operation failed" */ + GFX_FATAL = -2 + /* Fatal error: Used by graphics drivers to indicate that they were unable to + ** do anything useful + */ +}; + + +typedef enum {/* Map masks */ + GFX_MASK_NONE = 0, + GFX_MASK_VISUAL = 1, + GFX_MASK_PRIORITY = 2, + GFX_MASK_CONTROL = 4 +} gfx_map_mask_t; + +/* 'no priority' mode */ +#define GFX_NO_PRIORITY -1 + +/* Text alignment values */ + +typedef enum { + ALIGN_RIGHT = -1, + ALIGN_TOP = -1, + ALIGN_CENTER = 1, + ALIGN_LEFT = 0, + ALIGN_BOTTOM = 0 +} gfx_alignment_t; + + +typedef enum { + GFX_LINE_MODE_CORRECT, /* Scaled separately */ + GFX_LINE_MODE_FAST, /* Scaled by (xfact+yfact)/2 */ + GFX_LINE_MODE_FINE /* Always drawn at width 1 */ +} gfx_line_mode_t; + +typedef enum { + GFX_BRUSH_MODE_SCALED, /* Just scale the brush pixels */ + GFX_BRUSH_MODE_ELLIPSES, /* Replace pixels with ellipses */ + GFX_BRUSH_MODE_RANDOM_ELLIPSES, /* Replace pixels with ellipses moved and re-scaled randomly */ + GFX_BRUSH_MODE_MORERANDOM /* Distribute randomly */ +} gfx_brush_mode_t; + + +typedef enum { + GFX_LINE_STYLE_NORMAL, + GFX_LINE_STYLE_STIPPLED +} gfx_line_style_t; + + +typedef enum { + GFX_SHADE_FLAT, /* Don't shade */ + GFX_SHADE_VERTICALLY, /* Shade vertically */ + GFX_SHADE_HORIZONTALLY /* Shade horizontally */ +} gfx_rectangle_fill_t; + + +typedef enum { + GFX_COLOR_MODE_AUTO = 0, /* Auto-detect- handled by the gfxop library */ + GFX_COLOR_MODE_INDEX = 1, /* Index mode */ + GFX_COLOR_MODE_HIGH = 2, /* High color mode (15bpp or 16 bpp) */ + GFX_COLOR_MODE_TRUE = 4 /* True color mode (24 bpp padded to 32 bpp) */ +} gfx_color_mode_t; + +} // End of namespace Sci + +#endif /* !_SCI_GFX_SYSTEM_ */ diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 18d449d140..99232e55ab 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -24,7 +24,7 @@ */ #include "sci/include/sci_memory.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h new file mode 100644 index 0000000000..b02e437c26 --- /dev/null +++ b/engines/sci/gfx/gfx_tools.h @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* FreeSCI 0.3.1+ graphics subsystem helper functions */ + + +#ifndef _GFX_TOOLS_H_ +#define _GFX_TOOLS_H_ + +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_driver.h" + +namespace Sci { + +typedef enum { + GFX_XLATE_FILTER_NONE, + GFX_XLATE_FILTER_LINEAR, + GFX_XLATE_FILTER_TRILINEAR +} gfx_xlate_filter_t; + +typedef enum { + GFXR_ANTIALIASING_NONE, + GFXR_ANTIALIASING_SIMPLE +} gfxr_antialiasing_t; + + +extern int gfx_crossblit_alpha_threshold; /* Crossblitting functions use this value as threshold + ** for distinguishing between transparent and opaque + ** wrt alpha values */ + +gfx_mode_t *gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask, + unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift, + int blue_shift, int alpha_shift, int palette, int flags); +/* Allocates a new gfx_mode_t structure with the specified parameters +** Parameters: (int x int) xfact x yfact: Horizontal and vertical scaling factors +** (int) bytespp: Bytes per pixel +** (unsigned int) red_mask: Red bit mask +** (unsigned int) green_mask: Green bit mask +** (unsigned int) blue_mask: Blue bit mask +** (unsigned int) Alpha_mask: Alpha bit mask, or 0 if the alpha channel is not supported +** (int) red_shift: Red shift value +** (int) green_shift: Green shift value +** (int) blue_shift: Blue shift value +** (int) alpha_shift: Alpha shift value +** (int) palette: Number of palette colors, 0 if we're not in palette mode +** (int) flags: GFX_MODE_FLAG_* values ORred together, or just 0 +** Returns : (gfx_mode_t *) A newly allocated gfx_mode_t structure +*/ + + +void gfx_clip_box_basic(rect_t *box, int maxx, int maxy); +/* Clips a rect_t +** Parameters: (rect_t *) box: Pointer to the box to clip +** (int x int) maxx, maxy: Maximum allowed width and height +** Returns : (void) +*/ + + +void gfx_free_mode(gfx_mode_t *mode); +/* Frees all memory allocated by a mode structure +** Parameters: (gfx_mode_t *) mode: The mode to free +** Returns : (void) +*/ + + +gfx_pixmap_t *gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel); +/* Creates a new pixmap structure +** Parameters: (int x int) xl x yl: The dimensions (in SCI coordinates) of the pixmap +** (int) resid: The pixmap's resource ID, or GFX_RESID_NONE +** (int) loop: For views: The pixmap's loop number +** (int) cel: For cels: The pixmap's cel number +** Returns : (gfx_pixmap_t *) The newly allocated pixmap +** The following fiels are initialized: +** ID, loop, cel, index_xl, index_yl, xl, yl, data <- NULL, +** alpha_map <- NULL, internal.handle <- 0, internal.info <- NULL, colors <- NULL, +** index_scaled <- 0 +*/ + +gfx_pixmap_t *gfx_clone_pixmap(gfx_pixmap_t *pixmap, gfx_mode_t *mode); +/* Clones a pixmap, minus its index data, palette and driver-specific handles +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to clone +** (gfx_mode_t *) mode: The mode to be applied to the pixmap +** Returns : (gfx_pixmap_t *) The clone +*/ + + +gfx_pixmap_t *gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap); +/* Allocates the index_data field of a pixmap +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to allocate for +** Returns : (gfx_pixmap_t *) pixmap +*/ + +gfx_pixmap_t *gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap); +/* Frees the index_data field of a pixmap +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to modify +** Returns : (gfx_pixmap_t *) pixmap +*/ + +gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode); +/* Allocates the data field of a pixmap +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to allocate for +** (gfx_mode_t *) mode: The mode the memory is to be allocated for +** Returns : (gfx_pixmap_t *) pixmap +*/ + +gfx_pixmap_t *gfx_pixmap_free_data(gfx_pixmap_t *pixmap); +/* Frees the memory allocated for a pixmap's data field +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to modify +** Returns : (gfx_pixmap_t *) pixmap +*/ + +void gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm); +/* Frees all memory associated with a pixmap +** Parameters: (gfx_driver_t *) driver: The driver the pixmap is to be removed from +** (gfx_pixmap_t *) pxm: The pixmap to free +** Returns : (void) +*/ + +void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color); +/* Draws a line to a pixmap's index data buffer +** Parameters: (gfx_pixmap_t *) pxm: The pixmap to draw to +** (Common::Point) start: Starting point of the line to draw +** (Common::Point) end: End point of the line to draw +** (int) color: The byte value to write +** Returns : (void) +** Remember, this only draws to the /index/ buffer, not to the drawable buffer. +** The line is not clipped. Invalid x, y, x1, y1 values will result in memory corruption. +*/ + +void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, + Common::Point start, Common::Point end, unsigned int color); +/* Draws a line to a linear pixel buffer +** Parameters: (byte *) buffer: Pointer to the start of the buffer to draw to +** (int) linewidth: Number of bytes per pixel line in the buffer +** (int) pixelwidth: Number of bytes per pixel +** (Common::Point) start: Starting point of the line to draw +** (Common::Point) end: End point of the line to draw +** (rect_t) Coordinates: the line should be drawn to (must be clipped already) +** xl and yl describe relative offsets, as usual. +** (unsigned int) color: The color to draw (only the lowest 8 * pixelwidth bits are relevant) +** Returns : (void) +** This function assumes 1 <= pixelwidth <= 4 +*/ + +void gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color); +/* Draws a filled rectangular area to a pixmap's index buffer +** Parameters: (gfx_pixmap_t *) pxm: The pixmap to draw to +** (rect_t) box: The box to fill +** (int) color: The color to use for drawing +** Returns : (void) +** This function only draws to the index buffer. +*/ + +void gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box); +/* Copies part of a pixmap to another pixmap, with clipping +** Parameters: (gfx_pixmap_t *) dest: The destination pixmap +** (gfx_pixmap_t *) src: The source pixmap +** (rect_t) box: The area to copy +** Returns : (void) +*/ + +void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter); +/* Translates a pixmap's index data to drawable graphics data +** Parameters: (gfx_pixmap_t *) pxm: The pixmap to translate +** (gfx_mode_t *) mode: The mode according which to scale +** (gfx_xlate_filter_t) filter: How to filter the data +** Returns : (void) +*/ + +void gfxr_antialiase(gfx_pixmap_t *pixmap, gfx_mode_t *mode, gfxr_antialiasing_t type); +/* Performs antialiasing on a pixmap +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to antialiase +** (gfx_mode_t *) mode: The current mode +** (gfxr_antialiasing_t) type: Antialiasing algorithm to use +** Returns : (void) +*/ + +#define GFX_CROSSBLIT_FLAG_DATA_IS_HOMED (1<<0) +/* Means that the first byte in the visual data refers to the +** point corresponding to (dest.x, dest.y) */ + +int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, + rect_t src_coords, rect_t dest_coords, byte *dest, + int dest_line_width, byte *priority_dest, + int priority_line_width, int priority_skip, + int flags); +/* Transfers the non-transparent part of a pixmap to a linear pixel buffer +** Parameters: (gfx_mode_t *) mode: The graphics mode of the target buffer +** (gfx_pixmap_t *) pxm: The pixmap to transfer +** (int priority): The pixmap's priority +** (rect_t) src_coords: The source coordinates within the pixmap +** (rect_t) dest_coords: The destination coordinates (no scaling) +** (byte *) dest: Memory position of the upper left pixel of the +** linear pixel buffer +** (int) dest_line_width: Byte offset of the very first pixel in the +** second line of the linear pixel buffer, +** relative to dest. +** (byte *) priority_dest: Destination buffer for the pixmap's priority +** values +** (int) priority_line_width: Byte offset of the first pixel in the +** second line of the priority buffer +** (int) priority_skip: Amount of bytes allocated by each priority value +** (int) flags: Any crossblit flags +** Returns : (int) GFX_OK, or GFX_ERROR if the specified mode was invalid or unsupported +** A 'linear buffer' in this context means a data buffer containing an entire +** screen (visual or priority), with fixed offsets between each data row, and +** linear access. +*/ + +int gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color); +/* Allocates a color entry for the specified pixmap color +** Parameters: (gfx_palette_t *) pal: The palette structure the color should be allocated in +** (gfx_pixmap_color_t *) color: The color to allocate +** Returns : (int) GFX_ERROR if any error occured, GFX_OK if the color could be mapped to an +** existing color or a positive value if a new color was allocated in the +** palette. +*/ + +int gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color); +/* Frees the color entry allocated for the specified pixmap color +** Parameters: (gfx_palette_t *) pal: The palette structure the color was previously allocated in +** (gfx_pixmap_color_t *) color: The color to free +** Returns : (int) GFX_ERROR if any error occured, GFX_OK otherwise +*/ + +gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode); +/* Scales the index data associated with a pixmap +** Parameters: (gfx_pixmap_t *) pixmap: The pixmap whose index data should be scaled +** (gfx_mode_t *) mode: The mode to scale it to +** Returns : (gfx_pixmap_t *) pixmap +*/ + +} // End of namespace Sci + +#endif /* !_GFX_TOOLS_H_ */ diff --git a/engines/sci/gfx/gfx_widgets.h b/engines/sci/gfx/gfx_widgets.h new file mode 100644 index 0000000000..1c853648a6 --- /dev/null +++ b/engines/sci/gfx/gfx_widgets.h @@ -0,0 +1,520 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Graphical state management */ + +#ifndef _GFX_WIDGETS_H_ +#define _GFX_WIDGETS_H_ + +#include "sci/gfx/gfx_state_internal.h" + +namespace Sci { + +/* Enable the next line to keep a list of pointers to all widgets, with up to the specified amount +** of members (/SLOW/) */ +/* #define GFXW_DEBUG_WIDGETS 2048 */ + +/* Our strategy for dirty rectangle management */ +#define GFXW_DIRTY_STRATEGY GFXOP_DIRTY_FRAMES_CLUSTERS + +/* Properly belongs in sci_widgets.h, but we need it here */ +#define WINDOW_FLAG_AUTO_RESTORE 0x2000000 + +/* Indicates that a Chrono-Port should not be created even if it doesn't exist. */ +#define GFXW_CHRONO_NO_CREATE 1 + +/* Indicates that non-topmost ports should be scanned for a Chrono-Port. */ +#define GFXW_CHRONO_NON_TOPMOST 2 + +/* Terminology +** +** Two special terms are used in here: /equivalent/ and /clear/. Their meanings +** in this context are as follows: +** +** /clear/: Clearing a widget means overwriting the space it occupies in the back +** buffer with data from the static buffer. This affects both the visual and the +** priority buffer, the static buffer (and any effect the widget may have had on +** it) is not touched. +** +** /equivalent/: Two Widgets A and B are equivalent if and only if either of the +** following conditions is met: +** a) Both A and B are text widgets, and they occupy the same bounding rectangle. +** b) Both A and B are dynview widgets, and they have the same unique ID +** Note that /equivalent/ is not really an equivalence relation- while it is ob- +** viously transitive and symmetrical, it is not reflexive (e.g. a box widget +** is not /equivalent/ to itself), although this might be a nice addition for the +** future. +*/ + + +/*********************************/ +/* Fundamental widget operations */ +/*********************************/ + + +#define GFXW(foo) ((gfxw_widget_t *) foo) +/* Typecast an arbitrary widget to gfxw_widget_t*. Might eventually be changed to do tests as well. */ + +#define GFXWC(foo) ((gfxw_container_t *) foo) +/* Typecasts a container widget to gfxw_container_widget_t *. */ + +/* gfxw_point_zero is declared in gfx/widgets.c */ +extern Common::Point gfxw_point_zero; + +/*********************/ +/* Widget operations */ +/*********************/ + +/* These are for documentation purposes only. The actual declarations are in +** gfx_state_internal.h. +** +** +** +** -- draw(gfxw_widget_t *self, Common::Point pos) +** Draws the widget. +** Parameters: (gfxw_widget_t *) self: self reference +** (Common::Point) pos: The position to draw to (added to the widget's +** internal position) +** Returns : (int) 0 +** The widget is drawn iff it is flagged as dirty. Invoking this operation on +** a container widget will recursively draw all of its contents. +** +** +** -- widfree(gfxw_widget_t *self) +** Frees all memory associated to the widget +** Parameters: (gfxw_widget_t *) self: self reference +** Returns : (int) 0 +** The widget automatically removes itself from its owner, if it has one. +** Invoking this operation on a container will recursively free all of its +** contents. +** +** +** -- tag(gfxw_widget_t *self) +** Tags the specified widget +** Parameters: (gfxw_widget_t *) self: self reference +** Returns : (int) 0 +** If invoked on a container widget, this will also tag all of the container's +** contents (but not the contents' contents!) +** +** +** -- print(gfxw_widget_t *self, int indentation) +** Prints a string representation of the widget with sciprintf +** Parameters: (gfxw_widget_t *) self: self reference +** (int) indentation: Number of double spaces to indent +** Returns ; (int) 0 +** Will recursively print all of the widget's contents if the widget contains +** further sub-widgets +** +** +** -- compare_to(gfxw_widget_t *self, gfxw_widget_t *other) +** Compares two compareable widgets by their screen position +** Parameters: (gfxw_widget_t *) self: self reference +** (gfxw_widget_t *) other: other widget +** Returns : (int) <0, 0, or >0 if other is, respectively, less than, equal +** to, or greater than self +** This comparison only applies to some widgets; compare_to(a,a)=0 is not +** guaranteed. It may be used for sorting for all widgets. +** +** +** -- equals(gfxw_widget_t *self, gfxw_widget_t *other) +** Compares two compareable widgets for equality +** Parameters: (gfxw_widget_t *) self: self reference +** (gfxw_widget_t *) other: other widget +** Returns : (int) 0 if the widgets are not equal, != 0 if they match +** This operation checks whether two widgets describe the same graphical data. +** It is used to determine whether a new widget should be discarded because it +** describes the same graphical data as an old widget that has already been +** drawn. For lists, it also checks whether all contents are in an identical +** order. +** +** +** -- should_replace(gfxw_widget_t *self, gfxw_widget_t *other) +** Compares two compareable widgets for equality +** Parameters: (gfxw_widget_t *) self: self reference +** (gfxw_widget_t *) other: other widget +** Returns : (int) 0 if 'self' should be kept, != 0 if it should be replaced +** by the 'other' +** When 'equals' returns true, this means that no new widget will be added. +** However, in some cases newer widgets may contain information that should +** cause the older widget to be removed nonetheless; this is indicated by this +** function. +** +** +** -- superarea_of(gfxw_widget_t *self, gfxw_widget_t *other) +** Tests whether drawing self after other would reduce all traces of other +** Parameters: (gfxw_widget_t *) self: self reference +** (gxfw_widget_t *) other: The widget to compare for containment +** Returns : (int) 1 if self is superarea_of other, 0 otherwise +** +** +** -- set_visual(gfxw_widget_t *self) +** Sets the visual for the widget +** Parameters: (gfxw_widget_t *) self: self reference +** Returns : (int) 0 +** This function is called by container->add() and need not be invoked explicitly. +** It also makes sure that dirty rectangles are passed to parent containers. +** +** +** +** ************************** +** ** Container operations ** +** ************************** +** +** +** -- free_tagged(gfxw_container_t *self) +** Frees all tagged resources in the container +** Parameters: (gfxw_container_t *) self: self reference +** Returns : (int) 0 +** The container itself is never freed in this way. +** +** +** -- free_contents(gfxw_container_t *self) +** Frees all resources contained in the container +** Parameters: (gfxw_container_t *) self: self reference +** Returns : (int) 0 +** +** +** -- add_dirty_abs(gfxw_container_t *self, rect_t dirty, int propagate) +** Adds a dirty rectangle to the container's list of dirty rects +** Parameters: (gfxw_container_t *) self: self reference +** (rect_t) dirty: The rectangular screen area that is to be flagged +** as dirty, absolute to the screen +** (int) propagate: Whether the dirty rect should be propagated to the +** widget's parents +** Returns : (int) 0 +** Transparent containers will usually pass this value to their next ancestor, +** because areas below them might have to be redrawn. +** The dirty rectangle management strategy is defined in this file in +** GFXW_DIRTY_STRATEGY. +** +** +** -- add_dirty_rel(gfxw_container_t *self, rect_t dirty, int propagate) +** Adds a dirty rectangle to the container's list of dirty rects +** Parameters: (gfxw_container_t *) self: self reference +** (rect_t) dirty: The rectangular screen area that is to be flagged +** as dirty, relative to the widget +** (int) propagate: Whether the dirty rect should be propagated to the +** widget's parents +** Returns : (int) 0 +** Transparent containers will usually pass this value to their next ancestor, +** because areas below them might have to be redrawn. +** The dirty rectangle management strategy is defined in this file in +** GFXW_DIRTY_STRATEGY. +** +** +** -- add(gfxw_container_t *self, gfxw_widget_t *widget) +** Adds a widget to the list of contained widgets +** Parameters: (gfxw_container_t *) self: self reference +** (gfxw_widget_t *) widget: The widget to add +** Returns : (int) 0 +** Sorted lists sort their content into the list rather than adding it to the +** end. +*/ + + +/***************************/ +/* Basic widget generation */ +/***************************/ + +/*-- Primitive types --*/ + +gfxw_box_t *gfxw_new_box(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type); +/* Creates a new box +** Parameters: (gfx_state_t *) state: The (optional) state +** (rect_t) area: The box's dimensions, relative to its container widget +** (gfx_color_t) color1: The primary color +** (gfx_color_t) color1: The secondary color (ignored if shading is disabled) +** (gfx_box_shade_t) shade_type: The shade type for the box +** Returns : (gfxw_box_t *) The resulting box widget +** The graphics state- if non-NULL- is used here for some optimizations. +*/ + +gfxw_primitive_t *gfxw_new_rect(rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); +/* Creates a new rectangle +** Parameters: (rect_t) rect: The rectangle area +** (gfx_color_t) color: The rectangle's color +** (gfx_line_mode_t) line_mode: The line mode for the lines that make up the rectangle +** (gfx_line_style_t) line_style: The rectangle's lines' style +** Returns : (gfxw_primitive_t *) The newly allocated rectangle widget (a Primitive) +*/ + +gfxw_primitive_t *gfxw_new_line(Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); +/* Creates a new line +** Parameters: (Common::Point * Common::Point) (start, line): The line origin and end point +** (gfx_color_t) color: The line's color +** (gfx_line_mode_t) line_mode: The line mode to use for drawing +** (gfx_line_style_t) line_style: The line style +** Returns : (gfxw_primitive_t *) The newly allocated line widget (a Primitive) +*/ + + +/* Whether the view should be static */ +#define GFXW_VIEW_FLAG_STATIC (1 << 0) + +/* Whether the view should _not_ apply its x/y offset modifyers */ +#define GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET (1 << 1) + +gfxw_view_t *gfxw_new_view(gfx_state_t *state, Common::Point pos, int view, int loop, int cel, int palette, int priority, int control, + gfx_alignment_t halign, gfx_alignment_t valign, int flags); +/* Creates a new view (a cel, actually) +** Parameters: (gfx_state_t *) state: The graphics state +** (Common::Point) pos: The position to place the view at +** (int x int x int) view, loop, cel: The global cel ID +** (int) priority: The priority to use for drawing, or -1 for none +** (int) control: The value to write to the control map, or -1 for none +** (gfx_alignment_t x gfx_alignment_t) halign, valign: Horizontal and vertical +** cel alignment +** (int) flags: Any combination of GFXW_VIEW_FLAGs +** Returns : (gfxw_cel_t *) A newly allocated cel according to the specs +*/ + +gfxw_dyn_view_t *gfxw_new_dyn_view(gfx_state_t *state, Common::Point pos, int z, int view, int loop, int cel, int palette, + int priority, int control, gfx_alignment_t halign, gfx_alignment_t valign, + int sequence); +/* Creates a new dyn view +** Parameters: (gfx_state_t *) state: The graphics state +** (Common::Point) pos: The position to place the dynamic view at +** (int) z: The z coordinate +** (int x int x int) view, loop, cel: The global cel ID +** (int) priority: The priority to use for drawing, or -1 for none +** (int) control: The value to write to the control map, or -1 for none +** (gfx_alignment_t x gfx_alignment_t) halign, valign: Horizontal and vertical +** cel alignment +** (int) sequence: Sequence number: When sorting dynviews, this number is +** considered last for sorting (ascending order) +** Returns : (gfxw_cel_t *) A newly allocated cel according to the specs +** Dynamic views are non-pic views with a unique global identifyer. This allows for drawing +** optimizations when they move or change shape. +*/ + +gfxw_text_t *gfxw_new_text(gfx_state_t *state, rect_t area, int font, const char *text, gfx_alignment_t halign, + gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, + gfx_color_t bgcolor, int flags); +/* Creates a new text widget +** Parameters: (gfx_state_t *) state: The state the text is to be calculated from +** (rect_t) area: The area the text is to be confined to (the yl value is only +** relevant for text aligment, though) +** (int) font: The number of the font to use +** (gfx_alignment_t x gfx_alignment_t) halign, valign: Horizontal and +** vertical text alignment +** (gfx_color_t x gfx_color_t) color1, color2: Text foreground colors (if not equal, +** The foreground is dithered between them) +** (gfx_color_t) bgcolor: Text background color +** (int) flags: GFXR_FONT_FLAGs, orred together (see gfx_resource.h) +** Returns : (gfxw_text_t *) The resulting text widget +*/ + +void gfxw_text_info(gfx_state_t *state, gfxw_text_t *text, int *lines_nr, + int *lineheight, int *offset); +/* Determines text widget meta-information +** Parameters: (gfx_state_t *) state: The state to operate on +** (gfx_text_t *) text: The widget to query +** Returns : (int) lines_nr: Number of lines used in the text +** (int) lineheight: Pixel height (SCI scale) of each text line +** (int) offset: Pixel offset (SCI scale) of the space after the +** last character in the last line +*/ + +gfxw_widget_t *gfxw_set_id(gfxw_widget_t *widget, int ID, int subID); +/* Sets a widget's ID +** Parmaeters: (gfxw_widget_t *) widget: The widget whose ID should be set +** (int x int) ID, subID: The ID to set +** Returns : (gfxw_widget_t *) widget +** A widget ID is unique within the container it is stored in, if and only if it was +** added to that container with gfxw_add(). +** This function handles widget = NULL gracefully (by doing nothing and returning NULL). +*/ + +gfxw_widget_t *gfxw_remove_id(gfxw_container_t *container, int ID, int subID); +/* Finds a widget with a specific ID in a container and removes it from there +** Parameters: (gfxw_container_t *) container: The container to search in +** (int) ID: The ID to look for +** (int) subID: The subID to look for, or GFXW_NO_ID for any +** Returns : (gfxw_widget_t *) The resulting widget or NULL if no match was found +** Search is non-recursive; widgets with IDs hidden in subcontainers will not be found. +*/ + + +gfxw_dyn_view_t *gfxw_dyn_view_set_params(gfxw_dyn_view_t *widget, int under_bits, void *under_bitsp, int signal, void *signalp); +/* Initializes a dyn view's interpreter attributes +** Parameters: (gfxw_dyn_view_t *) widget: The widget affected +** (int x void * x int x void *) under_bits, inder_bitsp, signal, signalp: Interpreter-dependant data +** Returns : (gfxw_dyn_view_t *) widget +*/ + +gfxw_widget_t *gfxw_hide_widget(gfxw_widget_t *widget); +/* Makes a widget invisible without removing it from the list of widgets +** Parameters: (gfxw_widget_t *) widget: The widget to invisibilize +** Returns : (gfxw_widget_t *) widget +** Has no effect on invisible widgets +*/ + +gfxw_widget_t *gfxw_show_widget(gfxw_widget_t *widget); +/* Makes an invisible widget reappear +** Parameters: (gfxw_widget_t *) widget: The widget to show again +** Returns : (gfxw_widget_t *) widget +** Does not affect visible widgets +*/ + +gfxw_widget_t *gfxw_abandon_widget(gfxw_widget_t *widget); +/* Marks a widget as "abandoned" +** Parameters: (gfxw_widget_t *) widget: The widget to abandon +** Returns : (gfxw_widget_t *) widget +*/ + +/*-- Container types --*/ + +#define GFXW_LIST_UNSORTED 0 +#define GFXW_LIST_SORTED 1 + +gfxw_list_t *gfxw_new_list(rect_t area, int sorted); +/* Creates a new list widget +** Parameters: (rect_t) area: The area covered by the list (absolute position) +** (int) sorted: Whether the list should be a sorted list +** Returns : (gfxw_list_t *) A newly allocated list widget +** List widgets are also referred to as Display Lists. +*/ + +gfxw_visual_t *gfxw_new_visual(gfx_state_t *state, int font); +/* Creates a new visual widget +** Parameters: (gfx_state_t *) state: The graphics state +** (int) font: The default font number for contained ports +** Returns : (gfxw_list_t *) A newly allocated visual widget +** Visual widgets are containers for port widgets. +*/ + + +gfxw_port_t *gfxw_new_port(gfxw_visual_t *visual, gfxw_port_t *predecessor, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor); +/* Creates a new port widget with the default settings +** Paramaters: (gfxw_visual_t *) visual: The visual the port is added to +** (gfxw_port_t *) predecessor: The port's predecessor +** (rect_t) area: The screen area covered by the port (absolute position) +** (gfx_color_t) fgcolor: Foreground drawing color +** (gfx_color_t) bgcolor: Background color +** Returns : (gfxw_port_t *) A newly allocated port widget +** A port differentiates itself from a list in that it contains additional information, +** and an optional title (stored in a display list). +** Ports are assigned implicit IDs identifying their position within the port stack. +*/ + +gfxw_port_t *gfxw_find_port(gfxw_visual_t *visual, int ID); +/* Retrieves a port with the specified ID +** Parameters: (gfxw_visual_t *) visual: The visual the port is to be retrieved from +** (int) ID: The port's ID +** Returns : (gfxw_port_t *) The requested port, or NULL if it didn't exist +** This function is O(1). +*/ + +gfxw_port_t *gfxw_find_default_port(gfxw_visual_t *visual); +/* Retreives the default port from a visual +** Parameters: (gfxw_visual_t *) visual: The visual the port should be retrieved from +** Returns : (gfxw_port_t *) The default port, or NULL if no port is present +** The 'default port' is the last port to be instantiated; usually the topmost +** or highest-ranking port. +*/ + +void gfxw_port_set_auto_restore(gfxw_visual_t *visual, gfxw_port_t *window, rect_t auto_rect); +/* Sets rectangle to be restored upon port removal +** Parameters: (state_t *) s: The state to operate on + (gfxw_port_t *) window: The affected window +** (rect_t) auto_rect: The area to restore +** Returns : (void) +*/ + +gfxw_port_t *gfxw_remove_port(gfxw_visual_t *visual, gfxw_port_t *port); +/* Removes a port from a visual +** Parameters: (gfxw_visual_t *) visual: The visual the port should be removed from +** (gfxw_port_t *) port: The port to remove +** Returns : (gfxw_port_t *) port's parent port, or NULL if it had none +*/ + +void gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *widget); +/* Removes the widget from the specified port +** Parameters: (gfxw_container_t *) container: The container it should be removed from +** (gfxw_widget_t *) widget: The widget to remove +** Returns : (void) +*/ + +gfxw_snapshot_t *gfxw_make_snapshot(gfxw_visual_t *visual, rect_t area); +/* Makes a "snapshot" of a visual +** Parameters: (gfxw_visual_t *) visual: The visual a snapshot is to be taken of +** (rect_t) area: The area a snapshot should be taken of +** Returns : (gfxw_snapshot_t *) The resulting, newly allocated snapshot +** It's not really a full qualified snaphot, though. See gfxw_restore_snapshot +** for a full discussion. +** This operation also increases the global serial number counter by one. +*/ + +int gfxw_widget_matches_snapshot(gfxw_snapshot_t *snapshot, gfxw_widget_t *widget); +/* Predicate to test whether a widget would be destroyed by applying a snapshot +** Parameters: (gfxw_snapshot_t *) snapshot: The snapshot to test against +** (gfxw_widget_t *) widget: The widget to test +** Retunrrs : (int) An appropriate boolean value +*/ + +gfxw_snapshot_t *gfxw_restore_snapshot(gfxw_visual_t *visual, gfxw_snapshot_t *snapshot); +/* Restores a snapshot to a visual +** Parameters: (gfxw_visual_t *) visual: The visual to operate on +** (gfxw_snapshot_t *) snapshot: The snapshot to restore +** Returns : (gfxw_snapshot_t *) snapshot (still needs to be freed) +** The snapshot is not really restored; only more recent widgets touching +** the snapshotted area are destroyed. +*/ + +void gfxw_annihilate(gfxw_widget_t *widget); +/* As widget->widfree(widget), but destroys all overlapping widgets +** Parameters: (gfxw_widget_t *) widget: The widget to use +** Returns : (void) +** This operation calls widget->widfree(widget), but it also destroys +** all widgets with a higher or equal priority drawn after this widget. +*/ + +gfxw_dyn_view_t *gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview); +/* Turns a dynview into a picview +** Parameters: (gfxw_dyn_view_t *) dynview: The victim +** Returns : (gfxw_dyn_view_t *) The victim, after his transformation +** The only changes are in function and type variables, actually. +*/ + +void gfxw_port_auto_restore_background(gfxw_visual_t *visual, gfxw_port_t *window, rect_t auto_rect); +/* Tags a window widget as automatically restoring the visual background upon removal +** Parameters: (gfx_visual_t *) visual: The base visual +** (gfxw_port_t *) window: The window to tag +** (rect_t) auto_rect: The background to remember +** Also records the specified background rectangle, for later recovery +*/ + + +gfxw_port_t *gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags); + +void gfxw_add_to_chrono(gfxw_visual_t *visual, gfxw_widget_t *widget); + +void gfxw_widget_reparent_chrono(gfxw_visual_t *visual, gfxw_widget_t *view, gfxw_list_t *target); + +void gfxw_widget_kill_chrono(gfxw_visual_t *visual, int window); + +} // End of namespace Sci + +#endif /* !_GFX_WIDGETS_H_ */ diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index dbeeb38122..c4d6a9f471 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -26,7 +26,7 @@ // Graphical operations, called from the widget state manager #include "sci/include/sci_memory.h" -#include "sci/include/gfx_operations.h" +#include "sci/gfx/gfx_operations.h" #include diff --git a/engines/sci/gfx/resmgr.cpp b/engines/sci/gfx/resmgr.cpp index 62f0493775..c722175b12 100644 --- a/engines/sci/gfx/resmgr.cpp +++ b/engines/sci/gfx/resmgr.cpp @@ -29,11 +29,11 @@ // filenames, are misleading. This should be renamed to "Graphics manager" // or something like that. -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" -#include "sci/include/gfx_driver.h" -#include "sci/include/gfx_resmgr.h" -#include "sci/include/gfx_state_internal.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" +#include "sci/gfx/gfx_driver.h" +#include "sci/gfx/gfx_resmgr.h" +#include "sci/gfx/gfx_state_internal.h" #include "common/system.h" diff --git a/engines/sci/gfx/resource/sci_cursor_0.cpp b/engines/sci/gfx/resource/sci_cursor_0.cpp index aa60fb4b7d..f231cb31f9 100644 --- a/engines/sci/gfx/resource/sci_cursor_0.cpp +++ b/engines/sci/gfx/resource/sci_cursor_0.cpp @@ -23,9 +23,9 @@ * */ -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/resource/sci_font.cpp b/engines/sci/gfx/resource/sci_font.cpp index 8b1eb4b8b2..a6d3abcb9d 100644 --- a/engines/sci/gfx/resource/sci_font.cpp +++ b/engines/sci/gfx/resource/sci_font.cpp @@ -24,9 +24,9 @@ */ #include "sci/include/sci_memory.h" -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/resource/sci_pal_1.cpp b/engines/sci/gfx/resource/sci_pal_1.cpp index 6ba33b5ae7..97280cef25 100644 --- a/engines/sci/gfx/resource/sci_pal_1.cpp +++ b/engines/sci/gfx/resource/sci_pal_1.cpp @@ -26,8 +26,8 @@ /* SCI1 palette resource defrobnicator */ #include "sci/include/sci_memory.h" -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_resource.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_resource.h" namespace Sci { diff --git a/engines/sci/gfx/resource/sci_pic_0.cpp b/engines/sci/gfx/resource/sci_pic_0.cpp index 8f0e311f7c..392996d4e5 100644 --- a/engines/sci/gfx/resource/sci_pic_0.cpp +++ b/engines/sci/gfx/resource/sci_pic_0.cpp @@ -25,8 +25,8 @@ #include // for time() to seed rand() via srand() #include "sci/include/sci_memory.h" -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/resource/sci_picfill.cpp b/engines/sci/gfx/resource/sci_picfill.cpp index 669c30ee8e..0867b84c6e 100644 --- a/engines/sci/gfx/resource/sci_picfill.cpp +++ b/engines/sci/gfx/resource/sci_picfill.cpp @@ -23,7 +23,7 @@ * */ -#include "sci/include/gfx_resource.h" +#include "sci/gfx/gfx_resource.h" namespace Sci { diff --git a/engines/sci/gfx/resource/sci_resmgr.cpp b/engines/sci/gfx/resource/sci_resmgr.cpp index a82ff3c979..734c91e2c3 100644 --- a/engines/sci/gfx/resource/sci_resmgr.cpp +++ b/engines/sci/gfx/resource/sci_resmgr.cpp @@ -27,9 +27,9 @@ #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" -#include "sci/include/gfx_widgets.h" -#include "sci/include/gfx_resmgr.h" -#include "sci/include/gfx_options.h" +#include "sci/gfx/gfx_widgets.h" +#include "sci/gfx/gfx_resmgr.h" +#include "sci/gfx/gfx_options.h" #include "common/util.h" diff --git a/engines/sci/gfx/resource/sci_view_0.cpp b/engines/sci/gfx/resource/sci_view_0.cpp index 437733328e..a43a8acac5 100644 --- a/engines/sci/gfx/resource/sci_view_0.cpp +++ b/engines/sci/gfx/resource/sci_view_0.cpp @@ -24,9 +24,9 @@ */ #include "sci/include/sci_memory.h" -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/resource/sci_view_1.cpp b/engines/sci/gfx/resource/sci_view_1.cpp index 1a395e93f1..6da617c7ec 100644 --- a/engines/sci/gfx/resource/sci_view_1.cpp +++ b/engines/sci/gfx/resource/sci_view_1.cpp @@ -26,9 +26,9 @@ // SCI 1 view resource defrobnicator #include "sci/include/sci_memory.h" -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" +#include "sci/gfx/gfx_system.h" +#include "sci/gfx/gfx_resource.h" +#include "sci/gfx/gfx_tools.h" namespace Sci { diff --git a/engines/sci/gfx/sbtree.cpp b/engines/sci/gfx/sbtree.cpp index fd7e7f0197..5520dd156d 100644 --- a/engines/sci/gfx/sbtree.cpp +++ b/engines/sci/gfx/sbtree.cpp @@ -27,9 +27,7 @@ #include "sci/include/sci_memory.h" -#include "sci/include/sbtree.h" -#include -#include +#include "sci/gfx/sbtree.h" namespace Sci { diff --git a/engines/sci/gfx/sbtree.h b/engines/sci/gfx/sbtree.h new file mode 100644 index 0000000000..0639d80bfc --- /dev/null +++ b/engines/sci/gfx/sbtree.h @@ -0,0 +1,110 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Static binary tree header file */ + +/* Static binary trees are used to link ints to pointers. They are not capable +** of resizing after being initialized. +*/ + +#ifndef _SBTREE_H_ +#define _SBTREE_H_ + +#ifdef SBTREE_DEBUG +# include +#endif + +namespace Sci { + +typedef struct { + int entries_nr; + int min_entry; + int max_entry; + int levels; + int alloced_entries; + void *data; +} sbtree_t; + + +sbtree_t *sbtree_new(int size, int *keys); +/* Generates a new sbtree with the specified key set +** Parameters: (int) size: Number of entries in 'keys' +** (int *) keys: Array of 'size' integer keys +** Returns : (sbtree_t *) A new sbtree +** Only positive keys are allowed. Duplicates are not detected and will +** cause additional memory usage and slower access times if not removed +** beforehand. +*/ + +void sbtree_free(sbtree_t *tree); +/* Frees an sbtree +** Parameters: (sbtree_t *) tree: The tree to free +** Returns : (void) Nothing at all +*/ + +int sbtree_set(sbtree_t *tree, int key, void *value); +/* Sets a key to a value +** Parameters: (sbtree_t *) tree: The tree to modify +** (int) key: The key to set +** (void *) value: The value part of the (key,value) tuple +** Returns : (int) 0 if everything went OK, -1 if the key was invalid +** value may, of course, be NULL here. +*/ + +void *sbtree_get(sbtree_t *tree, int key); +/* Retreives a key +** Parameters: (sbtree_t *) tree: The tree to search in +** (int) key: The key to retrieve +** Returns : (void *) The value mapped to the key +** If key was not found/invalid, NULL is returned. Note that there is no +** way of distinguishing between keys mapped to NULL and invalid keys, +** short of attempting to set that key. +*/ + +void sbtree_foreach(sbtree_t *tree, void *args, void *(*operation)(sbtree_t *, const int, + const void *, void *)); +/* Operates once on each entry in the tree +** Parameters: (sbtree_t *) tree: The tree to operate on +** (void *) arguments: Additional arguments to pass to 'operation' +** (int (int, void *, void *)) operation: The operation to execute +** Returns : (void) +** The parameters of the function that is to be executed are as follows: +** operation (sbtree_t *tree, int key, void *value, void *args) +** Parameters: (sbtree_t *) tree: The tree the operation was executed on +** (int) key: Key of the entry the operation was invoked on +** (void *) value: Value of the entry the operation was invoked on +** (void *) args: The 'args' parameter passed to sbtree_foreach() +** Returns : (void *) The new value of this entry +** This function will only work properly the original data contained no duplicate keys. +*/ + +} // End of namespace Sci + +#endif /* !_SBTREE_H_ */ + + + + + diff --git a/engines/sci/gfx/sci_widgets.cpp b/engines/sci/gfx/sci_widgets.cpp index 2a059b8641..7e853904db 100644 --- a/engines/sci/gfx/sci_widgets.cpp +++ b/engines/sci/gfx/sci_widgets.cpp @@ -23,8 +23,8 @@ * */ -#include "sci/include/gfx_operations.h" -#include "sci/include/gfx_widgets.h" +#include "sci/gfx/gfx_operations.h" +#include "sci/gfx/gfx_widgets.h" #include "sci/include/engine.h" #include "sci/include/menubar.h" #include "sci/include/sci_widgets.h" diff --git a/engines/sci/gfx/widgets.cpp b/engines/sci/gfx/widgets.cpp index e3a662ff17..1253829a41 100644 --- a/engines/sci/gfx/widgets.cpp +++ b/engines/sci/gfx/widgets.cpp @@ -24,7 +24,7 @@ */ #include "sci/include/sci_memory.h" -#include "sci/include/gfx_widgets.h" +#include "sci/gfx/gfx_widgets.h" namespace Sci { diff --git a/engines/sci/include/engine.h b/engines/sci/include/engine.h index d6e54460a8..27416b3beb 100644 --- a/engines/sci/include/engine.h +++ b/engines/sci/include/engine.h @@ -42,8 +42,8 @@ namespace Common { #include "sci/include/menubar.h" #include "sci/include/versions.h" #include "sci/include/kernel.h" -#include "sci/include/gfx_state_internal.h" -#include "sci/include/sfx_engine.h" +#include "sci/gfx/gfx_state_internal.h" +#include "sci/sfx/sfx_engine.h" namespace Sci { diff --git a/engines/sci/include/gfx_driver.h b/engines/sci/include/gfx_driver.h deleted file mode 100644 index 21355eec6b..0000000000 --- a/engines/sci/include/gfx_driver.h +++ /dev/null @@ -1,322 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _SCI_GFX_DRIVER_H_ -#define _SCI_GFX_DRIVER_H_ - -#include "sci/include/gfx_system.h" -#include "sci/include/uinput.h" - -namespace Sci { - -typedef enum { - GFX_BUFFER_FRONT = 0, - GFX_BUFFER_BACK = 1, - GFX_BUFFER_STATIC = 2 -} gfx_buffer_t; - - -/* graphics driver hints */ -#define GFX_CAPABILITY_SHADING (1<<0) -#define GFX_CAPABILITY_STIPPLED_LINES (1<<6) - -#define GFX_DEBUG_POINTER (1<<0) -#define GFX_DEBUG_UPDATES (1<<1) -#define GFX_DEBUG_PIXMAPS (1<<2) -#define GFX_DEBUG_BASIC (1<<3) /* Basic geometric ops (lines, boxes, etc) */ - -/* Principial graphics driver architecture -** --------------------------------------- -** -** All graphics drivers must provide -** - One visual front buffer (the actually visible thing) -** - Two dynamic back buffers: -** + visual -** + priority -** - Two static buffers (containing the background image and picviews): -** + visual -** + priority -** -** The control buffer is handled outside the graphics driver architecture. -** Graphics are drawn by first setting the static buffers, then updating -** the back buffers (from the static buffers), adding all picviews and other -** widgets, and finally updating the front buffer. -** -** All coordinates refer to the scaled coordinate system. -** Invalid parameters should produce an error message. -** Support for some valid parameter values is optional (like different line -** modes). If an unsupported but valid parameter is specified, the function -** must use a reasonable default value. -*/ - -typedef struct _gfx_driver { /* Graphics driver */ - - gfx_mode_t *mode; /* Currently active mode, NULL if no mode is active */ - - int pointer_x, pointer_y; /* Mouse pointer position */ - - int capabilities; /* The driver's capabilities: A list of flags that may - ** be pre-defined or set after a successful initialization. - */ - /* Capability flags: - ** - ** The words MUST, SHOULD and MAY are to be interpreted as described in - ** the IETF RFC 1123. - ** - ** GFX_CAPABILITY_SHADING: draw_filled_rect() supports drawing shaded - ** rectangles. - ** GFX_CAPABILITY_STIPPLED_LINES: The driver is able to draw stippled lines - ** horizontally and vertically (xl = 0 or yl = 0). - */ - - unsigned int debug_flags; /* Driver debug flags */ - - - /*** Initialization ***/ - - int (*set_parameter)(struct _gfx_driver *drv, char *attribute, char *value); - /* Sets a driver-specific parameter - ** Parameters: (gfx_driver_t *) drv: Pointer to the affected driver - ** (char *) attribute: Name of the attribute/parameter to set - ** (char *) value: The value to set, or NULL to query the value - ** Returns : (int) GFX_OK or GFX_FATAL, which signals a fatal error - ** condition. - ** This function should make extensive use of sciprintf() to signal invalid - ** values or unapplicable attributes. - ** Note that it may be called either before initialization (to interpret - ** config file or command line parameters) or afterwars (from the command - ** console). - */ - - int (*init_specific)(struct _gfx_driver *drv, int xres, int yres, - int bytespp); - /* Attempts to initialize a specific graphics mode - ** Parameters: (gfx_driver_t *) drv: The affected driver - ** (int x int) xres, yres: Horizontal and vertical scaling - ** factors - ** (int) bytespp: Any of GFX_COLOR_MODE_*. GFX_COLOR_MODE_INDEX - ** implies color index mode. - ** Returns : (int) GFX_OK on success, GFX_ERROR if the mode could not be - ** set, or GFX_FATAL if the graphics target is unuseable. - ** The scaling factors apply to the standard SCI resolution of 320x200 pixels - ** and is used for internal representation of graphical data. The physical - ** resolution set by the graphics driver may be different for practical - ** reasons. - ** Must also set drv->mode, preferably with the gfx_new_mode() function - ** specified in gfx_tools.h. - */ - - int (*init)(struct _gfx_driver *drv); - /* Initialize any graphics mode - ** Parameters: (gfx_driver_t *) drv: The affected driver - ** Returns : (int) GFX_OK on success, GFX_FATAL otherwise. - ** This function attempts to set /any/ graphics mode, starting with the one - ** most 'natural' to the graphics target. Target implementors have relatively - ** free reign in choosing the heuristics used to determine the resulting - ** mode. - ** Must also set drv->mode, preferably with the gfx_new_mode() function - ** specified in gfx_tools.h. - */ - - void (*exit)(struct _gfx_driver *drv); - /* Uninitializes the current graphics mode - ** Paramters: (gfx_driver_t *) drv: The driver to uninitialize - ** Return : (void) - ** This function frees all memory allocated by the graphics driver, - ** including mode and palette information, uninstalls all console commands - ** introduced by preceeding init() or init_specific() commands, and does any - ** clean-up work (like closing visuals or returning to text mode) required by - ** the graphics infrastructure used. - */ - - - /*** Drawing operations ***/ - - int (*draw_line)(struct _gfx_driver *drv, - Common::Point start, Common::Point end, - gfx_color_t color, - gfx_line_mode_t line_mode, gfx_line_style_t line_style); - /* Draws a single line to the back buffer. - ** Parameters: (gfx_driver_t *) drv: The driver affected - ** (Common::Point) start: Starting point of the line to draw - ** (Common::Point) end: End point of the line to draw - ** (gfx_color_t *) color: The color to draw with - ** (int) line_mode: Any of the line modes - ** (int) line_style: Any of the line styles - ** Returns : (int) GFX_OK or GFX_FATAL - ** Note that color.priority is relevant and must be drawn if - ** (color.mask & GFX_MASK_PRIORITY). - ** Support for line modes other than GFX_LINE_MODE_FAST is optional. - ** For non-fine lines, the coordinates provided describe the upper left - ** corner of the pixels of the line to draw. - ** line_style support is optional, if GFX_CAPABILITY_STIPPLED_LINES is not - ** set. - */ - - int (*draw_filled_rect)(struct _gfx_driver *drv, rect_t rect, - gfx_color_t color1, gfx_color_t color2, - gfx_rectangle_fill_t shade_mode); - /* Draws a single filled and possibly shaded rectangle to the back buffer. - ** Parameters: (gfx_driver_t *) drv: The driver affected - ** (rect_t *) rect: The rectangle to draw - ** (gfx_color_t *) color1, color2: The colors to draw with - ** (int) shade_mode: Any of GFX_SHADE_*. - ** Returns : (int) GFX_OK or GFX_FATAL - ** Note that color.priority is relevant and must be drawn if - ** (color.mask & GFX_MASK_PRIORITY). - ** color2 is relevant only if shade_mode is not GFX_SHADE_FLAT. - ** Support for shade modes other than GFX_SHADE_FLAT is optional. - */ - - /*** Pixmap operations ***/ - - int (*draw_pixmap)(struct _gfx_driver *drv, gfx_pixmap_t *pxm, int priority, - rect_t src, rect_t dest, gfx_buffer_t buffer); - /* Draws part of a pixmap to the static or back buffer - ** Parameters: (gfx_driver_t *) drv: The affected driver - ** (gfx_pixmap_t *) pxm: The pixmap to draw - ** (int) priority: The priority to draw with, or GFX_NO_PRIORITY - ** to draw on top of everything without setting the - ** priority back buffer - ** (rect_t) src: The pixmap-relative source rectangle - ** (rect_t) dest: The destination rectangle - ** (int) buffer: One of GFX_BUFFER_STATIC and GFX_BUFFER_BACK - ** Returns : (int) GFX_OK or GFX_FATAL, or GFX_ERROR if pxm was not - ** (but should have been) registered. - */ - - int (*grab_pixmap)(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm, - gfx_map_mask_t map); - /* Grabs an image from the visual or priority back buffer - ** Parameters: (gfx_driver_t *) drv: The affected driver - ** (rect_t) src: The rectangle to grab - ** (gfx_pixmap_t *) pxm: The pixmap structure the data is to - ** be written to - ** (int) map: GFX_MASK_VISUAL or GFX_MASK_PRIORITY - ** Returns : (int) GFX_OK, GFX_FATAL, or GFX_ERROR for invalid map values - ** pxm may be assumed to be empty and pre-allocated with an appropriate - ** memory size. - ** This function is now mandatory. - */ - - - /*** Buffer operations ***/ - - int (*update)(struct _gfx_driver *drv, rect_t src, Common::Point dest, - gfx_buffer_t buffer); - /* Updates the front buffer or the back buffers - ** Parameters: (gfx_driver_t *) drv: The affected driver - ** (rect_t) src: Source rectangle - ** (Common::Point) dest: Destination point - ** (int) buffer: One of GFX_BUFFER_FRONT or GFX_BUFFER_BACK - ** Returns : (int) GFX_OK, GFX_ERROR or GFX_FATAL - ** This function updates either the visual front buffer, or the two back - ** buffers, by copying the specified source region to the destination - ** region. - ** For heuristical reasons, it may be assumed that the x and y fields of - ** src and dest will be identical in /most/ cases. - ** If they aren't, the priority map will not be required to be copied. - */ - - int (*set_static_buffer)(struct _gfx_driver *drv, gfx_pixmap_t *pic, - gfx_pixmap_t *priority); - /* Sets the contents of the static visual and priority buffers - ** Parameters: (gfx_driver_t *) drv: The affected driver - ** (gfx_pixmap_t *) pic: The image defining the new content - ** of the visual back buffer - ** (gfx_pixmap_t *) priority: The priority map containing - ** the new content of the priority back buffer - ** in the index buffer - ** Returns : (int) GFX_OK or GFX_FATAL - ** pic and priority may be modified or written to freely. They may also be - ** used as the actual static buffers, since they are not freed and re- - ** allocated between calls to set_static_buffer() and update(), unless - ** exit() was called in between. - ** Note that later version of the driver interface may disallow modifying - ** pic and priority. - ** pic and priority are always scaled to the appropriate resolution - */ - - - /*** Mouse pointer operations ***/ - - int (*set_pointer)(struct _gfx_driver *drv, gfx_pixmap_t *pointer); - /* Sets a new mouse pointer. - ** Parameters: (gfx_driver_t *) drv: The driver to modify - ** (gfx_pixmap_t *) pointer: The pointer to set, or NULL to set - ** no pointer - ** Returns : (int) GFX_OK or GFX_FATAL - ** If pointer is not NULL, it will have been scaled to the appropriate - ** size and registered as a pixmap (if neccessary) beforehand. - ** If this function is called for a target that supports only two-color - ** pointers, the image is a color index image, where only color index values - ** 0, 1, and GFX_COLOR_INDEX_TRANSPARENT are used. - */ - - - /*** Palette operations ***/ - - int (*set_palette)(struct _gfx_driver *drv, int index, byte red, byte green, - byte blue); - /* Manipulates a palette index in the hardware palette - ** Parameters: (gfx_driver_t *) drv: The driver affected - ** (int) index: The index of the palette entry to modify - ** (int x int x int) red, green, blue: The RGB intensities to - ** set for the specified index. The minimum - ** intensity is 0, maximum is 0xff. - ** Returns : (int) GFX_OK, GFX_ERROR or GFX_FATAL - ** This function does not need to update mode->palette, as this is done - ** by the calling code. - ** set_palette() is only required for targets supporting color index mode. - */ - - - /*** Event management ***/ - - sci_event_t (*get_event)(struct _gfx_driver *drv); - /* Returns the next event in the event queue for this driver - ** Parameters: (gfx_driver_t *) drv: The driver to query - ** Returns : (sci_event_t) The oldest event still in the driver's event - ** queue, or the null event if there is none. - */ - - int (*usec_sleep)(struct _gfx_driver *drv, long usecs); - /* Sleeps the specified amount of microseconds, or until the mouse moves - ** Parameters: (gfx_driver_t *) drv: The relevant driver - ** (long) usecs: Amount of microseconds to sleep - ** Returns : (int) GFX_OK or GFX_FATAL - ** This function returns when the specified amount of microseconds has - ** elapsed, or when the mouse pointer has been moved and needs to be redrawn. - ** Only targets that can handle colored mouse pointers may choose to handle - ** all mouse management internally. - */ - - void *state; /* Reserved for internal use */ - -} gfx_driver_t; - -} // End of namespace Sci - -#endif // !_SCI_GFX_DRIVER_H_ diff --git a/engines/sci/include/gfx_operations.h b/engines/sci/include/gfx_operations.h deleted file mode 100644 index 42342334a5..0000000000 --- a/engines/sci/include/gfx_operations.h +++ /dev/null @@ -1,684 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Graphical operations, called from the widget state manager */ - -#ifndef _GFX_OPERATIONS_H_ -#define _GFX_OPERATIONS_H_ - -#include "sci/include/gfx_resmgr.h" -#include "sci/include/gfx_tools.h" -#include "sci/include/gfx_options.h" -#include "sci/include/gfx_system.h" -#include "sci/include/uinput.h" - -namespace Sci { - -#define GFXOP_NO_POINTER -1 - -/* Threshold in color index mode to differentiate between visible and non-visible stuff. -** GFXOP_ALPHA_THRESHOLD itself should be treated as non-visible. -*/ -#define GFXOP_ALPHA_THRESHOLD 0xff - -typedef struct { - char *text; /* Copy of the actual text */ - - int lines_nr; - int line_height; - text_fragment_t *lines; /* Text offsets */ - gfx_bitmap_font_t *font; - gfx_pixmap_t **text_pixmaps; - - int width, height; - - int priority, control; - gfx_alignment_t halign, valign; -} gfx_text_handle_t; - -/* Unless individually stated otherwise, the following applies: -** All operations herein apply to the standard 320x200 coordinate system. -** All operations perform clipping relative to state->clip_zone. -*/ - -typedef enum { - GFX_BOX_SHADE_FLAT, - GFX_BOX_SHADE_RIGHT, - GFX_BOX_SHADE_LEFT, - GFX_BOX_SHADE_DOWN, - GFX_BOX_SHADE_UP -#if 0 - /* possible with alphaing, but there is no way to check for - ** alpha capability of gfx_driver->draw_filled_rect() yet - */ - , GFX_BOX_SHADE_RIGHT_DOWN, - GFX_BOX_SHADE_LEFT_DOWN, - GFX_BOX_SHADE_RIGHT_UP, - GFX_BOX_SHADE_LEFT_UP -#endif -} gfx_box_shade_t; - - -typedef struct _dirty_rect { - rect_t rect; - struct _dirty_rect *next; -} gfx_dirty_rect_t; - - -typedef struct _gfx_event { - sci_event_t event; - struct _gfx_event *next; -} gfx_input_event_t; - -typedef struct { - int version; /* Interpreter version */ - - gfx_options_t *options; - - Common::Point pointer_pos; /* Mouse pointer coordinates */ - - rect_t clip_zone_unscaled; /* The current UNSCALED clipping zone */ - rect_t clip_zone; /* The current SCALED clipping zone; a cached scaled version of clip_zone_unscaled */ - - gfx_driver_t *driver; - gfx_pixmap_color_t *static_palette; /* Null for dynamic palettes */ - int static_palette_entries; - - int visible_map; - - gfx_resstate_t *resstate; /* Resource state */ - - gfx_pixmap_t *priority_map; /* back buffer priority map (unscaled) */ - gfx_pixmap_t *static_priority_map; /* static buffer priority map (unscaled) */ - gfx_pixmap_t *control_map; /* back buffer control map (only exists unscaled in the first place) */ - - - int mouse_pointer_visible; /* Whether the pointer is drawn right now */ - Common::Point old_pointer_draw_pos; /* Mouse pointer draw coordinates */ - rect_t pointer_bg_zone; /* old-pointer-draw-pos relative zone inside the pointer - ** pixmap that was drawn */ - - int mouse_pointer_in_hw; /* Current pointer is being handled in hardware */ - - gfx_pixmap_t *mouse_pointer; /* Only set when drawing the mouse manually */ - gfx_pixmap_t *mouse_pointer_bg; /* Background under the pointer */ - - int tag_mode; /* Set to 1 after a new pic is drawn and the resource manager - ** has tagged all resources. Reset after the next front buffer - ** update is done, when all resources that are still tagged are - ** flushed. */ - - int disable_dirty; /* Set to 1 to disable dirty rect accounting */ - - int pic_nr; /* Number of the current pic */ - int palette_nr; /* Palette number of the current pic */ - - gfx_input_event_t *events; - - gfx_pixmap_t *fullscreen_override; /* An optional override picture which must have unscaled - ** full-screen size, which overrides all other visibility, and - ** which is generally slow */ - - gfxr_pic_t *pic, *pic_unscaled; /* The background picture and its unscaled equivalent */ - - struct _dirty_rect *dirty_rects; /* Dirty rectangles */ - - void *internal_state; /* Internal interpreter information */ - -} gfx_state_t; - - -/**************************/ -/* Fundamental operations */ -/**************************/ - -int gfxop_init_default(gfx_state_t *state, gfx_options_t *options, void *misc_info); -/* Initializes a graphics mode suggested by the graphics driver -** Parameters: (gfx_state_ t *) state: The state to initialize in that mode -** (gfx_options_t *) options: Rendering options -** (void *) misc_info: Additional information for the interpreter -** part of the resource loader -** Returns : (int) GFX_OK on success, GFX_FATAL otherwise -*/ - -int gfxop_init(gfx_state_t *state, int xfact, int yfact, gfx_color_mode_t bpp, - gfx_options_t *options, void *misc_info); -/* Initializes a custom graphics mode -** Parameters: (gfx_state_t *) state: The state to initialize -** (int x int) xfact, yfact: Horizontal and vertical scale factors -** (gfx_color_mode_t) bpp: Bytes per pixel to initialize with, or -** 0 (GFX_COLOR_MODE_AUTO) to auto-detect -** (gfx_options_t *) options: Rendering options -** (void *) misc_info: Additional information for the interpreter -** part of the resource loader -** Returns : (int) GFX_OK on success, GFX_ERROR if that particular mode is -** unavailable, or GFX_FATAL if the graphics driver is unable -** to provide any useful graphics support -*/ - -int gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value); -/* Sets a driver-specific parameter -** Parameters: (gfx_state_t *) state: The state, encapsulating the driver object to manipulate -** (char *) attribute: The attribute to set -** (char *) value: The value the attribute should be set to -** Returns : (int) GFX_OK on success, GFX_FATAL on fatal error conditions triggered -** by the command -*/ - -int gfxop_exit(gfx_state_t *state); -/* Deinitializes a currently active driver -** Parameters: (gfx_state_t *) state: The state encapsulating the driver in question -** Returns : (int) GFX_OK -*/ - -int gfxop_scan_bitmask(gfx_state_t *state, rect_t area, gfx_map_mask_t map); -/* Calculates a bit mask calculated from some pixels on the specified map -** Parameters: (gfx_state_t *) state: The state containing the pixels to scan -** (rect_t) area: The area to check -** (gfx_map_mask_t) map: The GFX_MASKed map(s) to test -** Returns : (int) An integer value where, for each 0<=i<=15, bit #i is set -** iff there exists a map for which the corresponding bit was set -** in the 'map' parameter and for which there exists a pixel within -** the specified area so that the pixel's lower 4 bits, interpreted -** as an integer value, equal i. -** (Short version: This is an implementation of "on_control()"). -*/ - -int gfxop_set_visible_map(gfx_state_t *state, gfx_map_mask_t map); -/* Sets the currently visible map -** Parameters: (gfx_state_t *) state: The state to modify -** (gfx_map_mask_t) map: The GFX_MASK to set -** Returns : (int) GFX_OK, or GFX_ERROR if map was invalid -** 'visible_map' can be any of GFX_MASK_VISUAL, GFX_MASK_PRIORITY and GFX_MASK_CONTROL; the appropriate -** map (as far as its contents are known to the graphics subsystem) is then subsequently drawn to the -** screen at each update. If this is set to anything other than GFX_MASK_VISUAL, slow full-screen updates -** are performed. Mostly useful for debugging. -** The screen needs to be updated for the changes to take effect. -*/ - -int gfxop_set_clip_zone(gfx_state_t *state, rect_t zone); -/* Sets a new clipping zone -** Parameters: (gfx_state_t *) state: The affected state -** (rect_t) zone: The new clipping zone -** Returns : (int) GFX_OK -*/ - -/******************************/ -/* Generic drawing operations */ -/******************************/ - -int gfxop_draw_line(gfx_state_t *state, - Common::Point start, Common::Point end, - gfx_color_t color, gfx_line_mode_t line_mode, - gfx_line_style_t line_style); -/* Renders a clipped line to the back buffer -** Parameters: (gfx_state_t *) state: The state affected -** (Common::Point) start: Starting point of the line -** (Common::Point) end: End point of the line -** (gfx_color_t) color: The color to use for drawing -** (gfx_line_mode_t) line_mode: Any valid line mode to use -** (gfx_line_style_t) line_style: The line style to use -** Returns : (int) GFX_OK or GFX_FATAL -*/ - -int gfxop_draw_rectangle(gfx_state_t *state, rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, - gfx_line_style_t line_style); -/* Draws a non-filled rectangular box to the back buffer -** Parameters: (gfx_state_t *) state: The affected state -** (rect_t) rect: The rectangular area the box is drawn to -** (gfx_color_t) color: The color the box is to be drawn in -** (gfx_line_mode_t) line_mode: The line mode to use -** (gfx_line_style_t) line_style: The line style to use for the box -** Returns : (int) GFX_OK or GFX_FATAL -** Boxes drawn in thin lines will surround the minimal area described by rect. -*/ - -int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t color2, - gfx_box_shade_t shade_type); -/* Draws a filled box to the back buffer -** Parameters: (gfx_state_t *) state: The affected state -** (rect_t) box: The area to draw to -** (gfx_color_t) color1: The primary color to use for drawing -** (gfx_color_t) color2: The secondary color to draw in -** (gfx_box_shade_t) shade_type: The shading system to use -** (e.g. GFX_BOX_SHADE_FLAT) -** Returns : (int) GFX_OK or GFX_FATAL -** The draw mask, control, and priority values are derived from color1. -*/ - -int gfxop_fill_box(gfx_state_t *state, rect_t box, gfx_color_t color); -/* Fills a box in the back buffer with a specific color -** Parameters: (gfx_state_t *) state: The state to draw to -** (rect_t) box: The box to fill -** (gfx_color_t) color: The color to use for filling -** Returns : (int) GFX_OK or GFX_FATAL -** This is a simple wrapper function for gfxop_draw_box -*/ - -int gfxop_clear_box(gfx_state_t *state, rect_t box); -/* Copies a box from the static buffer to the back buffer -** Parameters: (gfx_state_t *) state: The affected state -** (rect_t) box: The box to propagate from the static buffer -** Returns : (int) GFX_OK or GFX_FATAL -*/ - - -int gfxop_update(gfx_state_t *state); -/* Updates all dirty rectangles -** Parameters: (gfx_state_t) *state: The relevant state -** Returns : (int) GFX_OK or GFX_FATAL if reported by the driver -** In order to track dirty rectangles, they must be enabled in the options. -** This function instructs the resource manager to free all tagged data -** on certain occasions (see gfxop_new_pic). -*/ - - -int gfxop_update_box(gfx_state_t *state, rect_t box); -/* Propagates a box from the back buffer to the front (visible) buffer -** Parameters: (gfx_state_t *) state: The affected state -** (rect_t) box: The box to propagate to the front buffer -** Returns : (int) GFX_OK or GFX_FATAL -** This function instructs the resource manager to free all tagged data -** on certain occasions (see gfxop_new_pic). -** When called with dirty rectangle management enabled, it will automatically -** propagate all dirty rectangles as well, UNLESS dirty frame accounting has -** been disabled explicitly. -*/ - -int gfxop_enable_dirty_frames(gfx_state_t *state); -/* Enables dirty frame accounting -** Parameters: (gfx_state_t *) state: The state dirty frame accounting is to be enabled in -** Returns : (int) GFX_OK or GFX_ERROR if state was invalid -** Dirty frame accounting is enabled by default. -*/ - -int gfxop_disable_dirty_frames(gfx_state_t *state); -/* Disables dirty frame accounting -** Parameters: (gfx_state_t *) state: The state dirty frame accounting is to be disabled in -** Returns : (int) GFX_OK or GFX_ERROR if state was invalid -*/ - - -/********************/ -/* Color operations */ -/********************/ - -int gfxop_set_color(gfx_state_t *state, gfx_color_t *color, int r, int g, int b, int a, - int priority, int control); -/* Maps an r/g/b value to a color and sets a gfx_color_t structure -** Parameters: (gfx_state_t *) state: The current state -** (gfx_color_t *) color: Pointer to the structure to write to -** (int x int x int) r,g,b: The red/green/blue color intensity values -** of the result color (0x00 (minimum) to 0xff (max)) -** If any of these values is less than zero, the -** resulting color will not affect the visual map when -** used for drawing -** (int) a: The alpha (transparency) value, with 0x00 meaning absolutely -** opaque and 0xff meaning fully transparent. Alpha blending support -** is optional for drivers, so these are the only two values that -** are guaranteed to work as intended. Any value in between them -** must guarantee the following opaqueness: -** opaqueness(x-1) >= opaqueness(x) >= opaqueness (x+1) -** (i.e. ([0,255], less-transparent-than) must define a partial order) -** (int) priority: The priority to use for drawing, or -1 for none -** (int) control: The control to use for drawing, or -1 to disable drawing to the -** control map -** Returns : (int) GFX_OK or GFX_ERROR if state is invalid -** In palette mode, this may allocate a new color. Use gfxop_free_color() described below to -** free that color. -*/ - -int gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color); -/* Designates a color as a 'system color' -** Parameters: (gfx_state_t *) state: The affected state -** (gfx_color_t *) color: The color to designate as a system color -** Returns : (int) GFX_OK or GFX_ERROR if state is invalid -** System colors are permanent colors that cannot be deallocated. As such, they must be used -** with caution. -*/ - -int gfxop_free_color(gfx_state_t *state, gfx_color_t *color); -/* Frees a color allocated by gfxop_set_color() -** Parmaeters: (gfx_state_t *) state: The state affected -** (gfx_color_t *) color: The color to de-allocate -** Returns : (int) GFX_OK or GFX_ERROR if state is invalid -** This function is a no-op in non-index mode, or if color is a system color. -*/ - - -/**********************/ -/* Pointer and IO ops */ -/**********************/ - -int gfxop_usleep(gfx_state_t *state, long usecs); -/* Suspends program execution for the specified amount of microseconds -** Parameters: (gfx_state_t *) state: The state affected -** (long) usecs: The amount of microseconds to wait -** Returns : (int) GFX_OK or GFX_ERROR -** The mouse pointer will be redrawn continually, if applicable -*/ - -int gfxop_set_pointer_cursor(gfx_state_t *state, int nr); -/* Sets the mouse pointer to a cursor resource -** Parameters: (gfx_state_t *) state: The affected state -** (int) nr: Number of the cursor resource to use -** Returns : (int) GFX_OK, GFX_ERROR if the resource did not -** exist and was not GFXOP_NO_POINTER, or GFX_FATAL on -** fatal error conditions. -** Use nr = GFX_NO_POINTER to disable the mouse pointer (default). -*/ - -int gfxop_set_pointer_view(gfx_state_t *state, int nr, int loop, int cel, Common::Point *hotspot); -/* Sets the mouse pointer to a view resource -** Parameters: (gfx_state_t *) state: The affected state -** (int) nr: Number of the view resource to use -** (int) loop: View loop to use -** (int) cel: View cel to use -** (Common::Point *) hotspot: Manually set hotspot to use, or NULL for default. -** Returns : (int) GFX_OK or GFX_FATAL -** Use gfxop_set_pointer_cursor(state, GFXOP_NO_POINTER) to disable the -** pointer. -*/ - -int gfxop_set_pointer_position(gfx_state_t *state, Common::Point pos); -/* Teleports the mouse pointer to a specific position -** Parameters: (gfx_state_t *) state: The state the pointer is in -** (Common::Point) pos: The position to teleport it to -** Returns : (int) Any error code or GFX_OK -** Depending on the graphics driver, this operation may be without -** any effect -*/ - -sci_event_t gfxop_get_event(gfx_state_t *state, unsigned int mask); -/* Retreives the next input event from the driver -** Parameters: (gfx_state_t *) state: The affected state -** (int) mask: The event mask to poll from (see uinput.h) -** Returns : (sci_event_t) The next event in the driver's event queue, or -** a NONE event if no event matching the mask was found. -*/ - - -/*******************/ -/* View operations */ -/*******************/ - -int gfxop_lookup_view_get_loops(gfx_state_t *state, int nr); -/* Determines the number of loops associated with a view -** Parameters: (gfx_state_t *) state: The state to use -** (int) nr: Number of the view to investigate -** Returns : (int) The number of loops, or GFX_ERROR if the view didn't exist -*/ - -int gfxop_lookup_view_get_cels(gfx_state_t *state, int nr, int loop); -/* Determines the number of cels associated stored in a loop -** Parameters: (gfx_state_t *) state: The state to look up in -** (int) nr: Number of the view to look up in -** (int) loop: Number of the loop the number of cels of -** are to be investigated -** Returns : (int) The number of cels in that loop, or GFX_ERROR if either -** the view or the loop didn't exist -*/ - -int gfxop_check_cel(gfx_state_t *state, int nr, int *loop, int *cel); -/* Clips the view/loop/cel position of a cel -** Parameters: (gfx_state_t *) state: The state to use -** (int) nr: Number of the view to use -** (int *) loop: Pointer to the variable storing the loop -** number to verify -** (int *) cel: Pointer to the variable storing the cel -** number to check -** Returns : (int) GFX_OK or GFX_ERROR if the view didn't exist -** *loop is clipped first, then *cel. The resulting setup will be a valid -** view configuration. -*/ - -int gfxop_overflow_cel(gfx_state_t *state, int nr, int *loop, int *cel); -/* Resets loop/cel values to zero if they have become invalid -** Parameters: (gfx_state_t *) state: The state to use -** (int) nr: Number of the view to use -** (int *) loop: Pointer to the variable storing the loop -** number to verify -** (int *) cel: Pointer to the variable storing the cel -** number to check -** Returns : (int) GFX_OK or GFX_ERROR if the view didn't exist -** *loop is clipped first, then *cel. The resulting setup will be a valid -** view configuration. -*/ - -int gfxop_get_cel_parameters(gfx_state_t *state, int nr, int loop, int cel, - int *width, int *height, Common::Point *offset); -/* Retreives the width and height of a cel -** Parameters: (gfx_state_t *) state: The state to use -** (int) nr: Number of the view -** (int) loop: Loop number to examine -** (int) cel: The cel (inside the loop) to look up -** (int *) width: The variable the width will be stored in -** (int *) height: The variable the height will be stored in -** (Common::Point *) offset: The variable the cel's x/y offset will be stored in -** Returns : (int) GFX_OK if the lookup succeeded, GFX_ERROR if the nr/loop/cel -** combination was invalid -*/ - -int gfxop_draw_cel(gfx_state_t *state, int nr, int loop, int cel, Common::Point pos, - gfx_color_t color, int palette); -/* Draws (part of) a cel to the back buffer -** Parameters: (gfx_state_t *) state: The state encapsulating the driver to draw with -** (int) nr: Number of the view to draw -** (int) loop: Loop of the cel to draw -** (int) cel: The cel number of the cel to draw -** (Common::Point) pos: The positino the cel is to be drawn to -** (gfx_color_t color): The priority and control values to use for drawing -** (int) palette: The palette to use -** Returns : (int) GFX_OK or GFX_FATAL -*/ - - -int gfxop_draw_cel_static(gfx_state_t *state, int nr, int loop, int cel, Common::Point pos, - gfx_color_t color, int palette); -/* Draws a cel to the static buffer; no clipping is performed -** Parameters: (gfx_state_t *) state: The state encapsulating the driver to draw with -** (int) nr: Number of the view to draw -** (int) loop: Loop of the cel to draw -** (int) cel: The cel number of the cel to draw -** (Common::Point) pos: The positino the cel is to be drawn to -** (gfx_color_t color): The priority and control values to use for drawing -** (int) palette: The palette to use -** Returns : (int) GFX_OK or GFX_FATAL -** Let me repeat, no clipping (except for the display borders) is performed. -*/ - - -int gfxop_draw_cel_static_clipped(gfx_state_t *state, int nr, int loop, int cel, Common::Point pos, - gfx_color_t color, int palette); -/* Draws (part of) a clipped cel to the static buffer -** Parameters: (gfx_state_t *) state: The state encapsulating the driver to draw with -** (int) nr: Number of the view to draw -** (int) loop: Loop of the cel to draw -** (int) cel: The cel number of the cel to draw -** (Common::Point) pos: The positino the cel is to be drawn to -** (gfx_color_t color): The priority and control values to use for drawing -** (int) palette: The palette to use -** Returns : (int) GFX_OK or GFX_FATAL -** This function does clip. -*/ - - -/******************/ -/* Pic operations */ -/******************/ -/* These operations are exempt from clipping */ - -int gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette); -/* Draws a pic and writes it over the static buffer -** Parameters: (gfx_state_t *) state: The state affected -** (int) nr: Number of the pic to draw -** (int) flags: Interpreter-dependant flags to use for drawing -** (int) default_palette: The default palette for drawing -** Returns : (int) GFX_OK or GFX_FATAL -** This function instructs the resource manager to tag all data as "unused". -** See the resource manager tag functions for a full description. -*/ - -void *gfxop_get_pic_metainfo(gfx_state_t *state); -/* Retreives all meta-information assigned to the current pic -** Parameters: (gfx_state_t *) state: The state affected -** Returns : (void *) NULL if the pic doesn't exist or has no meta-information, -** the meta-info otherwise -** This meta-information is referred to as 'internal data' in the pic code -*/ - -int gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette); -/* Adds a pic to the static buffer -** Parameters: (gfx_state_t *) state: The state affected -** (int) nr: Number of the pic to add -** (int) flags: Interpreter-dependant flags to use for drawing -** (int) default_palette: The default palette for drawing -** Returns : (int) GFX_OK or GFX_FATAL -*/ - - - - -/*******************/ -/* Text operations */ -/*******************/ - - -int gfxop_get_font_height(gfx_state_t *state, int font_nr); -/* Returns the fixed line height for one specified font -** Parameters: (gfx_state_t *) state: The state to work on -** (int) font_nr: Number of the font to inspect -** Returns : (int) GFX_ERROR, GFX_FATAL, or the font line height -*/ - -int gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, - int maxwidth, int *width, int *height, int flags, - int *lines_nr, int *lineheight, int *lastline_width); -/* Calculates the width and height of a specified text in a specified font -** Parameters: (gfx_state_t *) state: The state to use -** (int) font_nr: Font number to use for the calculation -** (const char *) text: The text to examine -** (int) flags: ORred GFXR_FONT_FLAGs -** (int) maxwidth: The maximum pixel width to allow for the text -** Returns : (int) GFX_OK or GFX_ERROR if the font didn't exist -** (int) *width: The resulting width -** (int) *height: The resulting height -** (int) *lines_nr: Number of lines used in the text -** (int) *lineheight: Pixel height (SCI scale) of each text line -** (int) *lastline_wdith: Pixel offset (SCI scale) of the space -** after the last character in the last line -*/ - -gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, - gfx_alignment_t halign, gfx_alignment_t valign, - gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, - int flags); -/* Generates a new text handle that can be used to draw any text -** Parameters: (gfx_state_t *) state: The state to use -** (int) font_nr: Font number to use for the calculation -** (char *) text: The text to examine -** (int) maxwidth: The maximum pixel width to allow for the text -** (gfx_alignment_t) halign: The horizontal text alignment -** (gfx_alignment_t) valign: The vertical text alignment -** (gfx_color_t x gfx_color_t) color1, color2: The text's foreground colors -** (the function will dither between those two) -** (gfx_color_t) bg_color: The background color -** (int) flags: ORred GFXR_FONT_FLAGs -** Returns : (gfx_text_handle_t *) A newly allocated gfx_text_handle_t, or -** NULL if font_nr was invalid -** The control and priority values for the text will be extracted from color1. -** Note that the colors must have been allocated properly, or the text may display in -** incorrect colors. -*/ - -int gfxop_free_text(gfx_state_t *state, gfx_text_handle_t *handle); -/* Frees a previously allocated text handle and all related resources -** Parameters: (gfx_state_t *) state: The state to use -** (gfx_text_handle_t *) handle: The handle to free -** Returns : (int) GFX_OK -*/ - -int gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone); -/* Draws text stored in a text handle -** Parameters: (gfx_state_t *) state: The target state -** (gfx_text_handle_t *) handle: The text handle to use for drawing -** (rect_t) zone: The rectangular box to draw to. In combination with -** halign and valign, this defines where the text is -** drawn to. -** Returns : (int) GFX_OK or GFX_FATAL -*/ - - -/****************************/ -/* Manual pixmap operations */ -/****************************/ - -gfx_pixmap_t *gfxop_grab_pixmap(gfx_state_t *state, rect_t area); -/* Grabs a screen section from the back buffer and stores it in a pixmap -** Parameters: (gfx_state_t *) state: The affected state -** (rect_t) area: The area to grab -** Returns : (gfx_pixmap_t *) A result pixmap, or NULL on error -** Obviously, this only affects the visual map -*/ - -int gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos); -/* Draws part of a pixmap to the screen -** Parameters: (gfx_state_t *) state: The affected state -** (gfx_pixmap_t *) pxm: The pixmap to draw -** (rect_t) zone: The segment of the pixmap to draw -** (Common::Point) pos: The position the pixmap should be drawn to -** Returns : (int) GFX_OK or any error code -*/ - -int gfxop_free_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm); -/* Frees a pixmap returned by gfxop_grab_pixmap() -** Parameters: (gfx_state_t *) state: The affected state -** (gfx_pixmap_t *) pxm: The pixmap to free -** Returns : (int) GFX_OK, or GFX_ERROR if the state was invalid -*/ - -/******************************/ -/* Dirty rectangle operations */ -/******************************/ - -gfx_dirty_rect_t *gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy); -/* Adds a dirty rectangle to 'base' according to a strategy -** Parameters: (gfx_dirty_rect_t *) base: The base rectangle to add to, or NULL -** (rect_t) box: The dirty frame to add -** (int) strategy: The dirty frame heuristic to use (see gfx_options.h) -** Returns : (gfx_dirty_rect_t *) an appropriate singly-linked dirty rectangle -** result cluster -*/ - -int _gfxop_clip(rect_t *rect, rect_t clipzone); -/* Clips a rectangle against another one -** Parameters: (rect_t *) rect: The rectangle to clip -** (rect_t) clipzone: The outer bounds rect must be in -** Reuturns : (int) 1 if rect is empty now, 0 otherwise -*/ - -} // End of namespace Sci - -#endif // !_GFX_OPERATIONS_H_ diff --git a/engines/sci/include/gfx_options.h b/engines/sci/include/gfx_options.h deleted file mode 100644 index 45c5efdd5c..0000000000 --- a/engines/sci/include/gfx_options.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - - -#ifndef _GFX_OPTIONS_H_ -#define _GFX_OPTIONS_H_ - -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_tools.h" -#include "sci/include/gfx_res_options.h" - -namespace Sci { - -/* Dirty rectangle heuristics: */ - -/* One: Redraw one rectangle surrounding the dirty area (insert is O(1)) */ -#define GFXOP_DIRTY_FRAMES_ONE 1 - -/* Clusters: Accumulate dirty rects, merging those that overlap (insert is O(n)) */ -#define GFXOP_DIRTY_FRAMES_CLUSTERS 2 - - -typedef struct _gfx_options { - /* gfx_options_t: Contains all user options to the rendering pipeline */ - /* See note in sci_conf.h for config_entry_t before changing types of - ** variables */ - - int buffer_pics_nr; /* Number of unused pics to buffer */ - - int correct_rendering; /* Whether to render slow, but correct (rather than - ** fast and almost correct) */ - - /* SCI0 pic resource options */ - int pic0_unscaled; /* Don't draw scaled SCI0 pics */ - - int pic0_dither_mode; /* Defined in gfx_resource.h */ - int pic0_dither_pattern; /* Defined in gfx_resource.h */ - - gfx_brush_mode_t pic0_brush_mode; - gfx_line_mode_t pic0_line_mode; - - gfx_xlate_filter_t cursor_xlate_filter; - gfx_xlate_filter_t view_xlate_filter; - gfx_xlate_filter_t pic_xlate_filter; /* Only relevant if (pic0_unscaled) */ - gfx_xlate_filter_t text_xlate_filter; - gfxr_font_scale_filter_t fixed_font_xlate_filter; /* Scale filter for systems that provide font support which isn't scaled */ - - gfxr_antialiasing_t pic0_antialiasing; - - gfx_res_fullconf_t res_conf; /* Resource customisation: Per-resource palettes etc. */ - - int dirty_frames; - - int workarounds; /* Workaround flags- see below */ - - rect_t pic_port_bounds; -} gfx_options_t; - -/* SQ3 counts whitespaces towards the total text size, as does gfxop_get_text_params() if this is set: */ -#define GFX_WORKAROUND_WHITESPACE_COUNT (1 << 0) - -} // End of namespace Sci - -#endif // !_GFX_OPTIONS_H_ - diff --git a/engines/sci/include/gfx_res_options.h b/engines/sci/include/gfx_res_options.h deleted file mode 100644 index 7f857cbeeb..0000000000 --- a/engines/sci/include/gfx_res_options.h +++ /dev/null @@ -1,110 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Configuration options for per-resource customisations */ - -#ifndef _GFX_RES_OPTIONS_H_ -#define _GFX_RES_OPTIONS_H_ - -#include "sci/include/gfx_resource.h" -#include "sci/include/gfx_resmgr.h" - -namespace Sci { - -struct gfx_res_pattern_t { - int min, max; -}; - -/* GFX resource assignments */ - -typedef struct { - short type; /* GFX_RES_ASSIGN_TYPE_* */ - - union { - struct { - int colors_nr; - gfx_pixmap_color_t *colors; - } palette; - } assign; -} gfx_res_assign_t; - - -/* GFX resource modifications */ - -#define GFX_RES_MULTIPLY_FIXED 0 /* Linear palette update */ - -typedef struct { - short type; /* GFX_RES_ASSIGN_TYPE_* */ - - union { - byte factor[3]; /* divide by 16 to retrieve factor */ - } mod; -} gfx_res_mod_t; - - -typedef struct _gfx_res_conf { - int type; /* Resource type-- only one allowed */ - - /* If any of the following is 0, it means that there is no restriction. - ** Otherwise, one of the patterns associated with them must match. */ - int patterns_nr; /* Number of patterns (only 'view' patterns for views) */ - int loops_nr, cels_nr; /* Number of loop/cel patterns, for views only. - ** For pics, loops_nr identifies the palette. */ - - gfx_res_pattern_t *patterns; - - union { - gfx_res_assign_t assign; - gfx_res_mod_t mod; - } conf; /* The actual configuration */ - - struct _gfx_res_conf *next; -} gfx_res_conf_t; - - -typedef gfx_res_conf_t *gfx_res_conf_p_t; - -typedef struct { - gfx_res_conf_p_t assign[GFX_RESOURCE_TYPES_NR]; - gfx_res_conf_p_t mod[GFX_RESOURCE_TYPES_NR]; -} gfx_res_fullconf_t; - - -struct _gfx_options; - -int gfx_get_res_config(struct _gfx_options *options, - gfx_pixmap_t *pxm); -/* Configures a graphical pixmap according to config options -** Parameters: (gfx_options_t *) options: The options according to which -** configuration should be performed -** (gfx_resource_type_t) pxm: The pixmap to configure -** Returns : (int) 0 on success, non-zero otherwise -** Modifies pxm as considered appropriate by configuration options. Does -** not do anything in colour index mode. -*/ - -} // End of namespace Sci - -#endif /* !_GFX_RES_OPTIONS_H_ */ diff --git a/engines/sci/include/gfx_resmgr.h b/engines/sci/include/gfx_resmgr.h deleted file mode 100644 index 6ba34b8815..0000000000 --- a/engines/sci/include/gfx_resmgr.h +++ /dev/null @@ -1,338 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _GFX_RESMGR_H_ -#define _GFX_RESMGR_H_ - -// FIXME/TODO: The name "(Graphics) resource manager", and the associated -// filenames, are misleading. This should be renamed to "Graphics manager" -// or something like that. - -#include "sci/include/gfx_resource.h" -#include "sci/include/sbtree.h" - -namespace Sci { - -typedef enum { - GFX_RESOURCE_TYPE_VIEW = 0, - GFX_RESOURCE_TYPE_PIC, - GFX_RESOURCE_TYPE_FONT, - GFX_RESOURCE_TYPE_CURSOR, - GFX_RESOURCE_TYPE_PALETTE, - /* FIXME: Add PAL resource */ - - GFX_RESOURCE_TYPES_NR /* Number of resource types that are to be supported */ -} gfx_resource_type_t; - -#define GFX_RESOURCE_TYPE_0 GFX_RESOURCE_TYPE_VIEW - -#define GFXR_RES_ID(type, index) ((type) << 16 | (index)) -#define GFXR_RES_TYPE(id) (id >> 16) -#define GFXR_RES_NR(id) (id & 0xffff) - - -struct gfx_resource_t { - int ID; /* Resource ID */ - int lock_sequence_nr; /* See description of lock_counter in gfx_resstate_t */ - int mode; /* A mode type hash */ - - union { - gfx_pixmap_t *pointer; - gfxr_view_t *view; - gfx_bitmap_font_t *font; - gfxr_pic_t *pic; - } scaled_data; - - union { - gfx_pixmap_t *pointer; - gfxr_view_t *view; - gfx_bitmap_font_t *font; - gfxr_pic_t *pic; - } unscaled_data; - -}; - - -struct _gfx_options; - -typedef struct { - int version; /* Interpreter version */ - struct _gfx_options *options; - gfx_driver_t *driver; - gfx_pixmap_color_t *static_palette; - int static_palette_entries; - int lock_counter; /* Global lock counter; increased for each new resource allocated. - ** The newly allocated resource will then be assigned the new value - ** of the lock_counter, as will any resources referenced afterwards. - */ - int tag_lock_counter; /* lock counter value at tag time */ - - sbtree_t *resource_trees[GFX_RESOURCE_TYPES_NR]; - void *misc_payload; -} gfx_resstate_t; - - - -gfx_resstate_t *gfxr_new_resource_manager(int version, struct _gfx_options *options, - gfx_driver_t *driver, void *misc_payload); -/* Allocates and initializes a new resource manager -** Parameters: (int) version: Interpreter version -** (gfx_options_t *): Pointer to all relevant drawing options -** (gfx_driver_t *): The graphics driver (needed for capability flags and the mode -** structure) -** (void *) misc_payload: Additional information for the interpreter's -** resource loaders -** Returns : (gfx_resstate_t *): A newly allocated resource manager -** The options are considered to be read-only, as they belong to the overlying state object. -*/ - -void gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state); -/* Frees a previously allocated resource manager, and all allocated resources. -** Parameters: (gfx_driver_t *) driver: The graphics driver; used to free pixmaps that -** are installed in a driver-specific registry -** (gfx_resstate_t *) state: The state manager to free -** Return : (void) -*/ - -void gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state); -/* Frees all resources currently allocated -** Parameter: (gfx_driver_t *) driver: The driver to free with -** (gfx_resstate_t *) state: The state to do this on -** Returns : (void) -** This function is intended to be used primarily for debugging. -*/ - -void gfxr_tag_resources(gfx_resstate_t *state); -/* 'Tags' all resources for deletion -** Paramters: (gfx_resstate_t *) state: The resource state to modify -** Returns : (void) -** Tagged resources are untagged if they are referenced. -*/ - -void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state); -/* Frees all tagged resources. -** Parameters: (gfx_driver_t *) driver: The graphics driver the pixmaps are potentially -** registered in -** (gfx_resstate_t *) state: The state to alter -** Returns : (void) -** Resources are tagged by calling gfx_tag_resources(), and untagged by calling the -** approprate dereferenciation function. -** Note that this function currently only affects view resources, as pic resources are -** treated differently, while font and cursor resources are relatively rare. -*/ - - -gfxr_pic_t *gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, - int default_palette, int scaled); -/* Retreives a displayable (translated) pic resource -** Parameters: (gfx_resstate_t *) state: The resource state -** (int) nr: Number of the pic resource -** (int) maps: The maps to translate (ORred GFX_MASK_*) -** (int) flags: Interpreter-dependant pic flags -** (int) default_palette: The default palette to use for drawing (if applicable) -** (int) scaled: Whether to return the scaled maps, or the unscaled -** ones (which may be identical) for some special operations. -** Returns : (gfx_pic_t *) The appropriate pic resource with all maps as index (but not -** neccessarily translated) data. -*/ - -gfxr_pic_t *gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int maps, int flags, - int old_default_palette, int default_palette, int scaled); -/* Retreives a displayable (translated) pic resource written ontop of an existing pic -** Parameters: (gfx_resstate_t *) state: The resource state -** (int) old_nr: Number of the pic resource to write on -** (int) new_nr: Number of the pic resource that is to be added -** (int) maps: The maps to translate (ORred GFX_MASK_*) -** (int) flags: Interpreter-dependant pic flags -** (int) default_palette: The default palette to use for drawing (if applicable) -** (int) scaled: Whether to return the scaled maps, or the unscaled -** ones (which may be identical) for some special operations. -** Returns : (gfx_pic_t *) The appropriate pic resource with all maps as index (but not -** neccessarily translated) data. -** This function invalidates the cached pic pointed to by old_nr in the cache. While subsequent -** gfxr_add_to_pic() writes will still modify the 'invalidated' pic, gfxr_get_pic() operations will -** cause it to be removed from the cache and to be replaced by a clean version. -*/ - -gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, int palette); -/* Retreives a translated view cel -** Parameters: (gfx_resstate_t *) state: The resource state -** (int) nr: The view number -** (int *) loop: Pointer to a variable containing the loop number -** (int *) cel: Pointer to a variable containing the cel number -** (int) palette: The palette to use -** Returns : (gfx_view_t *) The relevant view, or NULL if nr was invalid -** loop and cel are given as pointers in order to allow the underlying variables to be -** modified if they are invalid (this is relevant for SCI version 0, where invalid -** loop and cel numbers have to be interpreted as 'maximum' or 'minimum' by the interpreter) -*/ - -gfx_bitmap_font_t *gfxr_get_font(gfx_resstate_t *state, int nr, int scaled); -/* Retreives a font -** Parameters: (gfx_resstate_t *) state: The relevant resource state -** (int) nr: The font number -** (int) scaled: Whether the font should be font-scaled -** Returns : (gfx_font_t *) The appropriate font, or NULL on error -*/ - -gfx_pixmap_t *gfxr_get_cursor(gfx_resstate_t *state, int nr); -/* Retreives an SCI0/SCI01 mouse cursor -** Parameters: (gfx_resstate_t *) state: The resource state -** (int) nr: The cursour number -** Returns : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error -*/ - -gfx_pixmap_color_t *gfxr_get_palette(gfx_resstate_t *state, int nr); -/* Retreives a palette -** Parameters: (gfx_resstate_t *) state: The resource state -** (int) nr: The cursour number -** Returns : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error -*/ - - -/* =========================== */ -/* Interpreter-dependant stuff */ -/* =========================== */ - - -int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, - struct _gfx_options *options, void *internal, int palette); -/* Calculates a unique hash value for the specified options/type setup -** Parameters: (gfx_resource_type_t) type: The type the hash is to be generated for -** (int) version: The interpreter type and version -** (gfx_options_t *) options: The options to hashify -** (void *) internal: Internal information provided by the interpreter -** (int) palette: The palette to use (FIXME: should this be here?) -** Returns : (int) A hash over the values of the options entries, covering entries iff -** they are relevant for the specified type -** Covering more entries than relevant may slow down the system when options are changed, -** while covering less may result in invalid cached data being used. -** Only positive values may be returned, as negative values are used internally by the generic -** resource manager code. -** Also, only the lower 20 bits are available to the interpreter. -** (Yes, this isn't really a "hash" in the traditional sense...) -*/ - -int *gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, - int version, int *entries_nr, void *internal); -/* Retreives all resources of a specified type that are available from the interpreter -** Parameters: (gfx_resstate_t *) state: The relevant resource state -** (gfx_respirce_type_t) type: The resource type to query -** (int) version: The interpreter type and version -** (int *) entries_nr: The variable the number of entries will eventually be stored in -** (void *) internal: Internal information provided by the interpreter -** Returns : (int *) An array of resource numbers -** Unsupported/non-existing resources should return NULL here; this is equivalent to supported -** resources of which zero are available. -** The returned structure (if non-zero) must be freed by the querying code (the resource manager). -*/ - -gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal); -/* Initializes a pic -** Parameters: (int) version: Interpreter version to use -** (gfx_mode_t *) mode: The graphics mode the pic will be using -** (int) ID: The ID to assign to the gfxr_pic_t structure -** (void *) internal: Internal information provided by the interpreter -** Returns : (gfxr_pic_t *) A newly allocated pic -** This function is typically called befode gfxr_interpreter_clear_pic(). -** Must remember to initialize 'internal' to NULL or a malloc()'d area. -*/ - -void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal); -/* Clears a previously allocated pic -** Parameters: (int) version: Interpreter version -** (gfxr_pic_t *) pic: The pic to clear -** (void *) internal: Internal information provided by the interpreter -** Returns : (void) -** This function is called in preparation for the pic to be drawn with gfxr_interpreter_calculate_pic. -*/ - -int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, - int flags, int default_palette, int nr, void *internal); -/* Instructs the interpreter-specific code to calculate a picture -** Parameters: (gfx_resstate_t *) state: The resource state, containing options and version information -** (gfxr_pic_t *) scaled_pic: The pic structure that is to be written to -** (gfxr_pic_t *) unscaled_pic: The pic structure the unscaled pic is to be written to, -** or NULL if it isn't needed. -** (int) flags: Pic drawing flags (interpreter dependant) -** (int) default_palette: The default palette to use for pic drawing (interpreter dependant) -** (int) nr: pic resource number -** (void *) internal: Internal information provided by the interpreter -** Returns : (int) GFX_ERROR if the resource could not be found, GFX_OK otherwise -*/ - -gfxr_view_t *gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette); -/* Instructs the interpreter-specific code to calculate a view -** Parameters: (gfx_resstate_t *) state: The resource manager state -** (int) nr: The view resource number -** (void *) internal: Internal information provided by the interpreter -** Returns : (gfx_view_t *) The appropriate view, or NULL on error -*/ - -gfx_bitmap_font_t *gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal); -/* Instructs the interpreter-specific code to calculate a font -** Parameters: (gfx_resstate_t *) state: The resource manager state -** (int) nr: The font resource number -** (void *) internal: Internal information provided by the interpreter -** Returns : (gfx_font_t *) The newly calculated font, or NULL on error -*/ - -gfx_pixmap_t *gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal); -/* Instructs the interpreter-specific code to calculate a cursor -** Paramaters: (gfx_resstate_t *) state: The resource manager state -** (int nr): The cursor resource number -** (void *) internal: Internal information provided by the interpreter -** Returns : (gfx_pixmap_t *) The cursor pixmap, or NULL on error -*/ - -gfx_pixmap_color_t *gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal); -/* Retreives the static palette from the interpreter-specific code -** Parameters: (int) version: Interpreter version to use -** (int *) colors_nr: Number of colors to use -** (void *) internal: Internal information provided by the interpreter -** Returns : (gfx_pixmap_color_t *) *colors_nr static color entries -** if a static palette must be used, NULL otherwise -*/ - -gfx_pixmap_color_t *gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr); -/* Retreives the static palette from the interpreter-specific code -** Parameters: (int) version: Interpreter version to use -** (int *) colors_nr: Number of colors to use -** (void *) internal: Internal information provided by the interpreter -** Returns : (gfx_pixmap_color_t *) *colors_nr static color entries -** if a static palette must be used, NULL otherwise -*/ - -int gfxr_interpreter_needs_multicolored_pointers(int version, void *internal); -/* Determines whether support for pointers with more than two colors is required -** Parameters: (int) version: Interpreter version to test for -** (void *) internal: Internal information provided by the interpreter -** Returns : (int) 0 if no support for multi-colored pointers is required, non-0 -** otherwise -*/ - -} // End of namespace Sci - -#endif /* !_GFX_RSMGR_H_ */ diff --git a/engines/sci/include/gfx_resource.h b/engines/sci/include/gfx_resource.h deleted file mode 100644 index d83e06b9c5..0000000000 --- a/engines/sci/include/gfx_resource.h +++ /dev/null @@ -1,414 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* SCI Resource library */ - -#ifndef _GFX_RESOURCE_H_ -#define _GFX_RESOURCE_H_ - -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_driver.h" - -namespace Sci { - -/*** Styles for pic0 drawing ***/ -/* Dithering modes */ -#define GFXR_DITHER_MODE_D16 0 /* Sierra SCI style */ -#define GFXR_DITHER_MODE_F256 1 /* Flat color interpolation */ -#define GFXR_DITHER_MODE_D256 2 /* 256 color dithering */ -/* Dithering patterns */ -#define GFXR_DITHER_PATTERN_SCALED 0 /* Dither per pixel on the 320x200 grid */ -#define GFXR_DITHER_PATTERN_1 1 /* Dither per pixel on the target */ - -#define SCI_TITLEBAR_SIZE 10 - -#define DRAWPIC01_FLAG_FILL_NORMALLY 1 -#define DRAWPIC01_FLAG_OVERLAID_PIC 2 - -#define GFXR_AUX_MAP_SIZE (320*200) - - -#define GFX_SCI0_IMAGE_COLORS_NR 16 -#define GFX_SCI0_PIC_COLORS_NR 256 - -#define GFX_SCI1_AMIGA_COLORS_NR 32 - -extern int sci0_palette; - -/* (gfx_pic_0.c) The 16 EGA base colors */ -extern gfx_pixmap_color_t gfx_sci0_image_colors[][16]; - -/* (gfx_pic_0.c) The 256 interpolated colors (initialized when -** gfxr_init_pic() is called for the first time, or when gfxr_init_static_palette() is called) -*/ -extern gfx_pixmap_color_t gfx_sci0_pic_colors[]; - - -typedef struct { - gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */ - gfx_brush_mode_t brush_mode; - rect_t pic_port_bounds; -} gfxr_pic0_params_t; - -typedef struct { - int ID; /* pic number (NOT resource ID, just number) */ - gfx_mode_t *mode; - gfx_pixmap_t *visual_map; - gfx_pixmap_t *priority_map; - gfx_pixmap_t *control_map; - - byte aux_map[GFXR_AUX_MAP_SIZE]; - - /* Auxiliary map details: - ** Bit 0: Vis - ** Bit 1: Pri - ** Bit 2: Ctrl - ** Bit 3-5: 'filled' (all three bits are set to 1) - */ - - rect_t bounds; - - void *undithered_buffer; /* copies visual_map->index_data before dithering */ - int undithered_buffer_size; - - void *internal; /* Interpreter information, or NULL. Will be freed - ** automatically when the pic is freed! */ - -} gfxr_pic_t; - - -typedef struct { - int cels_nr; - gfx_pixmap_t **cels; -} gfxr_loop_t; - - -typedef struct { - int ID; - - int flags; - int colors_nr; - gfx_pixmap_color_t *colors; - - int loops_nr; - gfxr_loop_t *loops; - - int translation[GFX_SCI0_IMAGE_COLORS_NR]; -} gfxr_view_t; - - -typedef enum { - GFXR_FONT_SCALE_FILTER_NONE -} gfxr_font_scale_filter_t; - - -typedef struct { - const char *offset; - int length; -} text_fragment_t; - -/* unscaled color index mode: Used in addition to a scaled mode -** to render the pic resource twice. See gfxr_remove_artifacts_pic0(). -*/ -extern gfx_mode_t mode_1x1_color_index; - -void gfxr_init_static_palette(); -/* Initializes the static 256 color palette -** Parameters: (void) -** Returns : (void) -*/ - -gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1); -/* Initializes a gfxr_pic_t for a specific mode -** Parameters: (gfx_mode_t *) mode: The specific graphics mode -** (int) ID: The ID to assign to the resulting pixmaps -** Returns : (gfxr_pic_t *) The allocated pic resource, or NULL on error. -** This function allocates memory for use by resource drawer functions. -*/ - -void gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic); -/* Uninitializes a pic resource -** Parameters: (gfx_driver_t *) driver: The driver the pic should be removed from -** (gfxr_pic_t *) pic: The pic to free -** Returns : (void) -*/ - -void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view); -/* Frees all memory associated with a view -** Paremeters: (gfx_driver_t *) driver: The driver the view should be removed from -** (gfxr_view_t *) view: The view to free -** Returns : (void) -*/ - - -/*******************/ -/* Font operations */ -/*******************/ -/* SCI0, SCI01 and SCI1 all use the same font format. */ - -/* SQ3 uses a somewhat different scheme for calculating text sizes: it counts -** whitespace while calculating the text size. */ -#define GFXR_FONT_FLAG_COUNT_WHITESPACE (1<<0) -/* Don't give newline characters special semantics */ -#define GFXR_FONT_FLAG_NO_NEWLINES (1<<1) -/* Interpret CR LF sequences as a single newline, rather than two of them */ -#define GFXR_FONT_FLAG_EAT_TRAILING_LF (1<<2) - - -gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size); -/* Geneartes a bitmap font data structure from a resource -** Parameters: (int) id: Resource ID of the resulting font -** (byte *) resource: Pointer to the resource data -** (int) size: Size of the resource block -** Returns : (gfx_bitmap_font_t *) The resulting font structure, or -** NULL on error -*/ - -void gfxr_free_font(gfx_bitmap_font_t *font); -/* Frees a previously allocated font structure -** Parameters: (gfx_bitmap_font_t *) font: The font to free -** Returns : (void) -*/ - -gfx_bitmap_font_t *gfxr_scale_font(gfx_bitmap_font_t *font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter); -/* Scales a font resource -** Parameters: (gfx_bitmap_font_t *) font: The font to scale -** (gfx_mode_t *) mode: The graphics mode to scale it for -** (gfxr_font_scale_filter_t) filter: A filter to use -** Returns : (gfx_bitmap_font_t *) A scaled font, or NULL on error -*/ - -text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text, - int *width, int *height, - int *lines, int *line_height, int *last_offset, - int flags); -/* Calculates the size that would be occupied by drawing a specified text -** Parameters: (gfx_bitmap_font_t *) font: The font to calculate with -** (int) max_width: Maximum pixel width allowed for the output -** (const char *) text: The text to calculate for -** (int) flags: Any text formatting flags -** Returns : (text_fragment *) a newly allocated array of text_fragments, -** containing the start and size of each string -** segment -** (int) *width: The resulting width -** (int) *height: The resulting height -** (int) *lines: Number of lines used -** (int) *line_height: Pixel height of a single line of text -** (int) *last_offset: Pixel offset after the last drawn line -** This function assumes 320x200 mode. -*/ - -gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *text, int characters, - gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg); -/* Draws text in a specific font to a pixmap -** Parameters: (gfx_bitmap_font_t *) font: The font to use for drawing -** (char *) text: The start of the text to draw -** (int) characters: The number of characters to draw -** (gfx_pixmap_color_t *) fg0: The first foreground color -** (gfx_pixmap_color_t *) fg1: The second foreground color -** (gfx_pixmap_color_t *) bg: The background color -** Returns : (gfx_pixmap_t *) The result pixmap, or NULL on error -** The results are written to the pixmap's index buffer. Contents of the -** foreground and background fields are copied into a newly allocated font -** structure, so that the pixmap may be translated directly. -** If any of the colors is null, it will be assumed to be transparent. -** In color index mode, the specified colors have to be preallocated. -*/ - - -/*********************/ -/* SCI0 operations */ -/*********************/ - - -void gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size); -/* Clears all pic buffers of one pic -** Parameters: (gfxr_pic_t) pic: The picture to clear -** (int) sci_titlebar_size: How much space to reserve for the title bar -** Returns : (void) -** This function should be called before gfxr_draw_pic0, unless cumulative -** drawing is intended -*/ - - -void gfxr_draw_pic01(gfxr_pic_t *pic, int fill_normally, int default_palette, - int size, byte *resource, gfxr_pic0_params_t *style, int resid, int sci1, - gfx_pixmap_color_t *static_pal, int static_pal_nr); -/* Draws a pic resource (all formats prior to SCI1.1) -** Parameters: (gfxr_pic_t *) pic: The pic to draw to -** (int) fill_normally: If 1, the pic is drawn normally; if 0, all -** fill operations will fill with black -** (int) default_palette: The default palette to use for drawing -** (int) size: Resource size -** (byte *) resource: Pointer to the resource data -** (gfxr_pic0_params_t *) style: The drawing style -** (int) resid: The resource ID -** (int) sci1: Nonzero if SCI1 -** (gfx_pixmap_color_t *) static_pal: The static palette -** (int) static_pal_nr: Number of entries in static palette -** Returns : (void) -** The result is stored in gfxr_visual_map, gfxr_priority_map, and gfxr_control_map. -** The palette entry of gfxr_visual_map is never used. -** Note that the picture will not be drawn dithered; use gfxr_dither_pic0 for that. -*/ - -void gfxr_draw_pic11(gfxr_pic_t *pic, int fill_normally, int default_palette, - int size, byte *resource, gfxr_pic0_params_t *style, int resid, - gfx_pixmap_color_t *static_pal, int static_pal_nr); -/* Draws a pic resource (SCI1.1) -** Parameters: (gfxr_pic_t *) pic: The pic to draw to -** (int) fill_normally: If 1, the pic is drawn normally; if 0, all -** fill operations will fill with black -** (int) default_palette: The default palette to use for drawing -** (int) size: Resource size -** (byte *) resource: Pointer to the resource data -** (gfxr_pic0_params_t *) style: The drawing style -** (int) resid: The resource ID -** (gfx_pixmap_color_t *) static_pal: The static palette -** (int) static_pal_nr: Number of entries in static palette -** Returns : (void) -** The result is stored in gfxr_visual_map, gfxr_priority_map, and gfxr_control_map. -** The palette entry of gfxr_visual_map is never used. -** Note that the picture will not be drawn dithered; use gfxr_dither_pic0 for that. -*/ - -void gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src); -/* Removes artifacts from a scaled pic -** Parameters: (gfxr_pic_t *) dest: The scaled pic -** (gfxr_pic_t *) src: An unscaled pic -** Returns : (void) -** Using information from the (correctly rendered) src pic, this function implements -** some heuristics to remove artifacts from dest. Must be used before dither_pic0 is -** called, because it operates on the index buffer. -*/ - -void gfxr_dither_pic0(gfxr_pic_t *pic, int mode, int pattern); -/* Dithers a gfxr_visual_map -** Parameters: (gfxr_pic_t *) pic: The pic to dither -** (int) mode: One of GFXR_DITHER_MODE -** (int) pattern: One of GFXR_DITHER_PATTERN -** Returns : (void) -*/ - -gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette); -/* Calculates an SCI0 view -** Parameters: (int) id: Resource ID of the view -** (byte *) resource: Pointer to the resource to read -** (int) size: Size of the resource -** (int) palette: The palette to use -** Returns : (gfxr_view_t *) The resulting view -*/ - -gfx_pixmap_t *gfxr_draw_cursor0(int id, byte *resource, int size); -/* Calculates an SCI0 cursor -** Parameters: (int) id: The cursor's resource ID -** (byte *) resource: Pointer to the resource data -** (int) size: Resource size -** Returns : (gfx_pixmap_t *) A newly allocated pixmap storing the cursor -*/ - -/**********************/ -/* SCI01 operations */ -/**********************/ - -gfx_pixmap_t *gfxr_draw_cursor01(int id, byte *resource, int size); -/* Calculates an SCI01 cursor -** Parameters: (int) id: The cursor's resource ID -** (byte *) resource: Pointer to the resource data -** (int) size: Resource size -** Returns : (gfx_pixmap_t *) A newly allocated pixmap containing an index -** color representation of the cursor -*/ - - -/*********************/ -/* SCI1 operations */ -/*********************/ - -gfx_pixmap_color_t *gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size); -/* Reads an SCI1 palette -** Parameters: (int) id: Resource ID for the palette (or the view it was found in) -** (int *) colors_nr: Pointer to the variable the number of colors -** will be stored in -** (byte *) resource: Source data -** (int) size: Size of the memory block pointed to by resource -** Returns : (gfx_pixmap_color_t *) *colors_nr color_t entries with the colors -*/ - -gfx_pixmap_color_t *gfxr_read_pal1_amiga(int *colors_nr, FILE *f); -/* Reads an SCI1 palette -** Parameters: (int *) colors_nr: Pointer to the variable the number of colors -** will be stored in -** (FILE *) f: Palette file -** Returns : (gfx_pixmap_color_t *) *colors_nr color_t entries with the colors -*/ - -gfx_pixmap_color_t *gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size); -/* Reads an SCI1.1 palette -** Parameters: (int) id: Resource ID for the palette (or the view it was found in) -** (int *) colors_nr: Pointer to the variable the number of colors -** will be stored in -** (byte *) resource: Source data -** (int) size: Size of the memory block pointed to by resource -** Returns : (gfx_pixmap_color_t *) *colors_nr color_t entries with the colors -*/ - -gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal, - int static_pal_nr); -/* Calculates an SCI1 view -** Parameters: (int) id: Resource ID of the view -** (byte *) resource: Pointer to the resource to read -** (int) size: Size of the resource -** (gfx_pixmap_color_t *) static_pal: The static palette -** (int) static_pal_nr: Number of entries in static palette -** Returns : (gfxr_view_t *) The resulting view -*/ - -gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view); - - -gfx_pixmap_t *gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode); -/* Endianness-adjusts a pixmap, if neccessary -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to adjust -** (gfx_mode_t *) mode: The mode to adjust it for -** Returns : (gfx_pixmap_t *) pixmap, or NULL on error -** The pixmap is adjusted iff the mode signals that this is -** required (by means of setting the appropriate flag), and -** the mode has a byte depth of more than 1. -*/ - - -static inline int get_uint_16(const byte *offset) { - return ((unsigned int) offset[0] | (((unsigned int) offset[1]) << 8)); -} - -static inline int get_int_16(const byte *offset) { - return ((int) offset[0] | (((int) offset[1]) << 8)); -} - -} // End of namespace Sci - -#endif /* !_GFX_RESOURCE_H_ */ - diff --git a/engines/sci/include/gfx_state_internal.h b/engines/sci/include/gfx_state_internal.h deleted file mode 100644 index f32c19988e..0000000000 --- a/engines/sci/include/gfx_state_internal.h +++ /dev/null @@ -1,239 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _GFX_STATE_INTERNAL_H_ -#define _GFX_STATE_INTERNAL_H_ - -#include "sci/include/gfx_tools.h" -#include "sci/include/gfx_options.h" -#include "sci/include/gfx_operations.h" -#include "sci/include/gfx_resmgr.h" -#include "sci/include/gfx_system.h" - -namespace Sci { - -#define GFXW_FLAG_VISIBLE (1<<0) -#define GFXW_FLAG_OPAQUE (1<<1) -#define GFXW_FLAG_CONTAINER (1<<2) -#define GFXW_FLAG_DIRTY (1<<3) -#define GFXW_FLAG_TAGGED (1<<4) -#define GFXW_FLAG_MULTI_ID (1<<5) /* Means that the ID used herein may be used more than once, i.e. is not unique */ -#define GFXW_FLAG_IMMUNE_TO_SNAPSHOTS (1<<6) /* Snapshot restoring doesn't kill this widget, and +5 bonus to saving throws vs. Death Magic */ -#define GFXW_FLAG_NO_IMPLICIT_SWITCH (1<<7) /* Ports: Don't implicitly switch to this port when disposing windows */ - -typedef struct { - int serial; /* The first serial number to kill */ - rect_t area; -} gfxw_snapshot_t; - -typedef enum { - GFXW_, /* Base widget */ - - GFXW_BOX, - GFXW_RECT, - GFXW_LINE, /* For lines, the bounding rectangle's xl, yl determine the line's expansion: - ** (x2, y2) = (x+xl, y+yl) */ - GFXW_INVERSE_LINE, - GFXW_VIEW, - GFXW_STATIC_VIEW, - GFXW_DYN_VIEW, - GFXW_PIC_VIEW, - GFXW_TEXT, - - GFXW_CONTAINER, - - GFXW_LIST, - GFXW_SORTED_LIST, - GFXW_VISUAL, - GFXW_PORT - -} gfxw_widget_type_t; - - -#define GFXW_MAGIC_VALID 0xC001 -#define GFXW_MAGIC_INVALID 0xbad - -#define GFXW_NO_ID -1 - -struct _gfxw_widget; -struct _gfxw_container_widget; -struct _gfxw_visual; - -typedef int gfxw_point_op(struct _gfxw_widget *, Common::Point); -typedef int gfxw_visual_op(struct _gfxw_widget *, struct _gfxw_visual *); -typedef int gfxw_op(struct _gfxw_widget *); -typedef int gfxw_op_int(struct _gfxw_widget *, int); -typedef int gfxw_bin_op(struct _gfxw_widget *, struct _gfxw_widget *); - -#define WIDGET_COMMON \ - int magic; /* Extra check after typecasting */ \ - int serial; /* Serial number */ \ - int flags; /* Widget flags */ \ - gfxw_widget_type_t type; \ - rect_t bounds; /* Boundaries */ \ - struct _gfxw_widget *next; /* Next widget in widget list */ \ - int ID; /* Unique ID or GFXW_NO_ID */ \ - int subID; /* A 'sub-ID', or GFXW_NO_ID */ \ - struct _gfxw_container_widget *parent; /* The parent widget, or NULL if not owned */ \ - struct _gfxw_visual *visual; /* The owner visual */ \ - int widget_priority; /* Drawing priority, or -1 */ \ - gfxw_point_op *draw; /* Draw widget (if dirty) and anything else required for the display to be consistant */ \ - gfxw_op *widfree; /* Remove widget (and any sub-widgets it may contain) */ \ - gfxw_op *tag; /* Tag the specified widget */ \ - gfxw_op_int *print; /* Prints the widget's contents, using sciprintf. Second parameter is indentation. */ \ - gfxw_bin_op *compare_to; /* a.compare_to(a, b) returns <0 if a0 if a>b */ \ - gfxw_bin_op *equals; /* a equals b if both cause the same data to be displayed */ \ - gfxw_bin_op *should_replace; /* (only if a equals b) Whether b should replace a even though they are equivalent */ \ - gfxw_bin_op *superarea_of; /* a superarea_of b <=> for each pixel of b there exists an opaque pixel in a at the same location */ \ - gfxw_visual_op *set_visual /* Sets the visual the widget belongs to */ - -typedef struct _gfxw_widget { - WIDGET_COMMON; -} gfxw_widget_t; - - -#define GFXW_IS_BOX(widget) ((widget)->type == GFXW_BOX) -typedef struct { - WIDGET_COMMON; - gfx_color_t color1, color2; - gfx_box_shade_t shade_type; -} gfxw_box_t; - - -#define GFXW_IS_PRIMITIVE(widget) ((widget)->type == GFXW_RECT || (widget)->type == GFXW_LINE || (widget->type == GFXW_INVERSE_LINE)) -typedef struct { - WIDGET_COMMON; - gfx_color_t color; - gfx_line_mode_t line_mode; - gfx_line_style_t line_style; -} gfxw_primitive_t; - - - -#define VIEW_COMMON \ - WIDGET_COMMON; \ - Common::Point pos; /* Implies the value of 'bounds' in WIDGET_COMMON */ \ - gfx_color_t color; \ - int view, loop, cel; \ - int palette - -#define GFXW_IS_VIEW(widget) ((widget)->type == GFXW_VIEW || (widget)->type == GFXW_STATIC_VIEW \ - || (widget)->type == GFXW_DYN_VIEW || (widget)->type == GFXW_PIC_VIEW) -typedef struct { - VIEW_COMMON; -} gfxw_view_t; - -#define GFXW_IS_DYN_VIEW(widget) ((widget)->type == GFXW_DYN_VIEW || (widget)->type == GFXW_PIC_VIEW) -typedef struct { - VIEW_COMMON; - /* fixme: This code is specific to SCI */ - rect_t draw_bounds; /* The correct position to draw to */ - void *under_bitsp, *signalp; - int under_bits, signal; - int z; /* The z coordinate: Added to y, but used for sorting */ - int sequence; /* Sequence number: For sorting */ - int force_precedence; /* Precedence enforcement variable for sorting- defaults to 0 */ -} gfxw_dyn_view_t; - - - -#define GFXW_IS_TEXT(widget) ((widget)->type == GFXW_TEXT) -typedef struct { - WIDGET_COMMON; - int font_nr; - int lines_nr, lineheight, lastline_width; - char *text; - gfx_alignment_t halign, valign; - gfx_color_t color1, color2, bgcolor; - int text_flags; - int width, height; /* Real text width and height */ - gfx_text_handle_t *text_handle; -} gfxw_text_t; - - -/* Container widgets */ - -typedef int gfxw_unary_container_op(struct _gfxw_container_widget *); -typedef int gfxw_container_op(struct _gfxw_container_widget *, gfxw_widget_t *); -typedef int gfxw_rect_op(struct _gfxw_container_widget *, rect_t, int); - -#define WIDGET_CONTAINER \ - WIDGET_COMMON; \ - rect_t zone; /* The writeable zone (absolute) for contained objects */ \ - gfx_dirty_rect_t *dirty; /* List of dirty rectangles */ \ - gfxw_widget_t *contents; \ - gfxw_widget_t **nextpp; /* Pointer to the 'next' pointer in the last entry in contents */ \ - gfxw_unary_container_op *free_tagged; /* Free all tagged contained widgets */ \ - gfxw_unary_container_op *free_contents; /* Free all contained widgets */ \ - gfxw_rect_op *add_dirty_abs; /* Add an absolute dirty rectangle */ \ - gfxw_rect_op *add_dirty_rel; /* Add a relative dirty rectangle */ \ - gfxw_container_op *add /* Append widget to an appropriate position (for view and control lists) */ - - -typedef struct _gfxw_container_widget { - WIDGET_CONTAINER; -} gfxw_container_t; - - -#define GFXW_IS_CONTAINER(widget) ((widget)->type == GFXW_PORT || (widget)->type == GFXW_VISUAL || \ - (widget)->type == GFXW_SORTED_LIST || (widget)->type == GFXW_LIST) - -#define GFXW_IS_LIST(widget) ((widget)->type == GFXW_LIST || (widget)->type == GFXW_SORTED_LIST) -#define GFXW_IS_SORTED_LIST(widget) ((widget)->type == GFXW_SORTED_LIST) -typedef gfxw_container_t gfxw_list_t; - -#define GFXW_IS_VISUAL(widget) ((widget)->type == GFXW_VISUAL) -typedef struct _gfxw_visual { - WIDGET_CONTAINER; - struct _gfxw_port **port_refs; /* References to ports */ - int port_refs_nr; - int font_nr; /* Default font */ - gfx_state_t *gfx_state; -} gfxw_visual_t; - -#define GFXW_IS_PORT(widget) ((widget)->type == GFXW_PORT) -typedef struct _gfxw_port { - WIDGET_CONTAINER; - - gfxw_list_t *decorations; /* optional window decorations- drawn before the contents */ - gfxw_widget_t *port_bg; /* Port background widget or NULL */ - gfx_color_t color, bgcolor; - int chrono_port; - int font_nr; - Common::Point draw_pos; /* Drawing position */ - gfxw_snapshot_t *restore_snap; /* Snapshot to be restored automagically, - experimental feature used in the PQ3 interpreter */ - int port_flags; /* interpreter-dependant flags */ - const char *title_text; - byte gray_text; /* Whether text is 'grayed out' (dithered) */ -} gfxw_port_t; - -#undef WIDGET_COMMON -#undef WIDGET_CONTAINER - -} // End of namespace Sci - -#endif /* !_GFX_STATE_INTERNAL_H_ */ - diff --git a/engines/sci/include/gfx_system.h b/engines/sci/include/gfx_system.h deleted file mode 100644 index 6aa2b98d2b..0000000000 --- a/engines/sci/include/gfx_system.h +++ /dev/null @@ -1,395 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _SCI_GFX_SYSTEM_ -#define _SCI_GFX_SYSTEM_ - -#include "common/scummsys.h" -#include "common/rect.h" -#include "sci/include/sci_memory.h" -#include "sci/tools.h" - -namespace Sci { - -#define GFX_DEBUG - -/* General output macros */ -# define GFXERROR gfxprintf("GFX Error: %s, L%d:", __FILE__, __LINE__); sciprintf -# define GFXWARN gfxprintf("GFX Warning: %s, L%d:", __FILE__, __LINE__); sciprintf -# ifdef GFX_DEBUG -# define GFXDEBUG gfxprintf("GFX-debug: %s, L%d:", __FILE__, __LINE__); sciprintf -# else /* !GFX_DEBUG */ -# define GFXDEBUG if (0) printf -# endif /* !GFX_DEBUG */ - -/***********************/ -/*** Data structures ***/ -/***********************/ - -#define GFX_COLOR_SYSTEM -1 - - -/** Palette color description */ -struct gfx_palette_color_t { - - int lockers; /* Number of pixmaps holding a lock on that color. - ** 0 means that the color is unused, -1 means that it is - ** "system allocated" and may not be freed. */ - byte r, g, b; /* Red, green, blue; intensity varies from 0 (min) to 255 (max) */ - -}; - -/** Palette description for color index modes */ -struct gfx_palette_t{ - - int max_colors_nr; /* Maximum number of allocated colors */ - gfx_palette_color_t *colors; /* Actual colors, malloc()d as a block */ -}; - - - -#define GFX_MODE_IS_UNSCALED(mode) (((mode)->xfact == 1) && ((mode)->yfact == 1)) - -/* Reverse-endian: Target display has non-native endianness -** (BE if local is LE or the other way 'round */ -#define GFX_MODE_FLAG_REVERSE_ENDIAN (1<<0) -/* Reverse Alpha: Alpha values 0 mean "transparent" if this is -** enabled */ -#define GFX_MODE_FLAG_REVERSE_ALPHA (1<<1) - -/** Graphics mode description */ -struct gfx_mode_t { - - int xfact, yfact; /* Horizontal and vertical scaling factors */ - int bytespp; /* Bytes per pixel */ - - unsigned int flags; /* GFX_MODE_FLAG_* Flags- see above */ - - - gfx_palette_t *palette; /* Palette or NULL to indicate non-palette mode. - ** Palette (color-index) mode is only supported - ** for bytespp=1. */ - - /* Color masks */ - unsigned int red_mask, green_mask, blue_mask, alpha_mask; - short red_shift, green_shift, blue_shift, alpha_shift; - - /* Each of the mask/shift pairs describe where the corresponding color - ** values are stored for the described mode. Internally, color - ** calculations are done by using 32 bit values for r, g, b, a. After - ** the internal values have been calculated, they are shifted RIGHT - ** by the xxx_shift amount described above, then ANDed with the - ** corresponding color mask; finally, all three results are ORred to- - ** gether. The alpha values are used as appropriate; if alpha_mask is - ** zero, then images use a special alpha map. */ - -}; - - - -#define GFX_COLOR_INDEX_UNMAPPED -1 - -/** Pixmap-specific color entries */ -struct gfx_pixmap_color_t{ - int global_index; /* Global index color or GFX_COLOR_INDEX_UNMAPPED. */ - guint8 r, g, b; /* Real color */ -}; - -/** Full color */ -struct gfx_color_t { - gfx_pixmap_color_t visual; - guint8 alpha; /* transparency = (1-opacity) */ - signed char priority, control; - byte mask; /* see mask values below */ -}; - - -/** Rectangle description */ -struct rect_t{ - int x, y; - int xl, yl; /* width, height: (x,y,xl,yl)=(5,5,1,1) occupies 1 pixel */ -}; - - -/* Generates a rect_t from index data -** Parameters: (int x int) x,y: Upper left point of the rectangle -** (int x int) xl, yl: Horizontal and vertical extension of the rectangle -** Returns : (rect_t) A rectangle matching the supplied parameters -*/ -static inline rect_t gfx_rect(int x, int y, int xl, int yl) { - rect_t rect; - - rect.x = x; - rect.y = y; - rect.xl = xl; - rect.yl = yl; - - return rect; -} - -#define GFX_PRINT_RECT(rect) (rect).x, (rect).y, (rect).xl, (rect).yl - -#define OVERLAP(a, b, z, zl) (a.z >= b.z && a.z < (b.z + b.zl)) - -/* Determines whether two rects overlap -** Parameters: (rect_t x rect_t) a,b: The two rect_ts to check for overlap -** Returns : (int) 1 if they overlap, 0 otherwise -*/ -static inline int gfx_rects_overlap(rect_t a, rect_t b) { - return (OVERLAP(a, b, x, xl) || OVERLAP(b, a, x, xl)) && (OVERLAP(a, b, y, yl) || OVERLAP(b, a, y, yl)); -} - -#undef OVERLAP - -#define MERGE_PARTIAL(z, zl) \ -if (a.z < b.z) SUBMERGE_PARTIAL(a, b, z, zl) \ -else SUBMERGE_PARTIAL(b, a, z, zl) - -#define SUBMERGE_PARTIAL(a, b, z, zl) \ -{ \ - retval.z = a.z; \ - retval.zl = a.zl; \ - if (b.z + b.zl > a.z + a.zl) \ - retval.zl = (b.z + b.zl - a.z); \ -} - - - -#define RECT(a) a.x, a.y, a.xl, a.yl - -/* Merges two rects -** Parameters: (rect_t x rect_t) a,b: The two rects to merge -** Returns : (rect_t) The smallest rect containing both a and b -*/ -static inline rect_t gfx_rects_merge(rect_t a, rect_t b) { - rect_t retval; - MERGE_PARTIAL(x, xl); - MERGE_PARTIAL(y, yl); - return retval; -} -#undef MERGE_PARTIAL -#undef SUBMERGE_PARTIAL - - -/* Subset predicate for rectangles -** Parameters: (rect_t) a, b: The two rects to compare -** Returns : non-zero iff for each pixel p in a the following holds: p is in b. -*/ -static inline int gfx_rect_subset(rect_t a, rect_t b) { - return ((a.x >= b.x) && (a.y >= b.y) && ((a.x + a.xl) <= (b.x + b.xl)) && ((a.y + a.yl) <= (b.y + b.yl))); -} - - -/* Equality predicate for rects -** Parameters: (rect_t) a, b -** Returns : (int) gfx_rect_subset(a,b) AND gfx_rect_subset(b,a) -*/ -static inline int gfx_rect_equals(rect_t a, rect_t b) { - return (a.x == b.x && a.xl == b.xl && a.y == b.y && a.yl == b.yl); -} - - -/* gfx_rect_fullscreen is declared in gfx/gfx_tools.c */ -extern rect_t gfx_rect_fullscreen; - -/* Translation operation for rects -** Parameters: (rect_t) rect: The rect to translate -** (Common::Point) offset: The offset to translate it by -** Returns : (rect_t) The translated rect -*/ -static inline rect_t gfx_rect_translate(rect_t rect, Common::Point offset) { - rect.x += offset.x; - rect.y += offset.y; - - return rect; -} - -#define GFX_RESID_NONE -1 - -#define GFX_PIC_COLORS 256 - -#define GFX_PIXMAP_FLAG_SCALED_INDEX (1<<0) /* Index data is scaled already */ -#define GFX_PIXMAP_FLAG_EXTERNAL_PALETTE (1<<1) /* The colors pointer points to an external palette */ -#define GFX_PIXMAP_FLAG_INSTALLED (1<<2) /* Pixmap has been registered */ -#define GFX_PIXMAP_FLAG_PALETTE_ALLOCATED (1<<3) /* Palette has been allocated */ -#define GFX_PIXMAP_FLAG_PALETTE_SET (1<<4) /* Palette has been propagated to the driver */ -#define GFX_PIXMAP_FLAG_DONT_UNALLOCATE_PALETTE (1<<5) /* Used by text, which uses preallocated colors */ -#define GFX_PIXMAP_FLAG_PALETTIZED (1<<6) /* Indicates a palettized view */ - -#define GFX_PIXMAP_COLOR_KEY_NONE -1 /* No transpacency colour key */ - -typedef struct { /* gfx_pixmap_t: Pixel map */ - - /*** Meta information ***/ - int ID; /* Resource ID, or GFX_RESID_NONE for anonymous graphical data */ - short loop, cel; /* loop and cel number for views */ - - - /*** Color map ***/ - int colors_nr; - gfx_pixmap_color_t *colors; /* colors_nr color entries, or NULL if the - ** default palette is to be used. - ** A maximum of 255 colors is allowed; color - ** index 0xff is reserved for transparency. - ** As a special exception, 256 colors are - ** allowed for background pictures (which do - ** not use transparency) - */ - unsigned int flags; - - /*** Hot spot ***/ - int xoffset, yoffset; /* x and y coordinates of the 'hot spot' (unscaled) */ - - /*** Index data ***/ - int index_xl, index_yl; /* width and height of the indexed original image */ - byte *index_data; /* Color-index data, or NULL if read from an - ** external source - */ - - /*** Drawable data ***/ - int xl, yl; /* width and height of the actual image */ - int data_size; /* Amount of allocated memory */ - byte *data; /* Drawable data, or NULL if not converted. */ - - byte *alpha_map; /* Byte map with alpha values. It is used only if the - ** graphics mode's alpha_mask is zero. - */ - - int color_key; - - /*** Data reserved for gfx_driver use ***/ - struct pixmap_internal { /* Internal state management data for use by drivers */ - int handle; /* initialized to 0 */ - void *info; /* initialized to NULL */ - } internal; - -} gfx_pixmap_t; - - -#define GFX_FONT_BUILTIN_5x8 -1 -#define GFX_FONT_BUILTIN_6x10 -2 - -typedef struct { /* gfx_bitmap_font_t: Bitmap font information */ - int ID; /* Unique resource ID */ - - int chars_nr; /* Numer of available characters */ - - int *widths; /* chars_nr character widths, in pixels */ - - int row_size; /* Byte size of each pixel row. For unscaled fonts, this is - ** always 1, 2, or 4. Otherwise, it's a multiple of 4. - */ - - int line_height; /* Height of each text line (usually identical to height) */ - int height; /* Height for all characters, in pixel rows */ - int char_size; /* Amount of memory occupied by one character in data */ - - byte *data; /* Font data, consisting of 'chars_nr' entries of 'height' rows - ** of 'row_size' bytes. For each character ch, its first byte - ** (the topmost row) is located at (data + (charsize * ch)), and - ** its pixel width is widths[ch], provided that (ch < chars_nr). - */ - -} gfx_bitmap_font_t; - - - -/***********************/ -/*** Constant values ***/ -/***********************/ - -/* Default palettes */ -extern gfx_pixmap_color_t gfx_sci0_image_colors[][16]; -extern gfx_pixmap_color_t gfx_sci0_pic_colors[256]; - -/* Return values */ -enum gfx_return_value_t { - GFX_OK = 0, /* Indicates "operation successful" */ - GFX_ERROR = -1, /* Indicates "operation failed" */ - GFX_FATAL = -2 - /* Fatal error: Used by graphics drivers to indicate that they were unable to - ** do anything useful - */ -}; - - -typedef enum {/* Map masks */ - GFX_MASK_NONE = 0, - GFX_MASK_VISUAL = 1, - GFX_MASK_PRIORITY = 2, - GFX_MASK_CONTROL = 4 -} gfx_map_mask_t; - -/* 'no priority' mode */ -#define GFX_NO_PRIORITY -1 - -/* Text alignment values */ - -typedef enum { - ALIGN_RIGHT = -1, - ALIGN_TOP = -1, - ALIGN_CENTER = 1, - ALIGN_LEFT = 0, - ALIGN_BOTTOM = 0 -} gfx_alignment_t; - - -typedef enum { - GFX_LINE_MODE_CORRECT, /* Scaled separately */ - GFX_LINE_MODE_FAST, /* Scaled by (xfact+yfact)/2 */ - GFX_LINE_MODE_FINE /* Always drawn at width 1 */ -} gfx_line_mode_t; - -typedef enum { - GFX_BRUSH_MODE_SCALED, /* Just scale the brush pixels */ - GFX_BRUSH_MODE_ELLIPSES, /* Replace pixels with ellipses */ - GFX_BRUSH_MODE_RANDOM_ELLIPSES, /* Replace pixels with ellipses moved and re-scaled randomly */ - GFX_BRUSH_MODE_MORERANDOM /* Distribute randomly */ -} gfx_brush_mode_t; - - -typedef enum { - GFX_LINE_STYLE_NORMAL, - GFX_LINE_STYLE_STIPPLED -} gfx_line_style_t; - - -typedef enum { - GFX_SHADE_FLAT, /* Don't shade */ - GFX_SHADE_VERTICALLY, /* Shade vertically */ - GFX_SHADE_HORIZONTALLY /* Shade horizontally */ -} gfx_rectangle_fill_t; - - -typedef enum { - GFX_COLOR_MODE_AUTO = 0, /* Auto-detect- handled by the gfxop library */ - GFX_COLOR_MODE_INDEX = 1, /* Index mode */ - GFX_COLOR_MODE_HIGH = 2, /* High color mode (15bpp or 16 bpp) */ - GFX_COLOR_MODE_TRUE = 4 /* True color mode (24 bpp padded to 32 bpp) */ -} gfx_color_mode_t; - -} // End of namespace Sci - -#endif /* !_SCI_GFX_SYSTEM_ */ diff --git a/engines/sci/include/gfx_tools.h b/engines/sci/include/gfx_tools.h deleted file mode 100644 index 09fdc3891d..0000000000 --- a/engines/sci/include/gfx_tools.h +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* FreeSCI 0.3.1+ graphics subsystem helper functions */ - - -#ifndef _GFX_TOOLS_H_ -#define _GFX_TOOLS_H_ - -#include "sci/include/gfx_system.h" -#include "sci/include/gfx_driver.h" - -namespace Sci { - -typedef enum { - GFX_XLATE_FILTER_NONE, - GFX_XLATE_FILTER_LINEAR, - GFX_XLATE_FILTER_TRILINEAR -} gfx_xlate_filter_t; - -typedef enum { - GFXR_ANTIALIASING_NONE, - GFXR_ANTIALIASING_SIMPLE -} gfxr_antialiasing_t; - - -extern int gfx_crossblit_alpha_threshold; /* Crossblitting functions use this value as threshold - ** for distinguishing between transparent and opaque - ** wrt alpha values */ - -gfx_mode_t *gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask, - unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift, - int blue_shift, int alpha_shift, int palette, int flags); -/* Allocates a new gfx_mode_t structure with the specified parameters -** Parameters: (int x int) xfact x yfact: Horizontal and vertical scaling factors -** (int) bytespp: Bytes per pixel -** (unsigned int) red_mask: Red bit mask -** (unsigned int) green_mask: Green bit mask -** (unsigned int) blue_mask: Blue bit mask -** (unsigned int) Alpha_mask: Alpha bit mask, or 0 if the alpha channel is not supported -** (int) red_shift: Red shift value -** (int) green_shift: Green shift value -** (int) blue_shift: Blue shift value -** (int) alpha_shift: Alpha shift value -** (int) palette: Number of palette colors, 0 if we're not in palette mode -** (int) flags: GFX_MODE_FLAG_* values ORred together, or just 0 -** Returns : (gfx_mode_t *) A newly allocated gfx_mode_t structure -*/ - - -void gfx_clip_box_basic(rect_t *box, int maxx, int maxy); -/* Clips a rect_t -** Parameters: (rect_t *) box: Pointer to the box to clip -** (int x int) maxx, maxy: Maximum allowed width and height -** Returns : (void) -*/ - - -void gfx_free_mode(gfx_mode_t *mode); -/* Frees all memory allocated by a mode structure -** Parameters: (gfx_mode_t *) mode: The mode to free -** Returns : (void) -*/ - - -gfx_pixmap_t *gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel); -/* Creates a new pixmap structure -** Parameters: (int x int) xl x yl: The dimensions (in SCI coordinates) of the pixmap -** (int) resid: The pixmap's resource ID, or GFX_RESID_NONE -** (int) loop: For views: The pixmap's loop number -** (int) cel: For cels: The pixmap's cel number -** Returns : (gfx_pixmap_t *) The newly allocated pixmap -** The following fiels are initialized: -** ID, loop, cel, index_xl, index_yl, xl, yl, data <- NULL, -** alpha_map <- NULL, internal.handle <- 0, internal.info <- NULL, colors <- NULL, -** index_scaled <- 0 -*/ - -gfx_pixmap_t *gfx_clone_pixmap(gfx_pixmap_t *pixmap, gfx_mode_t *mode); -/* Clones a pixmap, minus its index data, palette and driver-specific handles -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to clone -** (gfx_mode_t *) mode: The mode to be applied to the pixmap -** Returns : (gfx_pixmap_t *) The clone -*/ - - -gfx_pixmap_t *gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap); -/* Allocates the index_data field of a pixmap -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to allocate for -** Returns : (gfx_pixmap_t *) pixmap -*/ - -gfx_pixmap_t *gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap); -/* Frees the index_data field of a pixmap -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to modify -** Returns : (gfx_pixmap_t *) pixmap -*/ - -gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode); -/* Allocates the data field of a pixmap -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to allocate for -** (gfx_mode_t *) mode: The mode the memory is to be allocated for -** Returns : (gfx_pixmap_t *) pixmap -*/ - -gfx_pixmap_t *gfx_pixmap_free_data(gfx_pixmap_t *pixmap); -/* Frees the memory allocated for a pixmap's data field -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to modify -** Returns : (gfx_pixmap_t *) pixmap -*/ - -void gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm); -/* Frees all memory associated with a pixmap -** Parameters: (gfx_driver_t *) driver: The driver the pixmap is to be removed from -** (gfx_pixmap_t *) pxm: The pixmap to free -** Returns : (void) -*/ - -void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color); -/* Draws a line to a pixmap's index data buffer -** Parameters: (gfx_pixmap_t *) pxm: The pixmap to draw to -** (Common::Point) start: Starting point of the line to draw -** (Common::Point) end: End point of the line to draw -** (int) color: The byte value to write -** Returns : (void) -** Remember, this only draws to the /index/ buffer, not to the drawable buffer. -** The line is not clipped. Invalid x, y, x1, y1 values will result in memory corruption. -*/ - -void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, - Common::Point start, Common::Point end, unsigned int color); -/* Draws a line to a linear pixel buffer -** Parameters: (byte *) buffer: Pointer to the start of the buffer to draw to -** (int) linewidth: Number of bytes per pixel line in the buffer -** (int) pixelwidth: Number of bytes per pixel -** (Common::Point) start: Starting point of the line to draw -** (Common::Point) end: End point of the line to draw -** (rect_t) Coordinates: the line should be drawn to (must be clipped already) -** xl and yl describe relative offsets, as usual. -** (unsigned int) color: The color to draw (only the lowest 8 * pixelwidth bits are relevant) -** Returns : (void) -** This function assumes 1 <= pixelwidth <= 4 -*/ - -void gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color); -/* Draws a filled rectangular area to a pixmap's index buffer -** Parameters: (gfx_pixmap_t *) pxm: The pixmap to draw to -** (rect_t) box: The box to fill -** (int) color: The color to use for drawing -** Returns : (void) -** This function only draws to the index buffer. -*/ - -void gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box); -/* Copies part of a pixmap to another pixmap, with clipping -** Parameters: (gfx_pixmap_t *) dest: The destination pixmap -** (gfx_pixmap_t *) src: The source pixmap -** (rect_t) box: The area to copy -** Returns : (void) -*/ - -void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter); -/* Translates a pixmap's index data to drawable graphics data -** Parameters: (gfx_pixmap_t *) pxm: The pixmap to translate -** (gfx_mode_t *) mode: The mode according which to scale -** (gfx_xlate_filter_t) filter: How to filter the data -** Returns : (void) -*/ - -void gfxr_antialiase(gfx_pixmap_t *pixmap, gfx_mode_t *mode, gfxr_antialiasing_t type); -/* Performs antialiasing on a pixmap -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to antialiase -** (gfx_mode_t *) mode: The current mode -** (gfxr_antialiasing_t) type: Antialiasing algorithm to use -** Returns : (void) -*/ - -#define GFX_CROSSBLIT_FLAG_DATA_IS_HOMED (1<<0) -/* Means that the first byte in the visual data refers to the -** point corresponding to (dest.x, dest.y) */ - -int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, - rect_t src_coords, rect_t dest_coords, byte *dest, - int dest_line_width, byte *priority_dest, - int priority_line_width, int priority_skip, - int flags); -/* Transfers the non-transparent part of a pixmap to a linear pixel buffer -** Parameters: (gfx_mode_t *) mode: The graphics mode of the target buffer -** (gfx_pixmap_t *) pxm: The pixmap to transfer -** (int priority): The pixmap's priority -** (rect_t) src_coords: The source coordinates within the pixmap -** (rect_t) dest_coords: The destination coordinates (no scaling) -** (byte *) dest: Memory position of the upper left pixel of the -** linear pixel buffer -** (int) dest_line_width: Byte offset of the very first pixel in the -** second line of the linear pixel buffer, -** relative to dest. -** (byte *) priority_dest: Destination buffer for the pixmap's priority -** values -** (int) priority_line_width: Byte offset of the first pixel in the -** second line of the priority buffer -** (int) priority_skip: Amount of bytes allocated by each priority value -** (int) flags: Any crossblit flags -** Returns : (int) GFX_OK, or GFX_ERROR if the specified mode was invalid or unsupported -** A 'linear buffer' in this context means a data buffer containing an entire -** screen (visual or priority), with fixed offsets between each data row, and -** linear access. -*/ - -int gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color); -/* Allocates a color entry for the specified pixmap color -** Parameters: (gfx_palette_t *) pal: The palette structure the color should be allocated in -** (gfx_pixmap_color_t *) color: The color to allocate -** Returns : (int) GFX_ERROR if any error occured, GFX_OK if the color could be mapped to an -** existing color or a positive value if a new color was allocated in the -** palette. -*/ - -int gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color); -/* Frees the color entry allocated for the specified pixmap color -** Parameters: (gfx_palette_t *) pal: The palette structure the color was previously allocated in -** (gfx_pixmap_color_t *) color: The color to free -** Returns : (int) GFX_ERROR if any error occured, GFX_OK otherwise -*/ - -gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode); -/* Scales the index data associated with a pixmap -** Parameters: (gfx_pixmap_t *) pixmap: The pixmap whose index data should be scaled -** (gfx_mode_t *) mode: The mode to scale it to -** Returns : (gfx_pixmap_t *) pixmap -*/ - -} // End of namespace Sci - -#endif /* !_GFX_TOOLS_H_ */ diff --git a/engines/sci/include/gfx_widgets.h b/engines/sci/include/gfx_widgets.h deleted file mode 100644 index 9f365a9959..0000000000 --- a/engines/sci/include/gfx_widgets.h +++ /dev/null @@ -1,520 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Graphical state management */ - -#ifndef _GFX_WIDGETS_H_ -#define _GFX_WIDGETS_H_ - -#include "sci/include/gfx_state_internal.h" - -namespace Sci { - -/* Enable the next line to keep a list of pointers to all widgets, with up to the specified amount -** of members (/SLOW/) */ -/* #define GFXW_DEBUG_WIDGETS 2048 */ - -/* Our strategy for dirty rectangle management */ -#define GFXW_DIRTY_STRATEGY GFXOP_DIRTY_FRAMES_CLUSTERS - -/* Properly belongs in sci_widgets.h, but we need it here */ -#define WINDOW_FLAG_AUTO_RESTORE 0x2000000 - -/* Indicates that a Chrono-Port should not be created even if it doesn't exist. */ -#define GFXW_CHRONO_NO_CREATE 1 - -/* Indicates that non-topmost ports should be scanned for a Chrono-Port. */ -#define GFXW_CHRONO_NON_TOPMOST 2 - -/* Terminology -** -** Two special terms are used in here: /equivalent/ and /clear/. Their meanings -** in this context are as follows: -** -** /clear/: Clearing a widget means overwriting the space it occupies in the back -** buffer with data from the static buffer. This affects both the visual and the -** priority buffer, the static buffer (and any effect the widget may have had on -** it) is not touched. -** -** /equivalent/: Two Widgets A and B are equivalent if and only if either of the -** following conditions is met: -** a) Both A and B are text widgets, and they occupy the same bounding rectangle. -** b) Both A and B are dynview widgets, and they have the same unique ID -** Note that /equivalent/ is not really an equivalence relation- while it is ob- -** viously transitive and symmetrical, it is not reflexive (e.g. a box widget -** is not /equivalent/ to itself), although this might be a nice addition for the -** future. -*/ - - -/*********************************/ -/* Fundamental widget operations */ -/*********************************/ - - -#define GFXW(foo) ((gfxw_widget_t *) foo) -/* Typecast an arbitrary widget to gfxw_widget_t*. Might eventually be changed to do tests as well. */ - -#define GFXWC(foo) ((gfxw_container_t *) foo) -/* Typecasts a container widget to gfxw_container_widget_t *. */ - -/* gfxw_point_zero is declared in gfx/widgets.c */ -extern Common::Point gfxw_point_zero; - -/*********************/ -/* Widget operations */ -/*********************/ - -/* These are for documentation purposes only. The actual declarations are in -** gfx_state_internal.h. -** -** -** -** -- draw(gfxw_widget_t *self, Common::Point pos) -** Draws the widget. -** Parameters: (gfxw_widget_t *) self: self reference -** (Common::Point) pos: The position to draw to (added to the widget's -** internal position) -** Returns : (int) 0 -** The widget is drawn iff it is flagged as dirty. Invoking this operation on -** a container widget will recursively draw all of its contents. -** -** -** -- widfree(gfxw_widget_t *self) -** Frees all memory associated to the widget -** Parameters: (gfxw_widget_t *) self: self reference -** Returns : (int) 0 -** The widget automatically removes itself from its owner, if it has one. -** Invoking this operation on a container will recursively free all of its -** contents. -** -** -** -- tag(gfxw_widget_t *self) -** Tags the specified widget -** Parameters: (gfxw_widget_t *) self: self reference -** Returns : (int) 0 -** If invoked on a container widget, this will also tag all of the container's -** contents (but not the contents' contents!) -** -** -** -- print(gfxw_widget_t *self, int indentation) -** Prints a string representation of the widget with sciprintf -** Parameters: (gfxw_widget_t *) self: self reference -** (int) indentation: Number of double spaces to indent -** Returns ; (int) 0 -** Will recursively print all of the widget's contents if the widget contains -** further sub-widgets -** -** -** -- compare_to(gfxw_widget_t *self, gfxw_widget_t *other) -** Compares two compareable widgets by their screen position -** Parameters: (gfxw_widget_t *) self: self reference -** (gfxw_widget_t *) other: other widget -** Returns : (int) <0, 0, or >0 if other is, respectively, less than, equal -** to, or greater than self -** This comparison only applies to some widgets; compare_to(a,a)=0 is not -** guaranteed. It may be used for sorting for all widgets. -** -** -** -- equals(gfxw_widget_t *self, gfxw_widget_t *other) -** Compares two compareable widgets for equality -** Parameters: (gfxw_widget_t *) self: self reference -** (gfxw_widget_t *) other: other widget -** Returns : (int) 0 if the widgets are not equal, != 0 if they match -** This operation checks whether two widgets describe the same graphical data. -** It is used to determine whether a new widget should be discarded because it -** describes the same graphical data as an old widget that has already been -** drawn. For lists, it also checks whether all contents are in an identical -** order. -** -** -** -- should_replace(gfxw_widget_t *self, gfxw_widget_t *other) -** Compares two compareable widgets for equality -** Parameters: (gfxw_widget_t *) self: self reference -** (gfxw_widget_t *) other: other widget -** Returns : (int) 0 if 'self' should be kept, != 0 if it should be replaced -** by the 'other' -** When 'equals' returns true, this means that no new widget will be added. -** However, in some cases newer widgets may contain information that should -** cause the older widget to be removed nonetheless; this is indicated by this -** function. -** -** -** -- superarea_of(gfxw_widget_t *self, gfxw_widget_t *other) -** Tests whether drawing self after other would reduce all traces of other -** Parameters: (gfxw_widget_t *) self: self reference -** (gxfw_widget_t *) other: The widget to compare for containment -** Returns : (int) 1 if self is superarea_of other, 0 otherwise -** -** -** -- set_visual(gfxw_widget_t *self) -** Sets the visual for the widget -** Parameters: (gfxw_widget_t *) self: self reference -** Returns : (int) 0 -** This function is called by container->add() and need not be invoked explicitly. -** It also makes sure that dirty rectangles are passed to parent containers. -** -** -** -** ************************** -** ** Container operations ** -** ************************** -** -** -** -- free_tagged(gfxw_container_t *self) -** Frees all tagged resources in the container -** Parameters: (gfxw_container_t *) self: self reference -** Returns : (int) 0 -** The container itself is never freed in this way. -** -** -** -- free_contents(gfxw_container_t *self) -** Frees all resources contained in the container -** Parameters: (gfxw_container_t *) self: self reference -** Returns : (int) 0 -** -** -** -- add_dirty_abs(gfxw_container_t *self, rect_t dirty, int propagate) -** Adds a dirty rectangle to the container's list of dirty rects -** Parameters: (gfxw_container_t *) self: self reference -** (rect_t) dirty: The rectangular screen area that is to be flagged -** as dirty, absolute to the screen -** (int) propagate: Whether the dirty rect should be propagated to the -** widget's parents -** Returns : (int) 0 -** Transparent containers will usually pass this value to their next ancestor, -** because areas below them might have to be redrawn. -** The dirty rectangle management strategy is defined in this file in -** GFXW_DIRTY_STRATEGY. -** -** -** -- add_dirty_rel(gfxw_container_t *self, rect_t dirty, int propagate) -** Adds a dirty rectangle to the container's list of dirty rects -** Parameters: (gfxw_container_t *) self: self reference -** (rect_t) dirty: The rectangular screen area that is to be flagged -** as dirty, relative to the widget -** (int) propagate: Whether the dirty rect should be propagated to the -** widget's parents -** Returns : (int) 0 -** Transparent containers will usually pass this value to their next ancestor, -** because areas below them might have to be redrawn. -** The dirty rectangle management strategy is defined in this file in -** GFXW_DIRTY_STRATEGY. -** -** -** -- add(gfxw_container_t *self, gfxw_widget_t *widget) -** Adds a widget to the list of contained widgets -** Parameters: (gfxw_container_t *) self: self reference -** (gfxw_widget_t *) widget: The widget to add -** Returns : (int) 0 -** Sorted lists sort their content into the list rather than adding it to the -** end. -*/ - - -/***************************/ -/* Basic widget generation */ -/***************************/ - -/*-- Primitive types --*/ - -gfxw_box_t *gfxw_new_box(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type); -/* Creates a new box -** Parameters: (gfx_state_t *) state: The (optional) state -** (rect_t) area: The box's dimensions, relative to its container widget -** (gfx_color_t) color1: The primary color -** (gfx_color_t) color1: The secondary color (ignored if shading is disabled) -** (gfx_box_shade_t) shade_type: The shade type for the box -** Returns : (gfxw_box_t *) The resulting box widget -** The graphics state- if non-NULL- is used here for some optimizations. -*/ - -gfxw_primitive_t *gfxw_new_rect(rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); -/* Creates a new rectangle -** Parameters: (rect_t) rect: The rectangle area -** (gfx_color_t) color: The rectangle's color -** (gfx_line_mode_t) line_mode: The line mode for the lines that make up the rectangle -** (gfx_line_style_t) line_style: The rectangle's lines' style -** Returns : (gfxw_primitive_t *) The newly allocated rectangle widget (a Primitive) -*/ - -gfxw_primitive_t *gfxw_new_line(Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); -/* Creates a new line -** Parameters: (Common::Point * Common::Point) (start, line): The line origin and end point -** (gfx_color_t) color: The line's color -** (gfx_line_mode_t) line_mode: The line mode to use for drawing -** (gfx_line_style_t) line_style: The line style -** Returns : (gfxw_primitive_t *) The newly allocated line widget (a Primitive) -*/ - - -/* Whether the view should be static */ -#define GFXW_VIEW_FLAG_STATIC (1 << 0) - -/* Whether the view should _not_ apply its x/y offset modifyers */ -#define GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET (1 << 1) - -gfxw_view_t *gfxw_new_view(gfx_state_t *state, Common::Point pos, int view, int loop, int cel, int palette, int priority, int control, - gfx_alignment_t halign, gfx_alignment_t valign, int flags); -/* Creates a new view (a cel, actually) -** Parameters: (gfx_state_t *) state: The graphics state -** (Common::Point) pos: The position to place the view at -** (int x int x int) view, loop, cel: The global cel ID -** (int) priority: The priority to use for drawing, or -1 for none -** (int) control: The value to write to the control map, or -1 for none -** (gfx_alignment_t x gfx_alignment_t) halign, valign: Horizontal and vertical -** cel alignment -** (int) flags: Any combination of GFXW_VIEW_FLAGs -** Returns : (gfxw_cel_t *) A newly allocated cel according to the specs -*/ - -gfxw_dyn_view_t *gfxw_new_dyn_view(gfx_state_t *state, Common::Point pos, int z, int view, int loop, int cel, int palette, - int priority, int control, gfx_alignment_t halign, gfx_alignment_t valign, - int sequence); -/* Creates a new dyn view -** Parameters: (gfx_state_t *) state: The graphics state -** (Common::Point) pos: The position to place the dynamic view at -** (int) z: The z coordinate -** (int x int x int) view, loop, cel: The global cel ID -** (int) priority: The priority to use for drawing, or -1 for none -** (int) control: The value to write to the control map, or -1 for none -** (gfx_alignment_t x gfx_alignment_t) halign, valign: Horizontal and vertical -** cel alignment -** (int) sequence: Sequence number: When sorting dynviews, this number is -** considered last for sorting (ascending order) -** Returns : (gfxw_cel_t *) A newly allocated cel according to the specs -** Dynamic views are non-pic views with a unique global identifyer. This allows for drawing -** optimizations when they move or change shape. -*/ - -gfxw_text_t *gfxw_new_text(gfx_state_t *state, rect_t area, int font, const char *text, gfx_alignment_t halign, - gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, - gfx_color_t bgcolor, int flags); -/* Creates a new text widget -** Parameters: (gfx_state_t *) state: The state the text is to be calculated from -** (rect_t) area: The area the text is to be confined to (the yl value is only -** relevant for text aligment, though) -** (int) font: The number of the font to use -** (gfx_alignment_t x gfx_alignment_t) halign, valign: Horizontal and -** vertical text alignment -** (gfx_color_t x gfx_color_t) color1, color2: Text foreground colors (if not equal, -** The foreground is dithered between them) -** (gfx_color_t) bgcolor: Text background color -** (int) flags: GFXR_FONT_FLAGs, orred together (see gfx_resource.h) -** Returns : (gfxw_text_t *) The resulting text widget -*/ - -void gfxw_text_info(gfx_state_t *state, gfxw_text_t *text, int *lines_nr, - int *lineheight, int *offset); -/* Determines text widget meta-information -** Parameters: (gfx_state_t *) state: The state to operate on -** (gfx_text_t *) text: The widget to query -** Returns : (int) lines_nr: Number of lines used in the text -** (int) lineheight: Pixel height (SCI scale) of each text line -** (int) offset: Pixel offset (SCI scale) of the space after the -** last character in the last line -*/ - -gfxw_widget_t *gfxw_set_id(gfxw_widget_t *widget, int ID, int subID); -/* Sets a widget's ID -** Parmaeters: (gfxw_widget_t *) widget: The widget whose ID should be set -** (int x int) ID, subID: The ID to set -** Returns : (gfxw_widget_t *) widget -** A widget ID is unique within the container it is stored in, if and only if it was -** added to that container with gfxw_add(). -** This function handles widget = NULL gracefully (by doing nothing and returning NULL). -*/ - -gfxw_widget_t *gfxw_remove_id(gfxw_container_t *container, int ID, int subID); -/* Finds a widget with a specific ID in a container and removes it from there -** Parameters: (gfxw_container_t *) container: The container to search in -** (int) ID: The ID to look for -** (int) subID: The subID to look for, or GFXW_NO_ID for any -** Returns : (gfxw_widget_t *) The resulting widget or NULL if no match was found -** Search is non-recursive; widgets with IDs hidden in subcontainers will not be found. -*/ - - -gfxw_dyn_view_t *gfxw_dyn_view_set_params(gfxw_dyn_view_t *widget, int under_bits, void *under_bitsp, int signal, void *signalp); -/* Initializes a dyn view's interpreter attributes -** Parameters: (gfxw_dyn_view_t *) widget: The widget affected -** (int x void * x int x void *) under_bits, inder_bitsp, signal, signalp: Interpreter-dependant data -** Returns : (gfxw_dyn_view_t *) widget -*/ - -gfxw_widget_t *gfxw_hide_widget(gfxw_widget_t *widget); -/* Makes a widget invisible without removing it from the list of widgets -** Parameters: (gfxw_widget_t *) widget: The widget to invisibilize -** Returns : (gfxw_widget_t *) widget -** Has no effect on invisible widgets -*/ - -gfxw_widget_t *gfxw_show_widget(gfxw_widget_t *widget); -/* Makes an invisible widget reappear -** Parameters: (gfxw_widget_t *) widget: The widget to show again -** Returns : (gfxw_widget_t *) widget -** Does not affect visible widgets -*/ - -gfxw_widget_t *gfxw_abandon_widget(gfxw_widget_t *widget); -/* Marks a widget as "abandoned" -** Parameters: (gfxw_widget_t *) widget: The widget to abandon -** Returns : (gfxw_widget_t *) widget -*/ - -/*-- Container types --*/ - -#define GFXW_LIST_UNSORTED 0 -#define GFXW_LIST_SORTED 1 - -gfxw_list_t *gfxw_new_list(rect_t area, int sorted); -/* Creates a new list widget -** Parameters: (rect_t) area: The area covered by the list (absolute position) -** (int) sorted: Whether the list should be a sorted list -** Returns : (gfxw_list_t *) A newly allocated list widget -** List widgets are also referred to as Display Lists. -*/ - -gfxw_visual_t *gfxw_new_visual(gfx_state_t *state, int font); -/* Creates a new visual widget -** Parameters: (gfx_state_t *) state: The graphics state -** (int) font: The default font number for contained ports -** Returns : (gfxw_list_t *) A newly allocated visual widget -** Visual widgets are containers for port widgets. -*/ - - -gfxw_port_t *gfxw_new_port(gfxw_visual_t *visual, gfxw_port_t *predecessor, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor); -/* Creates a new port widget with the default settings -** Paramaters: (gfxw_visual_t *) visual: The visual the port is added to -** (gfxw_port_t *) predecessor: The port's predecessor -** (rect_t) area: The screen area covered by the port (absolute position) -** (gfx_color_t) fgcolor: Foreground drawing color -** (gfx_color_t) bgcolor: Background color -** Returns : (gfxw_port_t *) A newly allocated port widget -** A port differentiates itself from a list in that it contains additional information, -** and an optional title (stored in a display list). -** Ports are assigned implicit IDs identifying their position within the port stack. -*/ - -gfxw_port_t *gfxw_find_port(gfxw_visual_t *visual, int ID); -/* Retrieves a port with the specified ID -** Parameters: (gfxw_visual_t *) visual: The visual the port is to be retrieved from -** (int) ID: The port's ID -** Returns : (gfxw_port_t *) The requested port, or NULL if it didn't exist -** This function is O(1). -*/ - -gfxw_port_t *gfxw_find_default_port(gfxw_visual_t *visual); -/* Retreives the default port from a visual -** Parameters: (gfxw_visual_t *) visual: The visual the port should be retrieved from -** Returns : (gfxw_port_t *) The default port, or NULL if no port is present -** The 'default port' is the last port to be instantiated; usually the topmost -** or highest-ranking port. -*/ - -void gfxw_port_set_auto_restore(gfxw_visual_t *visual, gfxw_port_t *window, rect_t auto_rect); -/* Sets rectangle to be restored upon port removal -** Parameters: (state_t *) s: The state to operate on - (gfxw_port_t *) window: The affected window -** (rect_t) auto_rect: The area to restore -** Returns : (void) -*/ - -gfxw_port_t *gfxw_remove_port(gfxw_visual_t *visual, gfxw_port_t *port); -/* Removes a port from a visual -** Parameters: (gfxw_visual_t *) visual: The visual the port should be removed from -** (gfxw_port_t *) port: The port to remove -** Returns : (gfxw_port_t *) port's parent port, or NULL if it had none -*/ - -void gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *widget); -/* Removes the widget from the specified port -** Parameters: (gfxw_container_t *) container: The container it should be removed from -** (gfxw_widget_t *) widget: The widget to remove -** Returns : (void) -*/ - -gfxw_snapshot_t *gfxw_make_snapshot(gfxw_visual_t *visual, rect_t area); -/* Makes a "snapshot" of a visual -** Parameters: (gfxw_visual_t *) visual: The visual a snapshot is to be taken of -** (rect_t) area: The area a snapshot should be taken of -** Returns : (gfxw_snapshot_t *) The resulting, newly allocated snapshot -** It's not really a full qualified snaphot, though. See gfxw_restore_snapshot -** for a full discussion. -** This operation also increases the global serial number counter by one. -*/ - -int gfxw_widget_matches_snapshot(gfxw_snapshot_t *snapshot, gfxw_widget_t *widget); -/* Predicate to test whether a widget would be destroyed by applying a snapshot -** Parameters: (gfxw_snapshot_t *) snapshot: The snapshot to test against -** (gfxw_widget_t *) widget: The widget to test -** Retunrrs : (int) An appropriate boolean value -*/ - -gfxw_snapshot_t *gfxw_restore_snapshot(gfxw_visual_t *visual, gfxw_snapshot_t *snapshot); -/* Restores a snapshot to a visual -** Parameters: (gfxw_visual_t *) visual: The visual to operate on -** (gfxw_snapshot_t *) snapshot: The snapshot to restore -** Returns : (gfxw_snapshot_t *) snapshot (still needs to be freed) -** The snapshot is not really restored; only more recent widgets touching -** the snapshotted area are destroyed. -*/ - -void gfxw_annihilate(gfxw_widget_t *widget); -/* As widget->widfree(widget), but destroys all overlapping widgets -** Parameters: (gfxw_widget_t *) widget: The widget to use -** Returns : (void) -** This operation calls widget->widfree(widget), but it also destroys -** all widgets with a higher or equal priority drawn after this widget. -*/ - -gfxw_dyn_view_t *gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview); -/* Turns a dynview into a picview -** Parameters: (gfxw_dyn_view_t *) dynview: The victim -** Returns : (gfxw_dyn_view_t *) The victim, after his transformation -** The only changes are in function and type variables, actually. -*/ - -void gfxw_port_auto_restore_background(gfxw_visual_t *visual, gfxw_port_t *window, rect_t auto_rect); -/* Tags a window widget as automatically restoring the visual background upon removal -** Parameters: (gfx_visual_t *) visual: The base visual -** (gfxw_port_t *) window: The window to tag -** (rect_t) auto_rect: The background to remember -** Also records the specified background rectangle, for later recovery -*/ - - -gfxw_port_t *gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags); - -void gfxw_add_to_chrono(gfxw_visual_t *visual, gfxw_widget_t *widget); - -void gfxw_widget_reparent_chrono(gfxw_visual_t *visual, gfxw_widget_t *view, gfxw_list_t *target); - -void gfxw_widget_kill_chrono(gfxw_visual_t *visual, int window); - -} // End of namespace Sci - -#endif /* !_GFX_WIDGETS_H_ */ diff --git a/engines/sci/include/menubar.h b/engines/sci/include/menubar.h index 7e8a0131a3..e437bddcf5 100644 --- a/engines/sci/include/menubar.h +++ b/engines/sci/include/menubar.h @@ -28,8 +28,8 @@ #ifndef _SCI_MENUBAR_H_ #define _SCI_MENUBAR_H_ -#include "sci/include/gfx_operations.h" -#include "sci/include/gfx_widgets.h" +#include "sci/gfx/gfx_operations.h" +#include "sci/gfx/gfx_widgets.h" namespace Sci { diff --git a/engines/sci/include/sbtree.h b/engines/sci/include/sbtree.h deleted file mode 100644 index 0639d80bfc..0000000000 --- a/engines/sci/include/sbtree.h +++ /dev/null @@ -1,110 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Static binary tree header file */ - -/* Static binary trees are used to link ints to pointers. They are not capable -** of resizing after being initialized. -*/ - -#ifndef _SBTREE_H_ -#define _SBTREE_H_ - -#ifdef SBTREE_DEBUG -# include -#endif - -namespace Sci { - -typedef struct { - int entries_nr; - int min_entry; - int max_entry; - int levels; - int alloced_entries; - void *data; -} sbtree_t; - - -sbtree_t *sbtree_new(int size, int *keys); -/* Generates a new sbtree with the specified key set -** Parameters: (int) size: Number of entries in 'keys' -** (int *) keys: Array of 'size' integer keys -** Returns : (sbtree_t *) A new sbtree -** Only positive keys are allowed. Duplicates are not detected and will -** cause additional memory usage and slower access times if not removed -** beforehand. -*/ - -void sbtree_free(sbtree_t *tree); -/* Frees an sbtree -** Parameters: (sbtree_t *) tree: The tree to free -** Returns : (void) Nothing at all -*/ - -int sbtree_set(sbtree_t *tree, int key, void *value); -/* Sets a key to a value -** Parameters: (sbtree_t *) tree: The tree to modify -** (int) key: The key to set -** (void *) value: The value part of the (key,value) tuple -** Returns : (int) 0 if everything went OK, -1 if the key was invalid -** value may, of course, be NULL here. -*/ - -void *sbtree_get(sbtree_t *tree, int key); -/* Retreives a key -** Parameters: (sbtree_t *) tree: The tree to search in -** (int) key: The key to retrieve -** Returns : (void *) The value mapped to the key -** If key was not found/invalid, NULL is returned. Note that there is no -** way of distinguishing between keys mapped to NULL and invalid keys, -** short of attempting to set that key. -*/ - -void sbtree_foreach(sbtree_t *tree, void *args, void *(*operation)(sbtree_t *, const int, - const void *, void *)); -/* Operates once on each entry in the tree -** Parameters: (sbtree_t *) tree: The tree to operate on -** (void *) arguments: Additional arguments to pass to 'operation' -** (int (int, void *, void *)) operation: The operation to execute -** Returns : (void) -** The parameters of the function that is to be executed are as follows: -** operation (sbtree_t *tree, int key, void *value, void *args) -** Parameters: (sbtree_t *) tree: The tree the operation was executed on -** (int) key: Key of the entry the operation was invoked on -** (void *) value: Value of the entry the operation was invoked on -** (void *) args: The 'args' parameter passed to sbtree_foreach() -** Returns : (void *) The new value of this entry -** This function will only work properly the original data contained no duplicate keys. -*/ - -} // End of namespace Sci - -#endif /* !_SBTREE_H_ */ - - - - - diff --git a/engines/sci/include/sciconsole.h b/engines/sci/include/sciconsole.h index 7e0ad876c4..c3b93a4671 100644 --- a/engines/sci/include/sciconsole.h +++ b/engines/sci/include/sciconsole.h @@ -39,7 +39,7 @@ #include "sci/include/vm_types.h" #define SCI_CONSOLE -#include "sci/include/gfx_operations.h" +#include "sci/gfx/gfx_operations.h" namespace Sci { diff --git a/engines/sci/include/sfx_core.h b/engines/sci/include/sfx_core.h deleted file mode 100644 index 7ac02d6cfc..0000000000 --- a/engines/sci/include/sfx_core.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _SFX_CORE_H_ -#define _SFX_CORE_H_ - -#include "common/scummsys.h" - -namespace Sci { - -#define SFX_OK 0 -#define SFX_ERROR -1 - -#define MIDI_CHANNELS 16 - -} // End of namespace Sci - -#endif /* !defined(_SFX_CORE_H_) */ diff --git a/engines/sci/include/sfx_engine.h b/engines/sci/include/sfx_engine.h deleted file mode 100644 index 3a037aa60b..0000000000 --- a/engines/sci/include/sfx_engine.h +++ /dev/null @@ -1,166 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Sound engine */ -#ifndef _SFX_ENGINE_H_ -#define _SFX_ENGINE_H_ - -#include "sci/include/sfx_core.h" -#include "sci/include/sfx_songlib.h" -#include "sci/include/sfx_iterator.h" -#include "sci/include/sciresource.h" - -namespace Sci { - -#define SOUND_TICK 1000000 / 60 -/* Approximately 16666 microseconds */ - - -#define SFX_STATE_FLAG_MULTIPLAY (1 << 0) /* More than one song playable -** simultaneously ? */ -#define SFX_STATE_FLAG_NOSOUND (1 << 1) /* Completely disable sound playing */ - - -#define SFX_DEBUG_SONGS (1 << 0) /* Debug song changes */ -#define SFX_DEBUG_CUES (1 << 1) /* Debug cues, loops, and -** song completions */ - -typedef struct { - song_iterator_t *it; /* The song iterator at the heart of things */ - unsigned int flags; /* SFX_STATE_FLAG_* */ - songlib_t songlib; /* Song library */ - song_t *song; /* Active song, or start of active song chain */ - int suspended; /* Whether we are suspended */ - unsigned int debug; /* Debug flags */ - -} sfx_state_t; - -/***********/ -/* General */ -/***********/ - -void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags); -/* Initializes the sound engine -** Parameters: (ResourceManager *) resmgr: Resource manager for initialization -** (int) flags: SFX_STATE_FLAG_* -*/ - -void sfx_exit(sfx_state_t *self); -/* Deinitializes the sound subsystem -*/ - -void sfx_suspend(sfx_state_t *self, int suspend); -/* Suspends/unsuspends the sound sybsystem -** Parameters: (int) suspend: Whether to suspend (non-null) or to unsuspend -*/ - -int sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue); -/* Polls the sound server for cues etc. -** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise -** (song_handle_t) *handle: The affected handle -** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP) -*/ - -int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue); -/* Polls the sound server for cues etc. -** Parameters: (song_handle_t) handle: The handle to poll -** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise -** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP) -*/ - -int sfx_get_volume(sfx_state_t *self); -/* Determines the current global volume settings -** Returns : (int) The global volume, between 0 (silent) and 127 (max. volume) -*/ - -void sfx_set_volume(sfx_state_t *self, int volume); -/* Determines the current global volume settings -** Parameters: (int) volume: The new global volume, between 0 and 127 (see above) -*/ - -void sfx_all_stop(sfx_state_t *self); -/* Stops all songs currently playing, purges song library -*/ - - -/*****************/ -/* Song basics */ -/*****************/ - -int sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t handle, int resnum); -/* Adds a song to the internal sound library -** Parameters: (song_iterator_t *) it: The iterator describing the song -** (int) priority: Initial song priority (higher <-> more important) -** (song_handle_t) handle: The handle to associate with the song -** Returns : (int) 0 on success, nonzero on error -*/ - - -void sfx_remove_song(sfx_state_t *self, song_handle_t handle); -/* Deletes a song and its associated song iterator from the song queue -** Parameters: (song_handle_t) handle: The song to remove -*/ - - -/**********************/ -/* Song modifications */ -/**********************/ - - -void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status); -/* Sets the song status, i.e. whether it is playing, suspended, or stopped. -** Parameters: (song_handle_t) handle: Handle of the song to modify -** (int) status: The song status the song should assume -** WAITING and PLAYING are set implicitly and essentially describe the same state -** as far as this function is concerned. -*/ - -void sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority); -/* Sets the new song priority -** Parameters: (song_handle_t) handle: The handle to modify -** (int) priority: The priority to set -*/ - -void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops); -/* Sets the number of loops for the specified song -** Parameters: (song_handle_t) handle: The song handle to reference -** (int) loops: Number of loops to set -*/ - -void sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold); -/* Sets the number of loops for the specified song -** Parameters: (song_handle_t) handle: The song handle to reference -** (int) hold: Number of loops to setn -*/ - -void sfx_song_set_fade(sfx_state_t *self, song_handle_t handle, fade_params_t *fade_setup); -/* Instructs a song to be faded out -** Parameters: (song_handle_t) handle: The song handle to reference -** (fade_params_t *) fade_setup: The precise fade-out configuration to use -*/ - -} // End of namespace Sci - -#endif /* !defined(_SFX_ENGINE_H_) */ diff --git a/engines/sci/include/sfx_iterator.h b/engines/sci/include/sfx_iterator.h deleted file mode 100644 index ceab4c5c47..0000000000 --- a/engines/sci/include/sfx_iterator.h +++ /dev/null @@ -1,350 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Song iterator declarations */ - -#ifndef _SCI_SFX_ITERATOR_H_ -#define _SCI_SFX_ITERATOR_H_ - -#include "sci/include/sfx_pcm.h" - -namespace Sci { - -#define SI_FINISHED -1 /* Song finished playing */ -#define SI_LOOP -2 /* Song just looped */ -#define SI_ABSOLUTE_CUE -3 /* Found a song cue (absolute) */ -#define SI_RELATIVE_CUE -4 /* Found a song cue (relative) */ -#define SI_PCM -5 /* Found a PCM */ -#define SI_IGNORE -6 /* This event got edited out by the remapper */ -#define SI_MORPH -255 /* Song iterator requested self-morph. */ - -#define FADE_ACTION_NONE 0 -#define FADE_ACTION_FADE_AND_STOP 1 -#define FADE_ACTION_FADE_AND_CONT 2 - -typedef struct { - int ticks_per_step; - int final_volume; - int step_size; - int action; -} fade_params_t; - -#define SONG_ITERATOR_MESSAGE_ARGUMENTS_NR 2 - -/* Helper defs for messages */ -/* Base messages */ -#define _SIMSG_BASE 0 /* Any base decoder */ -#define _SIMSG_BASEMSG_SET_LOOPS 0 /* Set loops */ -#define _SIMSG_BASEMSG_CLONE 1 /* Clone object and data. Must provide the -** (possibly negative) number of ticks that have -** passed since the last delay time started being -** used */ -#define _SIMSG_BASEMSG_SET_PLAYMASK 2 /* Set the current playmask for filtering */ -#define _SIMSG_BASEMSG_SET_RHYTHM 3 /* Activate/deactivate rhythm channel */ -#define _SIMSG_BASEMSG_ACK_MORPH 4 /* Acknowledge self-morph */ -#define _SIMSG_BASEMSG_STOP 5 /* Stop iterator */ -#define _SIMSG_BASEMSG_PRINT 6 /* Print self to stderr, after printing param1 tabs */ -#define _SIMSG_BASEMSG_SET_HOLD 7 /* Set value of hold parameter to expect */ -#define _SIMSG_BASEMSG_SET_FADE 8 /* Set fade parameters */ - -/* "Plastic" (discardable) wrapper messages */ -#define _SIMSG_PLASTICWRAP 1 /* Any base decoder */ -#define _SIMSG_PLASTICWRAP_ACK_MORPH 4 /* Acknowledge self-morph */ - -/* Messages */ -#define SIMSG_SET_LOOPS(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_LOOPS,(x),0 -#define SIMSG_SET_PLAYMASK(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_PLAYMASK,(x),0 -#define SIMSG_SET_RHYTHM(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_RHYTHM,(x),0 -#define SIMSG_CLONE(x) _SIMSG_BASE,_SIMSG_BASEMSG_CLONE,(x),0 -#define SIMSG_ACK_MORPH _SIMSG_PLASTICWRAP,_SIMSG_PLASTICWRAP_ACK_MORPH,0,0 -#define SIMSG_STOP _SIMSG_BASE,_SIMSG_BASEMSG_STOP,0,0 -#define SIMSG_PRINT(indentation) _SIMSG_BASE,_SIMSG_BASEMSG_PRINT,(indentation),0 -#define SIMSG_SET_HOLD(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_HOLD,(x),0 -/*#define SIMSG_SET_FADE(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_FADE,(x),0*/ - -/* Message transmission macro: Takes song reference, message reference */ -#define SIMSG_SEND(o, m) songit_handle_message(&(o), songit_make_message((o)->ID, m)) -#define SIMSG_SEND_FADE(o, m) songit_handle_message(&(o), songit_make_ptr_message((o)->ID, _SIMSG_BASE, _SIMSG_BASEMSG_SET_FADE, m, 0)) - -/* Event listener interface */ -struct listener_t { - void (*notify)(void *self, void *notifier); - void *self; -}; - -typedef unsigned long songit_id_t; - -typedef struct { - songit_id_t ID; - unsigned int recipient; /* Type of iterator supposed to receive this */ - unsigned int type; - union { - unsigned int i; - void * p; - } args[SONG_ITERATOR_MESSAGE_ARGUMENTS_NR]; -} song_iterator_message_t; - -#define INHERITS_SONG_ITERATOR \ - songit_id_t ID; \ - guint16 channel_mask; \ - fade_params_t fade; \ - unsigned int flags; \ - int priority; \ - int (*next) (song_iterator_t *self, unsigned char *buf, int *buf_size); \ - sfx_pcm_feed_t * (*get_pcm_feed) (song_iterator_t *s); \ - song_iterator_t * (* handle_message)(song_iterator_t *self, song_iterator_message_t msg); \ - void (*init) (struct _song_iterator *self); \ - void (*cleanup) (struct _song_iterator *self); \ - int (*get_timepos) (struct _song_iterator *self); \ - listener_t death_listeners[SONGIT_MAX_LISTENERS]; \ - int death_listeners_nr \ - -#define SONGIT_MAX_LISTENERS 2 - -typedef struct _song_iterator { - - songit_id_t ID; - guint16 channel_mask; /* Bitmask of all channels this iterator will use */ - fade_params_t fade; - unsigned int flags; - int priority; - - int (*next)(struct _song_iterator *self, - unsigned char *buf, int *result); - /* Reads the next MIDI operation _or_ delta time - ** Parameters: (song_iterator_t *) self - ** (byte *) buf: The buffer to write to (needs to be able to - ** store at least 4 bytes) - ** Returns : (int) zero if a MIDI operation was written, SI_FINISHED - ** if the song has finished playing, SI_LOOP if looping - ** (after updating the loop variable), SI_CUE if we found - ** a cue, SI_PCM if a PCM was found, or the number of ticks - ** to wait before this function should be called next. - ** (int) *result: Number of bytes written to the buffer - ** (equals the number of bytes that need to be passed - ** to the lower layers) for 0, the cue value for SI_CUE, - ** or the number of loops remaining for SI_LOOP. - ** If SI_PCM is returned, get_pcm() may be used to retrieve the associated - ** PCM, but this must be done before any subsequent calls to next(). - */ - - sfx_pcm_feed_t * (*get_pcm_feed)(struct _song_iterator *self); - /* Checks for the presence of a pcm sample - ** Parameters: (song_iterator_t *) self - ** Returns : (sfx_pcm_feed_t *) NULL if no PCM data was found, a - ** PCM feed otherwise - */ - - - struct _song_iterator * - (* handle_message)(struct _song_iterator *self, song_iterator_message_t msg); - /* Handles a message to the song iterator - ** Parameters: (song_iterator_t *) self - ** (song_iterator_messag_t) msg: The message to handle - ** Returns : (song_iterator_t *) NULL if the message was not understood, - ** self if the message could be handled, or a new song iterator - ** if the current iterator had to be morphed (but the message could - ** still be handled) - ** This function is not supposed to be called directly; use - ** songit_handle_message() instead. It should not recurse, since songit_handle_message() - ** takes care of that and makes sure that its delegate received the message (and - ** was morphed) before self. - */ - - - void (*init)(struct _song_iterator *self); - /* Resets/initializes the sound iterator - ** Parameters: (song_iterator_t *) self - ** Returns : (void) - */ - - void (*cleanup)(struct _song_iterator *self); - /* Frees any content of the iterator structure - ** Parameters: (song_iterator_t *) self - ** Does not physically free(self) yet. May be NULL if nothing needs to be done. - ** Must not recurse on its delegate. - */ - - int (*get_timepos)(struct _song_iterator *self); - /* Gets the song position to store in a savegame - ** Parameters: (song_iterator_t *) self - */ - - /* Death listeners */ - /* These are not reset during initialisation */ - listener_t death_listeners[SONGIT_MAX_LISTENERS]; - int death_listeners_nr; - - /* See songit_* for the constructor and non-virtual member functions */ - -} song_iterator_t; - - -/* Song iterator flags */ -#define SONGIT_FLAG_CLONE (1 << 0) /* This flag is set for clones, which are exclusively used in song players. -** Thus, this flag distinguishes song iterators in the main thread from those -** in the song-player thread. */ - -void song_iterator_add_death_listener(song_iterator_t *it, - void *client, - void (*notify)(void *self, void *notifier)); -/* Adds a death listener to a song iterator -** Parameters: (song_iterator_t *) it: The iterator to add to -** (void *) client: The object wanting to be notified -** (void* x void* -> void) notify: The notification function -** to invoke -** Effects: Fatally terminates the program if no listener slots are -** available -** Death listeners are NOT cloned. -*/ - -void song_iterator_remove_death_listener(song_iterator_t *it, - void *client); -/* Removes a death listener from a song iterator -** Parameters: (song_iterator_t *) it: The iterator to modify -** (void *) client: The object no longer wanting to be notified -** Effects: Fatally terminates the program if the listener was not -** found -** Death listeners are NOT cloned. -*/ - -/********************************/ -/*-- Song iterator operations --*/ -/********************************/ - -#define SCI_SONG_ITERATOR_TYPE_SCI0 0 -#define SCI_SONG_ITERATOR_TYPE_SCI1 1 - -#define IT_READER_MASK_MIDI (1 << 0) -#define IT_READER_MASK_DELAY (1 << 1) -#define IT_READER_MASK_LOOP (1 << 2) -#define IT_READER_MASK_CUE (1 << 3) -#define IT_READER_MASK_PCM (1 << 4) -#define IT_READER_MAY_FREE (1 << 10) /* Free SI_FINISHED iterators */ -#define IT_READER_MAY_CLEAN (1 << 11) -/* MAY_CLEAN: May instantiate cleanup iterators -** (use for players; this closes open channels at the end of a song) */ - -#define IT_READER_MASK_ALL ( IT_READER_MASK_MIDI \ - | IT_READER_MASK_DELAY \ - | IT_READER_MASK_LOOP \ - | IT_READER_MASK_CUE \ - | IT_READER_MASK_PCM ) - -int songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask); -/* Convenience wrapper around it->next -** Parameters: (song_iterator_t **it) Reference to the iterator to access -** (byte *) buf: The buffer to write to (needs to be able to -** store at least 4 bytes) -** (int) mask: IT_READER_MASK options specifying the events to -** listen for -** Returns : (int) zero if a MIDI operation was written, SI_FINISHED -** if the song has finished playing, SI_LOOP if looping -** (after updating the loop variable), SI_CUE if we found -** a cue, SI_PCM if a PCM was found, or the number of ticks -** to wait before this function should be called next. -** (int) *result: Number of bytes written to the buffer -** (equals the number of bytes that need to be passed -** to the lower layers) for 0, the cue value for SI_CUE, -** or the number of loops remaining for SI_LOOP. -*/ - -song_iterator_t *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id); -/* Constructs a new song iterator object -** Parameters: (byte *) data: The song data to iterate over -** (unsigned int) size: Number of bytes in the song -** (int) type: One of the SCI_SONG_ITERATOR_TYPEs -** (songit_id_t) id: An ID for addressing the song iterator -** Returns : (song_iterator_t *) A newly allocated but uninitialized song -** iterator, or NULL if 'type' was invalid or unsupported -*/ - -song_iterator_t *songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy); -/* Combines two iterators, returns the next event available from either -** Parameters: (song_iterator_t *) left: One of the iterators -** (song_iterator_t *) right: The other iterator -** (int) may_destroy: Whether completed song iterators may be -** destroyed -** Returns : (song_iterator_t *) A combined iterator, as suggested above -*/ - - -void songit_free(song_iterator_t *it); -/* Frees a song iterator and the song it wraps -** Parameters: (song_iterator_t *) it: The song iterator to free -** Returns : (void) -*/ - -song_iterator_message_t songit_make_message(songit_id_t id, - int recipient_class, int type, int a1, int a2); -/* Create a song iterator message -** Parameters: (songit_id_t) id: song ID the message is targetted to -** (int) recipient_class: Message recipient class -** (int) type: Message type -** (int x int) a1, a2: Arguments -** You should only use this with the SIMSG_* macros -*/ - -song_iterator_message_t songit_make_ptr_message(songit_id_t id, - int recipient_class, int type, void * a1, int a2); -/* Create a song iterator message, wherein the first parameter is a pointer -** Parameters: (songit_id_t) id: song ID the message is targetted to -** (int) recipient_class: Message recipient class -** (int) type: Message type -** (void* x int) a1, a2: Arguments -** You should only use this with the SIMSG_* macros -*/ - -int songit_handle_message(song_iterator_t **it_reg, song_iterator_message_t msg); -/* Handles a message to the song iterator -** Parameters: (song_iterator_t **): A reference to the variable storing the song iterator -** Returns : (int) Non-zero if the message was understood -** The song iterator may polymorph as result of msg, so a writeable reference is required. -*/ - - -song_iterator_t *songit_clone(song_iterator_t *it, int delta); -/* Clones a song iterator -** Parameters: (song_iterator_t *) it: The iterator to clone -** (int) delta: Number of ticks that still need to elapse until -** the next item should be read from the song iterator -** Returns : (song_iterator_t *) A shallow clone of 'it'. -** This performs a clone on the bottom-most part (containing the actual song data) _only_. -** The justification for requiring 'delta' to be passed in here is that this -** is typically maintained outside of the song iterator. -*/ - - -int sfx_play_iterator_pcm(song_iterator_t *it, unsigned long handle); -/* Plays a song iterator that found a PCM through a PCM device, if possible -** Parameters: (song_iterator_t *) it: The iterator to play -** (song_handle_t) handle: Debug handle -** Returns : (int) 0 if the effect will not be played, nonzero if it will -** This assumes that the last call to 'it->next()' returned SI_PCM. -*/ - -} // End of namespace Sci - -#endif diff --git a/engines/sci/include/sfx_iterator_internal.h b/engines/sci/include/sfx_iterator_internal.h deleted file mode 100644 index 8f71267edb..0000000000 --- a/engines/sci/include/sfx_iterator_internal.h +++ /dev/null @@ -1,236 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _SFX_ITERATOR_INTERNAL_ -#define _SFX_ITERATOR_INTERNAL_ - -#include "sci/include/sfx_iterator.h" -#include "sci/include/sci_midi.h" - -namespace Sci { - -/* States */ - -#define SI_STATE_UNINITIALISED -1 -#define SI_STATE_DELTA_TIME 0 /* Now at a delta time */ -#define SI_STATE_COMMAND 1 /* Now at a MIDI operation */ -#define SI_STATE_PENDING 2 /* Pending for loop */ -#define SI_STATE_FINISHED 3 /* End of song */ -#define SI_STATE_PCM 4 /* Should report a PCM next (-> DELTA_TIME) */ -#define SI_STATE_PCM_MAGIC_DELTA 5 /* Should report a ``magic'' one tick delta time next (goes on to FINISHED) */ - - -/* Iterator types */ - -#define SCI_SONG_ITERATOR_TYPE_SCI0 0 -#define SCI_SONG_ITERATOR_TYPE_SCI1 1 - -#define SIPFX __FILE__" : " - - -typedef struct { - int state; /* SI_STATE_* */ - int offset; /* Offset into the data chunk */ - int end; /* Last allowed byte in track */ - int id; /* Some channel ID */ - int loop_offset; - int delay; /* Number of ticks before the - ** specified channel is next - ** used, or - ** CHANNEL_DELAY_MISSING to - ** indicate that the delay has - ** not yet been read */ - - /* Two additional offsets for recovering: */ - int initial_offset; - int playmask; /* Active playmask (MIDI channels to play in here) */ - int notes_played; /* #of notes played since the last loop start */ - int loop_timepos; /* Total delay for this channel's loop marker */ - int total_timepos; /* Number of ticks since the beginning, ignoring loops */ - int timepos_increment; /* Number of ticks until the next command (to add) */ - - int saw_notes; /* Bitmask of channels we have currently played notes on */ - byte last_cmd; /* Last operation executed, for running status */ -} song_iterator_channel_t; - -#define INHERITS_BASE_SONG_ITERATOR \ - INHERITS_SONG_ITERATOR; /* aka "extends song iterator" */ \ - \ - int polyphony[MIDI_CHANNELS]; /* # of simultaneous notes on each */ \ - int importance[MIDI_CHANNELS]; /* priority rating for each channel, 0 means unrated. */ \ - \ - \ - int ccc; /* Cumulative cue counter, for those who need it */ \ - unsigned char resetflag; /* for 0x4C -- on DoSound StopSound, do we return to start? */ \ - int device_id; /* ID of the device we generating events for */ \ - int active_channels; /* Number of active channels */ \ - unsigned int size; /* Song size */ \ - unsigned char *data; \ - \ - int loops; /* Number of loops remaining */ \ - int recover_delay - -typedef struct _base_song_iterator { - INHERITS_BASE_SONG_ITERATOR; -} base_song_iterator_t; - -/********************************/ -/*--------- SCI 0 --------------*/ -/********************************/ - -typedef struct { - INHERITS_BASE_SONG_ITERATOR; - song_iterator_channel_t channel; - int delay_remaining; /* Number of ticks that haven't been polled yet */ -} sci0_song_iterator_t; - - -/********************************/ -/*--------- SCI 1 --------------*/ -/********************************/ - - -typedef struct _sci1_sample { - int delta; /* Time left-- initially, this is 'Sample point 1'. - ** After initialisation, it is 'sample point 1 minus the sample point of the previous sample' */ - int size; - int announced; /* Announced for download (SI_PCM) */ - sfx_pcm_config_t format; - byte *data; - struct _sci1_sample *next; -} sci1_sample_t; - -typedef struct { - INHERITS_BASE_SONG_ITERATOR; - song_iterator_channel_t channels[MIDI_CHANNELS]; - - /* Invariant: Whenever channels[i].delay == CHANNEL_DELAY_MISSING, - ** channel_offset[i] points to a delta time object. */ - - int initialised; /* Whether the MIDI channel setup has been initialised */ - int channels_nr; /* Number of channels actually used */ - sci1_sample_t *next_sample; - int channels_looped; /* Number of channels that are ready to loop */ - - int delay_remaining; /* Number of ticks that haven't been polled yet */ - int hold; - \ -} sci1_song_iterator_t; - -#define PLAYMASK_NONE 0x0 - -/*********************************/ -/*---------- Cleanup ------------*/ -/*********************************/ - - -song_iterator_t *new_cleanup_iterator(unsigned int channels); -/* Creates a new song iterator with the purpose of sending notes-off channel commands -** Parameters: (unsigned int) channels: Channel mask to send these commands for -** Returns : A song iterator with the aforementioned purpose -*/ - -int is_cleanup_iterator(song_iterator_t *it); -/* Determines whether a given song iterator is a cleanup song iterator -** Parameters: (song_iterator_t *) it: The iterator to check -** Returns : (int) 1 iff 'it' is a cleanup song iterator -** No deep recursion/delegation is considered. -*/ - - -/**********************************/ -/*--------- Fast Forward ---------*/ -/**********************************/ - -typedef struct { - INHERITS_SONG_ITERATOR; - song_iterator_t *delegate; - int delta; /* Remaining time */ -} fast_forward_song_iterator_t; - - -song_iterator_t *new_fast_forward_iterator(song_iterator_t *it, int delta); -/* Creates a new song iterator which fast-forwards -** Parameters: (song_iterator_t *) it: The iterator to wrap -** (int) delta: The number of ticks to skip -** Returns : (song_iterator_t) A newly created song iterator -** which skips all delta times -** until 'delta' has been used up -*/ - -/**********************************/ -/*--------- Fast Forward ---------*/ -/**********************************/ - -#define MAX_BUF_SIZE 4 - -#define TEE_LEFT 0 -#define TEE_RIGHT 1 -#define TEE_LEFT_ACTIVE (1<<0) -#define TEE_RIGHT_ACTIVE (1<<1) -#define TEE_LEFT_READY (1<<2) /* left result is ready */ -#define TEE_RIGHT_READY (1<<3) /* right result is ready */ -#define TEE_LEFT_PCM (1<<4) -#define TEE_RIGHT_PCM (1<<5) - -#define TEE_MORPH_NONE 0 /* Not waiting to self-morph */ -#define TEE_MORPH_READY 1 /* Ready to self-morph */ - -typedef struct { - INHERITS_SONG_ITERATOR; - - int status; - - int may_destroy; /* May destroy song iterators */ - - int morph_deferred; /* One of TEE_MORPH_* above */ - - struct { - song_iterator_t *it; - byte buf[MAX_BUF_SIZE]; - int result; - int retval; - - byte channel_remap[MIDI_CHANNELS]; - /* Remapping for channels */ - - } children[2]; -} tee_song_iterator_t; - - -sfx_pcm_feed_t *sfx_iterator_make_feed(byte *base_data, int offset, - int size, - sfx_pcm_config_t conf); -/* Generates a feed for a song iterator -** Parameters: (byte *) base_data: A refcounted memory chunk containing -** (among other things) PCM data -** (int) offset; Offset into base_data -** (int) size: Number of bytes to consider -** (pcm_data_internal_t) conf: PCM encoding -*/ - -} // End of namespace Sci - -#endif /* !defined(_SFX_ITERATOR_INTERNAL_ */ diff --git a/engines/sci/include/sfx_pcm.h b/engines/sci/include/sfx_pcm.h deleted file mode 100644 index 1169354bb8..0000000000 --- a/engines/sci/include/sfx_pcm.h +++ /dev/null @@ -1,184 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _SFX_PCM_H_ -#define _SFX_PCM_H_ - -#include "sci/include/sfx_core.h" -#include "sci/include/sfx_timer.h" -#include "sci/include/sfx_time.h" -#include "sci/include/scitypes.h" - -namespace Sci { - -#define SFX_PCM_MONO 0 -#define SFX_PCM_STEREO_LR 1 /* left sample, then right sample */ -#define SFX_PCM_STEREO_RL 2 /* right sample, then left sample */ - -/* The following are used internally by the mixer */ -#define SFX_PCM_FORMAT_LMASK 0x7 -#define SFX_PCM_FORMAT_BE 0 -#define SFX_PCM_FORMAT_LE 1 -#define SFX_PCM_FORMAT_ENDIANNESS 1 -#define SFX_PCM_FORMAT_8 0 -#define SFX_PCM_FORMAT_16 2 - - -/* Pick one of these formats (including the _NATIVE) ones for your PCM feed */ -#define SFX_PCM_FORMAT_U8 (0x0080 | SFX_PCM_FORMAT_8) /* Unsigned (bias 128) 8 bit format */ -#define SFX_PCM_FORMAT_S8 (0x0000 | SFX_PCM_FORMAT_8) /* Signed 8 bit format */ -#define SFX_PCM_FORMAT_U16_LE (0x8000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_LE) /* Unsigned (bias 32768) 16 bit LE format */ -#define SFX_PCM_FORMAT_S16_LE (0x0000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_LE) /* Signed 16 bit format, little endian */ -#define SFX_PCM_FORMAT_U16_BE (0x8000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_BE) /* Unsigned (bias 32768) 16 bit BE format */ -#define SFX_PCM_FORMAT_S16_BE (0x0000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_BE) /* Signed 16 bit format, big endian */ - -#ifdef SCUMM_BIG_ENDIAN -# define SFX_PCM_FORMAT_U16_NATIVE SFX_PCM_FORMAT_U16_BE -# define SFX_PCM_FORMAT_S16_NATIVE SFX_PCM_FORMAT_S16_BE -#else -# define SFX_PCM_FORMAT_U16_NATIVE SFX_PCM_FORMAT_U16_LE -# define SFX_PCM_FORMAT_S16_NATIVE SFX_PCM_FORMAT_S16_LE -#endif - -#define SFX_PCM_FRAME_SIZE(conf) ((conf).stereo? 2 : 1) * (((conf).format & SFX_PCM_FORMAT_16)? 2 : 1) - - -typedef struct { - int rate; /* Sampling rate */ - int stereo; /* The stereo mode used (SFX_PCM_MONO or SFX_PCM_STEREO_*) */ - unsigned int format; /* Sample format (SFX_PCM_FORMAT_*) */ -} sfx_pcm_config_t; - -typedef struct _sfx_pcm_device { - /* SFX devices are PCM players, i.e. output drivers for digitalised audio (sequences of audio samples). - ** Implementors are (in general) allowed to export specifics of these devices and let the mixer handle - ** endianness/signedness/bit size/mono-vs-stereo conversions. - */ - - int (*init)(struct _sfx_pcm_device *self); - /* Initializes the device - ** Parameters: (sfx_pcm_device_t *) self: Self reference - ** Returns : (int) SFX_OK on success, SFX_ERROR if the device could not be - ** opened - ** This should attempt to open the highest quality output allowed by any options - ** specified beforehand. - */ - - int (*output)(struct _sfx_pcm_device *self, byte *buf, - int count, sfx_timestamp_t *timestamp); - /* Writes output to the device - ** Parameters: (sfx_pcm_device_t *) self: Self reference - ** (byte *) buf: The buffer to write - ** (int) count: Number of /frames/ that should be written - ** (sfx_timestamp_t *) timestamp: Optional point in time - ** for which the PCM data is scheduled - ** Returns : (int) SFX_OK on success, SFX_ERROR on error - ** The size of the buffer allocated as 'buf' equals buf_size. - ** 'buf' is guaranteed not to be modified in between calls to 'output()'. - ** 'timestamp' is guaranteed to be used only in sequential order, but not - ** guaranteed to be used in all cases. It is guaranteed to be compaible with - ** the sample rate used by the device itself (i.e., the sfx_time.h functionality - ** is applicable) - */ - - sfx_timestamp_t - (*get_output_timestamp)(struct _sfx_pcm_device *self); - /* Determines the timestamp for 'output' - ** Parameters: (sfx_pcm_device_t *) self: Self reference - ** Returns : (sfx_timestamp_t) A timestamp (with the device's conf.rate) - ** describing the point in time at which - ** the next frame passed to 'output' - ** will be played - ** This function is OPTIONAL and may be NULL, but it is recommended - ** that pcm device implementers attempt to really implement it. - */ - - /* The following must be set after initialisation */ - sfx_pcm_config_t conf; - int buf_size; /* Output buffer size, i.e. the number of frames (!) - ** that can be queued by this driver before calling - ** output() will block or fail, drained according - ** to conf.rate */ - -} sfx_pcm_device_t; - - -#define PCM_FEED_TIMESTAMP 0 /* New timestamp available */ -#define PCM_FEED_IDLE 1 /* No sound ATM, but new timestamp may be available later */ -#define PCM_FEED_EMPTY 2 /* Feed is finished, can be destroyed */ - -typedef struct _sfx_pcm_feed_t { - /* PCM feeds are sources of input for the PCM mixer. Their member functions - ** are invoked as callbacks on demand, to provide the mixer with input it - ** (in turn) passes on to PCM output devices. - ** PCM feeds must explicitly register themselves with the mixer in order - ** to be considered. - */ - - int (*poll)(struct _sfx_pcm_feed_t *self, byte *dest, int size); - /* Asks the PCM feed to write out the next stuff it would like to have written - ** Parameters: (sfx_pcm_feed_t *) self: Self reference - ** (byte *) dest: The destination buffer to write to - ** (int) size: The maximum number of _frames_ (not neccessarily bytes) - ** to write - ** Returns : (int) The number of frames written - ** If the number of frames written is smaller than 'size', the PCM feed will - ** be queried for a new timestamp afterwards, or destroyed if no new timestamp - ** is available. - */ - - void (*destroy)(struct _sfx_pcm_feed_t *self); - /* Asks the PCM feed to free all resources it occupies - ** Parameters: (sfx_pcm_feed_t *) self: Self reference - ** free(self) should be part of this function, if applicable. - */ - - int - (*get_timestamp)(struct _sfx_pcm_feed_t *self, sfx_timestamp_t *timestamp); - /* Determines the timestamp of the next frame-to-read - ** Returns : (sfx_timestamp_t) timestamp: The timestamp of the next frame - ** (int) PCM_FEED_* - ** This function is OPTIONAL and may be NULL - */ - - void *internal; /* The private bits of a PCM feed. */ - - sfx_pcm_config_t conf; /* The channel's setup */ - - const char *debug_name; /* The channel name, for debugging */ - int debug_nr; /* A channel number relative to the channel name, for debugging - ** (print in hex) */ - int frame_size; /* Frame size, computed by the mixer for the feed */ - -} sfx_pcm_feed_t; - -int sfx_pcm_available(); -/* Determines whether a PCM device is available and has been initialised -** Returns : (int) zero iff no PCM device is available -*/ - -} // End of namespace Sci - -#endif /* !defined(_SFX_PCM_H_) */ diff --git a/engines/sci/include/sfx_player.h b/engines/sci/include/sfx_player.h deleted file mode 100644 index 7e3b7ea2f1..0000000000 --- a/engines/sci/include/sfx_player.h +++ /dev/null @@ -1,154 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* song player structure */ - -#ifndef _SFX_PLAYER_H -#define _SFX_PLAYER_H - -#include "sci/include/sfx_engine.h" -#include "sci/include/sfx_iterator.h" -#include "sci/include/sciresource.h" - -namespace Sci { - -typedef void tell_synth_func(int buf_nr, byte *buf); - -typedef struct { - const char *name; - const char *version; - - int (*set_option)(char *name, char *value); - /* Sets an option for player timing mechanism - ** Parameters: (char *) name: The name describing what to set - ** (char *) value: The value to set - ** Returns : (int) SFX_OK, or SFX_ERROR if the name wasn't understood - */ - - int (*init)(ResourceManager *resmgr, int expected_latency); - /* Initializes the player - ** Parameters: (ResourceManager *) resmgr: A resource manager for driver initialization - ** (int) expected_latency: Expected delay in between calls to 'maintenance' - ** (in microseconds) - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - */ - - int (*add_iterator)(song_iterator_t *it, GTimeVal start_time); - /* Adds an iterator to the song player - ** Parameters: (songx_iterator_t *) it: The iterator to play - ** (GTimeVal) start_time: The time to assume as the - ** time the first MIDI command executes at - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - ** The iterator should not be cloned (to avoid memory leaks) and - ** may be modified according to the needs of the player. - ** Implementors may use the 'sfx_iterator_combine()' function - ** to add iterators onto their already existing iterators - */ - - int (*fade_out)(); - /* Fades out the currently playing song (within two seconds - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - */ - - int (*stop)(); - /* Stops the currently playing song and deletes the associated iterator - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - */ - - int (*iterator_message)(song_iterator_message_t msg); - /* Transmits a song iterator message to the active song - ** Parameters: (song_iterator_message_t) msg: The message to transmit - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - ** OPTIONAL -- may be NULL - ** If this method is not present, sending messages will stop - ** and re-start playing, so it is preferred that it is present - */ - - int (*pause)(); /* OPTIONAL -- may be NULL */ - /* Pauses song playing - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - */ - - int (*resume)(); /* OPTIONAL -- may be NULL */ - /* Resumes song playing after a pause - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - */ - - int (*exit)(); - /* Stops the player - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - */ - - void (*maintenance)(); /* OPTIONAL -- may be NULL */ - /* Regularly called maintenance function - ** This function is called frequently and regularly (if present), it can be - ** used to emit sound. - */ - - tell_synth_func *tell_synth; - /* Pass a raw MIDI event to the synth - Parameters: (int) argc: Length of buffer holding the midi event - (byte *) argv: The buffer itself - */ - - int polyphony; /* Number of voices that can play simultaneously */ - -} sfx_player_t; - -sfx_player_t *sfx_find_player(char *name); -/* Looks up a player by name or finds the default player -** Parameters: (char *) name: Name of the player to look up, or NULL for dedault -** Returns : (sfx_player_t *) The player requested, or NULL if none was found -*/ - -tell_synth_func *sfx_get_player_tell_func(); -/* Gets the callback function of the player in use. -** Returns: (tell_synth_func *) The callback function. -*/ - -int sfx_get_player_polyphony(); -/* Determines the polyphony of the player in use -** Returns : (int) Number of voices the active player can emit -*/ - -void sfx_reset_player(); -/* Tells the player to stop its internal iterator -** Parameters: None. -** Returns: Nothing. - */ - -song_iterator_t *sfx_iterator_combine(song_iterator_t *it1, song_iterator_t *it2); -/* Combines two song iterators into one -** Parameters: (sfx_iterator_t *) it1: One of the two iterators, or NULL -** (sfx_iterator_t *) it2: The other iterator, or NULL -** Returns : (sfx_iterator_t *) A combined iterator -** If a combined iterator is returned, it will be flagged to be allowed to -** dispose of 'it1' and 'it2', where applicable. This means that this -** call should be used by song players, but not by the core sound system -*/ - -} // End of namespace Sci - -#endif /* !_SFX_PLAYER_H */ diff --git a/engines/sci/include/sfx_songlib.h b/engines/sci/include/sfx_songlib.h deleted file mode 100644 index 44523b27d2..0000000000 --- a/engines/sci/include/sfx_songlib.h +++ /dev/null @@ -1,191 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Song library */ - -#ifndef _SCI_SFX_SONGLIB_H_ -#define _SCI_SFX_SONGLIB_H_ - -#include "common/scummsys.h" - -#include "sci/tools.h" // For GTimeVal -#include "sci/include/scitypes.h" -#include "sci/include/sfx_iterator.h" - -namespace Sci { - -#define SOUND_STATUS_STOPPED 0 -#define SOUND_STATUS_PLAYING 1 -#define SOUND_STATUS_SUSPENDED 2 -/* suspended: only if ordered from kernel space */ -#define SOUND_STATUS_WAITING 3 -/* "waiting" means "tagged for playing, but not active right now" */ - -typedef unsigned long song_handle_t; - -typedef enum { - RESTORE_BEHAVIOR_CONTINUE, /* restart a song when restored from - a saved game */ - RESTORE_BEHAVIOR_RESTART /* continue it from where it was */ -} RESTORE_BEHAVIOR; - -typedef struct _song { - song_handle_t handle; - int resource_num; /* Resource number */ - int priority; /* Song priority (more important if priority is higher) */ - int status; /* See above */ - - int restore_behavior; - int restore_time; - - /* Grabbed from the sound iterator, for save/restore purposes */ - int loops; - int hold; - - song_iterator_t *it; - long delay; /* Delay before accessing the iterator, in microseconds */ - - GTimeVal wakeup_time; /* Used by the sound core: - ** Playing -> time at which 'delay' has elapsed - ** Suspended/Waiting -> stopping time */ - - struct _song *next; /* Next song or NULL if this is the last one */ - struct _song *next_playing; /* Next playing song; used by the - ** core song system */ - struct _song *next_stopping; /* Next song pending stopping; used exclusively by - ** the core song system's _update_multi_song() */ -} song_t; - - -typedef struct { - song_t **lib; - song_t *_s; -} songlib_t; - -/**************************/ -/* Song library commands: */ -/**************************/ - -song_t *song_new(song_handle_t handle, song_iterator_t *it, int priority); -/* Initializes a new song -** Parameters: (song_handle_t) handle: The sound handle -** (song_iterator_t *) it: The song -** (int) priority: The song's priority -** Returns : (song_t *) A freshly allocated song -** Other values are set to predefined defaults. -*/ - - -void song_lib_init(songlib_t *songlib); -/* Initializes a static song library -** Parameters: (songlib_t *) songlib: Pointer to the library -** to initialize -** Returns : (void) -*/ - -void song_lib_free(songlib_t songlib); -/* Frees a song library -** Parameters: (songlib_t) songlib: The library to free -** Returns : (void) -*/ - -void song_lib_add(songlib_t songlib, song_t *song); -/* Adds a song to a song library. -** Parameters: (songlib_t) songlib: An existing sound library, or NULL -** (song_t *) song: The song to add -** Returns : (void) -*/ - -song_t *song_lib_find(songlib_t songlib, song_handle_t handle); -/* Looks up the song with the specified handle -** Parameters: (songlib_t) songlib: An existing sound library, may point to NULL -** (song_handle_t) handle: The sound handle to look for -** Returns : (song_t *) The song or NULL if it wasn't found -*/ - -song_t *song_lib_find_active(songlib_t songlib); -/* Finds the first song playing with the highest priority -** Parameters: (songlib_t) songlib: An existing sound library -** Returns : (song_t *) The song that should be played next, or NULL if there is none -*/ - -song_t *song_lib_find_next_active(songlib_t songlib, song_t *song); -/* Finds the next song playing with the highest priority -** Parameters: (songlib_t) songlib: The song library to operate on -** (song_t *) song: A song previously returned from the song library -** Returns : (song_t *) The next song to play relative to 'song', or -** NULL if none are left -** The functions 'song_lib_find_active' and 'song_lib_find_next_active -** allow to iterate over all songs that satisfy the requirement of -** being 'playable'. -*/ - -int song_lib_remove(songlib_t songlib, song_handle_t handle); -/* Removes a song from the library -** Parameters: (songlib_t) songlib: An existing sound library -** (song_handle_t) handle: Handle of the song to remove -** Returns : (int) The status of the song that was removed -*/ - -void song_lib_resort(songlib_t songlib, song_t *song); -/* Removes a song from the library and sorts it in again; for use after renicing -** Parameters: (songlib_t) songlib: An existing sound library -** (song_t *) song: The song to work on -** Returns : (void) -*/ - -int song_lib_count(songlib_t songlib); -/* Counts the number of songs in a song library -** Parameters: (songlib_t) songlib: The library to count -** Returns : (int) The number of songs -*/ - -GTimeVal song_sleep_time(GTimeVal *lastslept, long ticks); -/* Caluculates the amount of seconds and microseconds to sleep. -** Parameters: (GTimeVal *) lastslept: The time to start counting on -** (long) ticks: Number of ticks to sleep -** Returns : (GTimeVal) The amount of time to sleep -*/ - -GTimeVal song_next_wakeup_time(GTimeVal *lastslept, long ticks); -/* Calculates the time at which "ticks" have passed, counting from "lastslept". -** Parameters: (GTimeVal *) lastslept: The base to start counting on -** (long) ticks: Number of ticks to count -** Returns : (GTimeVal) A structure describing the time at which the -** specified number of ticks has passed -*/ - -void song_lib_set_restore_behavior(songlib_t songlib, song_handle_t handle, - RESTORE_BEHAVIOR action); -/* Determines what should be done with the song "handle" when -** restoring it from a saved game. -** Parameters: (songlib_t) songlib: The library that contains the song -** (song_handle_t) handle: Its handle -** (RESTORE_BEHAVIOR) action: The desired action -*/ - -} // End of namespace Sci - -#endif /* !_SCI_SOUND_SERVER_H_ */ diff --git a/engines/sci/include/sfx_time.h b/engines/sci/include/sfx_time.h deleted file mode 100644 index d362dfa381..0000000000 --- a/engines/sci/include/sfx_time.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _SFX_TIME_H_ -#define _SFX_TIME_H_ - -namespace Sci { - -typedef struct { - long secs; - long usecs; - int frame_rate; - int frame_offset; - /* Total time: secs + usecs + frame_offset/frame_rate */ -} sfx_timestamp_t; - - -sfx_timestamp_t sfx_new_timestamp(long secs, long usecs, int frame_rate); -/* Creates a new mutable timestamp -** Parameters: (long x long) (secs, usecs): Initial timestamp -** (int) frame_rate: Frame rate, for increasing the time stamp -*/ - -sfx_timestamp_t sfx_timestamp_add(sfx_timestamp_t timestamp, int frames); -/* Adds a number of frames to a timestamp -** Parameters: (sfx_timestampt_t *) timestamp: The timestamp to update -** (int) frames: Number of frames to add -** Returns : (sfx_timestamp_t) The increased timestamp -*/ - -sfx_timestamp_t sfx_timestamp_renormalise(sfx_timestamp_t timestamp, int new_freq); -/* Translates a timestamp to a new base frame frequency -** Parameters: (sfx_timestamp_t *) timestamp: The timestamp to normalise -** (int) new_freq: The new frequency to normalise to -** Returns : (sfx_timestamp_t) The re-normalised timestamp -** The translation looses accuracy in the order of magnitude of milliseconds -** for "usual" sampling frequencies. -*/ - -int sfx_timestamp_frame_diff(sfx_timestamp_t a, sfx_timestamp_t b); -/* Computes the difference (# of frames) between two timestamps -** Parameters: (sfx_timestamp) a: See below -** (sfx_timestamp) b: See below -** Returns : (int) a-b -*/ - -long sfx_timestamp_usecs_diff(sfx_timestamp_t a, sfx_timestamp_t b); -/* Computes the difference (# of microseconds) between two timestamps -** Parameters: (sfx_timestamp) a: See below -** (sfx_timestamp) b: See below -** Returns : (long) a-b -*/ - -void sfx_timestamp_gettime(sfx_timestamp_t *timestamp, long *secs, long *usecs); -/* Determines the time described by a given timestamp -** Parameters: (sfx_timestamp_t *) timestamp: Timestamp to read from -** Returns : (int * x int *) (secs, usecs): Seconds and microseconds since -** the epoch described there -*/ - -} // End of namespace Sci - -#endif /* !defined(_SFX_TIME_H_) */ diff --git a/engines/sci/include/sfx_timer.h b/engines/sci/include/sfx_timer.h deleted file mode 100644 index 08120ffe57..0000000000 --- a/engines/sci/include/sfx_timer.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef _FREESCI_SFX_TIMER_H_ -#define _FREESCI_SFX_TIMER_H_ - -#include "sci/include/sfx_core.h" - -namespace Sci { - -typedef struct { - int delay_ms; /* Approximate delay (in milliseconds) between calls */ - - int (*init)(void (*callback)(void *data), void *data); - /* Initializes the timer - ** Parameters: (void* -> void) callback: - ** 'data' must contain the next argument: - ** (void *) data: Must always be passed to the callback - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - ** This does not start the timer yet, it just specifies and initializes it. - ** This function is called exactly once (provided that the timer is used at all). - */ - - int (*exit)(); - /* Stops the timer - ** Returns : (int) SFX_OK on success, SFX_ERROR on failure - ** All resources allocated with the timer should be freed as an effect - ** of this. - */ -} sfx_timer_t; - -} // End of namespace Sci - -#endif /* !_FREESCI_SFX_TIMER_H_ */ diff --git a/engines/sci/scicore/resource.cpp b/engines/sci/scicore/resource.cpp index 705546f6a4..34dd9d4647 100644 --- a/engines/sci/scicore/resource.cpp +++ b/engines/sci/scicore/resource.cpp @@ -38,15 +38,6 @@ namespace Sci { #undef SCI_REQUIRE_RESOURCE_FILES //#define SCI_VERBOSE_RESMGR 1 -// FIXME: Get rid of G_DIR_SEPARATOR / G_DIR_SEPARATOR_S -#if _MSC_VER -# define G_DIR_SEPARATOR_S "\\" -# define G_DIR_SEPARATOR '\\' -#else -# define G_DIR_SEPARATOR_S "/" -# define G_DIR_SEPARATOR '/' -#endif - const char* sci_version_types[] = { "SCI version undetermined (Autodetect failed / not run)", "SCI version 0.xxx", diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index 5ff66716b3..4d40d002ca 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -26,9 +26,9 @@ /* Sound subsystem core: Event handler, sound player dispatching */ #include -#include "sci/include/sfx_timer.h" -#include "sci/include/sfx_iterator_internal.h" -#include "sci/include/sfx_player.h" +#include "sci/sfx/sfx_timer.h" +#include "sci/sfx/sfx_iterator_internal.h" +#include "sci/sfx/sfx_player.h" #include "sci/sfx/mixer.h" #include "sci/include/sci_midi.h" #include "common/mutex.h" diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index 7c98e6d691..ff4faafde2 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -27,8 +27,8 @@ #include #include "common/util.h" -#include "sci/include/sfx_iterator_internal.h" -#include "sci/include/sfx_player.h" +#include "sci/sfx/sfx_iterator_internal.h" +#include "sci/sfx/sfx_player.h" #include "sci/tools.h" #include "sci/include/sci_memory.h" diff --git a/engines/sci/sfx/mixer.h b/engines/sci/sfx/mixer.h index 286dbc3a89..aea58ce2c9 100644 --- a/engines/sci/sfx/mixer.h +++ b/engines/sci/sfx/mixer.h @@ -26,7 +26,7 @@ #ifndef SCI_SFX_MIXER_H #define SCI_SFX_MIXER_H -#include "sci/include/sfx_pcm.h" +#include "sci/sfx/sfx_pcm.h" namespace Sci { diff --git a/engines/sci/sfx/pcm-iterator.cpp b/engines/sci/sfx/pcm-iterator.cpp index 9c72edfa13..7bf9ed6a06 100644 --- a/engines/sci/sfx/pcm-iterator.cpp +++ b/engines/sci/sfx/pcm-iterator.cpp @@ -23,7 +23,7 @@ * */ -#include "sci/include/sfx_iterator.h" +#include "sci/sfx/sfx_iterator.h" #include "sci/tools.h" /* for BREAKPOINT */ #include "sci/include/sci_memory.h" diff --git a/engines/sci/sfx/pcm_device.cpp b/engines/sci/sfx/pcm_device.cpp index 267dfa25e2..a0f590ee82 100644 --- a/engines/sci/sfx/pcm_device.cpp +++ b/engines/sci/sfx/pcm_device.cpp @@ -23,8 +23,8 @@ * */ -#include "sci/include/sfx_time.h" -#include "sci/include/sfx_pcm.h" +#include "sci/sfx/sfx_time.h" +#include "sci/sfx/sfx_pcm.h" #include "engines/engine.h" #include "sound/audiostream.h" #include "sound/mixer.h" diff --git a/engines/sci/sfx/player/players.cpp b/engines/sci/sfx/player/players.cpp index 32623d0fc7..131c467cff 100644 --- a/engines/sci/sfx/player/players.cpp +++ b/engines/sci/sfx/player/players.cpp @@ -23,7 +23,7 @@ * */ -#include "sci/include/sfx_player.h" +#include "sci/sfx/sfx_player.h" namespace Sci { diff --git a/engines/sci/sfx/player/polled.cpp b/engines/sci/sfx/player/polled.cpp index ab75c705e3..869f7c00b2 100644 --- a/engines/sci/sfx/player/polled.cpp +++ b/engines/sci/sfx/player/polled.cpp @@ -27,7 +27,7 @@ #include "common/util.h" #include "common/file.h" -#include "sci/include/sfx_player.h" +#include "sci/sfx/sfx_player.h" #include "sci/sfx/softseq.h" #include "sci/sfx/mixer.h" diff --git a/engines/sci/sfx/player/realtime.cpp b/engines/sci/sfx/player/realtime.cpp index e749f49220..ab08d7f44b 100644 --- a/engines/sci/sfx/player/realtime.cpp +++ b/engines/sci/sfx/player/realtime.cpp @@ -27,7 +27,7 @@ ** prays for some reasonable amount of soft real-time, but it's close ** enough, I guess. */ -#include "sci/include/sfx_player.h" +#include "sci/sfx/sfx_player.h" #include "sci/sfx/sequencer.h" namespace Sci { diff --git a/engines/sci/sfx/sequencer.h b/engines/sci/sfx/sequencer.h index d292a8100d..803b731449 100644 --- a/engines/sci/sfx/sequencer.h +++ b/engines/sci/sfx/sequencer.h @@ -30,7 +30,7 @@ #include "common/scummsys.h" #include "sci/tools.h" // For GTimeVal -#include "sci/include/sfx_core.h" +#include "sci/sfx/sfx_core.h" #include "sci/sfx/device.h" #include "sci/include/scitypes.h" diff --git a/engines/sci/sfx/sfx_core.h b/engines/sci/sfx/sfx_core.h new file mode 100644 index 0000000000..7ac02d6cfc --- /dev/null +++ b/engines/sci/sfx/sfx_core.h @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _SFX_CORE_H_ +#define _SFX_CORE_H_ + +#include "common/scummsys.h" + +namespace Sci { + +#define SFX_OK 0 +#define SFX_ERROR -1 + +#define MIDI_CHANNELS 16 + +} // End of namespace Sci + +#endif /* !defined(_SFX_CORE_H_) */ diff --git a/engines/sci/sfx/sfx_engine.h b/engines/sci/sfx/sfx_engine.h new file mode 100644 index 0000000000..60893e550f --- /dev/null +++ b/engines/sci/sfx/sfx_engine.h @@ -0,0 +1,166 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Sound engine */ +#ifndef _SFX_ENGINE_H_ +#define _SFX_ENGINE_H_ + +#include "sci/sfx/sfx_core.h" +#include "sci/sfx/sfx_songlib.h" +#include "sci/sfx/sfx_iterator.h" +#include "sci/include/sciresource.h" + +namespace Sci { + +#define SOUND_TICK 1000000 / 60 +/* Approximately 16666 microseconds */ + + +#define SFX_STATE_FLAG_MULTIPLAY (1 << 0) /* More than one song playable +** simultaneously ? */ +#define SFX_STATE_FLAG_NOSOUND (1 << 1) /* Completely disable sound playing */ + + +#define SFX_DEBUG_SONGS (1 << 0) /* Debug song changes */ +#define SFX_DEBUG_CUES (1 << 1) /* Debug cues, loops, and +** song completions */ + +typedef struct { + song_iterator_t *it; /* The song iterator at the heart of things */ + unsigned int flags; /* SFX_STATE_FLAG_* */ + songlib_t songlib; /* Song library */ + song_t *song; /* Active song, or start of active song chain */ + int suspended; /* Whether we are suspended */ + unsigned int debug; /* Debug flags */ + +} sfx_state_t; + +/***********/ +/* General */ +/***********/ + +void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags); +/* Initializes the sound engine +** Parameters: (ResourceManager *) resmgr: Resource manager for initialization +** (int) flags: SFX_STATE_FLAG_* +*/ + +void sfx_exit(sfx_state_t *self); +/* Deinitializes the sound subsystem +*/ + +void sfx_suspend(sfx_state_t *self, int suspend); +/* Suspends/unsuspends the sound sybsystem +** Parameters: (int) suspend: Whether to suspend (non-null) or to unsuspend +*/ + +int sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue); +/* Polls the sound server for cues etc. +** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise +** (song_handle_t) *handle: The affected handle +** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP) +*/ + +int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue); +/* Polls the sound server for cues etc. +** Parameters: (song_handle_t) handle: The handle to poll +** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise +** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP) +*/ + +int sfx_get_volume(sfx_state_t *self); +/* Determines the current global volume settings +** Returns : (int) The global volume, between 0 (silent) and 127 (max. volume) +*/ + +void sfx_set_volume(sfx_state_t *self, int volume); +/* Determines the current global volume settings +** Parameters: (int) volume: The new global volume, between 0 and 127 (see above) +*/ + +void sfx_all_stop(sfx_state_t *self); +/* Stops all songs currently playing, purges song library +*/ + + +/*****************/ +/* Song basics */ +/*****************/ + +int sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t handle, int resnum); +/* Adds a song to the internal sound library +** Parameters: (song_iterator_t *) it: The iterator describing the song +** (int) priority: Initial song priority (higher <-> more important) +** (song_handle_t) handle: The handle to associate with the song +** Returns : (int) 0 on success, nonzero on error +*/ + + +void sfx_remove_song(sfx_state_t *self, song_handle_t handle); +/* Deletes a song and its associated song iterator from the song queue +** Parameters: (song_handle_t) handle: The song to remove +*/ + + +/**********************/ +/* Song modifications */ +/**********************/ + + +void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status); +/* Sets the song status, i.e. whether it is playing, suspended, or stopped. +** Parameters: (song_handle_t) handle: Handle of the song to modify +** (int) status: The song status the song should assume +** WAITING and PLAYING are set implicitly and essentially describe the same state +** as far as this function is concerned. +*/ + +void sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority); +/* Sets the new song priority +** Parameters: (song_handle_t) handle: The handle to modify +** (int) priority: The priority to set +*/ + +void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops); +/* Sets the number of loops for the specified song +** Parameters: (song_handle_t) handle: The song handle to reference +** (int) loops: Number of loops to set +*/ + +void sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold); +/* Sets the number of loops for the specified song +** Parameters: (song_handle_t) handle: The song handle to reference +** (int) hold: Number of loops to setn +*/ + +void sfx_song_set_fade(sfx_state_t *self, song_handle_t handle, fade_params_t *fade_setup); +/* Instructs a song to be faded out +** Parameters: (song_handle_t) handle: The song handle to reference +** (fade_params_t *) fade_setup: The precise fade-out configuration to use +*/ + +} // End of namespace Sci + +#endif /* !defined(_SFX_ENGINE_H_) */ diff --git a/engines/sci/sfx/sfx_iterator.h b/engines/sci/sfx/sfx_iterator.h new file mode 100644 index 0000000000..9dc1f3a3b3 --- /dev/null +++ b/engines/sci/sfx/sfx_iterator.h @@ -0,0 +1,350 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Song iterator declarations */ + +#ifndef _SCI_SFX_ITERATOR_H_ +#define _SCI_SFX_ITERATOR_H_ + +#include "sci/sfx/sfx_pcm.h" + +namespace Sci { + +#define SI_FINISHED -1 /* Song finished playing */ +#define SI_LOOP -2 /* Song just looped */ +#define SI_ABSOLUTE_CUE -3 /* Found a song cue (absolute) */ +#define SI_RELATIVE_CUE -4 /* Found a song cue (relative) */ +#define SI_PCM -5 /* Found a PCM */ +#define SI_IGNORE -6 /* This event got edited out by the remapper */ +#define SI_MORPH -255 /* Song iterator requested self-morph. */ + +#define FADE_ACTION_NONE 0 +#define FADE_ACTION_FADE_AND_STOP 1 +#define FADE_ACTION_FADE_AND_CONT 2 + +typedef struct { + int ticks_per_step; + int final_volume; + int step_size; + int action; +} fade_params_t; + +#define SONG_ITERATOR_MESSAGE_ARGUMENTS_NR 2 + +/* Helper defs for messages */ +/* Base messages */ +#define _SIMSG_BASE 0 /* Any base decoder */ +#define _SIMSG_BASEMSG_SET_LOOPS 0 /* Set loops */ +#define _SIMSG_BASEMSG_CLONE 1 /* Clone object and data. Must provide the +** (possibly negative) number of ticks that have +** passed since the last delay time started being +** used */ +#define _SIMSG_BASEMSG_SET_PLAYMASK 2 /* Set the current playmask for filtering */ +#define _SIMSG_BASEMSG_SET_RHYTHM 3 /* Activate/deactivate rhythm channel */ +#define _SIMSG_BASEMSG_ACK_MORPH 4 /* Acknowledge self-morph */ +#define _SIMSG_BASEMSG_STOP 5 /* Stop iterator */ +#define _SIMSG_BASEMSG_PRINT 6 /* Print self to stderr, after printing param1 tabs */ +#define _SIMSG_BASEMSG_SET_HOLD 7 /* Set value of hold parameter to expect */ +#define _SIMSG_BASEMSG_SET_FADE 8 /* Set fade parameters */ + +/* "Plastic" (discardable) wrapper messages */ +#define _SIMSG_PLASTICWRAP 1 /* Any base decoder */ +#define _SIMSG_PLASTICWRAP_ACK_MORPH 4 /* Acknowledge self-morph */ + +/* Messages */ +#define SIMSG_SET_LOOPS(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_LOOPS,(x),0 +#define SIMSG_SET_PLAYMASK(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_PLAYMASK,(x),0 +#define SIMSG_SET_RHYTHM(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_RHYTHM,(x),0 +#define SIMSG_CLONE(x) _SIMSG_BASE,_SIMSG_BASEMSG_CLONE,(x),0 +#define SIMSG_ACK_MORPH _SIMSG_PLASTICWRAP,_SIMSG_PLASTICWRAP_ACK_MORPH,0,0 +#define SIMSG_STOP _SIMSG_BASE,_SIMSG_BASEMSG_STOP,0,0 +#define SIMSG_PRINT(indentation) _SIMSG_BASE,_SIMSG_BASEMSG_PRINT,(indentation),0 +#define SIMSG_SET_HOLD(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_HOLD,(x),0 +/*#define SIMSG_SET_FADE(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_FADE,(x),0*/ + +/* Message transmission macro: Takes song reference, message reference */ +#define SIMSG_SEND(o, m) songit_handle_message(&(o), songit_make_message((o)->ID, m)) +#define SIMSG_SEND_FADE(o, m) songit_handle_message(&(o), songit_make_ptr_message((o)->ID, _SIMSG_BASE, _SIMSG_BASEMSG_SET_FADE, m, 0)) + +/* Event listener interface */ +struct listener_t { + void (*notify)(void *self, void *notifier); + void *self; +}; + +typedef unsigned long songit_id_t; + +typedef struct { + songit_id_t ID; + unsigned int recipient; /* Type of iterator supposed to receive this */ + unsigned int type; + union { + unsigned int i; + void * p; + } args[SONG_ITERATOR_MESSAGE_ARGUMENTS_NR]; +} song_iterator_message_t; + +#define INHERITS_SONG_ITERATOR \ + songit_id_t ID; \ + guint16 channel_mask; \ + fade_params_t fade; \ + unsigned int flags; \ + int priority; \ + int (*next) (song_iterator_t *self, unsigned char *buf, int *buf_size); \ + sfx_pcm_feed_t * (*get_pcm_feed) (song_iterator_t *s); \ + song_iterator_t * (* handle_message)(song_iterator_t *self, song_iterator_message_t msg); \ + void (*init) (struct _song_iterator *self); \ + void (*cleanup) (struct _song_iterator *self); \ + int (*get_timepos) (struct _song_iterator *self); \ + listener_t death_listeners[SONGIT_MAX_LISTENERS]; \ + int death_listeners_nr \ + +#define SONGIT_MAX_LISTENERS 2 + +typedef struct _song_iterator { + + songit_id_t ID; + guint16 channel_mask; /* Bitmask of all channels this iterator will use */ + fade_params_t fade; + unsigned int flags; + int priority; + + int (*next)(struct _song_iterator *self, + unsigned char *buf, int *result); + /* Reads the next MIDI operation _or_ delta time + ** Parameters: (song_iterator_t *) self + ** (byte *) buf: The buffer to write to (needs to be able to + ** store at least 4 bytes) + ** Returns : (int) zero if a MIDI operation was written, SI_FINISHED + ** if the song has finished playing, SI_LOOP if looping + ** (after updating the loop variable), SI_CUE if we found + ** a cue, SI_PCM if a PCM was found, or the number of ticks + ** to wait before this function should be called next. + ** (int) *result: Number of bytes written to the buffer + ** (equals the number of bytes that need to be passed + ** to the lower layers) for 0, the cue value for SI_CUE, + ** or the number of loops remaining for SI_LOOP. + ** If SI_PCM is returned, get_pcm() may be used to retrieve the associated + ** PCM, but this must be done before any subsequent calls to next(). + */ + + sfx_pcm_feed_t * (*get_pcm_feed)(struct _song_iterator *self); + /* Checks for the presence of a pcm sample + ** Parameters: (song_iterator_t *) self + ** Returns : (sfx_pcm_feed_t *) NULL if no PCM data was found, a + ** PCM feed otherwise + */ + + + struct _song_iterator * + (* handle_message)(struct _song_iterator *self, song_iterator_message_t msg); + /* Handles a message to the song iterator + ** Parameters: (song_iterator_t *) self + ** (song_iterator_messag_t) msg: The message to handle + ** Returns : (song_iterator_t *) NULL if the message was not understood, + ** self if the message could be handled, or a new song iterator + ** if the current iterator had to be morphed (but the message could + ** still be handled) + ** This function is not supposed to be called directly; use + ** songit_handle_message() instead. It should not recurse, since songit_handle_message() + ** takes care of that and makes sure that its delegate received the message (and + ** was morphed) before self. + */ + + + void (*init)(struct _song_iterator *self); + /* Resets/initializes the sound iterator + ** Parameters: (song_iterator_t *) self + ** Returns : (void) + */ + + void (*cleanup)(struct _song_iterator *self); + /* Frees any content of the iterator structure + ** Parameters: (song_iterator_t *) self + ** Does not physically free(self) yet. May be NULL if nothing needs to be done. + ** Must not recurse on its delegate. + */ + + int (*get_timepos)(struct _song_iterator *self); + /* Gets the song position to store in a savegame + ** Parameters: (song_iterator_t *) self + */ + + /* Death listeners */ + /* These are not reset during initialisation */ + listener_t death_listeners[SONGIT_MAX_LISTENERS]; + int death_listeners_nr; + + /* See songit_* for the constructor and non-virtual member functions */ + +} song_iterator_t; + + +/* Song iterator flags */ +#define SONGIT_FLAG_CLONE (1 << 0) /* This flag is set for clones, which are exclusively used in song players. +** Thus, this flag distinguishes song iterators in the main thread from those +** in the song-player thread. */ + +void song_iterator_add_death_listener(song_iterator_t *it, + void *client, + void (*notify)(void *self, void *notifier)); +/* Adds a death listener to a song iterator +** Parameters: (song_iterator_t *) it: The iterator to add to +** (void *) client: The object wanting to be notified +** (void* x void* -> void) notify: The notification function +** to invoke +** Effects: Fatally terminates the program if no listener slots are +** available +** Death listeners are NOT cloned. +*/ + +void song_iterator_remove_death_listener(song_iterator_t *it, + void *client); +/* Removes a death listener from a song iterator +** Parameters: (song_iterator_t *) it: The iterator to modify +** (void *) client: The object no longer wanting to be notified +** Effects: Fatally terminates the program if the listener was not +** found +** Death listeners are NOT cloned. +*/ + +/********************************/ +/*-- Song iterator operations --*/ +/********************************/ + +#define SCI_SONG_ITERATOR_TYPE_SCI0 0 +#define SCI_SONG_ITERATOR_TYPE_SCI1 1 + +#define IT_READER_MASK_MIDI (1 << 0) +#define IT_READER_MASK_DELAY (1 << 1) +#define IT_READER_MASK_LOOP (1 << 2) +#define IT_READER_MASK_CUE (1 << 3) +#define IT_READER_MASK_PCM (1 << 4) +#define IT_READER_MAY_FREE (1 << 10) /* Free SI_FINISHED iterators */ +#define IT_READER_MAY_CLEAN (1 << 11) +/* MAY_CLEAN: May instantiate cleanup iterators +** (use for players; this closes open channels at the end of a song) */ + +#define IT_READER_MASK_ALL ( IT_READER_MASK_MIDI \ + | IT_READER_MASK_DELAY \ + | IT_READER_MASK_LOOP \ + | IT_READER_MASK_CUE \ + | IT_READER_MASK_PCM ) + +int songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask); +/* Convenience wrapper around it->next +** Parameters: (song_iterator_t **it) Reference to the iterator to access +** (byte *) buf: The buffer to write to (needs to be able to +** store at least 4 bytes) +** (int) mask: IT_READER_MASK options specifying the events to +** listen for +** Returns : (int) zero if a MIDI operation was written, SI_FINISHED +** if the song has finished playing, SI_LOOP if looping +** (after updating the loop variable), SI_CUE if we found +** a cue, SI_PCM if a PCM was found, or the number of ticks +** to wait before this function should be called next. +** (int) *result: Number of bytes written to the buffer +** (equals the number of bytes that need to be passed +** to the lower layers) for 0, the cue value for SI_CUE, +** or the number of loops remaining for SI_LOOP. +*/ + +song_iterator_t *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id); +/* Constructs a new song iterator object +** Parameters: (byte *) data: The song data to iterate over +** (unsigned int) size: Number of bytes in the song +** (int) type: One of the SCI_SONG_ITERATOR_TYPEs +** (songit_id_t) id: An ID for addressing the song iterator +** Returns : (song_iterator_t *) A newly allocated but uninitialized song +** iterator, or NULL if 'type' was invalid or unsupported +*/ + +song_iterator_t *songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy); +/* Combines two iterators, returns the next event available from either +** Parameters: (song_iterator_t *) left: One of the iterators +** (song_iterator_t *) right: The other iterator +** (int) may_destroy: Whether completed song iterators may be +** destroyed +** Returns : (song_iterator_t *) A combined iterator, as suggested above +*/ + + +void songit_free(song_iterator_t *it); +/* Frees a song iterator and the song it wraps +** Parameters: (song_iterator_t *) it: The song iterator to free +** Returns : (void) +*/ + +song_iterator_message_t songit_make_message(songit_id_t id, + int recipient_class, int type, int a1, int a2); +/* Create a song iterator message +** Parameters: (songit_id_t) id: song ID the message is targetted to +** (int) recipient_class: Message recipient class +** (int) type: Message type +** (int x int) a1, a2: Arguments +** You should only use this with the SIMSG_* macros +*/ + +song_iterator_message_t songit_make_ptr_message(songit_id_t id, + int recipient_class, int type, void * a1, int a2); +/* Create a song iterator message, wherein the first parameter is a pointer +** Parameters: (songit_id_t) id: song ID the message is targetted to +** (int) recipient_class: Message recipient class +** (int) type: Message type +** (void* x int) a1, a2: Arguments +** You should only use this with the SIMSG_* macros +*/ + +int songit_handle_message(song_iterator_t **it_reg, song_iterator_message_t msg); +/* Handles a message to the song iterator +** Parameters: (song_iterator_t **): A reference to the variable storing the song iterator +** Returns : (int) Non-zero if the message was understood +** The song iterator may polymorph as result of msg, so a writeable reference is required. +*/ + + +song_iterator_t *songit_clone(song_iterator_t *it, int delta); +/* Clones a song iterator +** Parameters: (song_iterator_t *) it: The iterator to clone +** (int) delta: Number of ticks that still need to elapse until +** the next item should be read from the song iterator +** Returns : (song_iterator_t *) A shallow clone of 'it'. +** This performs a clone on the bottom-most part (containing the actual song data) _only_. +** The justification for requiring 'delta' to be passed in here is that this +** is typically maintained outside of the song iterator. +*/ + + +int sfx_play_iterator_pcm(song_iterator_t *it, unsigned long handle); +/* Plays a song iterator that found a PCM through a PCM device, if possible +** Parameters: (song_iterator_t *) it: The iterator to play +** (song_handle_t) handle: Debug handle +** Returns : (int) 0 if the effect will not be played, nonzero if it will +** This assumes that the last call to 'it->next()' returned SI_PCM. +*/ + +} // End of namespace Sci + +#endif diff --git a/engines/sci/sfx/sfx_iterator_internal.h b/engines/sci/sfx/sfx_iterator_internal.h new file mode 100644 index 0000000000..4c104b5c52 --- /dev/null +++ b/engines/sci/sfx/sfx_iterator_internal.h @@ -0,0 +1,236 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _SFX_ITERATOR_INTERNAL_ +#define _SFX_ITERATOR_INTERNAL_ + +#include "sci/sfx/sfx_iterator.h" +#include "sci/include/sci_midi.h" + +namespace Sci { + +/* States */ + +#define SI_STATE_UNINITIALISED -1 +#define SI_STATE_DELTA_TIME 0 /* Now at a delta time */ +#define SI_STATE_COMMAND 1 /* Now at a MIDI operation */ +#define SI_STATE_PENDING 2 /* Pending for loop */ +#define SI_STATE_FINISHED 3 /* End of song */ +#define SI_STATE_PCM 4 /* Should report a PCM next (-> DELTA_TIME) */ +#define SI_STATE_PCM_MAGIC_DELTA 5 /* Should report a ``magic'' one tick delta time next (goes on to FINISHED) */ + + +/* Iterator types */ + +#define SCI_SONG_ITERATOR_TYPE_SCI0 0 +#define SCI_SONG_ITERATOR_TYPE_SCI1 1 + +#define SIPFX __FILE__" : " + + +typedef struct { + int state; /* SI_STATE_* */ + int offset; /* Offset into the data chunk */ + int end; /* Last allowed byte in track */ + int id; /* Some channel ID */ + int loop_offset; + int delay; /* Number of ticks before the + ** specified channel is next + ** used, or + ** CHANNEL_DELAY_MISSING to + ** indicate that the delay has + ** not yet been read */ + + /* Two additional offsets for recovering: */ + int initial_offset; + int playmask; /* Active playmask (MIDI channels to play in here) */ + int notes_played; /* #of notes played since the last loop start */ + int loop_timepos; /* Total delay for this channel's loop marker */ + int total_timepos; /* Number of ticks since the beginning, ignoring loops */ + int timepos_increment; /* Number of ticks until the next command (to add) */ + + int saw_notes; /* Bitmask of channels we have currently played notes on */ + byte last_cmd; /* Last operation executed, for running status */ +} song_iterator_channel_t; + +#define INHERITS_BASE_SONG_ITERATOR \ + INHERITS_SONG_ITERATOR; /* aka "extends song iterator" */ \ + \ + int polyphony[MIDI_CHANNELS]; /* # of simultaneous notes on each */ \ + int importance[MIDI_CHANNELS]; /* priority rating for each channel, 0 means unrated. */ \ + \ + \ + int ccc; /* Cumulative cue counter, for those who need it */ \ + unsigned char resetflag; /* for 0x4C -- on DoSound StopSound, do we return to start? */ \ + int device_id; /* ID of the device we generating events for */ \ + int active_channels; /* Number of active channels */ \ + unsigned int size; /* Song size */ \ + unsigned char *data; \ + \ + int loops; /* Number of loops remaining */ \ + int recover_delay + +typedef struct _base_song_iterator { + INHERITS_BASE_SONG_ITERATOR; +} base_song_iterator_t; + +/********************************/ +/*--------- SCI 0 --------------*/ +/********************************/ + +typedef struct { + INHERITS_BASE_SONG_ITERATOR; + song_iterator_channel_t channel; + int delay_remaining; /* Number of ticks that haven't been polled yet */ +} sci0_song_iterator_t; + + +/********************************/ +/*--------- SCI 1 --------------*/ +/********************************/ + + +typedef struct _sci1_sample { + int delta; /* Time left-- initially, this is 'Sample point 1'. + ** After initialisation, it is 'sample point 1 minus the sample point of the previous sample' */ + int size; + int announced; /* Announced for download (SI_PCM) */ + sfx_pcm_config_t format; + byte *data; + struct _sci1_sample *next; +} sci1_sample_t; + +typedef struct { + INHERITS_BASE_SONG_ITERATOR; + song_iterator_channel_t channels[MIDI_CHANNELS]; + + /* Invariant: Whenever channels[i].delay == CHANNEL_DELAY_MISSING, + ** channel_offset[i] points to a delta time object. */ + + int initialised; /* Whether the MIDI channel setup has been initialised */ + int channels_nr; /* Number of channels actually used */ + sci1_sample_t *next_sample; + int channels_looped; /* Number of channels that are ready to loop */ + + int delay_remaining; /* Number of ticks that haven't been polled yet */ + int hold; + \ +} sci1_song_iterator_t; + +#define PLAYMASK_NONE 0x0 + +/*********************************/ +/*---------- Cleanup ------------*/ +/*********************************/ + + +song_iterator_t *new_cleanup_iterator(unsigned int channels); +/* Creates a new song iterator with the purpose of sending notes-off channel commands +** Parameters: (unsigned int) channels: Channel mask to send these commands for +** Returns : A song iterator with the aforementioned purpose +*/ + +int is_cleanup_iterator(song_iterator_t *it); +/* Determines whether a given song iterator is a cleanup song iterator +** Parameters: (song_iterator_t *) it: The iterator to check +** Returns : (int) 1 iff 'it' is a cleanup song iterator +** No deep recursion/delegation is considered. +*/ + + +/**********************************/ +/*--------- Fast Forward ---------*/ +/**********************************/ + +typedef struct { + INHERITS_SONG_ITERATOR; + song_iterator_t *delegate; + int delta; /* Remaining time */ +} fast_forward_song_iterator_t; + + +song_iterator_t *new_fast_forward_iterator(song_iterator_t *it, int delta); +/* Creates a new song iterator which fast-forwards +** Parameters: (song_iterator_t *) it: The iterator to wrap +** (int) delta: The number of ticks to skip +** Returns : (song_iterator_t) A newly created song iterator +** which skips all delta times +** until 'delta' has been used up +*/ + +/**********************************/ +/*--------- Fast Forward ---------*/ +/**********************************/ + +#define MAX_BUF_SIZE 4 + +#define TEE_LEFT 0 +#define TEE_RIGHT 1 +#define TEE_LEFT_ACTIVE (1<<0) +#define TEE_RIGHT_ACTIVE (1<<1) +#define TEE_LEFT_READY (1<<2) /* left result is ready */ +#define TEE_RIGHT_READY (1<<3) /* right result is ready */ +#define TEE_LEFT_PCM (1<<4) +#define TEE_RIGHT_PCM (1<<5) + +#define TEE_MORPH_NONE 0 /* Not waiting to self-morph */ +#define TEE_MORPH_READY 1 /* Ready to self-morph */ + +typedef struct { + INHERITS_SONG_ITERATOR; + + int status; + + int may_destroy; /* May destroy song iterators */ + + int morph_deferred; /* One of TEE_MORPH_* above */ + + struct { + song_iterator_t *it; + byte buf[MAX_BUF_SIZE]; + int result; + int retval; + + byte channel_remap[MIDI_CHANNELS]; + /* Remapping for channels */ + + } children[2]; +} tee_song_iterator_t; + + +sfx_pcm_feed_t *sfx_iterator_make_feed(byte *base_data, int offset, + int size, + sfx_pcm_config_t conf); +/* Generates a feed for a song iterator +** Parameters: (byte *) base_data: A refcounted memory chunk containing +** (among other things) PCM data +** (int) offset; Offset into base_data +** (int) size: Number of bytes to consider +** (pcm_data_internal_t) conf: PCM encoding +*/ + +} // End of namespace Sci + +#endif /* !defined(_SFX_ITERATOR_INTERNAL_ */ diff --git a/engines/sci/sfx/sfx_pcm.h b/engines/sci/sfx/sfx_pcm.h new file mode 100644 index 0000000000..abb1704741 --- /dev/null +++ b/engines/sci/sfx/sfx_pcm.h @@ -0,0 +1,184 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _SFX_PCM_H_ +#define _SFX_PCM_H_ + +#include "sci/sfx/sfx_core.h" +#include "sci/sfx/sfx_timer.h" +#include "sci/sfx/sfx_time.h" +#include "sci/include/scitypes.h" + +namespace Sci { + +#define SFX_PCM_MONO 0 +#define SFX_PCM_STEREO_LR 1 /* left sample, then right sample */ +#define SFX_PCM_STEREO_RL 2 /* right sample, then left sample */ + +/* The following are used internally by the mixer */ +#define SFX_PCM_FORMAT_LMASK 0x7 +#define SFX_PCM_FORMAT_BE 0 +#define SFX_PCM_FORMAT_LE 1 +#define SFX_PCM_FORMAT_ENDIANNESS 1 +#define SFX_PCM_FORMAT_8 0 +#define SFX_PCM_FORMAT_16 2 + + +/* Pick one of these formats (including the _NATIVE) ones for your PCM feed */ +#define SFX_PCM_FORMAT_U8 (0x0080 | SFX_PCM_FORMAT_8) /* Unsigned (bias 128) 8 bit format */ +#define SFX_PCM_FORMAT_S8 (0x0000 | SFX_PCM_FORMAT_8) /* Signed 8 bit format */ +#define SFX_PCM_FORMAT_U16_LE (0x8000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_LE) /* Unsigned (bias 32768) 16 bit LE format */ +#define SFX_PCM_FORMAT_S16_LE (0x0000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_LE) /* Signed 16 bit format, little endian */ +#define SFX_PCM_FORMAT_U16_BE (0x8000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_BE) /* Unsigned (bias 32768) 16 bit BE format */ +#define SFX_PCM_FORMAT_S16_BE (0x0000 | SFX_PCM_FORMAT_16 | SFX_PCM_FORMAT_BE) /* Signed 16 bit format, big endian */ + +#ifdef SCUMM_BIG_ENDIAN +# define SFX_PCM_FORMAT_U16_NATIVE SFX_PCM_FORMAT_U16_BE +# define SFX_PCM_FORMAT_S16_NATIVE SFX_PCM_FORMAT_S16_BE +#else +# define SFX_PCM_FORMAT_U16_NATIVE SFX_PCM_FORMAT_U16_LE +# define SFX_PCM_FORMAT_S16_NATIVE SFX_PCM_FORMAT_S16_LE +#endif + +#define SFX_PCM_FRAME_SIZE(conf) ((conf).stereo? 2 : 1) * (((conf).format & SFX_PCM_FORMAT_16)? 2 : 1) + + +typedef struct { + int rate; /* Sampling rate */ + int stereo; /* The stereo mode used (SFX_PCM_MONO or SFX_PCM_STEREO_*) */ + unsigned int format; /* Sample format (SFX_PCM_FORMAT_*) */ +} sfx_pcm_config_t; + +typedef struct _sfx_pcm_device { + /* SFX devices are PCM players, i.e. output drivers for digitalised audio (sequences of audio samples). + ** Implementors are (in general) allowed to export specifics of these devices and let the mixer handle + ** endianness/signedness/bit size/mono-vs-stereo conversions. + */ + + int (*init)(struct _sfx_pcm_device *self); + /* Initializes the device + ** Parameters: (sfx_pcm_device_t *) self: Self reference + ** Returns : (int) SFX_OK on success, SFX_ERROR if the device could not be + ** opened + ** This should attempt to open the highest quality output allowed by any options + ** specified beforehand. + */ + + int (*output)(struct _sfx_pcm_device *self, byte *buf, + int count, sfx_timestamp_t *timestamp); + /* Writes output to the device + ** Parameters: (sfx_pcm_device_t *) self: Self reference + ** (byte *) buf: The buffer to write + ** (int) count: Number of /frames/ that should be written + ** (sfx_timestamp_t *) timestamp: Optional point in time + ** for which the PCM data is scheduled + ** Returns : (int) SFX_OK on success, SFX_ERROR on error + ** The size of the buffer allocated as 'buf' equals buf_size. + ** 'buf' is guaranteed not to be modified in between calls to 'output()'. + ** 'timestamp' is guaranteed to be used only in sequential order, but not + ** guaranteed to be used in all cases. It is guaranteed to be compaible with + ** the sample rate used by the device itself (i.e., the sfx_time.h functionality + ** is applicable) + */ + + sfx_timestamp_t + (*get_output_timestamp)(struct _sfx_pcm_device *self); + /* Determines the timestamp for 'output' + ** Parameters: (sfx_pcm_device_t *) self: Self reference + ** Returns : (sfx_timestamp_t) A timestamp (with the device's conf.rate) + ** describing the point in time at which + ** the next frame passed to 'output' + ** will be played + ** This function is OPTIONAL and may be NULL, but it is recommended + ** that pcm device implementers attempt to really implement it. + */ + + /* The following must be set after initialisation */ + sfx_pcm_config_t conf; + int buf_size; /* Output buffer size, i.e. the number of frames (!) + ** that can be queued by this driver before calling + ** output() will block or fail, drained according + ** to conf.rate */ + +} sfx_pcm_device_t; + + +#define PCM_FEED_TIMESTAMP 0 /* New timestamp available */ +#define PCM_FEED_IDLE 1 /* No sound ATM, but new timestamp may be available later */ +#define PCM_FEED_EMPTY 2 /* Feed is finished, can be destroyed */ + +typedef struct _sfx_pcm_feed_t { + /* PCM feeds are sources of input for the PCM mixer. Their member functions + ** are invoked as callbacks on demand, to provide the mixer with input it + ** (in turn) passes on to PCM output devices. + ** PCM feeds must explicitly register themselves with the mixer in order + ** to be considered. + */ + + int (*poll)(struct _sfx_pcm_feed_t *self, byte *dest, int size); + /* Asks the PCM feed to write out the next stuff it would like to have written + ** Parameters: (sfx_pcm_feed_t *) self: Self reference + ** (byte *) dest: The destination buffer to write to + ** (int) size: The maximum number of _frames_ (not neccessarily bytes) + ** to write + ** Returns : (int) The number of frames written + ** If the number of frames written is smaller than 'size', the PCM feed will + ** be queried for a new timestamp afterwards, or destroyed if no new timestamp + ** is available. + */ + + void (*destroy)(struct _sfx_pcm_feed_t *self); + /* Asks the PCM feed to free all resources it occupies + ** Parameters: (sfx_pcm_feed_t *) self: Self reference + ** free(self) should be part of this function, if applicable. + */ + + int + (*get_timestamp)(struct _sfx_pcm_feed_t *self, sfx_timestamp_t *timestamp); + /* Determines the timestamp of the next frame-to-read + ** Returns : (sfx_timestamp_t) timestamp: The timestamp of the next frame + ** (int) PCM_FEED_* + ** This function is OPTIONAL and may be NULL + */ + + void *internal; /* The private bits of a PCM feed. */ + + sfx_pcm_config_t conf; /* The channel's setup */ + + const char *debug_name; /* The channel name, for debugging */ + int debug_nr; /* A channel number relative to the channel name, for debugging + ** (print in hex) */ + int frame_size; /* Frame size, computed by the mixer for the feed */ + +} sfx_pcm_feed_t; + +int sfx_pcm_available(); +/* Determines whether a PCM device is available and has been initialised +** Returns : (int) zero iff no PCM device is available +*/ + +} // End of namespace Sci + +#endif /* !defined(_SFX_PCM_H_) */ diff --git a/engines/sci/sfx/sfx_player.h b/engines/sci/sfx/sfx_player.h new file mode 100644 index 0000000000..b1e6695f14 --- /dev/null +++ b/engines/sci/sfx/sfx_player.h @@ -0,0 +1,154 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* song player structure */ + +#ifndef _SFX_PLAYER_H +#define _SFX_PLAYER_H + +#include "sci/sfx/sfx_engine.h" +#include "sci/sfx/sfx_iterator.h" +#include "sci/include/sciresource.h" + +namespace Sci { + +typedef void tell_synth_func(int buf_nr, byte *buf); + +typedef struct { + const char *name; + const char *version; + + int (*set_option)(char *name, char *value); + /* Sets an option for player timing mechanism + ** Parameters: (char *) name: The name describing what to set + ** (char *) value: The value to set + ** Returns : (int) SFX_OK, or SFX_ERROR if the name wasn't understood + */ + + int (*init)(ResourceManager *resmgr, int expected_latency); + /* Initializes the player + ** Parameters: (ResourceManager *) resmgr: A resource manager for driver initialization + ** (int) expected_latency: Expected delay in between calls to 'maintenance' + ** (in microseconds) + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + */ + + int (*add_iterator)(song_iterator_t *it, GTimeVal start_time); + /* Adds an iterator to the song player + ** Parameters: (songx_iterator_t *) it: The iterator to play + ** (GTimeVal) start_time: The time to assume as the + ** time the first MIDI command executes at + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + ** The iterator should not be cloned (to avoid memory leaks) and + ** may be modified according to the needs of the player. + ** Implementors may use the 'sfx_iterator_combine()' function + ** to add iterators onto their already existing iterators + */ + + int (*fade_out)(); + /* Fades out the currently playing song (within two seconds + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + */ + + int (*stop)(); + /* Stops the currently playing song and deletes the associated iterator + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + */ + + int (*iterator_message)(song_iterator_message_t msg); + /* Transmits a song iterator message to the active song + ** Parameters: (song_iterator_message_t) msg: The message to transmit + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + ** OPTIONAL -- may be NULL + ** If this method is not present, sending messages will stop + ** and re-start playing, so it is preferred that it is present + */ + + int (*pause)(); /* OPTIONAL -- may be NULL */ + /* Pauses song playing + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + */ + + int (*resume)(); /* OPTIONAL -- may be NULL */ + /* Resumes song playing after a pause + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + */ + + int (*exit)(); + /* Stops the player + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + */ + + void (*maintenance)(); /* OPTIONAL -- may be NULL */ + /* Regularly called maintenance function + ** This function is called frequently and regularly (if present), it can be + ** used to emit sound. + */ + + tell_synth_func *tell_synth; + /* Pass a raw MIDI event to the synth + Parameters: (int) argc: Length of buffer holding the midi event + (byte *) argv: The buffer itself + */ + + int polyphony; /* Number of voices that can play simultaneously */ + +} sfx_player_t; + +sfx_player_t *sfx_find_player(char *name); +/* Looks up a player by name or finds the default player +** Parameters: (char *) name: Name of the player to look up, or NULL for dedault +** Returns : (sfx_player_t *) The player requested, or NULL if none was found +*/ + +tell_synth_func *sfx_get_player_tell_func(); +/* Gets the callback function of the player in use. +** Returns: (tell_synth_func *) The callback function. +*/ + +int sfx_get_player_polyphony(); +/* Determines the polyphony of the player in use +** Returns : (int) Number of voices the active player can emit +*/ + +void sfx_reset_player(); +/* Tells the player to stop its internal iterator +** Parameters: None. +** Returns: Nothing. + */ + +song_iterator_t *sfx_iterator_combine(song_iterator_t *it1, song_iterator_t *it2); +/* Combines two song iterators into one +** Parameters: (sfx_iterator_t *) it1: One of the two iterators, or NULL +** (sfx_iterator_t *) it2: The other iterator, or NULL +** Returns : (sfx_iterator_t *) A combined iterator +** If a combined iterator is returned, it will be flagged to be allowed to +** dispose of 'it1' and 'it2', where applicable. This means that this +** call should be used by song players, but not by the core sound system +*/ + +} // End of namespace Sci + +#endif /* !_SFX_PLAYER_H */ diff --git a/engines/sci/sfx/sfx_songlib.h b/engines/sci/sfx/sfx_songlib.h new file mode 100644 index 0000000000..6b968bbe08 --- /dev/null +++ b/engines/sci/sfx/sfx_songlib.h @@ -0,0 +1,191 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Song library */ + +#ifndef _SCI_SFX_SONGLIB_H_ +#define _SCI_SFX_SONGLIB_H_ + +#include "common/scummsys.h" + +#include "sci/tools.h" // For GTimeVal +#include "sci/include/scitypes.h" +#include "sci/sfx/sfx_iterator.h" + +namespace Sci { + +#define SOUND_STATUS_STOPPED 0 +#define SOUND_STATUS_PLAYING 1 +#define SOUND_STATUS_SUSPENDED 2 +/* suspended: only if ordered from kernel space */ +#define SOUND_STATUS_WAITING 3 +/* "waiting" means "tagged for playing, but not active right now" */ + +typedef unsigned long song_handle_t; + +typedef enum { + RESTORE_BEHAVIOR_CONTINUE, /* restart a song when restored from + a saved game */ + RESTORE_BEHAVIOR_RESTART /* continue it from where it was */ +} RESTORE_BEHAVIOR; + +typedef struct _song { + song_handle_t handle; + int resource_num; /* Resource number */ + int priority; /* Song priority (more important if priority is higher) */ + int status; /* See above */ + + int restore_behavior; + int restore_time; + + /* Grabbed from the sound iterator, for save/restore purposes */ + int loops; + int hold; + + song_iterator_t *it; + long delay; /* Delay before accessing the iterator, in microseconds */ + + GTimeVal wakeup_time; /* Used by the sound core: + ** Playing -> time at which 'delay' has elapsed + ** Suspended/Waiting -> stopping time */ + + struct _song *next; /* Next song or NULL if this is the last one */ + struct _song *next_playing; /* Next playing song; used by the + ** core song system */ + struct _song *next_stopping; /* Next song pending stopping; used exclusively by + ** the core song system's _update_multi_song() */ +} song_t; + + +typedef struct { + song_t **lib; + song_t *_s; +} songlib_t; + +/**************************/ +/* Song library commands: */ +/**************************/ + +song_t *song_new(song_handle_t handle, song_iterator_t *it, int priority); +/* Initializes a new song +** Parameters: (song_handle_t) handle: The sound handle +** (song_iterator_t *) it: The song +** (int) priority: The song's priority +** Returns : (song_t *) A freshly allocated song +** Other values are set to predefined defaults. +*/ + + +void song_lib_init(songlib_t *songlib); +/* Initializes a static song library +** Parameters: (songlib_t *) songlib: Pointer to the library +** to initialize +** Returns : (void) +*/ + +void song_lib_free(songlib_t songlib); +/* Frees a song library +** Parameters: (songlib_t) songlib: The library to free +** Returns : (void) +*/ + +void song_lib_add(songlib_t songlib, song_t *song); +/* Adds a song to a song library. +** Parameters: (songlib_t) songlib: An existing sound library, or NULL +** (song_t *) song: The song to add +** Returns : (void) +*/ + +song_t *song_lib_find(songlib_t songlib, song_handle_t handle); +/* Looks up the song with the specified handle +** Parameters: (songlib_t) songlib: An existing sound library, may point to NULL +** (song_handle_t) handle: The sound handle to look for +** Returns : (song_t *) The song or NULL if it wasn't found +*/ + +song_t *song_lib_find_active(songlib_t songlib); +/* Finds the first song playing with the highest priority +** Parameters: (songlib_t) songlib: An existing sound library +** Returns : (song_t *) The song that should be played next, or NULL if there is none +*/ + +song_t *song_lib_find_next_active(songlib_t songlib, song_t *song); +/* Finds the next song playing with the highest priority +** Parameters: (songlib_t) songlib: The song library to operate on +** (song_t *) song: A song previously returned from the song library +** Returns : (song_t *) The next song to play relative to 'song', or +** NULL if none are left +** The functions 'song_lib_find_active' and 'song_lib_find_next_active +** allow to iterate over all songs that satisfy the requirement of +** being 'playable'. +*/ + +int song_lib_remove(songlib_t songlib, song_handle_t handle); +/* Removes a song from the library +** Parameters: (songlib_t) songlib: An existing sound library +** (song_handle_t) handle: Handle of the song to remove +** Returns : (int) The status of the song that was removed +*/ + +void song_lib_resort(songlib_t songlib, song_t *song); +/* Removes a song from the library and sorts it in again; for use after renicing +** Parameters: (songlib_t) songlib: An existing sound library +** (song_t *) song: The song to work on +** Returns : (void) +*/ + +int song_lib_count(songlib_t songlib); +/* Counts the number of songs in a song library +** Parameters: (songlib_t) songlib: The library to count +** Returns : (int) The number of songs +*/ + +GTimeVal song_sleep_time(GTimeVal *lastslept, long ticks); +/* Caluculates the amount of seconds and microseconds to sleep. +** Parameters: (GTimeVal *) lastslept: The time to start counting on +** (long) ticks: Number of ticks to sleep +** Returns : (GTimeVal) The amount of time to sleep +*/ + +GTimeVal song_next_wakeup_time(GTimeVal *lastslept, long ticks); +/* Calculates the time at which "ticks" have passed, counting from "lastslept". +** Parameters: (GTimeVal *) lastslept: The base to start counting on +** (long) ticks: Number of ticks to count +** Returns : (GTimeVal) A structure describing the time at which the +** specified number of ticks has passed +*/ + +void song_lib_set_restore_behavior(songlib_t songlib, song_handle_t handle, + RESTORE_BEHAVIOR action); +/* Determines what should be done with the song "handle" when +** restoring it from a saved game. +** Parameters: (songlib_t) songlib: The library that contains the song +** (song_handle_t) handle: Its handle +** (RESTORE_BEHAVIOR) action: The desired action +*/ + +} // End of namespace Sci + +#endif /* !_SCI_SOUND_SERVER_H_ */ diff --git a/engines/sci/sfx/sfx_time.h b/engines/sci/sfx/sfx_time.h new file mode 100644 index 0000000000..d362dfa381 --- /dev/null +++ b/engines/sci/sfx/sfx_time.h @@ -0,0 +1,85 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _SFX_TIME_H_ +#define _SFX_TIME_H_ + +namespace Sci { + +typedef struct { + long secs; + long usecs; + int frame_rate; + int frame_offset; + /* Total time: secs + usecs + frame_offset/frame_rate */ +} sfx_timestamp_t; + + +sfx_timestamp_t sfx_new_timestamp(long secs, long usecs, int frame_rate); +/* Creates a new mutable timestamp +** Parameters: (long x long) (secs, usecs): Initial timestamp +** (int) frame_rate: Frame rate, for increasing the time stamp +*/ + +sfx_timestamp_t sfx_timestamp_add(sfx_timestamp_t timestamp, int frames); +/* Adds a number of frames to a timestamp +** Parameters: (sfx_timestampt_t *) timestamp: The timestamp to update +** (int) frames: Number of frames to add +** Returns : (sfx_timestamp_t) The increased timestamp +*/ + +sfx_timestamp_t sfx_timestamp_renormalise(sfx_timestamp_t timestamp, int new_freq); +/* Translates a timestamp to a new base frame frequency +** Parameters: (sfx_timestamp_t *) timestamp: The timestamp to normalise +** (int) new_freq: The new frequency to normalise to +** Returns : (sfx_timestamp_t) The re-normalised timestamp +** The translation looses accuracy in the order of magnitude of milliseconds +** for "usual" sampling frequencies. +*/ + +int sfx_timestamp_frame_diff(sfx_timestamp_t a, sfx_timestamp_t b); +/* Computes the difference (# of frames) between two timestamps +** Parameters: (sfx_timestamp) a: See below +** (sfx_timestamp) b: See below +** Returns : (int) a-b +*/ + +long sfx_timestamp_usecs_diff(sfx_timestamp_t a, sfx_timestamp_t b); +/* Computes the difference (# of microseconds) between two timestamps +** Parameters: (sfx_timestamp) a: See below +** (sfx_timestamp) b: See below +** Returns : (long) a-b +*/ + +void sfx_timestamp_gettime(sfx_timestamp_t *timestamp, long *secs, long *usecs); +/* Determines the time described by a given timestamp +** Parameters: (sfx_timestamp_t *) timestamp: Timestamp to read from +** Returns : (int * x int *) (secs, usecs): Seconds and microseconds since +** the epoch described there +*/ + +} // End of namespace Sci + +#endif /* !defined(_SFX_TIME_H_) */ diff --git a/engines/sci/sfx/sfx_timer.h b/engines/sci/sfx/sfx_timer.h new file mode 100644 index 0000000000..581f7d1ac5 --- /dev/null +++ b/engines/sci/sfx/sfx_timer.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _FREESCI_SFX_TIMER_H_ +#define _FREESCI_SFX_TIMER_H_ + +#include "sci/sfx/sfx_core.h" + +namespace Sci { + +typedef struct { + int delay_ms; /* Approximate delay (in milliseconds) between calls */ + + int (*init)(void (*callback)(void *data), void *data); + /* Initializes the timer + ** Parameters: (void* -> void) callback: + ** 'data' must contain the next argument: + ** (void *) data: Must always be passed to the callback + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + ** This does not start the timer yet, it just specifies and initializes it. + ** This function is called exactly once (provided that the timer is used at all). + */ + + int (*exit)(); + /* Stops the timer + ** Returns : (int) SFX_OK on success, SFX_ERROR on failure + ** All resources allocated with the timer should be freed as an effect + ** of this. + */ +} sfx_timer_t; + +} // End of namespace Sci + +#endif /* !_FREESCI_SFX_TIMER_H_ */ diff --git a/engines/sci/sfx/softseq.h b/engines/sci/sfx/softseq.h index 91c50ff3ec..5a2def8f41 100644 --- a/engines/sci/sfx/softseq.h +++ b/engines/sci/sfx/softseq.h @@ -26,8 +26,8 @@ #ifndef SCI_SFX_SOFTSEQ_H #define SCI_SFX_SOFTSEQ_H -#include "sci/include/sfx_core.h" -#include "sci/include/sfx_pcm.h" +#include "sci/sfx/sfx_core.h" +#include "sci/sfx/sfx_pcm.h" #include "sci/sfx/sequencer.h" #include "sci/tools.h" diff --git a/engines/sci/sfx/softseq/opl2.cpp b/engines/sci/sfx/softseq/opl2.cpp index 1de9bd4659..81a0d13fc3 100644 --- a/engines/sci/sfx/softseq/opl2.cpp +++ b/engines/sci/sfx/softseq/opl2.cpp @@ -43,7 +43,7 @@ ***************************************************************************/ #include "sci/tools.h" -#include "sci/include/sfx_iterator.h" +#include "sci/sfx/sfx_iterator.h" #include "../softseq.h" #include "../adlib.h" #include diff --git a/engines/sci/sfx/songlib.cpp b/engines/sci/sfx/songlib.cpp index 4adc1efa25..d98e387a96 100644 --- a/engines/sci/sfx/songlib.cpp +++ b/engines/sci/sfx/songlib.cpp @@ -24,7 +24,7 @@ */ #include -#include "sci/include/sfx_engine.h" +#include "sci/sfx/sfx_engine.h" #include "sci/include/sci_memory.h" namespace Sci { diff --git a/engines/sci/sfx/time.cpp b/engines/sci/sfx/time.cpp index 418343584a..720c233968 100644 --- a/engines/sci/sfx/time.cpp +++ b/engines/sci/sfx/time.cpp @@ -23,7 +23,7 @@ * */ -#include "sci/include/sfx_time.h" +#include "sci/sfx/sfx_time.h" #include "sci/tools.h" namespace Sci { diff --git a/engines/sci/sfx/timer.cpp b/engines/sci/sfx/timer.cpp index ba2453579d..d58de323cd 100644 --- a/engines/sci/sfx/timer.cpp +++ b/engines/sci/sfx/timer.cpp @@ -25,7 +25,7 @@ #include "common/timer.h" #include "engines/engine.h" -#include "sci/include/sfx_timer.h" +#include "sci/sfx/sfx_timer.h" namespace Sci { -- cgit v1.2.3