From 58d58d5100b5b2433192da03b2aa8a993cece605 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Thu, 7 Feb 2008 12:49:46 +0000 Subject: Implemented scroll command and added a couple more debug variables. svn-id: r30814 --- engines/parallaction/exec_br.cpp | 1 + engines/parallaction/gfxbase.cpp | 2 +- engines/parallaction/graphics.cpp | 111 ++++++++++++++++++++++++++++---------- engines/parallaction/graphics.h | 8 ++- 4 files changed, 91 insertions(+), 31 deletions(-) diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp index 8954b98a99..c969a7f028 100644 --- a/engines/parallaction/exec_br.cpp +++ b/engines/parallaction/exec_br.cpp @@ -267,6 +267,7 @@ DECLARE_COMMAND_OPCODE(zeta) { DECLARE_COMMAND_OPCODE(scroll) { warning("Parallaction_br::cmdOp_scroll not yet implemented"); + _gfx->setVar("scroll_x", _cmdRunCtxt.cmd->u._rvalue ); } diff --git a/engines/parallaction/gfxbase.cpp b/engines/parallaction/gfxbase.cpp index 6178c0e0df..6599a1f81c 100644 --- a/engines/parallaction/gfxbase.cpp +++ b/engines/parallaction/gfxbase.cpp @@ -163,7 +163,7 @@ void Gfx::drawGfxObjects(Graphics::Surface &surf) { GfxObj *obj = *b; if (obj->isVisible()) { obj->getRect(obj->frame, rect); - rect.translate(obj->x, obj->y); + rect.translate(obj->x - _varScrollX, obj->y); data = obj->getData(obj->frame); if (obj->getSize(obj->frame) == obj->getRawSize(obj->frame)) { blt(rect, data, &surf, obj->layer, 0); diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index ad01dcd894..314a97a8b4 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -405,8 +405,29 @@ void Gfx::beginFrame() { } + if (_vm->_screenWidth >= _backgroundInfo.width) { + _varScrollX = 0; + } else { + _varScrollX = getVar("scroll_x"); + } + + _varAnimRenderMode = getRenderMode("anim_render_mode"); + _varMiscRenderMode = getRenderMode("misc_render_mode"); +} + +int32 Gfx::getRenderMode(const char *type) { + + int32 mode = getVar(type); + if (mode < 0 || mode > 2) { + warning("new value for '%s' is wrong: resetting default", type); + setVar(type, 1); + mode = 1; + } + return mode; + } + void Gfx::updateScreen() { // background may not cover the whole screen, so adjust bulk update size @@ -417,17 +438,19 @@ void Gfx::updateScreen() { uint16 backgroundPitch = 0; switch (_varBackgroundMode) { case 1: - backgroundData = (byte*)_backgroundInfo.bg.pixels; + backgroundData = (byte*)_backgroundInfo.bg.getBasePtr(_varScrollX, 0); backgroundPitch = _backgroundInfo.bg.pitch; break; case 2: - backgroundData = (byte*)_bitmapMask.pixels; + backgroundData = (byte*)_bitmapMask.getBasePtr(_varScrollX, 0); backgroundPitch = _bitmapMask.pitch; break; } g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo.x, _backgroundInfo.y, w, h); + _varRenderMode = _varAnimRenderMode; + // TODO: transform objects coordinates to be drawn with scrolling Graphics::Surface *surf = g_system->lockScreen(); drawGfxObjects(*surf); @@ -455,11 +478,11 @@ void Gfx::updateScreen() { g_system->unlockScreen(); - drawInventory(); + _varRenderMode = _varMiscRenderMode; + drawInventory(); drawItems(); drawBalloons(); - drawLabels(); g_system->updateScreen(); @@ -526,6 +549,7 @@ void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surf blt(r, _unpackedBitmap, surf, z, transparentColor); } + void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor) { Common::Point dp; @@ -547,40 +571,65 @@ void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 uint sPitch = r.width() - q.width(); uint dPitch = surf->w - q.width(); - if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) { - for (uint16 i = 0; i < q.height(); i++) { + if (_varRenderMode == 2) { - for (uint16 j = 0; j < q.width(); j++) { - if (*s != transparentColor) { - byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i); - if (z >= v) *d = *s; - } + for (uint16 i = 0; i < q.height(); i++) { + + for (uint16 j = 0; j < q.width(); j++) { + if (*s != transparentColor) { + if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) { + byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i); + if (z >= v) *d = 5; + } else { + *d = 5; + } + } - s++; - d++; - } + s++; + d++; + } - s += sPitch; - d += dPitch; - } + s += sPitch; + d += dPitch; + } } else { + if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) { + + for (uint16 i = 0; i < q.height(); i++) { + + for (uint16 j = 0; j < q.width(); j++) { + if (*s != transparentColor) { + byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i); + if (z >= v) *d = *s; + } + + s++; + d++; + } + + s += sPitch; + d += dPitch; + } - for (uint16 i = q.top; i < q.bottom; i++) { - for (uint16 j = q.left; j < q.right; j++) { - if (*s != transparentColor) - *d = *s; + } else { + + for (uint16 i = q.top; i < q.bottom; i++) { + for (uint16 j = q.left; j < q.right; j++) { + if (*s != transparentColor) + *d = *s; - s++; - d++; - } + s++; + d++; + } - s += sPitch; - d += dPitch; - } + s += sPitch; + d += dPitch; + } - } + } + } } @@ -855,6 +904,12 @@ Gfx::Gfx(Parallaction* vm) : registerVar("background_mode", 1); _varBackgroundMode = 1; + registerVar("scroll_x", 0); + _varScrollX = 0; + + registerVar("anim_render_mode", 1); + registerVar("misc_render_mode", 1); + return; } diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 02be8a2c4b..13c756e0c1 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -538,9 +538,13 @@ protected: int _hbCircleRadius; // frame data stored in programmable variables - int32 _varBackgroundMode; + int32 _varBackgroundMode; // 1 = normal, 2 = only mask + int32 _varScrollX; + int32 _varAnimRenderMode; // 1 = normal, 2 = flat + int32 _varMiscRenderMode; // 1 = normal, 2 = flat + int32 _varRenderMode; Graphics::Surface _bitmapMask; - + int32 getRenderMode(const char *type); protected: static int16 _dialogueBalloonX[5]; -- cgit v1.2.3