diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/callables_ns.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/graphics.cpp | 44 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 57 | ||||
-rw-r--r-- | engines/parallaction/gui_ns.cpp | 3 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 28 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 12 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 20 | ||||
-rw-r--r-- | engines/parallaction/parser_br.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/walk.h | 34 |
9 files changed, 119 insertions, 99 deletions
diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index 51145dabaa..51a4fb1f6f 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -330,7 +330,7 @@ void Parallaction_ns::_c_onMouse(void *parm) { void Parallaction_ns::_c_setMask(void *parm) { - memset(_backgroundInfo->mask.data + 3600, 0, 3600); + memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600); _gfx->_bgLayers[1] = 500; return; @@ -586,7 +586,7 @@ void Parallaction_ns::_c_sketch(void *parm) { newx = _rightHandPositions[2*index]; } - Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _backgroundInfo); + Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _gfx->_backgroundInfo); _rightHandAnim->_left = newx; _rightHandAnim->_top = newy - 20; @@ -608,11 +608,11 @@ void Parallaction_ns::_c_shade(void *parm) { _rightHandAnim->_top ); - uint16 _di = r.left/4 + r.top * _backgroundInfo->mask.internalWidth; + uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth; for (uint16 _si = r.top; _si < r.bottom; _si++) { - memset(_backgroundInfo->mask.data + _di, 0, r.width()/4+1); - _di += _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/graphics.cpp b/engines/parallaction/graphics.cpp index 2ed4a99405..6479a796d2 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -345,6 +345,7 @@ void Gfx::drawBalloons() { } void Gfx::updateScreen() { +#if 0 if (_halfbrite) { Graphics::Surface *surf = g_system->lockScreen(); byte *src = (byte*)_buffers[kBitFront]->pixels; @@ -359,6 +360,8 @@ void Gfx::updateScreen() { } else { g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight); } +#endif + g_system->copyRectToScreen((const byte*)_buffers[kBit2]->pixels, _buffers[kBit2]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight); Graphics::Surface *surf = g_system->lockScreen(); drawGfxObjects(*surf); @@ -900,6 +903,7 @@ Gfx::Gfx(Parallaction* vm) : _hbCircleRadius = 0; _font = NULL; + _backgroundInfo = new BackgroundInfo; return; } @@ -908,6 +912,9 @@ Gfx::~Gfx() { freeBuffers(); + freeBackground(); + delete _backgroundInfo; + return; } @@ -1173,4 +1180,41 @@ bool Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 } +void Gfx::freeBackground() { + + if (!_backgroundInfo) + return; + + _backgroundInfo->bg.free(); + _backgroundInfo->mask.free(); + _backgroundInfo->path.free(); + +} + +void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) { + + if (type == kBackgroundLocation) { + + _disk->loadScenery(*_backgroundInfo, name, mask, path); + + setPalette(_backgroundInfo->palette); + _palette.clone(_backgroundInfo->palette); + setBackground(&_backgroundInfo->bg); + + if (_backgroundInfo->mask.data) + setMask(&_backgroundInfo->mask); + + } else { + + _disk->loadSlide(*_backgroundInfo, name); + + setPalette(_backgroundInfo->palette); + setBackground(&_backgroundInfo->bg); + + } + + return; +} + + } // namespace Parallaction diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 1af1d1e8ea..2791285320 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -152,6 +152,41 @@ public: }; + +struct PathBuffer { + // handles a 1-bit depth buffer used for masking non-walkable areas + + uint16 w; + uint16 internalWidth; + uint16 h; + uint size; + byte *data; + +public: + PathBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) { + } + + void create(uint16 width, uint16 height) { + w = width; + internalWidth = w >> 3; + h = height; + size = (internalWidth * h); + data = (byte*)calloc(size, 1); + } + + void free() { + ::free(data); + data = 0; + w = 0; + h = 0; + internalWidth = 0; + size = 0; + } + + inline byte getValue(uint16 x, uint16 y); +}; + + class Palette { byte _data[768]; @@ -290,9 +325,25 @@ public: void release(); }; - typedef Common::List<GfxObj*> GfxObjList; +struct BackgroundInfo { + uint width; + uint height; + + Graphics::Surface bg; + MaskBuffer mask; + PathBuffer path; + + Palette palette; +}; + + +enum { + kBackgroundLocation = 1, + kBackgroundSlide = 2 +}; + class Gfx { public: @@ -315,6 +366,10 @@ public: void drawGfxObjects(Graphics::Surface &surf); void sortAnimations(); + BackgroundInfo *_backgroundInfo; + void freeBackground(); + void setBackground(uint type, const char* name, const char* mask, const char* path); + public: // balloons and text diff --git a/engines/parallaction/gui_ns.cpp b/engines/parallaction/gui_ns.cpp index 93ed953163..ad059ac0d2 100644 --- a/engines/parallaction/gui_ns.cpp +++ b/engines/parallaction/gui_ns.cpp @@ -178,11 +178,12 @@ void Parallaction_ns::guiSplash() { showSlide("intro"); _gfx->updateScreen(); g_system->delayMillis(2000); + freeBackground(); showSlide("minintro"); _gfx->updateScreen(); g_system->delayMillis(2000); - + freeBackground(); } int Parallaction_ns::guiNewGame() { diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index acf01cf433..57a1cc6e96 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -118,9 +118,6 @@ Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gam Parallaction::~Parallaction() { delete _debugger; - freeBackground(); - delete _backgroundInfo; - delete _globalTable; delete _callableNames; @@ -160,14 +157,11 @@ int Parallaction::init() { _location._comment = NULL; _location._endComment = NULL; - _backgroundInfo = 0; _pathBuffer = 0; _activeZone = 0; _screenSize = _screenWidth * _screenHeight; - _backgroundInfo = new BackgroundInfo; - strcpy(_characterName1, "null"); memset(_locationNames, 0, NUM_LOCATIONS * 32); @@ -725,6 +719,7 @@ void Parallaction::freeLocation() { _location._walkNodes.clear(); _gfx->clearGfxObjects(); + freeBackground(); freeZones(); freeAnimations(); @@ -743,30 +738,15 @@ void Parallaction::freeLocation() { void Parallaction::freeBackground() { - if (!_backgroundInfo) - return; - - _backgroundInfo->bg.free(); - _backgroundInfo->mask.free(); - _backgroundInfo->path.free(); - + _gfx->freeBackground(); _pathBuffer = 0; } void Parallaction::setBackground(const char* name, const char* mask, const char* path) { - _disk->loadScenery(*_backgroundInfo, name, mask, path); - - _gfx->setPalette(_backgroundInfo->palette); - _gfx->_palette.clone(_backgroundInfo->palette); - _gfx->setBackground(&_backgroundInfo->bg); - - if (_backgroundInfo->mask.data) - _gfx->setMask(&_backgroundInfo->mask); - - if (_backgroundInfo->path.data) - _pathBuffer = &_backgroundInfo->path; + _gfx->setBackground(kBackgroundLocation, name, mask, path); + _pathBuffer = &_gfx->_backgroundInfo->path; return; } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index b77d30e41e..8cfddd889b 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -237,16 +237,6 @@ public: -struct BackgroundInfo { - uint width; - uint height; - - Graphics::Surface bg; - MaskBuffer mask; - PathBuffer path; - - Palette palette; -}; class Opcode { @@ -453,8 +443,6 @@ protected: // data bool _hasLocationSound; char _locationSound[50]; - BackgroundInfo *_backgroundInfo; - Zone *_hoverZone; diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 98a9ea0202..72a01d3d90 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -266,24 +266,7 @@ void Parallaction_ns::switchBackground(const char* background, const char* mask) void Parallaction_ns::showSlide(const char *name) { - - BackgroundInfo info; - - _disk->loadSlide(info, name); - - // TODO: avoid using screen buffers for displaying slides. Using a generic buffer - // allows for positioning of graphics as needed by Big Red Adventure. - // The main problem lies with menu, which relies on multiple buffers, mainly because - // it is crappy code. - _gfx->setBackground(&info.bg); - _gfx->setPalette(info.palette); - _gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); - - info.bg.free(); - info.mask.free(); - info.path.free(); - - return; + _gfx->setBackground(kBackgroundSlide, name, 0, 0); } // changeLocation handles transitions between locations, and is able to display slides @@ -315,6 +298,7 @@ void Parallaction_ns::changeLocation(char *location) { _gfx->showLabel(id, CENTER_LABEL_HORIZONTAL, 14); waitUntilLeftClick(); _gfx->freeLabels(); + freeBackground(); } if (locname.hasCharacter()) { diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index 9b42b043af..8d6d5d9ab0 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -125,7 +125,7 @@ DECLARE_LOCATION_PARSER(location) { } else { nextToken = 2; } - +#if 0 _disk->loadScenery(*_backgroundInfo, _location._name, NULL, NULL); // if (flip) { @@ -135,7 +135,7 @@ DECLARE_LOCATION_PARSER(location) { _gfx->setBackground(&_backgroundInfo->bg); _gfx->_palette.clone(_backgroundInfo->palette); _gfx->setPalette(_backgroundInfo->palette); - +#endif if (_tokens[nextToken][0] != '\0') { _char._ani._left = atoi(_tokens[nextToken]); @@ -271,21 +271,23 @@ DECLARE_LOCATION_PARSER(null) { DECLARE_LOCATION_PARSER(mask) { debugC(7, kDebugParser, "LOCATION_PARSER(mask) "); - +#if 0 _disk->loadScenery(*_backgroundInfo, NULL, _tokens[1], NULL); _gfx->setMask(&_backgroundInfo->mask); _gfx->_bgLayers[0] = atoi(_tokens[2]); _gfx->_bgLayers[1] = atoi(_tokens[3]); _gfx->_bgLayers[2] = atoi(_tokens[4]); +#endif } DECLARE_LOCATION_PARSER(path) { debugC(7, kDebugParser, "LOCATION_PARSER(path) "); - +#if 0 _disk->loadScenery(*_backgroundInfo, NULL, NULL, _tokens[1]); _pathBuffer = &_backgroundInfo->path; +#endif } diff --git a/engines/parallaction/walk.h b/engines/parallaction/walk.h index c5e8cebc8a..1b03aa6334 100644 --- a/engines/parallaction/walk.h +++ b/engines/parallaction/walk.h @@ -47,40 +47,6 @@ public: typedef ManagedList<WalkNode*> WalkNodeList; -struct PathBuffer { - // handles a 1-bit depth buffer used for masking non-walkable areas - - uint16 w; - uint16 internalWidth; - uint16 h; - uint size; - byte *data; - -public: - PathBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) { - } - - void create(uint16 width, uint16 height) { - w = width; - internalWidth = w >> 3; - h = height; - size = (internalWidth * h); - data = (byte*)calloc(size, 1); - } - - void free() { - ::free(data); - data = 0; - w = 0; - h = 0; - internalWidth = 0; - size = 0; - } - - inline byte getValue(uint16 x, uint16 y); -}; - - class PathBuilder { Animation *_anim; |