aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2009-03-22 23:11:43 +0000
committerFilippos Karapetis2009-03-22 23:11:43 +0000
commite3f9acc3e6c66ab42e6e992536c933069771c99e (patch)
treebe078568570a92d40052a5149c382128684062ba /engines/sci/engine
parent052a6ea1f904079f85854cac9d255b7934130b84 (diff)
downloadscummvm-rg350-e3f9acc3e6c66ab42e6e992536c933069771c99e.tar.gz
scummvm-rg350-e3f9acc3e6c66ab42e6e992536c933069771c99e.tar.bz2
scummvm-rg350-e3f9acc3e6c66ab42e6e992536c933069771c99e.zip
Further objectification of the graphics resource manager
svn-id: r39621
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/game.cpp12
-rw-r--r--engines/sci/engine/kgraphics.cpp38
-rw-r--r--engines/sci/engine/scriptdebug.cpp13
3 files changed, 14 insertions, 49 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 6f2cf4b008..564bbf6598 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -125,22 +125,16 @@ int _reset_graphics_input(EngineState *s) {
// Check for Amiga palette file.
Common::File file;
if (file.open("spal")) {
- if (s->gfx_state->resstate->static_palette)
- s->gfx_state->resstate->static_palette->free();
- s->gfx_state->resstate->static_palette = gfxr_read_pal1_amiga(file);
- s->gfx_state->resstate->static_palette->name = "static palette";
+ s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal1_amiga(file));
file.close();
_sci1_alloc_system_colors(s);
} else {
resource = s->resmgr->findResource(kResourceTypePalette, 999, 1);
if (resource) {
- if (s->gfx_state->resstate->static_palette)
- s->gfx_state->resstate->static_palette->free();
if (s->version < SCI_VERSION(1, 001, 000))
- s->gfx_state->resstate->static_palette = gfxr_read_pal1(999, resource->data, resource->size);
+ s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal1(999, resource->data, resource->size));
else
- s->gfx_state->resstate->static_palette = gfxr_read_pal11(999, resource->data, resource->size);
- s->gfx_state->resstate->static_palette->name = "static palette";
+ s->gfx_state->gfxResMan->setStaticPalette(gfxr_read_pal11(999, resource->data, resource->size));
_sci1_alloc_system_colors(s);
s->resmgr->unlockResource(resource, 999, kResourceTypePalette);
} else {
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index dbda9bcd15..b4f00c77e6 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -260,28 +260,16 @@ void graph_restore_box(EngineState *s, reg_t handle) {
kfree(s, handle);
}
-#if 0
-#define KERNEL_COLOR_PALETTE s->gfx_state->pic->visual_map->colors
-#define KERNEL_COLORS_NR s->gfx_state->pic->visual_map->colors_nr
-#else
-#define KERNEL_COLOR_PALETTE (s->gfx_state->resstate->static_palette)
-#define KERNEL_COLORS_NR (s->gfx_state->resstate->static_palette ? s->gfx_state->resstate->static_palette->size() : 0)
-#endif
-
-//static gfx_pixmap_color_t white = {GFX_COLOR_INDEX_UNMAPPED, 255, 255, 255};
-
-//PaletteEntry white(255, 255, 255);
-
PaletteEntry get_pic_color(EngineState *s, int color) {
if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA)
return s->ega_colors[color].visual;
if (color == 255)
return PaletteEntry(255,255,255);
- else if (color < (int)KERNEL_COLORS_NR)
- return KERNEL_COLOR_PALETTE->getColor(color);
+ else if (color < s->gfx_state->gfxResMan->getNumberOfColors())
+ return s->gfx_state->gfxResMan->getStaticPalette()->getColor(color);
else {
- SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, KERNEL_COLORS_NR);
+ SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, s->gfx_state->gfxResMan->getNumberOfColors());
BREAKPOINT();
return PaletteEntry(0,0,0);
}
@@ -873,11 +861,7 @@ reg_t kIsItSkip(EngineState *s, int funct_nr, int argc, reg_t *argv) {
gfxr_view_t *res = NULL;
gfx_pixmap_t *pxm = NULL;
- // FIXME: the initialization of the GFX resource manager should
- // be pushed up, and it shouldn't occur here
- GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate);
- res = _gfx->getView(view, &loop, &cel, 0);
- delete _gfx;
+ res = s->gfx_state->gfxResMan->getView(view, &loop, &cel, 0);
if (!res) {
GFXWARN("Attempt to get cel parameters for invalid view %d\n", view);
@@ -1278,10 +1262,10 @@ reg_t kPalette(EngineState *s, int funct_nr, int argc, reg_t *argv) {
int i, delta, bestindex = -1, bestdelta = 200000;
- for (i = 0; i < (int)KERNEL_COLORS_NR; i++) {
- int dr = abs(KERNEL_COLOR_PALETTE->getColor(i).r - r);
- int dg = abs(KERNEL_COLOR_PALETTE->getColor(i).g - g);
- int db = abs(KERNEL_COLOR_PALETTE->getColor(i).b - b);
+ for (i = 0; i < s->gfx_state->gfxResMan->getNumberOfColors(); i++) {
+ int dr = abs(s->gfx_state->gfxResMan->getStaticPalette()->getColor(i).r - r);
+ int dg = abs(s->gfx_state->gfxResMan->getStaticPalette()->getColor(i).g - g);
+ int db = abs(s->gfx_state->gfxResMan->getStaticPalette()->getColor(i).b - b);
delta = dr * dr + dg * dg + db * db;
@@ -2356,11 +2340,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) {
// FIXME: Should really only invalidate all loaded pic resources here;
// this is overkill
- // FIXME: the initialization of the GFX resource manager should
- // be pushed up, and it shouldn't occur here
- GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate);
- _gfx->freeAllResources();
- delete _gfx;
+ s->gfx_state->gfxResMan->freeAllResources();
break;
}
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index c6b1078686..69d823a369 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -864,10 +864,6 @@ int c_viewinfo(EngineState *s) {
else {
sciprintf("has %d loops:\n", loops);
- // FIXME: the initialization of the GFX resource manager should
- // be pushed up, and it shouldn't occur here
- GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate);
-
for (i = 0; i < loops; i++) {
int j, cels;
@@ -878,11 +874,10 @@ int c_viewinfo(EngineState *s) {
Common::Point mod;
if (con_can_handle_pixmaps()) {
- view_pixmaps = _gfx->getView(view, &i, &j, palette);
+ view_pixmaps = s->gfx_state->gfxResMan->getView(view, &i, &j, palette);
con_insert_pixmap(gfx_clone_pixmap(view_pixmaps->loops[i].cels[j], s->gfx_state->driver->mode));
}
- delete _gfx;
gfxop_get_cel_parameters(s->gfx_state, view, i, j, &width, &height, &mod);
sciprintf(" cel %d: size %dx%d, adj+(%d,%d)\n", j, width, height, mod.x, mod.y);
@@ -2016,11 +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));
- // FIXME: the initialization of the GFX resource manager should
- // be pushed up, and it shouldn't occur here
- GfxResManager *_gfx = new GfxResManager(s->gfx_state->resstate);
- _gfx->freeAllResources();
- delete _gfx;
+ s->gfx_state->gfxResMan->freeAllResources();
s->visual = NULL;
return 0;