diff options
author | Filippos Karapetis | 2009-05-23 10:07:01 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-05-23 10:07:01 +0000 |
commit | 3811df7aca96071489381a004981b36d578cf427 (patch) | |
tree | 3cbbae10272a5e6b4b5b16abf4755ecb31fc2da7 /engines | |
parent | 248f415face22b2def45e84630dac66fb407aad9 (diff) | |
download | scummvm-rg350-3811df7aca96071489381a004981b36d578cf427.tar.gz scummvm-rg350-3811df7aca96071489381a004981b36d578cf427.tar.bz2 scummvm-rg350-3811df7aca96071489381a004981b36d578cf427.zip |
Fixed the incorrectly placed views in the KQ6 intro, by reintroducing port bounds in the graphics resource manager and removing two relevant hacks
svn-id: r40803
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 3 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 16 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.h | 9 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resource.h | 6 | ||||
-rw-r--r-- | engines/sci/gfx/res_pic.cpp | 30 |
5 files changed, 33 insertions, 31 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 14e82a9a62..e956051677 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -2377,6 +2377,9 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (s->_gameName != "LSL6") { s->gfx_state->pic_port_bounds = gfx_rect(UKPV(5), UKPV(4), UKPV(3), UKPV(2)); + // Notify the graphics resource manager that the pic port bounds changed + s->gfx_state->gfxResMan->changePortBounds(UKPV(5), UKPV(4), UKPV(3), UKPV(2)); + // FIXME: Should really only invalidate all loaded pic resources here; // this is overkill s->gfx_state->gfxResMan->freeAllResources(); diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 42a2427b9b..1a0920bcfb 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -54,6 +54,8 @@ GfxResManager::GfxResManager(int version, bool isVGA, gfx_options_t *options, gf _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) { _staticPalette = gfx_sci0_pic_colors->getref(); } else if (_version == SCI_VERSION_1_1) { @@ -74,12 +76,6 @@ GfxResManager::~GfxResManager() { _staticPalette = 0; } -#define DRAW_PIC01(pic, picStyle, isSci1) \ - gfxr_draw_pic01((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, (isSci1), _staticPalette); - -#define DRAW_PIC11(pic, picStyle) \ - gfxr_draw_pic11((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, _staticPalette); - int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr) { Resource *res = _resManager->findResource(kResourceTypePic, nr, 0); int need_unscaled = unscaled_pic != NULL; @@ -101,18 +97,18 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic if (need_unscaled) { if (_version == SCI_VERSION_1_1) - DRAW_PIC11(unscaled_pic, &basic_style) + gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, _staticPalette, _portBounds); else - DRAW_PIC01(unscaled_pic, &basic_style, _isVGA) + gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, _isVGA, _staticPalette, _portBounds); } if (scaled_pic && scaled_pic->undithered_buffer) memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size); if (_version == SCI_VERSION_1_1) - DRAW_PIC11(scaled_pic, &style) + gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, _staticPalette, _portBounds); else - DRAW_PIC01(scaled_pic, &style, _isVGA) + gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, _isVGA, _staticPalette, _portBounds); if (!_isVGA) { if (need_unscaled) diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index 68eccebc49..7e7d71f934 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -34,6 +34,7 @@ #include "sci/resource.h" #include "common/hashmap.h" +#include "common/rect.h" namespace Sci { @@ -227,6 +228,13 @@ public: // Set static palette and merge it into the global palette void setStaticPalette(Palette *newPalette); + /* + ** Sets the picture port bounds + */ + void changePortBounds(int x1, int y1, int x2, int y2) { + _portBounds = Common::Rect(x1, y1, x2, y2); + } + #if 0 void setPaletteIntensity(int16 from, int16 to, int16 intensity) { Palette *pal = _staticPalette->getref(); @@ -257,6 +265,7 @@ private: ** of the lock_counter, as will any resources referenced afterwards. */ int _tagLockCounter; /* lock counter value at tag time */ + Common::Rect _portBounds; IntResMap _resourceMaps[GFX_RESOURCE_TYPES_NR]; ResourceManager *_resManager; diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h index 96e72b1e2a..711681c14d 100644 --- a/engines/sci/gfx/gfx_resource.h +++ b/engines/sci/gfx/gfx_resource.h @@ -31,6 +31,8 @@ #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_driver.h" +#include "common/rect.h" + namespace Common { class File; } @@ -172,7 +174,7 @@ void gfxr_clear_pic0(gfxr_pic_t *pic, int titlebar_size); 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, - Palette *static_pal); + Palette *static_pal, Common::Rect portBounds); /* 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 @@ -193,7 +195,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int fill_normally, int default_palette, 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, - Palette *static_pal); + Palette *static_pal, Common::Rect portBounds); /* 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 diff --git a/engines/sci/gfx/res_pic.cpp b/engines/sci/gfx/res_pic.cpp index 7f5ecfbb51..d72afc9700 100644 --- a/engines/sci/gfx/res_pic.cpp +++ b/engines/sci/gfx/res_pic.cpp @@ -1129,7 +1129,7 @@ extern gfx_pixmap_t *gfxr_draw_cel0(int id, int loop, int cel, byte *resource, i extern void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp); void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource, - gfxr_pic0_params_t *style, int resid, int sci1, Palette *static_pal) { + gfxr_pic0_params_t *style, int resid, int sci1, Palette *static_pal, Common::Rect portBounds) { const int default_palette_table[GFXR_PIC0_PALETTE_SIZE] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x88, @@ -1160,10 +1160,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, int pal = 0, index = 0; int temp; int line_mode = style->line_mode; - // NOTE: here, it is assumed that the titlebar size is always 10. This may differ depending on - // the port bounds y starting point, but we haven't come across a case where this actually occurs. - // Also, there is a check further down which sets the titlebar size to 0 if the picture port goes off screen. - int titlebar_size = 10; + int titlebar_size = portBounds.top; byte op, opx; #ifdef FILL_RECURSIVE_DEBUG @@ -1540,10 +1537,9 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, } else view->palette = embedded_view_pal->getref(); - // Hack to prevent overflowing the visual map buffer. - // Yes, this does happen otherwise. - if (view->index_height + titlebar_size > 200) - titlebar_size = 0; + // Clip the view's height to fit within the screen buffer + // It can go off screen at some cases, e.g. in KQ6's intro + view->index_height = CLIP<int>(view->index_height, 0, portBounds.height()); // Set up mode structure for resizing the view Graphics::PixelFormat format = { 1, 0, 0, 0, 0, 0, 0, 0, 0 }; // 1byte/p, which handles masks and the rest for us @@ -1634,16 +1630,13 @@ end_op_loop: {} } void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource, - gfxr_pic0_params_t *style, int resid, Palette *static_pal) { + gfxr_pic0_params_t *style, int resid, Palette *static_pal, Common::Rect portBounds) { int has_bitmap = READ_LE_UINT16(resource + 4); int vector_data_ptr = READ_LE_UINT16(resource + 16); int palette_data_ptr = READ_LE_UINT16(resource + 28); int bitmap_data_ptr = READ_LE_UINT16(resource + 32); gfx_pixmap_t *view = NULL; - // NOTE: here, it is assumed that the titlebar size is always 10. This may differ depending on - // the port bounds y starting point, but we haven't come across a case where this actually occurs. - // Also, there is a check further down which sets the titlebar size to 0 if the picture port goes off screen. - int titlebar_size = 10; + int titlebar_size = portBounds.top; if (pic->visual_map->palette) pic->visual_map->palette->free(); pic->visual_map->palette = gfxr_read_pal11(-1, resource + palette_data_ptr, 1284); @@ -1664,10 +1657,9 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, if (flags & DRAWPIC01_FLAG_OVERLAID_PIC) view_transparentize(view, pic->visual_map, 0, 0, view->index_width, view->index_height); - // Hack to prevent overflowing the visual map buffer. - // Yes, this does happen otherwise. - if (view->index_height + titlebar_size > 200) - titlebar_size = 0; + // Clip the view's height to fit within the screen buffer + // It can go off screen at some cases, e.g. in KQ6's intro + view->index_height = CLIP<int>(view->index_height, 0, portBounds.height()); _gfx_crossblit_simple(pic->visual_map->index_data + titlebar_size*view->index_width, view->index_data, @@ -1679,7 +1671,7 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, GFXWARN("No view was contained in SCI1.1 pic resource"); } - gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, resource + vector_data_ptr, style, resid, 1, static_pal); + gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, resource + vector_data_ptr, style, resid, 1, static_pal, portBounds); } void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) { |