From 8b93142467254526533279c9074d0a2bb7757a94 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Sun, 19 Feb 2017 12:33:15 +0100 Subject: ADL: Implement hires6 direction opcodes --- engines/adl/adl_v5.cpp | 69 ----------------------------------- engines/adl/adl_v5.h | 3 -- engines/adl/hires6.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 72 deletions(-) (limited to 'engines') diff --git a/engines/adl/adl_v5.cpp b/engines/adl/adl_v5.cpp index 31d0033dea..09abefd1ca 100644 --- a/engines/adl/adl_v5.cpp +++ b/engines/adl/adl_v5.cpp @@ -60,75 +60,6 @@ AdlEngine_v5::RegionChunkType AdlEngine_v5::getRegionChunkType(const uint16 addr } } -typedef Common::Functor1Mem OpcodeV5; -#define SetOpcodeTable(x) table = &x; -#define Opcode(x) table->push_back(new OpcodeV5(this, &AdlEngine_v5::x)) -#define OpcodeUnImpl() table->push_back(new OpcodeV5(this, 0)) - -void AdlEngine_v5::setupOpcodeTables() { - Common::Array *table = 0; - - SetOpcodeTable(_condOpcodes); - // 0x00 - OpcodeUnImpl(); - Opcode(o2_isFirstTime); - Opcode(o2_isRandomGT); - Opcode(o4_isItemInRoom); - // 0x04 - Opcode(o5_isNounNotInRoom); - Opcode(o1_isMovesGT); - Opcode(o1_isVarEQ); - Opcode(o2_isCarryingSomething); - // 0x08 - Opcode(o4_isVarGT); - Opcode(o1_isCurPicEQ); - Opcode(o5_abortScript); - - SetOpcodeTable(_actOpcodes); - // 0x00 - OpcodeUnImpl(); - Opcode(o1_varAdd); - Opcode(o1_varSub); - Opcode(o1_varSet); - // 0x04 - Opcode(o1_listInv); - Opcode(o4_moveItem); - Opcode(o1_setRoom); - Opcode(o2_setCurPic); - // 0x08 - Opcode(o2_setPic); - Opcode(o1_printMsg); - Opcode(o5_dummy); - Opcode(o5_setTextMode); - // 0x0c - Opcode(o4_moveAllItems); - Opcode(o1_quit); - Opcode(o5_dummy); - Opcode(o4_save); - // 0x10 - Opcode(o4_restore); - Opcode(o1_restart); - Opcode(o5_setRegionRoom); - Opcode(o5_dummy); - // 0x14 - Opcode(o1_resetPic); - Opcode(o1_goDirection); - Opcode(o1_goDirection); - Opcode(o1_goDirection); - // 0x18 - Opcode(o1_goDirection); - Opcode(o1_goDirection); - Opcode(o1_goDirection); - Opcode(o1_takeItem); - // 0x1c - Opcode(o1_dropItem); - Opcode(o1_setRoomPic); - Opcode(o_winGame); - OpcodeUnImpl(); - // 0x20 - Opcode(o2_initDisk); -} - int AdlEngine_v5::o5_isNounNotInRoom(ScriptEnv &e) { OP_DEBUG_1("\t&& NO_SUCH_ITEMS_IN_ROOM(%s)", itemRoomStr(e.arg(1)).c_str()); diff --git a/engines/adl/adl_v5.h b/engines/adl/adl_v5.h index 0c5837f26c..0d3823d141 100644 --- a/engines/adl/adl_v5.h +++ b/engines/adl/adl_v5.h @@ -34,9 +34,6 @@ public: protected: AdlEngine_v5(OSystem *syst, const AdlGameDescription *gd); - // AdlEngine - virtual void setupOpcodeTables(); - // AdlEngine_v4 virtual RegionChunkType getRegionChunkType(const uint16 addr) const; virtual void initRoomState(RoomState &roomState) const; diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index 01de061584..7955d1aba5 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -44,6 +44,7 @@ public: private: // AdlEngine + void setupOpcodeTables(); void runIntro(); void init(); void initGameState(); @@ -56,12 +57,108 @@ private: // AdlEngine_v2 void printString(const Common::String &str); + template + int o_goDirection(ScriptEnv &e); + static const uint kRegions = 3; static const uint kItems = 15; byte _currVerb, _currNoun; }; +typedef Common::Functor1Mem OpcodeH6; +#define SetOpcodeTable(x) table = &x; +#define Opcode(x) table->push_back(new OpcodeH6(this, &HiRes6Engine::x)) +#define OpcodeUnImpl() table->push_back(new OpcodeH6(this, 0)) + +void HiRes6Engine::setupOpcodeTables() { + Common::Array *table = 0; + + SetOpcodeTable(_condOpcodes); + // 0x00 + OpcodeUnImpl(); + Opcode(o2_isFirstTime); + Opcode(o2_isRandomGT); + Opcode(o4_isItemInRoom); + // 0x04 + Opcode(o5_isNounNotInRoom); + Opcode(o1_isMovesGT); + Opcode(o1_isVarEQ); + Opcode(o2_isCarryingSomething); + // 0x08 + Opcode(o4_isVarGT); + Opcode(o1_isCurPicEQ); + Opcode(o5_abortScript); + + SetOpcodeTable(_actOpcodes); + // 0x00 + OpcodeUnImpl(); + Opcode(o1_varAdd); + Opcode(o1_varSub); + Opcode(o1_varSet); + // 0x04 + Opcode(o1_listInv); + Opcode(o4_moveItem); + Opcode(o1_setRoom); + Opcode(o2_setCurPic); + // 0x08 + Opcode(o2_setPic); + Opcode(o1_printMsg); + Opcode(o5_dummy); + Opcode(o5_setTextMode); + // 0x0c + Opcode(o4_moveAllItems); + Opcode(o1_quit); + Opcode(o5_dummy); + Opcode(o4_save); + // 0x10 + Opcode(o4_restore); + Opcode(o1_restart); + Opcode(o5_setRegionRoom); + Opcode(o5_dummy); + // 0x14 + Opcode(o1_resetPic); + Opcode(o_goDirection); + Opcode(o_goDirection); + Opcode(o_goDirection); + // 0x18 + Opcode(o_goDirection); + Opcode(o_goDirection); + Opcode(o_goDirection); + Opcode(o1_takeItem); + // 0x1c + Opcode(o1_dropItem); + Opcode(o1_setRoomPic); + Opcode(o_winGame); + OpcodeUnImpl(); + // 0x20 + Opcode(o2_initDisk); +} + +template +int HiRes6Engine::o_goDirection(ScriptEnv &e) { + OP_DEBUG_0((Common::String("\tGO_") + dirStr(D) + "()").c_str()); + + byte room = getCurRoom().connections[D]; + + if (room == 0) { + if (getVar(33) == 2) + setVar(34, getVar(34) + 1); + + printMessage(_messageIds.cantGoThere); + return -1; + } + + switchRoom(room); + + if (getVar(33) == 2) { + printMessage(102); + setVar(33, 0); + } + + return -1; +} + #define SECTORS_PER_TRACK 16 #define BYTES_PER_SECTOR 256 -- cgit v1.2.3