uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit f1cc022e9b90c66afc93b1e75ce7a9aa27ae4076
parent 44a7f5ef0eed389b2d169e5d86e71ffdbd513a36
Author: neauoire <aliceffekt@gmail.com>
Date:   Thu, 13 Jan 2022 08:34:32 -0800

Uxncli now uses the system_inspect

Diffstat:
Msrc/devices/system.c | 13++++++++-----
Msrc/devices/system.h | 1+
Msrc/uxncli.c | 21+--------------------
Msrc/uxnemu.c | 2+-
4 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/src/devices/system.c b/src/devices/system.c @@ -23,7 +23,7 @@ static const char *errors[] = { "Return-stack division by zero"}; static void -inspect(Stack *s, char *name) +print_stack(Stack *s, char *name) { Uint8 x, y; fprintf(stderr, "\n%s\n", name); @@ -57,6 +57,12 @@ uxn_halt(Uxn *u, Uint8 error, Uint16 addr) return 0; } +void +system_inspect(Uxn *u){ + print_stack(&u->wst, "Working-stack"); + print_stack(&u->rst, "Return-stack"); +} + /* IO */ Uint8 @@ -75,10 +81,7 @@ system_deo(Device *d, Uint8 port) switch(port) { case 0x2: d->u->wst.ptr = d->dat[port]; break; case 0x3: d->u->rst.ptr = d->dat[port]; break; - case 0xe: - inspect(&d->u->wst, "Working-stack"); - inspect(&d->u->rst, "Return-stack"); - break; + case 0xe: system_inspect(d->u); break; default: system_deo_special(d, port); } } diff --git a/src/devices/system.h b/src/devices/system.h @@ -14,6 +14,7 @@ typedef struct SystemDevice { struct UxnScreen *screen; } SystemDevice; +void system_inspect(Uxn *u); Uint8 system_dei(Device *d, Uint8 port); void system_deo(Device *d, Uint8 port); void system_deo_special(Device *d, Uint8 port); diff --git a/src/uxncli.c b/src/uxncli.c @@ -31,29 +31,10 @@ error(char *msg, const char *err) return 0; } -static void -inspect(Stack *s, char *name) -{ - Uint8 x, y; - fprintf(stderr, "\n%s\n", name); - for(y = 0; y < 0x04; y++) { - for(x = 0; x < 0x08; x++) { - Uint8 p = y * 0x08 + x; - fprintf(stderr, - p == s->ptr ? "[%02x]" : " %02x ", - s->dat[p]); - } - fprintf(stderr, "\n"); - } -} - void system_deo_special(Device *d, Uint8 port) { - if(port == 0xe) { - inspect(&d->u->wst, "Working-stack"); - inspect(&d->u->rst, "Return-stack"); - } + } static void diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -372,7 +372,7 @@ do_shortcut(Uxn *u, SDL_Event *event) if(event->key.keysym.sym == SDLK_F1) set_zoom(zoom > 2 ? 1 : zoom + 1); else if(event->key.keysym.sym == SDLK_F2) - toggle_debugger(); + system_inspect(u); else if(event->key.keysym.sym == SDLK_F3) capture_screen(); else if(event->key.keysym.sym == SDLK_F4)