[Scummvm-cvs-logs] SF.net SVN: scummvm: [21084] scummvm/trunk/engines/scumm

kirben at users.sourceforge.net kirben at users.sourceforge.net
Sun Mar 5 14:20:54 CET 2006


Revision: 21084
Author:   kirben
Date:     2006-03-04 19:46:41 -0800 (Sat, 04 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=21084&view=rev

Log Message:
-----------
Add some basic walkbox support for C64 maniac

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/boxes.cpp
    scummvm/trunk/engines/scumm/boxes.h
    scummvm/trunk/engines/scumm/room.cpp
Modified: scummvm/trunk/engines/scumm/boxes.cpp
===================================================================
--- scummvm/trunk/engines/scumm/boxes.cpp	2006-03-04 21:25:11 UTC (rev 21083)
+++ scummvm/trunk/engines/scumm/boxes.cpp	2006-03-05 03:46:41 UTC (rev 21084)
@@ -38,6 +38,14 @@
 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 @@
 
 	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--;
 
 	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 @@
 			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 @@
 
 	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.

Modified: scummvm/trunk/engines/scumm/boxes.h
===================================================================
--- scummvm/trunk/engines/scumm/boxes.h	2006-03-04 21:25:11 UTC (rev 21083)
+++ scummvm/trunk/engines/scumm/boxes.h	2006-03-05 03:46:41 UTC (rev 21084)
@@ -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

Modified: scummvm/trunk/engines/scumm/room.cpp
===================================================================
--- scummvm/trunk/engines/scumm/room.cpp	2006-03-04 21:25:11 UTC (rev 21083)
+++ scummvm/trunk/engines/scumm/room.cpp	2006-03-05 03:46:41 UTC (rev 21084)
@@ -715,26 +715,53 @@
 	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!!!







More information about the Scummvm-git-logs mailing list