aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r--engines/sci/gfx/antialias.cpp4
-rw-r--r--engines/sci/gfx/font-5x8.cpp2
-rw-r--r--engines/sci/gfx/font-6x10.cpp2
-rw-r--r--engines/sci/gfx/font.cpp6
-rw-r--r--engines/sci/gfx/gfx_driver.cpp4
-rw-r--r--engines/sci/gfx/gfx_driver.h322
-rw-r--r--engines/sci/gfx/gfx_operations.h684
-rw-r--r--engines/sci/gfx/gfx_options.h87
-rw-r--r--engines/sci/gfx/gfx_res_options.cpp6
-rw-r--r--engines/sci/gfx/gfx_res_options.h110
-rw-r--r--engines/sci/gfx/gfx_resmgr.h338
-rw-r--r--engines/sci/gfx/gfx_resource.cpp6
-rw-r--r--engines/sci/gfx/gfx_resource.h414
-rw-r--r--engines/sci/gfx/gfx_state_internal.h239
-rw-r--r--engines/sci/gfx/gfx_support.cpp4
-rw-r--r--engines/sci/gfx/gfx_system.h395
-rw-r--r--engines/sci/gfx/gfx_tools.cpp2
-rw-r--r--engines/sci/gfx/gfx_tools.h257
-rw-r--r--engines/sci/gfx/gfx_widgets.h520
-rw-r--r--engines/sci/gfx/operations.cpp2
-rw-r--r--engines/sci/gfx/resmgr.cpp10
-rw-r--r--engines/sci/gfx/resource/sci_cursor_0.cpp6
-rw-r--r--engines/sci/gfx/resource/sci_font.cpp6
-rw-r--r--engines/sci/gfx/resource/sci_pal_1.cpp4
-rw-r--r--engines/sci/gfx/resource/sci_pic_0.cpp4
-rw-r--r--engines/sci/gfx/resource/sci_picfill.cpp2
-rw-r--r--engines/sci/gfx/resource/sci_resmgr.cpp6
-rw-r--r--engines/sci/gfx/resource/sci_view_0.cpp6
-rw-r--r--engines/sci/gfx/resource/sci_view_1.cpp6
-rw-r--r--engines/sci/gfx/sbtree.cpp4
-rw-r--r--engines/sci/gfx/sbtree.h110
-rw-r--r--engines/sci/gfx/sci_widgets.cpp4
-rw-r--r--engines/sci/gfx/widgets.cpp2
33 files changed, 3524 insertions, 50 deletions
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 <ctype.h>
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 a<b, =0 if a=b and >0 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 <ctype.h>
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 <time.h> // 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 <stdlib.h>
-#include <stdio.h>
+#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 <stdio.h>
+#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 {