diff options
-rw-r--r-- | engines/mohawk/myst_scripts.cpp | 149 | ||||
-rw-r--r-- | engines/mohawk/myst_scripts.h | 9 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/channelwood.cpp | 105 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/credits.cpp | 78 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/mechanical.cpp | 125 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/myst.cpp | 222 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/selenitic.cpp | 123 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/stoneship.cpp | 129 |
8 files changed, 290 insertions, 650 deletions
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp index 9c21887e43..b140542136 100644 --- a/engines/mohawk/myst_scripts.cpp +++ b/engines/mohawk/myst_scripts.cpp @@ -79,10 +79,8 @@ const uint16 MystScriptParser::start_card[11] = { // NOTE: Credits Start Card is 10000 -#define OPCODE(op, x) { op, &MystScriptParser::x, #x } - MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) : _vm(vm) { - setupOpcodes(); + setupCommonOpcodes(); _invokingResource = NULL; _savedCardId = 0; _savedCursorId = 0; @@ -90,69 +88,69 @@ MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) : _vm(vm) { } MystScriptParser::~MystScriptParser() { -} - -void MystScriptParser::setupOpcodes() { - // "invalid" opcodes do not exist or have not been observed - // "unknown" opcodes exist, but their meaning is unknown - - static const MystOpcode myst_opcodes[] = { - // "Standard" Opcodes - OPCODE(0, o_toggleVar), - OPCODE(1, o_setVar), - OPCODE(2, o_changeCardSwitch), - OPCODE(3, o_takePage), - OPCODE(4, o_redrawCard), - // Opcode 5 Not Present - OPCODE(6, o_goToDest), - OPCODE(7, o_goToDest), - OPCODE(8, o_goToDest), - OPCODE(9, o_triggerMovie), - OPCODE(10, o_toggleVarNoRedraw), - // Opcode 11 Not Present - OPCODE(12, o_changeCardSwitch), - OPCODE(13, o_changeCardSwitch), - OPCODE(14, o_drawAreaState), - OPCODE(15, o_redrawAreaForVar), - OPCODE(16, o_changeCardDirectional), - OPCODE(17, o_changeCardPush), - OPCODE(18, o_changeCardPop), - OPCODE(19, o_enableAreas), - OPCODE(20, o_disableAreas), - OPCODE(21, o_directionalUpdate), - OPCODE(22, o_goToDest), - OPCODE(23, o_toggleAreasActivation), - OPCODE(24, o_playSound), - // Opcode 25 Not Present, original calls replaceSound - OPCODE(26, o_stopSoundBackground), - OPCODE(27, o_playSoundBlocking), - OPCODE(28, o_restoreDefaultRect), - OPCODE(29, o_blitRect), - OPCODE(30, o_changeSound), - OPCODE(31, o_soundPlaySwitch), - OPCODE(32, o_soundResumeBackground), - OPCODE(33, o_blitRect), - OPCODE(34, o_changeCard), - OPCODE(35, o_drawImageChangeCard), - OPCODE(36, o_changeMainCursor), - OPCODE(37, o_hideCursor), - OPCODE(38, o_showCursor), - OPCODE(39, o_delay), - OPCODE(40, o_changeStack), - OPCODE(41, o_changeCardPlaySoundDirectional), - OPCODE(42, o_directionalUpdatePlaySound), - OPCODE(43, o_saveMainCursor), - OPCODE(44, o_restoreMainCursor), - // Opcode 45 Not Present - OPCODE(46, o_soundWaitStop), - // Opcodes 47 to 99 Not Present - - OPCODE(0xFFFF, NOP) - }; - - _opcodes = myst_opcodes; - _opcodeCount = ARRAYSIZE(myst_opcodes); -} + for (uint32 i = 0; i < _opcodes.size(); i++) + delete _opcodes[i]; +} + +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, &MystScriptParser::x, #x)) + +void MystScriptParser::setupCommonOpcodes() { + // These opcodes are common to each stack + + // "Standard" Opcodes + OPCODE(0, o_toggleVar); + OPCODE(1, o_setVar); + OPCODE(2, o_changeCardSwitch); + OPCODE(3, o_takePage); + OPCODE(4, o_redrawCard); + // Opcode 5 Not Present + OPCODE(6, o_goToDest); + OPCODE(7, o_goToDest); + OPCODE(8, o_goToDest); + OPCODE(9, o_triggerMovie); + OPCODE(10, o_toggleVarNoRedraw); + // Opcode 11 Not Present + OPCODE(12, o_changeCardSwitch); + OPCODE(13, o_changeCardSwitch); + OPCODE(14, o_drawAreaState); + OPCODE(15, o_redrawAreaForVar); + OPCODE(16, o_changeCardDirectional); + OPCODE(17, o_changeCardPush); + OPCODE(18, o_changeCardPop); + OPCODE(19, o_enableAreas); + OPCODE(20, o_disableAreas); + OPCODE(21, o_directionalUpdate); + OPCODE(22, o_goToDest); + OPCODE(23, o_toggleAreasActivation); + OPCODE(24, o_playSound); + // Opcode 25 is unused; original calls replaceSound + OPCODE(26, o_stopSoundBackground); + OPCODE(27, o_playSoundBlocking); + OPCODE(28, o_restoreDefaultRect); + OPCODE(29, o_blitRect); + OPCODE(30, o_changeSound); + OPCODE(31, o_soundPlaySwitch); + OPCODE(32, o_soundResumeBackground); + OPCODE(33, o_blitRect); + OPCODE(34, o_changeCard); + OPCODE(35, o_drawImageChangeCard); + OPCODE(36, o_changeMainCursor); + OPCODE(37, o_hideCursor); + OPCODE(38, o_showCursor); + OPCODE(39, o_delay); + OPCODE(40, o_changeStack); + OPCODE(41, o_changeCardPlaySoundDirectional); + OPCODE(42, o_directionalUpdatePlaySound); + OPCODE(43, o_saveMainCursor); + OPCODE(44, o_restoreMainCursor); + // Opcode 45 Not Present + OPCODE(46, o_soundWaitStop); + // Opcodes 47 to 99 Not Present + + OPCODE(0xFFFF, NOP); +} + +#undef OPCODE void MystScriptParser::runScript(MystScript script, MystResource *invokingResource) { debugC(kDebugScript, "Script Size: %d", script->size()); @@ -160,11 +158,10 @@ void MystScriptParser::runScript(MystScript script, MystResource *invokingResour MystScriptEntry &entry = script->operator[](i); debugC(kDebugScript, "\tOpcode %d: %d", i, entry.opcode); - if (entry.type == kMystScriptNormal) { + if (entry.type == kMystScriptNormal) _invokingResource = invokingResource; - } else { + else _invokingResource = _vm->_resources[entry.resourceId]; - } runOpcode(entry.opcode, entry.var, entry.argc, entry.argv); } @@ -173,21 +170,21 @@ void MystScriptParser::runScript(MystScript script, MystResource *invokingResour void MystScriptParser::runOpcode(uint16 op, uint16 var, uint16 argc, uint16 *argv) { bool ranOpcode = false; - for (uint16 i = 0; i < _opcodeCount; i++) - if (_opcodes[i].op == op) { - (this->*(_opcodes[i].proc)) (op, var, argc, argv); + for (uint16 i = 0; i < _opcodes.size(); i++) + if (_opcodes[i]->op == op) { + (this->*(_opcodes[i]->proc)) (op, var, argc, argv); ranOpcode = true; break; } if (!ranOpcode) - error ("Trying to run invalid opcode %d", op); + error("Trying to run invalid opcode %d", op); } const char *MystScriptParser::getOpcodeDesc(uint16 op) { - for (uint16 i = 0; i < _opcodeCount; i++) - if (_opcodes[i].op == op) - return _opcodes[i].desc; + for (uint16 i = 0; i < _opcodes.size(); i++) + if (_opcodes[i]->op == op) + return _opcodes[i]->desc; error("Unknown opcode %d", op); return ""; diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h index 6d805ebd37..69389fe28b 100644 --- a/engines/mohawk/myst_scripts.h +++ b/engines/mohawk/myst_scripts.h @@ -126,13 +126,14 @@ protected: typedef void (MystScriptParser::*OpcodeProcMyst)(uint16 op, uint16 var, uint16 argc, uint16* argv); struct MystOpcode { + MystOpcode(uint16 o, OpcodeProcMyst p, const char *d) : op(o), proc(p), desc(d) {} + uint16 op; OpcodeProcMyst proc; const char *desc; }; - uint16 _opcodeCount; - const MystOpcode *_opcodes; + Common::Array<MystOpcode*> _opcodes; MystResource *_invokingResource; @@ -143,11 +144,11 @@ protected: static const uint8 stack_map[]; static const uint16 start_card[]; - void setupOpcodes(); + void setupCommonOpcodes(); void varUnusedCheck(uint16 op, uint16 var); }; -} +} // End of namespace Mohawk #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp index 0f4a6e5a03..b710b426b4 100644 --- a/engines/mohawk/myst_stacks/channelwood.cpp +++ b/engines/mohawk/myst_stacks/channelwood.cpp @@ -34,11 +34,6 @@ namespace Mohawk { -// NOTE: Credits Start Card is 10000 - -#define OPCODE(op, x) { op, &MystScriptParser::x, #x } -#define SPECIFIC_OPCODE(op, x) { op, (OpcodeProcMyst) &MystScriptParser_Channelwood::x, #x } - MystScriptParser_Channelwood::MystScriptParser_Channelwood(MohawkEngine_Myst *vm) : MystScriptParser(vm) { setupOpcodes(); } @@ -46,87 +41,31 @@ MystScriptParser_Channelwood::MystScriptParser_Channelwood(MohawkEngine_Myst *vm MystScriptParser_Channelwood::~MystScriptParser_Channelwood() { } +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Channelwood::x, #x)) + void MystScriptParser_Channelwood::setupOpcodes() { - // "invalid" opcodes do not exist or have not been observed - // "unknown" opcodes exist, but their meaning is unknown - - static const MystOpcode channelwoodOpcodes[] = { - // "Standard" Opcodes - OPCODE(0, o_toggleVar), - OPCODE(1, o_setVar), - OPCODE(2, o_changeCardSwitch), - OPCODE(3, o_takePage), - OPCODE(4, o_redrawCard), - // TODO: Opcode 5 Not Present - OPCODE(6, o_goToDest), - OPCODE(7, o_goToDest), - OPCODE(8, o_goToDest), - OPCODE(9, o_triggerMovie), - OPCODE(10, o_toggleVarNoRedraw), - // TODO: Opcode 10 to 11 Not Present - OPCODE(12, o_changeCardSwitch), - OPCODE(13, o_changeCardSwitch), - OPCODE(14, o_drawAreaState), - OPCODE(15, o_redrawAreaForVar), - OPCODE(16, o_changeCardDirectional), - OPCODE(17, o_changeCardPush), - OPCODE(18, o_changeCardPop), - OPCODE(19, o_enableAreas), - OPCODE(20, o_disableAreas), - OPCODE(21, o_directionalUpdate), - OPCODE(22, o_goToDest), - OPCODE(23, o_toggleAreasActivation), - OPCODE(24, o_playSound), - // TODO: Opcode 25 Not Present - OPCODE(26, o_stopSoundBackground), - OPCODE(27, o_playSoundBlocking), - OPCODE(28, o_restoreDefaultRect), - OPCODE(29, o_blitRect), - OPCODE(30, o_changeSound), - OPCODE(31, o_soundPlaySwitch), - OPCODE(32, o_soundResumeBackground), - OPCODE(33, o_blitRect), - OPCODE(34, o_changeCard), - OPCODE(35, o_drawImageChangeCard), - OPCODE(36, o_changeMainCursor), - OPCODE(37, o_hideCursor), - OPCODE(38, o_showCursor), - OPCODE(39, o_delay), - OPCODE(40, o_changeStack), - OPCODE(41, o_changeCardPlaySoundDirectional), - OPCODE(42, o_directionalUpdatePlaySound), - OPCODE(43, o_saveMainCursor), - OPCODE(44, o_restoreMainCursor), - // TODO: Opcode 45 Not Present - OPCODE(46, o_soundWaitStop), - // TODO: Opcodes 47 to 99 Not Present - - // "Stack-Specific" Opcodes - SPECIFIC_OPCODE(101, opcode_101), - SPECIFIC_OPCODE(102, opcode_102), - SPECIFIC_OPCODE(104, opcode_104), - SPECIFIC_OPCODE(117, opcode_117), - SPECIFIC_OPCODE(118, opcode_118), - SPECIFIC_OPCODE(119, opcode_119), - SPECIFIC_OPCODE(122, opcode_122), - SPECIFIC_OPCODE(127, opcode_127), - SPECIFIC_OPCODE(129, opcode_129), - - // "Init" Opcodes - SPECIFIC_OPCODE(201, opcode_201), - SPECIFIC_OPCODE(202, opcode_202), - SPECIFIC_OPCODE(203, opcode_203), - - // "Exit" Opcodes - SPECIFIC_OPCODE(300, opcode_300), - - OPCODE(0xFFFF, NOP) - }; - - _opcodes = channelwoodOpcodes; - _opcodeCount = ARRAYSIZE(channelwoodOpcodes); + // "Stack-Specific" Opcodes + OPCODE(101, opcode_101); + OPCODE(102, opcode_102); + OPCODE(104, opcode_104); + OPCODE(117, opcode_117); + OPCODE(118, opcode_118); + OPCODE(119, opcode_119); + OPCODE(122, opcode_122); + OPCODE(127, opcode_127); + OPCODE(129, opcode_129); + + // "Init" Opcodes + OPCODE(201, opcode_201); + OPCODE(202, opcode_202); + OPCODE(203, opcode_203); + + // "Exit" Opcodes + OPCODE(300, opcode_300); } +#undef OPCODE + void MystScriptParser_Channelwood::disablePersistentScripts() { opcode_202_disable(); opcode_203_disable(); diff --git a/engines/mohawk/myst_stacks/credits.cpp b/engines/mohawk/myst_stacks/credits.cpp index f508892ee4..152740139a 100644 --- a/engines/mohawk/myst_stacks/credits.cpp +++ b/engines/mohawk/myst_stacks/credits.cpp @@ -36,85 +36,25 @@ namespace Mohawk { // NOTE: Credits Start Card is 10000 -#define OPCODE(op, x) { op, &MystScriptParser::x, #x } -#define SPECIFIC_OPCODE(op, x) { op, (OpcodeProcMyst) &MystScriptParser_Credits::x, #x } - MystScriptParser_Credits::MystScriptParser_Credits(MohawkEngine_Myst *vm) : MystScriptParser(vm) { setupOpcodes(); - _invokingResource = NULL; } MystScriptParser_Credits::~MystScriptParser_Credits() { } +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Credits::x, #x)) + void MystScriptParser_Credits::setupOpcodes() { - // "invalid" opcodes do not exist or have not been observed - // "unknown" opcodes exist, but their meaning is unknown - - static const MystOpcode creditsOpcodes[] = { - // "Standard" Opcodes - OPCODE(0, o_toggleVar), - OPCODE(1, o_setVar), - OPCODE(2, o_changeCardSwitch), - OPCODE(3, o_takePage), - OPCODE(4, o_redrawCard), - // TODO: Opcode 5 Not Present - OPCODE(6, o_goToDest), - OPCODE(7, o_goToDest), - OPCODE(8, o_goToDest), - OPCODE(9, o_triggerMovie), - OPCODE(10, o_toggleVarNoRedraw), - // TODO: Opcode 10 to 11 Not Present - OPCODE(12, o_changeCardSwitch), - OPCODE(13, o_changeCardSwitch), - OPCODE(14, o_drawAreaState), - OPCODE(15, o_redrawAreaForVar), - OPCODE(16, o_changeCardDirectional), - OPCODE(17, o_changeCardPush), - OPCODE(18, o_changeCardPop), - OPCODE(19, o_enableAreas), - OPCODE(20, o_disableAreas), - OPCODE(21, o_directionalUpdate), - OPCODE(22, o_goToDest), - OPCODE(23, o_toggleAreasActivation), - OPCODE(24, o_playSound), - // TODO: Opcode 25 Not Present - OPCODE(26, o_stopSoundBackground), - OPCODE(27, o_playSoundBlocking), - OPCODE(28, o_restoreDefaultRect), - OPCODE(29, o_blitRect), - OPCODE(30, o_changeSound), - OPCODE(31, o_soundPlaySwitch), - OPCODE(32, o_soundResumeBackground), - OPCODE(33, o_blitRect), - OPCODE(34, o_changeCard), - OPCODE(35, o_drawImageChangeCard), - OPCODE(36, o_changeMainCursor), - OPCODE(37, o_hideCursor), - OPCODE(38, o_showCursor), - OPCODE(39, o_delay), - OPCODE(40, o_changeStack), - OPCODE(41, o_changeCardPlaySoundDirectional), - OPCODE(42, o_directionalUpdatePlaySound), - OPCODE(43, o_saveMainCursor), - OPCODE(44, o_restoreMainCursor), - // TODO: Opcode 45 Not Present - OPCODE(46, o_soundWaitStop), - // TODO: Opcodes 47 to 99 Not Present - - // "Stack-Specific" Opcodes - SPECIFIC_OPCODE(100, o_quit), - - // "Init" Opcodes - SPECIFIC_OPCODE(200, o_runCredits), - - OPCODE(0xFFFF, NOP) - }; - - _opcodes = creditsOpcodes; - _opcodeCount = ARRAYSIZE(creditsOpcodes); + // "Stack-Specific" Opcodes + OPCODE(100, o_quit); + + // "Init" Opcodes + OPCODE(200, o_runCredits); } +#undef OPCODE + void MystScriptParser_Credits::disablePersistentScripts() { _creditsRunning = false; _creditsVar = 0; diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp index bb4712c947..3024136463 100644 --- a/engines/mohawk/myst_stacks/mechanical.cpp +++ b/engines/mohawk/myst_stacks/mechanical.cpp @@ -34,9 +34,6 @@ namespace Mohawk { -#define OPCODE(op, x) { op, &MystScriptParser::x, #x } -#define SPECIFIC_OPCODE(op, x) { op, (OpcodeProcMyst) &MystScriptParser_Mechanical::x, #x } - MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm) : MystScriptParser(vm) { setupOpcodes(); } @@ -44,96 +41,40 @@ MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm) MystScriptParser_Mechanical::~MystScriptParser_Mechanical() { } +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Mechanical::x, #x)) + void MystScriptParser_Mechanical::setupOpcodes() { - // "invalid" opcodes do not exist or have not been observed - // "unknown" opcodes exist, but their meaning is unknown - - static const MystOpcode myst_opcodes[] = { - // "Standard" Opcodes - OPCODE(0, o_toggleVar), - OPCODE(1, o_setVar), - OPCODE(2, o_changeCardSwitch), - OPCODE(3, o_takePage), - OPCODE(4, o_redrawCard), - // TODO: Opcode 5 Not Present - OPCODE(6, o_goToDest), - OPCODE(7, o_goToDest), - OPCODE(8, o_goToDest), - OPCODE(9, o_triggerMovie), - OPCODE(10, o_toggleVarNoRedraw), - // TODO: Opcode 10 to 11 Not Present - OPCODE(12, o_changeCardSwitch), - OPCODE(13, o_changeCardSwitch), - OPCODE(14, o_drawAreaState), - OPCODE(15, o_redrawAreaForVar), - OPCODE(16, o_changeCardDirectional), - OPCODE(17, o_changeCardPush), - OPCODE(18, o_changeCardPop), - OPCODE(19, o_enableAreas), - OPCODE(20, o_disableAreas), - OPCODE(21, o_directionalUpdate), - OPCODE(22, o_goToDest), - OPCODE(23, o_toggleAreasActivation), - OPCODE(24, o_playSound), - // TODO: Opcode 25 Not Present - OPCODE(26, o_stopSoundBackground), - OPCODE(27, o_playSoundBlocking), - OPCODE(28, o_restoreDefaultRect), - OPCODE(29, o_blitRect), - OPCODE(30, o_changeSound), - OPCODE(31, o_soundPlaySwitch), - OPCODE(32, o_soundResumeBackground), - OPCODE(33, o_blitRect), - OPCODE(34, o_changeCard), - OPCODE(35, o_drawImageChangeCard), - OPCODE(36, o_changeMainCursor), - OPCODE(37, o_hideCursor), - OPCODE(38, o_showCursor), - OPCODE(39, o_delay), - OPCODE(40, o_changeStack), - OPCODE(41, o_changeCardPlaySoundDirectional), - OPCODE(42, o_directionalUpdatePlaySound), - OPCODE(43, o_saveMainCursor), - OPCODE(44, o_restoreMainCursor), - // TODO: Opcode 45 Not Present - OPCODE(46, o_soundWaitStop), - // TODO: Opcodes 47 to 99 Not Present - - // "Stack-Specific" Opcodes - SPECIFIC_OPCODE(104, opcode_104), - SPECIFIC_OPCODE(105, opcode_105), - SPECIFIC_OPCODE(121, opcode_121), - SPECIFIC_OPCODE(122, opcode_122), - SPECIFIC_OPCODE(123, opcode_123), - SPECIFIC_OPCODE(124, opcode_124), - SPECIFIC_OPCODE(125, opcode_125), - SPECIFIC_OPCODE(126, opcode_126), - SPECIFIC_OPCODE(127, opcode_127), - SPECIFIC_OPCODE(128, opcode_128), - SPECIFIC_OPCODE(129, opcode_129), - SPECIFIC_OPCODE(130, opcode_130), - SPECIFIC_OPCODE(131, opcode_131), - SPECIFIC_OPCODE(132, opcode_132), - - // "Init" Opcodes - SPECIFIC_OPCODE(200, opcode_200), - SPECIFIC_OPCODE(201, opcode_201), - SPECIFIC_OPCODE(202, opcode_202), - SPECIFIC_OPCODE(203, opcode_203), - SPECIFIC_OPCODE(204, opcode_204), - SPECIFIC_OPCODE(205, opcode_205), - SPECIFIC_OPCODE(206, opcode_206), - SPECIFIC_OPCODE(209, opcode_209), - - // "Exit" Opcodes - SPECIFIC_OPCODE(300, opcode_300), - - OPCODE(0xFFFF, NOP) - }; - - _opcodes = myst_opcodes; - _opcodeCount = ARRAYSIZE(myst_opcodes); -} + // "Stack-Specific" Opcodes + OPCODE(104, opcode_104); + OPCODE(105, opcode_105); + OPCODE(121, opcode_121); + OPCODE(122, opcode_122); + OPCODE(123, opcode_123); + OPCODE(124, opcode_124); + OPCODE(125, opcode_125); + OPCODE(126, opcode_126); + OPCODE(127, opcode_127); + OPCODE(128, opcode_128); + OPCODE(129, opcode_129); + OPCODE(130, opcode_130); + OPCODE(131, opcode_131); + OPCODE(132, opcode_132); + + // "Init" Opcodes + OPCODE(200, opcode_200); + OPCODE(201, opcode_201); + OPCODE(202, opcode_202); + OPCODE(203, opcode_203); + OPCODE(204, opcode_204); + OPCODE(205, opcode_205); + OPCODE(206, opcode_206); + OPCODE(209, opcode_209); + + // "Exit" Opcodes + OPCODE(300, opcode_300); +} + +#undef OPCODE void MystScriptParser_Mechanical::disablePersistentScripts() { opcode_200_disable(); diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index 8aaaf4a662..0209510390 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -36,12 +36,8 @@ namespace Mohawk { // NOTE: Credits Start Card is 10000 -#define OPCODE(op, x) { op, &MystScriptParser::x, #x } -#define SPECIFIC_OPCODE(op, x) { op, (OpcodeProcMyst) &MystScriptParser_Myst::x, #x } - MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : MystScriptParser(vm) { setupOpcodes(); - _invokingResource = NULL; // Card ID preinitialized by the engine for use by opcode 18 // when linking back to Myst in the library @@ -52,144 +48,88 @@ MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : MystScript MystScriptParser_Myst::~MystScriptParser_Myst() { } +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Myst::x, #x)) + void MystScriptParser_Myst::setupOpcodes() { - // "invalid" opcodes do not exist or have not been observed - // "unknown" opcodes exist, but their meaning is unknown - - static const MystOpcode myst_opcodes[] = { - // "Standard" Opcodes - OPCODE(0, o_toggleVar), - OPCODE(1, o_setVar), - OPCODE(2, o_changeCardSwitch), - OPCODE(3, o_takePage), - OPCODE(4, o_redrawCard), - // TODO: Opcode 5 Not Present - OPCODE(6, o_goToDest), - OPCODE(7, o_goToDest), - OPCODE(8, o_goToDest), - OPCODE(9, o_triggerMovie), - OPCODE(10, o_toggleVarNoRedraw), - // TODO: Opcode 10 to 11 Not Present - OPCODE(12, o_changeCardSwitch), - OPCODE(13, o_changeCardSwitch), - OPCODE(14, o_drawAreaState), - OPCODE(15, o_redrawAreaForVar), - OPCODE(16, o_changeCardDirectional), - OPCODE(17, o_changeCardPush), - OPCODE(18, o_changeCardPop), - OPCODE(19, o_enableAreas), - OPCODE(20, o_disableAreas), - OPCODE(21, o_directionalUpdate), - OPCODE(22, o_goToDest), - OPCODE(23, o_toggleAreasActivation), - OPCODE(24, o_playSound), - // TODO: Opcode 25 Not Present - OPCODE(26, o_stopSoundBackground), - OPCODE(27, o_playSoundBlocking), - OPCODE(28, o_restoreDefaultRect), - OPCODE(29, o_blitRect), - OPCODE(30, o_changeSound), - OPCODE(31, o_soundPlaySwitch), - OPCODE(32, o_soundResumeBackground), - OPCODE(33, o_blitRect), - OPCODE(34, o_changeCard), - OPCODE(35, o_drawImageChangeCard), - OPCODE(36, o_changeMainCursor), - OPCODE(37, o_hideCursor), - OPCODE(38, o_showCursor), - OPCODE(39, o_delay), - OPCODE(40, o_changeStack), - OPCODE(41, o_changeCardPlaySoundDirectional), - OPCODE(42, o_directionalUpdatePlaySound), - OPCODE(43, o_saveMainCursor), - OPCODE(44, o_restoreMainCursor), - // TODO: Opcode 45 Not Present - OPCODE(46, o_soundWaitStop), - // TODO: Opcodes 47 to 99 Not Present - - // "Stack-Specific" Opcodes - SPECIFIC_OPCODE(100, opcode_100), - SPECIFIC_OPCODE(101, opcode_101), - SPECIFIC_OPCODE(102, opcode_102), - SPECIFIC_OPCODE(103, opcode_103), - SPECIFIC_OPCODE(104, opcode_104), - SPECIFIC_OPCODE(105, opcode_105), - SPECIFIC_OPCODE(109, opcode_109), - SPECIFIC_OPCODE(113, opcode_113), - SPECIFIC_OPCODE(114, opcode_114), - SPECIFIC_OPCODE(115, opcode_115), - SPECIFIC_OPCODE(116, opcode_116), - SPECIFIC_OPCODE(117, opcode_117), - SPECIFIC_OPCODE(118, opcode_118), - SPECIFIC_OPCODE(119, opcode_119), - SPECIFIC_OPCODE(120, opcode_120), - SPECIFIC_OPCODE(121, opcode_121), - SPECIFIC_OPCODE(133, opcode_133), - // TODO: Opcodes 134 to 146 Not Present - SPECIFIC_OPCODE(147, opcode_147), - // TODO: Opcodes 148 to 163 Not Present - SPECIFIC_OPCODE(164, opcode_164), - // TODO: Opcodes 165 to 168 Not Present - SPECIFIC_OPCODE(169, opcode_169), - // TODO: Opcodes 170 to 181 Not Present - SPECIFIC_OPCODE(182, opcode_182), - SPECIFIC_OPCODE(183, opcode_183), - SPECIFIC_OPCODE(184, opcode_184), - SPECIFIC_OPCODE(185, opcode_185), - // TODO: Opcodes 186 to 195 Not Present - SPECIFIC_OPCODE(196, opcode_196), // Demo only - SPECIFIC_OPCODE(197, opcode_197), // Demo only - SPECIFIC_OPCODE(198, opcode_198), - SPECIFIC_OPCODE(199, opcode_199), - - // "Init" Opcodes - SPECIFIC_OPCODE(200, opcode_200), - SPECIFIC_OPCODE(201, opcode_201), - SPECIFIC_OPCODE(202, opcode_202), - SPECIFIC_OPCODE(203, opcode_203), - SPECIFIC_OPCODE(204, opcode_204), - SPECIFIC_OPCODE(205, opcode_205), - SPECIFIC_OPCODE(206, opcode_206), - SPECIFIC_OPCODE(208, opcode_208), - SPECIFIC_OPCODE(209, opcode_209), - SPECIFIC_OPCODE(210, opcode_210), - SPECIFIC_OPCODE(211, opcode_211), - SPECIFIC_OPCODE(212, opcode_212), - SPECIFIC_OPCODE(213, opcode_213), - SPECIFIC_OPCODE(214, opcode_214), - SPECIFIC_OPCODE(215, opcode_215), - SPECIFIC_OPCODE(216, opcode_216), - SPECIFIC_OPCODE(217, opcode_217), - SPECIFIC_OPCODE(218, opcode_218), - SPECIFIC_OPCODE(219, opcode_219), - SPECIFIC_OPCODE(220, opcode_220), - SPECIFIC_OPCODE(221, opcode_221), - SPECIFIC_OPCODE(222, opcode_222), - // TODO: Opcodes 223 to 297 Not Present - SPECIFIC_OPCODE(298, opcode_298), // Demo only - SPECIFIC_OPCODE(299, opcode_299), // Demo only - - // "Exit" Opcodes - SPECIFIC_OPCODE(300, opcode_300), - SPECIFIC_OPCODE(301, opcode_301), - SPECIFIC_OPCODE(302, opcode_302), - SPECIFIC_OPCODE(303, opcode_303), - SPECIFIC_OPCODE(304, opcode_304), - SPECIFIC_OPCODE(305, opcode_305), - SPECIFIC_OPCODE(306, opcode_306), - SPECIFIC_OPCODE(307, opcode_307), - SPECIFIC_OPCODE(308, opcode_308), - SPECIFIC_OPCODE(309, opcode_309), - // TODO: Opcodes 310 to 311 Not Present - SPECIFIC_OPCODE(312, opcode_312), - // TODO: Opcodes 313 and greater Not Present - - OPCODE(0xFFFF, NOP) - }; - - _opcodes = myst_opcodes; - _opcodeCount = ARRAYSIZE(myst_opcodes); -} + // "Stack-Specific" Opcodes + OPCODE(100, opcode_100); + OPCODE(101, opcode_101); + OPCODE(102, opcode_102); + OPCODE(103, opcode_103); + OPCODE(104, opcode_104); + OPCODE(105, opcode_105); + OPCODE(109, opcode_109); + OPCODE(113, opcode_113); + OPCODE(114, opcode_114); + OPCODE(115, opcode_115); + OPCODE(116, opcode_116); + OPCODE(117, opcode_117); + OPCODE(118, opcode_118); + OPCODE(119, opcode_119); + OPCODE(120, opcode_120); + OPCODE(121, opcode_121); + OPCODE(133, opcode_133); + // TODO: Opcodes 134 to 146 Not Present + OPCODE(147, opcode_147); + // TODO: Opcodes 148 to 163 Not Present + OPCODE(164, opcode_164); + // TODO: Opcodes 165 to 168 Not Present + OPCODE(169, opcode_169); + // TODO: Opcodes 170 to 181 Not Present + OPCODE(182, opcode_182); + OPCODE(183, opcode_183); + OPCODE(184, opcode_184); + OPCODE(185, opcode_185); + // TODO: Opcodes 186 to 195 Not Present + OPCODE(196, opcode_196); // Demo only + OPCODE(197, opcode_197); // Demo only + OPCODE(198, opcode_198); + OPCODE(199, opcode_199); + + // "Init" Opcodes + OPCODE(200, opcode_200); + OPCODE(201, opcode_201); + OPCODE(202, opcode_202); + OPCODE(203, opcode_203); + OPCODE(204, opcode_204); + OPCODE(205, opcode_205); + OPCODE(206, opcode_206); + OPCODE(208, opcode_208); + OPCODE(209, opcode_209); + OPCODE(210, opcode_210); + OPCODE(211, opcode_211); + OPCODE(212, opcode_212); + OPCODE(213, opcode_213); + OPCODE(214, opcode_214); + OPCODE(215, opcode_215); + OPCODE(216, opcode_216); + OPCODE(217, opcode_217); + OPCODE(218, opcode_218); + OPCODE(219, opcode_219); + OPCODE(220, opcode_220); + OPCODE(221, opcode_221); + OPCODE(222, opcode_222); + // TODO: Opcodes 223 to 297 Not Present + OPCODE(298, opcode_298); // Demo only + OPCODE(299, opcode_299); // Demo only + + // "Exit" Opcodes + OPCODE(300, opcode_300); + OPCODE(301, opcode_301); + OPCODE(302, opcode_302); + OPCODE(303, opcode_303); + OPCODE(304, opcode_304); + OPCODE(305, opcode_305); + OPCODE(306, opcode_306); + OPCODE(307, opcode_307); + OPCODE(308, opcode_308); + OPCODE(309, opcode_309); + // TODO: Opcodes 310 to 311 Not Present + OPCODE(312, opcode_312); + // TODO: Opcodes 313 and greater Not Present +} + +#undef OPCODE void MystScriptParser_Myst::disablePersistentScripts() { opcode_200_disable(); diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp index daf4953561..74c12f243c 100644 --- a/engines/mohawk/myst_stacks/selenitic.cpp +++ b/engines/mohawk/myst_stacks/selenitic.cpp @@ -36,9 +36,6 @@ namespace Mohawk { -#define OPCODE(op, x) { op, &MystScriptParser::x, #x } -#define SPECIFIC_OPCODE(op, x) { op, (OpcodeProcMyst) &MystScriptParser_Selenitic::x, #x } - MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) : MystScriptParser(vm) { setupOpcodes(); _invokingResource = NULL; @@ -49,97 +46,41 @@ MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) : MystScriptParser_Selenitic::~MystScriptParser_Selenitic() { } -void MystScriptParser_Selenitic::setupOpcodes() { - // "invalid" opcodes do not exist or have not been observed - // "unknown" opcodes exist, but their meaning is unknown - - static const MystOpcode myst_opcodes[] = { - // "Standard" Opcodes - OPCODE(0, o_toggleVar), - OPCODE(1, o_setVar), - OPCODE(2, o_changeCardSwitch), - OPCODE(3, o_takePage), - OPCODE(4, o_redrawCard), - // TODO: Opcode 5 Not Present - OPCODE(6, o_goToDest), - OPCODE(7, o_goToDest), - OPCODE(8, o_goToDest), - OPCODE(9, o_triggerMovie), - OPCODE(10, o_toggleVarNoRedraw), - // TODO: Opcode 10 to 11 Not Present - OPCODE(12, o_changeCardSwitch), - OPCODE(13, o_changeCardSwitch), - OPCODE(14, o_drawAreaState), - OPCODE(15, o_redrawAreaForVar), - OPCODE(16, o_changeCardDirectional), - OPCODE(17, o_changeCardPush), - OPCODE(18, o_changeCardPop), - OPCODE(19, o_enableAreas), - OPCODE(20, o_disableAreas), - OPCODE(21, o_directionalUpdate), - OPCODE(22, o_goToDest), - OPCODE(23, o_toggleAreasActivation), - OPCODE(24, o_playSound), - // TODO: Opcode 25 Not Present - OPCODE(26, o_stopSoundBackground), - OPCODE(27, o_playSoundBlocking), - OPCODE(28, o_restoreDefaultRect), - OPCODE(29, o_blitRect), - OPCODE(30, o_changeSound), - OPCODE(31, o_soundPlaySwitch), - OPCODE(32, o_soundResumeBackground), - OPCODE(33, o_blitRect), - OPCODE(34, o_changeCard), - OPCODE(35, o_drawImageChangeCard), - OPCODE(36, o_changeMainCursor), - OPCODE(37, o_hideCursor), - OPCODE(38, o_showCursor), - OPCODE(39, o_delay), - OPCODE(40, o_changeStack), - OPCODE(41, o_changeCardPlaySoundDirectional), - OPCODE(42, o_directionalUpdatePlaySound), - OPCODE(43, o_saveMainCursor), - OPCODE(44, o_restoreMainCursor), - // TODO: Opcode 45 Not Present - OPCODE(46, o_soundWaitStop), - // TODO: Opcodes 47 to 99 Not Present - - // "Stack-Specific" Opcodes - SPECIFIC_OPCODE(100, o_mazeRunnerMove), - SPECIFIC_OPCODE(101, o_mazeRunnerSoundRepeat), - SPECIFIC_OPCODE(102, o_soundReceiverSigma), - SPECIFIC_OPCODE(103, o_soundReceiverRight), - SPECIFIC_OPCODE(104, o_soundReceiverLeft), - SPECIFIC_OPCODE(105, o_soundReceiverSource), - SPECIFIC_OPCODE(106, o_soundReceiverSource), - SPECIFIC_OPCODE(107, o_soundReceiverSource), - SPECIFIC_OPCODE(108, o_soundReceiverSource), - SPECIFIC_OPCODE(109, o_soundReceiverSource), - SPECIFIC_OPCODE(110, o_mazeRunnerDoorButton), - SPECIFIC_OPCODE(111, o_soundReceiverUpdateSound), - SPECIFIC_OPCODE(112, o_soundLockMove), - SPECIFIC_OPCODE(113, o_soundLockStartMove), - SPECIFIC_OPCODE(114, o_soundLockEndMove), - SPECIFIC_OPCODE(115, o_soundLockButton), - SPECIFIC_OPCODE(116, NOP), - SPECIFIC_OPCODE(117, o_soundReceiverEndMove), - - // "Init" Opcodes - SPECIFIC_OPCODE(200, o_mazeRunnerCompass_init), - SPECIFIC_OPCODE(201, o_mazeRunnerWindow_init), - SPECIFIC_OPCODE(202, o_mazeRunnerLight_init), - SPECIFIC_OPCODE(203, o_soundReceiver_init), - SPECIFIC_OPCODE(204, o_soundLock_init), - SPECIFIC_OPCODE(205, o_mazeRunnerRight_init), - SPECIFIC_OPCODE(206, o_mazeRunnerLeft_init), - - OPCODE(0xFFFF, NOP) - }; +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Selenitic::x, #x)) - _opcodes = myst_opcodes; - _opcodeCount = ARRAYSIZE(myst_opcodes); +void MystScriptParser_Selenitic::setupOpcodes() { + // "Stack-Specific" Opcodes + OPCODE(100, o_mazeRunnerMove); + OPCODE(101, o_mazeRunnerSoundRepeat); + OPCODE(102, o_soundReceiverSigma); + OPCODE(103, o_soundReceiverRight); + OPCODE(104, o_soundReceiverLeft); + OPCODE(105, o_soundReceiverSource); + OPCODE(106, o_soundReceiverSource); + OPCODE(107, o_soundReceiverSource); + OPCODE(108, o_soundReceiverSource); + OPCODE(109, o_soundReceiverSource); + OPCODE(110, o_mazeRunnerDoorButton); + OPCODE(111, o_soundReceiverUpdateSound); + OPCODE(112, o_soundLockMove); + OPCODE(113, o_soundLockStartMove); + OPCODE(114, o_soundLockEndMove); + OPCODE(115, o_soundLockButton); + OPCODE(116, NOP); + OPCODE(117, o_soundReceiverEndMove); + + // "Init" Opcodes + OPCODE(200, o_mazeRunnerCompass_init); + OPCODE(201, o_mazeRunnerWindow_init); + OPCODE(202, o_mazeRunnerLight_init); + OPCODE(203, o_soundReceiver_init); + OPCODE(204, o_soundLock_init); + OPCODE(205, o_mazeRunnerRight_init); + OPCODE(206, o_mazeRunnerLeft_init); } +#undef OPCODE + void MystScriptParser_Selenitic::disablePersistentScripts() { _soundReceiverRunning = false; } diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp index 9e53a1e2bf..8979a2561d 100644 --- a/engines/mohawk/myst_stacks/stoneship.cpp +++ b/engines/mohawk/myst_stacks/stoneship.cpp @@ -34,9 +34,6 @@ namespace Mohawk { -#define OPCODE(op, x) { op, &MystScriptParser::x, #x } -#define SPECIFIC_OPCODE(op, x) { op, (OpcodeProcMyst) &MystScriptParser_Stoneship::x, #x } - MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) : MystScriptParser(vm) { setupOpcodes(); } @@ -44,98 +41,42 @@ MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) : MystScriptParser_Stoneship::~MystScriptParser_Stoneship() { } +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Stoneship::x, #x)) + void MystScriptParser_Stoneship::setupOpcodes() { - // "invalid" opcodes do not exist or have not been observed - // "unknown" opcodes exist, but their meaning is unknown - - static const MystOpcode stoneshipOpcodes[] = { - // "Standard" Opcodes - OPCODE(0, o_toggleVar), - OPCODE(1, o_setVar), - OPCODE(2, o_changeCardSwitch), - OPCODE(3, o_takePage), - OPCODE(4, o_redrawCard), - // TODO: Opcode 5 Not Present - OPCODE(6, o_goToDest), - OPCODE(7, o_goToDest), - OPCODE(8, o_goToDest), - OPCODE(9, o_triggerMovie), - OPCODE(10, o_toggleVarNoRedraw), - // TODO: Opcode 10 to 11 Not Present - OPCODE(12, o_changeCardSwitch), - OPCODE(13, o_changeCardSwitch), - OPCODE(14, o_drawAreaState), - OPCODE(15, o_redrawAreaForVar), - OPCODE(16, o_changeCardDirectional), - OPCODE(17, o_changeCardPush), - OPCODE(18, o_changeCardPop), - OPCODE(19, o_enableAreas), - OPCODE(20, o_disableAreas), - OPCODE(21, o_directionalUpdate), - OPCODE(22, o_goToDest), - OPCODE(23, o_toggleAreasActivation), - OPCODE(24, o_playSound), - // TODO: Opcode 25 Not Present - OPCODE(26, o_stopSoundBackground), - OPCODE(27, o_playSoundBlocking), - OPCODE(28, o_restoreDefaultRect), - OPCODE(29, o_blitRect), - OPCODE(30, o_changeSound), - OPCODE(31, o_soundPlaySwitch), - OPCODE(32, o_soundResumeBackground), - OPCODE(33, o_blitRect), - OPCODE(34, o_changeCard), - OPCODE(35, o_drawImageChangeCard), - OPCODE(36, o_changeMainCursor), - OPCODE(37, o_hideCursor), - OPCODE(38, o_showCursor), - OPCODE(39, o_delay), - OPCODE(40, o_changeStack), - OPCODE(41, o_changeCardPlaySoundDirectional), - OPCODE(42, o_directionalUpdatePlaySound), - OPCODE(43, o_saveMainCursor), - OPCODE(44, o_restoreMainCursor), - // TODO: Opcode 45 Not Present - OPCODE(46, o_soundWaitStop), - // TODO: Opcodes 47 to 99 Not Present - - // "Stack-Specific" Opcodes - SPECIFIC_OPCODE(100, opcode_100), - SPECIFIC_OPCODE(101, opcode_101), - SPECIFIC_OPCODE(102, opcode_102), - SPECIFIC_OPCODE(103, opcode_103), - SPECIFIC_OPCODE(104, opcode_104), - SPECIFIC_OPCODE(111, opcode_111), - SPECIFIC_OPCODE(112, opcode_112), - SPECIFIC_OPCODE(116, opcode_116), - SPECIFIC_OPCODE(117, opcode_117), - SPECIFIC_OPCODE(118, opcode_118), - SPECIFIC_OPCODE(119, opcode_119), - SPECIFIC_OPCODE(120, opcode_120), - SPECIFIC_OPCODE(125, opcode_125), - - // "Init" Opcodes - SPECIFIC_OPCODE(200, opcode_200), - SPECIFIC_OPCODE(201, opcode_201), - SPECIFIC_OPCODE(202, opcode_202), - SPECIFIC_OPCODE(203, opcode_203), - SPECIFIC_OPCODE(204, opcode_204), - SPECIFIC_OPCODE(205, opcode_205), - SPECIFIC_OPCODE(206, opcode_206), - SPECIFIC_OPCODE(207, opcode_207), - SPECIFIC_OPCODE(208, opcode_208), - SPECIFIC_OPCODE(209, opcode_209), - SPECIFIC_OPCODE(210, opcode_210), - - // "Exit" Opcodes - SPECIFIC_OPCODE(300, opcode_300), - - OPCODE(0xFFFF, NOP) - }; - - _opcodes = stoneshipOpcodes; - _opcodeCount = ARRAYSIZE(stoneshipOpcodes); -} + // "Stack-Specific" Opcodes + OPCODE(100, opcode_100); + OPCODE(101, opcode_101); + OPCODE(102, opcode_102); + OPCODE(103, opcode_103); + OPCODE(104, opcode_104); + OPCODE(111, opcode_111); + OPCODE(112, opcode_112); + OPCODE(116, opcode_116); + OPCODE(117, opcode_117); + OPCODE(118, opcode_118); + OPCODE(119, opcode_119); + OPCODE(120, opcode_120); + OPCODE(125, opcode_125); + + // "Init" Opcodes + OPCODE(200, opcode_200); + OPCODE(201, opcode_201); + OPCODE(202, opcode_202); + OPCODE(203, opcode_203); + OPCODE(204, opcode_204); + OPCODE(205, opcode_205); + OPCODE(206, opcode_206); + OPCODE(207, opcode_207); + OPCODE(208, opcode_208); + OPCODE(209, opcode_209); + OPCODE(210, opcode_210); + + // "Exit" Opcodes + OPCODE(300, opcode_300); +} + +#undef OPCODE void MystScriptParser_Stoneship::disablePersistentScripts() { opcode_200_disable(); |