[Scummvm-cvs-logs] CVS: scummvm/scumm boxes.cpp,1.34,1.35

Max Horn fingolfin at users.sourceforge.net
Sat May 31 10:02:01 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv4096

Modified Files:
	boxes.cpp 
Log Message:
some box debugging code

Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/boxes.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- boxes.cpp	26 May 2003 02:26:13 -0000	1.34
+++ boxes.cpp	31 May 2003 16:20:20 -0000	1.35
@@ -751,6 +751,42 @@
 	return false;
 }
 
+#define BOX_DEBUG 0
+
+#if BOX_DEBUG
+static void printMatrix(byte *boxm, int num) {
+	int i;
+	for (i = 0; i < num; i++) {
+		printf("%d: ", i);
+		while (*boxm != 0xFF) {
+			printf("%d, ", *boxm);
+			boxm++;
+		}
+		boxm++;
+		printf("\n");
+	}
+}
+
+static void printMatrix2(byte *matrix, int num) {
+	int i, j;
+	printf("    ");
+	for (i = 0; i < num; i++)
+		printf("%2d ", i);
+	printf("\n");
+	for (i = 0; i < num; i++) {
+		printf("%2d: ", i);
+		for (j = 0; j < num; j++) {
+			int val = matrix[i * 64 + j];
+			if (val == 250)
+				printf(" ? ");
+			else
+				printf("%2d ", val);
+		}
+		printf("\n");
+	}
+}
+#endif
+
 void Scumm::createBoxMatrix() {
 	int num, i, j;
 	byte flags;
@@ -758,6 +794,7 @@
 	int counter, val;
 	int code;
 
+
 	// A heap (an optiimsation to avoid calling malloc/free extremly often)
 	_maxBoxVertexHeap = 1000;
 	createResource(rtMatrix, 4, _maxBoxVertexHeap);
@@ -774,6 +811,21 @@
 
 	num = getNumBoxes();
 
+#if BOX_DEBUG
+printf("Creating box matrix...\n");
+	for (i = 0; i < num; i++) {
+		BoxCoords coords;
+		flags = getBoxFlags(i);
+		getBoxCoordinates(i, &coords);
+
+		printf("%d: [%d x %d] [%d x %d] [%d x %d] [%d x %d], flags=0x%02x\n",
+								i,
+								coords.ul.x, coords.ul.y, coords.ll.x, coords.ll.y,
+								coords.ur.x, coords.ur.y, coords.lr.x, coords.lr.y,
+								flags);
+	}
+#endif
+
 	// Initialise the distance matrix: each box has distance 0 to itself,
 	// and distance 1 to its direct neighbors. Initially, it has distance
 	// 250 (= infinity) to all other boxes.
@@ -788,6 +840,11 @@
 			}
 		}
 	}
+	
+#if BOX_DEBUG
+	printf("Initial matrix:\n");
+	printMatrix2(_boxMatrixPtr3, num);
+#endif
 
 	// Iterate over all boxes
 	for (j = 0; j < num; j++) {
@@ -877,6 +934,12 @@
 	addToBoxMatrix(0xFF);
 	nukeResource(rtMatrix, 4);
 	nukeResource(rtMatrix, 3);
+	
+#if BOX_DEBUG
+	printf("End result:\n");
+	printMatrix2(_boxMatrixPtr3, num);
+	printMatrix(getBoxMatrixBaseAddr(), num);
+#endif
 }
 
 PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node) {





More information about the Scummvm-git-logs mailing list