aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTravis Howell2006-03-05 03:46:41 +0000
committerTravis Howell2006-03-05 03:46:41 +0000
commit1fe0deeb548c4e87ed6fea9818f8bcaec7f8db4c (patch)
tree9d3f0813c7658b547a7f672a0952cb7661fe284f /engines
parent4fb6c18f0e2c66f788534ceef4c8993dcf9ccf20 (diff)
downloadscummvm-rg350-1fe0deeb548c4e87ed6fea9818f8bcaec7f8db4c.tar.gz
scummvm-rg350-1fe0deeb548c4e87ed6fea9818f8bcaec7f8db4c.tar.bz2
scummvm-rg350-1fe0deeb548c4e87ed6fea9818f8bcaec7f8db4c.zip
Add some basic walkbox support for C64 maniac
svn-id: r21084
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/boxes.cpp43
-rw-r--r--engines/scumm/boxes.h1
-rw-r--r--engines/scumm/room.cpp51
3 files changed, 81 insertions, 14 deletions
diff --git a/engines/scumm/boxes.cpp b/engines/scumm/boxes.cpp
index 33707d971e..1ab025c1b6 100644
--- a/engines/scumm/boxes.cpp
+++ b/engines/scumm/boxes.cpp
@@ -38,6 +38,14 @@ namespace Scumm {
struct Box { /* Internal walkbox file format */
union {
struct {
+ byte x1;
+ byte x2;
+ byte y1;
+ byte y2;
+ byte flags;
+ } GCC_PACK c64;
+
+ struct {
byte uy;
byte ly;
byte ulx;
@@ -102,6 +110,9 @@ byte ScummEngine::getMaskFromBox(int box) {
if (_game.version == 8)
return (byte) FROM_LE_32(ptr->v8.mask);
+ else if (_game.id == GID_MANIAC && _game.platform == Common::kPlatformC64)
+ // No mask?
+ return 0;
else if (_game.version <= 2)
return ptr->v2.mask;
else
@@ -393,7 +404,9 @@ Box *ScummEngine::getBoxBaseAddr(int box) {
box--;
checkRange(ptr[0] - 1, 0, box, "Illegal box %d");
- if (_game.version <= 2)
+ if (_game.id == GID_MANIAC && _game.platform == Common::kPlatformC64)
+ return (Box *)(ptr + box * SIZEOF_BOX_C64 + 1);
+ else if (_game.version <= 2)
return (Box *)(ptr + box * SIZEOF_BOX_V2 + 1);
else if (_game.version == 3)
return (Box *)(ptr + box * SIZEOF_BOX_V3 + 1);
@@ -501,6 +514,16 @@ void ScummEngine::getBoxCoordinates(int boxnum, BoxCoords *box) {
SWAP(box->ul, box->ur);
SWAP(box->ll, box->lr);
}
+ } else if (_game.id == GID_MANIAC && _game.platform == Common::kPlatformC64) {
+ box->ul.x = bp->c64.x1 * 8;
+ box->ul.y = bp->c64.y1 * 2;
+ box->ur.x = bp->c64.x2 * 8;
+ box->ur.y = bp->c64.y1 * 2;
+
+ box->ll.x = bp->c64.x1 * 8;
+ box->ll.y = bp->c64.y2 * 2;
+ box->lr.x = bp->c64.x2 * 8;
+ box->lr.y = bp->c64.y2 * 2;
} else if (_game.version <= 2) {
box->ul.x = bp->v2.ulx * 8;
box->ul.y = bp->v2.uy * 2;
@@ -720,7 +743,23 @@ int ScummEngine::getPathToDestBox(byte from, byte to) {
boxm = getBoxMatrixBaseAddr();
- if (_game.version <= 2) {
+ if (_game.id == GID_MANIAC && _game.platform == Common::kPlatformC64) {
+ // Skip up to the matrix data for box 'from'
+ for (i = 0; i < from; i++) {
+ while (*boxm != 0xFF)
+ boxm++;
+ boxm++;
+ }
+
+ // Now search for the entry for box 'to'
+ while (boxm[0] != 0xFF) {
+ if (boxm[0] == to)
+ dest = (int8)boxm[0];
+ boxm++;
+ }
+
+ return dest;
+ } else if (_game.version <= 2) {
// The v2 box matrix is a real matrix with numOfBoxes rows and columns.
// The first numOfBoxes bytes contain indices to the start of the corresponding
// row (although that seems unnecessary to me - the value is easily computable.
diff --git a/engines/scumm/boxes.h b/engines/scumm/boxes.h
index f5fb7160fd..cb7dbc2bf8 100644
--- a/engines/scumm/boxes.h
+++ b/engines/scumm/boxes.h
@@ -28,6 +28,7 @@
namespace Scumm {
+#define SIZEOF_BOX_C64 5
#define SIZEOF_BOX_V2 8
#define SIZEOF_BOX_V3 18
#define SIZEOF_BOX 20
diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp
index 3d678696c3..4a3b536bcc 100644
--- a/engines/scumm/room.cpp
+++ b/engines/scumm/room.cpp
@@ -715,26 +715,53 @@ void ScummEngine_v3old::initRoomSubBlocks() {
res.nukeResource(rtMatrix, 1);
res.nukeResource(rtMatrix, 2);
- // TODO: Convert older walkbox format
- if (_game.id == GID_MANIAC && _game.platform == Common::kPlatformC64)
- return;
-
if (_game.version <= 2)
ptr = roomptr + *(roomptr + 0x15);
else
ptr = roomptr + READ_LE_UINT16(roomptr + 0x15);
if (ptr) {
- byte numOfBoxes = *ptr;
+ byte numOfBoxes = 0;
int size;
- if (_game.version <= 2)
- size = numOfBoxes * SIZEOF_BOX_V2 + 1;
- else
- size = numOfBoxes * SIZEOF_BOX_V3 + 1;
- res.createResource(rtMatrix, 2, size);
- memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
+ if (_game.id == GID_MANIAC && _game.platform == Common::kPlatformC64) {
+ // Count number of boxes
+ while (*ptr != 0xFF) {
+ numOfBoxes++;
+ ptr += 5;
+ }
+
+ ptr = roomptr + *(roomptr + 0x15);
+ size = numOfBoxes * SIZEOF_BOX_C64 + 1;
+
+ res.createResource(rtMatrix, 2, size + 1);
+ getResourceAddress(rtMatrix, 2)[0] = numOfBoxes;
+ memcpy(getResourceAddress(rtMatrix, 2) + 1, ptr, size);
+ } else {
+ numOfBoxes = *ptr;
+ if (_game.version <= 2)
+ size = numOfBoxes * SIZEOF_BOX_V2 + 1;
+ else
+ size = numOfBoxes * SIZEOF_BOX_V3 + 1;
+
+ res.createResource(rtMatrix, 2, size);
+ memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
+ }
+
ptr += size;
- if (_game.version <= 2) {
+ if (_game.id == GID_MANIAC && _game.platform == Common::kPlatformC64) {
+ const byte *tmp = ptr;
+ size = 0;
+
+ // Compute matrix size
+ for (i = 0; i < numOfBoxes; i++) {
+ while (*tmp != 0xFF) {
+ size++;
+ tmp++;
+ }
+ size++;
+ tmp++;
+ }
+ } else if (_game.version <= 2) {
size = numOfBoxes * (numOfBoxes + 1);
} else {
// FIXME. This is an evil HACK!!!