Browse code

Fixed issue with uxncli debugger

neauoire authored on 16/08/2021 14:22:53
Showing 2 changed files
... ...
@@ -59,7 +59,12 @@ To start the rom, point the emulator to the newly created rom:
59 59
 bin/uxnemu bin/life.rom
60 60
 ```
61 61
 
62
-You can also use the emulator without graphics by using `uxncli`. You can find additional roms [here](https://sr.ht/~rabbits/uxn/sources).
62
+You can also use the emulator without graphics by using `uxncli`. You can find additional roms [here](https://sr.ht/~rabbits/uxn/sources). If you only wish to build `uxncli`
63
+
64
+```
65
+cc src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli
66
+
67
+```
63 68
 
64 69
 ### I/O
65 70
 
... ...
@@ -27,7 +27,7 @@ error(char *msg, const char *err)
27 27
 }
28 28
 
29 29
 static void
30
-inspect(Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
30
+inspect(Stack *wst)
31 31
 {
32 32
 	Uint8 x, y;
33 33
 	fprintf(stderr, "\n\n");
... ...
@@ -35,8 +35,8 @@ inspect(Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
35 35
 		for(x = 0; x < 0x08; ++x) {
36 36
 			Uint8 p = y * 0x08 + x;
37 37
 			fprintf(stderr,
38
-				p == wptr ? "[%02x]" : " %02x ",
39
-				stack[p]);
38
+				p == wst->ptr ? "[%02x]" : " %02x ",
39
+				wst->dat[p]);
40 40
 		}
41 41
 		fprintf(stderr, "\n");
42 42
 	}
... ...
@@ -56,6 +56,7 @@ system_talk(Device *d, Uint8 b0, Uint8 w)
56 56
 		switch(b0) {
57 57
 		case 0x2: d->u->wst.ptr = d->dat[0x2]; break;
58 58
 		case 0x3: d->u->rst.ptr = d->dat[0x3]; break;
59
+		case 0xe: inspect(&d->u->wst); break;
59 60
 		case 0xf: d->u->ram.ptr = 0x0000; break;
60 61
 		}
61 62
 	}
... ...
@@ -132,11 +133,8 @@ static void
132 133
 run(Uxn *u)
133 134
 {
134 135
 	uxn_eval(u, PAGE_PROGRAM);
135
-	while(read(0, &devconsole->dat[0x2], 1) > 0) {
136
-		if(devsystem->dat[0xe])
137
-			inspect(u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat);
136
+	while(read(0, &devconsole->dat[0x2], 1) > 0) 
138 137
 		uxn_eval(u, mempeek16(devconsole->dat, 0));
139
-	}
140 138
 }
141 139
 
142 140
 static int