Uxncli now uses the system_inspect

This commit is contained in:
neauoire 2022-01-13 08:34:32 -08:00
parent 44a7f5ef0e
commit f1cc022e9b
4 changed files with 11 additions and 26 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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

View File

@ -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)