diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/adl/adl_v2.cpp | 5 | ||||
-rw-r--r-- | engines/adl/adl_v2.h | 1 | ||||
-rw-r--r-- | engines/adl/hires0.cpp | 6 | ||||
-rw-r--r-- | engines/adl/hires2.cpp | 4 | ||||
-rw-r--r-- | engines/adl/hires4.cpp | 50 | ||||
-rw-r--r-- | engines/adl/hires4.h | 11 | ||||
-rw-r--r-- | engines/adl/hires6.cpp | 3 |
7 files changed, 65 insertions, 15 deletions
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 307bf98b46..c251433f05 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -414,6 +414,11 @@ void AdlEngine_v2::loadRooms(Common::SeekableReadStream &stream, byte count) { error("Error loading rooms"); } +void AdlEngine_v2::loadMessages(Common::SeekableReadStream &stream, byte count) { + for (uint i = 0; i < count; ++i) + _messages.push_back(readDataBlockPtr(stream)); +} + int AdlEngine_v2::o2_isFirstTime(ScriptEnv &e) { OP_DEBUG_0("\t&& IS_FIRST_TIME()"); diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index 54300853c4..c2dd7f8272 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -55,6 +55,7 @@ protected: virtual void adjustDataBlockPtr(byte &track, byte §or, byte &offset, byte &size) const { } void loadItems(Common::SeekableReadStream &stream); void loadRooms(Common::SeekableReadStream &stream, byte count); + void loadMessages(Common::SeekableReadStream &stream, byte count); void checkTextOverflow(char c); diff --git a/engines/adl/hires0.cpp b/engines/adl/hires0.cpp index e6ff0bd317..34a1b264f3 100644 --- a/engines/adl/hires0.cpp +++ b/engines/adl/hires0.cpp @@ -37,12 +37,10 @@ void HiRes0Engine::init() { _disk->setSectorLimit(13); - StreamPtr stream(_disk->createReadStream(0x1f, 0x2, 0x00, 2)); - // TODO: all these strings/offsets/etc are the same as hires2 - for (uint i = 0; i < IDI_HR0_NUM_MESSAGES; ++i) - _messages.push_back(readDataBlockPtr(*stream)); + StreamPtr stream(_disk->createReadStream(0x1f, 0x2, 0x00, 2)); + loadMessages(*stream, IDI_HR0_NUM_MESSAGES); // Read parser messages stream.reset(_disk->createReadStream(0x1a, 0x1)); diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp index b662142f0c..e9ca86ff82 100644 --- a/engines/adl/hires2.cpp +++ b/engines/adl/hires2.cpp @@ -63,9 +63,7 @@ void HiRes2Engine::init() { _disk->setSectorLimit(13); StreamPtr stream(_disk->createReadStream(0x1f, 0x2, 0x00, 4)); - - for (uint i = 0; i < IDI_HR2_NUM_MESSAGES; ++i) - _messages.push_back(readDataBlockPtr(*stream)); + loadMessages(*stream, IDI_HR2_NUM_MESSAGES); // Read parser messages stream.reset(_disk->createReadStream(0x1a, 0x1)); diff --git a/engines/adl/hires4.cpp b/engines/adl/hires4.cpp index 312cce6a55..41bbd95b02 100644 --- a/engines/adl/hires4.cpp +++ b/engines/adl/hires4.cpp @@ -45,7 +45,24 @@ void HiRes4Engine::init() { if (!_boot->open(getDiskImageName(0))) error("Failed to open disk image '%s'", getDiskImageName(0)); - StreamPtr stream(createReadStream(_boot, 0x06, 0xd, 0x12, 2)); + _disk = new DiskImage(); + if (!_disk->open(getDiskImageName(1))) + error("Failed to open disk image '%s'", getDiskImageName(1)); + + loadCommonData(); + + StreamPtr stream(createReadStream(_boot, 0x06, 0x2)); + _strings.verbError = readStringAt(*stream, 0x4f); + _strings.nounError = readStringAt(*stream, 0x83); + _strings.enterCommand = readStringAt(*stream, 0xa6); + + _messageIds.cantGoThere = IDI_HR4_MSG_CANT_GO_THERE; + _messageIds.dontUnderstand = IDI_HR4_MSG_DONT_UNDERSTAND; + _messageIds.itemDoesntMove = IDI_HR4_MSG_ITEM_DOESNT_MOVE; + _messageIds.itemNotHere = IDI_HR4_MSG_ITEM_NOT_HERE; + _messageIds.thanksForPlaying = IDI_HR4_MSG_THANKS_FOR_PLAYING; + + stream.reset(createReadStream(_boot, 0x06, 0xd, 0x12, 2)); loadItemDescriptions(*stream, IDI_HR4_NUM_ITEM_DESCS); stream.reset(createReadStream(_boot, 0x05, 0x4, 0x00, 3)); @@ -55,6 +72,22 @@ void HiRes4Engine::init() { loadWords(*stream, _nouns, _priNouns); } +Common::String HiRes4Engine::formatVerbError(const Common::String &verb) const { + Common::String err = _strings.verbError; + for (uint i = 0; i < verb.size(); ++i) + err.setChar(verb[i], i + 8); + return err; +} + +Common::String HiRes4Engine::formatNounError(const Common::String &verb, const Common::String &noun) const { + Common::String err = _strings.nounError; + for (uint i = 0; i < verb.size(); ++i) + err.setChar(verb[i], i + 8); + for (uint i = 0; i < noun.size(); ++i) + err.setChar(noun[i], i + 19); + return err; +} + void HiRes4Engine::goToSideC() { delete _disk; @@ -63,19 +96,24 @@ void HiRes4Engine::goToSideC() { error("Failed to open disk image '%s'", getDiskImageName(2)); // As room.data is bound to the DiskImage, we need to rebind them here - StreamPtr stream(createReadStream(_boot, 0x03, 0x1, 0x0e, 17)); + StreamPtr stream(createReadStream(_boot, 0x03, 0x1, 0x0e, 9)); for (uint i = 0; i < IDI_HR4_NUM_ROOMS; ++i) { stream->skip(7); _state.rooms[i].data = readDataBlockPtr(*stream); stream->skip(3); } + + // Rebind data that is on both side B and C + loadCommonData(); } -void HiRes4Engine::initGameState() { - _disk = new DiskImage(); - if (!_disk->open(getDiskImageName(1))) - error("Failed to open disk image '%s'", getDiskImageName(1)); +void HiRes4Engine::loadCommonData() { + _messages.clear(); + StreamPtr stream(createReadStream(_boot, 0x0a, 0x4, 0x00, 3)); + loadMessages(*stream, IDI_HR4_NUM_MESSAGES); +} +void HiRes4Engine::initGameState() { _state.vars.resize(IDI_HR4_NUM_VARS); StreamPtr stream(createReadStream(_boot, 0x03, 0x1, 0x0e, 9)); diff --git a/engines/adl/hires4.h b/engines/adl/hires4.h index b522657111..1d21e0c55b 100644 --- a/engines/adl/hires4.h +++ b/engines/adl/hires4.h @@ -30,9 +30,17 @@ namespace Adl { #define IDI_HR4_NUM_ROOMS 164 +#define IDI_HR4_NUM_MESSAGES 255 #define IDI_HR4_NUM_VARS 40 #define IDI_HR4_NUM_ITEM_DESCS 44 +// Messages used outside of scripts +#define IDI_HR4_MSG_CANT_GO_THERE 110 +#define IDI_HR4_MSG_DONT_UNDERSTAND 112 +#define IDI_HR4_MSG_ITEM_DOESNT_MOVE 114 +#define IDI_HR4_MSG_ITEM_NOT_HERE 115 +#define IDI_HR4_MSG_THANKS_FOR_PLAYING 113 + class HiRes4Engine : public AdlEngine_v3 { public: ~HiRes4Engine(); @@ -43,8 +51,11 @@ protected: // AdlEngine void init(); void initGameState(); + Common::String formatVerbError(const Common::String &verb) const; + Common::String formatNounError(const Common::String &verb, const Common::String &noun) const; Common::SeekableReadStream *createReadStream(DiskImage *disk, byte track, byte sector, byte offset = 0, byte size = 0) const; + void loadCommonData(); void goToSideC(); virtual const char *getDiskImageName(byte index) const = 0; diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index 553729d38d..756ead93ce 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -213,8 +213,7 @@ void HiRes6Engine::loadDisk(byte disk) { // Messages _messages.clear(); uint count = size / 4; - for (uint i = 0; i < count; ++i) - _messages.push_back(readDataBlockPtr(*stream)); + loadMessages(*stream, count); break; } case 0x4a80: { |