aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kgraphics.cpp2
-rw-r--r--engines/sci/engine/scriptdebug.cpp2
-rw-r--r--engines/sci/gfx/gfx_driver.cpp2
-rw-r--r--engines/sci/gfx/gfx_resmgr.h177
-rw-r--r--engines/sci/gfx/gfx_resource.cpp16
-rw-r--r--engines/sci/gfx/gfx_resource.h10
-rw-r--r--engines/sci/gfx/gfx_tools.cpp11
-rw-r--r--engines/sci/gfx/gfx_tools.h5
-rw-r--r--engines/sci/gfx/operations.cpp74
-rw-r--r--engines/sci/gfx/resmgr.cpp162
-rw-r--r--engines/sci/gfx/resource/res_manager.cpp88
-rw-r--r--engines/sci/gfx/resource/res_pic.cpp6
-rw-r--r--engines/sci/gfx/resource/res_view0.cpp4
-rw-r--r--engines/sci/gfx/resource/res_view1.cpp12
14 files changed, 231 insertions, 340 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 446f5be4b7..b3957a251d 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -2350,7 +2350,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) {
UKPV(3), UKPV(2));
// FIXME: Should really only invalidate all loaded pic resources here;
// this is overkill
- gfxr_free_all_resources(s->gfx_state->driver, s->gfx_state->resstate);
+ gfxr_free_all_resources(s->gfx_state->resstate);
break;
}
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 10b8dbfa79..c5c00ceff1 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -2011,7 +2011,7 @@ static int c_gfx_flush_resources(EngineState *s) {
gfxop_set_pointer_cursor(s->gfx_state, GFXOP_NO_POINTER);
sciprintf("Flushing resources...\n");
s->visual->widfree(GFXW(s->visual));
- gfxr_free_all_resources(s->gfx_state->driver, s->gfx_state->resstate);
+ gfxr_free_all_resources(s->gfx_state->resstate);
s->visual = NULL;
return 0;
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp
index e8d2366a59..985033de09 100644
--- a/engines/sci/gfx/gfx_driver.cpp
+++ b/engines/sci/gfx/gfx_driver.cpp
@@ -94,7 +94,7 @@ static void scummvm_exit(gfx_driver_t *drv) {
int i;
if (S) {
for (i = 0; i < 2; i++) {
- gfx_free_pixmap(drv, S->priority[i]);
+ gfx_free_pixmap(S->priority[i]);
S->priority[i] = NULL;
}
diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h
index df6484627e..675bda6eb2 100644
--- a/engines/sci/gfx/gfx_resmgr.h
+++ b/engines/sci/gfx/gfx_resmgr.h
@@ -114,34 +114,22 @@ gfx_resstate_t *gfxr_new_resource_manager(int version, gfx_options_t *options,
** 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);
+void gfxr_free_resource_manager(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
+** Parameters: (gfx_resstate_t *) state: The state manager to free
** Return : (void)
*/
-void gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state);
+void gfxr_free_all_resources(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
+** Parameter: (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);
+void gfxr_free_tagged_resources(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
+** Parameters: (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.
@@ -150,19 +138,64 @@ void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state);
*/
-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.
-*/
+class GfxResManager {
+public:
+ GfxResManager(gfx_resstate_t *state) : _state(state) {}
+ ~GfxResManager() {}
+
+ /* 'Tags' all resources for deletion
+ ** Paramters: (void)
+ ** Returns : (void)
+ ** Tagged resources are untagged if they are referenced.
+ */
+ void tagResources() { (_state->tag_lock_counter)++; }
+
+ /* Retreives an SCI0/SCI01 mouse cursor
+ ** Parameters: (int) num: The cursor number
+ ** Returns : (gfx_font_t *) The approprate cursor as a pixmap, or NULL on error
+ */
+ gfx_pixmap_t *getCursor(int num);
+
+
+ /* Retreives the static palette from the interpreter-specific code
+ ** Parameters: (int *) colors_nr: Number of colors to use
+ ** (int) nr: The palette to read
+ ** Returns : (gfx_pixmap_color_t *) *colors_nr static color entries
+ ** if a static palette must be used, NULL otherwise
+ */
+ Palette *getPalette(int *colors_nr, int num = 999);
+
+
+ /* Retreives a font
+ ** Parameters: (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_bitmap_font_t *getFont(int num, bool scaled = false);
+
+
+ /* Retreives a displayable (translated) pic resource
+ ** Parameters: (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)
+ ** (bool) 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 *getPic(int num, int maps, int flags, int default_palette, bool scaled = false);
+
+
+ /* Determines whether support for pointers with more than two colors is required
+ ** Returns : (bool) false if no support for multi-colored pointers is required, true
+ ** otherwise
+ */
+ bool multicoloredPointers() { return _state->version > SCI_VERSION_1; }
+
+private:
+ gfx_resstate_t *_state;
+};
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);
@@ -195,30 +228,6 @@ gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, i
** loop and cel numbers have to be interpreted as 'maximum' or 'minimum' by the interpreter)
*/
-gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_t *state, int nr, int scaled);
-/* Retreives a font
-** Parameters: (ResourceManager&) resourceManager: supplies the resource repository capability
-** (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 */
/* =========================== */
@@ -241,23 +250,6 @@ int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version,
** (Yes, this isn't really a "hash" in the traditional sense...)
*/
-gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID);
-/* 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
-** Returns : (gfxr_pic_t *) A newly allocated pic
-** This function is typically called befode gfxr_interpreter_clear_pic().
-*/
-
-void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic);
-/* Clears a previously allocated pic
-** Parameters: (int) version: Interpreter version
-** (gfxr_pic_t *) pic: The pic to clear
-** 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);
/* Instructs the interpreter-specific code to calculate a picture
@@ -281,47 +273,6 @@ gfxr_view_t *gfxr_interpreter_get_view(ResourceManager& resourceManager, int nr,
** Returns : (gfx_view_t *) The appropriate view, or NULL on error
*/
-gfx_bitmap_font_t *gfxr_interpreter_get_font(ResourceManager& resourceManager, int nr);
-/* Instructs the interpreter-specific code to calculate a font
-** Parameters: (ResourceManager& ) resourceManager: The resource manager
-** (int) nr: The font resource number
-** Returns : (gfx_font_t *) The newly calculated font, or NULL on error
-*/
-
-gfx_pixmap_t *gfxr_interpreter_get_cursor(ResourceManager& resourceManager, int nr, int version);
-/* Instructs the interpreter-specific code to calculate a cursor
-** Parameters: (ResourceManager& ) state: The resource manager
-** (int nr): The cursor resource number
-** (int version): The SCI version used
-** Returns : (gfx_pixmap_t *) The cursor pixmap, or NULL on error
-*/
-
-Palette *gfxr_interpreter_get_static_palette(ResourceManager& resourceManager, int version, int *colors_nr);
-/* Retreives the static palette (palette 999) from the interpreter-specific code
-** Parameters: (ResourceManager& ) state: The resource manager
-** (int) version: Interpreter version to use
-** (int *) colors_nr: Number of colors to use
-** Returns : (gfx_pixmap_color_t *) *colors_nr static color entries
-** if a static palette must be used, NULL otherwise
-*/
-
-Palette *gfxr_interpreter_get_palette(ResourceManager& resourceManager, int version, int *colors_nr, int nr);
-/* Retreives the static palette from the interpreter-specific code
-** Parameters: (ResourceManager& ) state: The resource manager
-** (int) version: Interpreter version to use
-** (int *) colors_nr: Number of colors to use
-** (int) nr: The palette to read
-** 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);
-/* Determines whether support for pointers with more than two colors is required
-** Parameters: (int) version: Interpreter version to test for
-** Returns : (int) 0 if no support for multi-colored pointers is required, non-0
-** otherwise
-*/
-
} // End of namespace Sci
#endif // SCI_GFX_GFX_RSMGR_H
diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp
index b2e2eb4320..387f6e596b 100644
--- a/engines/sci/gfx/gfx_resource.cpp
+++ b/engines/sci/gfx/gfx_resource.cpp
@@ -40,19 +40,19 @@ gfx_mode_t mode_1x1_color_index = { /* Fake 1x1 mode */
};
-static void gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) {
+static void gfxr_free_loop(gfxr_loop_t *loop) {
int i;
if (loop->cels) {
for (i = 0; i < loop->cels_nr; i++)
if (loop->cels[i])
- gfx_free_pixmap(driver, loop->cels[i]);
+ gfx_free_pixmap(loop->cels[i]);
free(loop->cels);
}
}
-void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) {
+void gfxr_free_view(gfxr_view_t *view) {
int i;
if (view->palette)
@@ -60,7 +60,7 @@ void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) {
if (view->loops) {
for (i = 0; i < view->loops_nr; i++)
- gfxr_free_loop(driver, view->loops + i);
+ gfxr_free_loop(view->loops + i);
free(view->loops);
}
@@ -393,10 +393,10 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t fi
}
}
-void gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic) {
- gfx_free_pixmap(driver, pic->visual_map);
- gfx_free_pixmap(driver, pic->priority_map);
- gfx_free_pixmap(driver, pic->control_map);
+void gfxr_free_pic(gfxr_pic_t *pic) {
+ gfx_free_pixmap(pic->visual_map);
+ gfx_free_pixmap(pic->priority_map);
+ gfx_free_pixmap(pic->control_map);
pic->visual_map = NULL;
pic->priority_map = NULL;
pic->control_map = NULL;
diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h
index fba47c4f2f..6979e9a9b4 100644
--- a/engines/sci/gfx/gfx_resource.h
+++ b/engines/sci/gfx/gfx_resource.h
@@ -140,17 +140,15 @@ gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1);
** This function allocates memory for use by resource drawer functions.
*/
-void gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic);
+void gfxr_free_pic(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
+** Parameters: (gfxr_pic_t *) pic: The pic to free
** Returns : (void)
*/
-void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view);
+void gfxr_free_view(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
+** Paremeters: (gfxr_view_t *) view: The view to free
** Returns : (void)
*/
diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp
index e650aee111..4ac71c0459 100644
--- a/engines/sci/gfx/gfx_tools.cpp
+++ b/engines/sci/gfx/gfx_tools.cpp
@@ -81,6 +81,7 @@ void gfx_free_mode(gfx_mode_t *mode) {
if (mode->palette)
mode->palette->free();
free(mode);
+ mode = NULL;
}
void gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) {
@@ -146,13 +147,9 @@ gfx_pixmap_t *gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) {
return pxm;
}
-void gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) {
- if (driver) {
- if (driver->mode->palette) {
- if (pxm->palette)
- pxm->palette->free();
- }
- }
+void gfx_free_pixmap(gfx_pixmap_t *pxm) {
+ if (pxm->palette)
+ pxm->palette->free();
free(pxm->index_data);
free(pxm->alpha_map);
diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h
index 3e192a1deb..4d3c047bf7 100644
--- a/engines/sci/gfx/gfx_tools.h
+++ b/engines/sci/gfx/gfx_tools.h
@@ -118,10 +118,9 @@ gfx_pixmap_t *gfx_pixmap_free_data(gfx_pixmap_t *pixmap);
** Returns : (gfx_pixmap_t *) pixmap
*/
-void gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm);
+void gfx_free_pixmap(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
+** Parameters: (gfx_pixmap_t *) pxm: The pixmap to free
** Returns : (void)
*/
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index 585e380e0d..4faee292e7 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -433,8 +433,17 @@ static int _gfxop_init_common(gfx_state_t *state, gfx_options_t *options, Resour
return GFX_FATAL;
}
- int size;
- state->static_palette = gfxr_interpreter_get_static_palette(*(state->resstate->resManager), state->version, &size);
+ state->static_palette = NULL;
+
+ if (state->version < SCI_VERSION_01_VGA) {
+ state->static_palette = gfx_sci0_pic_colors->getref();
+ } else if (state->version == SCI_VERSION_1_1 || state->version == SCI_VERSION_32) {
+ GFXDEBUG("Palettes are not yet supported in this SCI version\n");
+ } else {
+ Resource *res = state->resstate->resManager->findResource(kResourceTypePalette, 999, 0);
+ if (res && res->data)
+ state->static_palette = gfxr_read_pal1(res->id, res->data, res->size);
+ }
state->visible_map = GFX_MASK_VISUAL;
state->fullscreen_override = NULL; // No magical override
@@ -495,20 +504,20 @@ int gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value) {
int gfxop_exit(gfx_state_t *state) {
BASIC_CHECKS(GFX_ERROR);
- gfxr_free_resource_manager(state->driver, state->resstate);
+ gfxr_free_resource_manager(state->resstate);
if (state->control_map) {
- gfx_free_pixmap(state->driver, state->control_map);
+ gfx_free_pixmap(state->control_map);
state->control_map = NULL;
}
if (state->priority_map) {
- gfx_free_pixmap(state->driver, state->priority_map);
+ gfx_free_pixmap(state->priority_map);
state->priority_map = NULL;
}
if (state->static_priority_map) {
- gfx_free_pixmap(state->driver, state->static_priority_map);
+ gfx_free_pixmap(state->static_priority_map);
state->static_priority_map = NULL;
}
@@ -1162,7 +1171,7 @@ int gfxop_update(gfx_state_t *state) {
if (state->tag_mode) {
// This usually happens after a pic and all resources have been drawn
- gfxr_free_tagged_resources(state->driver, state->resstate);
+ gfxr_free_tagged_resources(state->resstate);
state->tag_mode = 0;
}
@@ -1237,7 +1246,11 @@ int gfxop_set_pointer_cursor(gfx_state_t *state, int nr) {
if (nr == GFXOP_NO_POINTER)
new_pointer = NULL;
else {
- new_pointer = gfxr_get_cursor(state->resstate, nr);
+ // FIXME: the initialization of the GFX resource manager should
+ // be pushed up, and it shouldn't occur here
+ GfxResManager *_gfx = new GfxResManager(state->resstate);
+ new_pointer = _gfx->getCursor(nr);
+ delete _gfx;
if (!new_pointer) {
GFXWARN("Attempt to set invalid pointer #%d\n", nr);
@@ -1848,16 +1861,24 @@ int *gfxop_get_pic_metainfo(gfx_state_t *state) {
int gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) {
BASIC_CHECKS(GFX_FATAL);
- gfxr_tag_resources(state->resstate);
+ // FIXME: the initialization of the GFX resource manager should
+ // be pushed up, and it shouldn't occur here
+ GfxResManager *_gfx = new GfxResManager(state->resstate);
+ _gfx->tagResources();
state->tag_mode = 1;
state->palette_nr = default_palette;
+ state->pic = _gfx->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true);
+ delete _gfx;
- state->pic = gfxr_get_pic(state->resstate, nr, GFX_MASK_VISUAL, flags, default_palette, 1);
-
- if (state->driver->mode->xfact == 1 && state->driver->mode->yfact == 1)
+ if (state->driver->mode->xfact == 1 && state->driver->mode->yfact == 1) {
state->pic_unscaled = state->pic;
- else
- state->pic_unscaled = gfxr_get_pic(state->resstate, nr, GFX_MASK_VISUAL, flags, default_palette, 0);
+ } else {
+ // FIXME: the initialization of the GFX resource manager should
+ // be pushed up, and it shouldn't occur here
+ GfxResManager *_gfx = new GfxResManager(state->resstate);
+ state->pic = _gfx->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, false);
+ delete _gfx;
+ }
if (!state->pic || !state->pic_unscaled) {
GFXERROR("Could not retrieve background pic %d!\n", nr);
@@ -1904,7 +1925,12 @@ int gfxop_get_font_height(gfx_state_t *state, int font_nr) {
gfx_bitmap_font_t *font;
BASIC_CHECKS(GFX_FATAL);
- font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
+ // FIXME: the initialization of the GFX resource manager should
+ // be pushed up, and it shouldn't occur here
+ GfxResManager *_gfx = new GfxResManager(state->resstate);
+ font = _gfx->getFont(font_nr);
+ delete _gfx;
+
if (!font)
return GFX_ERROR;
@@ -1918,7 +1944,11 @@ int gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, int
BASIC_CHECKS(GFX_FATAL);
- font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
+ // FIXME: the initialization of the GFX resource manager should
+ // be pushed up, and it shouldn't occur here
+ GfxResManager *_gfx = new GfxResManager(state->resstate);
+ font = _gfx->getFont(font_nr);
+ delete _gfx;
if (!font) {
GFXERROR("Attempt to calculate text size with invalid font #%d\n", font_nr);
@@ -1956,7 +1986,11 @@ gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, i
return NULL;
}
- font = gfxr_get_font(*(state->resstate->resManager), state->resstate, font_nr, 0);
+ // FIXME: the initialization of the GFX resource manager should
+ // be pushed up, and it shouldn't occur here
+ GfxResManager *_gfx = new GfxResManager(state->resstate);
+ font = _gfx->getFont(font_nr);
+ delete _gfx;
if (!font) {
GFXERROR("Attempt to draw text with invalid font #%d\n", font_nr);
@@ -2001,7 +2035,7 @@ gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, i
int j;
for (j = 0; j < i; j++)
- gfx_free_pixmap(state->driver, handle->text_pixmaps[j]);
+ gfx_free_pixmap(handle->text_pixmaps[j]);
free(handle->text_pixmaps);
free(handle->text);
@@ -2027,7 +2061,7 @@ int gfxop_free_text(gfx_state_t *state, gfx_text_handle_t *handle) {
if (handle->text_pixmaps) {
for (j = 0; j < handle->lines_nr; j++)
- gfx_free_pixmap(state->driver, handle->text_pixmaps[j]);
+ gfx_free_pixmap(handle->text_pixmaps[j]);
free(handle->text_pixmaps);
}
@@ -2167,7 +2201,7 @@ int gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, Common
int gfxop_free_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm) {
BASIC_CHECKS(GFX_ERROR);
- gfx_free_pixmap(state->driver, pxm);
+ gfx_free_pixmap(pxm);
return GFX_OK;
}
diff --git a/engines/sci/gfx/resmgr.cpp b/engines/sci/gfx/resmgr.cpp
index 1c6e50da2a..925054d373 100644
--- a/engines/sci/gfx/resmgr.cpp
+++ b/engines/sci/gfx/resmgr.cpp
@@ -40,8 +40,6 @@
namespace Sci {
-#undef TIME_PICDRAWING
-
// Invalid hash mode: Used to invalidate modified pics
#define MODE_INVALID -1
@@ -66,21 +64,13 @@ gfx_resstate_t *gfxr_new_resource_manager(int version, gfx_options_t *options, g
#define FREEALL(freecmd, type) \
if (resource->scaled_data.type) \
- freecmd(driver, resource->scaled_data.type); \
- resource->scaled_data.type = NULL; \
- if (resource->unscaled_data.type) \
- freecmd(driver, resource->unscaled_data.type); \
- resource->unscaled_data.type = NULL;
-
-#define FREEALL_SIMPLE(freecmd, type) \
- if (resource->scaled_data.type) \
freecmd(resource->scaled_data.type); \
resource->scaled_data.type = NULL; \
if (resource->unscaled_data.type) \
freecmd(resource->unscaled_data.type); \
resource->unscaled_data.type = NULL;
-void gfxr_free_resource(gfx_driver_t *driver, gfx_resource_t *resource, int type) {
+void gfxr_free_resource(gfx_resource_t *resource, int type) {
if (!resource)
return;
@@ -95,7 +85,7 @@ void gfxr_free_resource(gfx_driver_t *driver, gfx_resource_t *resource, int type
break;
case GFX_RESOURCE_TYPE_FONT:
- FREEALL_SIMPLE(gfxr_free_font, font);
+ FREEALL(gfxr_free_font, font);
break;
case GFX_RESOURCE_TYPE_CURSOR:
@@ -109,25 +99,21 @@ void gfxr_free_resource(gfx_driver_t *driver, gfx_resource_t *resource, int type
free(resource);
}
-void gfxr_free_all_resources(gfx_driver_t *driver, gfx_resstate_t *state) {
+void gfxr_free_all_resources(gfx_resstate_t *state) {
for (int type = 0; type < GFX_RESOURCE_TYPES_NR; ++type) {
for (IntResMap::iterator iter = state->_resourceMaps[type].begin(); iter != state->_resourceMaps[type].end(); ++iter) {
- gfxr_free_resource(driver, iter->_value, type);
+ gfxr_free_resource(iter->_value, type);
iter->_value = 0;
}
}
}
-void gfxr_free_resource_manager(gfx_driver_t *driver, gfx_resstate_t *state) {
- gfxr_free_all_resources(driver, state);
+void gfxr_free_resource_manager(gfx_resstate_t *state) {
+ gfxr_free_all_resources(state);
delete state;
}
-void gfxr_tag_resources(gfx_resstate_t *state) {
- (state->tag_lock_counter)++;
-}
-
-void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state) {
+void gfxr_free_tagged_resources(gfx_resstate_t *state) {
// Current heuristics: free tagged views and old pics
IntResMap::iterator iter;
@@ -140,7 +126,7 @@ void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state) {
if (resource) {
if (resource->lock_sequence_nr < tmp) {
- gfxr_free_resource(driver, resource, type);
+ gfxr_free_resource(resource, type);
iter->_value = 0;
} else {
resource->lock_sequence_nr = 0;
@@ -154,7 +140,7 @@ void gfxr_free_tagged_resources(gfx_driver_t *driver, gfx_resstate_t *state) {
if (resource) {
if (resource->lock_sequence_nr < 0) {
- gfxr_free_resource(driver, resource, type);
+ gfxr_free_resource(resource, type);
iter->_value = 0;
} else {
resource->lock_sequence_nr--;
@@ -191,89 +177,76 @@ static gfxr_pic_t *gfxr_pic_xlate_common(gfx_resource_t *res, int maps, int scal
}
#undef XLATE_AS_APPROPRIATE
-gfxr_pic_t *gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_palette, int scaled) {
+gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_palette, bool scaled) {
gfxr_pic_t *npic = NULL;
gfx_resource_type_t restype = GFX_RESOURCE_TYPE_PIC;
- IntResMap &resMap = state->_resourceMaps[restype];
+ IntResMap &resMap = _state->_resourceMaps[restype];
gfx_resource_t *res = NULL;
- int hash = gfxr_interpreter_options_hash(restype, state->version, state->options, 0);
+ int hash = gfxr_interpreter_options_hash(restype, _state->version, _state->options, 0);
int must_post_process_pic = 0;
- int need_unscaled = (state->driver->mode->xfact != 1 || state->driver->mode->yfact != 1);
+ int need_unscaled = (_state->driver->mode->xfact != 1 || _state->driver->mode->yfact != 1);
hash |= (flags << 20) | ((default_palette & 0x7) << 28);
- res = resMap.contains(nr) ? resMap[nr] : NULL;
+ res = resMap.contains(num) ? resMap[num] : NULL;
if (!res || res->mode != hash) {
gfxr_pic_t *pic;
gfxr_pic_t *unscaled_pic = NULL;
- if (state->options->pic0_unscaled) {
+ if (_state->options->pic0_unscaled) {
need_unscaled = 0;
- pic = gfxr_interpreter_init_pic(state->version, &mode_1x1_color_index, GFXR_RES_ID(restype, nr));
+ pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(restype, num), _state->version >= SCI_VERSION_01_VGA);
} else
- pic = gfxr_interpreter_init_pic(state->version, state->driver->mode, GFXR_RES_ID(restype, nr));
-
+ pic = gfxr_init_pic(_state->driver->mode, GFXR_RES_ID(restype, num), _state->version >= SCI_VERSION_01_VGA);
if (!pic) {
GFXERROR("Failed to allocate scaled pic!\n");
return NULL;
}
- gfxr_interpreter_clear_pic(state->version, pic);
+ gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);
if (need_unscaled) {
- unscaled_pic = gfxr_interpreter_init_pic(state->version, &mode_1x1_color_index, GFXR_RES_ID(restype, nr));
+ unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(restype, num), _state->version >= SCI_VERSION_01_VGA);
if (!unscaled_pic) {
GFXERROR("Failed to allocate unscaled pic!\n");
return NULL;
}
- gfxr_interpreter_clear_pic(state->version, unscaled_pic);
+ gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);
}
-#ifdef TIME_PICDRAWING
- {
- uint32 start_msec, end_msec;
- start_msec = g_system->getMillis();
-#endif
- if (gfxr_interpreter_calculate_pic(state, pic, unscaled_pic, flags, default_palette, nr)) {
- gfxr_free_pic(state->driver, pic);
- if (unscaled_pic)
- gfxr_free_pic(state->driver, unscaled_pic);
-
- return NULL;
- }
-#ifdef TIME_PICDRAWING
- end_msec = g_system->getMillis();
- printf("\nTIME: %d ms for drawing pic.%03d\n", end_msec - start_msec, nr);
+ if (gfxr_interpreter_calculate_pic(_state, pic, unscaled_pic, flags, default_palette, num)) {
+ gfxr_free_pic(pic);
+ if (unscaled_pic)
+ gfxr_free_pic(unscaled_pic);
+ return NULL;
}
-#endif
-
if (!res) {
res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
- res->ID = GFXR_RES_ID(restype, nr);
- res->lock_sequence_nr = state->options->buffer_pics_nr;
- resMap[nr] = res;
+ res->ID = GFXR_RES_ID(restype, num);
+ res->lock_sequence_nr = _state->options->buffer_pics_nr;
+ resMap[num] = res;
} else {
- gfxr_free_pic(state->driver, res->scaled_data.pic);
+ gfxr_free_pic(res->scaled_data.pic);
if (res->unscaled_data.pic)
- gfxr_free_pic(state->driver, res->unscaled_data.pic);
+ gfxr_free_pic(res->unscaled_data.pic);
}
res->mode = hash;
res->scaled_data.pic = pic;
res->unscaled_data.pic = unscaled_pic;
} else {
- res->lock_sequence_nr = state->options->buffer_pics_nr; // Update lock counter
+ res->lock_sequence_nr = _state->options->buffer_pics_nr; // Update lock counter
}
must_post_process_pic = res->scaled_data.pic->visual_map->data == NULL;
// If the pic was only just drawn, we'll have to endianness-adjust it now
- npic = gfxr_pic_xlate_common(res, maps, scaled || state->options->pic0_unscaled, 0, state->driver->mode,
- state->options->pic_xlate_filter, 0, state->options);
+ npic = gfxr_pic_xlate_common(res, maps, scaled || _state->options->pic0_unscaled, 0, _state->driver->mode,
+ _state->options->pic_xlate_filter, 0, _state->options);
if (must_post_process_pic) {
- gfxr_endianness_adjust(npic->visual_map, state->driver->mode);
+ gfxr_endianness_adjust(npic->visual_map, _state->driver->mode);
}
return npic;
@@ -338,7 +311,11 @@ gfxr_pic_t *gfxr_add_to_pic(gfx_resstate_t *state, int old_nr, int new_nr, int m
res = resMap.contains(old_nr) ? resMap[old_nr] : NULL;
if (!res || (res->mode != MODE_INVALID && res->mode != hash)) {
- gfxr_get_pic(state, old_nr, 0, flags, old_default_palette, scaled);
+ // FIXME: the initialization of the GFX resource manager should
+ // be pushed up, and it shouldn't occur here
+ GfxResManager *_gfx = new GfxResManager(state);
+ _gfx->getPic(old_nr, 0, flags, old_default_palette, scaled);
+ delete _gfx;
res = resMap.contains(old_nr) ? resMap[old_nr] : NULL;
@@ -398,7 +375,7 @@ gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, i
res->mode = hash;
resMap[nr] = res;
} else {
- gfxr_free_view(state->driver, res->unscaled_data.view);
+ gfxr_free_view(res->unscaled_data.view);
}
res->mode = hash;
@@ -453,29 +430,30 @@ gfxr_view_t *gfxr_get_view(gfx_resstate_t *state, int nr, int *loop, int *cel, i
return view;
}
-gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_t *state, int nr, int scaled) {
+gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) {
gfx_resource_type_t restype = GFX_RESOURCE_TYPE_FONT;
- IntResMap &resMap = state->_resourceMaps[restype];
+ IntResMap &resMap = _state->_resourceMaps[restype];
gfx_resource_t *res = NULL;
int hash;
- hash = gfxr_interpreter_options_hash(restype, state->version, state->options, 0);
+ hash = gfxr_interpreter_options_hash(restype, _state->version, _state->options, 0);
- res = resMap.contains(nr) ? resMap[nr] : NULL;
+ res = resMap.contains(num) ? resMap[num] : NULL;
if (!res || res->mode != hash) {
- gfx_bitmap_font_t *font = gfxr_interpreter_get_font(resourceManager, nr);
-
- if (!font)
+ Resource *fontRes = _state->resManager->findResource(kResourceTypeFont, num, 0);
+ if (!fontRes || !fontRes->data)
return NULL;
+ gfx_bitmap_font_t *font = gfxr_read_font(fontRes->id, fontRes->data, fontRes->size);
+
if (!res) {
res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
res->scaled_data.font = NULL;
- res->ID = GFXR_RES_ID(restype, nr);
- res->lock_sequence_nr = state->tag_lock_counter;
+ res->ID = GFXR_RES_ID(restype, num);
+ res->lock_sequence_nr = _state->tag_lock_counter;
res->mode = hash;
- resMap[nr] = res;
+ resMap[num] = res;
} else {
gfxr_free_font(res->unscaled_data.font);
}
@@ -484,7 +462,7 @@ gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_
return font;
} else {
- res->lock_sequence_nr = state->tag_lock_counter; // Update lock counter
+ res->lock_sequence_nr = _state->tag_lock_counter; // Update lock counter
if (res->unscaled_data.pointer)
return res->unscaled_data.font;
else
@@ -492,16 +470,26 @@ gfx_bitmap_font_t *gfxr_get_font(ResourceManager& resourceManager, gfx_resstate_
}
}
-gfx_pixmap_t *gfxr_get_cursor(gfx_resstate_t *state, int nr) {
+gfx_pixmap_t *GfxResManager::getCursor(int num) {
gfx_resource_type_t restype = GFX_RESOURCE_TYPE_CURSOR;
- IntResMap &resMap = state->_resourceMaps[restype];
+ IntResMap &resMap = _state->_resourceMaps[restype];
gfx_resource_t *res = NULL;
- int hash = gfxr_interpreter_options_hash(restype, state->version, state->options, 0);
+ int hash = gfxr_interpreter_options_hash(restype, _state->version, _state->options, 0);
- res = resMap.contains(nr) ? resMap[nr] : NULL;
+ res = resMap.contains(num) ? resMap[num] : NULL;
if (!res || res->mode != hash) {
- gfx_pixmap_t *cursor = gfxr_interpreter_get_cursor(*(state->resManager), nr, state->version);
+ Resource *cursorRes = _state->resManager->findResource(kResourceTypeCursor, num, 0);
+ if (!cursorRes || !cursorRes->data)
+ return NULL;
+
+ if (_state->version >= SCI_VERSION_1_1) {
+ GFXWARN("Attempt to retrieve cursor in SCI1.1 or later\n");
+ return NULL;
+ }
+
+ gfx_pixmap_t *cursor = gfxr_draw_cursor(GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, num),
+ cursorRes->data, cursorRes->size, _state->version != SCI_VERSION_0);
if (!cursor)
return NULL;
@@ -509,22 +497,22 @@ gfx_pixmap_t *gfxr_get_cursor(gfx_resstate_t *state, int nr) {
if (!res) {
res = (gfx_resource_t *)sci_malloc(sizeof(gfx_resource_t));
res->scaled_data.pointer = NULL;
- res->ID = GFXR_RES_ID(restype, nr);
- res->lock_sequence_nr = state->tag_lock_counter;
+ res->ID = GFXR_RES_ID(restype, num);
+ res->lock_sequence_nr = _state->tag_lock_counter;
res->mode = hash;
- resMap[nr] = res;
+ resMap[num] = res;
} else {
- gfx_free_pixmap(state->driver, res->unscaled_data.pointer);
+ gfx_free_pixmap(res->unscaled_data.pointer);
}
- gfx_get_res_config(state->options, cursor);
- gfx_xlate_pixmap(cursor, state->driver->mode, state->options->cursor_xlate_filter);
- gfxr_endianness_adjust(cursor, state->driver->mode);
+ gfx_get_res_config(_state->options, cursor);
+ gfx_xlate_pixmap(cursor, _state->driver->mode, _state->options->cursor_xlate_filter);
+ gfxr_endianness_adjust(cursor, _state->driver->mode);
res->unscaled_data.pointer = cursor;
return cursor;
} else {
- res->lock_sequence_nr = state->tag_lock_counter; // Update lock counter
+ res->lock_sequence_nr = _state->tag_lock_counter; // Update lock counter
return res->unscaled_data.pointer;
}
}
diff --git a/engines/sci/gfx/resource/res_manager.cpp b/engines/sci/gfx/resource/res_manager.cpp
index e11fe188d0..55af83bee8 100644
--- a/engines/sci/gfx/resource/res_manager.cpp
+++ b/engines/sci/gfx/resource/res_manager.cpp
@@ -49,8 +49,6 @@ int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_opt
| (options->pic0_dither_pattern << 8) | (options->pic0_brush_mode << 4) | (options->pic0_line_mode);
case GFX_RESOURCE_TYPE_FONT:
- return 0;
-
case GFX_RESOURCE_TYPE_CURSOR:
return 0;
@@ -61,14 +59,6 @@ int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_opt
}
}
-gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID) {
- return gfxr_init_pic(mode, ID, version >= SCI_VERSION_01_VGA);
-}
-
-void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic) {
- gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);
-}
-
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) {
ResourceManager& resourceManager = *(state->resManager);
@@ -152,22 +142,12 @@ gfxr_view_t *gfxr_interpreter_get_view(ResourceManager& resourceManager, int nr,
if (version < SCI_VERSION_01) palette = -1;
- switch (version) {
- case SCI_VERSION_0:
- case SCI_VERSION_01:
+ if (version <= SCI_VERSION_01)
result = gfxr_draw_view0(resid, res->data, res->size, palette);
- break;
- case SCI_VERSION_01_VGA:
- case SCI_VERSION_01_VGA_ODD:
- case SCI_VERSION_1_EARLY:
- case SCI_VERSION_1_LATE:
+ else if (version >= SCI_VERSION_01_VGA && version <= SCI_VERSION_1_LATE)
result = gfxr_draw_view1(resid, res->data, res->size, staticPalette);
- break;
- case SCI_VERSION_1_1:
- case SCI_VERSION_32:
+ else if (version >= SCI_VERSION_1_1)
result = gfxr_draw_view11(resid, res->data, res->size);
- break;
- }
if (version >= SCI_VERSION_01_VGA) {
if (!result->palette) {
@@ -179,66 +159,4 @@ gfxr_view_t *gfxr_interpreter_get_view(ResourceManager& resourceManager, int nr,
return result;
}
-gfx_bitmap_font_t *gfxr_interpreter_get_font(ResourceManager& resourceManager, int nr) {
- Resource *res = resourceManager.findResource(kResourceTypeFont, nr, 0);
- if (!res || !res->data)
- return NULL;
-
- return gfxr_read_font(res->id, res->data, res->size);
-}
-
-gfx_pixmap_t *gfxr_interpreter_get_cursor(ResourceManager& resourceManager, int nr, int version) {
- Resource *res = resourceManager.findResource(kResourceTypeCursor, nr, 0);
- int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, nr);
-
- if (!res || !res->data)
- return NULL;
-
- if (version >= SCI_VERSION_1_1) {
- GFXWARN("Attempt to retrieve cursor in SCI1.1 or later\n");
- return NULL;
- }
-
- return gfxr_draw_cursor(resid, res->data, res->size, version != SCI_VERSION_0);
-}
-
-Palette *gfxr_interpreter_get_static_palette(ResourceManager& resourceManager, int version, int *colors_nr) {
- if (version >= SCI_VERSION_01_VGA)
- return gfxr_interpreter_get_palette(resourceManager, version, colors_nr, 999);
-
- *colors_nr = GFX_SCI0_PIC_COLORS_NR;
- return gfx_sci0_pic_colors->getref();
-}
-
-Palette *gfxr_interpreter_get_palette(ResourceManager& resourceManager, int version, int *colors_nr, int nr) {
- Resource *res;
-
- if (version < SCI_VERSION_01_VGA)
- return NULL;
-
- res = resourceManager.findResource(kResourceTypePalette, nr, 0);
- if (!res || !res->data)
- return NULL;
-
- switch (version) {
- case SCI_VERSION_01_VGA :
- case SCI_VERSION_01_VGA_ODD :
- case SCI_VERSION_1_EARLY :
- case SCI_VERSION_1_LATE :
- return gfxr_read_pal1(res->id, res->data, res->size);
- case SCI_VERSION_1_1 :
- case SCI_VERSION_32 :
- GFXDEBUG("Palettes are not yet supported in this SCI version\n");
- return NULL;
-
- default:
- BREAKPOINT();
- return NULL;
- }
-}
-
-int gfxr_interpreter_needs_multicolored_pointers(int version) {
- return (version > SCI_VERSION_1);
-}
-
} // End of namespace Sci
diff --git a/engines/sci/gfx/resource/res_pic.cpp b/engines/sci/gfx/resource/res_pic.cpp
index 622d65bb56..f9f56e4ce9 100644
--- a/engines/sci/gfx/resource/res_pic.cpp
+++ b/engines/sci/gfx/resource/res_pic.cpp
@@ -1699,6 +1699,9 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE);
gfx_free_mode(mode);
+ // When the mode is freed, the associated view
+ // palette is freed too, so set it to NULL
+ view->palette = NULL;
if (flags & DRAWPIC01_FLAG_OVERLAID_PIC)
view_transparentize(view, pic->visual_map, posx, sci_titlebar_size + posy,
@@ -1708,7 +1711,8 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
view->index_data, pic->visual_map->index_width, view->index_width,
view->index_width, view->index_height, 1);
- gfx_free_pixmap(NULL, view);
+ gfx_free_pixmap(view);
+ view = NULL;
}
goto end_op_loop;
diff --git a/engines/sci/gfx/resource/res_view0.cpp b/engines/sci/gfx/resource/res_view0.cpp
index 6a0ca140c4..dd01ae4ad0 100644
--- a/engines/sci/gfx/resource/res_view0.cpp
+++ b/engines/sci/gfx/resource/res_view0.cpp
@@ -57,7 +57,7 @@ gfx_pixmap_t *gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size
}
if (xl <= 0 || yl <= 0) {
- gfx_free_pixmap(NULL, retval);
+ gfx_free_pixmap(retval);
GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
return NULL;
}
@@ -218,7 +218,7 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) {
if (error_token || gfxr_draw_loop0(view->loops + i, id, i, resource, loop_offset, size, view, mirrored)) {
// An error occured
view->loops_nr = i;
- gfxr_free_view(NULL, view);
+ gfxr_free_view(view);
return NULL;
}
}
diff --git a/engines/sci/gfx/resource/res_view1.cpp b/engines/sci/gfx/resource/res_view1.cpp
index 937264d84c..d743804971 100644
--- a/engines/sci/gfx/resource/res_view1.cpp
+++ b/engines/sci/gfx/resource/res_view1.cpp
@@ -246,9 +246,11 @@ gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *reso
if (view)
retval->palette = view->palette->getref();
+ else
+ retval->palette = NULL;
if (xl <= 0 || yl <= 0) {
- gfx_free_pixmap(NULL, retval);
+ gfx_free_pixmap(retval);
GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
return NULL;
}
@@ -261,7 +263,7 @@ gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *reso
pos, xl, yl, retval->color_key);
if (decompress_failed) {
- gfx_free_pixmap(NULL, retval);
+ gfx_free_pixmap(retval);
return NULL;
}
@@ -381,7 +383,7 @@ gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_p
if (error_token || gfxr_draw_loop1(view->loops + i, id, i, mirror_mask & (1 << i), resource, loop_offset, size, view, amiga_game)) {
// An error occured
view->loops_nr = i;
- gfxr_free_view(NULL, view);
+ gfxr_free_view(view);
return NULL;
}
}
@@ -429,7 +431,7 @@ gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *res
retval->palette = view->palette->getref();
if (xl <= 0 || yl <= 0) {
- gfx_free_pixmap(NULL, retval);
+ gfx_free_pixmap(retval);
GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
return NULL;
}
@@ -438,7 +440,7 @@ gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *res
runlength_offset, literal_offset, xl, yl, retval->color_key);
if (decompress_failed) {
- gfx_free_pixmap(NULL, retval);
+ gfx_free_pixmap(retval);
return NULL;
}