diff options
-rw-r--r-- | engines/parallaction/callables_ns.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/exec_ns.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/gfxbase.cpp | 8 | ||||
-rw-r--r-- | engines/parallaction/graphics.cpp | 58 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 4 | ||||
-rw-r--r-- | engines/parallaction/gui_br.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/parser_br.cpp | 8 |
8 files changed, 51 insertions, 53 deletions
diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index 9cd6b610ff..761e11dc7d 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -291,8 +291,8 @@ void Parallaction_ns::_c_onMouse(void *parm) { void Parallaction_ns::_c_setMask(void *parm) { - memset(_gfx->_backgroundInfo.mask.data + 3600, 0, 3600); - _gfx->_backgroundInfo.layers[1] = 500; + memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600); + _gfx->_backgroundInfo->layers[1] = 500; return; } @@ -502,11 +502,11 @@ void Parallaction_ns::_c_shade(void *parm) { _rightHandAnim->_top ); - uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo.mask.internalWidth; + uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth; for (uint16 _si = r.top; _si < r.bottom; _si++) { - memset(_gfx->_backgroundInfo.mask.data + _di, 0, r.width()/4+1); - _di += _gfx->_backgroundInfo.mask.internalWidth; + memset(_gfx->_backgroundInfo->mask.data + _di, 0, r.width()/4+1); + _di += _gfx->_backgroundInfo->mask.internalWidth; } return; diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index 3e3ee19a03..99a492863b 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -347,7 +347,7 @@ void Parallaction_ns::drawAnimations() { if (anim->_flags & kFlagsNoMasked) layer = 3; else - layer = _gfx->_backgroundInfo.getLayer(anim->_top + anim->height()); + layer = _gfx->_backgroundInfo->getLayer(anim->_top + anim->height()); if (obj) { _gfx->showGfxObj(obj, true); diff --git a/engines/parallaction/gfxbase.cpp b/engines/parallaction/gfxbase.cpp index aa02253cb1..1c373dda44 100644 --- a/engines/parallaction/gfxbase.cpp +++ b/engines/parallaction/gfxbase.cpp @@ -291,8 +291,8 @@ void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 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 (_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; @@ -308,13 +308,13 @@ void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 } } else { - if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) { + 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); + byte v = _backgroundInfo->mask.getValue(dp.x + j, dp.y + i); if (z >= v) *d = *s; } diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index a31b7f4994..7aa284e82c 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -269,7 +269,7 @@ void Gfx::animatePalette() { PaletteFxRange *range; for (uint16 i = 0; i < 4; i++) { - range = &_backgroundInfo.ranges[i]; + range = &_backgroundInfo->ranges[i]; if ((range->_flags & 1) == 0) continue; // animated palette range->_timer += range->_step * 2; // update timer @@ -359,7 +359,7 @@ void Gfx::clearScreen() { } void Gfx::beginFrame() { - _skipBackground = (_backgroundInfo.bg.pixels == 0); // don't render frame if background is missing + _skipBackground = (_backgroundInfo->bg.pixels == 0); // don't render frame if background is missing if (!_skipBackground) { int32 oldBackgroundMode = _varBackgroundMode; @@ -370,11 +370,11 @@ void Gfx::beginFrame() { _bitmapMask.free(); break; case 2: - _bitmapMask.create(_backgroundInfo.width, _backgroundInfo.height, 1); + _bitmapMask.create(_backgroundInfo->width, _backgroundInfo->height, 1); byte *data = (byte*)_bitmapMask.pixels; for (uint y = 0; y < _bitmapMask.h; y++) { for (uint x = 0; x < _bitmapMask.w; x++) { - *data++ = _backgroundInfo.mask.getValue(x, y); + *data++ = _backgroundInfo->mask.getValue(x, y); } } break; @@ -389,7 +389,7 @@ void Gfx::beginFrame() { warning("Path zones are supported only in Big Red Adventure"); } - if (_skipBackground || (_vm->_screenWidth >= _backgroundInfo.width)) { + if (_skipBackground || (_vm->_screenWidth >= _backgroundInfo->width)) { _varScrollX = 0; } else { _varScrollX = getVar("scroll_x"); @@ -416,22 +416,22 @@ void Gfx::updateScreen() { if (!_skipBackground) { // background may not cover the whole screen, so adjust bulk update size - uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo.width); - uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo.height); + uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo->width); + uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo->height); byte *backgroundData = 0; uint16 backgroundPitch = 0; switch (_varBackgroundMode) { case 1: - backgroundData = (byte*)_backgroundInfo.bg.getBasePtr(_varScrollX, 0); - backgroundPitch = _backgroundInfo.bg.pitch; + backgroundData = (byte*)_backgroundInfo->bg.getBasePtr(_varScrollX, 0); + backgroundPitch = _backgroundInfo->bg.pitch; break; case 2: backgroundData = (byte*)_bitmapMask.getBasePtr(_varScrollX, 0); backgroundPitch = _bitmapMask.pitch; break; } - g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo.x, _backgroundInfo.y, w, h); + g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo->x, _backgroundInfo->y, w, h); } if (_varDrawPathZones == 1) { @@ -499,17 +499,17 @@ void Gfx::patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask) Common::Rect r(surf.w, surf.h); r.moveTo(x, y); - uint16 z = (mask) ? _backgroundInfo.getLayer(y) : LAYER_FOREGROUND; - blt(r, (byte*)surf.pixels, &_backgroundInfo.bg, z, 0); + uint16 z = (mask) ? _backgroundInfo->getLayer(y) : LAYER_FOREGROUND; + blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 0); } void Gfx::fillBackground(const Common::Rect& r, byte color) { - _backgroundInfo.bg.fillRect(r, color); + _backgroundInfo->bg.fillRect(r, color); } void Gfx::invertBackground(const Common::Rect& r) { - byte *d = (byte*)_backgroundInfo.bg.getBasePtr(r.left, r.top); + byte *d = (byte*)_backgroundInfo->bg.getBasePtr(r.left, r.top); for (int i = 0; i < r.height(); i++) { for (int j = 0; j < r.width(); j++) { @@ -517,7 +517,7 @@ void Gfx::invertBackground(const Common::Rect& r) { d++; } - d += (_backgroundInfo.bg.pitch - r.width()); + d += (_backgroundInfo->bg.pitch - r.width()); } } @@ -724,7 +724,7 @@ void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surf } void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) { - copyRect(r, _backgroundInfo.bg, dst); + copyRect(r, _backgroundInfo->bg, dst); } @@ -744,6 +744,8 @@ Gfx::Gfx(Parallaction* vm) : _screenX = 0; _screenY = 0; + _backgroundInfo = 0; + _halfbrite = false; _hbCircleRadius = 0; @@ -766,7 +768,6 @@ Gfx::Gfx(Parallaction* vm) : BackgroundInfo paletteInfo; _disk->loadSlide(paletteInfo, "pointer"); _backupPal.clone(paletteInfo.palette); - paletteInfo.free(); } return; @@ -774,7 +775,8 @@ Gfx::Gfx(Parallaction* vm) : Gfx::~Gfx() { - freeBackground(); + delete _backgroundInfo; + freeLabels(); delete []_unpackedBitmap; @@ -829,16 +831,14 @@ void Gfx::freeItems() { _numItems = 0; } -void Gfx::freeBackground() { - _backgroundInfo.free(); -} void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) { - freeBackground(); + delete _backgroundInfo; + _backgroundInfo = new BackgroundInfo; if (type == kBackgroundLocation) { - _disk->loadScenery(_backgroundInfo, name, mask, path); + _disk->loadScenery(*_backgroundInfo, name, mask, path); // The PC version of BRA needs the entries 20-31 of the palette to be constant, but // the background resource files are screwed up. The right colors come from an unused @@ -847,17 +847,17 @@ void Gfx::setBackground(uint type, const char* name, const char* mask, const cha int r, g, b; for (uint i = 16; i < 32; i++) { _backupPal.getEntry(i, r, g, b); - _backgroundInfo.palette.setEntry(i, r, g, b); + _backgroundInfo->palette.setEntry(i, r, g, b); } } - setPalette(_backgroundInfo.palette); - _palette.clone(_backgroundInfo.palette); + setPalette(_backgroundInfo->palette); + _palette.clone(_backgroundInfo->palette); } else { - _disk->loadSlide(_backgroundInfo, name); + _disk->loadSlide(*_backgroundInfo, name); for (uint i = 0; i < 6; i++) - _backgroundInfo.ranges[i]._flags = 0; // disable palette cycling for slides - setPalette(_backgroundInfo.palette); + _backgroundInfo->ranges[i]._flags = 0; // disable palette cycling for slides + setPalette(_backgroundInfo->palette); } } diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 52b7a4b870..71eaa3724f 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -436,7 +436,7 @@ struct BackgroundInfo { return LAYER_FOREGROUND; } - void free() { + ~BackgroundInfo() { bg.free(); mask.free(); path.free(); @@ -511,7 +511,7 @@ public: void freeItems(); // background surface - BackgroundInfo _backgroundInfo; + BackgroundInfo *_backgroundInfo; void setBackground(uint type, const char* name, const char* mask, const char* path); void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false); void grabBackground(const Common::Rect& r, Graphics::Surface &dst); diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp index b10237046e..89226bc9ac 100644 --- a/engines/parallaction/gui_br.cpp +++ b/engines/parallaction/gui_br.cpp @@ -65,7 +65,7 @@ public: uint32 curTime = _vm->_system->getMillis(); if (curTime - _startTime > _timeOut) { _fadeSteps = 64; - pal.clone(_vm->_gfx->_backgroundInfo.palette); + pal.clone(_vm->_gfx->_backgroundInfo->palette); } return this; } @@ -73,8 +73,8 @@ public: virtual void enter() { _vm->_gfx->clearScreen(); _vm->_gfx->setBackground(kBackgroundSlide, _slideName.c_str(), 0, 0); - _vm->_gfx->_backgroundInfo.x = (_vm->_screenWidth - _vm->_gfx->_backgroundInfo.width) >> 1; - _vm->_gfx->_backgroundInfo.y = (_vm->_screenHeight - _vm->_gfx->_backgroundInfo.height) >> 1; + _vm->_gfx->_backgroundInfo->x = (_vm->_screenWidth - _vm->_gfx->_backgroundInfo->width) >> 1; + _vm->_gfx->_backgroundInfo->y = (_vm->_screenHeight - _vm->_gfx->_backgroundInfo->height) >> 1; _vm->_input->setMouseState(MOUSE_DISABLED); _startTime = g_system->getMillis(); @@ -217,8 +217,8 @@ public: _vm->_gfx->clearScreen(); _vm->_gfx->setBackground(kBackgroundSlide, "tbra", 0, 0); if (_vm->getPlatform() == Common::kPlatformPC) { - _vm->_gfx->_backgroundInfo.x = 20; - _vm->_gfx->_backgroundInfo.y = 50; + _vm->_gfx->_backgroundInfo->x = 20; + _vm->_gfx->_backgroundInfo->y = 50; } // TODO: load progress from savefile diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 54cb175e46..e13d2f9aa4 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -264,7 +264,6 @@ void Parallaction::freeLocation() { _location._walkPoints.clear(); _gfx->clearGfxObjects(kGfxObjNormal); - freeBackground(); _location._programs.clear(); freeZones(); @@ -284,7 +283,6 @@ void Parallaction::freeLocation() { void Parallaction::freeBackground() { - _gfx->freeBackground(); _pathBuffer = 0; } @@ -292,7 +290,7 @@ void Parallaction::freeBackground() { void Parallaction::setBackground(const char* name, const char* mask, const char* path) { _gfx->setBackground(kBackgroundLocation, name, mask, path); - _pathBuffer = &_gfx->_backgroundInfo.path; + _pathBuffer = &_gfx->_backgroundInfo->path; return; } diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index 3ba2beb288..df992b9a20 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -464,9 +464,9 @@ DECLARE_LOCATION_PARSER(mask) { debugC(7, kDebugParser, "LOCATION_PARSER(mask) "); ctxt.maskName = strdup(_tokens[1]); - _vm->_gfx->_backgroundInfo.layers[0] = atoi(_tokens[2]); - _vm->_gfx->_backgroundInfo.layers[1] = atoi(_tokens[3]); - _vm->_gfx->_backgroundInfo.layers[2] = atoi(_tokens[4]); + _vm->_gfx->_backgroundInfo->layers[0] = atoi(_tokens[2]); + _vm->_gfx->_backgroundInfo->layers[1] = atoi(_tokens[3]); + _vm->_gfx->_backgroundInfo->layers[2] = atoi(_tokens[4]); } @@ -1179,7 +1179,7 @@ void LocationParser_br::parse(Script *script) { LocationParser_ns::parse(script); _vm->_gfx->setBackground(kBackgroundLocation, ctxt.bgName, ctxt.maskName, ctxt.pathName); - _vm->_pathBuffer = &_vm->_gfx->_backgroundInfo.path; + _vm->_pathBuffer = &_vm->_gfx->_backgroundInfo->path; if (ctxt.characterName) { _vm->changeCharacter(ctxt.characterName); |