aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Bouclet2018-05-28 20:22:29 +0200
committerBastien Bouclet2018-06-13 07:55:55 +0200
commit47ddd9c2144c236e2b3bc0dd0f8349ae8657efb7 (patch)
treed8cdf846dab9e4c4f62e3f19baa57db2b90e14fe
parentea60aef8a8018ac75ea9a5b507f4140eafe2d660 (diff)
downloadscummvm-rg350-47ddd9c2144c236e2b3bc0dd0f8349ae8657efb7.tar.gz
scummvm-rg350-47ddd9c2144c236e2b3bc0dd0f8349ae8657efb7.tar.bz2
scummvm-rg350-47ddd9c2144c236e2b3bc0dd0f8349ae8657efb7.zip
MOHAWK: MYST: Move the current stack id to ScriptParser
-rw-r--r--engines/mohawk/console.cpp23
-rw-r--r--engines/mohawk/dialogs.cpp4
-rw-r--r--engines/mohawk/myst.cpp65
-rw-r--r--engines/mohawk/myst.h8
-rw-r--r--engines/mohawk/myst_areas.cpp46
-rw-r--r--engines/mohawk/myst_card.cpp20
-rw-r--r--engines/mohawk/myst_scripts.cpp5
-rw-r--r--engines/mohawk/myst_scripts.h7
-rw-r--r--engines/mohawk/myst_stacks/channelwood.cpp2
-rw-r--r--engines/mohawk/myst_stacks/credits.cpp2
-rw-r--r--engines/mohawk/myst_stacks/demo.cpp4
-rw-r--r--engines/mohawk/myst_stacks/dni.cpp2
-rw-r--r--engines/mohawk/myst_stacks/intro.cpp4
-rw-r--r--engines/mohawk/myst_stacks/intro.h2
-rw-r--r--engines/mohawk/myst_stacks/makingof.cpp2
-rw-r--r--engines/mohawk/myst_stacks/mechanical.cpp2
-rw-r--r--engines/mohawk/myst_stacks/myst.cpp4
-rw-r--r--engines/mohawk/myst_stacks/myst.h2
-rw-r--r--engines/mohawk/myst_stacks/preview.cpp2
-rw-r--r--engines/mohawk/myst_stacks/selenitic.cpp2
-rw-r--r--engines/mohawk/myst_stacks/slides.cpp2
-rw-r--r--engines/mohawk/myst_stacks/stoneship.cpp2
-rw-r--r--engines/mohawk/myst_state.cpp4
-rw-r--r--engines/mohawk/myst_state.h4
24 files changed, 111 insertions, 109 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 2251ce097f..bd0e5c7551 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -100,9 +100,9 @@ bool MystConsole::Cmd_Var(int argc, const char **argv) {
}
if (argc > 2)
- _vm->_scriptParser->setVarValue((uint16)atoi(argv[1]), (uint16)atoi(argv[2]));
+ _vm->_stack->setVarValue((uint16)atoi(argv[1]), (uint16)atoi(argv[2]));
- debugPrintf("%d = %d\n", (uint16)atoi(argv[1]), _vm->_scriptParser->getVar((uint16)atoi(argv[1])));
+ debugPrintf("%d = %d\n", (uint16)atoi(argv[1]), _vm->_stack->getVar((uint16)atoi(argv[1])));
return true;
}
@@ -138,7 +138,7 @@ static const uint16 default_start_card[12] = {
};
bool MystConsole::Cmd_CurStack(int argc, const char **argv) {
- debugPrintf("Current Stack: %s\n", mystStackNames[_vm->getCurStack()]);
+ debugPrintf("Current Stack: %s\n", mystStackNames[_vm->_stack->getStackId()]);
return true;
}
@@ -178,7 +178,7 @@ bool MystConsole::Cmd_ChangeStack(int argc, const char **argv) {
else
card = default_start_card[stackNum - 1];
- _vm->changeToStack(stackNum - 1, card, 0, 0);
+ _vm->changeToStack(static_cast<MystStack>(stackNum - 1), card, 0, 0);
return false;
}
@@ -290,7 +290,7 @@ bool MystConsole::Cmd_DisableInitOpcodes(int argc, const char **argv) {
return true;
}
- _vm->_scriptParser->disablePersistentScripts();
+ _vm->_stack->disablePersistentScripts();
return true;
}
@@ -331,9 +331,12 @@ bool MystConsole::Cmd_QuickTest(int argc, const char **argv) {
// Go through all the ages, all the views and click random stuff
for (uint i = 0; i < ARRAYSIZE(mystStackNames); i++) {
- if (i == 2 || i == 5 || i == 9 || i == 10) continue;
- debug("Loading stack %s", mystStackNames[i]);
- _vm->changeToStack(i, default_start_card[i], 0, 0);
+ MystStack stackId = static_cast<MystStack>(i);
+ if (stackId == kDemoStack || stackId == kMakingOfStack
+ || stackId == kDemoSlidesStack || stackId == kDemoPreviewStack) continue;
+
+ debug("Loading stack %s", mystStackNames[stackId]);
+ _vm->changeToStack(stackId, default_start_card[stackId], 0, 0);
Common::Array<uint16> ids = _vm->getResourceIDList(ID_VIEW);
for (uint j = 0; j < ids.size(); j++) {
@@ -355,9 +358,9 @@ bool MystConsole::Cmd_QuickTest(int argc, const char **argv) {
_vm->doFrame();
- if (_vm->getCurStack() != i) {
+ if (_vm->_stack->getStackId() != stackId) {
// Clicking may have linked us to another age
- _vm->changeToStack(i, default_start_card[i], 0, 0);
+ _vm->changeToStack(stackId, default_start_card[stackId], 0, 0);
}
}
}
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index b9575ce963..f4433152a8 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -209,13 +209,13 @@ void MystOptionsDialog::open() {
_dropPageButton->setEnabled(canDropPage);
if (_showMapButton) {
- bool canShowMap = _vm->isInteractive() && _vm->_scriptParser->getMap();
+ bool canShowMap = _vm->isInteractive() && _vm->_stack->getMap();
_showMapButton->setEnabled(canShowMap);
}
if (_returnToMenuButton) {
// Return to menu button is not enabled on the menu
- bool canReturnToMenu = _vm->isInteractive() && _vm->getCurStack() != kDemoStack;
+ bool canReturnToMenu = _vm->isInteractive() && _vm->_stack->getStackId() != kDemoStack;
_returnToMenuButton->setEnabled(canReturnToMenu);
}
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 3f7264720b..eda9da501c 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -71,7 +71,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_currentCursor = 0;
_mainCursor = kDefaultMystCursor;
_showResourceRects = false;
- _curStack = 0;
_lastSaveTime = 0;
_sound = nullptr;
@@ -249,7 +248,7 @@ void MohawkEngine_Myst::playMovieBlocking(const Common::String &name, MystStack
waitUntilMovieEnds(video);
}
-void MohawkEngine_Myst::playFlybyMovie(uint16 stack, uint16 card) {
+void MohawkEngine_Myst::playFlybyMovie(MystStack stack, uint16 card) {
static const uint16 kMasterpieceOnly = 0xFFFF;
// Play Flyby Entry Movie on Masterpiece Edition.
@@ -384,7 +383,7 @@ void MohawkEngine_Myst::doFrame() {
_video->updateMovies();
if (isInteractive()) {
_waitingOnBlockingOperation = true;
- _scriptParser->runPersistentScripts();
+ _stack->runPersistentScripts();
_waitingOnBlockingOperation = false;
}
@@ -433,7 +432,7 @@ void MohawkEngine_Myst::doFrame() {
}
if (_needsShowMap) {
- _scriptParser->showMap();
+ _stack->showMap();
_needsShowMap = false;
}
@@ -533,8 +532,8 @@ void MohawkEngine_Myst::pauseEngineIntern(bool pause) {
}
}
-void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcSound, uint16 linkDstSound) {
- debug(2, "changeToStack(%d)", stack);
+void MohawkEngine_Myst::changeToStack(MystStack stackId, uint16 card, uint16 linkSrcSound, uint16 linkDstSound) {
+ debug(2, "changeToStack(%d)", stackId);
// Fill screen with black and empty cursor
_cursor->setCursor(0);
@@ -546,8 +545,8 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
// In Myst ME, play a fullscreen flyby movie, except when loading saves.
// Also play a flyby when first linking to Myst.
if (getFeatures() & GF_ME
- && (_curStack != kIntroStack || (stack == kMystStack && card == 4134))) {
- playFlybyMovie(stack, card);
+ && ((_stack && _stack->getStackId() != kIntroStack) || (stackId == kMystStack && card == 4134))) {
+ playFlybyMovie(stackId, card);
}
_sound->stopBackground();
@@ -565,55 +564,53 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
_card.reset();
}
- _curStack = stack;
-
- switch (_curStack) {
+ switch (stackId) {
case kChannelwoodStack:
_gameState->_globals.currentAge = kChannelwood;
- _scriptParser = MystScriptParserPtr(new MystStacks::Channelwood(this));
+ _stack = MystScriptParserPtr(new MystStacks::Channelwood(this));
break;
case kCreditsStack:
- _scriptParser = MystScriptParserPtr(new MystStacks::Credits(this));
+ _stack = MystScriptParserPtr(new MystStacks::Credits(this));
break;
case kDemoStack:
_gameState->_globals.currentAge = kSelenitic;
- _scriptParser = MystScriptParserPtr(new MystStacks::Demo(this));
+ _stack = MystScriptParserPtr(new MystStacks::Demo(this));
break;
case kDniStack:
_gameState->_globals.currentAge = kDni;
- _scriptParser = MystScriptParserPtr(new MystStacks::Dni(this));
+ _stack = MystScriptParserPtr(new MystStacks::Dni(this));
break;
case kIntroStack:
- _scriptParser = MystScriptParserPtr(new MystStacks::Intro(this));
+ _stack = MystScriptParserPtr(new MystStacks::Intro(this));
break;
case kMakingOfStack:
- _scriptParser = MystScriptParserPtr(new MystStacks::MakingOf(this));
+ _stack = MystScriptParserPtr(new MystStacks::MakingOf(this));
break;
case kMechanicalStack:
_gameState->_globals.currentAge = kMechanical;
- _scriptParser = MystScriptParserPtr(new MystStacks::Mechanical(this));
+ _stack = MystScriptParserPtr(new MystStacks::Mechanical(this));
break;
case kMystStack:
_gameState->_globals.currentAge = kMystLibrary;
- _scriptParser = MystScriptParserPtr(new MystStacks::Myst(this));
+ _stack = MystScriptParserPtr(new MystStacks::Myst(this));
break;
case kDemoPreviewStack:
- _scriptParser = MystScriptParserPtr(new MystStacks::Preview(this));
+ _stack = MystScriptParserPtr(new MystStacks::Preview(this));
break;
case kSeleniticStack:
_gameState->_globals.currentAge = kSelenitic;
- _scriptParser = MystScriptParserPtr(new MystStacks::Selenitic(this));
+ _stack = MystScriptParserPtr(new MystStacks::Selenitic(this));
break;
case kDemoSlidesStack:
_gameState->_globals.currentAge = kStoneship;
- _scriptParser = MystScriptParserPtr(new MystStacks::Slides(this));
+ _stack = MystScriptParserPtr(new MystStacks::Slides(this));
break;
case kStoneshipStack:
_gameState->_globals.currentAge = kStoneship;
- _scriptParser = MystScriptParserPtr(new MystStacks::Stoneship(this));
+ _stack = MystScriptParserPtr(new MystStacks::Stoneship(this));
break;
default:
- error("Unknown Myst stack %d", _curStack);
+ error("Unknown Myst stack %d", stackId);
}
// If the array is empty, add a new one. Otherwise, delete the first
@@ -625,8 +622,8 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
_mhk[0] = new MohawkArchive();
}
- if (!_mhk[0]->openFile(mystFiles[_curStack]))
- error("Could not open %s", mystFiles[_curStack]);
+ if (!_mhk[0]->openFile(mystFiles[stackId]))
+ error("Could not open %s", mystFiles[stackId]);
// Clear the resource cache and the image cache
_cache.clear();
@@ -641,7 +638,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
debug(2, "changeToCard(%d)", card);
- _scriptParser->disablePersistentScripts();
+ _stack->disablePersistentScripts();
_video->stopVideos();
@@ -698,7 +695,7 @@ void MohawkEngine_Myst::refreshCursor() {
}
void MohawkEngine_Myst::redrawResource(MystAreaImageSwitch *resource, bool update) {
- resource->drawConditionalDataToScreen(_scriptParser->getVar(resource->getImageSwitchVar()), update);
+ resource->drawConditionalDataToScreen(_stack->getVar(resource->getImageSwitchVar()), update);
}
MystArea *MohawkEngine_Myst::loadResource(Common::SeekableReadStream *rlstStream, MystArea *parent) {
@@ -772,7 +769,7 @@ bool MohawkEngine_Myst::hasGameSaveSupport() const {
}
bool MohawkEngine_Myst::isInteractive() {
- return !_scriptParser->isScriptRunning() && !_waitingOnBlockingOperation;
+ return !_stack->isScriptRunning() && !_waitingOnBlockingOperation;
}
bool MohawkEngine_Myst::canLoadGameStateCurrently() {
@@ -798,7 +795,7 @@ bool MohawkEngine_Myst::canSaveGameStateCurrently() {
}
// There's a limited number of stacks the game can save in
- switch (_curStack) {
+ switch (_stack->getStackId()) {
case kChannelwoodStack:
case kDniStack:
case kMechanicalStack:
@@ -806,9 +803,9 @@ bool MohawkEngine_Myst::canSaveGameStateCurrently() {
case kSeleniticStack:
case kStoneshipStack:
return true;
+ default:
+ return false;
}
-
- return false;
}
void MohawkEngine_Myst::dropPage() {
@@ -825,7 +822,7 @@ void MohawkEngine_Myst::dropPage() {
// Redraw page area
if (whitePage && _gameState->_globals.currentAge == kMystLibrary) {
- _scriptParser->toggleVar(41);
+ _stack->toggleVar(41);
_card->redrawArea(41);
} else if (bluePage) {
if (page == kBlueFirePlacePage) {
@@ -899,7 +896,7 @@ void MohawkEngine_Myst::applySoundBlock(const MystSoundBlock &block) {
uint16 soundActionVolume = 0;
if (block.sound == kMystSoundActionConditional) {
- uint16 soundVarValue = _scriptParser->getVar(block.soundVar);
+ uint16 soundVarValue = _stack->getVar(block.soundVar);
if (soundVarValue >= block.soundList.size())
warning("Conditional sound variable outside range");
else {
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 1bd51e8aa8..d626221ab3 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -136,11 +136,10 @@ public:
Common::Array<uint16> getResourceIDList(uint32 type) const;
void cachePreload(uint32 tag, uint16 id);
- void changeToStack(uint16 stack, uint16 card, uint16 linkSrcSound, uint16 linkDstSound);
+ void changeToStack(MystStack stackId, uint16 card, uint16 linkSrcSound, uint16 linkDstSound);
void changeToCard(uint16 card, TransitionType transition);
MystCard *getCard() { return _card.get(); };
MystCardPtr getCardPtr() { return _card; };
- uint16 getCurStack() { return _curStack; }
void setMainCursor(uint16 cursor);
uint16 getMainCursor() { return _mainCursor; }
void refreshCursor();
@@ -163,7 +162,7 @@ public:
MystSound *_sound;
MystGraphics *_gfx;
MystGameState *_gameState;
- MystScriptParserPtr _scriptParser;
+ MystScriptParserPtr _stack;
Common::RandomSource *_rnd;
MystArea *loadResource(Common::SeekableReadStream *rlstStream, MystArea *parent);
@@ -175,7 +174,7 @@ public:
VideoEntryPtr playMovie(const Common::String &name, MystStack stack);
VideoEntryPtr findVideo(const Common::String &name, MystStack stack);
void playMovieBlocking(const Common::String &name, MystStack stack, uint16 x, uint16 y);
- void playFlybyMovie(uint16 stack, uint16 card);
+ void playFlybyMovie(MystStack stack, uint16 card);
void waitUntilMovieEnds(const VideoEntryPtr &video);
void playSoundBlocking(uint16 id);
@@ -201,7 +200,6 @@ private:
MystOptionsDialog *_optionsDialog;
ResourceCache _cache;
- uint16 _curStack;
MystCardPtr _card;
uint32 _lastSaveTime;
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 5fc6cbeed6..d03c78a497 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -94,8 +94,8 @@ void MystArea::handleMouseUp() {
break;
}
- _vm->_scriptParser->setInvokingResource(this);
- _vm->_scriptParser->runOpcode(opcode, 0);
+ _vm->_stack->setInvokingResource(this);
+ _vm->_stack->runOpcode(opcode, 0);
}
bool MystArea::canBecomeActive() {
@@ -104,7 +104,7 @@ bool MystArea::canBecomeActive() {
bool MystArea::unreachableZipDest() {
return (_flags & kMystZipModeEnableFlag)
- && !_vm->_gameState->isReachableZipDest(_vm->getCurStack() , _dest);
+ && !_vm->_gameState->isReachableZipDest(_vm->_stack->getStackId() , _dest);
}
bool MystArea::isEnabled() {
@@ -143,14 +143,14 @@ MystAreaAction::MystAreaAction(MohawkEngine_Myst *vm, ResourceType type, Common:
MystArea(vm, type, rlstStream, parent) {
debugC(kDebugResource, "\tResource Type 5 Script:");
- _script = vm->_scriptParser->readScript(rlstStream, kMystScriptNormal);
+ _script = vm->_stack->readScript(rlstStream, kMystScriptNormal);
}
void MystAreaAction::handleMouseUp() {
// Keep a reference to the stack so it is not freed if a script switches to another stack
- MystScriptParserPtr parser = _vm->_scriptParser;
+ MystScriptParserPtr stack = _vm->_stack;
- parser->runScript(_script, this);
+ stack->runScript(_script, this);
}
const Common::String MystAreaAction::describe() {
@@ -160,7 +160,7 @@ const Common::String MystAreaAction::describe() {
desc += " ops:";
for (uint i = 0; i < _script.size(); i++)
- desc += " " + _vm->_scriptParser->getOpcodeDesc(_script[i].opcode);
+ desc += " " + _vm->_stack->getOpcodeDesc(_script[i].opcode);
}
return desc;
@@ -320,7 +320,7 @@ void MystAreaActionSwitch::doSwitch(AreaHandler handler) {
else if (_subResources.size() != 0)
warning("Action switch resource with _numSubResources of %d, but no control variable", _subResources.size());
} else {
- uint16 varValue = _vm->_scriptParser->getVar(_actionSwitchVar);
+ uint16 varValue = _vm->_stack->getVar(_actionSwitchVar);
if (_subResources.size() == 1 && varValue != 0)
(_subResources[0]->*handler)();
@@ -404,7 +404,7 @@ void MystAreaImageSwitch::drawDataToScreen() {
} else if (_subImages.size() != 0)
warning("Image Switch resource with _numSubImages of %d, but no control variable", _subImages.size());
} else {
- uint16 varValue = _vm->_scriptParser->getVar(_imageSwitchVar);
+ uint16 varValue = _vm->_stack->getVar(_imageSwitchVar);
if (_subImages.size() == 1 && varValue != 0) {
subImageId = 0;
@@ -586,7 +586,7 @@ void MystAreaSlider::handleMouseUp() {
value = _pos.x;
}
- _vm->_scriptParser->setVarValue(_imageSwitchVar, value);
+ _vm->_stack->setVarValue(_imageSwitchVar, value);
MystAreaDrag::handleMouseUp();
}
@@ -714,32 +714,32 @@ void MystAreaDrag::handleMouseDown() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
setPositionClipping(mouse, _pos);
- _vm->_scriptParser->setInvokingResource(this);
- _vm->_scriptParser->runOpcode(_mouseDownOpcode, _imageSwitchVar);
+ _vm->_stack->setInvokingResource(this);
+ _vm->_stack->runOpcode(_mouseDownOpcode, _imageSwitchVar);
}
void MystAreaDrag::handleMouseUp() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
setPositionClipping(mouse, _pos);
- _vm->_scriptParser->setInvokingResource(this);
- _vm->_scriptParser->runOpcode(_mouseUpOpcode, _imageSwitchVar);
+ _vm->_stack->setInvokingResource(this);
+ _vm->_stack->runOpcode(_mouseUpOpcode, _imageSwitchVar);
}
void MystAreaDrag::handleMouseDrag() {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
setPositionClipping(mouse, _pos);
- _vm->_scriptParser->setInvokingResource(this);
- _vm->_scriptParser->runOpcode(_mouseDragOpcode, _imageSwitchVar);
+ _vm->_stack->setInvokingResource(this);
+ _vm->_stack->runOpcode(_mouseDragOpcode, _imageSwitchVar);
}
const Common::String MystAreaDrag::describe() {
return Common::String::format("%s down: %s drag: %s up: %s",
MystAreaImageSwitch::describe().c_str(),
- _vm->_scriptParser->getOpcodeDesc(_mouseDownOpcode).c_str(),
- _vm->_scriptParser->getOpcodeDesc(_mouseDragOpcode).c_str(),
- _vm->_scriptParser->getOpcodeDesc(_mouseUpOpcode).c_str());
+ _vm->_stack->getOpcodeDesc(_mouseDownOpcode).c_str(),
+ _vm->_stack->getOpcodeDesc(_mouseDragOpcode).c_str(),
+ _vm->_stack->getOpcodeDesc(_mouseUpOpcode).c_str());
}
void MystAreaDrag::setPositionClipping(const Common::Point &mouse, Common::Point &dest) {
@@ -836,13 +836,13 @@ MystAreaHover::MystAreaHover(MohawkEngine_Myst *vm, ResourceType type, Common::S
void MystAreaHover::handleMouseEnter() {
// Pass along the enter opcode to the script parser
// The variable to use is stored in the dest field
- _vm->_scriptParser->runOpcode(_enterOpcode, _dest);
+ _vm->_stack->runOpcode(_enterOpcode, _dest);
}
void MystAreaHover::handleMouseLeave() {
// Pass along the leave opcode (with no parameters) to the script parser
// The variable to use is stored in the dest field
- _vm->_scriptParser->runOpcode(_leaveOpcode, _dest);
+ _vm->_stack->runOpcode(_leaveOpcode, _dest);
}
void MystAreaHover::handleMouseUp() {
@@ -854,8 +854,8 @@ void MystAreaHover::handleMouseUp() {
const Common::String MystAreaHover::describe() {
return Common::String::format("%s enter: %s leave: %s",
MystArea::describe().c_str(),
- _vm->_scriptParser->getOpcodeDesc(_enterOpcode).c_str(),
- _vm->_scriptParser->getOpcodeDesc(_leaveOpcode).c_str());
+ _vm->_stack->getOpcodeDesc(_enterOpcode).c_str(),
+ _vm->_stack->getOpcodeDesc(_leaveOpcode).c_str());
}
} // End of namespace Mohawk
diff --git a/engines/mohawk/myst_card.cpp b/engines/mohawk/myst_card.cpp
index 71b546c047..a58720264d 100644
--- a/engines/mohawk/myst_card.cpp
+++ b/engines/mohawk/myst_card.cpp
@@ -49,7 +49,7 @@ void MystCard::enter() {
_vm->applySoundBlock(_soundBlock);
if (_flags & kMystZipDestination)
- _vm->_gameState->addZipDest(_vm->getCurStack(), _id);
+ _vm->_gameState->addZipDest(_vm->_stack->getStackId(), _id);
// Run the entrance script (if present)
runInitScript();
@@ -184,7 +184,7 @@ void MystCard::loadView() {
// Precache Image Block data
if (!_conditionalImages.empty()) {
for (uint16 i = 0; i < _conditionalImages.size(); i++) {
- uint16 value = _vm->_scriptParser->getVar(_conditionalImages[i].var);
+ uint16 value = _vm->_stack->getVar(_conditionalImages[i].var);
_vm->cachePreload(cacheImageType, _conditionalImages[i].values[value]);
}
} else {
@@ -195,7 +195,7 @@ void MystCard::loadView() {
if (_soundBlock.sound > 0)
_vm->cachePreload(ID_MSND, _soundBlock.sound);
else if (_soundBlock.sound == kMystSoundActionConditional) {
- uint16 value = _vm->_scriptParser->getVar(_soundBlock.soundVar);
+ uint16 value = _vm->_stack->getVar(_soundBlock.soundVar);
if (_soundBlock.soundList[value].action > 0) {
_vm->cachePreload(ID_MSND, _soundBlock.soundList[value].action);
}
@@ -207,7 +207,7 @@ void MystCard::loadView() {
int16 id;
if (_scriptResources[i].type == kResourceSwitch) {
type = _scriptResources[i].switchResourceType;
- uint16 value = _vm->_scriptParser->getVar(_scriptResources[i].switchVar);
+ uint16 value = _vm->_stack->getVar(_scriptResources[i].switchVar);
id = _scriptResources[i].switchResourceIds[value];
} else {
type = _scriptResources[i].type;
@@ -296,7 +296,7 @@ uint16 MystCard::getBackgroundImageId() {
imageToDraw = _mainImage;
else {
for (uint16 i = 0; i < _conditionalImages.size(); i++) {
- uint16 varValue = _vm->_scriptParser->getVar(_conditionalImages[i].var);
+ uint16 varValue = _vm->_stack->getVar(_conditionalImages[i].var);
if (varValue < _conditionalImages[i].values.size())
imageToDraw = _conditionalImages[i].values[varValue];
}
@@ -318,10 +318,10 @@ void MystCard::runInitScript() {
debugC(kDebugINIT, "Running INIT script");
Common::SeekableReadStream *initStream = _vm->getResource(ID_INIT, _initScriptId);
- MystScript script = _vm->_scriptParser->readScript(initStream, kMystScriptInit);
+ MystScript script = _vm->_stack->readScript(initStream, kMystScriptInit);
delete initStream;
- _vm->_scriptParser->runScript(script);
+ _vm->_stack->runScript(script);
}
void MystCard::runExitScript() {
@@ -333,10 +333,10 @@ void MystCard::runExitScript() {
debugC(kDebugEXIT, "Running EXIT script");
Common::SeekableReadStream *exitStream = _vm->getResource(ID_EXIT, _exitScriptId);
- MystScript script = _vm->_scriptParser->readScript(exitStream, kMystScriptExit);
+ MystScript script = _vm->_stack->readScript(exitStream, kMystScriptExit);
delete exitStream;
- _vm->_scriptParser->runScript(script);
+ _vm->_stack->runScript(script);
}
void MystCard::drawResourceRects() {
@@ -406,7 +406,7 @@ int16 MystCard::getActiveResourceCursor() {
for (uint16 i = 0; i < _cursorHints.size(); i++) {
if (_activeResource && _resources[_cursorHints[i].id] == _activeResource && _activeResource->isEnabled()) {
if (_cursorHints[i].cursor == -1) {
- uint16 var_value = _vm->_scriptParser->getVar(_cursorHints[i].variableHint.var);
+ uint16 var_value = _vm->_stack->getVar(_cursorHints[i].variableHint.var);
if (var_value >= _cursorHints[i].variableHint.values.size())
warning("Variable %d Out of Range in variable HINT Resource %d", _cursorHints[i].variableHint.var,
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 9403bebda7..a2a0c5e171 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -44,7 +44,7 @@ MystScriptEntry::MystScriptEntry() {
opcode = 0;
}
-const uint8 MystScriptParser::_stackMap[11] = {
+const MystStack MystScriptParser::_stackMap[11] = {
kSeleniticStack,
kStoneshipStack,
kMystStack,
@@ -74,8 +74,9 @@ const uint16 MystScriptParser::_startCard[11] = {
// NOTE: Credits Start Card is 10000
-MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) :
+MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm, MystStack stackId) :
_vm(vm),
+ _stackId(stackId),
_globals(vm->_gameState->_globals) {
setupCommonOpcodes();
_invokingResource = nullptr;
diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h
index f89a76e63a..38be09c8d6 100644
--- a/engines/mohawk/myst_scripts.h
+++ b/engines/mohawk/myst_scripts.h
@@ -60,7 +60,7 @@ typedef Common::Array<MystScriptEntry> MystScript;
class MystScriptParser {
public:
- explicit MystScriptParser(MohawkEngine_Myst *vm);
+ MystScriptParser(MohawkEngine_Myst *vm, MystStack stackId);
virtual ~MystScriptParser();
void runScript(const MystScript &script, MystArea *invokingResource = nullptr);
@@ -83,6 +83,7 @@ public:
virtual void toggleVar(uint16 var);
virtual bool setVarValue(uint16 var, uint16 value);
+ MystStack getStackId() const { return _stackId; }
virtual uint16 getMap() { return 0; }
void showMap();
@@ -166,7 +167,7 @@ protected:
int16 _tempVar; // Generic temp var used by the scripts
uint32 _startTime; // Generic start time used by the scripts
- static const uint8 _stackMap[];
+ static const MystStack _stackMap[];
static const uint16 _startCard[];
void setupCommonOpcodes();
@@ -188,6 +189,8 @@ private:
MystArea *_invokingResource;
int32 _scriptNestingLevel;
+ const MystStack _stackId;
+
Common::String describeCommand(const MystOpcode &command, uint16 var, const ArgumentsArray &args);
};
diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp
index d1281fa5e0..7e4e5e12b1 100644
--- a/engines/mohawk/myst_stacks/channelwood.cpp
+++ b/engines/mohawk/myst_stacks/channelwood.cpp
@@ -38,7 +38,7 @@ namespace Mohawk {
namespace MystStacks {
Channelwood::Channelwood(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+ MystScriptParser(vm, kChannelwoodStack),
_state(vm->_gameState->_channelwood),
_valveVar(0),
_siriusDrawerState(0),
diff --git a/engines/mohawk/myst_stacks/credits.cpp b/engines/mohawk/myst_stacks/credits.cpp
index 135aded96c..423dc9c216 100644
--- a/engines/mohawk/myst_stacks/credits.cpp
+++ b/engines/mohawk/myst_stacks/credits.cpp
@@ -37,7 +37,7 @@ namespace MystStacks {
// NOTE: Credits Start Card is 10000
Credits::Credits(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+ MystScriptParser(vm, kCreditsStack),
_creditsRunning(false),
_curImage(0) {
setupOpcodes();
diff --git a/engines/mohawk/myst_stacks/demo.cpp b/engines/mohawk/myst_stacks/demo.cpp
index d2ba70c198..b98a16d73e 100644
--- a/engines/mohawk/myst_stacks/demo.cpp
+++ b/engines/mohawk/myst_stacks/demo.cpp
@@ -31,7 +31,7 @@ namespace Mohawk {
namespace MystStacks {
Demo::Demo(MohawkEngine_Myst *vm) :
- Intro(vm),
+ Intro(vm, kDemoStack),
_returnToMenuRunning(false),
_returnToMenuStep(0),
_returnToMenuNextTime(0) {
@@ -86,7 +86,7 @@ void Demo::returnToMenu_run() {
if (time < _returnToMenuNextTime)
return;
- switch (_returnToMenuStep){
+ switch (_returnToMenuStep) {
case 0:
_vm->_gfx->fadeToBlack();
_vm->changeToCard(2003, kNoTransition);
diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp
index a38b5d3857..bb1adf2353 100644
--- a/engines/mohawk/myst_stacks/dni.cpp
+++ b/engines/mohawk/myst_stacks/dni.cpp
@@ -34,7 +34,7 @@ namespace Mohawk {
namespace MystStacks {
Dni::Dni(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+ MystScriptParser(vm, kDniStack),
_notSeenAtrus(true),
_atrusRunning(false),
_waitForLoop(false),
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index 9e03713b0f..f6a7987b25 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -31,8 +31,8 @@
namespace Mohawk {
namespace MystStacks {
-Intro::Intro(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+Intro::Intro(MohawkEngine_Myst *vm, MystStack stackId) :
+ MystScriptParser(vm, stackId),
_introMoviesRunning(false),
_introStep(0),
_linkBookRunning(false),
diff --git a/engines/mohawk/myst_stacks/intro.h b/engines/mohawk/myst_stacks/intro.h
index ec78199802..06a1e03290 100644
--- a/engines/mohawk/myst_stacks/intro.h
+++ b/engines/mohawk/myst_stacks/intro.h
@@ -38,7 +38,7 @@ namespace MystStacks {
class Intro : public MystScriptParser {
public:
- explicit Intro(MohawkEngine_Myst *vm);
+ explicit Intro(MohawkEngine_Myst *vm, MystStack stackId = kIntroStack);
~Intro() override;
void disablePersistentScripts() override;
diff --git a/engines/mohawk/myst_stacks/makingof.cpp b/engines/mohawk/myst_stacks/makingof.cpp
index 4e0ce516b8..7e57f98aa1 100644
--- a/engines/mohawk/myst_stacks/makingof.cpp
+++ b/engines/mohawk/myst_stacks/makingof.cpp
@@ -31,7 +31,7 @@ namespace Mohawk {
namespace MystStacks {
MakingOf::MakingOf(MohawkEngine_Myst *vm) :
- MystScriptParser(vm) {
+ MystScriptParser(vm, kMakingOfStack) {
setupOpcodes();
}
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 495f40bee2..5c0e273913 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -37,7 +37,7 @@ namespace Mohawk {
namespace MystStacks {
Mechanical::Mechanical(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+ MystScriptParser(vm, kMechanicalStack),
_state(vm->_gameState->_mechanical) {
setupOpcodes();
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index a3e5685be1..03f4a3faf7 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -37,8 +37,8 @@
namespace Mohawk {
namespace MystStacks {
-Myst::Myst(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+Myst::Myst(MohawkEngine_Myst *vm, MystStack stackId) :
+ MystScriptParser(vm, stackId),
_state(_vm->_gameState->_myst),
_towerRotationCenter(Common::Point(383, 124)) {
setupOpcodes();
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index ee89af115d..3739630379 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -37,7 +37,7 @@ namespace MystStacks {
class Myst : public MystScriptParser {
public:
- explicit Myst(MohawkEngine_Myst *vm);
+ explicit Myst(MohawkEngine_Myst *vm, MystStack stackId = kMystStack);
~Myst() override;
void disablePersistentScripts() override;
diff --git a/engines/mohawk/myst_stacks/preview.cpp b/engines/mohawk/myst_stacks/preview.cpp
index 348a195dea..8348c45478 100644
--- a/engines/mohawk/myst_stacks/preview.cpp
+++ b/engines/mohawk/myst_stacks/preview.cpp
@@ -35,7 +35,7 @@ namespace Mohawk {
namespace MystStacks {
Preview::Preview(MohawkEngine_Myst *vm) :
- Myst(vm) {
+ Myst(vm, kDemoPreviewStack) {
setupOpcodes();
_vm->_cursor->hideCursor();
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 8d95cb5172..4ef7828a69 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -37,7 +37,7 @@ namespace Mohawk {
namespace MystStacks {
Selenitic::Selenitic(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+ MystScriptParser(vm, kSeleniticStack),
_state(vm->_gameState->_selenitic) {
setupOpcodes();
diff --git a/engines/mohawk/myst_stacks/slides.cpp b/engines/mohawk/myst_stacks/slides.cpp
index 25d5cf480d..7524dde77d 100644
--- a/engines/mohawk/myst_stacks/slides.cpp
+++ b/engines/mohawk/myst_stacks/slides.cpp
@@ -34,7 +34,7 @@ namespace Mohawk {
namespace MystStacks {
Slides::Slides(MohawkEngine_Myst *vm) :
- MystScriptParser(vm) {
+ MystScriptParser(vm, kDemoSlidesStack) {
setupOpcodes();
_vm->_cursor->hideCursor();
diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp
index 0ae78c17d8..3791972325 100644
--- a/engines/mohawk/myst_stacks/stoneship.cpp
+++ b/engines/mohawk/myst_stacks/stoneship.cpp
@@ -38,7 +38,7 @@ namespace Mohawk {
namespace MystStacks {
Stoneship::Stoneship(MohawkEngine_Myst *vm) :
- MystScriptParser(vm),
+ MystScriptParser(vm, kStoneshipStack),
_state(vm->_gameState->_stoneship) {
setupOpcodes();
diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp
index c65ece55d5..a0df54f8a1 100644
--- a/engines/mohawk/myst_state.cpp
+++ b/engines/mohawk/myst_state.cpp
@@ -532,7 +532,7 @@ void MystGameState::deleteSave(int slot) {
g_system->getSavefileManager()->removeSavefile(metadataFilename);
}
-void MystGameState::addZipDest(uint16 stack, uint16 view) {
+void MystGameState::addZipDest(MystStack stack, uint16 view) {
ZipDests *zipDests = nullptr;
// The demo has no zip dest storage
@@ -576,7 +576,7 @@ void MystGameState::addZipDest(uint16 stack, uint16 view) {
(*zipDests)[firstEmpty] = view;
}
-bool MystGameState::isReachableZipDest(uint16 stack, uint16 view) {
+bool MystGameState::isReachableZipDest(MystStack stack, uint16 view) {
// Zip mode enabled
if (!_globals.zipMode)
return false;
diff --git a/engines/mohawk/myst_state.h b/engines/mohawk/myst_state.h
index 28bbf60d63..7dc75c74f4 100644
--- a/engines/mohawk/myst_state.h
+++ b/engines/mohawk/myst_state.h
@@ -113,8 +113,8 @@ public:
bool isAutoSaveAllowed();
static void deleteSave(int slot);
- void addZipDest(uint16 stack, uint16 view);
- bool isReachableZipDest(uint16 stack, uint16 view);
+ void addZipDest(MystStack stack, uint16 view);
+ bool isReachableZipDest(MystStack stack, uint16 view);
/* 8 Game Global Variables :
0 = Unknown - Fixed at 2