diff options
Diffstat (limited to 'engines/parallaction/graphics.cpp')
-rw-r--r-- | engines/parallaction/graphics.cpp | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 1c2cb58b5b..2bd3935f01 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -34,8 +34,9 @@ namespace Parallaction { // this is the size of the receiving buffer for unpacked frames, -// since BRA uses some insanely big animations. -#define MAXIMUM_UNPACKED_BITMAP_SIZE 640*401 +// since BRA uses some insanely big animations (the largest is +// part0/ani/dino.ani). +#define MAXIMUM_UNPACKED_BITMAP_SIZE 641*401 void Gfx::registerVar(const Common::String &name, int32 initialValue) { @@ -251,7 +252,7 @@ void Gfx::setPalette(Palette pal) { byte sysPal[256*4]; uint n = pal.fillRGBA(sysPal); - g_system->setPalette(sysPal, 0, n); + _vm->_system->setPalette(sysPal, 0, n); } void Gfx::setBlackPalette() { @@ -327,7 +328,7 @@ void Gfx::drawInventory() { _vm->_inventoryRenderer->getRect(r); byte *data = _vm->_inventoryRenderer->getData(); - g_system->copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height()); + _vm->_system->copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height()); } void Gfx::drawItems() { @@ -335,11 +336,11 @@ void Gfx::drawItems() { return; } - Graphics::Surface *surf = g_system->lockScreen(); + Graphics::Surface *surf = _vm->_system->lockScreen(); for (uint i = 0; i < _numItems; i++) { drawGfxObject(_items[i].data, *surf, false); } - g_system->unlockScreen(); + _vm->_system->unlockScreen(); } void Gfx::drawBalloons() { @@ -347,15 +348,15 @@ void Gfx::drawBalloons() { return; } - Graphics::Surface *surf = g_system->lockScreen(); + Graphics::Surface *surf = _vm->_system->lockScreen(); for (uint i = 0; i < _balloons.size(); i++) { drawGfxObject(_balloons[i], *surf, false); } - g_system->unlockScreen(); + _vm->_system->unlockScreen(); } void Gfx::clearScreen() { - g_system->clearScreen(); + _vm->_system->clearScreen(); } void Gfx::beginFrame() { @@ -377,7 +378,7 @@ void Gfx::beginFrame() { *data++ = _backgroundInfo->mask.getValue(x, y); } } -#if 1 +#if 0 Common::DumpFile dump; dump.open("maskdump.bin"); dump.write(_bitmapMask.pixels, _bitmapMask.w * _bitmapMask.h); @@ -437,11 +438,11 @@ void Gfx::updateScreen() { backgroundPitch = _bitmapMask.pitch; break; } - g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo->x, _backgroundInfo->y, w, h); + _vm->_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo->x, _backgroundInfo->y, w, h); } if (_varDrawPathZones == 1) { - Graphics::Surface *surf = g_system->lockScreen(); + Graphics::Surface *surf = _vm->_system->lockScreen(); ZoneList::iterator b = _vm->_location._zones.begin(); ZoneList::iterator e = _vm->_location._zones.end(); for (; b != e; b++) { @@ -450,13 +451,13 @@ void Gfx::updateScreen() { surf->frameRect(Common::Rect(z->getX(), z->getY(), z->getX() + z->width(), z->getY() + z->height()), 2); } } - g_system->unlockScreen(); + _vm->_system->unlockScreen(); } _varRenderMode = _varAnimRenderMode; // TODO: transform objects coordinates to be drawn with scrolling - Graphics::Surface *surf = g_system->lockScreen(); + Graphics::Surface *surf = _vm->_system->lockScreen(); drawGfxObjects(*surf); if (_halfbrite) { @@ -480,7 +481,7 @@ void Gfx::updateScreen() { } } - g_system->unlockScreen(); + _vm->_system->unlockScreen(); _varRenderMode = _varMiscRenderMode; @@ -489,7 +490,7 @@ void Gfx::updateScreen() { drawBalloons(); drawLabels(); - g_system->updateScreen(); + _vm->_system->updateScreen(); return; } @@ -506,7 +507,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) { @@ -600,30 +601,41 @@ void Gfx::updateFloatingLabel() { return; } - int16 _si, _di; - - Common::Point cursor; - _vm->_input->getCursorPos(cursor); + struct FloatingLabelTraits { + Common::Point _offsetWithItem; + Common::Point _offsetWithoutItem; + int _minX; + int _minY; + int _maxX; + int _maxY; + } *traits; Common::Rect r; _labels[_floatingLabel]->getRect(0, r); - if (_vm->_input->_activeItem._id != 0) { - _si = cursor.x + 16 - r.width()/2; - _di = cursor.y + 34; + if (_vm->getGameType() == GType_Nippon) { + FloatingLabelTraits traits_NS = { + Common::Point(16 - r.width()/2, 34), + Common::Point(8 - r.width()/2, 21), + 0, 0, _vm->_screenWidth - r.width(), 190 + }; + traits = &traits_NS; } else { - _si = cursor.x + 8 - r.width()/2; - _di = cursor.y + 21; + // FIXME: _maxY for BRA is not constant (390), but depends on _vm->_subtitleY + FloatingLabelTraits traits_BR = { + Common::Point(34 - r.width()/2, 70), + Common::Point(16 - r.width()/2, 37), + 0, 0, _vm->_screenWidth - r.width(), 390 + }; + traits = &traits_BR; } - if (_si < 0) _si = 0; - if (_di > 190) _di = 190; - - if (r.width() + _si > _vm->_screenWidth) - _si = _vm->_screenWidth - r.width(); + Common::Point cursor; + _vm->_input->getCursorPos(cursor); + Common::Point offset = (_vm->_input->_activeItem._id) ? traits->_offsetWithItem : traits->_offsetWithoutItem; - _labels[_floatingLabel]->x = _si; - _labels[_floatingLabel]->y = _di; + _labels[_floatingLabel]->x = CLIP(cursor.x + offset.x, traits->_minX, traits->_maxX); + _labels[_floatingLabel]->y = CLIP(cursor.y + offset.y, traits->_minY, traits->_maxY); } @@ -703,13 +715,13 @@ void Gfx::drawLabels() { updateFloatingLabel(); - Graphics::Surface* surf = g_system->lockScreen(); + Graphics::Surface* surf = _vm->_system->lockScreen(); for (uint i = 0; i < _labels.size(); i++) { drawGfxObject(_labels[i], *surf, false); } - g_system->unlockScreen(); + _vm->_system->unlockScreen(); } @@ -737,10 +749,10 @@ void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) { Gfx::Gfx(Parallaction* vm) : _vm(vm), _disk(vm->_disk) { - g_system->beginGFXTransaction(); - g_system->initSize(_vm->_screenWidth, _vm->_screenHeight); + _vm->_system->beginGFXTransaction(); + _vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight); _vm->initCommonGFX(_vm->getGameType() == GType_BRA); - g_system->endGFXTransaction(); + _vm->_system->endGFXTransaction(); setPalette(_palette); |