From 526696d44b1a2c2dd447d1904427a3f72850f43e Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 10 Jan 2024 12:59:29 -0800 Subject: [PATCH] (ref) Moved console_listen into main loop --- ref/uxn.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/ref/uxn.c b/ref/uxn.c index 9a3071f..cc5bafb 100644 --- a/ref/uxn.c +++ b/ref/uxn.c @@ -1,5 +1,4 @@ #include -#include /* clang-format off */ @@ -27,21 +26,10 @@ int console_input(Uxn *u, char c, int type) { Uint8 *d = &u->dev[0x10]; - d[0x2] = c; - d[0x7] = type; + d[0x2] = c, d[0x7] = type; return uxn_eval(u, PEEK2(d)); } -void -console_listen(Uxn *u, int i, int argc, char **argv) -{ - for(; i < argc; i++) { - char *p = argv[i]; - while(*p) console_input(u, *p++, 0x2); - console_input(u, '\n', i == argc - 1 ? 0x4 : 0x3); - } -} - void console_deo(Uint8 *d, Uint8 port) { @@ -149,9 +137,9 @@ uxn_eval(Uxn *u, Uint16 pc) int main(int argc, char **argv) { + FILE *f; int i = 1; Uxn u = {0}; - FILE *f; if(i == argc) { fprintf(stdout, "usage: %s file.rom [args..]\n", argv[0]); return 0; @@ -166,7 +154,11 @@ main(int argc, char **argv) /* eval */ u.dev[0x17] = argc - i; if(uxn_eval(&u, 0x0100)) { - console_listen(&u, i, argc, argv); + for(; i < argc; i++) { + char *p = argv[i]; + while(*p) console_input(&u, *p++, 0x2); + console_input(&u, '\n', i == argc - 1 ? 0x4 : 0x3); + } while(!u.dev[0x0f]) { char c = fgetc(stdin); if(c == EOF) {