From 19b07a7c125b40d42996e1c943131504649b97eb Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Mon, 27 Feb 2017 22:12:46 +0100 Subject: ADL: Move multi-disk handling into v2 --- engines/adl/adl_v2.cpp | 22 ++++++++++++++++++++++ engines/adl/adl_v2.h | 3 +++ engines/adl/adl_v4.cpp | 24 ++---------------------- engines/adl/adl_v4.h | 3 --- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 23294391ab..dfc2df6ef4 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -26,6 +26,7 @@ #include "adl/adl_v2.h" #include "adl/display.h" #include "adl/graphics.h" +#include "adl/detection.h" namespace Adl { @@ -38,6 +39,7 @@ AdlEngine_v2::AdlEngine_v2(OSystem *syst, const AdlGameDescription *gd) : AdlEngine(syst, gd), _maxLines(4), _disk(nullptr), + _currentVolume(0), _itemRemoved(false), _roomOnScreen(0), _picOnScreen(0), @@ -45,6 +47,26 @@ AdlEngine_v2::AdlEngine_v2(OSystem *syst, const AdlGameDescription *gd) : _random = new Common::RandomSource("adl"); } +Common::String AdlEngine_v2::getDiskImageName(byte volume) const { + const ADGameFileDescription *ag; + + for (ag = _gameDescription->desc.filesDescriptions; ag->fileName; ag++) + if (ag->fileType == volume) + return ag->fileName; + + error("Disk volume %d not found", volume); +} + +void AdlEngine_v2::insertDisk(byte volume) { + delete _disk; + _disk = new DiskImage(); + + if (!_disk->open(getDiskImageName(volume))) + error("Failed to open disk volume %d", volume); + + _currentVolume = volume; +} + typedef Common::Functor1Mem OpcodeV2; #define SetOpcodeTable(x) table = &x; #define Opcode(x) table->push_back(new OpcodeV2(this, &AdlEngine_v2::x)) diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index 9d4d5fa600..889b03c90f 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -54,6 +54,8 @@ protected: // Engine bool canSaveGameStateCurrently(); + Common::String getDiskImageName(byte volume) const; + void insertDisk(byte volume); virtual DataBlockPtr readDataBlockPtr(Common::ReadStream &f) const; virtual void adjustDataBlockPtr(byte &track, byte §or, byte &offset, byte &size) const { } void loadItems(Common::ReadStream &stream); @@ -91,6 +93,7 @@ protected: uint _maxLines; DiskImage *_disk; + byte _currentVolume; Common::Array _itemPics; bool _itemRemoved; byte _roomOnScreen, _picOnScreen, _itemsOnScreen; diff --git a/engines/adl/adl_v4.cpp b/engines/adl/adl_v4.cpp index e8ee798199..c06099b98d 100644 --- a/engines/adl/adl_v4.cpp +++ b/engines/adl/adl_v4.cpp @@ -20,15 +20,15 @@ * */ +#include "common/error.h" + #include "adl/adl_v4.h" #include "adl/display.h" -#include "adl/detection.h" namespace Adl { AdlEngine_v4::AdlEngine_v4(OSystem *syst, const AdlGameDescription *gd) : AdlEngine_v3(syst, gd), - _currentVolume(0), _itemPicIndex(nullptr) { } @@ -190,26 +190,6 @@ Common::String AdlEngine_v4::getItemDescription(const Item &item) const { return _itemDesc[item.id - 1]; } -Common::String AdlEngine_v4::getDiskImageName(byte volume) const { - const ADGameFileDescription *ag; - - for (ag = _gameDescription->desc.filesDescriptions; ag->fileName; ag++) - if (ag->fileType == volume) - return ag->fileName; - - error("Disk volume %d not found", volume); -} - -void AdlEngine_v4::insertDisk(byte volume) { - delete _disk; - _disk = new DiskImage(); - - if (!_disk->open(getDiskImageName(volume))) - error("Failed to open disk volume %d", volume); - - _currentVolume = volume; -} - void AdlEngine_v4::loadRegionLocations(Common::ReadStream &stream, uint regions) { for (uint r = 0; r < regions; ++r) { RegionLocation loc; diff --git a/engines/adl/adl_v4.h b/engines/adl/adl_v4.h index ca9aeff492..efb58b250b 100644 --- a/engines/adl/adl_v4.h +++ b/engines/adl/adl_v4.h @@ -71,8 +71,6 @@ protected: kRegionChunkGlobalCmds }; - Common::String getDiskImageName(byte volume) const; - void insertDisk(byte volume); void loadRegionLocations(Common::ReadStream &stream, uint regions); void loadRegionInitDataOffsets(Common::ReadStream &stream, uint regions); void initRegions(const byte *roomsPerRegion, uint regions); @@ -98,7 +96,6 @@ protected: int o4_setRegionRoom(ScriptEnv &e); int o4_setRoomPic(ScriptEnv &e); - byte _currentVolume; Common::Array _regionLocations; Common::Array _regionInitDataOffsets; Common::SeekableReadStream *_itemPicIndex; -- cgit v1.2.3