uxn

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

commit 4d7ce3e893c68a64c95bb1f968beffbe2bd9e641
parent 8d4074b3727d74f98ef8fa58e3e9dc26ecb3d838
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue, 15 Aug 2023 16:24:40 -0700

Made a console_listen function

Diffstat:
Msrc/devices/console.c | 10++++++++++
Msrc/devices/console.h | 1+
Msrc/uxncli.c | 6+-----
Msrc/uxnemu.c | 6+-----
4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/devices/console.c b/src/devices/console.c @@ -25,6 +25,16 @@ console_input(Uxn *u, char c, int type) } 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++, CONSOLE_ARG); + console_input(u, '\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA); + } +} + +void console_deo(Uint8 *d, Uint8 port) { switch(port) { diff --git a/src/devices/console.h b/src/devices/console.h @@ -19,4 +19,5 @@ WITH REGARD TO THIS SOFTWARE. #define CONSOLE_END 0x4 int console_input(Uxn *u, char c, int type); +void console_listen(Uxn *u, int i, int argc, char **argv); void console_deo(Uint8 *d, Uint8 port); diff --git a/src/uxncli.c b/src/uxncli.c @@ -62,11 +62,7 @@ main(int argc, char **argv) /* Game Loop */ u.dev[0x17] = argc - i; if(uxn_eval(&u, PAGE_PROGRAM)) { - for(; i < argc; i++) { - char *p = argv[i]; - while(*p) console_input(&u, *p++, CONSOLE_ARG); - console_input(&u, '\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA); - } + console_listen(&u, i, argc, argv); while(!u.dev[0x0f]) { int c = fgetc(stdin); if(c == EOF) break; diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -549,11 +549,7 @@ main(int argc, char **argv) if(!emu_start(&u, rom_path)) return system_error("Start", "Failed"); /* read arguments */ - for(; i < argc; i++) { - char *p = argv[i]; - while(*p) console_input(&u, *p++, CONSOLE_ARG); - console_input(&u, '\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA); - } + console_listen(&u, i, argc, argv); /* start rom */ run(&u, rom_path); /* finished */