aboutsummaryrefslogtreecommitdiff
path: root/scumm/boxes.cpp
diff options
context:
space:
mode:
authorMax Horn2003-05-31 16:20:20 +0000
committerMax Horn2003-05-31 16:20:20 +0000
commit83e1815a726375ca44603feb20950a955d250cf2 (patch)
treebcf4f19b1109710a2c2c913cbfd88e157fab36f0 /scumm/boxes.cpp
parent2fd98601f720b8fa5296f8e8e06c09388c40c3a7 (diff)
downloadscummvm-rg350-83e1815a726375ca44603feb20950a955d250cf2.tar.gz
scummvm-rg350-83e1815a726375ca44603feb20950a955d250cf2.tar.bz2
scummvm-rg350-83e1815a726375ca44603feb20950a955d250cf2.zip
some box debugging code
svn-id: r8182
Diffstat (limited to 'scumm/boxes.cpp')
-rw-r--r--scumm/boxes.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/scumm/boxes.cpp b/scumm/boxes.cpp
index 1ce65d6448..bb1b5629ce 100644
--- a/scumm/boxes.cpp
+++ b/scumm/boxes.cpp
@@ -751,6 +751,42 @@ bool Actor::findPathTowards(byte box1nr, byte box2nr, byte box3nr, int16 &foundP
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 @@ void Scumm::createBoxMatrix() {
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 @@ void Scumm::createBoxMatrix() {
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 @@ void Scumm::createBoxMatrix() {
}
}
}
+
+#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 @@ void Scumm::createBoxMatrix() {
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) {