ADL: Load hires4 messages

This commit is contained in:
Walter van Niftrik 2016-08-28 13:13:00 +02:00
parent 56c2ef9efc
commit 9dc3c78827
7 changed files with 65 additions and 15 deletions

View File

@ -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()");

View File

@ -55,6 +55,7 @@ protected:
virtual void adjustDataBlockPtr(byte &track, byte &sector, 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);

View File

@ -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));

View File

@ -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));

View File

@ -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::loadCommonData() {
_messages.clear();
StreamPtr stream(createReadStream(_boot, 0x0a, 0x4, 0x00, 3));
loadMessages(*stream, IDI_HR4_NUM_MESSAGES);
}
void HiRes4Engine::initGameState() {
_disk = new DiskImage();
if (!_disk->open(getDiskImageName(1)))
error("Failed to open disk image '%s'", getDiskImageName(1));
_state.vars.resize(IDI_HR4_NUM_VARS);
StreamPtr stream(createReadStream(_boot, 0x03, 0x1, 0x0e, 9));

View File

@ -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;

View File

@ -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: {