ADL: Move multi-disk handling into v2

This commit is contained in:
Walter van Niftrik 2017-02-27 22:12:46 +01:00
parent c88d30d8d3
commit 19b07a7c12
4 changed files with 27 additions and 25 deletions

View File

@ -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<ScriptEnv &, int, AdlEngine_v2> OpcodeV2;
#define SetOpcodeTable(x) table = &x;
#define Opcode(x) table->push_back(new OpcodeV2(this, &AdlEngine_v2::x))

View File

@ -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 &sector, byte &offset, byte &size) const { }
void loadItems(Common::ReadStream &stream);
@ -91,6 +93,7 @@ protected:
uint _maxLines;
DiskImage *_disk;
byte _currentVolume;
Common::Array<DataBlockPtr> _itemPics;
bool _itemRemoved;
byte _roomOnScreen, _picOnScreen, _itemsOnScreen;

View File

@ -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;

View File

@ -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<RegionLocation> _regionLocations;
Common::Array<RegionInitDataOffset> _regionInitDataOffsets;
Common::SeekableReadStream *_itemPicIndex;