aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWalter van Niftrik2016-02-28 13:24:41 +0100
committerWalter van Niftrik2016-03-09 10:03:13 +0100
commit6a1dd071978f8ef48cb980d736877f1944a9a78f (patch)
tree8a59134274e4cbaa14d7c0c4623f1e90fc4e4746 /engines
parent1e17a23879c6e81a09e2ad80d0ae7a1c0cc10732 (diff)
downloadscummvm-rg350-6a1dd071978f8ef48cb980d736877f1944a9a78f.tar.gz
scummvm-rg350-6a1dd071978f8ef48cb980d736877f1944a9a78f.tar.bz2
scummvm-rg350-6a1dd071978f8ef48cb980d736877f1944a9a78f.zip
ADL: Move more functionality into base class
Diffstat (limited to 'engines')
-rw-r--r--engines/adl/adl.cpp303
-rw-r--r--engines/adl/adl.h46
-rw-r--r--engines/adl/hires1.cpp395
-rw-r--r--engines/adl/hires1.h25
-rw-r--r--engines/adl/parser.cpp6
5 files changed, 420 insertions, 355 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 3ee72e8255..2c11290919 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -103,6 +103,309 @@ void AdlEngine::printStrings(Common::SeekableReadStream &stream, int count) {
};
}
+Common::String AdlEngine::getEngineString(int str) {
+ return _strings[str];
+}
+
+void AdlEngine::wordWrap(Common::String &str) {
+ uint end = 39;
+
+ while (1) {
+ if (str.size() <= end)
+ return;
+
+ while (str[end] != APPLECHAR(' '))
+ --end;
+
+ str.setChar(APPLECHAR('\r'), end);
+ end += 40;
+ }
+}
+
+void AdlEngine::printMessage(uint idx, bool wait) {
+ Common::String msg = _messages[idx - 1];
+ wordWrap(msg);
+ _display->printString(msg);
+
+ if (wait)
+ _display->delay(14 * 166018 / 1000);
+}
+
+void AdlEngine::printEngineMessage(EngineMessage msg) {
+ printMessage(getEngineMessage(msg));
+}
+
+void AdlEngine::readCommands(Common::ReadStream &stream, Commands &commands) {
+ while (1) {
+ Command command;
+ command.room = stream.readByte();
+
+ if (command.room == 0xff)
+ return;
+
+ command.verb = stream.readByte();
+ command.noun = stream.readByte();
+
+ byte scriptSize = stream.readByte() - 6;
+
+ command.numCond = stream.readByte();
+ command.numAct = stream.readByte();
+
+ for (uint i = 0; i < scriptSize; ++i)
+ command.script.push_back(stream.readByte());
+
+ if (stream.eos() || stream.err())
+ error("Failed to read commands");
+
+ commands.push_back(command);
+ }
+}
+
+void AdlEngine::takeItem(byte noun) {
+ Common::Array<Item>::iterator it;
+
+ for (it = _inventory.begin(); it != _inventory.end(); ++it) {
+ if (it->field1 != noun || it->field2 != _room)
+ continue;
+
+ if (it->field7 == 2) {
+ printEngineMessage(IDI_MSG_ITEM_DOESNT_MOVE);
+ return;
+ }
+
+ if (it->field7 == 1) {
+ it->field2 = 0xfe;
+ it->field7 = 1;
+ return;
+ }
+
+ Common::Array<byte>::const_iterator it2;
+ for (it2 = it->field10.begin(); it->field10.end(); ++it2) {
+ if (*it2 == _rooms[_room].picture) {
+ it->field2 = 0xfe;
+ it->field7 = 1;
+ return;
+ }
+ }
+ }
+
+ printEngineMessage(IDI_MSG_ITEM_NOT_HERE);
+}
+
+void AdlEngine::dropItem(byte noun) {
+ Common::Array<Item>::iterator it;
+
+ for (it = _inventory.begin(); it != _inventory.end(); ++it) {
+ if (it->field1 != noun || it->field2 != 0xfe)
+ continue;
+
+ it->field2 = _room;
+ it->field7 = 1;
+ return;
+ }
+
+ // Don't understand
+ printEngineMessage(IDI_MSG_DONT_UNDERSTAND);
+}
+
+void AdlEngine::doActions(const Command &command, byte noun, byte offset) {
+ for (uint i = 0; i < command.numAct; ++i) {
+ switch (command.script[offset]) {
+ case 1:
+ _variables[command.script[offset + 2]] += command.script[offset + 1];
+ offset += 3;
+ break;
+ case 2:
+ _variables[command.script[offset + 2]] -= command.script[offset + 1];
+ offset += 3;
+ break;
+ case 3:
+ _variables[command.script[offset + 1]] = command.script[offset + 2];
+ offset += 3;
+ break;
+ case 4: {
+ Common::Array<Item>::const_iterator it;
+
+ for (it = _inventory.begin(); it != _inventory.end(); ++it)
+ if (it->field2 == 0xfe)
+ printMessage(it->field8);
+
+ ++offset;
+ break;
+ }
+ case 5:
+ _inventory[command.script[offset + 1] - 1].field2 = command.script[offset + 2];
+ offset += 3;
+ break;
+ case 6:
+ _rooms[_room].picture = _rooms[_room].field8;
+ _room = command.script[offset + 1];
+ offset += 2;
+ break;
+ case 7:
+ _rooms[_room].picture = command.script[offset + 1];
+ offset += 2;
+ break;
+ case 8:
+ _rooms[_room].field8 = _rooms[_room].picture = command.script[offset + 1];
+ offset += 2;
+ break;
+ case 9:
+ printMessage(command.script[offset + 1]);
+ offset += 2;
+ break;
+ case 0xa:
+ _isDark = false;
+ ++offset;
+ break;
+ case 0xb:
+ _isDark = true;
+ ++offset;
+ break;
+ case 0xf:
+ warning("Save game not implemented");
+ ++offset;
+ break;
+ case 0x10:
+ warning("Load game not implemented");
+ ++offset;
+ break;
+ case 0x11: {
+ _display->printString(_strings[IDI_STR_PLAY_AGAIN]);
+ Common::String input = _display->inputString();
+ if (input.size() == 0 || input[0] != APPLECHAR('N')) {
+ warning("Restart game not implemented");
+ return;
+ }
+ // Fall-through
+ }
+ case 0xd:
+ printEngineMessage(IDI_MSG_THANKS_FOR_PLAYING);
+ quitGame();
+ return;
+ case 0x12: {
+ byte item = command.script[offset + 1] - 1;
+ _inventory[item].field2 = command.script[offset + 2];
+ _inventory[item].field5 = command.script[offset + 3];
+ _inventory[item].field6 = command.script[offset + 4];
+ offset += 5;
+ break;
+ }
+ case 0x13: {
+ byte item = command.script[offset + 2] - 1;
+ _inventory[item].field3 = command.script[offset + 1];
+ offset += 3;
+ break;
+ }
+ case 0x14:
+ _rooms[_room].picture = _rooms[_room].field8;
+ ++offset;
+ break;
+ case 0x15:
+ case 0x16:
+ case 0x17:
+ case 0x18:
+ case 0x19:
+ case 0x1a: {
+ byte room = _rooms[_room].connections[command.script[offset] - 0x15];
+
+ if (room == 0) {
+ printEngineMessage(IDI_MSG_CANT_GO_THERE);
+ return;
+ }
+
+ _rooms[_room].picture = _rooms[_room].field8;
+ _room = room;
+ return;
+ }
+ case 0x1b:
+ takeItem(noun);
+ ++offset;
+ break;
+ case 0x1c:
+ dropItem(noun);
+ ++offset;
+ break;
+ case 0x1d:
+ _rooms[command.script[offset + 1]].field8 = _rooms[command.script[offset + 1]].picture = command.script[offset + 2];
+ offset += 3;
+ break;
+ default:
+ error("Invalid action opcode %02x", command.script[offset]);
+ }
+ }
+}
+
+bool AdlEngine::checkCommand(const Command &command, byte verb, byte noun) {
+ if (command.room != 0xfe && command.room != _room)
+ return false;
+
+ if (command.verb != 0xfe && command.verb != verb)
+ return false;
+
+ if (command.noun != 0xfe && command.noun != noun)
+ return false;
+
+ uint offset = 0;
+ for (uint i = 0; i < command.numCond; ++i) {
+ switch (command.script[offset]) {
+ case 3:
+ if (_inventory[command.script[offset + 1] - 1].field2 != command.script[offset + 2])
+ return false;
+ offset += 3;
+ break;
+ case 5:
+ if (command.script[offset + 1] > _steps)
+ return false;
+ offset += 2;
+ break;
+ case 6:
+ if (_variables[command.script[offset + 1]] != command.script[offset + 2])
+ return false;
+ offset += 3;
+ break;
+ case 9:
+ if (_rooms[_room].picture != command.script[offset + 1])
+ return false;
+ offset += 2;
+ break;
+ case 10:
+ if (_inventory[command.script[offset + 1] - 1].field3 != command.script[offset + 2])
+ return false;
+ offset += 3;
+ break;
+ default:
+ error("Invalid condition opcode %02x", command.script[offset]);
+ }
+ }
+
+ doActions(command, noun, offset);
+
+ return true;
+}
+
+bool AdlEngine::doOneCommand(const Commands &commands, byte verb, byte noun) {
+ Commands::const_iterator it;
+
+ for (it = commands.begin(); it != commands.end(); ++it)
+ if (checkCommand(*it, verb, noun))
+ return true;
+
+ return false;
+}
+
+void AdlEngine::doAllCommands(const Commands &commands, byte verb, byte noun) {
+ Commands::const_iterator it;
+
+ for (it = commands.begin(); it != commands.end(); ++it)
+ checkCommand(*it, verb, noun);
+}
+
+void AdlEngine::clearScreen() {
+ _display->setMode(Display::kModeMixed);
+ _display->clear(0x00);
+}
+
AdlEngine *AdlEngine::create(GameType type, OSystem *syst, const AdlGameDescription *gd) {
switch(type) {
case kGameTypeHires1:
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 5252916c2f..beb915ca9f 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -42,16 +42,33 @@ class Parser;
class Console;
struct AdlGameDescription;
+struct StringOffset {
+ int stringIdx;
+ uint offset;
+};
+
enum GameType {
kGameTypeNone = 0,
kGameTypeHires1
};
-enum {
- STR_COMMON_ENTERCMD,
- STR_COMMON_VERBERR,
- STR_COMMON_NOUNERR,
- STR_CUSTOM_START
+// Messages used outside of scripts
+enum EngineMessage {
+ IDI_MSG_CANT_GO_THERE,
+ IDI_MSG_DONT_UNDERSTAND,
+ IDI_MSG_ITEM_DOESNT_MOVE,
+ IDI_MSG_ITEM_NOT_HERE,
+ IDI_MSG_THANKS_FOR_PLAYING
+};
+
+// Strings embedded in the executable
+enum EngineString {
+ IDI_STR_ENTER_COMMAND,
+ IDI_STR_VERB_ERROR,
+ IDI_STR_NOUN_ERROR,
+ IDI_STR_PLAY_AGAIN,
+
+ IDI_STR_TOTAL
};
struct Room {
@@ -99,17 +116,29 @@ public:
static AdlEngine *create(GameType type, OSystem *syst, const AdlGameDescription *gd);
Common::Error run();
- virtual Common::String getExeString(uint id) = 0;
+ virtual Common::String getEngineString(int str);
protected:
virtual void runGame() = 0;
+ virtual uint getEngineMessage(EngineMessage msg) = 0;
Common::String readString(Common::ReadStream &stream, byte until = 0);
void printStrings(Common::SeekableReadStream &stream, int count = 1);
+ virtual void printMessage(uint idx, bool wait = true);
+ void wordWrap(Common::String &str);
+ void readCommands(Common::ReadStream &stream, Commands &commands);
+ bool checkCommand(const Command &command, byte verb, byte noun);
+ bool doOneCommand(const Commands &commands, byte verb, byte noun);
+ void doAllCommands(const Commands &commands, byte verb, byte noun);
+ void doActions(const Command &command, byte noun, byte offset);
+ void clearScreen();
+ void takeItem(byte noun);
+ void dropItem(byte noun);
Display *_display;
Parser *_parser;
- Common::Array<Common::String> _msgStrings;
+ Common::Array<Common::String> _strings;
+ Common::Array<Common::String> _messages;
Common::Array<Picture> _pictures;
Common::Array<Item> _inventory;
Common::Array<Common::Point> _itemOffsets;
@@ -123,6 +152,9 @@ protected:
uint16 _steps;
Common::Array<byte> _variables;
bool _isDark;
+
+private:
+ void printEngineMessage(EngineMessage);
};
AdlEngine *HiRes1Engine__create(OSystem *syst, const AdlGameDescription *gd);
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 28aa13568d..7d52d2ab05 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -41,8 +41,34 @@
namespace Adl {
-static uint exeStrings[STR_MH_TOTAL] = {
- 23484, 23375, 23438, 27658, 0x6c31, 27729, 27772, 0x5f1e
+// Messages used outside of scripts
+#define IDI_HR1_MSG_CANT_GO_THERE 137
+#define IDI_HR1_MSG_DONT_UNDERSTAND 37
+#define IDI_HR1_MSG_ITEM_DOESNT_MOVE 151
+#define IDI_HR1_MSG_ITEM_NOT_HERE 152
+#define IDI_HR1_MSG_THANKS_FOR_PLAYING 140
+#define IDI_HR1_MSG_DONT_HAVE_IT 127
+#define IDI_HR1_MSG_GETTING_DARK 7
+
+// Strings embedded in the executable
+enum {
+ IDI_HR1_STR_CANT_GO_THERE = IDI_STR_TOTAL,
+ IDI_HR1_STR_DONT_HAVE_IT,
+ IDI_HR1_STR_DONT_UNDERSTAND,
+ IDI_HR1_STR_GETTING_DARK,
+
+ IDI_HR1_STR_TOTAL
+};
+
+static const StringOffset stringOffsets[] = {
+ { IDI_STR_ENTER_COMMAND, 0x5bbc },
+ { IDI_STR_VERB_ERROR, 0x5b4f },
+ { IDI_STR_NOUN_ERROR, 0x5b8e },
+ { IDI_STR_PLAY_AGAIN, 0x5f1e },
+ { IDI_HR1_STR_CANT_GO_THERE, 0x6c0a },
+ { IDI_HR1_STR_DONT_HAVE_IT, 0x6c31 },
+ { IDI_HR1_STR_DONT_UNDERSTAND, 0x6c51 },
+ { IDI_HR1_STR_GETTING_DARK, 0x6c7c }
};
HiRes1Engine::HiRes1Engine(OSystem *syst, const AdlGameDescription *gd) :
@@ -225,324 +251,6 @@ void HiRes1Engine::showRoom() {
printMessage(_rooms[_room].description, false);
}
-Common::String HiRes1Engine::getExeString(uint idx) {
- return _exeStrings[idx];
-}
-
-void HiRes1Engine::wordWrap(Common::String &str) {
- uint end = 39;
-
- while (1) {
- if (str.size() <= end)
- return;
-
- while (str[end] != APPLECHAR(' '))
- --end;
-
- str.setChar(APPLECHAR('\r'), end);
- end += 40;
- }
-}
-
-void HiRes1Engine::printMessage(uint idx, bool wait) {
- // Hardcoded overrides that don't wait after printing
- // Note: strings may differ slightly from the ones in MESSAGES
- switch (idx) {
- case 137:
- _display->printString(_exeStrings[STR_MH_DIRERR]);
- return;
- case 127:
- _display->printString(_exeStrings[STR_MH_DONTHAVEIT]);
- return;
- case 37:
- _display->printString(_exeStrings[STR_MH_DONTUNDERSTAND]);
- return;
- case 7:
- _display->printString(_exeStrings[STR_MH_GETTINGDARK]);
- return;
- }
-
- Common::String msg = _msgStrings[idx - 1];
- wordWrap(msg);
- _display->printString(msg);
-
- if (wait)
- _display->delay(14 * 166018 / 1000);
-}
-
-void HiRes1Engine::readCommands(Common::ReadStream &stream, Commands &commands) {
- while (1) {
- Command command;
- command.room = stream.readByte();
-
- if (command.room == 0xff)
- return;
-
- command.verb = stream.readByte();
- command.noun = stream.readByte();
-
- byte scriptSize = stream.readByte() - 6;
-
- command.numCond = stream.readByte();
- command.numAct = stream.readByte();
-
- for (uint i = 0; i < scriptSize; ++i)
- command.script.push_back(stream.readByte());
-
- if (stream.eos() || stream.err())
- error("Failed to read commands");
-
- commands.push_back(command);
- }
-}
-
-void HiRes1Engine::takeItem(byte noun) {
- Common::Array<Item>::iterator it;
-
- for (it = _inventory.begin(); it != _inventory.end(); ++it) {
- if (it->field1 != noun || it->field2 != _room)
- continue;
-
- if (it->field7 == 2) {
- // It doesn't move
- printMessage(151);
- return;
- }
-
- if (it->field7 == 1) {
- it->field2 = 0xfe;
- it->field7 = 1;
- return;
- }
-
- Common::Array<byte>::const_iterator it2;
- for (it2 = it->field10.begin(); it->field10.end(); ++it2) {
- if (*it2 == _rooms[_room].picture) {
- it->field2 = 0xfe;
- it->field7 = 1;
- return;
- }
- }
- }
-
- // Item not here
- printMessage(152);
-}
-
-void HiRes1Engine::dropItem(byte noun) {
- Common::Array<Item>::iterator it;
-
- for (it = _inventory.begin(); it != _inventory.end(); ++it) {
- if (it->field1 != noun || it->field2 != 0xfe)
- continue;
-
- it->field2 = _room;
- it->field7 = 1;
- return;
- }
-
- // Don't understand
- printMessage(37);
-}
-
-void HiRes1Engine::doActions(const Command &command, byte noun, byte offset) {
- for (uint i = 0; i < command.numAct; ++i) {
- switch (command.script[offset]) {
- case 1:
- _variables[command.script[offset + 2]] += command.script[offset + 1];
- offset += 3;
- break;
- case 2:
- _variables[command.script[offset + 2]] -= command.script[offset + 1];
- offset += 3;
- break;
- case 3:
- _variables[command.script[offset + 1]] = command.script[offset + 2];
- offset += 3;
- break;
- case 4: {
- Common::Array<Item>::const_iterator it;
-
- for (it = _inventory.begin(); it != _inventory.end(); ++it)
- if (it->field2 == 0xfe)
- printMessage(it->field8);
-
- ++offset;
- break;
- }
- case 5:
- _inventory[command.script[offset + 1] - 1].field2 = command.script[offset + 2];
- offset += 3;
- break;
- case 6:
- _rooms[_room].picture = _rooms[_room].field8;
- _room = command.script[offset + 1];
- offset += 2;
- break;
- case 7:
- _rooms[_room].picture = command.script[offset + 1];
- offset += 2;
- break;
- case 8:
- _rooms[_room].field8 = _rooms[_room].picture = command.script[offset + 1];
- offset += 2;
- break;
- case 9:
- printMessage(command.script[offset + 1]);
- offset += 2;
- break;
- case 0xa:
- _isDark = false;
- ++offset;
- break;
- case 0xb:
- _isDark = true;
- ++offset;
- break;
- case 0xf:
- warning("Save game not implemented");
- ++offset;
- break;
- case 0x10:
- warning("Load game not implemented");
- ++offset;
- break;
- case 0x11: {
- _display->printString(_exeStrings[STR_MH_PLAYAGAIN]);
- Common::String input = _display->inputString();
- if (input.size() == 0 || input[0] != APPLECHAR('N')) {
- warning("Restart game not implemented");
- return;
- }
- // Fall-through
- }
- case 0xd:
- printMessage(140);
- quitGame();
- return;
- case 0x12: {
- byte item = command.script[offset + 1] - 1;
- _inventory[item].field2 = command.script[offset + 2];
- _inventory[item].field5 = command.script[offset + 3];
- _inventory[item].field6 = command.script[offset + 4];
- offset += 5;
- break;
- }
- case 0x13: {
- byte item = command.script[offset + 2] - 1;
- _inventory[item].field3 = command.script[offset + 1];
- offset += 3;
- break;
- }
- case 0x14:
- _rooms[_room].picture = _rooms[_room].field8;
- ++offset;
- break;
- case 0x15:
- case 0x16:
- case 0x17:
- case 0x18:
- case 0x19:
- case 0x1a: {
- byte room = _rooms[_room].connections[command.script[offset] - 0x15];
-
- if (room == 0) {
- printMessage(137);
- return;
- }
-
- _rooms[_room].picture = _rooms[_room].field8;
- _room = room;
- return;
- }
- case 0x1b:
- takeItem(noun);
- ++offset;
- break;
- case 0x1c:
- dropItem(noun);
- ++offset;
- break;
- case 0x1d:
- _rooms[command.script[offset + 1]].field8 = _rooms[command.script[offset + 1]].picture = command.script[offset + 2];
- offset += 3;
- break;
- default:
- error("Invalid action opcode %02x", command.script[offset]);
- }
- }
-}
-
-bool HiRes1Engine::checkCommand(const Command &command, byte verb, byte noun) {
- if (command.room != 0xfe && command.room != _room)
- return false;
-
- if (command.verb != 0xfe && command.verb != verb)
- return false;
-
- if (command.noun != 0xfe && command.noun != noun)
- return false;
-
- uint offset = 0;
- for (uint i = 0; i < command.numCond; ++i) {
- switch (command.script[offset]) {
- case 3:
- if (_inventory[command.script[offset + 1] - 1].field2 != command.script[offset + 2])
- return false;
- offset += 3;
- break;
- case 5:
- if (command.script[offset + 1] > _steps)
- return false;
- offset += 2;
- break;
- case 6:
- if (_variables[command.script[offset + 1]] != command.script[offset + 2])
- return false;
- offset += 3;
- break;
- case 9:
- if (_rooms[_room].picture != command.script[offset + 1])
- return false;
- offset += 2;
- break;
- case 10:
- if (_inventory[command.script[offset + 1] - 1].field3 != command.script[offset + 2])
- return false;
- offset += 3;
- break;
- default:
- error("Invalid condition opcode %02x", command.script[offset]);
- }
- }
-
- doActions(command, noun, offset);
-
- return true;
-}
-
-bool HiRes1Engine::doOneCommand(const Commands &commands, byte verb, byte noun) {
- Commands::const_iterator it;
-
- for (it = commands.begin(); it != commands.end(); ++it)
- if (checkCommand(*it, verb, noun))
- return true;
-
- return false;
-}
-
-void HiRes1Engine::doAllCommands(const Commands &commands, byte verb, byte noun) {
- Commands::const_iterator it;
-
- for (it = commands.begin(); it != commands.end(); ++it)
- checkCommand(*it, verb, noun);
-}
-
-void HiRes1Engine::clearScreen() {
- _display->setMode(Display::kModeMixed);
- _display->clear(0x00);
-}
-
void HiRes1Engine::runGame() {
runIntro();
_display->printASCIIString("\r");
@@ -553,7 +261,7 @@ void HiRes1Engine::runGame() {
error("Failed to open file");
while (!f.eos() && !f.err())
- _msgStrings.push_back(readString(f, APPLECHAR('\r')) + APPLECHAR('\r'));
+ _messages.push_back(readString(f, APPLECHAR('\r')) + APPLECHAR('\r'));
f.close();
@@ -561,9 +269,10 @@ void HiRes1Engine::runGame() {
error("Failed to open file");
// Load strings from executable
- for (uint idx = 0; idx < STR_MH_TOTAL; ++idx) {
- f.seek(exeStrings[idx]);
- _exeStrings.push_back(readString(f));
+ _strings.resize(IDI_HR1_STR_TOTAL);
+ for (uint idx = 0; idx < IDI_HR1_STR_TOTAL; ++idx) {
+ f.seek(stringOffsets[idx].offset);
+ _strings[stringOffsets[idx].stringIdx] = readString(f);
}
// Load room data from executable
@@ -673,6 +382,44 @@ void HiRes1Engine::runGame() {
}
}
+void HiRes1Engine::printMessage(uint idx, bool wait) {
+ // Hardcoded overrides that don't wait after printing
+ // Note: strings may differ slightly from the ones in MESSAGES
+ switch (idx) {
+ case 137:
+ _display->printString(_strings[IDI_HR1_STR_CANT_GO_THERE]);
+ return;
+ case 127:
+ _display->printString(_strings[IDI_HR1_STR_DONT_HAVE_IT]);
+ return;
+ case 37:
+ _display->printString(_strings[IDI_HR1_STR_DONT_UNDERSTAND]);
+ return;
+ case 7:
+ _display->printString(_strings[IDI_HR1_STR_GETTING_DARK]);
+ return;
+ }
+
+ AdlEngine::printMessage(idx, wait);
+}
+
+uint HiRes1Engine::getEngineMessage(EngineMessage msg) {
+ switch (msg) {
+ case IDI_MSG_CANT_GO_THERE:
+ return IDI_HR1_MSG_CANT_GO_THERE;
+ case IDI_MSG_DONT_UNDERSTAND:
+ return IDI_HR1_MSG_DONT_UNDERSTAND;
+ case IDI_MSG_ITEM_DOESNT_MOVE:
+ return IDI_HR1_MSG_ITEM_DOESNT_MOVE;
+ case IDI_MSG_ITEM_NOT_HERE:
+ return IDI_HR1_MSG_ITEM_NOT_HERE;
+ case IDI_MSG_THANKS_FOR_PLAYING:
+ return IDI_HR1_MSG_THANKS_FOR_PLAYING;
+ default:
+ error("Cannot find engine message %i", msg);
+ }
+}
+
AdlEngine *HiRes1Engine__create(OSystem *syst, const AdlGameDescription *gd) {
return new HiRes1Engine(syst, gd);
}
diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h
index e9e274cc58..19aa55ee9f 100644
--- a/engines/adl/hires1.h
+++ b/engines/adl/hires1.h
@@ -32,20 +32,12 @@ class ReadStream;
namespace Adl {
enum {
- // Some of these are probably common
- STR_MH_DIRERR = STR_CUSTOM_START,
- STR_MH_DONTHAVEIT,
- STR_MH_DONTUNDERSTAND,
- STR_MH_GETTINGDARK,
- STR_MH_PLAYAGAIN,
-
- STR_MH_TOTAL
+ IDI_HR1_MSG_
};
class HiRes1Engine : public AdlEngine {
public:
HiRes1Engine(OSystem *syst, const AdlGameDescription *gd);
- Common::String getExeString(uint idx);
protected:
void runGame();
@@ -57,23 +49,14 @@ private:
MH_ITEM_OFFSETS = 21
};
+ void printMessage(uint idx, bool wait = true);
+ uint getEngineMessage(EngineMessage msg);
+
void runIntro();
void drawPic(Common::ReadStream &stream, byte xOffset, byte yOffset);
void showRoom();
- void printMessage(uint idx, bool wait = true);
- void wordWrap(Common::String &str);
- void readCommands(Common::ReadStream &stream, Commands &commands);
- bool checkCommand(const Command &command, byte verb, byte noun);
- bool doOneCommand(const Commands &commands, byte verb, byte noun);
- void doAllCommands(const Commands &commands, byte verb, byte noun);
- void doActions(const Command &command, byte noun, byte offset);
- void clearScreen();
- void takeItem(byte noun);
- void dropItem(byte noun);
void drawItems();
void drawPic(byte pic, byte xOffset, byte yOffset);
-
- Common::Array<Common::String> _exeStrings;
};
} // End of namespace Adl
diff --git a/engines/adl/parser.cpp b/engines/adl/parser.cpp
index 1611fc7f54..a697301664 100644
--- a/engines/adl/parser.cpp
+++ b/engines/adl/parser.cpp
@@ -129,7 +129,7 @@ Common::String Parser::getWord(const Common::String &line, uint &index) {
void Parser::getInput(uint &verb, uint &noun) {
while (1) {
- _display.printString(_engine.getExeString(STR_COMMON_ENTERCMD));
+ _display.printString(_engine.getEngineString(IDI_STR_ENTER_COMMAND));
Common::String line = getLine();
if (g_engine->shouldQuit())
@@ -139,7 +139,7 @@ void Parser::getInput(uint &verb, uint &noun) {
Common::String verbStr = getWord(line, index);
if (!_verbs.contains(verbStr)) {
- Common::String err = _engine.getExeString(STR_COMMON_VERBERR);
+ Common::String err = _engine.getEngineString(IDI_STR_VERB_ERROR);
for (uint i = 0; i < verbStr.size(); ++i)
err.setChar(verbStr[i], i + 19);
_display.printString(err);
@@ -151,7 +151,7 @@ void Parser::getInput(uint &verb, uint &noun) {
Common::String nounStr = getWord(line, index);
if (!_nouns.contains(nounStr)) {
- Common::String err = _engine.getExeString(STR_COMMON_NOUNERR);
+ Common::String err = _engine.getEngineString(IDI_STR_NOUN_ERROR);
for (uint i = 0; i < verbStr.size(); ++i)
err.setChar(verbStr[i], i + 19);
for (uint i = 0; i < nounStr.size(); ++i)