diff options
Diffstat (limited to 'engines/agos/script_s2.cpp')
-rw-r--r-- | engines/agos/script_s2.cpp | 309 |
1 files changed, 263 insertions, 46 deletions
diff --git a/engines/agos/script_s2.cpp b/engines/agos/script_s2.cpp index ea2ef5d1bb..100da239bb 100644 --- a/engines/agos/script_s2.cpp +++ b/engines/agos/script_s2.cpp @@ -27,55 +27,272 @@ namespace AGOS { -void AGOSEngine_Simon2::setupOpcodes(OpcodeProc *op) { - AGOSEngine::setupOpcodes(op); - - op[65] = &AGOSEngine::oww_addTextBox; - op[66] = &AGOSEngine::oww_setShortText; - op[67] = &AGOSEngine::oww_setLongText; - op[70] = &AGOSEngine::os2_printLongText; - op[83] = &AGOSEngine::os2_rescan; - op[88] = &AGOSEngine::o_haltAnimation; - op[89] = &AGOSEngine::o_restartAnimation; - op[98] = &AGOSEngine::os2_animate; - op[99] = &AGOSEngine::os2_stopAnimate; - op[127] = &AGOSEngine::os2_playTune; - op[135] = &AGOSEngine::os1_pauseGame; - op[161] = &AGOSEngine::os1_screenTextBox; - op[162] = &AGOSEngine::os1_screenTextMsg; - op[163] = &AGOSEngine::os1_playEffect; - op[164] = &AGOSEngine::oe2_getDollar2; - op[165] = &AGOSEngine::oe2_isAdjNoun; - op[166] = &AGOSEngine::oe2_b2Set; - op[167] = &AGOSEngine::oe2_b2Clear; - op[168] = &AGOSEngine::oe2_b2Zero; - op[169] = &AGOSEngine::oe2_b2NotZero; - op[175] = &AGOSEngine::oww_lockZones; - op[176] = &AGOSEngine::oww_unlockZones; - op[177] = &AGOSEngine::os2_screenTextPObj; - op[178] = &AGOSEngine::os1_getPathPosn; - op[179] = &AGOSEngine::os1_scnTxtLongText; - op[180] = &AGOSEngine::os2_mouseOn; - op[181] = &AGOSEngine::os2_mouseOff; - op[184] = &AGOSEngine::os1_unloadZone; - op[186] = &AGOSEngine::os1_unfreezeZones; - op[188] = &AGOSEngine::os2_isShortText; - op[189] = &AGOSEngine::os2_clearMarks; - op[190] = &AGOSEngine::os2_waitMark; +#define OPCODE(x) _OPCODE(AGOSEngine_Simon2, x) + +void AGOSEngine_Simon2::setupOpcodes() { + static const OpcodeEntrySimon2 opcodes[] = { + /* 00 */ + OPCODE(o_invalid), + OPCODE(o_at), + OPCODE(o_notAt), + OPCODE(o_invalid), + /* 04 */ + OPCODE(o_invalid), + OPCODE(o_carried), + OPCODE(o_notCarried), + OPCODE(o_isAt), + /* 08 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_zero), + /* 12 */ + OPCODE(o_notZero), + OPCODE(o_eq), + OPCODE(o_notEq), + OPCODE(o_gt), + /* 16 */ + OPCODE(o_lt), + OPCODE(o_eqf), + OPCODE(o_notEqf), + OPCODE(o_ltf), + /* 20 */ + OPCODE(o_gtf), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_chance), + /* 24 */ + OPCODE(o_invalid), + OPCODE(o_isRoom), + OPCODE(o_isObject), + OPCODE(o_state), + /* 28 */ + OPCODE(o_oflag), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_destroy), + /* 32 */ + OPCODE(o_invalid), + OPCODE(o_place), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 36 */ + OPCODE(o_copyff), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 40 */ + OPCODE(o_invalid), + OPCODE(o_clear), + OPCODE(o_let), + OPCODE(o_add), + /* 44 */ + OPCODE(o_sub), + OPCODE(o_addf), + OPCODE(o_subf), + OPCODE(o_mul), + /* 48 */ + OPCODE(o_div), + OPCODE(o_mulf), + OPCODE(o_divf), + OPCODE(o_mod), + /* 52 */ + OPCODE(o_modf), + OPCODE(o_random), + OPCODE(o_invalid), + OPCODE(o_goto), + /* 56 */ + OPCODE(o_oset), + OPCODE(o_oclear), + OPCODE(o_putBy), + OPCODE(o_inc), + /* 60 */ + OPCODE(o_dec), + OPCODE(o_setState), + OPCODE(o_print), + OPCODE(o_message), + /* 64 */ + OPCODE(o_msg), + OPCODE(oww_addTextBox), + OPCODE(oww_setShortText), + OPCODE(oww_setLongText), + /* 68 */ + OPCODE(o_end), + OPCODE(o_done), + OPCODE(os2_printLongText), + OPCODE(o_process), + /* 72 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 76 */ + OPCODE(o_when), + OPCODE(o_if1), + OPCODE(o_if2), + OPCODE(o_isCalled), + /* 80 */ + OPCODE(o_is), + OPCODE(o_invalid), + OPCODE(o_debug), + OPCODE(os2_rescan), + /* 84 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_comment), + /* 88 */ + OPCODE(o_haltAnimation), + OPCODE(o_restartAnimation), + OPCODE(o_getParent), + OPCODE(o_getNext), + /* 92 */ + OPCODE(o_getChildren), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 96 */ + OPCODE(o_picture), + OPCODE(o_loadZone), + OPCODE(os2_animate), + OPCODE(os2_stopAnimate), + /* 100 */ + OPCODE(o_killAnimate), + OPCODE(o_defWindow), + OPCODE(o_window), + OPCODE(o_cls), + /* 104 */ + OPCODE(o_closeWindow), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_addBox), + /* 108 */ + OPCODE(o_delBox), + OPCODE(o_enableBox), + OPCODE(o_disableBox), + OPCODE(o_moveBox), + /* 112 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_doIcons), + OPCODE(o_isClass), + /* 116 */ + OPCODE(o_setClass), + OPCODE(o_unsetClass), + OPCODE(o_invalid), + OPCODE(o_waitSync), + /* 120 */ + OPCODE(o_sync), + OPCODE(o_defObj), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 124 */ + OPCODE(o_invalid), + OPCODE(o_here), + OPCODE(o_doClassIcons), + OPCODE(os2_playTune), + /* 128 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_setAdjNoun), + OPCODE(o_invalid), + /* 132 */ + OPCODE(o_saveUserGame), + OPCODE(o_loadUserGame), + OPCODE(o_invalid), + OPCODE(os1_pauseGame), + /* 136 */ + OPCODE(o_copysf), + OPCODE(o_restoreIcons), + OPCODE(o_freezeZones), + OPCODE(o_placeNoIcons), + /* 140 */ + OPCODE(o_clearTimers), + OPCODE(o_setDollar), + OPCODE(o_isBox), + OPCODE(oe2_doTable), + /* 144 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 148 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(oe2_storeItem), + /* 152 */ + OPCODE(oe2_getItem), + OPCODE(oe2_bSet), + OPCODE(oe2_bClear), + OPCODE(oe2_bZero), + /* 156C */ + OPCODE(oe2_bNotZero), + OPCODE(oe2_getOValue), + OPCODE(oe2_setOValue), + OPCODE(o_invalid), + /* 160 */ + OPCODE(oe2_ink), + OPCODE(os1_screenTextBox), + OPCODE(os1_screenTextMsg), + OPCODE(os1_playEffect), + /* 164 */ + OPCODE(oe2_getDollar2), + OPCODE(oe2_isAdjNoun), + OPCODE(oe2_b2Set), + OPCODE(oe2_b2Clear), + /* 168 */ + OPCODE(oe2_b2Zero), + OPCODE(oe2_b2NotZero), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 172 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(oww_lockZones), + /* 176 */ + OPCODE(oww_unlockZones), + OPCODE(os2_screenTextPObj), + OPCODE(os1_getPathPosn), + OPCODE(os1_scnTxtLongText), + /* 180 */ + OPCODE(os2_mouseOn), + OPCODE(os2_mouseOff), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 184 */ + OPCODE(os1_unloadZone), + OPCODE(o_invalid), + OPCODE(os1_unfreezeZones), + OPCODE(o_invalid), + /* 188 */ + OPCODE(os2_isShortText), + OPCODE(os2_clearMarks), + OPCODE(os2_waitMark), + }; + + _opcodesSimon2 = opcodes; + _numOpcodes = 191; +} + +void AGOSEngine_Simon2::executeOpcode(int opcode) { + OpcodeProcSimon2 op = _opcodesSimon2[opcode].proc; + (this->*op) (); } // ----------------------------------------------------------------------- // Simon 2 Opcodes // ----------------------------------------------------------------------- -void AGOSEngine::os2_printLongText() { +void AGOSEngine_Simon2::os2_printLongText() { // 70: show string from array const char *str = (const char *)getStringPtrByID(_longText[getVarOrByte()]); writeVariable(51, strlen(str) / 53 * 8 + 8); showMessageFormat("%s\n", str); } -void AGOSEngine::os2_rescan() { +void AGOSEngine_Simon2::os2_rescan() { // 83: restart subroutine if (_exitCutscene) { if (getBitFlag(9)) { @@ -88,7 +305,7 @@ void AGOSEngine::os2_rescan() { setScriptReturn(-10); } -void AGOSEngine::os2_animate() { +void AGOSEngine_Simon2::os2_animate() { // 98: start vga uint zoneNum = getVarOrWord(); uint vgaSpriteId = getVarOrWord(); @@ -102,14 +319,14 @@ void AGOSEngine::os2_animate() { _lockWord &= ~0x40; } -void AGOSEngine::os2_stopAnimate() { +void AGOSEngine_Simon2::os2_stopAnimate() { // 99: kill sprite uint a = getVarOrWord(); uint b = getVarOrWord(); stopAnimateSimon2(a, b); } -void AGOSEngine::os2_playTune() { +void AGOSEngine_Simon2::os2_playTune() { // 127: deals with music int music = getVarOrWord(); int track = getVarOrWord(); @@ -131,7 +348,7 @@ void AGOSEngine::os2_playTune() { _midi.startTrack(track); } -void AGOSEngine::os2_screenTextPObj() { +void AGOSEngine_Simon2::os2_screenTextPObj() { // 177: inventory descriptions uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); @@ -216,7 +433,7 @@ void AGOSEngine::os2_screenTextPObj() { } } -void AGOSEngine::os2_mouseOn() { +void AGOSEngine_Simon2::os2_mouseOn() { // 180: force mouseOn if (getGameType() == GType_SIMON2 && getBitFlag(79)) { _mouseCursor = 0; @@ -224,26 +441,26 @@ void AGOSEngine::os2_mouseOn() { _mouseHideCount = 0; } -void AGOSEngine::os2_mouseOff() { +void AGOSEngine_Simon2::os2_mouseOff() { // 181: force mouseOff scriptMouseOff(); changeWindow(1); showMessageFormat("\xC"); } -void AGOSEngine::os2_isShortText() { +void AGOSEngine_Simon2::os2_isShortText() { // 188: string2 is uint i = getVarOrByte(); uint str = getNextStringID(); setScriptCondition(str < _numTextBoxes && _shortText[i] == str); } -void AGOSEngine::os2_clearMarks() { +void AGOSEngine_Simon2::os2_clearMarks() { // 189: clear_op189_flag _marks = 0; } -void AGOSEngine::os2_waitMark() { +void AGOSEngine_Simon2::os2_waitMark() { // 190 uint i = getVarOrByte(); if (!(_marks & (1 << i))) |