diff options
author | Walter van Niftrik | 2016-02-28 17:12:00 +0100 |
---|---|---|
committer | Walter van Niftrik | 2016-03-09 10:03:13 +0100 |
commit | 34cb2f4c53280d5b1f10ded5951d0ca5c0bf754d (patch) | |
tree | 28d4eb8ff796e12079c9dbb960b4828d70c4a0e9 | |
parent | 24c478c5ecd61d42a1456a7b8cbecec70e24cd1a (diff) | |
download | scummvm-rg350-34cb2f4c53280d5b1f10ded5951d0ca5c0bf754d.tar.gz scummvm-rg350-34cb2f4c53280d5b1f10ded5951d0ca5c0bf754d.tar.bz2 scummvm-rg350-34cb2f4c53280d5b1f10ded5951d0ca5c0bf754d.zip |
ADL: Move functionality into base class
-rw-r--r-- | engines/adl/adl.cpp | 47 | ||||
-rw-r--r-- | engines/adl/adl.h | 3 | ||||
-rw-r--r-- | engines/adl/hires1.cpp | 55 | ||||
-rw-r--r-- | engines/adl/hires1.h | 5 |
4 files changed, 56 insertions, 54 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index c46b74799a..9676924f34 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -206,7 +206,7 @@ void AdlEngine::dropItem(byte noun) { printEngineMessage(IDI_MSG_DONT_UNDERSTAND); } -#define ARG(N) (command.script[offset + N]) +#define ARG(N) (command.script[offset + (N)]) void AdlEngine::doActions(const Command &command, byte noun, byte offset) { for (uint i = 0; i < command.numAct; ++i) { @@ -404,6 +404,51 @@ void AdlEngine::clearScreen() { _display->clear(0x00); } +void AdlEngine::drawItems() { + Common::Array<Item>::const_iterator item; + + uint dropped = 0; + + for (item = _inventory.begin(); item != _inventory.end(); ++item) { + if (item->room != _room) + continue; + + if (item->state == IDI_ITEM_MOVED) { + if (_rooms[_room].picture == _rooms[_room].curPicture) { + const Common::Point &p = _itemOffsets[dropped]; + if (item->isDrawing) + _display->drawRightAngles(_drawings[item->picture - 1], p, 0, 1, 0x7f); + 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 == _rooms[_room].curPicture) { + if (item->isDrawing) + _display->drawRightAngles(_drawings[item->picture - 1], item->position, 0, 1, 0x7f); + else + drawPic(item->picture, item->position); + continue; + } + } + } +} + +void AdlEngine::showRoom() { + if (!_isDark) { + drawPic(_rooms[_room].curPicture); + drawItems(); + } + + _display->decodeFrameBuffer(); + printMessage(_rooms[_room].description, false); +} + AdlEngine *AdlEngine::create(GameType type, OSystem *syst, const AdlGameDescription *gd) { switch(type) { case kGameTypeHires1: diff --git a/engines/adl/adl.h b/engines/adl/adl.h index 02207d951e..a030059ec0 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -174,6 +174,9 @@ protected: void doAllCommands(const Commands &commands, byte verb, byte noun); void doActions(const Command &command, byte noun, byte offset); void clearScreen(); + virtual void drawPic(byte pic, Common::Point pos = Common::Point()) = 0; + void drawItems(); + void showRoom(); void takeItem(byte noun); void dropItem(byte noun); diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp index dde8ed0fc7..64ae81fbeb 100644 --- a/engines/adl/hires1.cpp +++ b/engines/adl/hires1.cpp @@ -169,7 +169,7 @@ void HiRes1Engine::runIntro() { } } -void HiRes1Engine::drawPic(Common::ReadStream &stream, byte xOffset, byte yOffset) { +void HiRes1Engine::drawPic(Common::ReadStream &stream, Common::Point pos) { byte x, y; bool bNewLine = false; byte oldX = 0, oldY = 0; @@ -188,8 +188,8 @@ void HiRes1Engine::drawPic(Common::ReadStream &stream, byte xOffset, byte yOffse continue; } - x += xOffset; - y += yOffset; + x += pos.x; + y += pos.y; if (y > 160) y = 160; @@ -206,7 +206,7 @@ void HiRes1Engine::drawPic(Common::ReadStream &stream, byte xOffset, byte yOffse } } -void HiRes1Engine::drawPic(byte pic, byte xOffset, byte yOffset) { +void HiRes1Engine::drawPic(byte pic, Common::Point pos) { Common::File f; Common::String name = Common::String::format("BLOCK%i", _pictures[pic].block); @@ -214,52 +214,7 @@ void HiRes1Engine::drawPic(byte pic, byte xOffset, byte yOffset) { error("Failed to open file"); f.seek(_pictures[pic].offset); - drawPic(f, xOffset, yOffset); -} - -void HiRes1Engine::drawItems() { - Common::Array<Item>::const_iterator item; - - uint dropped = 0; - - for (item = _inventory.begin(); item != _inventory.end(); ++item) { - if (item->room != _room) - continue; - - if (item->state == IDI_ITEM_MOVED) { - if (_rooms[_room].picture == _rooms[_room].curPicture) { - const Common::Point &p = _itemOffsets[dropped]; - if (item->isDrawing) - _display->drawRightAngles(_drawings[item->picture - 1], Common::Point(p.x, p.y), 0, 1, 0x7f); - else - drawPic(item->picture, p.x, p.y); - ++dropped; - } - continue; - } - - Common::Array<byte>::const_iterator pic; - - for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) { - if (*pic == _rooms[_room].curPicture) { - if (item->isDrawing) - _display->drawRightAngles(_drawings[item->picture - 1], item->position, 0, 1, 0x7f); - else - drawPic(item->picture, item->position.x, item->position.y); - continue; - } - } - } -} - -void HiRes1Engine::showRoom() { - if (!_isDark) { - drawPic(_rooms[_room].curPicture, 0, 0); - drawItems(); - } - - _display->decodeFrameBuffer(); - printMessage(_rooms[_room].description, false); + drawPic(f, pos); } void HiRes1Engine::runGame() { diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h index 19aa55ee9f..4bd0a87034 100644 --- a/engines/adl/hires1.h +++ b/engines/adl/hires1.h @@ -53,10 +53,9 @@ private: uint getEngineMessage(EngineMessage msg); void runIntro(); - void drawPic(Common::ReadStream &stream, byte xOffset, byte yOffset); - void showRoom(); + void drawPic(Common::ReadStream &stream, Common::Point pos); void drawItems(); - void drawPic(byte pic, byte xOffset, byte yOffset); + void drawPic(byte pic, Common::Point pos); }; } // End of namespace Adl |