diff options
-rw-r--r-- | engines/parallaction/graphics.cpp | 24 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 21 | ||||
-rw-r--r-- | engines/parallaction/parallaction_br.cpp | 22 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 2 |
4 files changed, 40 insertions, 29 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 7b000c911f..8c00c165ef 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -344,10 +344,20 @@ void Gfx::drawBalloons() { g_system->unlockScreen(); } +void Gfx::clearScreen() { + g_system->clearScreen(); +} + void Gfx::updateScreen() { - g_system->copyRectToScreen((const byte*)_backgroundInfo.bg.pixels, _backgroundInfo.bg.pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight); + // background may not cover the whole screen, so adjust bulk update size + uint w = MIN(_vm->_screenWidth, _backgroundInfo.width); + uint h = MIN(_vm->_screenHeight, _backgroundInfo.height); + // TODO: add displacement to source to handle scrolling in BRA + g_system->copyRectToScreen((const byte*)_backgroundInfo.bg.pixels, _backgroundInfo.bg.pitch, _backgroundInfo.x, _backgroundInfo.y, w, h); + + // TODO: transform objects coordinates to be drawn with scrolling Graphics::Surface *surf = g_system->lockScreen(); drawGfxObjects(*surf); @@ -382,9 +392,6 @@ void Gfx::updateScreen() { // // graphic primitives // -void Gfx::clearBackground() { - memset(_backgroundInfo.bg.pixels, 0, _vm->_screenSize); -} void Gfx::patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask) { @@ -925,10 +932,9 @@ void Gfx::drawText(Graphics::Surface* surf, uint16 x, uint16 y, const char *text _font->drawString(dst, surf->w, text); } -bool Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth) { +void Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth) { uint16 lines = 0; - bool rv = false; uint16 linewidth = 0; uint16 rx = 10; @@ -954,8 +960,6 @@ bool Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 strcpy(token, "> ......."); strncpy(token+2, _password, strlen(_password)); tokenWidth = _font->getStringWidth(token); - - rv = true; } else { tokenWidth = _font->getStringWidth(token); @@ -983,8 +987,6 @@ bool Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 text = Common::ltrim(text); } - return rv; - } void Gfx::freeBackground() { @@ -993,6 +995,8 @@ void Gfx::freeBackground() { void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) { + freeBackground(); + if (type == kBackgroundLocation) { _disk->loadScenery(_backgroundInfo, name, mask, path); setPalette(_backgroundInfo.palette); diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 8aae823a1a..c2b46a1fba 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -328,9 +328,15 @@ typedef Common::List<GfxObj*> GfxObjList; #define LAYER_FOREGROUND 3 +/* + BackgroundInfo keeps information about the background bitmap that can be seen in the game. + These bitmaps can be of any size, smaller or larger than the visible screen, the latter + being the most common options. +*/ struct BackgroundInfo { - uint width; - uint height; + int x, y; // used to display bitmaps smaller than the screen + int width; + int height; Graphics::Surface bg; MaskBuffer mask; @@ -341,7 +347,7 @@ struct BackgroundInfo { int layers[4]; PaletteFxRange ranges[6]; - BackgroundInfo() : width(0), height(0) { + BackgroundInfo() : x(0), y(0), width(0), height(0) { layers[0] = layers[1] = layers[2] = layers[3] = 0; memset(ranges, 0, sizeof(ranges)); } @@ -362,6 +368,10 @@ struct BackgroundInfo { bg.free(); mask.free(); path.free(); + x = 0; + y = 0; + width = 0; + height = 0; } }; @@ -412,7 +422,6 @@ public: // background surface BackgroundInfo _backgroundInfo; void setBackground(uint type, const char* name, const char* mask, const char* path); - void clearBackground(); void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false); void grabBackground(const Common::Rect& r, Graphics::Surface &dst); void fillBackground(const Common::Rect& r, byte color); @@ -432,6 +441,8 @@ public: Gfx(Parallaction* vm); virtual ~Gfx(); + + void clearScreen(); void updateScreen(); public: @@ -493,7 +504,7 @@ protected: // low level text and patches void setFont(Font* font); void drawText(Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color); - bool drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth); + void drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth); void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor); }; diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 0b1d0006e8..d1afbc2740 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -144,27 +144,23 @@ int Parallaction_br::go() { } void Parallaction_br::splash(const char *name) { -#if 0 - BackgroundInfo info; - _gfx->clearScreen(Gfx::kBitFront); - - _disk->loadSlide(info, name); - _gfx->setPalette(info.palette); - _gfx->flatBlitCnv(&info.bg, (640 - info.width) >> 1, (400 - info.height) >> 1, Gfx::kBitFront); + _gfx->clearScreen(); + _gfx->setBackground(kBackgroundSlide, name, 0, 0); + _gfx->_backgroundInfo.x = (_screenWidth - _gfx->_backgroundInfo.width) >> 1; + _gfx->_backgroundInfo.y = (_screenHeight - _gfx->_backgroundInfo.height) >> 1; _gfx->updateScreen(); _system->delayMillis(600); - Palette pal; + Palette blackPal; + Palette pal(_gfx->_backgroundInfo.palette); for (uint i = 0; i < 64; i++) { - info.palette.fadeTo(pal, 1); - _gfx->setPalette(info.palette); + pal.fadeTo(blackPal, 1); + _gfx->setPalette(pal); _gfx->updateScreen(); _system->delayMillis(20); } - info.bg.free(); -#endif - return; + } #define MENUITEMS_X 250 diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 5c8e8e5113..fb240a6108 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -248,7 +248,7 @@ void Parallaction_ns::switchBackground(const char* background, const char* mask) uint16 v2 = 0; if (!scumm_stricmp(background, "final")) { - _gfx->clearBackground(); + _gfx->clearScreen(); for (uint16 _si = 0; _si < 32; _si++) { pal.setEntry(_si, v2, v2, v2); v2 += 4; |