aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/adl/adl.cpp370
-rw-r--r--engines/adl/adl.h46
-rw-r--r--engines/adl/hires1.cpp13
-rw-r--r--engines/adl/hires1.h5
-rw-r--r--engines/adl/hires2.cpp3
-rw-r--r--engines/adl/hires2.h1
6 files changed, 223 insertions, 215 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 1ab74c3cf6..47623d45e2 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -264,6 +264,186 @@ void AdlEngine::readCommands(Common::ReadStream &stream, Commands &commands) {
}
}
+void AdlEngine::clearScreen() const {
+ _display->setMode(DISPLAY_MODE_MIXED);
+ _display->clear(0x00);
+}
+
+void AdlEngine::drawItems() const {
+ Common::Array<Item>::const_iterator item;
+
+ uint dropped = 0;
+
+ for (item = _state.items.begin(); item != _state.items.end(); ++item) {
+ if (item->room != _state.room)
+ continue;
+
+ if (item->state == IDI_ITEM_MOVED) {
+ if (getCurRoom().picture == getCurRoom().curPicture) {
+ const Common::Point &p = _itemOffsets[dropped];
+ if (item->isLineArt)
+ drawLineArt(_lineArt[item->picture - 1], p);
+ else
+ drawPic(item->picture, p);
+ ++dropped;
+ }
+ continue;
+ }
+
+ Common::Array<byte>::const_iterator pic;
+
+ for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
+ if (*pic == getCurRoom().curPicture) {
+ if (item->isLineArt)
+ drawLineArt(_lineArt[item->picture - 1], item->position);
+ else
+ drawPic(item->picture, item->position);
+ continue;
+ }
+ }
+ }
+}
+
+void AdlEngine::drawNextPixel(Common::Point &p, byte color, byte bits, byte quadrant) const {
+ if (bits & 4)
+ _display->putPixel(p, color);
+
+ bits += quadrant;
+
+ if (bits & 1)
+ p.x += (bits & 2 ? -1 : 1);
+ else
+ p.y += (bits & 2 ? 1 : -1);
+}
+
+void AdlEngine::drawLineArt(const Common::Array<byte> &lineArt, const Common::Point &pos, byte rotation, byte scaling, byte color) const {
+ const byte stepping[] = {
+ 0xff, 0xfe, 0xfa, 0xf4, 0xec, 0xe1, 0xd4, 0xc5,
+ 0xb4, 0xa1, 0x8d, 0x78, 0x61, 0x49, 0x31, 0x18,
+ 0xff
+ };
+
+ byte quadrant = rotation >> 4;
+ rotation &= 0xf;
+ byte xStep = stepping[rotation];
+ byte yStep = stepping[(rotation ^ 0xf) + 1] + 1;
+
+ Common::Point p(pos);
+
+ for (uint i = 0; i < lineArt.size(); ++i) {
+ byte b = lineArt[i];
+
+ do {
+ byte xFrac = 0x80;
+ byte yFrac = 0x80;
+ for (uint j = 0; j < scaling; ++j) {
+ if (xFrac + xStep + 1 > 255)
+ drawNextPixel(p, color, b, quadrant);
+ xFrac += xStep + 1;
+ if (yFrac + yStep > 255)
+ drawNextPixel(p, color, b, quadrant + 1);
+ yFrac += yStep;
+ }
+ b >>= 3;
+ } while (b != 0);
+ }
+}
+
+const Room &AdlEngine::getRoom(uint i) const {
+ if (i < 1 || i > _state.rooms.size())
+ error("Room %i out of range [1, %i]", i, _state.rooms.size());
+
+ return _state.rooms[i - 1];
+}
+
+Room &AdlEngine::getRoom(uint i) {
+ if (i < 1 || i > _state.rooms.size())
+ error("Room %i out of range [1, %i]", i, _state.rooms.size());
+
+ return _state.rooms[i - 1];
+}
+
+const Room &AdlEngine::getCurRoom() const {
+ return getRoom(_state.room);
+}
+
+Room &AdlEngine::getCurRoom() {
+ return getRoom(_state.room);
+}
+
+const Item &AdlEngine::getItem(uint i) const {
+ if (i < 1 || i > _state.items.size())
+ error("Item %i out of range [1, %i]", i, _state.items.size());
+
+ return _state.items[i - 1];
+}
+
+Item &AdlEngine::getItem(uint i) {
+ if (i < 1 || i > _state.items.size())
+ error("Item %i out of range [1, %i]", i, _state.items.size());
+
+ return _state.items[i - 1];
+}
+
+byte AdlEngine::getVar(uint i) const {
+ if (i >= _state.vars.size())
+ error("Variable %i out of range [0, %i]", i, _state.vars.size() - 1);
+
+ return _state.vars[i];
+}
+
+void AdlEngine::setVar(uint i, byte value) {
+ if (i >= _state.vars.size())
+ error("Variable %i out of range [0, %i]", i, _state.vars.size() - 1);
+
+ _state.vars[i] = value;
+}
+
+void AdlEngine::takeItem(byte noun) {
+ Common::Array<Item>::iterator item;
+
+ for (item = _state.items.begin(); item != _state.items.end(); ++item) {
+ if (item->noun != noun || item->room != _state.room)
+ continue;
+
+ if (item->state == IDI_ITEM_DOESNT_MOVE) {
+ printMessage(_messageIds.itemDoesntMove);
+ return;
+ }
+
+ if (item->state == IDI_ITEM_MOVED) {
+ item->room = IDI_NONE;
+ return;
+ }
+
+ Common::Array<byte>::const_iterator pic;
+ for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
+ if (*pic == getCurRoom().curPicture) {
+ item->room = IDI_NONE;
+ item->state = IDI_ITEM_MOVED;
+ return;
+ }
+ }
+ }
+
+ printMessage(_messageIds.itemNotHere);
+}
+
+void AdlEngine::dropItem(byte noun) {
+ Common::Array<Item>::iterator item;
+
+ for (item = _state.items.begin(); item != _state.items.end(); ++item) {
+ if (item->noun != noun || item->room != IDI_NONE)
+ continue;
+
+ item->room = _state.room;
+ item->state = IDI_ITEM_MOVED;
+ return;
+ }
+
+ printMessage(_messageIds.dontUnderstand);
+}
+
Common::Error AdlEngine::run() {
_display = new Display();
@@ -636,196 +816,6 @@ void AdlEngine::getInput(uint &verb, uint &noun) {
}
}
-void AdlEngine::showRoom() const {
- if (!_state.isDark) {
- drawPic(getCurRoom().curPicture);
- drawItems();
- }
-
- _display->updateHiResScreen();
- printMessage(getCurRoom().description, false);
-}
-
-void AdlEngine::clearScreen() const {
- _display->setMode(DISPLAY_MODE_MIXED);
- _display->clear(0x00);
-}
-
-void AdlEngine::drawItems() const {
- Common::Array<Item>::const_iterator item;
-
- uint dropped = 0;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->room != _state.room)
- continue;
-
- if (item->state == IDI_ITEM_MOVED) {
- if (getCurRoom().picture == getCurRoom().curPicture) {
- const Common::Point &p = _itemOffsets[dropped];
- if (item->isLineArt)
- drawLineArt(_lineArt[item->picture - 1], p);
- else
- drawPic(item->picture, p);
- ++dropped;
- }
- continue;
- }
-
- Common::Array<byte>::const_iterator pic;
-
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture) {
- if (item->isLineArt)
- drawLineArt(_lineArt[item->picture - 1], item->position);
- else
- drawPic(item->picture, item->position);
- continue;
- }
- }
- }
-}
-
-void AdlEngine::drawNextPixel(Common::Point &p, byte color, byte bits, byte quadrant) const {
- if (bits & 4)
- _display->putPixel(p, color);
-
- bits += quadrant;
-
- if (bits & 1)
- p.x += (bits & 2 ? -1 : 1);
- else
- p.y += (bits & 2 ? 1 : -1);
-}
-
-void AdlEngine::drawLineArt(const Common::Array<byte> &lineArt, const Common::Point &pos, byte rotation, byte scaling, byte color) const {
- const byte stepping[] = {
- 0xff, 0xfe, 0xfa, 0xf4, 0xec, 0xe1, 0xd4, 0xc5,
- 0xb4, 0xa1, 0x8d, 0x78, 0x61, 0x49, 0x31, 0x18,
- 0xff
- };
-
- byte quadrant = rotation >> 4;
- rotation &= 0xf;
- byte xStep = stepping[rotation];
- byte yStep = stepping[(rotation ^ 0xf) + 1] + 1;
-
- Common::Point p(pos);
-
- for (uint i = 0; i < lineArt.size(); ++i) {
- byte b = lineArt[i];
-
- do {
- byte xFrac = 0x80;
- byte yFrac = 0x80;
- for (uint j = 0; j < scaling; ++j) {
- if (xFrac + xStep + 1 > 255)
- drawNextPixel(p, color, b, quadrant);
- xFrac += xStep + 1;
- if (yFrac + yStep > 255)
- drawNextPixel(p, color, b, quadrant + 1);
- yFrac += yStep;
- }
- b >>= 3;
- } while (b != 0);
- }
-}
-
-const Room &AdlEngine::getRoom(uint i) const {
- if (i < 1 || i > _state.rooms.size())
- error("Room %i out of range [1, %i]", i, _state.rooms.size());
-
- return _state.rooms[i - 1];
-}
-
-Room &AdlEngine::getRoom(uint i) {
- if (i < 1 || i > _state.rooms.size())
- error("Room %i out of range [1, %i]", i, _state.rooms.size());
-
- return _state.rooms[i - 1];
-}
-
-const Room &AdlEngine::getCurRoom() const {
- return getRoom(_state.room);
-}
-
-Room &AdlEngine::getCurRoom() {
- return getRoom(_state.room);
-}
-
-const Item &AdlEngine::getItem(uint i) const {
- if (i < 1 || i > _state.items.size())
- error("Item %i out of range [1, %i]", i, _state.items.size());
-
- return _state.items[i - 1];
-}
-
-Item &AdlEngine::getItem(uint i) {
- if (i < 1 || i > _state.items.size())
- error("Item %i out of range [1, %i]", i, _state.items.size());
-
- return _state.items[i - 1];
-}
-
-byte AdlEngine::getVar(uint i) const {
- if (i >= _state.vars.size())
- error("Variable %i out of range [0, %i]", i, _state.vars.size() - 1);
-
- return _state.vars[i];
-}
-
-void AdlEngine::setVar(uint i, byte value) {
- if (i >= _state.vars.size())
- error("Variable %i out of range [0, %i]", i, _state.vars.size() - 1);
-
- _state.vars[i] = value;
-}
-
-void AdlEngine::takeItem(byte noun) {
- Common::Array<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun != noun || item->room != _state.room)
- continue;
-
- if (item->state == IDI_ITEM_DOESNT_MOVE) {
- printMessage(_messageIds.itemDoesntMove);
- return;
- }
-
- if (item->state == IDI_ITEM_MOVED) {
- item->room = IDI_NONE;
- return;
- }
-
- Common::Array<byte>::const_iterator pic;
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture) {
- item->room = IDI_NONE;
- item->state = IDI_ITEM_MOVED;
- return;
- }
- }
- }
-
- printMessage(_messageIds.itemNotHere);
-}
-
-void AdlEngine::dropItem(byte noun) {
- Common::Array<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun != noun || item->room != IDI_NONE)
- continue;
-
- item->room = _state.room;
- item->state = IDI_ITEM_MOVED;
- return;
- }
-
- printMessage(_messageIds.dontUnderstand);
-}
-
#define ARG(N) (command.script[offset + (N)])
bool AdlEngine::matchCommand(const Command &command, byte verb, byte noun, uint *actions) const {
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 4ea7566669..df917b1868 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -149,6 +149,28 @@ protected:
void loadWords(Common::ReadStream &stream, WordMap &map) const;
void readCommands(Common::ReadStream &stream, Commands &commands);
+ // Graphics
+ void clearScreen() const;
+ void drawItems() const;
+ void drawNextPixel(Common::Point &p, byte color, byte bits, byte quadrant) const;
+ void drawLineArt(const Common::Array<byte> &lineArt, const Common::Point &pos, byte rotation = 0, byte scaling = 1, byte color = 0x7f) const;
+
+ // Game state functions
+ const Room &getRoom(uint i) const;
+ Room &getRoom(uint i);
+ const Room &getCurRoom() const;
+ Room &getCurRoom();
+ const Item &getItem(uint i) const;
+ Item &getItem(uint i);
+ byte getVar(uint i) const;
+ void setVar(uint i, byte value);
+ void takeItem(byte noun);
+ void dropItem(byte noun);
+ bool matchCommand(const Command &command, byte verb, byte noun, uint *actions = nullptr) const;
+ void doActions(const Command &command, byte noun, byte offset);
+ bool doOneCommand(const Commands &commands, byte verb, byte noun);
+ void doAllCommands(const Commands &commands, byte verb, byte noun);
+
Display *_display;
// Message strings in data file
@@ -193,6 +215,7 @@ private:
virtual void initState() = 0;
virtual void restartGame() = 0;
virtual void drawPic(byte pic, Common::Point pos = Common::Point()) const = 0;
+ virtual void showRoom() const = 0;
// Engine
Common::Error run();
@@ -211,29 +234,6 @@ private:
Common::String getWord(const Common::String &line, uint &index) const;
void getInput(uint &verb, uint &noun);
- // Graphics
- void showRoom() const;
- void clearScreen() const;
- void drawItems() const;
- void drawNextPixel(Common::Point &p, byte color, byte bits, byte quadrant) const;
- void drawLineArt(const Common::Array<byte> &lineArt, const Common::Point &pos, byte rotation = 0, byte scaling = 1, byte color = 0x7f) const;
-
- // Game state functions
- const Room &getRoom(uint i) const;
- Room &getRoom(uint i);
- const Room &getCurRoom() const;
- Room &getCurRoom();
- const Item &getItem(uint i) const;
- Item &getItem(uint i);
- byte getVar(uint i) const;
- void setVar(uint i, byte value);
- void takeItem(byte noun);
- void dropItem(byte noun);
- bool matchCommand(const Command &command, byte verb, byte noun, uint *actions = nullptr) const;
- void doActions(const Command &command, byte noun, byte offset);
- bool doOneCommand(const Commands &commands, byte verb, byte noun);
- void doAllCommands(const Commands &commands, byte verb, byte noun);
-
const AdlGameDescription *_gameDescription;
bool _isRestarting, _isRestoring;
byte _saveVerb, _saveNoun, _restoreVerb, _restoreNoun;
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 6e1e31df9f..c77504497e 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -239,11 +239,12 @@ void HiRes1Engine::initState() {
// Load room data from executable
_state.rooms.clear();
+ _roomDesc.clear();
f.seek(IDI_HR1_OFS_ROOMS);
for (uint i = 0; i < IDI_HR1_NUM_ROOMS; ++i) {
Room room;
f.readByte();
- room.description = f.readByte();
+ _roomDesc.push_back(f.readByte());
for (uint j = 0; j < 6; ++j)
room.connections[j] = f.readByte();
room.picture = f.readByte();
@@ -313,6 +314,16 @@ void HiRes1Engine::printMessage(uint idx, bool wait) const {
AdlEngine::printMessage(idx, wait);
}
+void HiRes1Engine::showRoom() const {
+ if (!_state.isDark) {
+ drawPic(getCurRoom().curPicture);
+ drawItems();
+ }
+
+ _display->updateHiResScreen();
+ printMessage(_roomDesc[_state.room - 1], false);
+}
+
void HiRes1Engine::drawLine(const Common::Point &p1, const Common::Point &p2, byte color) const {
// This draws a four-connected line
diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h
index 25f4744d26..422118d876 100644
--- a/engines/adl/hires1.h
+++ b/engines/adl/hires1.h
@@ -97,8 +97,9 @@ private:
void loadData();
void initState();
void restartGame();
- void drawPic(byte pic, Common::Point pos) const;
+ void drawPic(byte pic, Common::Point pos = Common::Point()) const;
void printMessage(uint idx, bool wait = true) const;
+ void showRoom() const;
void drawLine(const Common::Point &p1, const Common::Point &p2, byte color) const;
void drawPic(Common::ReadStream &stream, const Common::Point &pos) const;
@@ -106,6 +107,8 @@ private:
struct {
Common::String pressReturn;
} _gameStrings;
+
+ Common::Array<byte> _roomDesc;
};
} // End of namespace Adl
diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp
index 1831266aec..44abc22bca 100644
--- a/engines/adl/hires2.cpp
+++ b/engines/adl/hires2.cpp
@@ -73,6 +73,9 @@ void HiRes2Engine::restartGame() {
void HiRes2Engine::drawPic(byte pic, Common::Point pos) const {
}
+void HiRes2Engine::showRoom() const {
+}
+
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 60c6ca12d8..e37af5a4b2 100644
--- a/engines/adl/hires2.h
+++ b/engines/adl/hires2.h
@@ -56,6 +56,7 @@ private:
void initState();
void restartGame();
void drawPic(byte pic, Common::Point pos) const;
+ void showRoom() const;
};
} // End of namespace Adl