diff options
author | Strangerke | 2014-03-29 09:41:55 +0100 |
---|---|---|
committer | Strangerke | 2014-03-29 09:41:55 +0100 |
commit | d801c2ffdd1b2e5cfefcea18309a4779e0a824a1 (patch) | |
tree | 446f5f17cf47890e5b1289eaed2d014561aaf49d /engines/mads | |
parent | e8de00f8770ab43259176400a9245006bc3b327a (diff) | |
download | scummvm-rg350-d801c2ffdd1b2e5cfefcea18309a4779e0a824a1.tar.gz scummvm-rg350-d801c2ffdd1b2e5cfefcea18309a4779e0a824a1.tar.bz2 scummvm-rg350-d801c2ffdd1b2e5cfefcea18309a4779e0a824a1.zip |
MADS: Implement palette::lock() and unlock(), get rid of some magic values in scene 202 and 203, some renaming
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/game.cpp | 1 | ||||
-rw-r--r-- | engines/mads/nebular/nebular_scenes2.cpp | 32 | ||||
-rw-r--r-- | engines/mads/nebular/nebular_scenes2.h | 4 | ||||
-rw-r--r-- | engines/mads/palette.cpp | 42 | ||||
-rw-r--r-- | engines/mads/palette.h | 9 |
5 files changed, 52 insertions, 36 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index a1ca02cbf4..faa2bfaefc 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -142,6 +142,7 @@ void Game::gameLoop() { } // TODO: Extra reset methods + _vm->_palette->unlock(); _vm->_events->waitCursor(); _vm->_events->freeCursors(); _vm->_sound->closeDriver(); diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp index ed43275451..99c6cf4103 100644 --- a/engines/mads/nebular/nebular_scenes2.cpp +++ b/engines/mads/nebular/nebular_scenes2.cpp @@ -464,7 +464,7 @@ void Scene202::setRandomKernelMessage() { } void Scene202::step() { - if (!_activeMsgFl && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8) && (_vm->getRandomNumber(999) == 0)) { + if (!_activeMsgFl && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH) && (_vm->getRandomNumber(999) == 0)) { _scene->_kernelMessages.reset(); _activeMsgFl = false; if (_vm->getRandomNumber(4) == 0) @@ -939,7 +939,7 @@ void Scene202::actions() { } else if (action->isAction(VERB_LOOK, 0x142)) { _vm->_dialogs->show(0x4EF2); } else if (action->isAction(VERB_LOOK, 0xAA)) { - if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8)) + if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH)) _vm->_dialogs->show(0x4EF4); else _vm->_dialogs->show(0x4EF3); @@ -980,23 +980,23 @@ void Scene203::enter() { } else if (_scene->_priorSceneId == 209) { _game._player._playerPos = Common::Point(308, 117); _game._player._facing = FACING_WEST; - } else if (_scene->_priorSceneId == -2) { + } else if (_scene->_priorSceneId != -2) { _game._player._playerPos = Common::Point(155, 152); _game._player._facing = FACING_NORTH; } - _globals._v0 = 0; - _globals._frameTime = 0; + _rhotundaEatFl = false; + _rhotundaEat2Fl = false; - if ((_globals[kRhotundaStatus] == 0) && (_scene->_roomChanged == 0)) { - _globals._v0 = -1; + if ((_globals[kRhotundaStatus] == 0) && (!_scene->_roomChanged)) { + _rhotundaEatFl = true; _game._player.walk(Common::Point(158, 135), FACING_SOUTH); int idx = _scene->_dynamicHotspots.add(131, 396, 0, Common::Rect(0, 0, 320, 156)); _scene->_dynamicHotspots.setPosition(idx, 155, 152, FACING_SOUTH); _scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN); } - if (_globals._v0 == 0) { + if (!_rhotundaEatFl) { _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('b', -1), 0); if (_vm->getRandomNumber(1, 3) == 2) { _globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 9, 1, 0, 0); @@ -1008,7 +1008,7 @@ void Scene203::enter() { _game.loadQuoteSet(0x67, 0x68, 0x69, 0x6A, 0x5A, 0); - if (_globals._v0 != 0) { + if (_rhotundaEatFl) { _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(_vm->getRandomNumber(103, 106))); } @@ -1016,21 +1016,21 @@ void Scene203::enter() { } void Scene203::step() { - if (_globals._v0 == 0) + if (!_rhotundaEatFl) return; - if ((_game._trigger == 0) && (_globals._frameTime != 0)) + if ((_game._trigger == 0) && _rhotundaEat2Fl) return; - if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._facing != 2)) + if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._facing != FACING_SOUTH)) return; - _globals._frameTime = 0xFFFF; + _rhotundaEat2Fl = true; if (_game._trigger == 0) { _game._player._visible = false; _game._player._stepEnabled = false; - _vm->_palette->sub7BBF8(); + _vm->_palette->lock(); _scene->_kernelMessages.reset(); _scene->resetScene(); _vm->_events->setCursor2(CURSOR_WAIT); @@ -1042,7 +1042,7 @@ void Scene203::step() { } void Scene203::preActions() { - if (_globals._v0 && !_action.isAction(0x18C, 0x83)) { + if (_rhotundaEatFl && !_action.isAction(0x18C, 0x83)) { _game._player.walk(Common::Point(158, 136), FACING_SOUTH); _action._inProgress = false; return; @@ -1449,7 +1449,7 @@ void Scene208::step() { if (_globals._v0 == 0) return; - if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._facing != 6)) + if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._facing != FACING_EAST)) return; if ((_game._trigger == 0) && ((_globals._frameTime & 0xFFFF) != 0)) diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h index 0f247f3146..44ee528b8f 100644 --- a/engines/mads/nebular/nebular_scenes2.h +++ b/engines/mads/nebular/nebular_scenes2.h @@ -87,8 +87,10 @@ public: }; class Scene203: public Scene2xx { +private: + bool _rhotundaEat2Fl, _rhotundaEatFl; public: - Scene203(MADSEngine *vm) : Scene2xx(vm) {} + Scene203(MADSEngine *vm) : Scene2xx(vm), _rhotundaEat2Fl(false), _rhotundaEatFl(false) {} virtual void setup(); virtual void enter(); virtual void step(); diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index 311bd633e1..34ba0acf54 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -235,7 +235,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) { palette[palIndex]._palIndex = var4; } - _vm->_palette->_rgbList[rgbIndex] = -1; + _vm->_palette->_rgbList[rgbIndex] = true; return rgbIndex; } @@ -263,7 +263,7 @@ void PaletteUsage::updateUsage(Common::Array<int> &usageList, int sceneUsageInde uint32 bitMask = 1 << usageList[idx]; mask1 ^= bitMask; mask2 |= bitMask; - _vm->_palette->_rgbList[usageList[idx]] = 0; + _vm->_palette->_rgbList[usageList[idx]] = false; } uint32 mask3 = 1 << sceneUsageIndex; @@ -276,7 +276,7 @@ void PaletteUsage::updateUsage(Common::Array<int> &usageList, int sceneUsageInde } } - _vm->_palette->_rgbList[sceneUsageIndex] = -1; + _vm->_palette->_rgbList[sceneUsageIndex] = true; } int PaletteUsage::getGamePalFreeIndex(int *palIndex) { @@ -306,11 +306,13 @@ int PaletteUsage::rgbFactor(byte *palEntry, RGB6 &pal6) { /*------------------------------------------------------------------------*/ void RGBList::clear() { - Common::fill(&_data[0], &_data[32], 0); + for (int i = 0; i < 32; i++) + _data[i] = false; } void RGBList::reset() { - Common::fill(&_data[2], &_data[32], 0); + for (int i = 2; i < 32; i++) + _data[i] = false; } int RGBList::scan() { @@ -319,7 +321,7 @@ int RGBList::scan() { return i; } - error("List was full"); + error("RGBList was full"); } /*------------------------------------------------------------------------*/ @@ -327,7 +329,7 @@ int RGBList::scan() { Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) { reset(); - _v1 = 0; + _lockFl = false; _lowRange = 0; _highRange = 0; Common::fill(&_mainPalette[0], &_mainPalette[PALETTE_SIZE], 0); @@ -435,9 +437,9 @@ void Palette::resetGamePalette(int lowRange, int highRange) { } _rgbList.clear(); - _rgbList[0] = _rgbList[1] = -1; + _rgbList[0] = _rgbList[1] = true; - _v1 = 0; + _lockFl = false; _lowRange = lowRange; _highRange = highRange; } @@ -463,7 +465,7 @@ void Palette::initPalette() { for (int idx = 0; idx < PALETTE_COUNT; ++idx) _palFlags[idx] = palMask; - _v1 = 0; + _lockFl = false; _rgbList.reset(); } @@ -486,12 +488,12 @@ void Palette::setLowRange() { void Palette::fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6) { } -void Palette::sub7BBF8() { - if ((_rgbList[31] != 0) && (_v1 == 0)) - error("Palette - Unexpected values"); +void Palette::lock() { + if (_rgbList[31] && !_lockFl) + error("Palette Lock - Unexpected values"); - _v1 = -1; - _rgbList[31] = -1; + _lockFl = true; + _rgbList[31] = true; for (int i = 0; i < 256; i++) { if (_palFlags[i]) @@ -499,4 +501,14 @@ void Palette::sub7BBF8() { } } +void Palette::unlock() { + if (!_lockFl) + return; + + for (int i = 0; i < 256; i++) + _palFlags[i] &= 0x7FFFFFFF; + + _rgbList[31] = false; + _lockFl = false; +} } // End of namespace MADS diff --git a/engines/mads/palette.h b/engines/mads/palette.h index ae29d181ec..dd5eaf6c2b 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -110,7 +110,7 @@ public: class RGBList { private: - int16 _data[32]; + bool _data[32]; public: RGBList() { clear(); } @@ -123,7 +123,7 @@ public: */ int scan(); - int16 &operator[](int idx) { return _data[idx]; } + bool &operator[](int idx) { return _data[idx]; } }; #define PALETTE_COUNT 256 @@ -146,7 +146,7 @@ public: uint32 _palFlags[PALETTE_COUNT]; PaletteUsage _paletteUsage; RGBList _rgbList; - int _v1; + bool _lockFl; int _lowRange; int _highRange; public: @@ -229,7 +229,8 @@ public: void fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6); - void sub7BBF8(); + void lock(); + void unlock(); }; } // End of namespace MADS |