diff options
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 49 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.h | 6 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resource.h | 11 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gfx/operations.h | 3 | ||||
-rw-r--r-- | engines/sci/gfx/res_view.cpp | 4 |
6 files changed, 39 insertions, 40 deletions
diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 4abcc1fb78..9343b66cb8 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -49,14 +49,14 @@ struct param_struct { GfxDriver *driver; }; -GfxResManager::GfxResManager(int version, bool isVGA, gfx_options_t *options, GfxDriver *driver, ResourceManager *resManager) : - _version(version), _isVGA(isVGA), _options(options), _driver(driver), _resManager(resManager), +GfxResManager::GfxResManager(int version, gfx_options_t *options, GfxDriver *driver, ResourceManager *resManager) : + _version(version), _options(options), _driver(driver), _resManager(resManager), _lockCounter(0), _tagLockCounter(0), _staticPalette(0) { gfxr_init_static_palette(); _portBounds = Common::Rect(0, 10, 320, 200); // default value, with a titlebar of 10px - if (_version < SCI_VERSION_01_VGA || !_isVGA) { + if (!_resManager->isVGA()) { _staticPalette = gfx_sci0_pic_colors->getref(); } else if (_version == SCI_VERSION_1_1) { debugC(2, kDebugLevelGraphics, "Palettes are not yet supported in this SCI version\n"); @@ -99,7 +99,7 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic if (_version == SCI_VERSION_1_1) gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _staticPalette, _portBounds); else - gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _isVGA, _staticPalette, _portBounds); + gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _resManager->isVGA(), _staticPalette, _portBounds); } if (scaled_pic && scaled_pic->undithered_buffer) @@ -108,9 +108,9 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic if (_version == SCI_VERSION_1_1) gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _staticPalette, _portBounds); else - gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _isVGA, _staticPalette, _portBounds); + gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _resManager->isVGA(), _staticPalette, _portBounds); - if (!_isVGA) { + if (!_resManager->isVGA()) { if (need_unscaled) gfxr_remove_artifacts_pic0(scaled_pic, unscaled_pic); @@ -144,7 +144,7 @@ int GfxResManager::getOptionsHash(gfx_resource_type_t type) { case GFX_RESOURCE_TYPE_PIC: #ifdef CUSTOM_GRAPHICS_OPTIONS - if (_version >= SCI_VERSION_01_VGA) + if (_resManager->isVGA()) // NOTE: here, it is assumed that the upper port bound is always 10, but this doesn't seem to matter for the // generated options hash anyway return 10; @@ -153,7 +153,7 @@ int GfxResManager::getOptionsHash(gfx_resource_type_t type) { | (_options->pic0_dither_pattern << 8) | (_options->pic0_brush_mode << 4) | (_options->pic0_line_mode); #else - if (_version >= SCI_VERSION_01_VGA) + if (_resManager->isVGA()) return 10; else return 0x10000 | (GFXR_DITHER_PATTERN_SCALED << 8) | (GFX_BRUSH_MODE_RANDOM_ELLIPSES << 4) | GFX_LINE_MODE_CORRECT; @@ -341,12 +341,12 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale #ifdef CUSTOM_GRAPHICS_OPTIONS if (_options->pic0_unscaled) { need_unscaled = 0; - pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); + pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA()); } else - pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); + pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA()); #else need_unscaled = 0; - pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); + pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA()); #endif if (!pic) { @@ -357,7 +357,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); if (need_unscaled) { - unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); + unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA()); if (!unscaled_pic) { error("Failed to allocate unscaled pic"); return NULL; @@ -530,17 +530,16 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { return NULL; int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); + + if (!_resManager->isVGA()) { + int pal = (_version == SCI_VERSION_0) ? -1 : palette; + view = getEGAView(resid, viewRes->data, viewRes->size, pal); + } else { + if (_version < SCI_VERSION_1_1) + view = getVGAView(resid, viewRes->data, viewRes->size, _staticPalette, false); + else + view = getVGAView(resid, viewRes->data, viewRes->size, 0, true); - if (_version < SCI_VERSION_01_EGA) - view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, -1); - else if (_version == SCI_VERSION_01_EGA || !_isVGA) - view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, palette); - else if (_version >= SCI_VERSION_01_VGA && _version <= SCI_VERSION_1) - view = gfxr_draw_view1(resid, viewRes->data, viewRes->size, _staticPalette, false); - else if (_version >= SCI_VERSION_1_1) - view = gfxr_draw_view1(resid, viewRes->data, viewRes->size, 0, true); - - if (_isVGA) { if (!view->palette) { view->palette = new Palette(_staticPalette->size()); view->palette->name = "interpreter_get_view"; @@ -554,7 +553,6 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { view->palette->setColor(i, sc.r, sc.g, sc.b); } } - } if (!res) { @@ -619,6 +617,11 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_FONT); + // Workaround: LSL1VGA mixes its own internal fonts with the global + // SCI ones, so we translate them here, by removing their extra bits + if (!resMap.contains(num) && !_resManager->testResource(ResourceId(kResourceTypeFont, num))) + num = num & 0x7ff; + res = resMap.contains(num) ? resMap[num] : NULL; if (!res || res->mode != hash) { diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index 1f0f58dce9..8230e84aa0 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -90,7 +90,7 @@ typedef Common::HashMap<int, gfx_resource_t *> IntResMap; /** Graphics resource manager */ class GfxResManager { public: - GfxResManager(int version, bool isVGA, gfx_options_t *options, + GfxResManager(int version, gfx_options_t *options, GfxDriver *driver, ResourceManager *resManager); ~GfxResManager(); @@ -311,14 +311,12 @@ public: * * @return Number of pallete entries */ - int getColorCount() - { + int getColorCount() { return _staticPalette ? _staticPalette->size() : 0; } private: int _version; - bool _isVGA; gfx_options_t *_options; GfxDriver *_driver; Palette *_staticPalette; diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h index 780060bc4f..9c83cf07cd 100644 --- a/engines/sci/gfx/gfx_resource.h +++ b/engines/sci/gfx/gfx_resource.h @@ -245,7 +245,7 @@ void gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src); void gfxr_dither_pic0(gfxr_pic_t *pic, int mode, int pattern); /** - * Calculates a SCI0 view. + * Calculates an EGA view. * * @param[in] id Resource ID of the view * @param[in] resource Pointer to the resource to read @@ -253,7 +253,7 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, int mode, int pattern); * @param[in] palette The palette to use * @return The resulting view */ -gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette); +gfxr_view_t *getEGAView(int id, byte *resource, int size, int palette); /** * Calculates a SCI cursor. @@ -265,8 +265,7 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette); * @return A newly allocated pixmap containing an index color * representation of the cursor */ -gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, - bool isSci01); +gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01); /** @} */ @@ -304,7 +303,7 @@ Palette *gfxr_read_pal1_amiga(Common::File &file); Palette *gfxr_read_pal11(int id, byte *resource, int size); /** - * Calculates an SCI1 view. + * Calculates a VGA view. * * @param[in] id Resource ID of the view * @param[in] resource Pointer to the resource to read @@ -313,7 +312,7 @@ Palette *gfxr_read_pal11(int id, byte *resource, int size); * @param[in] isSci11 true if SCI1.1, false otherwise * @return The resulting view */ -gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_pal, bool isSci11); +gfxr_view_t *getVGAView(int id, byte *resource, int size, Palette *static_pal, bool isSci11); gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, byte *cel_base, int size, gfxr_view_t *view, bool isAmiga, bool isSci11); /** @} */ diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 80adb9eddb..057f28b56f 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -404,7 +404,7 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) { (*pixmap)->palette = new Palette(default_colors, DEFAULT_COLORS_NR); } -int gfxop_init(int version, bool isVGA, GfxState *state, +int gfxop_init(int version, GfxState *state, gfx_options_t *options, ResourceManager *resManager, Graphics::PixelFormat mode, int xfact, int yfact) { //int color_depth = bpp ? bpp : 1; @@ -424,8 +424,8 @@ int gfxop_init(int version, bool isVGA, GfxState *state, state->driver = new GfxDriver(xfact, yfact, mode); - state->gfxResMan = new GfxResManager(version, isVGA, state->options, state->driver, resManager); - + state->gfxResMan = new GfxResManager(version, state->options, state->driver, resManager); + gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200)); init_aux_pixmap(&(state->control_map)); diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index d567934ceb..ec0a810224 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -135,7 +135,6 @@ struct GfxState { * Initializes a graphics mode. * * @param[in] version The interpreter version - * @param[in] isVGA true if using VGA resolution * @param[in] state The state to initialize * @param[in] xfact Horizontal scale factor * @param[in] yfact Vertical scale factors @@ -146,7 +145,7 @@ struct GfxState { * is unavailable, or GFX_FATAL if the graphics driver * is unable to provide any useful graphics support */ -int gfxop_init(int version, bool isVGA, GfxState *state, +int gfxop_init(int version, GfxState *state, gfx_options_t *options, ResourceManager *resManager, Graphics::PixelFormat mode, int xfact = 1, int yfact = 1); diff --git a/engines/sci/gfx/res_view.cpp b/engines/sci/gfx/res_view.cpp index 41cb55fa75..d484136f8e 100644 --- a/engines/sci/gfx/res_view.cpp +++ b/engines/sci/gfx/res_view.cpp @@ -135,7 +135,7 @@ gfx_pixmap_t *gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size return retval; } -gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) { +gfxr_view_t *getEGAView(int id, byte *resource, int size, int palette) { int i; gfxr_view_t *view; int mirror_bitpos = 1; @@ -365,7 +365,7 @@ gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *reso return retval; } -gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_pal, bool isSci11) { +gfxr_view_t *getVGAView(int id, byte *resource, int size, Palette *static_pal, bool isSci11) { uint16 palOffset = READ_LE_UINT16(resource + V1_PALETTE_OFFSET + (isSci11 ? 2 : 0)); uint16 headerSize = isSci11 ? READ_LE_UINT16(resource + V2_HEADER_SIZE) : 0; byte* seeker = resource + headerSize; |