diff options
-rw-r--r-- | engines/mohawk/myst.cpp | 30 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 4 | ||||
-rw-r--r-- | engines/mohawk/myst_saveload.cpp | 278 | ||||
-rw-r--r-- | engines/mohawk/myst_saveload.h | 50 | ||||
-rw-r--r-- | engines/mohawk/myst_scripts.cpp | 17 | ||||
-rw-r--r-- | engines/mohawk/myst_scripts.h | 3 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/channelwood.cpp | 70 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/channelwood.h | 2 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/dni.cpp | 6 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/dni.h | 2 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/intro.cpp | 2 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/mechanical.cpp | 26 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/mechanical.h | 2 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/myst.cpp | 676 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/myst.h | 2 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/selenitic.cpp | 176 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/selenitic.h | 2 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/stoneship.cpp | 10 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/stoneship.h | 2 |
19 files changed, 624 insertions, 736 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 0a4f127138..5ce47848d1 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -87,7 +87,7 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription _console = NULL; _scriptParser = NULL; _varStore = NULL; - _saveLoad = NULL; + _gameState = NULL; _loadDialog = NULL; _optionsDialog = NULL; @@ -116,7 +116,7 @@ MohawkEngine_Myst::~MohawkEngine_Myst() { delete _console; delete _scriptParser; delete _varStore; - delete _saveLoad; + delete _gameState; delete _loadDialog; delete _optionsDialog; delete _prevStack; @@ -255,7 +255,7 @@ Common::Error MohawkEngine_Myst::run() { _gfx = new MystGraphics(this); _console = new MystConsole(this); _varStore = new MystVar(this); - _saveLoad = new MystSaveLoad(this, _saveFileMan); + _gameState = new MystGameState(this, _saveFileMan); _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load")); _loadDialog->setSaveMode(false); _optionsDialog = new MystOptionsDialog(this); @@ -266,10 +266,10 @@ Common::Error MohawkEngine_Myst::run() { // Load game from launcher/command line if requested if (ConfMan.hasKey("save_slot") && canLoadGameStateCurrently()) { uint32 gameToLoad = ConfMan.getInt("save_slot"); - Common::StringArray savedGamesList = _saveLoad->generateSaveGameList(); + Common::StringArray savedGamesList = _gameState->generateSaveGameList(); if (gameToLoad > savedGamesList.size()) error ("Could not find saved game"); - _saveLoad->loadGame(savedGamesList[gameToLoad]); + _gameState->load(savedGamesList[gameToLoad]); } else { // Start us on the first stack. if (getGameType() == GType_MAKINGOF) @@ -390,7 +390,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack) { switch (_curStack) { case kChannelwoodStack: - _saveLoad->_v->globals.currentAge = 4; + _gameState->_globals.currentAge = 4; _scriptParser = new MystScriptParser_Channelwood(this); break; case kCreditsStack: @@ -400,7 +400,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack) { _scriptParser = new MystScriptParser_Demo(this); break; case kDniStack: - _saveLoad->_v->globals.currentAge = 6; + _gameState->_globals.currentAge = 6; _scriptParser = new MystScriptParser_Dni(this); break; case kIntroStack: @@ -410,25 +410,25 @@ void MohawkEngine_Myst::changeToStack(uint16 stack) { _scriptParser = new MystScriptParser_MakingOf(this); break; case kMechanicalStack: - _saveLoad->_v->globals.currentAge = 3; + _gameState->_globals.currentAge = 3; _scriptParser = new MystScriptParser_Mechanical(this); break; case kMystStack: - _saveLoad->_v->globals.currentAge = 2; + _gameState->_globals.currentAge = 2; _scriptParser = new MystScriptParser_Myst(this); break; case kDemoPreviewStack: _scriptParser = new MystScriptParser_Preview(this); break; case kSeleniticStack: - _saveLoad->_v->globals.currentAge = 0; + _gameState->_globals.currentAge = 0; _scriptParser = new MystScriptParser_Selenitic(this); break; case kDemoSlidesStack: _scriptParser = new MystScriptParser_Slides(this); break; case kStoneshipStack: - _saveLoad->_v->globals.currentAge = 1; + _gameState->_globals.currentAge = 1; _scriptParser = new MystScriptParser_Stoneship(this); break; default: @@ -1069,19 +1069,19 @@ void MohawkEngine_Myst::runLoadDialog() { } Common::Error MohawkEngine_Myst::loadGameState(int slot) { - if (_saveLoad->loadGame(_saveLoad->generateSaveGameList()[slot])) + if (_gameState->load(_gameState->generateSaveGameList()[slot])) return Common::kNoError; return Common::kUnknownError; } Common::Error MohawkEngine_Myst::saveGameState(int slot, const char *desc) { - Common::StringArray saveList = _saveLoad->generateSaveGameList(); + Common::StringArray saveList = _gameState->generateSaveGameList(); if ((uint)slot < saveList.size()) - _saveLoad->deleteSave(saveList[slot]); + _gameState->deleteSave(saveList[slot]); - return _saveLoad->saveGame(Common::String(desc)) ? Common::kNoError : Common::kUnknownError; + return _gameState->save(Common::String(desc)) ? Common::kNoError : Common::kUnknownError; } bool MohawkEngine_Myst::canLoadGameStateCurrently() { diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index fb42938ec3..d7a6528f68 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -43,7 +43,7 @@ class VideoManager; class MystGraphics; class MystScriptParser; class MystConsole; -class MystSaveLoad; +class MystGameState; class MystOptionsDialog; class MystResource; class MystResourceType8; @@ -172,7 +172,7 @@ public: MystView _view; MystGraphics *_gfx; - MystSaveLoad *_saveLoad; + MystGameState *_gameState; MystScriptParser *_scriptParser; Common::Array<MystResource*> _resources; MystResource *_dragResource; diff --git a/engines/mohawk/myst_saveload.cpp b/engines/mohawk/myst_saveload.cpp index b99d020449..6496693592 100644 --- a/engines/mohawk/myst_saveload.cpp +++ b/engines/mohawk/myst_saveload.cpp @@ -32,39 +32,45 @@ namespace Mohawk { -MystSaveLoad::MystSaveLoad(MohawkEngine_Myst *vm, Common::SaveFileManager *saveFileMan) : _vm(vm), _saveFileMan(saveFileMan) { - _v = new MystVariables(); - +MystGameState::MystGameState(MohawkEngine_Myst *vm, Common::SaveFileManager *saveFileMan) : _vm(vm), _saveFileMan(saveFileMan) { // Most of the variables are zero at game start. - _v->globals.u0 = 2; + memset(&_globals, 0, sizeof(_globals)); + memset(&_myst, 0, sizeof(_myst)); + memset(&_channelwood, 0, sizeof(_channelwood)); + memset(&_mechanical, 0, sizeof(_mechanical)); + memset(&_selenitic, 0, sizeof(_selenitic)); + memset(&_stoneship, 0, sizeof(_stoneship)); + memset(&_dni, 0, sizeof(_dni)); + + // Unknown + _globals.u0 = 2; // Current Age / Stack - Start in Myst - _v->globals.currentAge = 7; - _v->globals.u1 = 1; + _globals.currentAge = 7; + _globals.u1 = 1; // Library Bookcase Door - Default to Up - _v->myst.libraryBookcaseDoor = 1; + _myst.libraryBookcaseDoor = 1; // Dock Imager Numeric Selection - Default to 67 - _v->myst.imagerSelection = 67; + _myst.imagerSelection = 67; // Dock Imager Active - Default to Active - _v->myst.imagerActive = 1; + _myst.imagerActive = 1; // Stellar Observatory Lights - Default to On - _v->myst.observatoryLights = 1; + _myst.observatoryLights = 1; // Lighthouse Trapdoor State - Default to Locked - _v->stoneship.trapdoorState = 2; + _stoneship.trapdoorState = 2; // Lighthouse Chest Water State - Default to Full - _v->stoneship.chestWaterState = 1; + _stoneship.chestWaterState = 1; } -MystSaveLoad::~MystSaveLoad() { - delete _v; +MystGameState::~MystGameState() { } -Common::StringArray MystSaveLoad::generateSaveGameList() { +Common::StringArray MystGameState::generateSaveGameList() { return _saveFileMan->listSavefiles("*.mys"); } -bool MystSaveLoad::loadGame(const Common::String &filename) { +bool MystGameState::load(const Common::String &filename) { Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filename); if (!loadFile) return false; @@ -88,13 +94,13 @@ bool MystSaveLoad::loadGame(const Common::String &filename) { _vm->changeToStack(kIntroStack); // Set our default cursor - if (_v->globals.heldPage == 0 || _v->globals.heldPage > 13) + if (_globals.heldPage == 0 || _globals.heldPage > 13) _vm->setMainCursor(kDefaultMystCursor); - else if (_v->globals.heldPage < 7) + else if (_globals.heldPage < 7) _vm->setMainCursor(kBluePageCursor); - else if (_v->globals.heldPage < 13) + else if (_globals.heldPage < 13) _vm->setMainCursor(kRedPageCursor); - else // if (_v->globals.heldPage == 13) + else // if (globals.heldPage == 13) _vm->setMainCursor(kWhitePageCursor); // Set us to the linking book @@ -103,7 +109,7 @@ bool MystSaveLoad::loadGame(const Common::String &filename) { return true; } -bool MystSaveLoad::saveGame(const Common::String &fname) { +bool MystGameState::save(const Common::String &fname) { Common::String filename(fname); // Make sure we have the right extension if (!filename.hasSuffix(".mys") && !filename.hasSuffix(".MYS")) @@ -123,95 +129,95 @@ bool MystSaveLoad::saveGame(const Common::String &fname) { return true; } -void MystSaveLoad::syncGameState(Common::Serializer &s, bool isME) { +void MystGameState::syncGameState(Common::Serializer &s, bool isME) { // Globals first - s.syncAsUint16LE(_v->globals.u0); - s.syncAsUint16LE(_v->globals.currentAge); - s.syncAsUint16LE(_v->globals.heldPage); - s.syncAsUint16LE(_v->globals.u1); - s.syncAsUint16LE(_v->globals.transitions); - s.syncAsUint16LE(_v->globals.ending); - s.syncAsUint16LE(_v->globals.redPagesInBook); - s.syncAsUint16LE(_v->globals.bluePagesInBook); + s.syncAsUint16LE(_globals.u0); + s.syncAsUint16LE(_globals.currentAge); + s.syncAsUint16LE(_globals.heldPage); + s.syncAsUint16LE(_globals.u1); + s.syncAsUint16LE(_globals.transitions); + s.syncAsUint16LE(_globals.ending); + s.syncAsUint16LE(_globals.redPagesInBook); + s.syncAsUint16LE(_globals.bluePagesInBook); // Onto Myst if (isME) { - s.syncAsUint32LE(_v->myst.cabinMarkerSwitch); - s.syncAsUint32LE(_v->myst.clockTowerMarkerSwitch); - s.syncAsUint32LE(_v->myst.dockMarkerSwitch); - s.syncAsUint32LE(_v->myst.poolMarkerSwitch); - s.syncAsUint32LE(_v->myst.gearsMarkerSwitch); - s.syncAsUint32LE(_v->myst.generatorMarkerSwitch); - s.syncAsUint32LE(_v->myst.observatoryMarkerSwitch); - s.syncAsUint32LE(_v->myst.rocketshipMarkerSwitch); + s.syncAsUint32LE(_myst.cabinMarkerSwitch); + s.syncAsUint32LE(_myst.clockTowerMarkerSwitch); + s.syncAsUint32LE(_myst.dockMarkerSwitch); + s.syncAsUint32LE(_myst.poolMarkerSwitch); + s.syncAsUint32LE(_myst.gearsMarkerSwitch); + s.syncAsUint32LE(_myst.generatorMarkerSwitch); + s.syncAsUint32LE(_myst.observatoryMarkerSwitch); + s.syncAsUint32LE(_myst.rocketshipMarkerSwitch); } else { - s.syncAsByte(_v->myst.cabinMarkerSwitch); - s.syncAsByte(_v->myst.clockTowerMarkerSwitch); - s.syncAsByte(_v->myst.dockMarkerSwitch); - s.syncAsByte(_v->myst.poolMarkerSwitch); - s.syncAsByte(_v->myst.gearsMarkerSwitch); - s.syncAsByte(_v->myst.generatorMarkerSwitch); - s.syncAsByte(_v->myst.observatoryMarkerSwitch); - s.syncAsByte(_v->myst.rocketshipMarkerSwitch); + s.syncAsByte(_myst.cabinMarkerSwitch); + s.syncAsByte(_myst.clockTowerMarkerSwitch); + s.syncAsByte(_myst.dockMarkerSwitch); + s.syncAsByte(_myst.poolMarkerSwitch); + s.syncAsByte(_myst.gearsMarkerSwitch); + s.syncAsByte(_myst.generatorMarkerSwitch); + s.syncAsByte(_myst.observatoryMarkerSwitch); + s.syncAsByte(_myst.rocketshipMarkerSwitch); } - s.syncAsUint16LE(_v->myst.greenBookOpenedBefore); - s.syncAsUint16LE(_v->myst.shipFloating); - s.syncAsUint16LE(_v->myst.cabinValvePosition); - s.syncAsUint16LE(_v->myst.clockTowerHourPosition); - s.syncAsUint16LE(_v->myst.clockTowerMinutePosition); - s.syncAsUint16LE(_v->myst.gearsOpen); - s.syncAsUint16LE(_v->myst.clockTowerBridgeOpen); - s.syncAsUint16LE(_v->myst.generatorBreakers); - s.syncAsUint16LE(_v->myst.generatorButtons); - s.syncAsUint16LE(_v->myst.generatorVoltage); - s.syncAsUint16LE(_v->myst.libraryBookcaseDoor); - s.syncAsUint16LE(_v->myst.imagerSelection); - s.syncAsUint16LE(_v->myst.imagerActive); - s.syncAsUint16LE(_v->myst.imagerWaterErased); - s.syncAsUint16LE(_v->myst.imagerMountainErased); - s.syncAsUint16LE(_v->myst.imagerAtrusErased); - s.syncAsUint16LE(_v->myst.imagerMarkerErased); - s.syncAsUint16LE(_v->myst.towerRotationAngle); - s.syncAsUint16LE(_v->myst.courtyardImageBoxes); - s.syncAsUint16LE(_v->myst.cabinPilotLightLit); - s.syncAsUint16LE(_v->myst.observatoryDaySetting); - s.syncAsUint16LE(_v->myst.observatoryLights); - s.syncAsUint16LE(_v->myst.observatoryMonthSetting); - s.syncAsUint16LE(_v->myst.observatoryTimeSetting); - s.syncAsUint16LE(_v->myst.observatoryYearSetting); - s.syncAsUint16LE(_v->myst.observatoryDayTarget); - s.syncAsUint16LE(_v->myst.observatoryMonthTarget); - s.syncAsUint16LE(_v->myst.observatoryTimeTarget); - s.syncAsUint16LE(_v->myst.observatoryYearTarget); - s.syncAsUint16LE(_v->myst.cabinSafeCombination); - s.syncAsUint16LE(_v->myst.treePosition); - s.syncAsUint32LE(_v->myst.treeLastMoveTime); + s.syncAsUint16LE(_myst.greenBookOpenedBefore); + s.syncAsUint16LE(_myst.shipFloating); + s.syncAsUint16LE(_myst.cabinValvePosition); + s.syncAsUint16LE(_myst.clockTowerHourPosition); + s.syncAsUint16LE(_myst.clockTowerMinutePosition); + s.syncAsUint16LE(_myst.gearsOpen); + s.syncAsUint16LE(_myst.clockTowerBridgeOpen); + s.syncAsUint16LE(_myst.generatorBreakers); + s.syncAsUint16LE(_myst.generatorButtons); + s.syncAsUint16LE(_myst.generatorVoltage); + s.syncAsUint16LE(_myst.libraryBookcaseDoor); + s.syncAsUint16LE(_myst.imagerSelection); + s.syncAsUint16LE(_myst.imagerActive); + s.syncAsUint16LE(_myst.imagerWaterErased); + s.syncAsUint16LE(_myst.imagerMountainErased); + s.syncAsUint16LE(_myst.imagerAtrusErased); + s.syncAsUint16LE(_myst.imagerMarkerErased); + s.syncAsUint16LE(_myst.towerRotationAngle); + s.syncAsUint16LE(_myst.courtyardImageBoxes); + s.syncAsUint16LE(_myst.cabinPilotLightLit); + s.syncAsUint16LE(_myst.observatoryDaySetting); + s.syncAsUint16LE(_myst.observatoryLights); + s.syncAsUint16LE(_myst.observatoryMonthSetting); + s.syncAsUint16LE(_myst.observatoryTimeSetting); + s.syncAsUint16LE(_myst.observatoryYearSetting); + s.syncAsUint16LE(_myst.observatoryDayTarget); + s.syncAsUint16LE(_myst.observatoryMonthTarget); + s.syncAsUint16LE(_myst.observatoryTimeTarget); + s.syncAsUint16LE(_myst.observatoryYearTarget); + s.syncAsUint16LE(_myst.cabinSafeCombination); + s.syncAsUint16LE(_myst.treePosition); + s.syncAsUint32LE(_myst.treeLastMoveTime); for (int i = 0; i < 5; i++) - s.syncAsUint16LE(_v->myst.rocketSliderPosition[i]); + s.syncAsUint16LE(_myst.rocketSliderPosition[i]); - s.syncAsUint16LE(_v->myst.u6); - s.syncAsUint16LE(_v->myst.u7); - s.syncAsUint16LE(_v->myst.u8); - s.syncAsUint16LE(_v->myst.u9); + s.syncAsUint16LE(_myst.u6); + s.syncAsUint16LE(_myst.u7); + s.syncAsUint16LE(_myst.u8); + s.syncAsUint16LE(_myst.u9); // Channelwood if (isME) { - s.syncAsUint32LE(_v->channelwood.waterPumpBridgeState); - s.syncAsUint32LE(_v->channelwood.elevatorState); - s.syncAsUint32LE(_v->channelwood.stairsLowerDoorState); - s.syncAsUint32LE(_v->channelwood.pipeState); + s.syncAsUint32LE(_channelwood.waterPumpBridgeState); + s.syncAsUint32LE(_channelwood.elevatorState); + s.syncAsUint32LE(_channelwood.stairsLowerDoorState); + s.syncAsUint32LE(_channelwood.pipeState); } else { - s.syncAsByte(_v->channelwood.waterPumpBridgeState); - s.syncAsByte(_v->channelwood.elevatorState); - s.syncAsByte(_v->channelwood.stairsLowerDoorState); - s.syncAsByte(_v->channelwood.pipeState); + s.syncAsByte(_channelwood.waterPumpBridgeState); + s.syncAsByte(_channelwood.elevatorState); + s.syncAsByte(_channelwood.stairsLowerDoorState); + s.syncAsByte(_channelwood.pipeState); } - s.syncAsUint16LE(_v->channelwood.waterValveStates); - s.syncAsUint16LE(_v->channelwood.holoprojectorSelection); - s.syncAsUint16LE(_v->channelwood.stairsUpperDoorState); + s.syncAsUint16LE(_channelwood.waterValveStates); + s.syncAsUint16LE(_channelwood.holoprojectorSelection); + s.syncAsUint16LE(_channelwood.stairsUpperDoorState); if (isME) s.skip(4); @@ -220,93 +226,93 @@ void MystSaveLoad::syncGameState(Common::Serializer &s, bool isME) { // Mechanical - s.syncAsUint16LE(_v->mechanical.achenarPanelState); - s.syncAsUint16LE(_v->mechanical.sirrusPanelState); - s.syncAsUint16LE(_v->mechanical.staircaseState); - s.syncAsUint16LE(_v->mechanical.elevatorRotation); + s.syncAsUint16LE(_mechanical.achenarPanelState); + s.syncAsUint16LE(_mechanical.sirrusPanelState); + s.syncAsUint16LE(_mechanical.staircaseState); + s.syncAsUint16LE(_mechanical.elevatorRotation); for (int i = 0; i < 4; i++) - s.syncAsUint16LE(_v->mechanical.codeShape[i]); + s.syncAsUint16LE(_mechanical.codeShape[i]); // Selenitic if (isME) { - s.syncAsUint32LE(_v->selenitic.emitterEnabledWater); - s.syncAsUint32LE(_v->selenitic.emitterEnabledVolcano); - s.syncAsUint32LE(_v->selenitic.emitterEnabledClock); - s.syncAsUint32LE(_v->selenitic.emitterEnabledCrystal); - s.syncAsUint32LE(_v->selenitic.emitterEnabledWind); - s.syncAsUint32LE(_v->selenitic.soundReceiverOpened); - s.syncAsUint32LE(_v->selenitic.tunnelLightsSwitchedOn); + s.syncAsUint32LE(_selenitic.emitterEnabledWater); + s.syncAsUint32LE(_selenitic.emitterEnabledVolcano); + s.syncAsUint32LE(_selenitic.emitterEnabledClock); + s.syncAsUint32LE(_selenitic.emitterEnabledCrystal); + s.syncAsUint32LE(_selenitic.emitterEnabledWind); + s.syncAsUint32LE(_selenitic.soundReceiverOpened); + s.syncAsUint32LE(_selenitic.tunnelLightsSwitchedOn); } else { - s.syncAsByte(_v->selenitic.emitterEnabledWater); - s.syncAsByte(_v->selenitic.emitterEnabledVolcano); - s.syncAsByte(_v->selenitic.emitterEnabledClock); - s.syncAsByte(_v->selenitic.emitterEnabledCrystal); - s.syncAsByte(_v->selenitic.emitterEnabledWind); - s.syncAsByte(_v->selenitic.soundReceiverOpened); - s.syncAsByte(_v->selenitic.tunnelLightsSwitchedOn); + s.syncAsByte(_selenitic.emitterEnabledWater); + s.syncAsByte(_selenitic.emitterEnabledVolcano); + s.syncAsByte(_selenitic.emitterEnabledClock); + s.syncAsByte(_selenitic.emitterEnabledCrystal); + s.syncAsByte(_selenitic.emitterEnabledWind); + s.syncAsByte(_selenitic.soundReceiverOpened); + s.syncAsByte(_selenitic.tunnelLightsSwitchedOn); } - s.syncAsUint16LE(_v->selenitic.soundReceiverCurrentSource); + s.syncAsUint16LE(_selenitic.soundReceiverCurrentSource); for (byte i = 0; i < 5; i++) - s.syncAsUint16LE(_v->selenitic.soundReceiverPositions[i]); + s.syncAsUint16LE(_selenitic.soundReceiverPositions[i]); for (byte i = 0; i < 5; i++) - s.syncAsUint16LE(_v->selenitic.soundLockSliderPositions[i]); + s.syncAsUint16LE(_selenitic.soundLockSliderPositions[i]); // Stoneship if (isME) { - s.syncAsUint16LE(_v->stoneship.lightState); - s.syncAsUint16LE(_v->stoneship.u0); - s.syncAsUint16LE(_v->stoneship.u1); + s.syncAsUint16LE(_stoneship.lightState); + s.syncAsUint16LE(_stoneship.u0); + s.syncAsUint16LE(_stoneship.u1); } else { - s.syncAsByte(_v->stoneship.lightState); - s.syncAsByte(_v->stoneship.u0); - s.syncAsByte(_v->stoneship.u1); + s.syncAsByte(_stoneship.lightState); + s.syncAsByte(_stoneship.u0); + s.syncAsByte(_stoneship.u1); } - s.syncAsUint16LE(_v->stoneship.pumpState); - s.syncAsUint16LE(_v->stoneship.trapdoorState); - s.syncAsUint16LE(_v->stoneship.chestWaterState); - s.syncAsUint16LE(_v->stoneship.chestValveState); - s.syncAsUint16LE(_v->stoneship.chestOpenState); - s.syncAsUint16LE(_v->stoneship.trapdoorKeyState); + s.syncAsUint16LE(_stoneship.pumpState); + s.syncAsUint16LE(_stoneship.trapdoorState); + s.syncAsUint16LE(_stoneship.chestWaterState); + s.syncAsUint16LE(_stoneship.chestValveState); + s.syncAsUint16LE(_stoneship.chestOpenState); + s.syncAsUint16LE(_stoneship.trapdoorKeyState); for (int i = 0; i < 5; i++) - s.syncAsUint16LE(_v->stoneship.generatorPowerLevel[i]); + s.syncAsUint16LE(_stoneship.generatorPowerLevel[i]); // D'ni - s.syncAsUint16LE(_v->dni.outcomeState); + s.syncAsUint16LE(_dni.outcomeState); // Reading unknown region... // When Zero Value regions are included, these are 5 blocks of // 41 uint16 values. for (byte i = 0; i < 31; i++) - s.syncAsUint16LE(_v->unknownMyst[i]); + s.syncAsUint16LE(unknownMyst[i]); s.skip(20); for (byte i = 0; i < 37; i++) - s.syncAsUint16LE(_v->unknownChannelwood[i]); + s.syncAsUint16LE(unknownChannelwood[i]); s.skip(8); for (byte i = 0; i < 18; i++) - s.syncAsUint16LE(_v->unknownMech[i]); + s.syncAsUint16LE(unknownMech[i]); s.skip(46); for (byte i = 0; i < 30; i++) - s.syncAsUint16LE(_v->unknownSelenitic[i]); + s.syncAsUint16LE(unknownSelenitic[i]); s.skip(22); for (byte i = 0; i < 22; i++) - s.syncAsUint16LE(_v->unknownStoneship[i]); + s.syncAsUint16LE(unknownStoneship[i]); s.skip(38); @@ -314,7 +320,7 @@ void MystSaveLoad::syncGameState(Common::Serializer &s, bool isME) { warning("Unexpected File Position 0x%03X At End of Save/Load", s.bytesSynced()); } -void MystSaveLoad::deleteSave(const Common::String &saveName) { +void MystGameState::deleteSave(const Common::String &saveName) { debugC(kDebugSaveLoad, "Deleting save file \'%s\'", saveName.c_str()); _saveFileMan->removeSavefile(saveName.c_str()); } diff --git a/engines/mohawk/myst_saveload.h b/engines/mohawk/myst_saveload.h index b8f0bd739f..0f90d5093c 100644 --- a/engines/mohawk/myst_saveload.h +++ b/engines/mohawk/myst_saveload.h @@ -36,13 +36,17 @@ namespace Common { namespace Mohawk { -// These are left as uint16 currently, rather than -// being changed to bool etc. to save memory. -// This is because the exact structure -// is subject to change and the code to implement -// opcodes to access them is simpler this way.. -struct MystVariables { - MystVariables() { memset(this, 0, sizeof(MystVariables)); } +class MohawkEngine_Myst; + +class MystGameState { +public: + MystGameState(MohawkEngine_Myst*, Common::SaveFileManager*); + ~MystGameState(); + + Common::StringArray generateSaveGameList(); + bool load(const Common::String &); + bool save(const Common::String &); + void deleteSave(const Common::String &); /* 8 Game Global Variables : 0 = Unknown - Fixed at 2 @@ -63,7 +67,7 @@ struct MystVariables { uint16 ending; uint16 redPagesInBook; uint16 bluePagesInBook; - } globals; + } _globals; /* 50 Myst Specific Variables : 0 = Marker Switch Near Cabin @@ -163,7 +167,7 @@ struct MystVariables { uint16 u7; uint16 u8; uint16 u9; - } myst; + } _myst; /* 7 Channelwood Specific Variables : 0 = Water Pump Bridge State @@ -182,7 +186,7 @@ struct MystVariables { uint16 waterValveStates; uint16 holoprojectorSelection; uint16 stairsUpperDoorState; - } channelwood; + } _channelwood; /* 8 Mech Specific Variables : 0 = Achenar's Room Secret Panel State @@ -200,7 +204,7 @@ struct MystVariables { uint16 staircaseState; uint16 elevatorRotation; uint16 codeShape[4]; - } mechanical; + } _mechanical; /* 18 Selenitic Specific Variables : 0 = Sound Pickup At Water Pool @@ -233,14 +237,14 @@ struct MystVariables { uint16 soundReceiverCurrentSource; uint16 soundReceiverPositions[5]; uint16 soundLockSliderPositions[5]; - } selenitic; + } _selenitic; /* 14 Stoneship Specific Variables : 0 = Light State 1 = Unknown #1 2 = Unknown #2 3 = Water Pump State - 4 = Lighthouse Trapdoor State + 4 = Lighthouse Trapdoor St_v->ate 5 = Lighthouse Chest Water State 6 = Lighthouse Chest Valve State 7 = Lighthouse Chest Open State @@ -262,14 +266,14 @@ struct MystVariables { uint16 chestOpenState; uint16 trapdoorKeyState; uint16 generatorPowerLevel[5]; - } stoneship; + } _stoneship; /* 1 Dunny Specific Variable : 0 = Outcome State */ struct Dni { uint16 outcomeState; - } dni; + } _dni; // The values in these regions seem to be lists of resource IDs // which correspond to VIEW resources i.e. cards @@ -282,23 +286,9 @@ struct MystVariables { uint16 unknownSelenitic[30]; uint16 unknownStoneship[22]; -}; - -class MohawkEngine_Myst; - -class MystSaveLoad { -public: - MystSaveLoad(MohawkEngine_Myst*, Common::SaveFileManager*); - ~MystSaveLoad(); - - Common::StringArray generateSaveGameList(); - bool loadGame(const Common::String &); - bool saveGame(const Common::String &); - void deleteSave(const Common::String &); +private: void syncGameState(Common::Serializer &s, bool isME); - MystVariables *_v; -private: MohawkEngine_Myst *_vm; Common::SaveFileManager *_saveFileMan; }; diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp index bf1aadcea0..f463014e61 100644 --- a/engines/mohawk/myst_scripts.cpp +++ b/engines/mohawk/myst_scripts.cpp @@ -27,7 +27,6 @@ #include "mohawk/myst.h" #include "mohawk/graphics.h" #include "mohawk/myst_areas.h" -#include "mohawk/myst_saveload.h" #include "mohawk/myst_scripts.h" #include "mohawk/sound.h" #include "mohawk/video.h" @@ -79,7 +78,9 @@ const uint16 MystScriptParser::_startCard[11] = { // NOTE: Credits Start Card is 10000 -MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) : _vm(vm) { +MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) : + _vm(vm), + _globals(vm->_gameState->_globals) { setupCommonOpcodes(); _invokingResource = NULL; _savedCardId = 0; @@ -225,13 +226,11 @@ MystScript MystScriptParser::readScript(Common::SeekableReadStream *stream, Myst } uint16 MystScriptParser::getVar(uint16 var) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - switch(var) { case 105: return _tempVar; case 106: - return globals.ending; + return _globals.ending; default: warning("Unimplemented var getter 0x%02x (%d)", var, var); return _vm->_varStore->getVar(var); @@ -333,22 +332,20 @@ void MystScriptParser::o_changeCardSwitch(uint16 op, uint16 var, uint16 argc, ui } void MystScriptParser::o_takePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - uint16 cursorId = argv[0]; - uint16 oldPage = globals.heldPage; + uint16 oldPage = _globals.heldPage; debugC(kDebugScript, "Opcode %d: takePage Var %d CursorId %d", op, var, cursorId); // Take / drop page toggleVar(var); - if (oldPage != globals.heldPage) { + if (oldPage != _globals.heldPage) { _vm->_cursor->hideCursor(); _vm->redrawArea(var); // Set new cursor - if (globals.heldPage) + if (_globals.heldPage) _vm->setMainCursor(cursorId); else _vm->setMainCursor(kDefaultMystCursor); diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h index f16c4fcbd9..96e10293ef 100644 --- a/engines/mohawk/myst_scripts.h +++ b/engines/mohawk/myst_scripts.h @@ -30,6 +30,8 @@ #include "common/scummsys.h" #include "common/util.h" +#include "mohawk/myst_saveload.h" + namespace Mohawk { #define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) @@ -124,6 +126,7 @@ public: protected: MohawkEngine_Myst *_vm; + MystGameState::Globals &_globals; typedef void (MystScriptParser::*OpcodeProcMyst)(uint16 op, uint16 var, uint16 argc, uint16* argv); diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp index a43353c441..fff6664cd7 100644 --- a/engines/mohawk/myst_stacks/channelwood.cpp +++ b/engines/mohawk/myst_stacks/channelwood.cpp @@ -35,7 +35,8 @@ namespace Mohawk { -MystScriptParser_Channelwood::MystScriptParser_Channelwood(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +MystScriptParser_Channelwood::MystScriptParser_Channelwood(MohawkEngine_Myst *vm) : + MystScriptParser(vm), _state(vm->_gameState->_channelwood) { setupOpcodes(); } @@ -78,74 +79,71 @@ void MystScriptParser_Channelwood::runPersistentScripts() { } uint16 MystScriptParser_Channelwood::getVar(uint16 var) { -// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Channelwood &channelwood = _vm->_saveLoad->_v->channelwood; - switch(var) { case 1: // Water Pump Bridge Raised - return channelwood.waterPumpBridgeState; + return _state.waterPumpBridgeState; case 2: // Lower Walkway to Upper Walkway Elevator Raised - return channelwood.elevatorState; + return _state.elevatorState; case 3: // Water Flowing To Lower Walkway To Upper Walkway Elevator - return (channelwood.waterValveStates & 0xc0) ? 1 : 0; + return (_state.waterValveStates & 0xc0) ? 1 : 0; case 4: // Water Flowing To Book Room Elevator - return ((channelwood.waterValveStates & 0xf8) == 0xb0 && channelwood.pipeState) ? 1 : 0; + return ((_state.waterValveStates & 0xf8) == 0xb0 && _state.pipeState) ? 1 : 0; case 5: // Lower Walkway to Upper Walkway Spiral Stair Lower Door State - return channelwood.stairsLowerDoorState; + return _state.stairsLowerDoorState; case 6: // Pipe Bridge Extended - return channelwood.pipeState; + return _state.pipeState; case 7: // Water Flowing To Water Pump For Bridge - return ((channelwood.waterValveStates & 0xe2) == 0xc2 || (channelwood.waterValveStates & 0xf4) == 0xa0) ? 1 : 0; + return ((_state.waterValveStates & 0xe2) == 0xc2 || (_state.waterValveStates & 0xf4) == 0xa0) ? 1 : 0; case 8: // Water Tank Valve - return (channelwood.waterValveStates & 0x80) ? 1 : 0; + return (_state.waterValveStates & 0x80) ? 1 : 0; case 9: // State of First Water Valve - return (channelwood.waterValveStates & 0x40) ? 1 : 0; + return (_state.waterValveStates & 0x40) ? 1 : 0; case 10: // State of Second Water Valve - return (channelwood.waterValveStates & 0x20) ? 1 : 0; + return (_state.waterValveStates & 0x20) ? 1 : 0; case 11: // State of Right Third Water Valve - return (channelwood.waterValveStates & 0x10) ? 1 : 0; + return (_state.waterValveStates & 0x10) ? 1 : 0; case 12: // State of Right-Right Fourth Water Valve - return (channelwood.waterValveStates & 0x08) ? 1 : 0; + return (_state.waterValveStates & 0x08) ? 1 : 0; case 13: // State of Right-Left Fourth Water Valve - return (channelwood.waterValveStates & 0x04) ? 1 : 0; + return (_state.waterValveStates & 0x04) ? 1 : 0; case 14: // State of Left Third Water Valve - return (channelwood.waterValveStates & 0x02) ? 1 : 0; + return (_state.waterValveStates & 0x02) ? 1 : 0; case 15: // Water Flowing To Lower Walkway To Upper Walkway Elevator - return ((channelwood.waterValveStates & 0xf8) == 0xb8) ? 1 : 0; + return ((_state.waterValveStates & 0xf8) == 0xb8) ? 1 : 0; case 16: // Channelwood Lower Walkway to Upper Walkway Spiral Stair Upper Door State - return channelwood.stairsUpperDoorState; + return _state.stairsUpperDoorState; case 17: // Achenar's Holoprojector Selection - return channelwood.holoprojectorSelection; + return _state.holoprojectorSelection; // case 18: // Sirrus's Room Bed Drawer Open // return 0; // return 1; case 19: // Sound - Water Tank Valve - return (channelwood.waterValveStates & 0x80) ? 1 : 0; + return (_state.waterValveStates & 0x80) ? 1 : 0; case 20: // Sound - First Water Valve Water Flowing To Left - return ((channelwood.waterValveStates & 0xc0) == 0x80) ? 1 : 0; + return ((_state.waterValveStates & 0xc0) == 0x80) ? 1 : 0; case 21: // Sound - Second Water Valve Water Flowing To Right - return ((channelwood.waterValveStates & 0xe0) == 0xa0) ? 1 : 0; + return ((_state.waterValveStates & 0xe0) == 0xa0) ? 1 : 0; case 22: // Sound - Right Third Water Valve Water Flowing To Right - return ((channelwood.waterValveStates & 0xf0) == 0xb0) ? 1 : 0; + return ((_state.waterValveStates & 0xf0) == 0xb0) ? 1 : 0; case 23: // Sound - Right Third Water Valve Water Flowing To Left - return ((channelwood.waterValveStates & 0xf0) == 0xa0) ? 1 : 0; + return ((_state.waterValveStates & 0xf0) == 0xa0) ? 1 : 0; case 24: // Sound - Second Water Valve Water Flowing To Left - return ((channelwood.waterValveStates & 0xe0) == 0xc0) ? 1 : 0; + return ((_state.waterValveStates & 0xe0) == 0xc0) ? 1 : 0; case 25: // Sound - Right-Right Fourth Valve Water Flowing To Left (To Pipe Bridge) - return ((channelwood.waterValveStates & 0xf8) == 0xb0) ? 1 : 0; + return ((_state.waterValveStates & 0xf8) == 0xb0) ? 1 : 0; case 26: // Sound - Right-Left Fourth Valve Water Flowing To Right (To Pipe Down Tree) - return ((channelwood.waterValveStates & 0xf4) == 0xa4) ? 1 : 0; + return ((_state.waterValveStates & 0xf4) == 0xa4) ? 1 : 0; case 27: // Sound - Right-Left Fourth Valve Water Flowing To Left (To Pipe Fork) - return ((channelwood.waterValveStates & 0xf4) == 0xa0) ? 1 : 0; + return ((_state.waterValveStates & 0xf4) == 0xa0) ? 1 : 0; case 28: // Sound - Left Third Water Valve Flowing To Right (To Pipe Fork) - return ((channelwood.waterValveStates & 0xe2) == 0xc2) ? 1 : 0; + return ((_state.waterValveStates & 0xe2) == 0xc2) ? 1 : 0; case 29: // Sound - Left Third Water Valve Flowing To Left (To Pipe In Water) - return ((channelwood.waterValveStates & 0xe2) == 0xc0) ? 1 : 0; + return ((_state.waterValveStates & 0xe2) == 0xc0) ? 1 : 0; // case 30: // Temple Door State // return 0; // return 1; case 32: // Sound - Water Flowing in Pipe to Book Room Elevator - return ((channelwood.waterValveStates & 0xf8) == 0xb0 && channelwood.pipeState) ? 1 : 0; + return ((_state.waterValveStates & 0xf8) == 0xb0 && _state.pipeState) ? 1 : 0; // case 102: // Sirrus's Desk Drawer / Red Page State // return 0; // Drawer Closed // return 1; // Drawer Open, Red Page Taken @@ -159,12 +157,9 @@ uint16 MystScriptParser_Channelwood::getVar(uint16 var) { } void MystScriptParser_Channelwood::toggleVar(uint16 var) { -// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Channelwood &channelwood = _vm->_saveLoad->_v->channelwood; - switch(var) { case 6: // Pipe Bridge Extended - channelwood.pipeState ^= 1; + _state.pipeState ^= 1; default: MystScriptParser::toggleVar(var); break; @@ -172,7 +167,6 @@ void MystScriptParser_Channelwood::toggleVar(uint16 var) { } bool MystScriptParser_Channelwood::setVarValue(uint16 var, uint16 value) { -// MystVariables::Channelwood &channelwood = _vm->_saveLoad->_v->channelwood; bool refresh = false; switch (var) { diff --git a/engines/mohawk/myst_stacks/channelwood.h b/engines/mohawk/myst_stacks/channelwood.h index 2c88f72442..cf1da35baf 100644 --- a/engines/mohawk/myst_stacks/channelwood.h +++ b/engines/mohawk/myst_stacks/channelwood.h @@ -71,6 +71,8 @@ private: DECLARE_OPCODE(opcode_203); DECLARE_OPCODE(opcode_300); + + MystGameState::Channelwood &_state; }; } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp index 9eaf8b1bb3..e14ecc4b90 100644 --- a/engines/mohawk/myst_stacks/dni.cpp +++ b/engines/mohawk/myst_stacks/dni.cpp @@ -34,7 +34,8 @@ namespace Mohawk { -MystScriptParser_Dni::MystScriptParser_Dni(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +MystScriptParser_Dni::MystScriptParser_Dni(MohawkEngine_Myst *vm) : + MystScriptParser(vm), _state(_vm->_gameState->_dni) { setupOpcodes(); } @@ -64,9 +65,6 @@ void MystScriptParser_Dni::runPersistentScripts() { } uint16 MystScriptParser_Dni::getVar(uint16 var) { -// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; -// MystVariables::Dni &dni = _vm->_saveLoad->_v->dni; - switch(var) { // case 0: // Atrus Gone (from across room) // return 0; // Present diff --git a/engines/mohawk/myst_stacks/dni.h b/engines/mohawk/myst_stacks/dni.h index a3ddedd70d..f376fb2025 100644 --- a/engines/mohawk/myst_stacks/dni.h +++ b/engines/mohawk/myst_stacks/dni.h @@ -55,6 +55,8 @@ private: DECLARE_OPCODE(opcode_200); DECLARE_OPCODE(opcode_300); + + MystGameState::Dni &_state; }; } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp index 875eb6fce1..318edf57e9 100644 --- a/engines/mohawk/myst_stacks/intro.cpp +++ b/engines/mohawk/myst_stacks/intro.cpp @@ -67,7 +67,7 @@ void MystScriptParser_Intro::runPersistentScripts() { uint16 MystScriptParser_Intro::getVar(uint16 var) { switch(var) { case 0: - return _vm->_saveLoad->_v->globals.currentAge; + return _vm->_gameState->_globals.currentAge; default: return MystScriptParser::getVar(var); } diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp index e1933fbc28..714ec199f5 100644 --- a/engines/mohawk/myst_stacks/mechanical.cpp +++ b/engines/mohawk/myst_stacks/mechanical.cpp @@ -35,7 +35,8 @@ namespace Mohawk { -MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm) : + MystScriptParser(vm), _state(vm->_gameState->_mechanical) { setupOpcodes(); } @@ -100,14 +101,11 @@ void MystScriptParser_Mechanical::runPersistentScripts() { } uint16 MystScriptParser_Mechanical::getVar(uint16 var) { -// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Mechanical &mechanical = _vm->_saveLoad->_v->mechanical; - switch(var) { case 0: // Sirrus's Secret Panel State - return mechanical.sirrusPanelState; + return _state.sirrusPanelState; case 1: // Achenar's Secret Panel State - return mechanical.achenarPanelState; + return _state.achenarPanelState; // case 3: // Sirrus's Secret Room Crate State // return 0; // return 1; @@ -123,14 +121,14 @@ uint16 MystScriptParser_Mechanical::getVar(uint16 var) { // return 0; // return 1; case 7: // Fortress Elevator Open - if (mechanical.elevatorRotation == 4) + if (_state.elevatorRotation == 4) return 1; // Open else return 0; // Closed case 10: // Fortress Staircase State - return mechanical.staircaseState; + return _state.staircaseState; case 11: // Fortress Elevator Rotation Position - return mechanical.elevatorRotation; + return _state.elevatorRotation; // case 12: // Fortress Elevator Rotation Cog Position // return 0; // return 1; @@ -146,7 +144,7 @@ uint16 MystScriptParser_Mechanical::getVar(uint16 var) { case 17: // Code Lock Shape #2 case 18: // Code Lock Shape #3 case 19: // Code Lock Shape #4 - Right - return mechanical.codeShape[var - 16]; + return _state.codeShape[var - 16]; // case 20: // Crystal Lit Flag - Yellow // return 0; // return 1; @@ -170,21 +168,18 @@ uint16 MystScriptParser_Mechanical::getVar(uint16 var) { } void MystScriptParser_Mechanical::toggleVar(uint16 var) { -// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Mechanical &mechanical = _vm->_saveLoad->_v->mechanical; - switch(var) { // case 3: // Sirrus's Secret Room Crate State // temp ^= 1; // case 4: // Code Lock Puzzle Correct / Myst Book Room Staircase State // temp ^= 1; case 10: // Fortress Staircase State - mechanical.staircaseState ^= 1; + _state.staircaseState ^= 1; case 16: // Code Lock Shape #1 - Left case 17: // Code Lock Shape #2 case 18: // Code Lock Shape #3 case 19: // Code Lock Shape #4 - Right - mechanical.codeShape[var - 16] = (mechanical.codeShape[var - 16] + 1) % 10; + _state.codeShape[var - 16] = (_state.codeShape[var - 16] + 1) % 10; break; // case 102: // Red Page Grab/Release // globals.heldPage? @@ -197,7 +192,6 @@ void MystScriptParser_Mechanical::toggleVar(uint16 var) { } bool MystScriptParser_Mechanical::setVarValue(uint16 var, uint16 value) { -// MystVariables::Mechanical &mechanical = _vm->_saveLoad->_v->mechanical; bool refresh = false; switch (var) { diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h index 086986a2b2..6ea1bc6fd7 100644 --- a/engines/mohawk/myst_stacks/mechanical.h +++ b/engines/mohawk/myst_stacks/mechanical.h @@ -93,6 +93,8 @@ private: DECLARE_OPCODE(opcode_209); DECLARE_OPCODE(opcode_300); + + MystGameState::Mechanical &_state; }; } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index a01f98c318..bc77f150e2 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -40,9 +40,8 @@ namespace Mohawk { // NOTE: Credits Start Card is 10000 -MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : MystScriptParser(vm) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - +MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : + MystScriptParser(vm), _state(_vm->_gameState->_myst) { setupOpcodes(); // Card ID preinitialized by the engine for use by opcode 18 @@ -58,7 +57,7 @@ MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : MystScript _treeStopped = false; _treeMinPosition = 0; _imagerValidationStep = 0; - myst.treeLastMoveTime = _vm->_system->getMillis(); + _state.treeLastMoveTime = _vm->_system->getMillis(); } MystScriptParser_Myst::~MystScriptParser_Myst() { @@ -256,49 +255,46 @@ void MystScriptParser_Myst::runPersistentScripts() { } uint16 MystScriptParser_Myst::getVar(uint16 var) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - switch(var) { case 0: // Myst Library Bookcase Closed - return myst.libraryBookcaseDoor; + return _state.libraryBookcaseDoor; case 1: - if (globals.ending != 4) { - return myst.libraryBookcaseDoor != 1; - } else if (myst.libraryBookcaseDoor == 1) { + if (_globals.ending != 4) { + return _state.libraryBookcaseDoor != 1; + } else if (_state.libraryBookcaseDoor == 1) { return 2; } else { return 3; } case 2: // Marker Switch Near Cabin - return myst.cabinMarkerSwitch; + return _state.cabinMarkerSwitch; case 3: // Marker Switch Near Clock Tower - return myst.clockTowerMarkerSwitch; + return _state.clockTowerMarkerSwitch; case 4: // Marker Switch on Dock - return myst.dockMarkerSwitch; + return _state.dockMarkerSwitch; case 5: // Marker Switch Near Ship Pool - return myst.poolMarkerSwitch; + return _state.poolMarkerSwitch; case 6: // Marker Switch Near Cogs - return myst.gearsMarkerSwitch; + return _state.gearsMarkerSwitch; case 7: // Marker Switch Near Generator Room - return myst.generatorMarkerSwitch; + return _state.generatorMarkerSwitch; case 8: // Marker Switch Near Stellar Observatory - return myst.observatoryMarkerSwitch; + return _state.observatoryMarkerSwitch; case 9: // Marker Switch Near Rocket Ship - return myst.rocketshipMarkerSwitch; + return _state.rocketshipMarkerSwitch; case 10: // Ship Floating State - return myst.shipFloating; + return _state.shipFloating; case 11: // Cabin Door Open State return _cabinDoorOpened; case 12: // Clock tower gears bridge - return myst.clockTowerBridgeOpen; + return _state.clockTowerBridgeOpen; case 13: // Tower in right position - return myst.towerRotationAngle == 271 - || myst.towerRotationAngle == 83 - || myst.towerRotationAngle == 129 - || myst.towerRotationAngle == 152; + return _state.towerRotationAngle == 271 + || _state.towerRotationAngle == 83 + || _state.towerRotationAngle == 129 + || _state.towerRotationAngle == 152; case 14: // Tower Solution (Key) Plaque - switch (myst.towerRotationAngle) { + switch (_state.towerRotationAngle) { case 271: return 1; case 83: @@ -311,16 +307,16 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) { return 0; } case 15: // Tower Window (Book) View - switch (myst.towerRotationAngle) { + switch (_state.towerRotationAngle) { case 271: return 1; case 83: - if (myst.gearsOpen) + if (_state.gearsOpen) return 6; else return 2; case 129: - if (myst.shipFloating) + if (_state.shipFloating) return 5; else return 3; @@ -330,10 +326,10 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) { return 0; } case 16: // Tower Window (Book) View From Ladder Top - if (myst.towerRotationAngle != 271 - && myst.towerRotationAngle != 83 - && myst.towerRotationAngle != 129) { - if (myst.towerRotationAngle == 152) + if (_state.towerRotationAngle != 271 + && _state.towerRotationAngle != 83 + && _state.towerRotationAngle != 129) { + if (_state.towerRotationAngle == 152) return 2; else return 0; @@ -349,14 +345,14 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) { && _fireplaceLines[4] == 204 && _fireplaceLines[5] == 250; case 24: // Fireplace Blue Page Present - if (globals.ending != 4) { - return !(globals.bluePagesInBook & 32) && (globals.heldPage != 6); + if (_globals.ending != 4) { + return !(_globals.bluePagesInBook & 32) && (_globals.heldPage != 6); } else { return 0; } case 25: // Fireplace Red Page Present - if (globals.ending != 4) { - return !(globals.redPagesInBook & 32) && (globals.heldPage != 12); + if (_globals.ending != 4) { + return !(_globals.redPagesInBook & 32) && (_globals.heldPage != 12); } else { return 0; } @@ -370,16 +366,16 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) { case 33: // Courtyard Image Box - Ostrich if (!_tempVar) { return 0; - } else if (myst.courtyardImageBoxes & (0x01 << (var - 26))) { + } else if (_state.courtyardImageBoxes & (0x01 << (var - 26))) { return 2; } else { return 1; } case 34: // Sound Control In Dock forechamber - if (myst.imagerActive) { - if (myst.imagerSelection == 40 && !myst.imagerMountainErased) + if (_state.imagerActive) { + if (_state.imagerSelection == 40 && !_state.imagerMountainErased) return 1; - else if (myst.imagerSelection == 67 && !myst.imagerWaterErased) + else if (_state.imagerSelection == 67 && !_state.imagerWaterErased) return 2; else return 0; @@ -387,50 +383,50 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) { return 0; } case 35: // Dock Forechamber Imager Control Left Digit - if (myst.imagerSelection > 9) - return myst.imagerSelection / 10 - 1; + if (_state.imagerSelection > 9) + return _state.imagerSelection / 10 - 1; else return 9; case 36: // Dock Forechamber Imager Control Right Digit - return (10 + myst.imagerSelection - 1) % 10; + return (10 + _state.imagerSelection - 1) % 10; case 37: // Clock Tower Control Wheels Position - return 3 * ((myst.clockTowerMinutePosition / 5) % 3) + myst.clockTowerHourPosition % 3; + return 3 * ((_state.clockTowerMinutePosition / 5) % 3) + _state.clockTowerHourPosition % 3; case 40: // Gears Open State - return myst.gearsOpen; + return _state.gearsOpen; case 41: // Dock Marker Switch Vault State return _dockVaultState; case 43: // Clock Tower Time - return myst.clockTowerHourPosition * 12 + myst.clockTowerMinutePosition / 5; + return _state.clockTowerHourPosition * 12 + _state.clockTowerMinutePosition / 5; case 44: // Rocket ship power state - if (myst.generatorBreakers || myst.generatorVoltage == 0) + if (_state.generatorBreakers || _state.generatorVoltage == 0) return 0; - else if (myst.generatorVoltage != 59) + else if (_state.generatorVoltage != 59) return 1; else return 2; case 45: // Dock Vault Imager Active On Water - return myst.imagerActive && myst.imagerSelection == 67 && !myst.imagerWaterErased; + return _state.imagerActive && _state.imagerSelection == 67 && !_state.imagerWaterErased; case 46: return bookCountPages(100); case 47: return bookCountPages(101); case 48: - if (myst.dockMarkerSwitch && !myst.shipFloating) + if (_state.dockMarkerSwitch && !_state.shipFloating) return 1; - else if (!myst.dockMarkerSwitch && myst.shipFloating) + else if (!_state.dockMarkerSwitch && _state.shipFloating) return 2; else return 0; case 49: // Generator running - return myst.generatorVoltage > 0; + return _state.generatorVoltage > 0; case 51: // Forechamber Imager Movie Control - if (myst.imagerSelection == 40 && !myst.imagerMountainErased) + if (_state.imagerSelection == 40 && !_state.imagerMountainErased) return 1; - else if (myst.imagerSelection == 67 && !myst.imagerWaterErased) + else if (_state.imagerSelection == 67 && !_state.imagerWaterErased) return 2; - else if (myst.imagerSelection == 8 && !myst.imagerAtrusErased) + else if (_state.imagerSelection == 8 && !_state.imagerAtrusErased) return 3; - else if (myst.imagerSelection == 47 && !myst.imagerMarkerErased) + else if (_state.imagerSelection == 47 && !_state.imagerMarkerErased) return 4; else return 0; @@ -444,65 +440,65 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) { case 59: // Generator Switch #8 case 60: // Generator Switch #9 case 61: // Generator Switch #10 - return (myst.generatorButtons & (1 << (var - 52))) != 0; + return (_state.generatorButtons & (1 << (var - 52))) != 0; case 62: // Generator Power Dial Left LED Digit return _generatorVoltage / 10; case 63: // Generator Power Dial Right LED Digit return _generatorVoltage % 10; case 64: // Generator Power To Spaceship Dial Left LED Digit - if (myst.generatorVoltage > 59 || myst.generatorBreakers) + if (_state.generatorVoltage > 59 || _state.generatorBreakers) return 0; else - return myst.generatorVoltage / 10; + return _state.generatorVoltage / 10; case 65: // Generator Power To Spaceship Dial Right LED Digit - if (myst.generatorVoltage > 59 || myst.generatorBreakers) + if (_state.generatorVoltage > 59 || _state.generatorBreakers) return 0; else - return myst.generatorVoltage % 10; + return _state.generatorVoltage % 10; case 66: // Generators lights on return 0; case 67: // Cabin Safe Lock Number #1 - Left - return myst.cabinSafeCombination / 100; + return _state.cabinSafeCombination / 100; case 68: // Cabin Safe Lock Number #2 - return (myst.cabinSafeCombination / 10) % 10; + return (_state.cabinSafeCombination / 10) % 10; case 69: // Cabin Safe Lock Number #3 - Right - return myst.cabinSafeCombination % 10; + return _state.cabinSafeCombination % 10; case 70: // Cabin Safe Matchbox State return _cabinMatchState; case 71: // Stellar Observatory Lights - return myst.observatoryLights; + return _state.observatoryLights; case 72: // Channelwood tree position - return myst.treePosition; + return _state.treePosition; case 73: // Stellar Observatory Date - Month - return myst.observatoryMonthSetting; + return _state.observatoryMonthSetting; case 74: // Stellar Observatory Date - Day #1 (Left) - if (myst.observatoryDaySetting / 10 == 0) + if (_state.observatoryDaySetting / 10 == 0) return 10; else - return myst.observatoryDaySetting / 10; + return _state.observatoryDaySetting / 10; case 75: // Stellar Observatory Date - Day #2 (Right) - return myst.observatoryDaySetting % 10; + return _state.observatoryDaySetting % 10; case 76: // Stellar Observatory Date - Year #1 (Left) - return (myst.observatoryYearSetting >> 12) & 0x0f; + return (_state.observatoryYearSetting >> 12) & 0x0f; case 77: // Stellar Observatory Date - Year #2 - return (myst.observatoryYearSetting >> 8) & 0x0f; + return (_state.observatoryYearSetting >> 8) & 0x0f; case 78: // Stellar Observatory Date - Year #3 - return (myst.observatoryYearSetting >> 4) & 0x0f; + return (_state.observatoryYearSetting >> 4) & 0x0f; case 79: // Stellar Observatory Date - Year #4 (Right) - return (myst.observatoryYearSetting >> 0) & 0x0f; + return (_state.observatoryYearSetting >> 0) & 0x0f; case 80: // Stellar Observatory Hour #1 - Left ( Number 1 (0) or Blank (10)) - if (myst.observatoryTimeSetting % (12 * 60) < (10 * 60)) + if (_state.observatoryTimeSetting % (12 * 60) < (10 * 60)) return 10; else return 0; case 81: // Stellar Observatory Hour #2 - Right - return ((myst.observatoryTimeSetting % (12 * 60)) / 60) % 10; + return ((_state.observatoryTimeSetting % (12 * 60)) / 60) % 10; case 82: // Stellar Observatory Minutes #1 - Left - return (myst.observatoryTimeSetting % 60) / 10; + return (_state.observatoryTimeSetting % 60) / 10; case 83: // Stellar Observatory Minutes #2 - Right - return (myst.observatoryTimeSetting % 60) % 10; + return (_state.observatoryTimeSetting % 60) % 10; case 88: // Stellar Observatory AM/PM - if (myst.observatoryTimeSetting < (12 * 60)) + if (_state.observatoryTimeSetting < (12 * 60)) return 0; // AM else return 1; // PM @@ -512,107 +508,104 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) { case 92: // Stellar observatory sliders state return 1; case 93: // Breaker nearest Generator Room Blown - return myst.generatorBreakers == 1; + return _state.generatorBreakers == 1; case 94: // Breaker nearest Rocket Ship Blown - return myst.generatorBreakers == 2; + return _state.generatorBreakers == 2; case 95: // Going out of tree destination selection - if (myst.treePosition == 0) + if (_state.treePosition == 0) return 0; - else if (myst.treePosition == 4 || myst.treePosition == 5) + else if (_state.treePosition == 4 || _state.treePosition == 5) return 1; else return 2; case 96: // Generator Power Dial Needle Position - return myst.generatorVoltage / 4; + return _state.generatorVoltage / 4; case 97: // Generator Power To Spaceship Dial Needle Position - if (myst.generatorVoltage > 59 || myst.generatorBreakers) + if (_state.generatorVoltage > 59 || _state.generatorBreakers) return 0; else - return myst.generatorVoltage / 4; + return _state.generatorVoltage / 4; case 98: // Cabin Boiler Pilot Light Lit - return myst.cabinPilotLightLit; + return _state.cabinPilotLightLit; case 99: // Cabin Boiler Gas Valve Position - return myst.cabinValvePosition % 6; + return _state.cabinValvePosition % 6; case 102: // Red page - if (globals.ending != 4) { - return !(globals.redPagesInBook & 1) && (globals.heldPage != 7); + if (_globals.ending != 4) { + return !(_globals.redPagesInBook & 1) && (_globals.heldPage != 7); } else { return 0; } case 103: // Blue page - if (globals.ending != 4) { - return !(globals.bluePagesInBook & 1) && (globals.heldPage != 1); + if (_globals.ending != 4) { + return !(_globals.bluePagesInBook & 1) && (_globals.heldPage != 1); } else { return 0; } case 300: // Rocket Ship Music Puzzle Slider State return 1; case 302: // Green Book Opened Before Flag - return myst.greenBookOpenedBefore; + return _state.greenBookOpenedBefore; case 304: // Tower Rotation Map Initialized return _towerRotationMapInitialized; case 305: // Cabin Boiler Lit - return myst.cabinPilotLightLit == 1 && myst.cabinValvePosition > 0; + return _state.cabinPilotLightLit == 1 && _state.cabinValvePosition > 0; case 306: // Cabin Boiler Steam Sound Control - if (myst.cabinPilotLightLit == 1) { - if (myst.cabinValvePosition <= 0) + if (_state.cabinPilotLightLit == 1) { + if (_state.cabinValvePosition <= 0) return 26; else return 27; } else { - return myst.cabinValvePosition; + return _state.cabinValvePosition; } case 307: // Cabin Boiler Fully Pressurised - return myst.cabinPilotLightLit == 1 && myst.cabinValvePosition > 12; + return _state.cabinPilotLightLit == 1 && _state.cabinValvePosition > 12; default: return MystScriptParser::getVar(var); } } void MystScriptParser_Myst::toggleVar(uint16 var) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - switch(var) { case 2: // Marker Switch Near Cabin - myst.cabinMarkerSwitch = (myst.cabinMarkerSwitch + 1) % 2; + _state.cabinMarkerSwitch = (_state.cabinMarkerSwitch + 1) % 2; break; case 3: // Marker Switch Near Clock Tower - myst.clockTowerMarkerSwitch = (myst.clockTowerMarkerSwitch + 1) % 2; + _state.clockTowerMarkerSwitch = (_state.clockTowerMarkerSwitch + 1) % 2; break; case 4: // Marker Switch on Dock - myst.dockMarkerSwitch = (myst.dockMarkerSwitch + 1) % 2; + _state.dockMarkerSwitch = (_state.dockMarkerSwitch + 1) % 2; break; case 5: // Marker Switch Near Ship Pool - myst.poolMarkerSwitch = (myst.poolMarkerSwitch + 1) % 2; + _state.poolMarkerSwitch = (_state.poolMarkerSwitch + 1) % 2; break; case 6: // Marker Switch Near Cogs - myst.gearsMarkerSwitch = (myst.gearsMarkerSwitch + 1) % 2; + _state.gearsMarkerSwitch = (_state.gearsMarkerSwitch + 1) % 2; break; case 7: // Marker Switch Near Generator Room - myst.generatorMarkerSwitch = (myst.generatorMarkerSwitch + 1) % 2; + _state.generatorMarkerSwitch = (_state.generatorMarkerSwitch + 1) % 2; break; case 8: // Marker Switch Near Stellar Observatory - myst.observatoryMarkerSwitch = (myst.observatoryMarkerSwitch + 1) % 2; + _state.observatoryMarkerSwitch = (_state.observatoryMarkerSwitch + 1) % 2; break; case 9: // Marker Switch Near Rocket Ship - myst.rocketshipMarkerSwitch = (myst.rocketshipMarkerSwitch + 1) % 2; + _state.rocketshipMarkerSwitch = (_state.rocketshipMarkerSwitch + 1) % 2; break; case 24: // Fireplace Blue Page - if (globals.ending != 4 && !(globals.bluePagesInBook & 32)) { - if (globals.heldPage == 6) - globals.heldPage = 0; + if (_globals.ending != 4 && !(_globals.bluePagesInBook & 32)) { + if (_globals.heldPage == 6) + _globals.heldPage = 0; else { - globals.heldPage = 6; + _globals.heldPage = 6; } } break; case 25: // Fireplace Red page - if (globals.ending != 4 && !(globals.redPagesInBook & 32)) { - if (globals.heldPage == 12) - globals.heldPage = 0; + if (_globals.ending != 4 && !(_globals.redPagesInBook & 32)) { + if (_globals.heldPage == 12) + _globals.heldPage = 0; else { - globals.heldPage = 12; + _globals.heldPage = 12; } } break; @@ -626,37 +619,37 @@ void MystScriptParser_Myst::toggleVar(uint16 var) { case 33: // Courtyard Image Box - Ostrich { uint16 mask = 0x01 << (var - 26); - if (myst.courtyardImageBoxes & mask) - myst.courtyardImageBoxes &= ~mask; + if (_state.courtyardImageBoxes & mask) + _state.courtyardImageBoxes &= ~mask; else - myst.courtyardImageBoxes |= mask; + _state.courtyardImageBoxes |= mask; } case 41: // Vault white page - if (globals.ending != 4) { + if (_globals.ending != 4) { if (_dockVaultState == 1) { _dockVaultState = 2; - globals.heldPage = 0; + _globals.heldPage = 0; } else if (_dockVaultState == 2) { _dockVaultState = 1; - globals.heldPage = 13; + _globals.heldPage = 13; } } break; case 102: // Red page - if (globals.ending != 4 && !(globals.redPagesInBook & 1)) { - if (globals.heldPage == 7) - globals.heldPage = 0; + if (_globals.ending != 4 && !(_globals.redPagesInBook & 1)) { + if (_globals.heldPage == 7) + _globals.heldPage = 0; else { - globals.heldPage = 7; + _globals.heldPage = 7; } } break; case 103: // Blue page - if (globals.ending != 4 && !(globals.bluePagesInBook & 1)) { - if (globals.heldPage == 1) - globals.heldPage = 0; + if (_globals.ending != 4 && !(_globals.bluePagesInBook & 1)) { + if (_globals.heldPage == 1) + _globals.heldPage = 0; else { - globals.heldPage = 1; + _globals.heldPage = 1; } } break; @@ -667,13 +660,12 @@ void MystScriptParser_Myst::toggleVar(uint16 var) { } bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; bool refresh = false; switch (var) { case 0: // Myst Library Bookcase Closed - if (myst.libraryBookcaseDoor != value) { - myst.libraryBookcaseDoor = value; + if (_state.libraryBookcaseDoor != value) { + _state.libraryBookcaseDoor = value; _tempVar = 0; refresh = true; } @@ -691,7 +683,7 @@ bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) { } break; case 71: // Stellar Observatory Lights - myst.observatoryLights = value; + _state.observatoryLights = value; break; case 89: case 90: @@ -700,7 +692,7 @@ bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) { case 300: // Set slider value break; // Do nothing case 302: // Green Book Opened Before Flag - myst.greenBookOpenedBefore = value; + _state.greenBookOpenedBefore = value; break; case 303: // Library Bookcase status changed _libraryBookcaseChanged = value; @@ -723,16 +715,14 @@ bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) { } uint16 MystScriptParser_Myst::bookCountPages(uint16 var) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - uint16 pages = 0; uint16 cnt = 0; // Select book according to var if (var == 100) - pages = globals.redPagesInBook; + pages = _globals.redPagesInBook; else if (var == 101) - pages = globals.bluePagesInBook; + pages = _globals.bluePagesInBook; // Special page present if (pages & 64) @@ -836,28 +826,25 @@ void MystScriptParser_Myst::o_fireplaceRotation(uint16 op, uint16 var, uint16 ar void MystScriptParser_Myst::o_courtyardBoxesCheckSolution(uint16 op, uint16 var, uint16 argc, uint16 *argv) { uint16 soundId = argv[0]; - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; debugC(kDebugScript, "Opcode %d: Ship Puzzle Logic", op); debugC(kDebugScript, "\tsoundId: %d", soundId); // Change ship state if the boxes are correctly enabled - if (myst.courtyardImageBoxes == 50 && !myst.shipFloating) { + if (_state.courtyardImageBoxes == 50 && !_state.shipFloating) { _vm->_cursor->hideCursor(); - myst.shipFloating = 1; + _state.shipFloating = 1; _vm->_sound->playSoundBlocking(soundId); _vm->_cursor->showCursor(); - } else if (myst.courtyardImageBoxes != 50 && myst.shipFloating) { + } else if (_state.courtyardImageBoxes != 50 && _state.shipFloating) { _vm->_cursor->hideCursor(); - myst.shipFloating = 0; + _state.shipFloating = 0; _vm->_sound->playSoundBlocking(soundId); _vm->_cursor->showCursor(); } } void MystScriptParser_Myst::o_towerRotationStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _towerRotationBlinkLabel = false; _towerRotationMapClicked = true; _towerRotationSpeed = 0; @@ -865,7 +852,7 @@ void MystScriptParser_Myst::o_towerRotationStart(uint16 op, uint16 var, uint16 a _vm->_cursor->setCursor(700); const Common::Point center = Common::Point(383, 124); - Common::Point end = towerRotationMapComputeCoords(center, myst.towerRotationAngle); + Common::Point end = towerRotationMapComputeCoords(center, _state.towerRotationAngle); towerRotationMapComputeAngle(); towerRotationMapDrawLine(center, end); @@ -873,27 +860,25 @@ void MystScriptParser_Myst::o_towerRotationStart(uint16 op, uint16 var, uint16 a } void MystScriptParser_Myst::o_towerRotationEnd(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _towerRotationMapClicked = false; // Set angle value to expected value - if (myst.towerRotationAngle >= 265 - && myst.towerRotationAngle <= 277 - && myst.rocketshipMarkerSwitch) { - myst.towerRotationAngle = 271; - } else if (myst.towerRotationAngle >= 77 - && myst.towerRotationAngle <= 89 - && myst.gearsMarkerSwitch) { - myst.towerRotationAngle = 83; - } else if (myst.towerRotationAngle >= 123 - && myst.towerRotationAngle <= 135 - && myst.dockMarkerSwitch) { - myst.towerRotationAngle = 129; - } else if (myst.towerRotationAngle >= 146 - && myst.towerRotationAngle <= 158 - && myst.cabinMarkerSwitch) { - myst.towerRotationAngle = 152; + if (_state.towerRotationAngle >= 265 + && _state.towerRotationAngle <= 277 + && _state.rocketshipMarkerSwitch) { + _state.towerRotationAngle = 271; + } else if (_state.towerRotationAngle >= 77 + && _state.towerRotationAngle <= 89 + && _state.gearsMarkerSwitch) { + _state.towerRotationAngle = 83; + } else if (_state.towerRotationAngle >= 123 + && _state.towerRotationAngle <= 135 + && _state.dockMarkerSwitch) { + _state.towerRotationAngle = 129; + } else if (_state.towerRotationAngle >= 146 + && _state.towerRotationAngle <= 158 + && _state.cabinMarkerSwitch) { + _state.towerRotationAngle = 152; } _vm->_sound->replaceSound(6378); @@ -908,11 +893,9 @@ void MystScriptParser_Myst::o_imagerChangeSelection(uint16 op, uint16 var, uint1 if (_imagerValidationStep != 10) { _imagerValidationStep = 0; - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - int16 signedValue = argv[0]; - uint16 d1 = (myst.imagerSelection / 10) % 10; - uint16 d2 = myst.imagerSelection % 10; + uint16 d1 = (_state.imagerSelection / 10) % 10; + uint16 d2 = _state.imagerSelection % 10; if (var == 35 && signedValue > 0 && d1 < 9) d1++; @@ -923,8 +906,8 @@ void MystScriptParser_Myst::o_imagerChangeSelection(uint16 op, uint16 var, uint1 else if (var == 36 && signedValue < 0 && d2 > 0) d2--; - myst.imagerSelection = 10 * d1 + d2; - myst.imagerActive = 0; + _state.imagerSelection = 10 * d1 + d2; + _state.imagerActive = 0; _vm->redrawArea(var); } @@ -932,8 +915,6 @@ void MystScriptParser_Myst::o_imagerChangeSelection(uint16 op, uint16 var, uint1 void MystScriptParser_Myst::o_dockVaultOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { // Used on Myst 4143 (Dock near Marker Switch) - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; uint16 soundId = argv[0]; uint16 delay = argv[1]; uint16 directionalUpdateDataSize = argv[2]; @@ -942,15 +923,15 @@ void MystScriptParser_Myst::o_dockVaultOpen(uint16 op, uint16 var, uint16 argc, debugC(kDebugScript, "\tsoundId: %d", soundId); debugC(kDebugScript, "\tdirectionalUpdateDataSize: %d", directionalUpdateDataSize); - if ((myst.cabinMarkerSwitch == 1) && - (myst.clockTowerMarkerSwitch == 1) && - (myst.dockMarkerSwitch == 0) && - (myst.gearsMarkerSwitch == 1) && - (myst.generatorMarkerSwitch == 1) && - (myst.observatoryMarkerSwitch == 1) && - (myst.poolMarkerSwitch == 1) && - (myst.rocketshipMarkerSwitch == 1)) { - if (globals.heldPage != 13 && globals.ending != 4) + if ((_state.cabinMarkerSwitch == 1) && + (_state.clockTowerMarkerSwitch == 1) && + (_state.dockMarkerSwitch == 0) && + (_state.gearsMarkerSwitch == 1) && + (_state.generatorMarkerSwitch == 1) && + (_state.observatoryMarkerSwitch == 1) && + (_state.poolMarkerSwitch == 1) && + (_state.rocketshipMarkerSwitch == 1)) { + if (_globals.heldPage != 13 && _globals.ending != 4) _dockVaultState = 2; else _dockVaultState = 1; @@ -963,7 +944,6 @@ void MystScriptParser_Myst::o_dockVaultOpen(uint16 op, uint16 var, uint16 argc, void MystScriptParser_Myst::o_dockVaultClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) { // Used on Myst 4143 (Dock near Marker Switch) - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; uint16 soundId = argv[0]; uint16 delay = argv[1]; uint16 directionalUpdateDataSize = argv[2]; @@ -972,14 +952,14 @@ void MystScriptParser_Myst::o_dockVaultClose(uint16 op, uint16 var, uint16 argc, debugC(kDebugScript, "\tsoundId: %d", soundId); debugC(kDebugScript, "\tdirectionalUpdateDataSize: %d", directionalUpdateDataSize); - if ((myst.cabinMarkerSwitch == 1) && - (myst.clockTowerMarkerSwitch == 1) && - (myst.dockMarkerSwitch == 1) && - (myst.gearsMarkerSwitch == 1) && - (myst.generatorMarkerSwitch == 1) && - (myst.observatoryMarkerSwitch == 1) && - (myst.poolMarkerSwitch == 1) && - (myst.rocketshipMarkerSwitch == 1)) { + if ((_state.cabinMarkerSwitch == 1) && + (_state.clockTowerMarkerSwitch == 1) && + (_state.dockMarkerSwitch == 1) && + (_state.gearsMarkerSwitch == 1) && + (_state.generatorMarkerSwitch == 1) && + (_state.observatoryMarkerSwitch == 1) && + (_state.poolMarkerSwitch == 1) && + (_state.rocketshipMarkerSwitch == 1)) { if (_dockVaultState == 1 || _dockVaultState == 2) _dockVaultState = 0; @@ -990,8 +970,6 @@ void MystScriptParser_Myst::o_dockVaultClose(uint16 op, uint16 var, uint16 argc, } void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - uint16 cardIdLose = argv[0]; uint16 cardIdBookCover = argv[1]; uint16 soundIdAddPage = argv[2]; @@ -1003,7 +981,7 @@ void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, u debugC(kDebugScript, "SoundId (Add Page): %d", soundIdAddPage); // No page or white page - if (!globals.heldPage || globals.heldPage == 13) { + if (!_globals.heldPage || _globals.heldPage == 13) { _vm->changeToCard(cardIdBookCover, true); return; } @@ -1011,7 +989,7 @@ void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, u uint16 bookVar = 101; uint16 mask = 0; - switch (globals.heldPage) { + switch (_globals.heldPage) { case 7: bookVar = 100; case 1: @@ -1056,21 +1034,21 @@ void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, u // Add page to book if (var == 100) - globals.redPagesInBook |= mask; + _globals.redPagesInBook |= mask; else - globals.bluePagesInBook |= mask; + _globals.bluePagesInBook |= mask; // Remove page from hand - globals.heldPage = 0; + _globals.heldPage = 0; _vm->_cursor->showCursor(); if (mask == 32) { // You lose! if (var == 100) - globals.currentAge = 9; + _globals.currentAge = 9; else - globals.currentAge = 10; + _globals.currentAge = 10; _vm->changeToCard(cardIdLose, true); } else { @@ -1080,32 +1058,31 @@ void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, u void MystScriptParser_Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv) { // Used on Card 4006 (Clock Tower Time Controls) - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; uint16 soundId = argv[0]; debugC(kDebugScript, "Opcode %d: Clock Tower Bridge Puzzle Execute Button", op); // Correct time is 2:40 - bool correctTime = myst.clockTowerHourPosition == 2 - && myst.clockTowerMinutePosition == 40; + bool correctTime = _state.clockTowerHourPosition == 2 + && _state.clockTowerMinutePosition == 40; - if (!myst.clockTowerBridgeOpen && correctTime) { + if (!_state.clockTowerBridgeOpen && correctTime) { _vm->_sound->replaceSound(soundId); _vm->_system->delayMillis(500); // TODO: Play only 1st half of movie i.e. gears rise up, from 0 to 650 _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 33); - myst.clockTowerBridgeOpen = 1; + _state.clockTowerBridgeOpen = 1; _vm->redrawArea(12); - } else if (myst.clockTowerBridgeOpen && !correctTime) { + } else if (_state.clockTowerBridgeOpen && !correctTime) { _vm->_sound->replaceSound(soundId); _vm->_system->delayMillis(500); // TODO: Play only 2nd half of movie i.e. gears sink down, from 700 to 1300 _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 33); - myst.clockTowerBridgeOpen = 0; + _state.clockTowerBridgeOpen = 0; _vm->redrawArea(12); } } @@ -1113,7 +1090,6 @@ void MystScriptParser_Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 a void MystScriptParser_Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Imager play button", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; uint16 video = getVar(51); // Press button @@ -1133,7 +1109,7 @@ void MystScriptParser_Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 arg // Play selected video - if (!myst.imagerActive && video != 3) + if (!_state.imagerActive && video != 3) _vm->_sound->replaceSound(argv[0]); switch (video) { @@ -1143,34 +1119,34 @@ void MystScriptParser_Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 arg _imagerMovie->playMovie(); break; case 1: // Mountain - if (myst.imagerActive) { + if (_state.imagerActive) { // TODO: Play from 11180 to 16800 Common::String file = _vm->wrapMovieFilename("vltmntn", kMystStack); _vm->_video->playBackgroundMovie(file, 159, 96, false); - myst.imagerActive = 0; + _state.imagerActive = 0; } else { // TODO: Play from 0 to 11180 Common::String file = _vm->wrapMovieFilename("vltmntn", kMystStack); _vm->_video->playBackgroundMovie(file, 159, 96, false); - myst.imagerActive = 1; + _state.imagerActive = 1; } break; case 2: // Water - if (myst.imagerActive) { + if (_state.imagerActive) { _vm->_sound->replaceSound(argv[1]); // TODO: Play from 4204 to 6040 _imagerMovie->playMovie(); - myst.imagerActive = 0; + _state.imagerActive = 0; } else { // TODO: Play from 0 to 1814 // Then play from 1814 to 4204, looping _imagerMovie->playMovie(); - myst.imagerActive = 1; + _state.imagerActive = 1; } break; } @@ -1181,8 +1157,6 @@ void MystScriptParser_Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 arg void MystScriptParser_Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Imager erase button", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _imagerRedButton = static_cast<MystResourceType8 *>(_invokingResource->_parent); for (uint i = 0; i < 4; i++) _imagerSound[i] = argv[i]; @@ -1202,22 +1176,22 @@ void MystScriptParser_Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 ar _vm->_sound->playSoundBlocking(_imagerSound[3]); // Erase selected video from imager - switch (myst.imagerSelection) { + switch (_state.imagerSelection) { case 8: - myst.imagerAtrusErased = 1; + _state.imagerAtrusErased = 1; break; case 40: - myst.imagerMountainErased = 1; + _state.imagerMountainErased = 1; break; case 47: - myst.imagerMarkerErased = 1; + _state.imagerMarkerErased = 1; break; case 67: - myst.imagerWaterErased = 1; + _state.imagerWaterErased = 1; break; } - myst.imagerActive = 0; + _state.imagerActive = 0; _imagerValidationStep = 0; return; } else if (_imagerValidationStep == 11) { @@ -1283,23 +1257,22 @@ void MystScriptParser_Myst::o_towerElevatorAnimation(uint16 op, uint16 var, uint void MystScriptParser_Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Generator button pressed", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; MystResource *button = _invokingResource->_parent; generatorRedrawRocket(); - _generatorVoltage = myst.generatorVoltage; + _generatorVoltage = _state.generatorVoltage; uint16 mask = 0; uint16 value = 0; generatorButtonValue(button, mask, value); // Button pressed - if (myst.generatorButtons & mask) { - myst.generatorButtons &= ~mask; - myst.generatorVoltage -= value; + if (_state.generatorButtons & mask) { + _state.generatorButtons &= ~mask; + _state.generatorVoltage -= value; - if (myst.generatorVoltage) + if (_state.generatorVoltage) _vm->_sound->replaceSound(8297); else _vm->_sound->replaceSound(9297); @@ -1311,16 +1284,16 @@ void MystScriptParser_Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint _vm->_sound->replaceBackground(4297); } - myst.generatorButtons |= mask; - myst.generatorVoltage += value; + _state.generatorButtons |= mask; + _state.generatorVoltage += value; } // Redraw button _vm->redrawArea(button->getType8Var()); // Blow breaker - if (myst.generatorVoltage > 59) - myst.generatorBreakers = _vm->_rnd->getRandomNumberRng(1, 2); + if (_state.generatorVoltage > 59) + _state.generatorBreakers = _vm->_rnd->getRandomNumberRng(1, 2); } void MystScriptParser_Myst::generatorRedrawRocket() { @@ -1377,11 +1350,9 @@ void MystScriptParser_Myst::generatorButtonValue(MystResource *button, uint16 &m void MystScriptParser_Myst::o_cabinSafeChangeDigit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Cabin safe change digit", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - - uint16 d1 = myst.cabinSafeCombination / 100; - uint16 d2 = (myst.cabinSafeCombination / 10) % 10; - uint16 d3 = myst.cabinSafeCombination % 10; + uint16 d1 = _state.cabinSafeCombination / 100; + uint16 d2 = (_state.cabinSafeCombination / 10) % 10; + uint16 d3 = _state.cabinSafeCombination % 10; if (var == 67) d1 = (d1 + 1) % 10; @@ -1390,7 +1361,7 @@ void MystScriptParser_Myst::o_cabinSafeChangeDigit(uint16 op, uint16 var, uint16 else d3 = (d3 + 1) % 10; - myst.cabinSafeCombination = 100 * d1 + 10 * d2 + d3; + _state.cabinSafeCombination = 100 * d1 + 10 * d2 + d3; _vm->redrawArea(var); } @@ -1409,7 +1380,6 @@ void MystScriptParser_Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16 debugC(kDebugScript, "Opcode %d: Cabin safe handle move", op); // Used on Card 4100 - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); // Make the handle follow the mouse @@ -1428,7 +1398,7 @@ void MystScriptParser_Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16 _vm->_sound->replaceSound(soundId); } // Combination is right - if (myst.cabinSafeCombination == 724) { + if (_state.cabinSafeCombination == 724) { uint16 soundId = handle->getList2(1); if (soundId) _vm->_sound->replaceSound(soundId); @@ -1522,7 +1492,6 @@ void MystScriptParser_Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uin void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Circuit breaker move", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource); int16 maxStep = breaker->getStepsV() - 1; @@ -1541,7 +1510,7 @@ void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 a if (breaker->getType8Var() == 93) { // Voltage is still too high or not broken - if (myst.generatorVoltage > 59 || myst.generatorBreakers != 1) { + if (_state.generatorVoltage > 59 || _state.generatorBreakers != 1) { uint16 soundId = breaker->getList2(1); if (soundId) _vm->_sound->replaceSound(soundId); @@ -1551,11 +1520,11 @@ void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 a _vm->_sound->replaceSound(soundId); // Reset breaker state - myst.generatorBreakers = 0; + _state.generatorBreakers = 0; } } else { // Voltage is still too high or not broken - if (myst.generatorVoltage > 59 || myst.generatorBreakers != 2) { + if (_state.generatorVoltage > 59 || _state.generatorBreakers != 2) { uint16 soundId = breaker->getList2(1); if (soundId) _vm->_sound->replaceSound(soundId); @@ -1565,7 +1534,7 @@ void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 a _vm->_sound->replaceSound(soundId); // Reset breaker state - myst.generatorBreakers = 0; + _state.generatorBreakers = 0; } } } @@ -1582,10 +1551,9 @@ void MystScriptParser_Myst::o_circuitBreakerEndMove(uint16 op, uint16 var, uint1 void MystScriptParser_Myst::o_boilerIncreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Boiler increase pressure start", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; _treeStopped = true; - if (myst.cabinValvePosition < 25) + if (_state.cabinValvePosition < 25) _vm->_sound->stopBackground(); _boilerPressureIncreasing = true; @@ -1593,21 +1561,20 @@ void MystScriptParser_Myst::o_boilerIncreasePressureStart(uint16 op, uint16 var, void MystScriptParser_Myst::o_boilerLightPilot(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Boiler light pilot", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; // Match is lit if (_cabinMatchState == 1) { - myst.cabinPilotLightLit = 1; + _state.cabinPilotLightLit = 1; _vm->redrawArea(98); // Put out match _matchGoOutTime = _vm->_system->getMillis(); - if (myst.cabinValvePosition > 0) + if (_state.cabinValvePosition > 0) _vm->_sound->replaceBackground(8098, 49152); - if (myst.cabinValvePosition > 12) - myst.treeLastMoveTime = _vm->_system->getMillis(); + if (_state.cabinValvePosition > 12) + _state.treeLastMoveTime = _vm->_system->getMillis(); // TODO: Complete. Play movies } @@ -1615,36 +1582,33 @@ void MystScriptParser_Myst::o_boilerLightPilot(uint16 op, uint16 var, uint16 arg void MystScriptParser_Myst::o_boilerIncreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Boiler increase pressure stop", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; _treeStopped = false; _boilerPressureIncreasing = false; - myst.treeLastMoveTime = _vm->_system->getMillis(); + _state.treeLastMoveTime = _vm->_system->getMillis(); - if (myst.cabinPilotLightLit == 1) { - if (myst.cabinValvePosition > 0) + if (_state.cabinPilotLightLit == 1) { + if (_state.cabinValvePosition > 0) _vm->_sound->replaceBackground(8098, 49152); // TODO: Play movies } else { - if (myst.cabinValvePosition > 0) - _vm->_sound->replaceBackground(4098, myst.cabinValvePosition << 10); + if (_state.cabinValvePosition > 0) + _vm->_sound->replaceBackground(4098, _state.cabinValvePosition << 10); } } void MystScriptParser_Myst::boilerPressureIncrease_run() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - // Allow increasing pressure if sound has stopped - if (!_vm->_sound->isPlaying(5098) && myst.cabinValvePosition < 25) { - myst.cabinValvePosition++; - if (myst.cabinValvePosition == 1) { + if (!_vm->_sound->isPlaying(5098) && _state.cabinValvePosition < 25) { + _state.cabinValvePosition++; + if (_state.cabinValvePosition == 1) { // TODO: Play fire movie // Draw fire _vm->redrawArea(305); - } else if (myst.cabinValvePosition == 25) { - if (myst.cabinPilotLightLit == 1) + } else if (_state.cabinValvePosition == 25) { + if (_state.cabinPilotLightLit == 1) _vm->_sound->replaceBackground(8098, 49152); else _vm->_sound->replaceBackground(4098, 25600); @@ -1659,12 +1623,10 @@ void MystScriptParser_Myst::boilerPressureIncrease_run() { } void MystScriptParser_Myst::boilerPressureDecrease_run() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - // Allow decreasing pressure if sound has stopped - if (!_vm->_sound->isPlaying(5098) && myst.cabinValvePosition > 0) { - myst.cabinValvePosition--; - if (myst.cabinValvePosition == 0) { + if (!_vm->_sound->isPlaying(5098) && _state.cabinValvePosition > 0) { + _state.cabinValvePosition--; + if (_state.cabinValvePosition == 0) { // TODO: Play fire movie // Draw fire @@ -1690,20 +1652,19 @@ void MystScriptParser_Myst::o_boilerDecreasePressureStart(uint16 op, uint16 var, void MystScriptParser_Myst::o_boilerDecreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Boiler decrease pressure stop", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; _treeStopped = false; _boilerPressureDecreasing = false; - myst.treeLastMoveTime = _vm->_system->getMillis(); + _state.treeLastMoveTime = _vm->_system->getMillis(); - if (myst.cabinPilotLightLit == 1) { - if (myst.cabinValvePosition > 0) + if (_state.cabinPilotLightLit == 1) { + if (_state.cabinValvePosition > 0) _vm->_sound->replaceBackground(8098, 49152); // TODO: Play movies } else { - if (myst.cabinValvePosition > 0) - _vm->_sound->replaceBackground(4098, myst.cabinValvePosition << 10); + if (_state.cabinValvePosition > 0) + _vm->_sound->replaceBackground(4098, _state.cabinValvePosition << 10); } } @@ -1717,19 +1678,15 @@ void MystScriptParser_Myst::o_basementIncreasePressureStart(uint16 op, uint16 va void MystScriptParser_Myst::o_basementIncreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Basement increase pressure stop", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _treeStopped = false; _basementPressureIncreasing = false; - myst.treeLastMoveTime = _vm->_system->getMillis(); + _state.treeLastMoveTime = _vm->_system->getMillis(); } void MystScriptParser_Myst::basementPressureIncrease_run() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - // Allow increasing pressure if sound has stopped - if (!_vm->_sound->isPlaying(4642) && myst.cabinValvePosition < 25) { - myst.cabinValvePosition++; + if (!_vm->_sound->isPlaying(4642) && _state.cabinValvePosition < 25) { + _state.cabinValvePosition++; // Pressure increasing sound _vm->_sound->replaceSound(4642); @@ -1740,11 +1697,9 @@ void MystScriptParser_Myst::basementPressureIncrease_run() { } void MystScriptParser_Myst::basementPressureDecrease_run() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - // Allow decreasing pressure if sound has stopped - if (!_vm->_sound->isPlaying(4642) && myst.cabinValvePosition > 0) { - myst.cabinValvePosition--; + if (!_vm->_sound->isPlaying(4642) && _state.cabinValvePosition > 0) { + _state.cabinValvePosition--; // Pressure decreasing sound _vm->_sound->replaceSound(4642); @@ -1764,19 +1719,15 @@ void MystScriptParser_Myst::o_basementDecreasePressureStart(uint16 op, uint16 va void MystScriptParser_Myst::o_basementDecreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Basement decrease pressure stop", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _treeStopped = false; _basementPressureDecreasing = false; - myst.treeLastMoveTime = _vm->_system->getMillis(); + _state.treeLastMoveTime = _vm->_system->getMillis(); } void MystScriptParser_Myst::tree_run() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - uint16 pressure; - if (myst.cabinPilotLightLit) - pressure = myst.cabinValvePosition; + if (_state.cabinPilotLightLit) + pressure = _state.cabinValvePosition; else pressure = 0; @@ -1787,24 +1738,24 @@ void MystScriptParser_Myst::tree_run() { goingDown = false; // Tree is within bounds - if ((myst.treePosition < 12 && !goingDown) - || (myst.treePosition > _treeMinPosition && goingDown)) { + if ((_state.treePosition < 12 && !goingDown) + || (_state.treePosition > _treeMinPosition && goingDown)) { uint16 delay = treeNextMoveDelay(pressure); uint32 time = _vm->_system->getMillis(); - if (delay < time - myst.treeLastMoveTime) { + if (delay < time - _state.treeLastMoveTime) { // Tree movement if (goingDown) { - myst.treePosition--; + _state.treePosition--; _vm->_sound->replaceSound(2); } else { - myst.treePosition++; + _state.treePosition++; _vm->_sound->replaceSound(1); } // Stop background music if going up from book room if (_vm->getCurCard() == 4630) { - if (myst.treePosition > 0) + if (_state.treePosition > 0) _vm->_sound->stopBackground(); else _vm->_sound->replaceBackground(4630, 24576); @@ -1816,19 +1767,17 @@ void MystScriptParser_Myst::tree_run() { // Check if alcove is accessible treeSetAlcoveAccessible(); - myst.treeLastMoveTime = time; + _state.treeLastMoveTime = time; } } } } void MystScriptParser_Myst::treeSetAlcoveAccessible() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - if (_treeAlcove) { // Make alcove accessible if the tree is in the correct position - _treeAlcove->setEnabled(myst.treePosition >= _treeMinAccessiblePosition - && myst.treePosition <= _treeMaxAccessiblePosition); + _treeAlcove->setEnabled(_state.treePosition >= _treeMinAccessiblePosition + && _state.treePosition <= _treeMaxAccessiblePosition); } } @@ -1857,36 +1806,32 @@ void MystScriptParser_Myst::o_rocketSoundSliderMove(uint16 op, uint16 var, uint1 void MystScriptParser_Myst::o_rocketSoundSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Rocket slider end move", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _vm->checkCursorHints(); - if (myst.generatorVoltage == 59 && !myst.generatorBreakers) { + if (_state.generatorVoltage == 59 && !_state.generatorBreakers) { if (_rocketSliderSound) _vm->_sound->stopSound(); } if (_invokingResource == _rocketSlider1) { - myst.rocketSliderPosition[0] = _rocketSlider1->_pos.y; + _state.rocketSliderPosition[0] = _rocketSlider1->_pos.y; } else if (_invokingResource == _rocketSlider2) { - myst.rocketSliderPosition[1] = _rocketSlider2->_pos.y; + _state.rocketSliderPosition[1] = _rocketSlider2->_pos.y; } else if (_invokingResource == _rocketSlider3) { - myst.rocketSliderPosition[2] = _rocketSlider3->_pos.y; + _state.rocketSliderPosition[2] = _rocketSlider3->_pos.y; } else if (_invokingResource == _rocketSlider4) { - myst.rocketSliderPosition[3] = _rocketSlider4->_pos.y; + _state.rocketSliderPosition[3] = _rocketSlider4->_pos.y; } else if (_invokingResource == _rocketSlider5) { - myst.rocketSliderPosition[4] = _rocketSlider5->_pos.y; + _state.rocketSliderPosition[4] = _rocketSlider5->_pos.y; } _vm->_sound->resumeBackground(); } void MystScriptParser_Myst::rocketSliderMove() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - MystResourceType10 *slider = static_cast<MystResourceType10 *>(_invokingResource); - if (myst.generatorVoltage == 59 && !myst.generatorBreakers) { + if (_state.generatorVoltage == 59 && !_state.generatorBreakers) { uint16 soundId = rocketSliderGetSound(slider->_pos.y); if (soundId != _rocketSliderSound) { _rocketSliderSound = soundId; @@ -1964,7 +1909,6 @@ void MystScriptParser_Myst::rocketCheckSolution() { void MystScriptParser_Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Rocket piano start move", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource); // What the hell ?? @@ -1979,7 +1923,7 @@ void MystScriptParser_Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 arg _vm->_system->updateScreen(); // Play note - if (myst.generatorVoltage == 59 && !myst.generatorBreakers) { + if (_state.generatorVoltage == 59 && !_state.generatorBreakers) { uint16 soundId = key->getList1(0); _vm->_sound->replaceSound(soundId, Audio::Mixer::kMaxChannelVolume, true); } @@ -1990,7 +1934,6 @@ void MystScriptParser_Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos(); Common::Rect piano = Common::Rect(85, 123, 460, 270); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; // Unpress previous key MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource); @@ -2018,7 +1961,7 @@ void MystScriptParser_Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc _vm->_gfx->copyImageSectionToScreen(key->_subImages[1].wdib, src, dest); // Play note - if (myst.generatorVoltage == 59 && !myst.generatorBreakers) { + if (_state.generatorVoltage == 59 && !_state.generatorBreakers) { uint16 soundId = key->getList1(0); _vm->_sound->replaceSound(soundId, Audio::Mixer::kMaxChannelVolume, true); } @@ -2073,7 +2016,6 @@ void MystScriptParser_Myst::o_rocketOpenBook(uint16 op, uint16 var, uint16 argc, void MystScriptParser_Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Rocket lever move", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); // Make the lever follow the mouse @@ -2091,7 +2033,7 @@ void MystScriptParser_Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc _vm->_sound->replaceSound(soundId); // If rocket correctly powered - if (myst.generatorVoltage == 59 && !myst.generatorBreakers) { + if (_state.generatorVoltage == 59 && !_state.generatorBreakers) { rocketCheckSolution(); } } @@ -2124,32 +2066,28 @@ void MystScriptParser_Myst::o_cabinLeave(uint16 op, uint16 var, uint16 argc, uin void MystScriptParser_Myst::o_treePressureReleaseStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Tree pressure release start", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - Common::Rect src = Common::Rect(0, 0, 49, 86); Common::Rect dest = Common::Rect(78, 46, 127, 132); _vm->_gfx->copyImageSectionToScreen(4631, src, dest); _vm->_system->updateScreen(); - _tempVar = myst.cabinValvePosition; + _tempVar = _state.cabinValvePosition; - if (myst.treePosition >= 4) { - myst.cabinValvePosition = 0; + if (_state.treePosition >= 4) { + _state.cabinValvePosition = 0; _treeMinPosition = 4; - myst.treeLastMoveTime = 0; + _state.treeLastMoveTime = 0; } } void MystScriptParser_Myst::o_treePressureReleaseStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Tree pressure release stop", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - Common::Rect rect = Common::Rect(78, 46, 127, 132); _vm->_gfx->copyBackBufferToScreen(rect); _vm->_system->updateScreen(); - myst.cabinValvePosition = _tempVar; + _state.cabinValvePosition = _tempVar; _treeMinPosition = 0; } @@ -2307,14 +2245,12 @@ void MystScriptParser_Myst::clockWheelStartTurn(uint16 wheel) { } void MystScriptParser_Myst::clockWheelTurn(uint16 var) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - if (var == 38) { // Hours - myst.clockTowerHourPosition = (myst.clockTowerHourPosition + 1) % 12; + _state.clockTowerHourPosition = (_state.clockTowerHourPosition + 1) % 12; } else { // Minutes - myst.clockTowerMinutePosition = (myst.clockTowerMinutePosition + 5) % 60; + _state.clockTowerMinutePosition = (_state.clockTowerMinutePosition + 5) % 60; } } @@ -2428,7 +2364,6 @@ void MystScriptParser_Myst::opcode_197(uint16 op, uint16 var, uint16 argc, uint1 void MystScriptParser_Myst::o_dockVaultForceClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) { // Used on Myst 4143 (Dock near Marker Switch) - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; uint16 soundId = argv[0]; uint16 delay = argv[1]; uint16 directionalUpdateDataSize = argv[2]; @@ -2439,7 +2374,7 @@ void MystScriptParser_Myst::o_dockVaultForceClose(uint16 op, uint16 var, uint16 if (_dockVaultState) { // Open switch - myst.dockMarkerSwitch = 1; + _state.dockMarkerSwitch = 1; _vm->_sound->replaceSound(4143); _vm->redrawArea(4); @@ -2563,35 +2498,33 @@ void MystScriptParser_Myst::towerRotationDrawBuildings() { } uint16 MystScriptParser_Myst::towerRotationMapComputeAngle() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _towerRotationSpeed++; if (_towerRotationSpeed >= 7) _towerRotationSpeed = 7; else _towerRotationSpeed++; - myst.towerRotationAngle = (myst.towerRotationAngle + _towerRotationSpeed) % 360; - uint16 angle = myst.towerRotationAngle; + _state.towerRotationAngle = (_state.towerRotationAngle + _towerRotationSpeed) % 360; + uint16 angle = _state.towerRotationAngle; _towerRotationOverSpot = false; if (angle >= 265 && angle <= 277 - && myst.rocketshipMarkerSwitch) { + && _state.rocketshipMarkerSwitch) { angle = 271; _towerRotationOverSpot = true; _towerRotationSpeed = 1; } else if (angle >= 77 && angle <= 89 - && myst.gearsMarkerSwitch) { + && _state.gearsMarkerSwitch) { angle = 83; _towerRotationOverSpot = true; _towerRotationSpeed = 1; } else if (angle >= 123 && angle <= 135 - && myst.dockMarkerSwitch) { + && _state.dockMarkerSwitch) { angle = 129; _towerRotationOverSpot = true; _towerRotationSpeed = 1; } else if (angle >= 146 && angle <= 158 - && myst.cabinMarkerSwitch) { + && _state.cabinMarkerSwitch) { angle = 152; _towerRotationOverSpot = true; _towerRotationSpeed = 1; @@ -2660,10 +2593,8 @@ void MystScriptParser_Myst::o_forechamberDoor_init(uint16 op, uint16 var, uint16 } void MystScriptParser_Myst::o_shipAccess_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - // Enable acces to the ship - if (myst.shipFloating) { + if (_state.shipFloating) { _invokingResource->setEnabled(true); } } @@ -2685,11 +2616,9 @@ void MystScriptParser_Myst::o_imager_init(uint16 op, uint16 var, uint16 argc, ui } void MystScriptParser_Myst::imager_run() { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _imagerRunning = false; - if (myst.imagerActive && myst.imagerSelection == 67) { + if (_state.imagerActive && _state.imagerSelection == 67) { // TODO: play between 1814 and 4204 looping _imagerMovie->playMovie(); } @@ -2716,13 +2645,11 @@ void MystScriptParser_Myst::o_libraryBookcaseTransform_init(uint16 op, uint16 va } void MystScriptParser_Myst::generatorControlRoom_run(void) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - - if (_generatorVoltage == myst.generatorVoltage) { + if (_generatorVoltage == _state.generatorVoltage) { generatorRedrawRocket(); } else { // Animate generator gauge - if (_generatorVoltage > myst.generatorVoltage) + if (_generatorVoltage > _state.generatorVoltage) _generatorVoltage--; else _generatorVoltage++; @@ -2735,11 +2662,9 @@ void MystScriptParser_Myst::generatorControlRoom_run(void) { } void MystScriptParser_Myst::o_generatorControlRoom_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - debugC(kDebugScript, "Opcode %d: Generator control room init", op); - _generatorVoltage = myst.generatorVoltage; + _generatorVoltage = _state.generatorVoltage; _generatorControlRoomRunning = true; } @@ -2878,28 +2803,26 @@ void MystScriptParser_Myst::opcode_218(uint16 op, uint16 var, uint16 argc, uint1 void MystScriptParser_Myst::o_rocketSliders_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Rocket sliders init", op); - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - _rocketSlider1 = static_cast<MystResourceType10 *>(_vm->_resources[argv[0]]); _rocketSlider2 = static_cast<MystResourceType10 *>(_vm->_resources[argv[1]]); _rocketSlider3 = static_cast<MystResourceType10 *>(_vm->_resources[argv[2]]); _rocketSlider4 = static_cast<MystResourceType10 *>(_vm->_resources[argv[3]]); _rocketSlider5 = static_cast<MystResourceType10 *>(_vm->_resources[argv[4]]); - if (myst.rocketSliderPosition[0]) { - _rocketSlider1->setPosition(myst.rocketSliderPosition[0]); + if (_state.rocketSliderPosition[0]) { + _rocketSlider1->setPosition(_state.rocketSliderPosition[0]); } - if (myst.rocketSliderPosition[1]) { - _rocketSlider2->setPosition(myst.rocketSliderPosition[1]); + if (_state.rocketSliderPosition[1]) { + _rocketSlider2->setPosition(_state.rocketSliderPosition[1]); } - if (myst.rocketSliderPosition[2]) { - _rocketSlider3->setPosition(myst.rocketSliderPosition[2]); + if (_state.rocketSliderPosition[2]) { + _rocketSlider3->setPosition(_state.rocketSliderPosition[2]); } - if (myst.rocketSliderPosition[3]) { - _rocketSlider4->setPosition(myst.rocketSliderPosition[3]); + if (_state.rocketSliderPosition[3]) { + _rocketSlider4->setPosition(_state.rocketSliderPosition[3]); } - if (myst.rocketSliderPosition[4]) { - _rocketSlider5->setPosition(myst.rocketSliderPosition[4]); + if (_state.rocketSliderPosition[4]) { + _rocketSlider5->setPosition(_state.rocketSliderPosition[4]); } } @@ -2912,14 +2835,11 @@ void MystScriptParser_Myst::o_greenBook_init(uint16 op, uint16 var, uint16 argc, // Used for Card 4168 (Green Book Movies) debugC(kDebugScript, "Opcode %d: Green book init", op); - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Myst &myst = _vm->_saveLoad->_v->myst; - uint loopStart = 0; uint loopEnd = 0; Common::String file; - if (!myst.greenBookOpenedBefore) { + if (!_state.greenBookOpenedBefore) { loopStart = 113200; loopEnd = 116400; file = _vm->wrapMovieFilename("atrusbk1", kMystStack); @@ -2932,7 +2852,7 @@ void MystScriptParser_Myst::o_greenBook_init(uint16 op, uint16 var, uint16 argc, _vm->_sound->stopSound(); _vm->_sound->pauseBackground(); - if (globals.ending != 4) { + if (_globals.ending != 4) { _vm->_video->playBackgroundMovie(file, 314, 76); } diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h index 9b65e4174f..fa87009dc0 100644 --- a/engines/mohawk/myst_stacks/myst.h +++ b/engines/mohawk/myst_stacks/myst.h @@ -180,6 +180,8 @@ private: DECLARE_OPCODE(opcode_309); DECLARE_OPCODE(opcode_312); + MystGameState::Myst &_state; + bool _generatorControlRoomRunning; uint16 _generatorVoltage; // 58 diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp index 38b457e0cb..43c2f97d7e 100644 --- a/engines/mohawk/myst_stacks/selenitic.cpp +++ b/engines/mohawk/myst_stacks/selenitic.cpp @@ -36,7 +36,8 @@ namespace Mohawk { -MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) : + MystScriptParser(vm), _state(vm->_gameState->_selenitic) { setupOpcodes(); _invokingResource = NULL; _mazeRunnerPosition = 288; @@ -91,24 +92,21 @@ void MystScriptParser_Selenitic::runPersistentScripts() { } uint16 MystScriptParser_Selenitic::getVar(uint16 var) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - switch(var) { case 0: // Sound receiver emitters enabled - return selenitic.emitterEnabledWind; + return _state.emitterEnabledWind; case 1: - return selenitic.emitterEnabledVolcano; + return _state.emitterEnabledVolcano; case 2: - return selenitic.emitterEnabledClock; + return _state.emitterEnabledClock; case 3: - return selenitic.emitterEnabledWater; + return _state.emitterEnabledWater; case 4: - return selenitic.emitterEnabledCrystal; + return _state.emitterEnabledCrystal; case 5: // Sound receiver opened - return selenitic.soundReceiverOpened; + return _state.soundReceiverOpened; case 6: // Tunnel lights - return selenitic.tunnelLightsSwitchedOn; + return _state.tunnelLightsSwitchedOn; case 7:// Maze runner display if (_mazeRunnerPosition == 288) { return 0; @@ -122,15 +120,15 @@ uint16 MystScriptParser_Selenitic::getVar(uint16 var) { case 8: // Viewer return 0; case 9: // Sound receiver selected source - return selenitic.soundReceiverCurrentSource == 0; + return _state.soundReceiverCurrentSource == 0; case 10: - return selenitic.soundReceiverCurrentSource == 1; + return _state.soundReceiverCurrentSource == 1; case 11: - return selenitic.soundReceiverCurrentSource == 2; + return _state.soundReceiverCurrentSource == 2; case 12: - return selenitic.soundReceiverCurrentSource == 3; + return _state.soundReceiverCurrentSource == 3; case 13: - return selenitic.soundReceiverCurrentSource == 4; + return _state.soundReceiverCurrentSource == 4; case 14: // Sound receiver position return (*_soundReceiverPosition) / 1000; case 15: @@ -161,55 +159,52 @@ uint16 MystScriptParser_Selenitic::getVar(uint16 var) { case 33: // Maze runner at entry return _mazeRunnerPosition != 288; case 102: // Red page - return !(globals.redPagesInBook & 2) && (globals.heldPage != 8); + return !(_globals.redPagesInBook & 2) && (_globals.heldPage != 8); case 103: // Blue page - return !(globals.bluePagesInBook & 2) && (globals.heldPage != 2); + return !(_globals.bluePagesInBook & 2) && (_globals.heldPage != 2); default: return MystScriptParser::getVar(var); } } void MystScriptParser_Selenitic::toggleVar(uint16 var) { - MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - switch(var) { case 0: // Sound receiver emitters enabled - selenitic.emitterEnabledWind = (selenitic.emitterEnabledWind + 1) % 2; + _state.emitterEnabledWind = (_state.emitterEnabledWind + 1) % 2; break; case 1: - selenitic.emitterEnabledVolcano = (selenitic.emitterEnabledVolcano + 1) % 2; + _state.emitterEnabledVolcano = (_state.emitterEnabledVolcano + 1) % 2; break; case 2: - selenitic.emitterEnabledClock = (selenitic.emitterEnabledClock + 1) % 2; + _state.emitterEnabledClock = (_state.emitterEnabledClock + 1) % 2; break; case 3: - selenitic.emitterEnabledWater = (selenitic.emitterEnabledWater + 1) % 2; + _state.emitterEnabledWater = (_state.emitterEnabledWater + 1) % 2; break; case 4: - selenitic.emitterEnabledCrystal = (selenitic.emitterEnabledCrystal + 1) % 2; + _state.emitterEnabledCrystal = (_state.emitterEnabledCrystal + 1) % 2; break; case 5: // Sound receiver opened - selenitic.soundReceiverOpened = (selenitic.soundReceiverOpened + 1) % 2; + _state.soundReceiverOpened = (_state.soundReceiverOpened + 1) % 2; break; case 6: // Tunnel lights - selenitic.tunnelLightsSwitchedOn = (selenitic.tunnelLightsSwitchedOn + 1) % 2; + _state.tunnelLightsSwitchedOn = (_state.tunnelLightsSwitchedOn + 1) % 2; break; case 102: // Red page - if (!(globals.redPagesInBook & 2)) { - if (globals.heldPage == 8) - globals.heldPage = 0; + if (!(_globals.redPagesInBook & 2)) { + if (_globals.heldPage == 8) + _globals.heldPage = 0; else { - globals.heldPage = 8; + _globals.heldPage = 8; } } break; case 103: // Blue page - if (!(globals.bluePagesInBook & 2)) { - if (globals.heldPage == 2) - globals.heldPage = 0; + if (!(_globals.bluePagesInBook & 2)) { + if (_globals.heldPage == 2) + _globals.heldPage = 0; else { - globals.heldPage = 2; + _globals.heldPage = 2; } } break; @@ -220,66 +215,65 @@ void MystScriptParser_Selenitic::toggleVar(uint16 var) { } bool MystScriptParser_Selenitic::setVarValue(uint16 var, uint16 value) { - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; bool refresh = false; switch (var) { case 0: // Sound receiver emitters enabled - if (selenitic.emitterEnabledWind != value) { - selenitic.emitterEnabledWind = value; + if (_state.emitterEnabledWind != value) { + _state.emitterEnabledWind = value; refresh = true; } break; case 1: - if (selenitic.emitterEnabledVolcano != value) { - selenitic.emitterEnabledVolcano = value; + if (_state.emitterEnabledVolcano != value) { + _state.emitterEnabledVolcano = value; refresh = true; } break; case 2: - if (selenitic.emitterEnabledClock != value) { - selenitic.emitterEnabledClock = value; + if (_state.emitterEnabledClock != value) { + _state.emitterEnabledClock = value; refresh = true; } break; case 3: - if (selenitic.emitterEnabledWater != value) { - selenitic.emitterEnabledWater = value; + if (_state.emitterEnabledWater != value) { + _state.emitterEnabledWater = value; refresh = true; } break; case 4: - if (selenitic.emitterEnabledCrystal != value) { - selenitic.emitterEnabledCrystal = value; + if (_state.emitterEnabledCrystal != value) { + _state.emitterEnabledCrystal = value; refresh = true; } break; case 5: // Sound receiver opened - if (selenitic.soundReceiverOpened != value) { - selenitic.soundReceiverOpened = value; + if (_state.soundReceiverOpened != value) { + _state.soundReceiverOpened = value; refresh = true; } break; case 6: // Tunnel lights - if (selenitic.tunnelLightsSwitchedOn != value) { - selenitic.tunnelLightsSwitchedOn = value; + if (_state.tunnelLightsSwitchedOn != value) { + _state.tunnelLightsSwitchedOn = value; refresh = true; } break; case 20: // Sound lock sliders - selenitic.soundLockSliderPositions[0] = value; + _state.soundLockSliderPositions[0] = value; break; case 21: - selenitic.soundLockSliderPositions[1] = value; + _state.soundLockSliderPositions[1] = value; break; case 22: - selenitic.soundLockSliderPositions[2] = value; + _state.soundLockSliderPositions[2] = value; break; case 23: - selenitic.soundLockSliderPositions[3] = value; + _state.soundLockSliderPositions[3] = value; break; case 24: - selenitic.soundLockSliderPositions[4] = value; + _state.soundLockSliderPositions[4] = value; break; case 30: _mazeRunnerDoorOpened = value; @@ -592,8 +586,6 @@ void MystScriptParser_Selenitic::o_mazeRunnerSoundRepeat(uint16 op, uint16 var, * Sound receiver sigma button */ void MystScriptParser_Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - debugC(kDebugScript, "Opcode %d: Sound receiver sigma button", op); _vm->_cursor->hideCursor(); @@ -622,7 +614,7 @@ void MystScriptParser_Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uin break; } - _soundReceiverPosition = &selenitic.soundReceiverPositions[source]; + _soundReceiverPosition = &_state.soundReceiverPositions[source]; _vm->_sound->stopBackground(); _vm->_sound->replaceSound(2287); soundReceiverDrawView(); @@ -635,7 +627,7 @@ void MystScriptParser_Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uin _soundReceiverSigmaPressed = true; _vm->_sound->stopBackground(); - _soundReceiverSources[selenitic.soundReceiverCurrentSource]->drawConditionalDataToScreen(1); + _soundReceiverSources[_state.soundReceiverCurrentSource]->drawConditionalDataToScreen(1); soundReceiverDrawView(); @@ -714,8 +706,6 @@ void MystScriptParser_Selenitic::soundReceiverDrawAngle() { * Sound receiver source selection buttons */ void MystScriptParser_Selenitic::o_soundReceiverSource(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - debugC(kDebugScript, "Opcode %d: Sound receiver source", op); if (_soundReceiverSigmaPressed) { @@ -727,12 +717,12 @@ void MystScriptParser_Selenitic::o_soundReceiverSource(uint16 op, uint16 var, ui uint pressedButton = var - 9; - if (selenitic.soundReceiverCurrentSource != pressedButton) { - selenitic.soundReceiverCurrentSource = pressedButton; + if (_state.soundReceiverCurrentSource != pressedButton) { + _state.soundReceiverCurrentSource = pressedButton; _soundReceiverCurrentSource->drawConditionalDataToScreen(0); - _soundReceiverPosition = &selenitic.soundReceiverPositions[pressedButton]; + _soundReceiverPosition = &_state.soundReceiverPositions[pressedButton]; _soundReceiverCurrentSource = _soundReceiverSources[pressedButton]; _vm->_sound->stopSound(); @@ -841,25 +831,24 @@ void MystScriptParser_Selenitic::o_soundLockStartMove(uint16 op, uint16 var, uin void MystScriptParser_Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Sound lock end move", op); - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; MystResourceType10 *slider = soundLockSliderFromVar(var); uint16 *value = 0; switch (var) { case 20: // Sound lock sliders - value = &selenitic.soundLockSliderPositions[0]; + value = &_state.soundLockSliderPositions[0]; break; case 21: - value = &selenitic.soundLockSliderPositions[1]; + value = &_state.soundLockSliderPositions[1]; break; case 22: - value = &selenitic.soundLockSliderPositions[2]; + value = &_state.soundLockSliderPositions[2]; break; case 23: - value = &selenitic.soundLockSliderPositions[3]; + value = &_state.soundLockSliderPositions[3]; break; case 24: - value = &selenitic.soundLockSliderPositions[4]; + value = &_state.soundLockSliderPositions[4]; break; } @@ -899,7 +888,6 @@ void MystScriptParser_Selenitic::soundLockCheckSolution(MystResourceType10 *slid void MystScriptParser_Selenitic::o_soundLockButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Sound lock button", op); - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; bool solved = true; _vm->_sound->pauseBackground(); @@ -907,11 +895,11 @@ void MystScriptParser_Selenitic::o_soundLockButton(uint16 op, uint16 var, uint16 _soundLockButton->drawConditionalDataToScreen(1); _vm->_cursor->hideCursor(); - soundLockCheckSolution(_soundLockSlider1, selenitic.soundLockSliderPositions[0], 5, solved); - soundLockCheckSolution(_soundLockSlider2, selenitic.soundLockSliderPositions[1], 9, solved); - soundLockCheckSolution(_soundLockSlider3, selenitic.soundLockSliderPositions[2], 0, solved); - soundLockCheckSolution(_soundLockSlider4, selenitic.soundLockSliderPositions[3], 6, solved); - soundLockCheckSolution(_soundLockSlider5, selenitic.soundLockSliderPositions[4], 7, solved); + soundLockCheckSolution(_soundLockSlider1, _state.soundLockSliderPositions[0], 5, solved); + soundLockCheckSolution(_soundLockSlider2, _state.soundLockSliderPositions[1], 9, solved); + soundLockCheckSolution(_soundLockSlider3, _state.soundLockSliderPositions[2], 0, solved); + soundLockCheckSolution(_soundLockSlider4, _state.soundLockSliderPositions[3], 6, solved); + soundLockCheckSolution(_soundLockSlider5, _state.soundLockSliderPositions[4], 7, solved); _vm->_sound->replaceSound(1148); _vm->_sound->resumeBackground(); @@ -1006,9 +994,7 @@ void MystScriptParser_Selenitic::soundReceiverIncreaseSpeed() { } void MystScriptParser_Selenitic::soundReceiverUpdateSound() { - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - - uint16 soundId = soundReceiverCurrentSound(selenitic.soundReceiverCurrentSource, *_soundReceiverPosition); + uint16 soundId = soundReceiverCurrentSound(_state.soundReceiverCurrentSource, *_soundReceiverPosition); _vm->_sound->replaceSound(soundId); } @@ -1064,35 +1050,31 @@ uint16 MystScriptParser_Selenitic::soundReceiverCurrentSound(uint16 source, uint } void MystScriptParser_Selenitic::soundReceiverSolution(uint16 source, uint16 &solution, bool &enabled) { - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - switch (source) { case 0: - enabled = selenitic.emitterEnabledWater; + enabled = _state.emitterEnabledWater; solution = 1534; break; case 1: - enabled = selenitic.emitterEnabledVolcano; + enabled = _state.emitterEnabledVolcano; solution = 1303; break; case 2: - enabled = selenitic.emitterEnabledClock; + enabled = _state.emitterEnabledClock; solution = 556; break; case 3: - enabled = selenitic.emitterEnabledCrystal; + enabled = _state.emitterEnabledCrystal; solution = 150; break; case 4: - enabled = selenitic.emitterEnabledWind; + enabled = _state.emitterEnabledWind; solution = 2122; break; } } void MystScriptParser_Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - debugC(kDebugScript, "Opcode %d: Sound receiver init", op); // Used for Card 1245 (Sound Receiver) @@ -1112,16 +1094,14 @@ void MystScriptParser_Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uin _soundReceiverAngle3 = static_cast<MystResourceType8 *>(_vm->_resources[12]); _soundReceiverAngle4 = static_cast<MystResourceType8 *>(_vm->_resources[13]); - uint16 currentSource = selenitic.soundReceiverCurrentSource; - _soundReceiverPosition = &selenitic.soundReceiverPositions[currentSource]; + uint16 currentSource = _state.soundReceiverCurrentSource; + _soundReceiverPosition = &_state.soundReceiverPositions[currentSource]; _soundReceiverCurrentSource = _soundReceiverSources[currentSource]; _soundReceiverSigmaPressed = false; } void MystScriptParser_Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - MystVariables::Selenitic &selenitic = _vm->_saveLoad->_v->selenitic; - debugC(kDebugScript, "Opcode %d: Sound lock init", op); for (uint i = 0; i < _vm->_resources.size(); i++) { @@ -1129,23 +1109,23 @@ void MystScriptParser_Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 switch (_vm->_resources[i]->getType8Var()) { case 20: _soundLockSlider1 = static_cast<MystResourceType10 *>(_vm->_resources[i]); - _soundLockSlider1->setStep(selenitic.soundLockSliderPositions[0]); + _soundLockSlider1->setStep(_state.soundLockSliderPositions[0]); break; case 21: _soundLockSlider2 = static_cast<MystResourceType10 *>(_vm->_resources[i]); - _soundLockSlider2->setStep(selenitic.soundLockSliderPositions[1]); + _soundLockSlider2->setStep(_state.soundLockSliderPositions[1]); break; case 22: _soundLockSlider3 = static_cast<MystResourceType10 *>(_vm->_resources[i]); - _soundLockSlider3->setStep(selenitic.soundLockSliderPositions[2]); + _soundLockSlider3->setStep(_state.soundLockSliderPositions[2]); break; case 23: _soundLockSlider4 = static_cast<MystResourceType10 *>(_vm->_resources[i]); - _soundLockSlider4->setStep(selenitic.soundLockSliderPositions[3]); + _soundLockSlider4->setStep(_state.soundLockSliderPositions[3]); break; case 24: _soundLockSlider5 = static_cast<MystResourceType10 *>(_vm->_resources[i]); - _soundLockSlider5->setStep(selenitic.soundLockSliderPositions[4]); + _soundLockSlider5->setStep(_state.soundLockSliderPositions[4]); break; } } else if (_vm->_resources[i]->type == kMystConditionalImage) { diff --git a/engines/mohawk/myst_stacks/selenitic.h b/engines/mohawk/myst_stacks/selenitic.h index cb0f31f93b..54e9db4d66 100644 --- a/engines/mohawk/myst_stacks/selenitic.h +++ b/engines/mohawk/myst_stacks/selenitic.h @@ -76,6 +76,8 @@ private: void soundReceiver_run(); + MystGameState::Selenitic &_state; + bool _soundReceiverRunning; bool _soundReceiverSigmaPressed; // 6 MystResourceType8 *_soundReceiverSources[5]; // 92 -> 108 diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp index 7bd2ee1021..eb281d14e1 100644 --- a/engines/mohawk/myst_stacks/stoneship.cpp +++ b/engines/mohawk/myst_stacks/stoneship.cpp @@ -35,7 +35,8 @@ namespace Mohawk { -MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) : + MystScriptParser(vm), _state(vm->_gameState->_stoneship) { setupOpcodes(); } @@ -92,9 +93,6 @@ void MystScriptParser_Stoneship::runPersistentScripts() { } uint16 MystScriptParser_Stoneship::getVar(uint16 var) { -// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; -// MystVariables::Stoneship &stoneship = _vm->_saveLoad->_v->stoneship; - switch(var) { //case 0: // Water Drained From Lighthouse / Right Button Of Pump // return 0; // Water Present / Button Dark @@ -152,9 +150,6 @@ uint16 MystScriptParser_Stoneship::getVar(uint16 var) { } void MystScriptParser_Stoneship::toggleVar(uint16 var) { -// MystVariables::Globals &globals = _vm->_saveLoad->_v->globals; -// MystVariables::Stoneship &stoneship = _vm->_saveLoad->_v->stoneship; - switch(var) { default: MystScriptParser::toggleVar(var); @@ -163,7 +158,6 @@ void MystScriptParser_Stoneship::toggleVar(uint16 var) { } bool MystScriptParser_Stoneship::setVarValue(uint16 var, uint16 value) { -// MystVariables::Stoneship &stoneship = _vm->_saveLoad->_v->stoneship; bool refresh = false; switch (var) { diff --git a/engines/mohawk/myst_stacks/stoneship.h b/engines/mohawk/myst_stacks/stoneship.h index a0c7151bc1..9e65b9c33f 100644 --- a/engines/mohawk/myst_stacks/stoneship.h +++ b/engines/mohawk/myst_stacks/stoneship.h @@ -85,6 +85,8 @@ private: DECLARE_OPCODE(opcode_210); DECLARE_OPCODE(opcode_300); + + MystGameState::Stoneship &_state; }; } |