mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 09:18:38 +00:00
ADL: Load hires4 rooms
This commit is contained in:
parent
70588aecdc
commit
bcd5df5c6e
@ -395,6 +395,25 @@ void AdlEngine_v2::loadItems(Common::SeekableReadStream &stream) {
|
||||
error("Error loading items");
|
||||
}
|
||||
|
||||
void AdlEngine_v2::loadRooms(Common::SeekableReadStream &stream, byte count) {
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
Room room;
|
||||
|
||||
stream.readByte(); // number
|
||||
for (uint j = 0; j < 6; ++j)
|
||||
room.connections[j] = stream.readByte();
|
||||
room.data = readDataBlockPtr(stream);
|
||||
room.picture = stream.readByte();
|
||||
room.curPicture = stream.readByte();
|
||||
room.isFirstTime = stream.readByte();
|
||||
|
||||
_state.rooms.push_back(room);
|
||||
}
|
||||
|
||||
if (stream.eos() || stream.err())
|
||||
error("Error loading rooms");
|
||||
}
|
||||
|
||||
int AdlEngine_v2::o2_isFirstTime(ScriptEnv &e) {
|
||||
OP_DEBUG_0("\t&& IS_FIRST_TIME()");
|
||||
|
||||
|
@ -54,6 +54,7 @@ protected:
|
||||
virtual DataBlockPtr readDataBlockPtr(Common::ReadStream &f) const;
|
||||
virtual void adjustDataBlockPtr(byte &track, byte §or, byte &offset, byte &size) const { }
|
||||
void loadItems(Common::SeekableReadStream &stream);
|
||||
void loadRooms(Common::SeekableReadStream &stream, byte count);
|
||||
|
||||
void checkTextOverflow(char c);
|
||||
|
||||
|
@ -35,7 +35,7 @@ Common::String AdlEngine_v3::getItemDescription(const Item &item) const {
|
||||
void AdlEngine_v3::loadItemDescriptions(Common::SeekableReadStream &stream, byte count) {
|
||||
int32 startPos = stream.pos();
|
||||
uint16 baseAddr = stream.readUint16LE();
|
||||
debug("%04x", baseAddr);
|
||||
|
||||
// This code assumes that the first pointer points to a string that
|
||||
// directly follows the pointer table
|
||||
assert(baseAddr != 0);
|
||||
|
@ -119,21 +119,9 @@ void HiRes0Engine::initGameState() {
|
||||
_state.vars.resize(IDI_HR0_NUM_VARS);
|
||||
|
||||
StreamPtr stream(_disk->createReadStream(0x21, 0x5, 0x0e, 2));
|
||||
|
||||
for (uint i = 0; i < IDI_HR0_NUM_ROOMS; ++i) {
|
||||
Room room;
|
||||
stream->readByte(); // number
|
||||
for (uint j = 0; j < 6; ++j)
|
||||
room.connections[j] = stream->readByte();
|
||||
room.data = readDataBlockPtr(*stream);
|
||||
room.picture = stream->readByte();
|
||||
room.curPicture = stream->readByte();
|
||||
room.isFirstTime = stream->readByte();
|
||||
_state.rooms.push_back(room);
|
||||
}
|
||||
loadRooms(*stream, IDI_HR0_NUM_ROOMS);
|
||||
|
||||
stream.reset(_disk->createReadStream(0x21, 0x0));
|
||||
|
||||
loadItems(*stream);
|
||||
}
|
||||
|
||||
|
@ -142,21 +142,9 @@ void HiRes2Engine::initGameState() {
|
||||
_state.vars.resize(IDI_HR2_NUM_VARS);
|
||||
|
||||
StreamPtr stream(_disk->createReadStream(0x21, 0x5, 0x0e, 7));
|
||||
|
||||
for (uint i = 0; i < IDI_HR2_NUM_ROOMS; ++i) {
|
||||
Room room;
|
||||
stream->readByte(); // number
|
||||
for (uint j = 0; j < 6; ++j)
|
||||
room.connections[j] = stream->readByte();
|
||||
room.data = readDataBlockPtr(*stream);
|
||||
room.picture = stream->readByte();
|
||||
room.curPicture = stream->readByte();
|
||||
room.isFirstTime = stream->readByte();
|
||||
_state.rooms.push_back(room);
|
||||
}
|
||||
loadRooms(*stream, IDI_HR2_NUM_ROOMS);
|
||||
|
||||
stream.reset(_disk->createReadStream(0x21, 0x0, 0x00, 2));
|
||||
|
||||
loadItems(*stream);
|
||||
}
|
||||
|
||||
|
@ -35,40 +35,57 @@
|
||||
namespace Adl {
|
||||
|
||||
HiRes4Engine::~HiRes4Engine() {
|
||||
delete _disk2;
|
||||
delete _disk3;
|
||||
delete _boot;
|
||||
}
|
||||
|
||||
void HiRes4Engine::init() {
|
||||
_graphics = new Graphics_v2(*_display);
|
||||
|
||||
const char *const *names = getDiskImageNames();
|
||||
_boot = new DiskImage();
|
||||
if (!_boot->open(getDiskImageName(0)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(0));
|
||||
|
||||
_disk = new DiskImage();
|
||||
if (!_disk->open(names[0]))
|
||||
error("Failed to open disk image '%s'", names[0]);
|
||||
|
||||
_disk2 = new DiskImage();
|
||||
if (!_disk2->open(names[1]))
|
||||
error("Failed to open disk image '%s'", names[1]);
|
||||
|
||||
_disk3 = new DiskImage();
|
||||
if (!_disk3->open(names[2]))
|
||||
error("Failed to open disk image '%s'", names[2]);
|
||||
|
||||
StreamPtr stream(createReadStream(_disk, 0x06, 0xd, 0x12, 2));
|
||||
StreamPtr stream(createReadStream(_boot, 0x06, 0xd, 0x12, 2));
|
||||
loadItemDescriptions(*stream, IDI_HR4_NUM_ITEM_DESCS);
|
||||
|
||||
stream.reset(createReadStream(_disk, 0x05, 0x4, 0x00, 3));
|
||||
stream.reset(createReadStream(_boot, 0x05, 0x4, 0x00, 3));
|
||||
loadWords(*stream, _verbs, _priVerbs);
|
||||
|
||||
stream.reset(createReadStream(_disk, 0x03, 0xb, 0x00, 6));
|
||||
stream.reset(createReadStream(_boot, 0x03, 0xb, 0x00, 6));
|
||||
loadWords(*stream, _nouns, _priNouns);
|
||||
}
|
||||
|
||||
void HiRes4Engine::goToSideC() {
|
||||
delete _disk;
|
||||
|
||||
_disk = new DiskImage();
|
||||
if (!_disk->open(getDiskImageName(2)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(2));
|
||||
|
||||
// As room.data is bound to the DiskImage, we need to rebind them here
|
||||
StreamPtr stream(createReadStream(_boot, 0x03, 0x1, 0x0e, 17));
|
||||
for (uint i = 0; i < IDI_HR4_NUM_ROOMS; ++i) {
|
||||
stream->skip(7);
|
||||
_state.rooms[i].data = readDataBlockPtr(*stream);
|
||||
stream->skip(3);
|
||||
}
|
||||
}
|
||||
|
||||
void HiRes4Engine::initGameState() {
|
||||
StreamPtr stream(createReadStream(_disk, 0x02, 0xc, 0x00, 12));
|
||||
_disk = new DiskImage();
|
||||
if (!_disk->open(getDiskImageName(1)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(1));
|
||||
|
||||
_state.vars.resize(IDI_HR4_NUM_VARS);
|
||||
|
||||
StreamPtr stream(createReadStream(_boot, 0x03, 0x1, 0x0e, 9));
|
||||
loadRooms(*stream, IDI_HR4_NUM_ROOMS);
|
||||
|
||||
stream.reset(createReadStream(_boot, 0x02, 0xc, 0x00, 12));
|
||||
loadItems(*stream);
|
||||
|
||||
// FIXME
|
||||
_display->moveCursorTo(Common::Point(0, 23));
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *HiRes4Engine::createReadStream(DiskImage *disk, byte track, byte sector, byte offset, byte size) const {
|
||||
@ -98,9 +115,9 @@ void HiRes4Engine_Atari::adjustDataBlockPtr(byte &track, byte §or, byte &off
|
||||
sector = (sectorIndex - 1) % 18;
|
||||
}
|
||||
|
||||
const char *const *HiRes4Engine_Atari::getDiskImageNames() const {
|
||||
const char *HiRes4Engine_Atari::getDiskImageName(byte index) const {
|
||||
static const char *const disks[] = { "ULYS1A.XFD", "ULYS1B.XFD", "ULYS2C.XFD" };
|
||||
return disks;
|
||||
return disks[index];
|
||||
}
|
||||
|
||||
Engine *HiRes4Engine_create(OSystem *syst, const AdlGameDescription *gd) {
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
namespace Adl {
|
||||
|
||||
#define IDI_HR4_NUM_ROOMS 164
|
||||
#define IDI_HR4_NUM_VARS 40
|
||||
#define IDI_HR4_NUM_ITEM_DESCS 44
|
||||
|
||||
class HiRes4Engine : public AdlEngine_v3 {
|
||||
@ -43,10 +45,10 @@ protected:
|
||||
void initGameState();
|
||||
|
||||
Common::SeekableReadStream *createReadStream(DiskImage *disk, byte track, byte sector, byte offset = 0, byte size = 0) const;
|
||||
virtual const char *const *getDiskImageNames() const = 0;
|
||||
void goToSideC();
|
||||
virtual const char *getDiskImageName(byte index) const = 0;
|
||||
|
||||
// FIXME: use an array?
|
||||
DiskImage *_disk2, *_disk3;
|
||||
DiskImage *_boot;
|
||||
};
|
||||
|
||||
class HiRes4Engine_Atari : public HiRes4Engine {
|
||||
@ -55,10 +57,10 @@ public:
|
||||
|
||||
private:
|
||||
// AdlEngine_v2
|
||||
virtual void adjustDataBlockPtr(byte &track, byte §or, byte &offset, byte &size) const;
|
||||
void adjustDataBlockPtr(byte &track, byte §or, byte &offset, byte &size) const;
|
||||
|
||||
// HiRes4Engine
|
||||
virtual const char *const *getDiskImageNames() const;
|
||||
const char *getDiskImageName(byte index) const;
|
||||
};
|
||||
|
||||
} // End of namespace Adl
|
||||
|
@ -242,17 +242,7 @@ void HiRes6Engine::loadDisk(byte disk) {
|
||||
stream->skip(14); // Skip invalid room 0
|
||||
|
||||
_state.rooms.clear();
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
Room room;
|
||||
stream->readByte(); // number
|
||||
for (uint j = 0; j < 6; ++j)
|
||||
room.connections[j] = stream->readByte();
|
||||
room.data = readDataBlockPtr(*stream);
|
||||
room.picture = stream->readByte();
|
||||
room.curPicture = stream->readByte();
|
||||
room.isFirstTime = stream->readByte();
|
||||
_state.rooms.push_back(room);
|
||||
}
|
||||
loadRooms(*stream, count);
|
||||
break;
|
||||
}
|
||||
case 0x7b00:
|
||||
|
Loading…
x
Reference in New Issue
Block a user