From eaacfe1eede00d6370d1abb0afe2f0e6cf622b16 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Fri, 18 Mar 2016 00:50:30 +0100 Subject: ADL: Use template for direction opcode --- engines/adl/adl.cpp | 15 ++++++++------- engines/adl/adl.h | 13 ++++++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'engines/adl') diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index ad5f559fe0..8d501d8980 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -330,13 +330,13 @@ void AdlEngine::setupOpcodeTables() { Opcode(o1_setItemPic); // 0x14 Opcode(o1_resetPic); - Opcode(o1_goDirection); - Opcode(o1_goDirection); - Opcode(o1_goDirection); + Opcode(o1_goDirection); + Opcode(o1_goDirection); + Opcode(o1_goDirection); // 0x18 - Opcode(o1_goDirection); - Opcode(o1_goDirection); - Opcode(o1_goDirection); + Opcode(o1_goDirection); + Opcode(o1_goDirection); + Opcode(o1_goDirection); Opcode(o1_takeItem); // 0x1c Opcode(o1_dropItem); @@ -1017,8 +1017,9 @@ bool AdlEngine::o1_resetPic(ScriptEnv &env) { return true; } +template bool AdlEngine::o1_goDirection(ScriptEnv &env) { - byte room = getCurRoom().connections[ARG(0) - IDO_ACT_GO_NORTH]; + byte room = getCurRoom().connections[D]; if (room == 0) { printMessage(_messageIds.cantGoThere); diff --git a/engines/adl/adl.h b/engines/adl/adl.h index e007b15545..ce421143ba 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -90,9 +90,19 @@ typedef Common::Functor1 Opcode; #define IDI_WORD_SIZE 8 +enum Direction { + IDI_DIR_NORTH, + IDI_DIR_SOUTH, + IDI_DIR_EAST, + IDI_DIR_WEST, + IDI_DIR_UP, + IDI_DIR_DOWN, + IDI_DIR_TOTAL +}; + struct Room { byte description; - byte connections[6]; + byte connections[IDI_DIR_TOTAL]; byte track; byte sector; byte offset; @@ -207,6 +217,7 @@ protected: bool o1_placeItem(ScriptEnv &env); bool o1_setItemPic(ScriptEnv &env); bool o1_resetPic(ScriptEnv &env); + template bool o1_goDirection(ScriptEnv &env); bool o1_takeItem(ScriptEnv &env); bool o1_dropItem(ScriptEnv &env); -- cgit v1.2.3