Browse code

Simplified Inspect()

neauoire authored on 29/08/2021 20:18:42
Showing 1 changed files
... ...
@@ -27,26 +27,16 @@ error(char *msg, const char *err)
27 27
 }
28 28
 
29 29
 static void
30
-inspect(Uxn *u)
30
+inspect(Stack *s, char *name)
31 31
 {
32 32
 	Uint8 x, y;
33
-	fprintf(stderr, "\nWorking Stack\n");
33
+	fprintf(stderr, "\n%s\n", name);
34 34
 	for(y = 0; y < 0x04; ++y) {
35 35
 		for(x = 0; x < 0x08; ++x) {
36 36
 			Uint8 p = y * 0x08 + x;
37 37
 			fprintf(stderr,
38
-				p == u->wst.ptr ? "[%02x]" : " %02x ",
39
-				u->wst.dat[p]);
40
-		}
41
-		fprintf(stderr, "\n");
42
-	}
43
-	fprintf(stderr, "\nReturn Stack\n");
44
-	for(y = 0; y < 0x04; ++y) {
45
-		for(x = 0; x < 0x08; ++x) {
46
-			Uint8 p = y * 0x08 + x;
47
-			fprintf(stderr,
48
-				p == u->rst.ptr ? "[%02x]" : " %02x ",
49
-				u->rst.dat[p]);
38
+				p == s->ptr ? "[%02x]" : " %02x ",
39
+				s->dat[p]);
50 40
 		}
51 41
 		fprintf(stderr, "\n");
52 42
 	}
... ...
@@ -66,7 +56,10 @@ system_talk(Device *d, Uint8 b0, Uint8 w)
66 56
 		switch(b0) {
67 57
 		case 0x2: d->u->wst.ptr = d->dat[0x2]; break;
68 58
 		case 0x3: d->u->rst.ptr = d->dat[0x3]; break;
69
-		case 0xe: inspect(d->u); break;
59
+		case 0xe:
60
+			inspect(&d->u->wst, "Working-stack");
61
+			inspect(&d->u->rst, "Return-stack");
62
+			break;
70 63
 		case 0xf: d->u->ram.ptr = 0x0000; break;
71 64
 		}
72 65
 	}