aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/adl/adl.h4
-rw-r--r--engines/adl/adl_v2.cpp9
-rw-r--r--engines/adl/adl_v2.h1
-rw-r--r--engines/adl/console.cpp2
-rw-r--r--engines/adl/hires1.cpp39
-rw-r--r--engines/adl/hires1.h11
-rw-r--r--engines/adl/hires2.cpp14
-rw-r--r--engines/adl/hires2.h2
-rw-r--r--engines/adl/hires6.cpp11
-rw-r--r--engines/adl/hires6.h2
10 files changed, 58 insertions, 37 deletions
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 68327690cd..14e38eb0f4 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -226,7 +226,7 @@ protected:
void openFile(Common::File &file, const Common::String &name) const;
virtual void printString(const Common::String &str) = 0;
- virtual Common::String loadMessage(uint idx) const { return _messages[idx - 1]; }
+ virtual Common::String loadMessage(uint idx) const = 0;
virtual void printMessage(uint idx);
void delay(uint32 ms) const;
@@ -317,7 +317,7 @@ protected:
typedef Common::Functor1<ScriptEnv &, int> Opcode;
Common::Array<const Opcode *> _condOpcodes, _actOpcodes;
// Message strings in data file
- Common::Array<Common::String> _messages;
+ Common::Array<DataBlockPtr> _messages;
// Picture data
PictureMap _pictures;
// Dropped item screen offsets
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp
index 90ed7948cf..39cf0a7583 100644
--- a/engines/adl/adl_v2.cpp
+++ b/engines/adl/adl_v2.cpp
@@ -161,6 +161,15 @@ void AdlEngine_v2::checkTextOverflow(char c) {
}
}
+Common::String AdlEngine_v2::loadMessage(uint idx) const {
+ if (_messages[idx]) {
+ StreamPtr strStream(_messages[idx]->createReadStream());
+ return readString(*strStream, 0xff);
+ }
+
+ return Common::String();
+}
+
void AdlEngine_v2::printString(const Common::String &str) {
Common::String s(str);
byte endPos = TEXT_WIDTH - 1;
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h
index 2251a93b80..947b0d8faf 100644
--- a/engines/adl/adl_v2.h
+++ b/engines/adl/adl_v2.h
@@ -46,6 +46,7 @@ protected:
byte roomArg(byte room) const;
void advanceClock();
void printString(const Common::String &str);
+ Common::String loadMessage(uint idx) const;
void drawItems();
void drawItem(Item &item, const Common::Point &pos);
void loadRoom(byte roomNr);
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp
index c62d21c7ce..0415bcd506 100644
--- a/engines/adl/console.cpp
+++ b/engines/adl/console.cpp
@@ -300,7 +300,7 @@ void Console::printItem(const Item &item) {
name = _engine->_priNouns[item.noun - 1];
if (item.description > 0) {
- desc = toAscii(_engine->_messages[item.description - 1]);
+ desc = toAscii(_engine->loadMessage(item.description));
if (desc.lastChar() == '\r')
desc.deleteLastChar();
}
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 9193c27c04..4b3a83d443 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -137,18 +137,13 @@ void HiRes1Engine::init() {
_graphics = new Graphics_v1(*_display);
- StreamPtr stream(_files->createReadStream(IDS_HR1_MESSAGES));
-
- for (uint i = 0; i < IDI_HR1_NUM_MESSAGES; ++i)
- _messages.push_back(readString(*stream, APPLECHAR('\r')) + APPLECHAR('\r'));
-
- stream.reset(_files->createReadStream(IDS_HR1_EXE_1));
+ StreamPtr stream(_files->createReadStream(IDS_HR1_EXE_1));
// Some messages have overrides inside the executable
- _messages[IDI_HR1_MSG_CANT_GO_THERE - 1] = readStringAt(*stream, IDI_HR1_OFS_STR_CANT_GO_THERE);
- _messages[IDI_HR1_MSG_DONT_HAVE_IT - 1] = readStringAt(*stream, IDI_HR1_OFS_STR_DONT_HAVE_IT);
- _messages[IDI_HR1_MSG_DONT_UNDERSTAND - 1] = readStringAt(*stream, IDI_HR1_OFS_STR_DONT_UNDERSTAND);
- _messages[IDI_HR1_MSG_GETTING_DARK - 1] = readStringAt(*stream, IDI_HR1_OFS_STR_GETTING_DARK);
+ _gameStrings.cantGoThere = readStringAt(*stream, IDI_HR1_OFS_STR_CANT_GO_THERE);
+ _gameStrings.dontHaveIt = readStringAt(*stream, IDI_HR1_OFS_STR_DONT_HAVE_IT);
+ _gameStrings.dontUnderstand = readStringAt(*stream, IDI_HR1_OFS_STR_DONT_UNDERSTAND);
+ _gameStrings.gettingDark = readStringAt(*stream, IDI_HR1_OFS_STR_GETTING_DARK);
// Load other strings from executable
_strings.enterCommand = readStringAt(*stream, IDI_HR1_OFS_STR_ENTER_COMMAND);
@@ -165,6 +160,11 @@ void HiRes1Engine::init() {
_messageIds.itemNotHere = IDI_HR1_MSG_ITEM_NOT_HERE;
_messageIds.thanksForPlaying = IDI_HR1_MSG_THANKS_FOR_PLAYING;
+ // Load message offsets
+ stream->seek(IDI_HR1_OFS_MSGS);
+ for (uint i = 0; i < IDI_HR1_NUM_MESSAGES; ++i)
+ _messages.push_back(_files->getDataBlock(IDS_HR1_MESSAGES, stream->readUint16LE()));
+
// Load picture data from executable
stream->seek(IDI_HR1_OFS_PICS);
for (uint i = 1; i <= IDI_HR1_NUM_PICS; ++i) {
@@ -267,9 +267,12 @@ void HiRes1Engine::printString(const Common::String &str) {
delay(14 * 166018 / 1000);
}
-void HiRes1Engine::printMessage(uint idx) {
- const Common::String &msg = loadMessage(idx);
+Common::String HiRes1Engine::loadMessage(uint idx) const {
+ StreamPtr stream(_messages[idx]->createReadStream());
+ return readString(*stream, APPLECHAR('\r')) + APPLECHAR('\r');
+}
+void HiRes1Engine::printMessage(uint idx) {
// Messages with hardcoded overrides don't delay after printing.
// It's unclear if this is a bug or not. In some cases the result
// is that these strings will scroll past the four-line text window
@@ -279,14 +282,20 @@ void HiRes1Engine::printMessage(uint idx) {
// that system for this game as well.
switch (idx) {
case IDI_HR1_MSG_CANT_GO_THERE:
+ _display->printString(_gameStrings.cantGoThere);
+ return;
case IDI_HR1_MSG_DONT_HAVE_IT:
+ _display->printString(_gameStrings.dontHaveIt);
+ return;
case IDI_HR1_MSG_DONT_UNDERSTAND:
+ _display->printString(_gameStrings.dontUnderstand);
+ return;
case IDI_HR1_MSG_GETTING_DARK:
- _display->printString(msg);
+ _display->printString(_gameStrings.gettingDark);
return;
+ default:
+ printString(loadMessage(idx));
}
-
- printString(msg);
}
void HiRes1Engine::drawItems() {
diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h
index 8dc7081b23..273b7812d8 100644
--- a/engines/adl/hires1.h
+++ b/engines/adl/hires1.h
@@ -45,7 +45,7 @@ namespace Adl {
#define IDI_HR1_NUM_PICS 97
#define IDI_HR1_NUM_VARS 20
#define IDI_HR1_NUM_ITEM_OFFSETS 21
-#define IDI_HR1_NUM_MESSAGES 167
+#define IDI_HR1_NUM_MESSAGES 168
// Messages used outside of scripts
#define IDI_HR1_MSG_CANT_GO_THERE 137
@@ -83,6 +83,7 @@ namespace Adl {
#define IDI_HR1_OFS_PICS 0x4b03
#define IDI_HR1_OFS_CMDS_0 0x3c00
#define IDI_HR1_OFS_CMDS_1 0x3d00
+#define IDI_HR1_OFS_MSGS 0x4d00
#define IDI_HR1_OFS_ITEM_OFFSETS 0x68ff
#define IDI_HR1_OFS_CORNERS 0x4f00
@@ -105,6 +106,7 @@ private:
void initState();
void restartGame();
void printString(const Common::String &str);
+ Common::String loadMessage(uint idx) const;
void printMessage(uint idx);
void drawItems();
void drawItem(Item &item, const Common::Point &pos);
@@ -118,6 +120,13 @@ private:
Common::Array<DataBlockPtr> _corners;
Common::Array<byte> _roomDesc;
bool _messageDelay;
+
+ struct {
+ Common::String cantGoThere;
+ Common::String dontHaveIt;
+ Common::String dontUnderstand;
+ Common::String gettingDark;
+ } _gameStrings;
};
} // End of namespace Adl
diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp
index a0fa5a0ff8..06fdc5ff9a 100644
--- a/engines/adl/hires2.cpp
+++ b/engines/adl/hires2.cpp
@@ -54,18 +54,10 @@ void HiRes2Engine::init() {
if (!_disk->open(IDS_HR2_DISK_IMAGE))
error("Failed to open disk image '" IDS_HR2_DISK_IMAGE "'");
- StreamPtr stream(_disk->createReadStream(0x1f, 0x2, 0x04, 4));
+ StreamPtr stream(_disk->createReadStream(0x1f, 0x2, 0x00, 4));
- for (uint i = 0; i < IDI_HR2_NUM_MESSAGES; ++i) {
- DataBlockPtr str(readDataBlockPtr(*stream));
-
- if (str) {
- StreamPtr strStream(str->createReadStream());
- _messages.push_back(readString(*strStream, 0xff));
- } else {
- _messages.push_back(Common::String());
- }
- }
+ for (uint i = 0; i < IDI_HR2_NUM_MESSAGES; ++i)
+ _messages.push_back(readDataBlockPtr(*stream));
// Read parser messages
stream.reset(_disk->createReadStream(0x1a, 0x1));
diff --git a/engines/adl/hires2.h b/engines/adl/hires2.h
index b99fd6639c..6647e004b7 100644
--- a/engines/adl/hires2.h
+++ b/engines/adl/hires2.h
@@ -38,7 +38,7 @@ namespace Adl {
#define IDS_HR2_DISK_IMAGE "WIZARD.DSK"
#define IDI_HR2_NUM_ROOMS 135
-#define IDI_HR2_NUM_MESSAGES 254
+#define IDI_HR2_NUM_MESSAGES 255
#define IDI_HR2_NUM_VARS 40
#define IDI_HR2_NUM_ITEM_PICS 38
#define IDI_HR2_NUM_ITEM_OFFSETS 16
diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp
index a87cb7b0e9..e15cf43e5b 100644
--- a/engines/adl/hires6.cpp
+++ b/engines/adl/hires6.cpp
@@ -115,10 +115,6 @@ void HiRes6Engine::init() {
if (!boot->open(disks[0]))
error("Failed to open disk image '%s'", disks[0]);
- // TODO (needs refactoring of message handling)
- for (uint i = 0; i < 256; ++i)
- _messages.push_back(Common::String());
-
StreamPtr stream(loadSectors(boot, 7));
// Read parser messages
@@ -165,7 +161,7 @@ void HiRes6Engine::init() {
}
// Load global picture data
- stream.reset(_disk->createReadStream(0x1f, 0xf, 0x16, 0));
+ stream.reset(_disk->createReadStream(0x1f, 0xf, 0x16));
byte picNr;
while ((picNr = stream->readByte()) != 0xff) {
if (stream->eos() || stream->err())
@@ -173,6 +169,11 @@ void HiRes6Engine::init() {
_pictures[picNr] = readDataBlockPtr(*stream);
}
+ // Load message offsets
+ stream.reset(_disk->createReadStream(0x1f, 0xb, 0x16, 4));
+ for (uint i = 0; i < IDI_HR6_NUM_MESSAGES; ++i)
+ _messages.push_back(readDataBlockPtr(*stream));
+
// Load commands
stream.reset(_disk->createReadStream(0x21, 0x4, 0x85, 7));
readCommands(*stream, _roomCommands);
diff --git a/engines/adl/hires6.h b/engines/adl/hires6.h
index 99e9371dfe..c4e279dad7 100644
--- a/engines/adl/hires6.h
+++ b/engines/adl/hires6.h
@@ -36,7 +36,7 @@ class Point;
namespace Adl {
#define IDI_HR6_NUM_ROOMS 35
-#define IDI_HR6_NUM_MESSAGES 255
+#define IDI_HR6_NUM_MESSAGES 256
#define IDI_HR6_NUM_VARS 40
#define IDI_HR6_NUM_ITEM_PICS 15
#define IDI_HR6_NUM_ITEM_OFFSETS 16