aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/adl/adl.cpp8
-rw-r--r--engines/adl/adl.h1
-rw-r--r--engines/adl/hires2.cpp26
-rw-r--r--engines/adl/hires2.h6
4 files changed, 37 insertions, 4 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 81c9054bb2..1afc530ad4 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -273,6 +273,11 @@ void AdlEngine::readCommands(Common::ReadStream &stream, Commands &commands) {
}
}
+void AdlEngine::checkInput(byte verb, byte noun) {
+ if (!doOneCommand(_roomCommands, verb, noun))
+ printMessage(_messageIds.dontUnderstand);
+}
+
void AdlEngine::clearScreen() const {
_display->setMode(DISPLAY_MODE_MIXED);
_display->clear(0x00);
@@ -448,8 +453,7 @@ Common::Error AdlEngine::run() {
// If we just restored from the GMM, we skip this command
// set, as no command has been input by the user
if (!_isRestoring)
- if (!doOneCommand(_roomCommands, verb, noun))
- printMessage(_messageIds.dontUnderstand);
+ checkInput(verb, noun);
}
if (_isRestoring) {
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 20e8fbc30c..97077f94f7 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -163,6 +163,7 @@ protected:
void loadWords(Common::ReadStream &stream, WordMap &map) const;
void readCommands(Common::ReadStream &stream, Commands &commands);
+ virtual void checkInput(byte verb, byte noun);
// Graphics
void clearScreen() const;
diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp
index 226a8e33da..8b12746641 100644
--- a/engines/adl/hires2.cpp
+++ b/engines/adl/hires2.cpp
@@ -83,6 +83,13 @@ void HiRes2Engine::init() {
_messageIds.itemNotHere = IDI_HR2_MSG_ITEM_NOT_HERE;
_messageIds.thanksForPlaying = IDI_HR2_MSG_THANKS_FOR_PLAYING;
+ // Load commands from executable
+ f.seek(IDI_HR2_OFS_CMDS_1);
+ readCommands(f, _roomCommands);
+
+ f.seek(IDI_HR2_OFS_CMDS_0);
+ // readCommands(f, _globalCommands);
+
f.seek(IDI_HR2_OFS_VERBS);
loadWords(f, _verbs);
@@ -91,6 +98,9 @@ void HiRes2Engine::init() {
}
void HiRes2Engine::initState() {
+ _state.vars.clear();
+ _state.vars.resize(IDI_HR2_NUM_VARS);
+
Common::File f;
openFile(f, IDS_HR2_DISK_IMAGE);
@@ -119,7 +129,7 @@ void HiRes2Engine::loadRoom(byte roomNr) {
uint offset = TSO(room.track, room.sector, room.offset);
f.seek(offset);
uint16 descOffset = f.readUint16LE();
- /* uint16 commandOffset =*/ f.readUint16LE();
+ uint16 commandOffset = f.readUint16LE();
// There's no picture count. The original engine always checks at most
// five pictures. We use the description offset to bound our search.
@@ -134,7 +144,12 @@ void HiRes2Engine::loadRoom(byte roomNr) {
f.readByte();
_roomData.pictures.push_back(pic);
}
+
_roomData.description = readStringAt(f, offset + descOffset, 0xff);
+
+ f.seek(offset + commandOffset);
+
+ readCommands(f, _roomData.commands);
}
void HiRes2Engine::restartGame() {
@@ -158,16 +173,23 @@ void HiRes2Engine::drawPic(byte pic, Common::Point pos) const {
void HiRes2Engine::showRoom() {
loadRoom(_state.room);
- _linesPrinted = 0;
drawPic(getCurRoom().curPicture, Common::Point());
_display->updateHiResScreen();
printString(_roomData.description);
+ _linesPrinted = 0;
}
void HiRes2Engine::printMessage(uint idx, bool wait) {
printString(_messages[idx - 1]);
}
+void HiRes2Engine::checkInput(byte verb, byte noun) {
+ if (doOneCommand(_roomData.commands, verb, noun))
+ return;
+
+ AdlEngine::checkInput(verb, noun);
+}
+
void HiRes2Engine::checkTextOverflow(char c) {
if (c != APPLECHAR('\r'))
return;
diff --git a/engines/adl/hires2.h b/engines/adl/hires2.h
index 58831c497d..f9d6d924bc 100644
--- a/engines/adl/hires2.h
+++ b/engines/adl/hires2.h
@@ -47,8 +47,12 @@ namespace Adl {
#define IDI_HR2_OFS_ROOMS TSO(0x21, 0x5, 0x0e) // Skip bogus room 0
#define IDI_HR2_OFS_MESSAGES TSO(0x1f, 0x2, 0x04) // Skip bogus message 0
+#define IDI_HR2_OFS_CMDS_0 TS(0x1f, 0x7)
+#define IDI_HR2_OFS_CMDS_1 TS(0x1d, 0x7)
+
#define IDI_HR2_NUM_ROOMS 135
#define IDI_HR2_NUM_MESSAGES 254
+#define IDI_HR2_NUM_VARS 40
// Messages used outside of scripts
#define IDI_HR2_MSG_CANT_GO_THERE 123
@@ -73,6 +77,7 @@ struct Picture2 {
struct RoomData {
Common::String description;
Common::Array<Picture2> pictures;
+ Commands commands;
};
class HiRes2Engine : public AdlEngine {
@@ -89,6 +94,7 @@ private:
void drawItem(const Item &item, const Common::Point &pos) const { }
void showRoom();
void printMessage(uint idx, bool wait);
+ void checkInput(byte verb, byte noun);
void loadRoom(byte roomNr);
void checkTextOverflow(char c);