diff options
author | Walter van Niftrik | 2016-03-26 16:27:51 +0100 |
---|---|---|
committer | Walter van Niftrik | 2016-06-06 20:35:49 +0200 |
commit | bd588d96155d2b8626d8f760d4bb41fba60efc8e (patch) | |
tree | 8639bd761c6aafa8d3fa7f08c72ccb840b4e5c8c /engines | |
parent | aa661fae5c3a6be2d09a0a6632770131ff02c550 (diff) | |
download | scummvm-rg350-bd588d96155d2b8626d8f760d4bb41fba60efc8e.tar.gz scummvm-rg350-bd588d96155d2b8626d8f760d4bb41fba60efc8e.tar.bz2 scummvm-rg350-bd588d96155d2b8626d8f760d4bb41fba60efc8e.zip |
ADL: Use HashMaps for room/global pics
Diffstat (limited to 'engines')
-rw-r--r-- | engines/adl/adl.h | 13 | ||||
-rw-r--r-- | engines/adl/hires1.cpp | 8 | ||||
-rw-r--r-- | engines/adl/hires1.h | 4 | ||||
-rw-r--r-- | engines/adl/hires2.cpp | 33 | ||||
-rw-r--r-- | engines/adl/hires2.h | 3 |
5 files changed, 18 insertions, 43 deletions
diff --git a/engines/adl/adl.h b/engines/adl/adl.h index ffa35791b4..d8ee5d930c 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -86,9 +86,7 @@ struct Room { bool isFirstTime; }; -struct Picture { - DataBlockPtr data; -}; +typedef Common::HashMap<byte, DataBlockPtr> PictureMap; typedef Common::Array<byte> Script; @@ -164,14 +162,9 @@ struct State { typedef Common::List<Command> Commands; typedef Common::HashMap<Common::String, uint> WordMap; -struct Picture2 { - byte nr; - DataBlockPtr data; -}; - struct RoomData { Common::String description; - Common::Array<Picture2> pictures; + PictureMap pictures; Commands commands; }; @@ -272,7 +265,7 @@ protected: // Message strings in data file Common::Array<Common::String> _messages; // Picture data - Common::Array<Picture> _pictures; + PictureMap _pictures; // Dropped item screen offsets Common::Array<Common::Point> _itemOffsets; // <room, verb, noun, script> lists diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp index b191afd12c..4161bfed05 100644 --- a/engines/adl/hires1.cpp +++ b/engines/adl/hires1.cpp @@ -166,13 +166,11 @@ void HiRes1Engine::init() { // Load picture data from executable stream->seek(IDI_HR1_OFS_PICS); - for (uint i = 0; i < IDI_HR1_NUM_PICS; ++i) { - struct Picture pic; + for (uint i = 1; i <= IDI_HR1_NUM_PICS; ++i) { byte block = stream->readByte(); Common::String name = Common::String::format("BLOCK%i", block); uint16 offset = stream->readUint16LE(); - pic.data = _files->getDataBlock(name, offset); - _pictures.push_back(pic); + _pictures[i] = _files->getDataBlock(name, offset); } // Load commands from executable @@ -265,7 +263,7 @@ void HiRes1Engine::restartGame() { } void HiRes1Engine::drawPic(byte pic, Common::Point pos) const { - _graphics->drawPic(*_pictures[pic].data->createReadStream(), pos, 0x7f); + _graphics->drawPic(*_pictures[pic]->createReadStream(), pos, 0x7f); } void HiRes1Engine::printString(const Common::String &str) { diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h index d601f7d13d..29cdd5a3c2 100644 --- a/engines/adl/hires1.h +++ b/engines/adl/hires1.h @@ -42,7 +42,7 @@ namespace Adl { #define IDS_HR1_MESSAGES "MESSAGES" #define IDI_HR1_NUM_ROOMS 41 -#define IDI_HR1_NUM_PICS 98 +#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 @@ -79,7 +79,7 @@ namespace Adl { #define IDI_HR1_OFS_ITEMS 0x0100 #define IDI_HR1_OFS_ROOMS 0x050a -#define IDI_HR1_OFS_PICS 0x4b00 +#define IDI_HR1_OFS_PICS 0x4b03 #define IDI_HR1_OFS_CMDS_0 0x3c00 #define IDI_HR1_OFS_CMDS_1 0x3d00 diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp index d4f1c09499..f6818a6638 100644 --- a/engines/adl/hires2.cpp +++ b/engines/adl/hires2.cpp @@ -41,11 +41,6 @@ DataBlockPtr HiRes2Engine::readDataBlockPtr(Common::ReadStream &f) const { return _disk.getDataBlock(track, sector, offset, size); } -void HiRes2Engine::readPictureMeta(Common::ReadStream &f, Picture2 &pic) const { - pic.nr = f.readByte(); - pic.data = readDataBlockPtr(f); -} - void HiRes2Engine::runIntro() const { StreamPtr stream(_disk.createReadStream(0x00, 0xd, 0x17, 1)); @@ -105,9 +100,8 @@ void HiRes2Engine::init() { // Load item picture data stream.reset(_disk.createReadStream(0x1e, 0x9, 0x05)); for (uint i = 0; i < IDI_HR2_NUM_ITEM_PICS; ++i) { - Picture2 pic; - readPictureMeta(*stream, pic); - _itemPics.push_back(pic); + stream->readByte(); // number + _itemPics.push_back(readDataBlockPtr(*stream)); } // Load commands from executable @@ -187,22 +181,14 @@ void HiRes2Engine::restartGame() { } void HiRes2Engine::drawPic(byte pic, Common::Point pos) const { - Common::Array<Picture2>::const_iterator roomPic; - - for (roomPic = _roomData.pictures.begin(); roomPic != _roomData.pictures.end(); ++roomPic) { - if (roomPic->nr == pic) { - StreamPtr stream(roomPic->data->createReadStream()); - _graphics->drawPic(*stream, pos, 0); - return; - } - } - - // Check global pic list here + if (_roomData.pictures.contains(pic)) + _graphics->drawPic(*_roomData.pictures[pic]->createReadStream(), pos, 0); + else + _graphics->drawPic(*_pictures[pic]->createReadStream(), pos, 0); } void HiRes2Engine::drawItem(const Item &item, const Common::Point &pos) const { - const Picture2 &pic = _itemPics[item.picture - 1]; - StreamPtr stream(pic.data->createReadStream()); + StreamPtr stream(_itemPics[item.picture - 1]->createReadStream()); stream->readByte(); // Skip clear opcode _graphics->drawPic(*stream, pos, 0); } @@ -220,9 +206,8 @@ void HiRes2Engine::loadRoom(byte roomNr) { uint16 picCount = (descOffset - 4) / 5; for (uint i = 0; i < picCount; ++i) { - Picture2 pic; - readPictureMeta(*stream, pic); - _roomData.pictures.push_back(pic); + byte nr = stream->readByte(); + _roomData.pictures[nr] = readDataBlockPtr(*stream); } _roomData.description = readStringAt(*stream, descOffset, 0xff); diff --git a/engines/adl/hires2.h b/engines/adl/hires2.h index a4bc0b6859..17687b5359 100644 --- a/engines/adl/hires2.h +++ b/engines/adl/hires2.h @@ -66,10 +66,9 @@ private: void showRoom(); DataBlockPtr readDataBlockPtr(Common::ReadStream &f) const; - void readPictureMeta(Common::ReadStream &f, Picture2 &pic) const; DiskImage_DSK _disk; - Common::Array<Picture2> _itemPics; + Common::Array<DataBlockPtr> _itemPics; }; } // End of namespace Adl |