diff options
-rw-r--r-- | engines/parallaction/balloons.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/exec_ns.cpp | 15 | ||||
-rw-r--r-- | engines/parallaction/gfxbase.cpp | 190 | ||||
-rw-r--r-- | engines/parallaction/graphics.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 9 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 2 |
6 files changed, 175 insertions, 47 deletions
diff --git a/engines/parallaction/balloons.cpp b/engines/parallaction/balloons.cpp index 550b8316a4..3dff563c7d 100644 --- a/engines/parallaction/balloons.cpp +++ b/engines/parallaction/balloons.cpp @@ -318,7 +318,7 @@ int BalloonManager_ns::createBalloon(int16 w, int16 h, int16 winding, uint16 bor winding = (winding == 0 ? 1 : 0); Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT); s.moveTo(r.width()/2 - 5, r.bottom - 1); - _gfx->blt(s, _resBalloonTail[winding], balloon->surface, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR_NS); + _gfx->blt(s, _resBalloonTail[winding], balloon->surface, LAYER_FOREGROUND, 100, BALLOON_TRANSPARENT_COLOR_NS); } _numBalloons++; @@ -591,7 +591,7 @@ Graphics::Surface *BalloonManager_br::expandBalloon(Frames *data, int frameNum) Graphics::Surface *surf = new Graphics::Surface; surf->create(rect.width(), rect.height(), 1); - _gfx->unpackBlt(rect, data->getData(frameNum), data->getRawSize(frameNum), surf, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR_BR); + _gfx->unpackBlt(rect, data->getData(frameNum), data->getRawSize(frameNum), surf, LAYER_FOREGROUND, 100, BALLOON_TRANSPARENT_COLOR_BR); return surf; } diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index 0ee362e50b..e63efbbeec 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -321,7 +321,7 @@ DECLARE_COMMAND_OPCODE(stop) { void Parallaction_ns::drawAnimations() { debugC(9, kDebugExec, "Parallaction_ns::drawAnimations()\n"); - uint16 layer = 0; + uint16 layer = 0, scale = 100; for (AnimationList::iterator it = _location._animations.begin(); it != _location._animations.end(); it++) { @@ -350,6 +350,18 @@ void Parallaction_ns::drawAnimations() { } } + if (getGameType() == GType_BRA) { + if (anim->_flags & (kFlagsScaled | kFlagsCharacter)) { + if (anim->getZ() <= _location._zeta0) { + if (anim->getZ() >= _location._zeta1) { + scale = ((anim->getZ() - _location._zeta1) * (100 - _location._zeta2)) / (_location._zeta0 - _location._zeta1) + _location._zeta2; + } else { + scale = _location._zeta2; + } + } + } + } + if (obj) { _gfx->showGfxObj(obj, true); obj->frame = anim->getF(); @@ -357,6 +369,7 @@ void Parallaction_ns::drawAnimations() { obj->y = anim->getY(); obj->z = anim->getZ(); obj->layer = layer; + obj->scale = scale; } } diff --git a/engines/parallaction/gfxbase.cpp b/engines/parallaction/gfxbase.cpp index 1c373dda44..8eb9753edd 100644 --- a/engines/parallaction/gfxbase.cpp +++ b/engines/parallaction/gfxbase.cpp @@ -32,7 +32,7 @@ namespace Parallaction { -GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : _frames(frames), _keep(true), x(0), y(0), z(0), _flags(kGfxObjNormal), type(objType), frame(0), layer(3) { +GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : _frames(frames), _keep(true), x(0), y(0), z(0), _flags(kGfxObjNormal), type(objType), frame(0), layer(3), scale(100) { if (name) { _name = strdup(name); } else { @@ -180,9 +180,9 @@ void Gfx::drawGfxObject(GfxObj *obj, Graphics::Surface &surf, bool scene) { data = obj->getData(obj->frame); if (obj->getSize(obj->frame) == obj->getRawSize(obj->frame)) { - blt(rect, data, &surf, obj->layer, obj->transparentKey); + blt(rect, data, &surf, obj->layer, obj->scale, obj->transparentKey); } else { - unpackBlt(rect, data, obj->getRawSize(obj->frame), &surf, obj->layer, obj->transparentKey); + unpackBlt(rect, data, obj->getRawSize(obj->frame), &surf, obj->layer, obj->scale, obj->transparentKey); } } @@ -233,7 +233,7 @@ void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surf blt(r, _unpackedBitmap, surf, z, transparentColor); } #endif -void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor) { +void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) { byte *d = _unpackedBitmap; uint pixelsLeftInLine = r.width(); @@ -259,11 +259,154 @@ void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surf d += repeat; } - blt(r, _unpackedBitmap, surf, z, transparentColor); + blt(r, _unpackedBitmap, surf, z, scale, transparentColor); } -void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor) { +void Gfx::bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) { + if (scale == 100) { + // use optimized path + bltMaskNoScale(r, data, surf, z, transparentColor); + return; + } + + Common::Rect q(r); + Common::Rect clipper(surf->w, surf->h); + q.clip(clipper); + if (!q.isValidRect()) return; + + uint inc = r.width() * (100 - scale); + uint thr = r.width() * 100; + uint xAccum = 0, yAccum = 0; + + Common::Point dp; + dp.x = q.left + (r.width() * (100 - scale)) / 200; + dp.y = q.top + (r.height() * (100 - scale)) / 100; + q.translate(-r.left, -r.top); + byte *s = data + q.left + q.top * r.width(); + byte *d = (byte*)surf->getBasePtr(dp.x, dp.y); + + uint line = 0, col = 0; + + for (uint16 i = 0; i < q.height(); i++) { + yAccum += inc; + + if (yAccum >= thr) { + yAccum -= thr; + s += r.width(); + continue; + } + + xAccum = 0; + byte *d2 = d; + col = 0; + + for (uint16 j = 0; j < q.width(); j++) { + xAccum += inc; + + if (xAccum >= thr) { + xAccum -= thr; + s++; + continue; + } + + if (*s != transparentColor) { + byte v = _backgroundInfo->mask.getValue(dp.x + col, dp.y + line); + if (z >= v) *d2 = *s; + } + + s++; + d2++; + col++; + } + + s += r.width() - q.width(); + d += surf->w; + line++; + } + +} + +void Gfx::bltMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor) { + if (!_backgroundInfo->mask.data || (z == LAYER_FOREGROUND)) { + // use optimized path + bltNoMaskNoScale(r, data, surf, transparentColor); + return; + } + + Common::Point dp; + Common::Rect q(r); + + Common::Rect clipper(surf->w, surf->h); + + q.clip(clipper); + if (!q.isValidRect()) return; + + dp.x = q.left; + dp.y = q.top; + + q.translate(-r.left, -r.top); + + byte *s = data + q.left + q.top * r.width(); + byte *d = (byte*)surf->getBasePtr(dp.x, dp.y); + + uint sPitch = r.width() - q.width(); + uint dPitch = surf->w - q.width(); + + 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; + } + +} + +void Gfx::bltNoMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor) { + Common::Point dp; + Common::Rect q(r); + + Common::Rect clipper(surf->w, surf->h); + + q.clip(clipper); + if (!q.isValidRect()) return; + + dp.x = q.left; + dp.y = q.top; + + q.translate(-r.left, -r.top); + + byte *s = data + q.left + q.top * r.width(); + byte *d = (byte*)surf->getBasePtr(dp.x, dp.y); + + uint sPitch = r.width() - q.width(); + uint dPitch = surf->w - q.width(); + + 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 += sPitch; + d += dPitch; + } +} + + +void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) { Common::Point dp; Common::Rect q(r); @@ -308,40 +451,7 @@ void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 } } 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; - } - - } 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 += sPitch; - d += dPitch; - } - - } + bltMaskScale(r, data, surf, z, scale, transparentColor); } } diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 78d3991318..83b0a00169 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -506,7 +506,7 @@ void Gfx::patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask) r.moveTo(x, y); uint16 z = (mask) ? _backgroundInfo->getLayer(y) : LAYER_FOREGROUND; - blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 0); + blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 100, 0); } void Gfx::fillBackground(const Common::Rect& r, byte color) { diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 0aaa12b0e5..497152c08c 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -410,6 +410,7 @@ public: uint frame; uint layer; uint transparentKey; + uint scale; GfxObj(uint type, Frames *frames, const char *name = NULL); virtual ~GfxObj(); @@ -646,8 +647,12 @@ public: void drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color); void drawGfxObject(GfxObj *obj, Graphics::Surface &surf, bool scene); - void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor); - void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor); + void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor); + void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor); + + void bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor); + void bltMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor); + void bltNoMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor); }; diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index c810d22b33..fd4d3bdf59 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -514,7 +514,7 @@ Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) { _ani->setY(100); _ani->setZ(10); _ani->setF(0); - _ani->_flags = kFlagsActive | kFlagsNoName; + _ani->_flags = kFlagsActive | kFlagsNoName | kFlagsCharacter; _ani->_type = kZoneYou; strncpy(_ani->_name, "yourself", ZONENAME_LENGTH); |