From 1495f04bbcbe26bb3f2b93131e3d89c30ea47279 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 23 Apr 2014 21:57:25 -0400 Subject: MADS: Fix scenes previously using globals to properly use locals --- engines/mads/game.cpp | 3 + engines/mads/nebular/globals_nebular.cpp | 14 --- engines/mads/nebular/globals_nebular.h | 2 + engines/mads/nebular/nebular_scenes1.cpp | 10 +- engines/mads/nebular/nebular_scenes1.h | 3 + engines/mads/nebular/nebular_scenes2.cpp | 35 +++--- engines/mads/nebular/nebular_scenes2.h | 3 +- engines/mads/nebular/nebular_scenes3.cpp | 6 +- engines/mads/nebular/nebular_scenes8.cpp | 191 +++++++++++++++++-------------- engines/mads/nebular/nebular_scenes8.h | 10 ++ 10 files changed, 153 insertions(+), 124 deletions(-) diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index 462c6401a9..9c124aa6a6 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -409,6 +409,9 @@ void Game::synchronize(Common::Serializer &s, bool phase1) { _sectionNumber = _scene._nextSceneId / 100; _currentSectionNumber = _sectionNumber; _scene._frameStartTime = _vm->_events->getFrameCounter(); + + _player._spritesLoaded = false; + _player._spritesChanged = true; } } else { s.syncAsByte(_difficulty); diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp index a8b7cdce72..4144797abc 100644 --- a/engines/mads/nebular/globals_nebular.cpp +++ b/engines/mads/nebular/globals_nebular.cpp @@ -37,20 +37,6 @@ NebularGlobals::NebularGlobals(): Globals() { // Initialize game flags _timebombClock = 0; _timebombTimer = 0; - _v0 = 0; - _frameTime = 0; - _v2 = 0; - _v3 = 0; - _v4 = 0; - _v5 = 0; - _v6 = 0; - _v7 = 0; - _v8 = 0; - _abortVal = 0; - _v84262 = 0; - _v84264 = 0; - _v84266 = 0; - _v84268 = 0; } } // End of namespace Nebular diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h index b8fe17f333..56fbc1b4ca 100644 --- a/engines/mads/nebular/globals_nebular.h +++ b/engines/mads/nebular/globals_nebular.h @@ -285,6 +285,7 @@ public: Common::Array _sequenceIndexes; int _timebombClock, _timebombTimer; + /* int _v0; uint32 _frameTime; int _v2; @@ -296,6 +297,7 @@ public: int _v8; int _abortVal; int _v84262, _v84264, _v84266, _v84268; + */ public: /** * Constructor diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp index 2440068698..da2d358458 100644 --- a/engines/mads/nebular/nebular_scenes1.cpp +++ b/engines/mads/nebular/nebular_scenes1.cpp @@ -1267,8 +1267,8 @@ void Scene103::enter() { _vm->_palette->setEntry(252, 63, 63, 10); _vm->_palette->setEntry(253, 45, 45, 10); - _globals._v0 = 0; - _globals._frameTime = _scene->_frameStartTime; + _sayHiToBinky = false; + _updateClock = _scene->_frameStartTime; } void Scene103::step() { @@ -1296,7 +1296,7 @@ void Scene103::step() { break; } - if (_globals._frameTime <= _scene->_frameStartTime) { + if (_scene->_frameStartTime >= _updateClock) { pt = _vm->_game->_player._playerPos; dist = _vm->hypotenuse(pt.x - 79, pt.y - 137); _vm->_sound->command(29, (dist * -127 / 378) + 127); @@ -1309,7 +1309,7 @@ void Scene103::step() { dist = _vm->hypotenuse(pt.x - 266, pt.y - 138); _vm->_sound->command(32, (dist * -127 / 378) + 127); - _globals._frameTime = _scene->_frameStartTime + _vm->_game->_player._ticksAmount; + _updateClock = _scene->_frameStartTime + _vm->_game->_player._ticksAmount; } } @@ -1438,7 +1438,7 @@ void Scene103::actions() { case 1: { Common::String msg = _game.getQuote(72); _scene->_kernelMessages.add(Common::Point(310, 132), 0xFDFC, 16, 2, 120, msg); - _globals._v0 = 0; + _sayHiToBinky = false; break; } diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h index b4585b0ed3..d295c4d727 100644 --- a/engines/mads/nebular/nebular_scenes1.h +++ b/engines/mads/nebular/nebular_scenes1.h @@ -102,6 +102,9 @@ public: }; class Scene103 : public Scene1xx { +private: + bool _sayHiToBinky; + uint32 _updateClock; public: Scene103(MADSEngine *vm) : Scene1xx(vm) {} diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp index 7491ed1479..88b3f941ea 100644 --- a/engines/mads/nebular/nebular_scenes2.cpp +++ b/engines/mads/nebular/nebular_scenes2.cpp @@ -449,7 +449,8 @@ void Scene202::enter() { _game._player._playerPos = Common::Point(246, 124); _game._player._facing = FACING_NORTH; } - _globals._abortVal = 0; + + _meteorologistSpecial = 0; } void Scene202::setRandomKernelMessage() { @@ -493,7 +494,7 @@ void Scene202::step() { _action._activeAction._indirectObjectId = 438; _game._triggerSetupMode = SEQUENCE_TRIGGER_PARSER; _scene->_sequences.addTimer(120, 2); - _globals._abortVal = -1; + _meteorologistSpecial = -1; } else if (_globals[kMeteorologistWatch] == 2) { _scene->_sequences.addTimer(120, 90); } @@ -849,7 +850,7 @@ void Scene202::actions() { } break; case 2: - if (!_scene->_activeAnimation && (_globals._abortVal == 0)) { + if (!_scene->_activeAnimation && !_meteorologistSpecial) { _vm->_dialogs->show(0x4EFE); } _scene->_sequences.remove(_globals._sequenceIndexes[10]); @@ -905,7 +906,7 @@ void Scene202::actions() { case 2: if (!_scene->_activeAnimation) _vm->_dialogs->show(0x4EFE); - _globals._abortVal = 0; + _meteorologistSpecial = 0; _scene->_sequences.remove(_globals._sequenceIndexes[10]); _globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0); _scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82)); @@ -1136,7 +1137,7 @@ void Scene205::enter() { _scene->_hotspots.activate(450, false); } - _globals._frameTime &= 0xFFFF; + _beingKicked = false; _game.loadQuoteSet(0x6B, 0x70, 0x71, 0x72, 0x5A, 0x74, 0x75, 0x76, 0x77, 0x78, 0x73, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0xAC, 0xAD, 0xAE, 0x6C, 0x6D, 0x6E, 0x6F, 0x2, 0); warning("TODO: sub71A50(&dialog1, 0x5A, 0x78, 0x74, 0x75, 0x76, 0x77, 0);"); @@ -1150,7 +1151,7 @@ void Scene205::enter() { _vm->_palette->setEntry(252, 63, 63, 40); _vm->_palette->setEntry(253, 50, 50, 30); - _chickenTime = _globals._frameTime; + _chickenTime = _vm->_game->_scene._frameStartTime; if (_globals[kSexOfRex] == SEX_FEMALE) warning("sub71704(0x3, 0xC3, 0x108, 0x63, 0x86, 0xD, 2, 0xFDFC, 0x3C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6C, 0);"); @@ -1162,7 +1163,7 @@ void Scene205::enter() { _scene->loadAnimation(formAnimName('a', -1), 0); _scene->_activeAnimation->_resetFlag = false; } else { - _globals._frameTime |= 0xFFFF0000; + _beingKicked = true; _globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0); _game._player._visible = false; _game._player._stepEnabled = false; @@ -1178,19 +1179,21 @@ void Scene205::step() { if (_globals[kSexOfRex] == SEX_FEMALE) { warning("TODO: sub7178C()"); - if (_globals._frameTime >= _chickenTime) { + if (_vm->_game->_scene._frameStartTime >= _chickenTime) { warning("TODO: if (sub717B2(100, 1 + sub7176C()))"); _vm->_sound->command(28); // } - _chickenTime = _globals._frameTime + 2; + _chickenTime = _vm->_game->_scene._frameStartTime + 2; } } - if (_globals._frameTime - _lastFishTime > 1300) { - _globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 5, 1, 0, 0); - int idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0)); + if (_vm->_game->_scene._frameStartTime - _lastFishTime > 1300) { + _globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle( + _globals._spriteIndexes[6], false, 5, 1, 0, 0); + int idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6], + Common::Rect(0, 0, 0, 0)); _scene->_dynamicHotspots.setPosition(idx, Common::Point(49, 86), FACING_NORTH); - _lastFishTime = _globals._frameTime; + _lastFishTime = _vm->_game->_scene._frameStartTime; } if (_game._trigger == 73) { @@ -4296,7 +4299,7 @@ void Scene211::enter() { if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) warning("sub71704(0x2, 0x0, 0x36, 0x0, 0x1E, 0xD, 2, 0xFDFC, 0x3C, 0x97, 0x98, 0x99, 0x9A, 0);"); - _monkeyTime = _globals._frameTime; + _monkeyTime = _vm->_game->_scene._frameStartTime; _scrollY = 30; _ambushFl = false; @@ -4309,11 +4312,11 @@ void Scene211::step() { if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) { warning("TODO: sub7178C()"); - if (!_ambushFl && !_wakeFl && (_globals._frameTime >= _monkeyTime)) { + if (!_ambushFl && !_wakeFl && (_vm->_game->_scene._frameStartTime >= _monkeyTime)) { warning("if (sub717B2(80, 1 + sub7176C())) {"); _vm->_sound->command(18); // } - _monkeyTime = _globals._frameTime + 2; + _monkeyTime = _vm->_game->_scene._frameStartTime + 2; } if ((_game._player._playerPos == Common::Point(52, 132)) && (_game._player._facing == FACING_WEST) && !_game._player._moving && diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h index ad87681aac..45fe7908c6 100644 --- a/engines/mads/nebular/nebular_scenes2.h +++ b/engines/mads/nebular/nebular_scenes2.h @@ -68,6 +68,7 @@ private: bool _activeMsgFl, _ladderTopFl, _waitingMeteoFl, _toStationFl, _toTeleportFl; int _ladderHotspotId, _lastRoute, _stationCounter, _meteoFrame; uint32 _meteoClock1, _meteoClock2, _startTime; + int _meteorologistSpecial; int subStep1(int randVal); int subStep2(int randVal); @@ -105,7 +106,7 @@ public: class Scene205: public Scene2xx { private: uint32 _lastFishTime, _chickenTime; - + bool _beingKicked; public: Scene205(MADSEngine *vm) : Scene2xx(vm), _lastFishTime(0), _chickenTime(0) {} diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp index 4ca5a6c5b4..9f4873f55a 100644 --- a/engines/mads/nebular/nebular_scenes3.cpp +++ b/engines/mads/nebular/nebular_scenes3.cpp @@ -2536,7 +2536,7 @@ void Scene318::enter() { _vm->_palette->setEntry(252, 63, 63, 10); _vm->_palette->setEntry(253, 45, 45, 05); - _dropTimer = _globals._frameTime; + _dropTimer = _vm->_game->_scene._frameStartTime; sceneEntrySound(); if (_dialogFl) @@ -2662,11 +2662,11 @@ void Scene318::step() { } } - if ((_globals._frameTime - _dropTimer) > 600) { + if ((_vm->_game->_scene._frameStartTime - _dropTimer) > 600) { _vm->_sound->command(51); _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 14, 1, 0, 0); _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10); - _dropTimer = _globals._frameTime; + _dropTimer = _vm->_game->_scene._frameStartTime; } } diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp index 8a5c3dfed5..5a283d512d 100644 --- a/engines/mads/nebular/nebular_scenes8.cpp +++ b/engines/mads/nebular/nebular_scenes8.cpp @@ -80,14 +80,17 @@ void Scene804::setup() { } void Scene804::enter() { - _globals._frameTime = 0; - _globals._v2 = 0; - _globals._v3 = 0; - _globals._v4 = 0; - _globals._v5 = -1; - _globals._v6 = 0; - _globals._v7 = 0; - _globals._v8 = 0; + _messWithThrottle = false; + _throttleCounter = 0; + _movingThrottle = false; + _throttleGone = false; + _dontPullThrottleAgain = false; + _resetFrame = -1; + _pullThrottleReally = false; + _alreadyOrgan = false; + _alreadyPop = false; + + if (_globals[kCopyProtectFailed]) { // Copy protection failed _globals[kInSpace] = true; @@ -136,152 +139,170 @@ void Scene804::enter() { } void Scene804::step() { - if (_globals._frameTime) { - if (_scene->_activeAnimation->getCurrentFrame() == 36 && !_globals._v3) { - _scene->_sequences.remove(_globals._sequenceIndexes[1]); - _globals._v3 = -1; - } - if (_scene->_activeAnimation->getCurrentFrame() == 39) { - _globals._v2 = 0; - if ((_globals._frameTime / 256) == 3) - _scene->_sequences.addTimer(130, 120); - } + if (!_messWithThrottle) { - if (!_globals._v2) { - _globals._frameTime += 0x100; - _globals._v2 = -1; - - if ((_globals._frameTime / 256) >= 4) { - _globals._frameTime = 0; - _game._player._stepEnabled = true; - } else { - _globals._v5 = 34; - } - } - } else { - if (_globals._v3 && _globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 39) { - _globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1); + if ((_throttleGone) && (_movingThrottle) && (_scene->_activeAnimation->getCurrentFrame() == 39)) { + _globals._sequenceIndexes[1] = _scene->_sequences.startCycle + (_globals._spriteIndexes[1], false, 1); _scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(133, 139)); _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8); - _globals._v3 = 0; + _throttleGone = false; } - if (_globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 42) { - _globals._v5 = 0; - _globals._v2 = 0; + if ((_movingThrottle) && (_scene->_activeAnimation->getCurrentFrame() == 42)) { + _resetFrame = 0; + _movingThrottle = false; } - if (_game._trigger == 70) - _globals._v5 = 42; + if (_game._trigger == 70) { + _resetFrame = 42; + } - if (_scene->_activeAnimation->getCurrentFrame() == 65) + if (_scene->_activeAnimation->getCurrentFrame() == 65) { _scene->_sequences.remove(_globals._sequenceIndexes[7]); + } - switch (_game._storyMode) { + switch (_game._storyMode) { case STORYMODE_NAUGHTY: if (_scene->_activeAnimation->getCurrentFrame() == 81) { - _globals._v5 = 80; - } else { - _globals[kInSpace] = 0; - _globals[kBeamIsUp] = -1; + _resetFrame = 80; + _globals[kInSpace] = false; + _globals[kBeamIsUp] = true; + assert(!_globals[kCopyProtectFailed]); _game._winStatus = 4; _vm->quitGame(); } break; - case STORYMODE_NICE: + case STORYMODE_NICE: if (_scene->_activeAnimation->getCurrentFrame() == 68) { - _globals._v5 = 66; - } else { - _globals[kInSpace] = 0; - _globals[kBeamIsUp] = -1; + _resetFrame = 66; + _globals[kInSpace] = false; + _globals[kBeamIsUp] = true; + assert(!_globals[kCopyProtectFailed]); _game._winStatus = 4; _vm->quitGame(); } - break; } if (_scene->_activeAnimation->getCurrentFrame() == 34) { - _globals._v5 = 36; + _resetFrame = 36; _scene->_sequences.remove(_globals._sequenceIndexes[1]); } + if (_scene->_activeAnimation->getCurrentFrame() == 37) { - _globals._v5 = 36; - if (!_globals._v4) + _resetFrame = 36; + if (!_dontPullThrottleAgain) { + _dontPullThrottleAgain = true; _scene->_sequences.addTimer(60, 80); + } } - if (_game._trigger == 80) + if (_game._trigger == 80) { _scene->_nextSceneId = 803; + } - if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[kWindowFixed]) { + if ((_scene->_activeAnimation->getCurrentFrame() == 7) && (!_globals[kWindowFixed])) { _globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1); _scene->_sequences.addTimer(20, 110); - _globals[kWindowFixed] = -1; + _globals[kWindowFixed] = true; } if (_scene->_activeAnimation->getCurrentFrame() == 10) { - _globals._v5 = 0; + _resetFrame = 0; _game._player._stepEnabled = true; - _game._objects.setRoom(OBJ_POLYCEMENT, 1); + _game._objects.setRoom(OBJ_POLYCEMENT, NOWHERE); } - switch (_scene->_activeAnimation->getCurrentFrame()) { - case 1: - _globals[kRandomNumber] = _vm->getRandomNumber(1, 30); - switch (_globals[kRandomNumber]) { + if (_scene->_activeAnimation->getCurrentFrame() == 1) { + int randomVal = _vm->getRandomNumber(29) + 1; + switch (randomVal) { case 1: - _globals._v5 = 25; + _resetFrame = 25; break; case 2: - _globals._v5 = 27; + _resetFrame = 27; break; case 3: - _globals._v5 = 9; + _resetFrame = 29; break; default: - _globals._v5 = 0; + _resetFrame = 0; break; } - break; + } + switch (_scene->_activeAnimation->getCurrentFrame()) { case 26: case 28: case 31: - _globals._v5 = 0; + _resetFrame = 0; break; + } + } else { + if ((_scene->_activeAnimation->getCurrentFrame() == 36) && (!_throttleGone)) { + _scene->_sequences.remove(_globals._sequenceIndexes[1]); + _throttleGone = true; + } - default: - break; + if (_scene->_activeAnimation->getCurrentFrame() == 39) { + _movingThrottle = false; + switch (_throttleCounter) { + case 1: + break; + case 3: + _scene->_sequences.addTimer(130, 120); + break; + } } + + if (!_movingThrottle) { + ++_throttleCounter; + _movingThrottle = true; + if (_throttleCounter < 4) { + _resetFrame = 34; + } else { + _messWithThrottle = false; + _throttleCounter = 0; + _game._player._stepEnabled = true; + } + } + } + + if (_game._trigger == 120) { + _vm->_dialogs->show(80422); } - if (_game._trigger == 120) - _vm->_dialogs->show(0x13a26); - if (_game._trigger == 110) - _vm->_dialogs->show(0x13a2a); + if (_game._trigger == 110) { + _vm->_dialogs->show(80426); + } - if (_globals._v6) { - _globals._v5 = 32; - _globals._v6 = 0; + if (_pullThrottleReally) { + _resetFrame = 32; + _pullThrottleReally = false; } - if (_globals._v5 >= 0 && (_scene->_activeAnimation->getCurrentFrame() != _globals._v5)) { - _scene->_activeAnimation->setCurrentFrame(_globals._v5); - _globals._v5 = -1; + + if (_resetFrame >= 0) { + if (_resetFrame != _scene->_activeAnimation->getCurrentFrame()) { + _scene->_activeAnimation->setCurrentFrame(_resetFrame); + _resetFrame = -1; + } } - if (_game._trigger == 90) + if (_game._trigger == 90) { _scene->_nextSceneId = 803; + } - if (_scene->_activeAnimation->getCurrentFrame() == 7 &&!_globals._v8) { + if ((_scene->_activeAnimation->getCurrentFrame() == 72) && !_alreadyPop) { _vm->_sound->command(21); - _globals._v8 = -1; + _alreadyPop = true; } - if (_scene->_activeAnimation->getCurrentFrame() == 80 && !_globals._v7) { + + if ((_scene->_activeAnimation->getCurrentFrame() == 80) && !_alreadyOrgan) { _vm->_sound->command(22); - _globals._v7 = 0xFFFFFFFF; + _alreadyOrgan = true; } } diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h index a3bc97a990..45e8716d14 100644 --- a/engines/mads/nebular/nebular_scenes8.h +++ b/engines/mads/nebular/nebular_scenes8.h @@ -53,6 +53,16 @@ public: }; class Scene804: public Scene8xx { +private: + bool _messWithThrottle; + uint32 _throttleCounter = 0; + bool _movingThrottle; + bool _throttleGone; + bool _dontPullThrottleAgain; + int _resetFrame; + bool _pullThrottleReally; + bool _alreadyOrgan; + bool _alreadyPop; public: Scene804(MADSEngine *vm) : Scene8xx(vm) {} -- cgit v1.2.3