Browse code

Print stack with DEO on 0x0f

neauoire authored on 13/01/2022 16:25:59
Showing 6 changed files
... ...
@@ -60,8 +60,6 @@ then
60 60
 	clang-format -i src/devices/controller.c
61 61
 	clang-format -i src/devices/datetime.h
62 62
 	clang-format -i src/devices/datetime.c
63
-	clang-format -i src/devices/debug.h
64
-	clang-format -i src/devices/debug.c
65 63
 	clang-format -i src/uxnasm.c
66 64
 	clang-format -i src/uxnemu.c
67 65
 	clang-format -i src/uxncli.c
... ...
@@ -100,8 +98,8 @@ fi
100 98
 
101 99
 echo "Building.."
102 100
 ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
103
-${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
104
-${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/uxncli.c -o bin/uxncli
101
+${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
102
+${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli
105 103
 
106 104
 if [ -d "$HOME/bin" ]
107 105
 then
... ...
@@ -9,7 +9,6 @@ HFILES=\
9 9
 	src/devices/audio.h\
10 10
 	src/devices/controller.h\
11 11
 	src/devices/datetime.h\
12
-	src/devices/debug.h\
13 12
 	src/devices/file.h\
14 13
 	src/devices/mouse.h\
15 14
 	src/devices/screen.h\
... ...
@@ -34,19 +33,19 @@ bin:
34 33
 %.rom:Q: %.tal bin/uxnasm
35 34
 	bin/uxnasm $stem.tal $target >/dev/null
36 35
 
37
-bin/uxncli: file.$O datetime.$O debug.$O system.$O uxncli.$O uxn.$O
36
+bin/uxncli: file.$O datetime.$O system.$O uxncli.$O uxn.$O
38 37
 	$LD $LDFLAGS -o $target $prereq
39 38
 
40 39
 bin/uxnasm: uxnasm.$O
41 40
 	$LD $LDFLAGS -o $target $prereq
42 41
 
43
-bin/uxnemu: audio.$O controller.$O datetime.$O debug.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O
42
+bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O
44 43
 	$LD $LDFLAGS -o $target $prereq
45 44
 
46 45
 (uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c
47 46
 	$CC $CFLAGS -Isrc -o $target src/$stem1.c
48 47
 
49
-(audio|controller|datetime|debug|file|mouse|screen|system)\.$O:R: src/devices/\1.c
48
+(audio|controller|datetime|file|mouse|screen|system)\.$O:R: src/devices/\1.c
50 49
 	$CC $CFLAGS -Isrc -o $target src/devices/$stem1.c
51 50
 
52 51
 nuke:V: clean
... ...
@@ -22,6 +22,22 @@ static const char *errors[] = {
22 22
 	"Working-stack division by zero",
23 23
 	"Return-stack division by zero"};
24 24
 
25
+static void
26
+inspect(Stack *s, char *name)
27
+{
28
+	Uint8 x, y;
29
+	fprintf(stderr, "\n%s\n", name);
30
+	for(y = 0; y < 0x04; y++) {
31
+		for(x = 0; x < 0x08; x++) {
32
+			Uint8 p = y * 0x08 + x;
33
+			fprintf(stderr,
34
+				p == s->ptr ? "[%02x]" : " %02x ",
35
+				s->dat[p]);
36
+		}
37
+		fprintf(stderr, "\n");
38
+	}
39
+}
40
+
25 41
 int
26 42
 uxn_halt(Uxn *u, Uint8 error, Uint16 addr)
27 43
 {
... ...
@@ -59,6 +75,10 @@ system_deo(Device *d, Uint8 port)
59 75
 	switch(port) {
60 76
 	case 0x2: d->u->wst.ptr = d->dat[port]; break;
61 77
 	case 0x3: d->u->rst.ptr = d->dat[port]; break;
78
+	case 0xe:
79
+		inspect(&d->u->wst, "Working-stack");
80
+		inspect(&d->u->rst, "Return-stack");
81
+		break;
62 82
 	default: system_deo_special(d, port);
63 83
 	}
64 84
 }
... ...
@@ -9,6 +9,11 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 9
 WITH REGARD TO THIS SOFTWARE.
10 10
 */
11 11
 
12
+typedef struct SystemDevice {
13
+	Device device;
14
+	struct UxnScreen *screen;
15
+} SystemDevice;
16
+
12 17
 Uint8 system_dei(Device *d, Uint8 port);
13 18
 void system_deo(Device *d, Uint8 port);
14 19
 void system_deo_special(Device *d, Uint8 port);
... ...
@@ -5,7 +5,6 @@
5 5
 #include "devices/system.h"
6 6
 #include "devices/file.h"
7 7
 #include "devices/datetime.h"
8
-#include "devices/debug.h"
9 8
 
10 9
 /*
11 10
 Copyright (c) 2021 Devine Lu Linvega
... ...
@@ -15,7 +15,6 @@
15 15
 #include "devices/controller.h"
16 16
 #include "devices/mouse.h"
17 17
 #include "devices/datetime.h"
18
-#include "devices/debug.h"
19 18
 #pragma GCC diagnostic pop
20 19
 #pragma clang diagnostic pop
21 20
 
... ...
@@ -280,7 +279,7 @@ start(Uxn *u, char *rom)
280 279
 	/* unused   */ uxn_port(u, 0xc, nil_dei, nil_deo);
281 280
 	/* unused   */ uxn_port(u, 0xd, nil_dei, nil_deo);
282 281
 	/* unused   */ uxn_port(u, 0xe, nil_dei, nil_deo);
283
-	/* unused   */ uxn_port(u, 0xf, debug_dei, debug_deo);
282
+	/* unused   */ uxn_port(u, 0xf, nil_dei, nil_deo);
284 283
 	if(!uxn_eval(u, PAGE_PROGRAM))
285 284
 		return error("Boot", "Failed to start rom.");
286 285
 	return 1;