diff options
| author | Filippos Karapetis | 2009-03-23 08:43:53 +0000 |
|---|---|---|
| committer | Filippos Karapetis | 2009-03-23 08:43:53 +0000 |
| commit | a6f49a636bf0e8cef76bc416d80ed10020a1924a (patch) | |
| tree | ccdc650a66009b93eb5f51b84ba531fbfc44313e /engines/sci/gfx | |
| parent | 93ff05cb6de0ed8b199eab31812421e03a94809c (diff) | |
| download | scummvm-rg350-a6f49a636bf0e8cef76bc416d80ed10020a1924a.tar.gz scummvm-rg350-a6f49a636bf0e8cef76bc416d80ed10020a1924a.tar.bz2 scummvm-rg350-a6f49a636bf0e8cef76bc416d80ed10020a1924a.zip | |
- Moved palette initialization inside the graphics resource manager
- The static palette is no longer needlessly referenced directly outside the graphics resource manager
- Moved the SCI interpreter version inside the graphics resource manager, instead of gfx_state_t
svn-id: r39626
Diffstat (limited to 'engines/sci/gfx')
| -rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 21 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_resmgr.h | 19 | ||||
| -rw-r--r-- | engines/sci/gfx/operations.cpp | 17 | ||||
| -rw-r--r-- | engines/sci/gfx/operations.h | 8 |
4 files changed, 33 insertions, 32 deletions
diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 6ab69e6ecf..b474a1e36c 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -48,6 +48,27 @@ struct param_struct { gfx_driver_t *driver; }; +GfxResManager::GfxResManager(int version, gfx_options_t *options, gfx_driver_t *driver, ResourceManager *resManager) : + _version(version), _options(options), _driver(driver), _resManager(resManager), + _lockCounter(0), _tagLockCounter(0) { + gfxr_init_static_palette(); + + if (_version < SCI_VERSION_01_VGA) { + _staticPalette = gfx_sci0_pic_colors->getref(); + } else if (_version == SCI_VERSION_1_1 || _version == SCI_VERSION_32) { + GFXDEBUG("Palettes are not yet supported in this SCI version\n"); + } else { + Resource *res = resManager->findResource(kResourceTypePalette, 999, 0); + if (res && res->data) + _staticPalette = gfxr_read_pal1(res->id, res->data, res->size); + } +} + +GfxResManager::~GfxResManager() { + _staticPalette->free(); + delete _staticPalette; +} + #define DRAW_PIC01(pic, picStyle, isSci1) \ gfxr_draw_pic01((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, (isSci1), _staticPalette); diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index 6d303dfaf4..cb18ca5ae7 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -102,11 +102,9 @@ struct gfx_resstate_t { class GfxResManager { public: - GfxResManager(int version, gfx_options_t *options, gfx_driver_t *driver, Palette *staticPalette, ResourceManager *resManager) : - _version(version), _options(options), _driver(driver), _resManager(resManager), - _staticPalette(staticPalette), _lockCounter(0), _tagLockCounter(0) {} - ~GfxResManager() {} + GfxResManager(int version, gfx_options_t *options, gfx_driver_t *driver, ResourceManager *resManager); + ~GfxResManager(); /* 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 @@ -240,20 +238,17 @@ public: */ void freeResManager(); - Palette *getStaticPalette() { return _staticPalette; } + const PaletteEntry &getColor(int color) { return _staticPalette->getColor(color); } void setStaticPalette(Palette *newPalette) { - freeStaticPalette(); - _staticPalette = newPalette; - _staticPalette->name = "static palette"; - } - - void freeStaticPalette() { if (_staticPalette) _staticPalette->free(); + + _staticPalette = newPalette; + _staticPalette->name = "static palette"; } - int getNumberOfColors() { return _staticPalette ? _staticPalette->size() : 0; } + int getColorCount() { return _staticPalette ? _staticPalette->size() : 0; } private: int _version; diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 75b57dc4df..8932365dc5 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -414,11 +414,10 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) { (*pixmap)->palette = new Palette(default_colors, DEFAULT_COLORS_NR); } -int gfxop_init(gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager, +int gfxop_init(int version, gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager, int xfact, int yfact, gfx_color_mode_t bpp) { int color_depth = bpp ? bpp : 1; int initialized = 0; - Palette *staticPalette = NULL; /* Null for dynamic palettes */ BASIC_CHECKS(GFX_FATAL); @@ -443,19 +442,7 @@ int gfxop_init(gfx_state_t *state, gfx_options_t *options, ResourceManager *resM if (!initialized) return GFX_FATAL; - gfxr_init_static_palette(); - - if (state->version < SCI_VERSION_01_VGA) { - staticPalette = 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 = resManager->findResource(kResourceTypePalette, 999, 0); - if (res && res->data) - staticPalette = gfxr_read_pal1(res->id, res->data, res->size); - } - - state->gfxResMan = new GfxResManager(state->version, state->options, state->driver, staticPalette, resManager); + state->gfxResMan = new GfxResManager(version, state->options, state->driver, resManager); gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200)); diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index 30dce1afa0..d88f70724d 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -92,8 +92,6 @@ struct gfx_dirty_rect_t { struct gfx_state_t { - int version; /* Interpreter version */ - gfx_options_t *options; Common::Point pointer_pos; /* Mouse pointer coordinates */ @@ -105,7 +103,6 @@ struct gfx_state_t { int visible_map; - //gfx_resstate_t *resstate; /* Resource state */ GfxResManager *gfxResMan; gfx_pixmap_t *priority_map; /* back buffer priority map (unscaled) */ @@ -139,10 +136,11 @@ struct gfx_state_t { /* Fundamental operations */ /**************************/ -int gfxop_init(gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager, +int gfxop_init(int version, gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager, int xfact = 1, int yfact = 1, gfx_color_mode_t bpp = GFX_COLOR_MODE_INDEX); /* Initializes a graphics mode -** Parameters: (gfx_state_t *) state: The state to initialize +** Parameters: (int) version: The interpreter version +** (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 |
