From 48c21a1e314c9c3b605e498a1de612d515975b96 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 15 Apr 2007 12:04:47 +0000 Subject: Add eriktorbjorn's patch to split script opcodes into specific game engines. svn-id: r26490 --- engines/agos/script_e2.cpp | 383 +++++++++++++++++++++++++++++++++------------ 1 file changed, 284 insertions(+), 99 deletions(-) (limited to 'engines/agos/script_e2.cpp') diff --git a/engines/agos/script_e2.cpp b/engines/agos/script_e2.cpp index ac4d40a446..cab8f6ddf5 100644 --- a/engines/agos/script_e2.cpp +++ b/engines/agos/script_e2.cpp @@ -27,77 +27,262 @@ namespace AGOS { -void AGOSEngine_Elvira2::setupOpcodes(OpcodeProc *op) { - AGOSEngine::setupOpcodes(op); - - op[8] = &AGOSEngine::oe1_isNotAt; - op[9] = &AGOSEngine::oe1_sibling; - op[10] = &AGOSEngine::oe1_notSibling; - op[21] = &AGOSEngine::oe1_isIn; - op[22] = &AGOSEngine::oe1_isNotIn; - op[24] = &AGOSEngine::oe1_isPlayer; - op[29] = &AGOSEngine::oe1_canPut; - op[34] = &AGOSEngine::oe1_copyof; - op[35] = &AGOSEngine::oe1_copyfo; - op[37] = &AGOSEngine::oe1_whatO; - op[39] = &AGOSEngine::oe1_weigh; - op[54] = &AGOSEngine::oe2_moveDirn; - op[72] = &AGOSEngine::oe2_doClass; - op[73] = &AGOSEngine::oe2_pObj; - op[74] = &AGOSEngine::oe1_pName; - op[75] = &AGOSEngine::oe1_pcName; - op[79] = &AGOSEngine::oe1_isCalled; - op[83] = &AGOSEngine::oe1_rescan; - op[89] = &AGOSEngine::oe2_loadGame; - op[94] = &AGOSEngine::oe1_findMaster; - op[95] = &AGOSEngine::oe1_nextMaster; - op[98] = &AGOSEngine::oe1_animate; - op[99] = &AGOSEngine::oe1_stopAnimate; - op[113] = &AGOSEngine::oe2_drawItem; - op[123] = &AGOSEngine::oe1_setTime; - op[124] = &AGOSEngine::oe1_ifTime; - op[127] = &AGOSEngine::os1_playTune; - op[135] = &AGOSEngine::oe2_pauseGame; - op[144] = &AGOSEngine::oe2_setDoorOpen; - op[145] = &AGOSEngine::oe2_setDoorClosed; - op[146] = &AGOSEngine::oe2_setDoorLocked; - op[147] = &AGOSEngine::oe2_setDoorClosed; - op[148] = &AGOSEngine::oe2_ifDoorOpen; - op[149] = &AGOSEngine::oe2_ifDoorClosed; - op[150] = &AGOSEngine::oe2_ifDoorLocked; - op[161] = &AGOSEngine::oe2_printStats; - op[165] = &AGOSEngine::oe2_setSuperRoom; - op[166] = &AGOSEngine::oe2_getSuperRoom; - op[167] = &AGOSEngine::oe2_setExitOpen; - op[168] = &AGOSEngine::oe2_setExitClosed; - op[169] = &AGOSEngine::oe2_setExitLocked; - op[170] = &AGOSEngine::oe2_setExitClosed; - op[171] = &AGOSEngine::oe2_ifExitOpen; - op[172] = &AGOSEngine::oe2_ifExitClosed; - op[173] = &AGOSEngine::oe2_ifExitLocked; - op[174] = &AGOSEngine::oe2_unk174; - op[175] = &AGOSEngine::oe2_getDollar2; - op[176] = &AGOSEngine::oe2_setSRExit; - op[177] = &AGOSEngine::oe2_unk177; - op[178] = &AGOSEngine::oe2_unk178; - op[179] = &AGOSEngine::oe2_isAdjNoun; - op[180] = &AGOSEngine::oe2_b2Set; - op[181] = &AGOSEngine::oe2_b2Clear; - op[182] = &AGOSEngine::oe2_b2Zero; - op[183] = &AGOSEngine::oe2_b2NotZero; +#define OPCODE(x) _OPCODE(AGOSEngine_Elvira2, x) + +void AGOSEngine_Elvira2::setupOpcodes() { + static const OpcodeEntryElvira2 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(oe1_isNotAt), + OPCODE(oe1_sibling), + OPCODE(oe1_notSibling), + 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(oe1_isIn), + OPCODE(oe1_isNotIn), + OPCODE(o_chance), + /* 24 */ + OPCODE(oe1_isPlayer), + OPCODE(o_isRoom), + OPCODE(o_isObject), + OPCODE(o_state), + /* 28 */ + OPCODE(o_oflag), + OPCODE(oe1_canPut), + OPCODE(o_invalid), + OPCODE(o_destroy), + /* 32 */ + OPCODE(o_invalid), + OPCODE(o_place), + OPCODE(oe1_copyof), + OPCODE(oe1_copyfo), + /* 36 */ + OPCODE(o_copyff), + OPCODE(oe1_whatO), + OPCODE(o_invalid), + OPCODE(oe1_weigh), + /* 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(oe2_moveDirn), + 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(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 68 */ + OPCODE(o_end), + OPCODE(o_done), + OPCODE(o_invalid), + OPCODE(o_process), + /* 72 */ + OPCODE(oe2_doClass), + OPCODE(oe2_pObj), + OPCODE(oe1_pName), + OPCODE(oe1_pcName), + /* 76 */ + OPCODE(o_when), + OPCODE(o_if1), + OPCODE(o_if2), + OPCODE(oe1_isCalled), + /* 80 */ + OPCODE(o_is), + OPCODE(o_invalid), + OPCODE(o_debug), + OPCODE(oe1_rescan), + /* 84 */ + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_invalid), + OPCODE(o_comment), + /* 88 */ + OPCODE(o_invalid), + OPCODE(oe2_loadGame), + OPCODE(o_getParent), + OPCODE(o_getNext), + /* 92 */ + OPCODE(o_getChildren), + OPCODE(o_invalid), + OPCODE(oe1_findMaster), + OPCODE(oe1_nextMaster), + /* 96 */ + OPCODE(o_picture), + OPCODE(o_loadZone), + OPCODE(oe1_animate), + OPCODE(oe1_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(oe2_drawItem), + 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(oe1_setTime), + /* 124 */ + OPCODE(oe1_ifTime), + OPCODE(o_here), + OPCODE(o_doClassIcons), + OPCODE(o_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(oe2_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(oe2_setDoorOpen), + OPCODE(oe2_setDoorClosed), + OPCODE(oe2_setDoorLocked), + OPCODE(oe2_setDoorClosed), + /* 148 */ + OPCODE(oe2_ifDoorOpen), + OPCODE(oe2_ifDoorClosed), + OPCODE(oe2_ifDoorLocked), + OPCODE(oe2_storeItem), + /* 152 */ + OPCODE(oe2_getItem), + OPCODE(oe2_bSet), + OPCODE(oe2_bClear), + OPCODE(oe2_bZero), + /* 156 */ + OPCODE(oe2_bNotZero), + OPCODE(oe2_getOValue), + OPCODE(oe2_setOValue), + OPCODE(o_invalid), + /* 160 */ + OPCODE(oe2_ink), + OPCODE(oe2_printStats), + OPCODE(o_invalid), + OPCODE(o_invalid), + /* 164 */ + OPCODE(o_invalid), + OPCODE(oe2_setSuperRoom), + OPCODE(oe2_getSuperRoom), + OPCODE(oe2_setExitOpen), + /* 168 */ + OPCODE(oe2_setExitClosed), + OPCODE(oe2_setExitLocked), + OPCODE(oe2_setExitClosed), + OPCODE(oe2_ifExitOpen), + /* 172 */ + OPCODE(oe2_ifExitClosed), + OPCODE(oe2_ifExitLocked), + OPCODE(oe2_unk174), + OPCODE(oe2_getDollar2), + /* 176 */ + OPCODE(oe2_setSRExit), + OPCODE(oe2_unk177), + OPCODE(oe2_unk178), + OPCODE(oe2_isAdjNoun), + /* 180 */ + OPCODE(oe2_b2Set), + OPCODE(oe2_b2Clear), + OPCODE(oe2_b2Zero), + OPCODE(oe2_b2NotZero) + }; + + _opcodesElvira2 = opcodes; + _numOpcodes = 184; +} + +void AGOSEngine_Elvira2::executeOpcode(int opcode) { + OpcodeProcElvira2 op = _opcodesElvira2[opcode].proc; + (this->*op) (); } // ----------------------------------------------------------------------- // Elvira 2 Opcodes // ----------------------------------------------------------------------- -void AGOSEngine::oe2_moveDirn() { +void AGOSEngine_Elvira2::oe2_moveDirn() { // 54: move direction int16 d = getVarOrByte(); moveDirn_e2(me(), d); } -void AGOSEngine::oe2_doClass() { +void AGOSEngine_Elvira2::oe2_doClass() { // 72: do class Item *i = getNextItemPtr(); byte cm = getByte(); @@ -120,7 +305,7 @@ void AGOSEngine::oe2_doClass() { } } -void AGOSEngine::oe2_pObj() { +void AGOSEngine_Elvira2::oe2_pObj() { // 73: print object SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); @@ -128,7 +313,7 @@ void AGOSEngine::oe2_pObj() { showMessageFormat((const char *)getStringPtrByID(subObject->objectFlagValue[0])); } -void AGOSEngine::oe2_loadGame() { +void AGOSEngine_Elvira2::oe2_loadGame() { // 89: load game uint16 stringId = getNextStringID(); debug(0, "oe1_loadGame: stub (%s)", (const char *)getStringPtrByID(stringId)); @@ -140,7 +325,7 @@ void AGOSEngine::oe2_loadGame() { } } -void AGOSEngine::oe2_drawItem() { +void AGOSEngine_Elvira2::oe2_drawItem() { // 113: draw item Item *i = getNextItemPtr(); int a = getVarOrByte(); @@ -151,7 +336,7 @@ void AGOSEngine::oe2_drawItem() { mouseOn(); } -void AGOSEngine::oe2_doTable() { +void AGOSEngine_Elvira2::oe2_doTable() { // 143: start item sub Item *i = getNextItemPtr(); @@ -176,7 +361,7 @@ void AGOSEngine::oe2_doTable() { } } -void AGOSEngine::oe2_pauseGame() { +void AGOSEngine_Elvira2::oe2_pauseGame() { // 135: pause game HitArea *ha; @@ -205,53 +390,53 @@ void AGOSEngine::oe2_pauseGame() { _gameStoppedClock = time(NULL) - pauseTime + _gameStoppedClock; } -void AGOSEngine::oe2_setDoorOpen() { +void AGOSEngine_Elvira2::oe2_setDoorOpen() { // 144: set door open Item *i = getNextItemPtr(); setDoorState(i, getVarOrByte(), 1); } -void AGOSEngine::oe2_setDoorClosed() { +void AGOSEngine_Elvira2::oe2_setDoorClosed() { // 145: set door closed Item *i = getNextItemPtr(); setDoorState(i, getVarOrByte(), 2); } -void AGOSEngine::oe2_setDoorLocked() { +void AGOSEngine_Elvira2::oe2_setDoorLocked() { // 146: set door locked Item *i = getNextItemPtr(); setDoorState(i, getVarOrByte(), 3); } -void AGOSEngine::oe2_ifDoorOpen() { +void AGOSEngine_Elvira2::oe2_ifDoorOpen() { // 148: if door open Item *i = getNextItemPtr(); uint16 d = getVarOrByte(); setScriptCondition(getDoorState(i, d) == 1); } -void AGOSEngine::oe2_ifDoorClosed() { +void AGOSEngine_Elvira2::oe2_ifDoorClosed() { // 149: if door closed Item *i = getNextItemPtr(); uint16 d = getVarOrByte(); setScriptCondition(getDoorState(i, d) == 2); } -void AGOSEngine::oe2_ifDoorLocked() { +void AGOSEngine_Elvira2::oe2_ifDoorLocked() { // 150: if door locked Item *i=getNextItemPtr(); uint16 d = getVarOrByte(); setScriptCondition(getDoorState(i, d) == 3); } -void AGOSEngine::oe2_storeItem() { +void AGOSEngine_Elvira2::oe2_storeItem() { // 151: set array6 to item uint var = getVarOrByte(); Item *item = getNextItemPtr(); _itemStore[var] = item; } -void AGOSEngine::oe2_getItem() { +void AGOSEngine_Elvira2::oe2_getItem() { // 152: set m1 to m3 to array 6 Item *item = _itemStore[getVarOrByte()]; uint var = getVarOrByte(); @@ -262,22 +447,22 @@ void AGOSEngine::oe2_getItem() { } } -void AGOSEngine::oe2_bSet() { +void AGOSEngine_Elvira2::oe2_bSet() { // 153: set bit setBitFlag(getVarWrapper(), true); } -void AGOSEngine::oe2_bClear() { +void AGOSEngine_Elvira2::oe2_bClear() { // 154: clear bit setBitFlag(getVarWrapper(), false); } -void AGOSEngine::oe2_bZero() { +void AGOSEngine_Elvira2::oe2_bZero() { // 155: is bit clear setScriptCondition(!getBitFlag(getVarWrapper())); } -void AGOSEngine::oe2_bNotZero() { +void AGOSEngine_Elvira2::oe2_bNotZero() { // 156: is bit set uint bit = getVarWrapper(); @@ -289,7 +474,7 @@ void AGOSEngine::oe2_bNotZero() { setScriptCondition(getBitFlag(bit)); } -void AGOSEngine::oe2_getOValue() { +void AGOSEngine_Elvira2::oe2_getOValue() { // 157: get item int prop Item *item = getNextItemPtr(); SubObject *subObject = (SubObject *)findChildOfType(item, 2); @@ -303,7 +488,7 @@ void AGOSEngine::oe2_getOValue() { } } -void AGOSEngine::oe2_setOValue() { +void AGOSEngine_Elvira2::oe2_setOValue() { // 158: set item prop Item *item = getNextItemPtr(); SubObject *subObject = (SubObject *)findChildOfType(item, 2); @@ -316,12 +501,12 @@ void AGOSEngine::oe2_setOValue() { } } -void AGOSEngine::oe2_ink() { +void AGOSEngine_Elvira2::oe2_ink() { // 160 setTextColor(getVarOrByte()); } -void AGOSEngine::oe2_printStats() { +void AGOSEngine_Elvira2::oe2_printStats() { // 161: print stats WindowBlock *window = _dummyWindow; int val; @@ -366,17 +551,17 @@ void AGOSEngine::oe2_printStats() { mouseOn(); } -void AGOSEngine::oe2_setSuperRoom() { +void AGOSEngine_Elvira2::oe2_setSuperRoom() { // 165: set super room _superRoomNumber = getVarOrWord(); } -void AGOSEngine::oe2_getSuperRoom() { +void AGOSEngine_Elvira2::oe2_getSuperRoom() { // 166: get super room writeNextVarContents(_superRoomNumber); } -void AGOSEngine::oe2_setExitOpen() { +void AGOSEngine_Elvira2::oe2_setExitOpen() { // 167: set exit open Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); @@ -384,7 +569,7 @@ void AGOSEngine::oe2_setExitOpen() { setExitState(i, n, d, 1); } -void AGOSEngine::oe2_setExitClosed() { +void AGOSEngine_Elvira2::oe2_setExitClosed() { // 168: set exit closed Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); @@ -392,7 +577,7 @@ void AGOSEngine::oe2_setExitClosed() { setExitState(i, n, d, 2); } -void AGOSEngine::oe2_setExitLocked() { +void AGOSEngine_Elvira2::oe2_setExitLocked() { // 169: set exit locked Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); @@ -400,7 +585,7 @@ void AGOSEngine::oe2_setExitLocked() { setExitState(i, n, d, 3); } -void AGOSEngine::oe2_ifExitOpen() { +void AGOSEngine_Elvira2::oe2_ifExitOpen() { // 171: if exit open Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); @@ -408,7 +593,7 @@ void AGOSEngine::oe2_ifExitOpen() { setScriptCondition(getExitState(i, n, d) == 1); } -void AGOSEngine::oe2_ifExitClosed() { +void AGOSEngine_Elvira2::oe2_ifExitClosed() { // 172: if exit closed Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); @@ -416,7 +601,7 @@ void AGOSEngine::oe2_ifExitClosed() { setScriptCondition(getExitState(i, n, d) == 2); } -void AGOSEngine::oe2_ifExitLocked() { +void AGOSEngine_Elvira2::oe2_ifExitLocked() { // 173: if exit locked Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); @@ -424,13 +609,13 @@ void AGOSEngine::oe2_ifExitLocked() { setScriptCondition(getExitState(i, n, d) == 3); } -void AGOSEngine::oe2_unk174() { +void AGOSEngine_Elvira2::oe2_unk174() { // 174: uint a = getVarOrWord(); debug(0, "oe2_unk174: stub (%d)", a); } -void AGOSEngine::oe2_getDollar2() { +void AGOSEngine_Elvira2::oe2_getDollar2() { // 175 _showPreposition = true; @@ -455,7 +640,7 @@ void AGOSEngine::oe2_getDollar2() { _showPreposition = false; } -void AGOSEngine::oe2_setSRExit() { +void AGOSEngine_Elvira2::oe2_setSRExit() { // 176: set super room exit Item *i = getNextItemPtr(); uint n = getVarOrWord(); @@ -464,44 +649,44 @@ void AGOSEngine::oe2_setSRExit() { setSRExit(i, n, d, s); } -void AGOSEngine::oe2_unk177() { +void AGOSEngine_Elvira2::oe2_unk177() { // 177: set unknown vga event uint a = getVarOrByte(); debug(0, "oe2_unk177: stub (%d)", a); } -void AGOSEngine::oe2_unk178() { +void AGOSEngine_Elvira2::oe2_unk178() { // 178: set unknown vga event uint a = getVarOrByte(); debug(0, "oe2_unk178: stub (%d)", a); } -void AGOSEngine::oe2_isAdjNoun() { +void AGOSEngine_Elvira2::oe2_isAdjNoun() { // 179: item unk1 unk2 is Item *item = getNextItemPtr(); int16 a = getNextWord(), b = getNextWord(); setScriptCondition(item->adjective == a && item->noun == b); } -void AGOSEngine::oe2_b2Set() { +void AGOSEngine_Elvira2::oe2_b2Set() { // 180: set bit2 uint bit = getVarOrByte(); _bitArrayTwo[bit / 16] |= (1 << (bit & 15)); } -void AGOSEngine::oe2_b2Clear() { +void AGOSEngine_Elvira2::oe2_b2Clear() { // 181: clear bit2 uint bit = getVarOrByte(); _bitArrayTwo[bit / 16] &= ~(1 << (bit & 15)); } -void AGOSEngine::oe2_b2Zero() { +void AGOSEngine_Elvira2::oe2_b2Zero() { // 182: is bit2 clear uint bit = getVarOrByte(); setScriptCondition((_bitArrayTwo[bit / 16] & (1 << (bit & 15))) == 0); } -void AGOSEngine::oe2_b2NotZero() { +void AGOSEngine_Elvira2::oe2_b2NotZero() { // 183: is bit2 set uint bit = getVarOrByte(); setScriptCondition((_bitArrayTwo[bit / 16] & (1 << (bit & 15))) != 0); -- cgit v1.2.3