| ... | ... |
@@ -60,6 +60,8 @@ 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 |
|
| 63 | 65 |
clang-format -i src/uxnasm.c |
| 64 | 66 |
clang-format -i src/uxnemu.c |
| 65 | 67 |
clang-format -i src/uxncli.c |
| ... | ... |
@@ -98,8 +100,8 @@ fi |
| 98 | 100 |
|
| 99 | 101 |
echo "Building.." |
| 100 | 102 |
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
| 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
|
|
| 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
|
|
| 103 | 105 |
|
| 104 | 106 |
if [ -d "$HOME/bin" ] |
| 105 | 107 |
then |
| ... | ... |
@@ -9,6 +9,7 @@ HFILES=\ |
| 9 | 9 |
src/devices/audio.h\ |
| 10 | 10 |
src/devices/controller.h\ |
| 11 | 11 |
src/devices/datetime.h\ |
| 12 |
+ src/devices/debug.h\ |
|
| 12 | 13 |
src/devices/file.h\ |
| 13 | 14 |
src/devices/mouse.h\ |
| 14 | 15 |
src/devices/screen.h\ |
| ... | ... |
@@ -33,19 +34,19 @@ bin: |
| 33 | 34 |
%.rom:Q: %.tal bin/uxnasm |
| 34 | 35 |
bin/uxnasm $stem.tal $target >/dev/null |
| 35 | 36 |
|
| 36 |
-bin/uxncli: file.$O datetime.$O system.$O uxncli.$O uxn.$O |
|
| 37 |
+bin/uxncli: file.$O datetime.$O debug.$O system.$O uxncli.$O uxn.$O |
|
| 37 | 38 |
$LD $LDFLAGS -o $target $prereq |
| 38 | 39 |
|
| 39 | 40 |
bin/uxnasm: uxnasm.$O |
| 40 | 41 |
$LD $LDFLAGS -o $target $prereq |
| 41 | 42 |
|
| 42 |
-bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O |
|
| 43 |
+bin/uxnemu: audio.$O controller.$O datetime.$O debug.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O |
|
| 43 | 44 |
$LD $LDFLAGS -o $target $prereq |
| 44 | 45 |
|
| 45 | 46 |
(uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c |
| 46 | 47 |
$CC $CFLAGS -Isrc -o $target src/$stem1.c |
| 47 | 48 |
|
| 48 |
-(audio|controller|datetime|file|mouse|screen|system)\.$O:R: src/devices/\1.c |
|
| 49 |
+(audio|controller|datetime|debug|file|mouse|screen|system)\.$O:R: src/devices/\1.c |
|
| 49 | 50 |
$CC $CFLAGS -Isrc -o $target src/devices/$stem1.c |
| 50 | 51 |
|
| 51 | 52 |
nuke:V: clean |
| 52 | 53 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,50 @@ |
| 1 |
+#include <stdio.h> |
|
| 2 |
+ |
|
| 3 |
+#include "../uxn.h" |
|
| 4 |
+#include "debug.h" |
|
| 5 |
+ |
|
| 6 |
+/* |
|
| 7 |
+Copyright (c) 2021 Devine Lu Linvega |
|
| 8 |
+Copyright (c) 2021 Andrew Alderwick |
|
| 9 |
+ |
|
| 10 |
+Permission to use, copy, modify, and distribute this software for any |
|
| 11 |
+purpose with or without fee is hereby granted, provided that the above |
|
| 12 |
+copyright notice and this permission notice appear in all copies. |
|
| 13 |
+ |
|
| 14 |
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
| 15 |
+WITH REGARD TO THIS SOFTWARE. |
|
| 16 |
+*/ |
|
| 17 |
+ |
|
| 18 |
+static void |
|
| 19 |
+inspect(Stack *s, char *name) |
|
| 20 |
+{
|
|
| 21 |
+ Uint8 x, y; |
|
| 22 |
+ fprintf(stderr, "\n%s\n", name); |
|
| 23 |
+ for(y = 0; y < 0x04; y++) {
|
|
| 24 |
+ for(x = 0; x < 0x08; x++) {
|
|
| 25 |
+ Uint8 p = y * 0x08 + x; |
|
| 26 |
+ fprintf(stderr, |
|
| 27 |
+ p == s->ptr ? "[%02x]" : " %02x ", |
|
| 28 |
+ s->dat[p]); |
|
| 29 |
+ } |
|
| 30 |
+ fprintf(stderr, "\n"); |
|
| 31 |
+ } |
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+/* IO */ |
|
| 35 |
+ |
|
| 36 |
+Uint8 |
|
| 37 |
+debug_dei(Device *d, Uint8 port) |
|
| 38 |
+{
|
|
| 39 |
+ DebugDevice *debug = (DebugDevice *)d; |
|
| 40 |
+ return d->dat[port]; |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+void |
|
| 44 |
+debug_deo(Device *d, Uint8 port) |
|
| 45 |
+{
|
|
| 46 |
+ (void)d; |
|
| 47 |
+ (void)port; |
|
| 48 |
+ inspect(&d->u->wst, "Working-stack"); |
|
| 49 |
+ inspect(&d->u->rst, "Return-stack"); |
|
| 50 |
+} |
| 0 | 51 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,19 @@ |
| 1 |
+/* |
|
| 2 |
+Copyright (c) 2021 Devine Lu Linvega |
|
| 3 |
+Copyright (c) 2021 Andrew Alderwick |
|
| 4 |
+ |
|
| 5 |
+Permission to use, copy, modify, and distribute this software for any |
|
| 6 |
+purpose with or without fee is hereby granted, provided that the above |
|
| 7 |
+copyright notice and this permission notice appear in all copies. |
|
| 8 |
+ |
|
| 9 |
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
| 10 |
+WITH REGARD TO THIS SOFTWARE. |
|
| 11 |
+*/ |
|
| 12 |
+ |
|
| 13 |
+typedef struct DebugDevice {
|
|
| 14 |
+ Device device; |
|
| 15 |
+ struct UxnScreen *screen; |
|
| 16 |
+} DebugDevice; |
|
| 17 |
+ |
|
| 18 |
+Uint8 debug_dei(Device *d, Uint8 port); |
|
| 19 |
+void debug_deo(Device *d, Uint8 port); |
|
| 0 | 20 |
\ No newline at end of file |
| ... | ... |
@@ -15,6 +15,7 @@ |
| 15 | 15 |
#include "devices/controller.h" |
| 16 | 16 |
#include "devices/mouse.h" |
| 17 | 17 |
#include "devices/datetime.h" |
| 18 |
+#include "devices/debug.h" |
|
| 18 | 19 |
#pragma GCC diagnostic pop |
| 19 | 20 |
#pragma clang diagnostic pop |
| 20 | 21 |
|
| ... | ... |
@@ -279,11 +280,9 @@ start(Uxn *u, char *rom) |
| 279 | 280 |
/* unused */ uxn_port(u, 0xc, nil_dei, nil_deo); |
| 280 | 281 |
/* unused */ uxn_port(u, 0xd, nil_dei, nil_deo); |
| 281 | 282 |
/* unused */ uxn_port(u, 0xe, nil_dei, nil_deo); |
| 282 |
- /* unused */ uxn_port(u, 0xf, nil_dei, nil_deo); |
|
| 283 |
- |
|
| 283 |
+ /* unused */ uxn_port(u, 0xf, debug_dei, debug_deo); |
|
| 284 | 284 |
if(!uxn_eval(u, PAGE_PROGRAM)) |
| 285 | 285 |
return error("Boot", "Failed to start rom.");
|
| 286 |
- |
|
| 287 | 286 |
return 1; |
| 288 | 287 |
} |
| 289 | 288 |
|