aboutsummaryrefslogtreecommitdiff
path: root/engines/adl
diff options
context:
space:
mode:
authorWalter van Niftrik2016-03-26 14:29:26 +0100
committerWalter van Niftrik2016-06-06 20:35:49 +0200
commit41e82276379f87c74675cc34b682bc69bced865e (patch)
treee9e693620da8ca93d630bcdf70279aa711107243 /engines/adl
parentc9824921b4a5b2fa91751b03c24db91acbaac8c5 (diff)
downloadscummvm-rg350-41e82276379f87c74675cc34b682bc69bced865e.tar.gz
scummvm-rg350-41e82276379f87c74675cc34b682bc69bced865e.tar.bz2
scummvm-rg350-41e82276379f87c74675cc34b682bc69bced865e.zip
ADL: Set room description in hires1
Diffstat (limited to 'engines/adl')
-rw-r--r--engines/adl/adl.cpp6
-rw-r--r--engines/adl/adl.h4
-rw-r--r--engines/adl/adl_v2.h2
-rw-r--r--engines/adl/hires1.cpp23
-rw-r--r--engines/adl/hires1.h2
-rw-r--r--engines/adl/hires2.cpp51
-rw-r--r--engines/adl/hires2.h3
7 files changed, 53 insertions, 38 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index ce6ca03f0e..e77755986a 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -110,6 +110,10 @@ void AdlEngine::openFile(Common::File &file, const Common::String &name) const {
error("Error opening '%s'", name.c_str());
}
+void AdlEngine::printMessage(uint idx) {
+ printString(_messages[idx - 1]);
+}
+
void AdlEngine::delay(uint32 ms) const {
uint32 start = g_system->getMillis();
@@ -513,6 +517,8 @@ Common::Error AdlEngine::run() {
// (Also see comment below.)
if (!_isRestoring) {
clearScreen();
+ // FIXME: Should only be called when room changes
+ loadRoom(_state.room);
showRoom();
_canSaveNow = _canRestoreNow = true;
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 9121de4424..ffa35791b4 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -192,7 +192,8 @@ protected:
Common::String readStringAt(Common::SeekableReadStream &stream, uint offset, byte until = 0) const;
void openFile(Common::File &file, const Common::String &name) const;
- virtual void printMessage(uint idx) = 0;
+ virtual void printString(const Common::String &str) = 0;
+ virtual void printMessage(uint idx);
void delay(uint32 ms) const;
Common::String inputString(byte prompt = 0) const;
@@ -310,6 +311,7 @@ private:
virtual void initState() = 0;
virtual void restartGame() = 0;
virtual void drawItem(const Item &item, const Common::Point &pos) const = 0;
+ virtual void loadRoom(byte roomNr) = 0;
virtual void showRoom() = 0;
// Engine
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h
index cea4a9310e..3a32f48b8b 100644
--- a/engines/adl/adl_v2.h
+++ b/engines/adl/adl_v2.h
@@ -49,9 +49,9 @@ protected:
bool matchesCurrentPic(byte pic) const;
byte roomArg(byte room) const;
void advanceClock();
+ void printString(const Common::String &str);
void checkTextOverflow(char c);
- void printString(const Common::String &str);
int o2_isFirstTime(ScriptEnv &e);
int o2_isRandomGT(ScriptEnv &e);
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 804b122959..b191afd12c 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -268,10 +268,17 @@ void HiRes1Engine::drawPic(byte pic, Common::Point pos) const {
_graphics->drawPic(*_pictures[pic].data->createReadStream(), pos, 0x7f);
}
+void HiRes1Engine::printString(const Common::String &str) {
+ Common::String wrap = str;
+ wordWrap(wrap);
+ _display->printString(wrap);
+
+ if (_messageDelay)
+ delay(14 * 166018 / 1000);
+}
+
void HiRes1Engine::printMessage(uint idx) {
- Common::String msg = _messages[idx - 1];
- wordWrap(msg);
- _display->printString(msg);
+ const Common::String &msg = _messages[idx - 1];
// Messages with hardcoded overrides don't delay after printing.
// It's unclear if this is a bug or not. In some cases the result
@@ -285,11 +292,11 @@ void HiRes1Engine::printMessage(uint idx) {
case IDI_HR1_MSG_DONT_HAVE_IT:
case IDI_HR1_MSG_DONT_UNDERSTAND:
case IDI_HR1_MSG_GETTING_DARK:
+ _display->printString(msg);
return;
}
- if (_messageDelay)
- delay(14 * 166018 / 1000);
+ printString(msg);
}
void HiRes1Engine::drawItem(const Item &item, const Common::Point &pos) const {
@@ -300,6 +307,10 @@ void HiRes1Engine::drawItem(const Item &item, const Common::Point &pos) const {
drawPic(item.picture, pos);
}
+void HiRes1Engine::loadRoom(byte roomNr) {
+ _roomData.description = _messages[_roomDesc[_state.room - 1] - 1];
+}
+
void HiRes1Engine::showRoom() {
if (!_state.isDark) {
drawPic(getCurRoom().curPicture);
@@ -308,7 +319,7 @@ void HiRes1Engine::showRoom() {
_display->updateHiResScreen();
_messageDelay = false;
- printMessage(_roomDesc[_state.room - 1]);
+ printString(_roomData.description);
_messageDelay = true;
}
diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h
index 458b2f0018..d601f7d13d 100644
--- a/engines/adl/hires1.h
+++ b/engines/adl/hires1.h
@@ -104,8 +104,10 @@ private:
void initState();
void restartGame();
void drawPic(byte pic, Common::Point pos = Common::Point()) const;
+ void printString(const Common::String &str);
void printMessage(uint idx);
void drawItem(const Item &item, const Common::Point &pos) const;
+ void loadRoom(byte roomNr);
void showRoom();
void wordWrap(Common::String &str) const;
diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp
index dffbd81b67..39f2199e6a 100644
--- a/engines/adl/hires2.cpp
+++ b/engines/adl/hires2.cpp
@@ -182,29 +182,6 @@ void HiRes2Engine::initState() {
}
}
-void HiRes2Engine::loadRoom(byte roomNr) {
- Room &room = getRoom(roomNr);
- StreamPtr stream(room.data->createReadStream());
-
- uint16 descOffset = stream->readUint16LE();
- uint16 commandOffset = stream->readUint16LE();
-
- // There's no picture count. The original engine always checks at most
- // five pictures. We use the description offset to bound our search.
- uint16 picCount = (descOffset - 4) / 5;
-
- for (uint i = 0; i < picCount; ++i) {
- Picture2 pic;
- readPictureMeta(*stream, pic);
- _roomData.pictures.push_back(pic);
- }
-
- _roomData.description = readStringAt(*stream, descOffset, 0xff);
-
- stream->seek(commandOffset);
- readCommands(*stream, _roomData.commands);
-}
-
void HiRes2Engine::restartGame() {
initState();
}
@@ -230,8 +207,30 @@ void HiRes2Engine::drawItem(const Item &item, const Common::Point &pos) const {
_graphics->drawPic(*stream, pos, 0);
}
+void HiRes2Engine::loadRoom(byte roomNr) {
+ Room &room = getRoom(roomNr);
+ StreamPtr stream(room.data->createReadStream());
+
+ uint16 descOffset = stream->readUint16LE();
+ uint16 commandOffset = stream->readUint16LE();
+
+ // There's no picture count. The original engine always checks at most
+ // five pictures. We use the description offset to bound our search.
+ uint16 picCount = (descOffset - 4) / 5;
+
+ for (uint i = 0; i < picCount; ++i) {
+ Picture2 pic;
+ readPictureMeta(*stream, pic);
+ _roomData.pictures.push_back(pic);
+ }
+
+ _roomData.description = readStringAt(*stream, descOffset, 0xff);
+
+ stream->seek(commandOffset);
+ readCommands(*stream, _roomData.commands);
+}
+
void HiRes2Engine::showRoom() {
- loadRoom(_state.room);
drawPic(getCurRoom().curPicture, Common::Point());
drawItems();
_display->updateHiResScreen();
@@ -239,10 +238,6 @@ void HiRes2Engine::showRoom() {
_linesPrinted = 0;
}
-void HiRes2Engine::printMessage(uint idx) {
- printString(_messages[idx - 1]);
-}
-
Engine *HiRes2Engine_create(OSystem *syst, const AdlGameDescription *gd) {
return new HiRes2Engine(syst, gd);
}
diff --git a/engines/adl/hires2.h b/engines/adl/hires2.h
index 35d5e1e078..a4bc0b6859 100644
--- a/engines/adl/hires2.h
+++ b/engines/adl/hires2.h
@@ -62,10 +62,9 @@ private:
void restartGame();
void drawPic(byte pic, Common::Point pos) const;
void drawItem(const Item &item, const Common::Point &pos) const;
+ void loadRoom(byte roomNr);
void showRoom();
- void printMessage(uint idx);
- void loadRoom(byte roomNr);
DataBlockPtr readDataBlockPtr(Common::ReadStream &f) const;
void readPictureMeta(Common::ReadStream &f, Picture2 &pic) const;