mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 12:09:15 +00:00
ADL: Load hires4 commands and item pictures
This commit is contained in:
parent
70cd57892a
commit
177206cc2e
@ -429,6 +429,13 @@ void AdlEngine_v2::loadPictures(Common::SeekableReadStream &stream) {
|
||||
}
|
||||
}
|
||||
|
||||
void AdlEngine_v2::loadItemPictures(Common::SeekableReadStream &stream, byte count) {
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
stream.readByte(); // number
|
||||
_itemPics.push_back(readDataBlockPtr(stream));
|
||||
}
|
||||
}
|
||||
|
||||
int AdlEngine_v2::o2_isFirstTime(ScriptEnv &e) {
|
||||
OP_DEBUG_0("\t&& IS_FIRST_TIME()");
|
||||
|
||||
|
@ -57,6 +57,7 @@ protected:
|
||||
void loadRooms(Common::SeekableReadStream &stream, byte count);
|
||||
void loadMessages(Common::SeekableReadStream &stream, byte count);
|
||||
void loadPictures(Common::SeekableReadStream &stream);
|
||||
void loadItemPictures(Common::SeekableReadStream &stream, byte count);
|
||||
|
||||
void checkTextOverflow(char c);
|
||||
|
||||
|
@ -265,7 +265,7 @@ Common::SeekableReadStream *DiskImage::createReadStream(uint track, uint sector,
|
||||
bytesRemInTrack = bytesToRead - dataOffset;
|
||||
|
||||
if (_stream->read(data + dataOffset, bytesRemInTrack) < bytesRemInTrack)
|
||||
error("Error reading disk image");
|
||||
error("Error reading disk image at track %d; sector %d", track, sector);
|
||||
|
||||
++track;
|
||||
|
||||
|
@ -77,10 +77,7 @@ void HiRes0Engine::init() {
|
||||
|
||||
// Load item picture data
|
||||
stream.reset(_disk->createReadStream(0x1e, 0x9, 0x05));
|
||||
for (uint i = 0; i < IDI_HR0_NUM_ITEM_PICS; ++i) {
|
||||
stream->readByte(); // number
|
||||
_itemPics.push_back(readDataBlockPtr(*stream));
|
||||
}
|
||||
loadItemPictures(*stream, IDI_HR0_NUM_ITEM_PICS);
|
||||
|
||||
// Load commands from executable
|
||||
stream.reset(_disk->createReadStream(0x1d, 0x7, 0x00, 2));
|
||||
|
@ -100,10 +100,7 @@ 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) {
|
||||
stream->readByte(); // number
|
||||
_itemPics.push_back(readDataBlockPtr(*stream));
|
||||
}
|
||||
loadItemPictures(*stream, IDI_HR2_NUM_ITEM_PICS);
|
||||
|
||||
// Load commands from executable
|
||||
stream.reset(_disk->createReadStream(0x1d, 0x7, 0x00, 4));
|
||||
|
@ -45,9 +45,7 @@ void HiRes4Engine::init() {
|
||||
if (!_boot->open(getDiskImageName(0)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(0));
|
||||
|
||||
_disk = new DiskImage();
|
||||
if (!_disk->open(getDiskImageName(1)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(1));
|
||||
insertDisk(1);
|
||||
|
||||
loadCommonData();
|
||||
|
||||
@ -65,6 +63,12 @@ void HiRes4Engine::init() {
|
||||
stream.reset(createReadStream(_boot, 0x06, 0xd, 0x12, 2));
|
||||
loadItemDescriptions(*stream, IDI_HR4_NUM_ITEM_DESCS);
|
||||
|
||||
stream.reset(createReadStream(_boot, 0x08, 0xe, 0xa5, 5));
|
||||
readCommands(*stream, _roomCommands);
|
||||
|
||||
stream.reset(createReadStream(_boot, 0x0a, 0x9, 0x00, 3));
|
||||
readCommands(*stream, _globalCommands);
|
||||
|
||||
stream.reset(createReadStream(_boot, 0x05, 0x4, 0x00, 3));
|
||||
loadWords(*stream, _verbs, _priVerbs);
|
||||
|
||||
@ -72,6 +76,31 @@ void HiRes4Engine::init() {
|
||||
loadWords(*stream, _nouns, _priNouns);
|
||||
}
|
||||
|
||||
void HiRes4Engine::loadRoom(byte roomNr) {
|
||||
if (roomNr >= 59 && roomNr < 113) {
|
||||
insertDisk(2);
|
||||
rebindDisk();
|
||||
} else {
|
||||
insertDisk(1);
|
||||
rebindDisk();
|
||||
}
|
||||
|
||||
if (roomNr == 121) {
|
||||
// Room 121 is not present in the Atari version. This causes
|
||||
// problems when we're dumping scripts with the debugger, so
|
||||
// we intercept this room load here.
|
||||
// FIXME: Find out if the Apple II version does have this room
|
||||
// FIXME: Implement more generic handling of invalid rooms?
|
||||
debug("Warning: attempt to load non-existent room 121");
|
||||
_roomData.description.clear();
|
||||
_roomData.pictures.clear();
|
||||
_roomData.commands.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
AdlEngine_v3::loadRoom(roomNr);
|
||||
}
|
||||
|
||||
Common::String HiRes4Engine::formatVerbError(const Common::String &verb) const {
|
||||
Common::String err = _strings.verbError;
|
||||
for (uint i = 0; i < verb.size(); ++i)
|
||||
@ -88,13 +117,20 @@ Common::String HiRes4Engine::formatNounError(const Common::String &verb, const C
|
||||
return err;
|
||||
}
|
||||
|
||||
void HiRes4Engine::goToSideC() {
|
||||
void HiRes4Engine::insertDisk(byte diskNr) {
|
||||
if (_curDisk == diskNr)
|
||||
return;
|
||||
|
||||
_curDisk = diskNr;
|
||||
|
||||
delete _disk;
|
||||
|
||||
_disk = new DiskImage();
|
||||
if (!_disk->open(getDiskImageName(2)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(2));
|
||||
if (!_disk->open(getDiskImageName(diskNr)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(diskNr));
|
||||
}
|
||||
|
||||
void HiRes4Engine::rebindDisk() {
|
||||
// As room.data is bound to the DiskImage, we need to rebind them here
|
||||
// We cannot simply reload the rooms as that would reset their state
|
||||
|
||||
@ -119,6 +155,10 @@ void HiRes4Engine::loadCommonData() {
|
||||
_pictures.clear();
|
||||
stream.reset(createReadStream(_boot, 0x05, 0xe, 0x80));
|
||||
loadPictures(*stream);
|
||||
|
||||
_itemPics.clear();
|
||||
stream.reset(createReadStream(_boot, 0x09, 0xe, 0x05));
|
||||
loadItemPictures(*stream, IDI_HR4_NUM_ITEM_PICS);
|
||||
}
|
||||
|
||||
void HiRes4Engine::initGameState() {
|
||||
|
@ -32,6 +32,7 @@ namespace Adl {
|
||||
#define IDI_HR4_NUM_ROOMS 164
|
||||
#define IDI_HR4_NUM_MESSAGES 255
|
||||
#define IDI_HR4_NUM_VARS 40
|
||||
#define IDI_HR4_NUM_ITEM_PICS 41
|
||||
#define IDI_HR4_NUM_ITEM_DESCS 44
|
||||
|
||||
// Messages used outside of scripts
|
||||
@ -46,20 +47,26 @@ public:
|
||||
~HiRes4Engine();
|
||||
|
||||
protected:
|
||||
HiRes4Engine(OSystem *syst, const AdlGameDescription *gd) : AdlEngine_v3(syst, gd) { }
|
||||
HiRes4Engine(OSystem *syst, const AdlGameDescription *gd) :
|
||||
AdlEngine_v3(syst, gd),
|
||||
_boot(nullptr),
|
||||
_curDisk(0) { }
|
||||
|
||||
// AdlEngine
|
||||
void init();
|
||||
void initGameState();
|
||||
void loadRoom(byte roomNr);
|
||||
Common::String formatVerbError(const Common::String &verb) const;
|
||||
Common::String formatNounError(const Common::String &verb, const Common::String &noun) const;
|
||||
|
||||
Common::SeekableReadStream *createReadStream(DiskImage *disk, byte track, byte sector, byte offset = 0, byte size = 0) const;
|
||||
void loadCommonData();
|
||||
void goToSideC();
|
||||
void insertDisk(byte diskNr);
|
||||
void rebindDisk();
|
||||
virtual const char *getDiskImageName(byte index) const = 0;
|
||||
|
||||
DiskImage *_boot;
|
||||
byte _curDisk;
|
||||
};
|
||||
|
||||
class HiRes4Engine_Atari : public HiRes4Engine {
|
||||
|
@ -186,10 +186,7 @@ void HiRes6Engine::loadDisk(byte disk) {
|
||||
// Load item picture data (indexed on boot disk)
|
||||
StreamPtr stream(_boot->createReadStream(0xb, 0xd, 0x08));
|
||||
_itemPics.clear();
|
||||
for (uint i = 0; i < IDI_HR6_NUM_ITEM_PICS; ++i) {
|
||||
stream->readByte();
|
||||
_itemPics.push_back(readDataBlockPtr(*stream));
|
||||
}
|
||||
loadItemPictures(*stream, IDI_HR6_NUM_ITEM_PICS);
|
||||
|
||||
_curDisk = disk;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user