Standardized main() in uxncli and uxnemu

This commit is contained in:
neauoire 2023-08-15 18:47:34 -07:00
parent b66d3f2612
commit ddd3a46156
2 changed files with 13 additions and 7 deletions

View File

@ -41,7 +41,17 @@ emu_deo(Uxn *u, Uint8 addr)
} }
} }
int static void
emu_run(Uxn *u)
{
while(!u->dev[0x0f]) {
int c = fgetc(stdin);
if(c == EOF) break;
console_input(u, (Uint8)c, CONSOLE_STD);
}
}
static int
emu_end(Uxn *u) emu_end(Uxn *u)
{ {
free(u->ram); free(u->ram);
@ -70,11 +80,7 @@ main(int argc, char **argv)
u.dev[0x17] = argc - i; u.dev[0x17] = argc - i;
if(uxn_eval(&u, PAGE_PROGRAM)) { if(uxn_eval(&u, PAGE_PROGRAM)) {
console_listen(&u, i, argc, argv); console_listen(&u, i, argc, argv);
while(!u.dev[0x0f]) { emu_run(&u);
int c = fgetc(stdin);
if(c == EOF) break;
console_input(&u, (Uint8)c, CONSOLE_STD);
}
} }
return emu_end(&u); return emu_end(&u);
} }

View File

@ -517,7 +517,7 @@ emu_run(Uxn *u, char *rom)
} }
} }
int static int
emu_end(Uxn *u) emu_end(Uxn *u)
{ {
#ifdef _WIN32 #ifdef _WIN32