aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/adl/adl_v2.cpp19
-rw-r--r--engines/adl/adl_v2.h1
-rw-r--r--engines/adl/adl_v3.cpp2
-rw-r--r--engines/adl/hires0.cpp14
-rw-r--r--engines/adl/hires2.cpp14
-rw-r--r--engines/adl/hires4.cpp59
-rw-r--r--engines/adl/hires4.h12
-rw-r--r--engines/adl/hires6.cpp12
8 files changed, 69 insertions, 64 deletions
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp
index 2b9a1b061a..307bf98b46 100644
--- a/engines/adl/adl_v2.cpp
+++ b/engines/adl/adl_v2.cpp
@@ -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()");
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h
index e8894b5e87..54300853c4 100644
--- a/engines/adl/adl_v2.h
+++ b/engines/adl/adl_v2.h
@@ -54,6 +54,7 @@ protected:
virtual DataBlockPtr readDataBlockPtr(Common::ReadStream &f) const;
virtual void adjustDataBlockPtr(byte &track, byte &sector, byte &offset, byte &size) const { }
void loadItems(Common::SeekableReadStream &stream);
+ void loadRooms(Common::SeekableReadStream &stream, byte count);
void checkTextOverflow(char c);
diff --git a/engines/adl/adl_v3.cpp b/engines/adl/adl_v3.cpp
index 6551524c9e..ba9e4a063e 100644
--- a/engines/adl/adl_v3.cpp
+++ b/engines/adl/adl_v3.cpp
@@ -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);
diff --git a/engines/adl/hires0.cpp b/engines/adl/hires0.cpp
index 5bfe482c7c..e6ff0bd317 100644
--- a/engines/adl/hires0.cpp
+++ b/engines/adl/hires0.cpp
@@ -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);
}
diff --git a/engines/adl/hires2.cpp b/engines/adl/hires2.cpp
index 34de51885a..b662142f0c 100644
--- a/engines/adl/hires2.cpp
+++ b/engines/adl/hires2.cpp
@@ -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);
}
diff --git a/engines/adl/hires4.cpp b/engines/adl/hires4.cpp
index 1ce2a44c4a..312cce6a55 100644
--- a/engines/adl/hires4.cpp
+++ b/engines/adl/hires4.cpp
@@ -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 &sector, 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) {
diff --git a/engines/adl/hires4.h b/engines/adl/hires4.h
index a578080857..b522657111 100644
--- a/engines/adl/hires4.h
+++ b/engines/adl/hires4.h
@@ -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 &sector, byte &offset, byte &size) const;
+ void adjustDataBlockPtr(byte &track, byte &sector, byte &offset, byte &size) const;
// HiRes4Engine
- virtual const char *const *getDiskImageNames() const;
+ const char *getDiskImageName(byte index) const;
};
} // End of namespace Adl
diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp
index cf06591f6d..553729d38d 100644
--- a/engines/adl/hires6.cpp
+++ b/engines/adl/hires6.cpp
@@ -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: