From 2d3e77db85b50ae7f6b36bfff658dd02c29f9155 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 15 Apr 2007 05:04:48 +0000 Subject: Split game engines, to allow further cleanups. svn-id: r26481 --- engines/agos/script.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'engines/agos/script.cpp') diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 99f639474d..57cd96350b 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -36,7 +36,7 @@ extern bool isSmartphone(void); namespace AGOS { -void AGOSEngine::setupCommonOpcodes(OpcodeProc *op) { +void AGOSEngine::setupOpcodes(OpcodeProc *op) { // A common set of opcodes for Elvira 2 and later. op[1] = &AGOSEngine::o_at; @@ -147,25 +147,13 @@ void AGOSEngine::setupOpcodes() { switch (getGameType()) { case GType_ELVIRA1: - setupElvira1Opcodes(_opcode_table); - break; case GType_ELVIRA2: - setupElvira2Opcodes(_opcode_table); - break; case GType_WW: - setupWaxworksOpcodes(_opcode_table); - break; case GType_SIMON1: - setupSimon1Opcodes(_opcode_table); - break; case GType_SIMON2: - setupSimon2Opcodes(_opcode_table); - break; case GType_FF: - setupFeebleOpcodes(_opcode_table); - break; case GType_PP: - setupPuzzleOpcodes(_opcode_table); + setupOpcodes(_opcode_table); break; default: error("setupOpcodes: Unknown game"); -- cgit v1.2.3 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.cpp | 143 +++++++----------------------------------------- 1 file changed, 20 insertions(+), 123 deletions(-) (limited to 'engines/agos/script.cpp') diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 57cd96350b..3ba88524d9 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -36,128 +36,8 @@ extern bool isSmartphone(void); namespace AGOS { -void AGOSEngine::setupOpcodes(OpcodeProc *op) { - // A common set of opcodes for Elvira 2 and later. - - op[1] = &AGOSEngine::o_at; - op[2] = &AGOSEngine::o_notAt; - op[5] = &AGOSEngine::o_carried; - op[6] = &AGOSEngine::o_notCarried; - op[7] = &AGOSEngine::o_isAt; - op[11] = &AGOSEngine::o_zero; - op[12] = &AGOSEngine::o_notZero; - op[13] = &AGOSEngine::o_eq; - op[14] = &AGOSEngine::o_notEq; - op[15] = &AGOSEngine::o_gt; - op[16] = &AGOSEngine::o_lt; - op[17] = &AGOSEngine::o_eqf; - op[18] = &AGOSEngine::o_notEqf; - op[19] = &AGOSEngine::o_ltf; - op[20] = &AGOSEngine::o_gtf; - op[23] = &AGOSEngine::o_chance; - op[25] = &AGOSEngine::o_isRoom; - op[26] = &AGOSEngine::o_isObject; - op[27] = &AGOSEngine::o_state; - op[28] = &AGOSEngine::o_oflag; - op[31] = &AGOSEngine::o_destroy; - op[33] = &AGOSEngine::o_place; - op[36] = &AGOSEngine::o_copyff; - op[41] = &AGOSEngine::o_clear; - op[42] = &AGOSEngine::o_let; - op[43] = &AGOSEngine::o_add; - op[44] = &AGOSEngine::o_sub; - op[45] = &AGOSEngine::o_addf; - op[46] = &AGOSEngine::o_subf; - op[47] = &AGOSEngine::o_mul; - op[48] = &AGOSEngine::o_div; - op[49] = &AGOSEngine::o_mulf; - op[50] = &AGOSEngine::o_divf; - op[51] = &AGOSEngine::o_mod; - op[52] = &AGOSEngine::o_modf; - op[53] = &AGOSEngine::o_random; - op[55] = &AGOSEngine::o_goto; - op[56] = &AGOSEngine::o_oset; - op[57] = &AGOSEngine::o_oclear; - op[58] = &AGOSEngine::o_putBy; - op[59] = &AGOSEngine::o_inc; - op[60] = &AGOSEngine::o_dec; - op[61] = &AGOSEngine::o_setState; - op[62] = &AGOSEngine::o_print; - op[63] = &AGOSEngine::o_message; - op[64] = &AGOSEngine::o_msg; - op[68] = &AGOSEngine::o_end; - op[69] = &AGOSEngine::o_done; - op[71] = &AGOSEngine::o_process; - op[76] = &AGOSEngine::o_when; - op[77] = &AGOSEngine::o_if1; - op[78] = &AGOSEngine::o_if2; - op[79] = &AGOSEngine::o_isCalled; - op[80] = &AGOSEngine::o_is; - op[82] = &AGOSEngine::o_debug; - op[87] = &AGOSEngine::o_comment; - op[90] = &AGOSEngine::o_getParent; - op[91] = &AGOSEngine::o_getNext; - op[92] = &AGOSEngine::o_getChildren; - op[96] = &AGOSEngine::o_picture; - op[97] = &AGOSEngine::o_loadZone; - op[100] = &AGOSEngine::o_killAnimate; - op[101] = &AGOSEngine::o_defWindow; - op[102] = &AGOSEngine::o_window; - op[103] = &AGOSEngine::o_cls; - op[104] = &AGOSEngine::o_closeWindow; - op[107] = &AGOSEngine::o_addBox; - op[108] = &AGOSEngine::o_delBox; - op[109] = &AGOSEngine::o_enableBox; - op[110] = &AGOSEngine::o_disableBox; - op[111] = &AGOSEngine::o_moveBox; - op[114] = &AGOSEngine::o_doIcons; - op[115] = &AGOSEngine::o_isClass; - op[116] = &AGOSEngine::o_setClass; - op[117] = &AGOSEngine::o_unsetClass; - op[119] = &AGOSEngine::o_waitSync; - op[120] = &AGOSEngine::o_sync; - op[121] = &AGOSEngine::o_defObj; - op[125] = &AGOSEngine::o_here; - op[126] = &AGOSEngine::o_doClassIcons; - op[130] = &AGOSEngine::o_setAdjNoun; - op[132] = &AGOSEngine::o_saveUserGame; - op[133] = &AGOSEngine::o_loadUserGame; - op[136] = &AGOSEngine::o_copysf; - op[137] = &AGOSEngine::o_restoreIcons; - op[138] = &AGOSEngine::o_freezeZones; - op[139] = &AGOSEngine::o_placeNoIcons; - op[140] = &AGOSEngine::o_clearTimers; - op[141] = &AGOSEngine::o_setDollar; - op[142] = &AGOSEngine::o_isBox; - op[143] = &AGOSEngine::oe2_doTable; - op[151] = &AGOSEngine::oe2_storeItem; - op[152] = &AGOSEngine::oe2_getItem; - op[153] = &AGOSEngine::oe2_bSet; - op[154] = &AGOSEngine::oe2_bClear; - op[155] = &AGOSEngine::oe2_bZero; - op[156] = &AGOSEngine::oe2_bNotZero; - op[157] = &AGOSEngine::oe2_getOValue; - op[158] = &AGOSEngine::oe2_setOValue; - op[160] = &AGOSEngine::oe2_ink; -} - void AGOSEngine::setupOpcodes() { - memset(_opcode_table, 0, sizeof(_opcode_table)); - _numOpcodes = ARRAYSIZE(_opcode_table); - - switch (getGameType()) { - case GType_ELVIRA1: - case GType_ELVIRA2: - case GType_WW: - case GType_SIMON1: - case GType_SIMON2: - case GType_FF: - case GType_PP: - setupOpcodes(_opcode_table); - break; - default: - error("setupOpcodes: Unknown game"); - } + error("setupOpcodes: Unknown game"); } void AGOSEngine::setScriptCondition(bool cond) { @@ -180,6 +60,11 @@ int AGOSEngine::getScriptReturn() { // Common Opcodes // ----------------------------------------------------------------------- +void AGOSEngine::o_invalid() { + // TODO: Better error reporting + error("Invalid opcode"); +} + void AGOSEngine::o_at() { // 1: ptrA parent is setScriptCondition(me()->parent == getNextItemID()); @@ -815,6 +700,18 @@ void AGOSEngine::o_doClassIcons() { mouseOn(); } +void AGOSEngine::o_playTune() { + // 127: play tune + int music = getVarOrWord(); + int track = getVarOrWord(); + + if (music != _lastMusicPlayed) { + _lastMusicPlayed = music; + loadMusic(music); + _midi.startTrack(track); + } +} + void AGOSEngine::o_setAdjNoun() { // 130: set adj noun uint var = getVarOrByte(); @@ -1027,10 +924,10 @@ int AGOSEngine::runScript() { setScriptCondition(true); setScriptReturn(0); - if (opcode > _numOpcodes || !_opcode_table[opcode]) + if (opcode > _numOpcodes) error("Invalid opcode '%d' encountered", opcode); - (this->*_opcode_table[opcode]) (); + executeOpcode(opcode); } while (getScriptCondition() != flag && !getScriptReturn()); return getScriptReturn(); -- cgit v1.2.3 From 5668e15b2efb2aa9ab5bff3cf6b257a3986602ff Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 15 Apr 2007 14:32:58 +0000 Subject: Update reporting of invalid script opcodes. svn-id: r26501 --- engines/agos/script.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'engines/agos/script.cpp') diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 3ba88524d9..ecc43038c1 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -61,8 +61,7 @@ int AGOSEngine::getScriptReturn() { // ----------------------------------------------------------------------- void AGOSEngine::o_invalid() { - // TODO: Better error reporting - error("Invalid opcode"); + error("Invalid opcode %d", _opcode); } void AGOSEngine::o_at() { @@ -883,7 +882,6 @@ void AGOSEngine::writeVariable(uint variable, uint16 contents) { } int AGOSEngine::runScript() { - int opcode; bool flag; do { @@ -891,12 +889,12 @@ int AGOSEngine::runScript() { dumpOpcode(_codePtr); if (getGameType() == GType_ELVIRA1) { - opcode = getVarOrWord(); - if (opcode == 10000) + _opcode = getVarOrWord(); + if (_opcode == 10000) return 0; } else { - opcode = getByte(); - if (opcode == 0xFF) + _opcode = getByte(); + if (_opcode == 0xFF) return 0; } @@ -906,17 +904,17 @@ int AGOSEngine::runScript() { /* Invert condition? */ flag = false; if (getGameType() == GType_ELVIRA1) { - if (opcode == 203) { + if (_opcode == 203) { flag = true; - opcode = getVarOrWord(); - if (opcode == 10000) + _opcode = getVarOrWord(); + if (_opcode == 10000) return 0; } } else { - if (opcode == 0) { + if (_opcode == 0) { flag = true; - opcode = getByte(); - if (opcode == 0xFF) + _opcode = getByte(); + if (_opcode == 0xFF) return 0; } } @@ -924,10 +922,10 @@ int AGOSEngine::runScript() { setScriptCondition(true); setScriptReturn(0); - if (opcode > _numOpcodes) - error("Invalid opcode '%d' encountered", opcode); + if (_opcode > _numOpcodes) + error("Invalid opcode '%d' encountered", _opcode); - executeOpcode(opcode); + executeOpcode(_opcode); } while (getScriptCondition() != flag && !getScriptReturn()); return getScriptReturn(); -- cgit v1.2.3 From b6672f37a97f30298e51b1d4574eeb75a31da1a6 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 13 May 2007 08:46:48 +0000 Subject: Fix bugs #941074 and #828860, by switching to graphics renderer code used by earlier (non-Windows) versions of Simon the Sorcerer 1/2. svn-id: r26825 --- engines/agos/script.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'engines/agos/script.cpp') diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index ecc43038c1..9961a3ff0b 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -447,6 +447,18 @@ void AGOSEngine::o_comment() { void AGOSEngine::o_haltAnimation() { // 88: stop animation _lockWord |= 0x10; + + if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { + VgaTimerEntry *vte = _vgaTimerList; + while (vte->delay) { + if (vte->type == 0) + vte->delay += 10; + vte++; + } + + _scrollCount = 0; + _scrollFlag = 0; + } } void AGOSEngine::o_restartAnimation() { @@ -511,6 +523,13 @@ void AGOSEngine::o_loadZone() { } loadZone(vga_res); + + if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || + getGameType() == GType_WW) { + _copyScnFlag = 0; + _vgaSpriteChanged = 0; + } + _lockWord &= ~0x80; } -- cgit v1.2.3