From c7ce358d0d43e444b5826aad1d920553d19a4646 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 28 Feb 2024 09:03:56 -0800 Subject: [PATCH] Improved stack printing --- src/devices/system.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/devices/system.c b/src/devices/system.c index 7721616..0e5e89d 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -33,20 +33,12 @@ system_load(Uxn *u, char *filename) } static void -system_print(Stack *s, char *name) +system_print(Stack *s) { Uint8 i; - fprintf(stderr, "%s ", name); - for(i = 0; i < 9; i++) { - Uint8 pos = s->ptr - 4 + i; - if(!pos) - fprintf(stderr, "[%02x]", s->dat[pos]); - else if(i == 4) - fprintf(stderr, "<%02x>", s->dat[pos]); - else - fprintf(stderr, " %02x ", s->dat[pos]); - } - fprintf(stderr, "\n"); + for(i = s->ptr - 7; i != s->ptr + 1; i++) + fprintf(stderr, "%02x%c", s->dat[i], i == 0 ? '|' : ' '); + fprintf(stderr, "< \n"); } static void @@ -63,8 +55,8 @@ system_zero(Uxn *u, int soft) void system_inspect(Uxn *u) { - system_print(&u->wst, "wst"); - system_print(&u->rst, "rst"); + fprintf(stderr, "WST "), system_print(&u->wst); + fprintf(stderr, "RST "), system_print(&u->rst); } int