From 44c501ba91432475136db2f8fb59208ca60c0859 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 1 Jul 2024 07:53:37 -0800 Subject: [PATCH] Removed memory passing in console_deo --- src/devices/console.c | 19 +++++++------------ src/devices/console.h | 2 +- src/uxn11.c | 2 +- src/uxncli.c | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/devices/console.c b/src/devices/console.c index 59add90..95e8771 100644 --- a/src/devices/console.c +++ b/src/devices/console.c @@ -214,18 +214,13 @@ console_dei(Uint8 addr) } void -console_deo(Uint8 port) +console_deo(Uint8 addr) { - FILE *fd = NULL; - Uint8 *d = &uxn.dev[0x10]; - switch(port) { - case 0x5: /* Console/dead */ start_fork(d); break; - case 0x6: /* Console/exit*/ kill_child(d, 0); break; - case 0x8: fd = stdout; break; - case 0x9: fd = stderr; break; - } - if(fd) { - fputc(d[port], fd); - fflush(fd); + FILE *fd; + switch(addr) { + case 0x15: /* Console/dead */ start_fork(&uxn.dev[0x10]); break; + case 0x16: /* Console/exit*/ kill_child(&uxn.dev[0x10], 0); break; + case 0x18: fd = stdout, fputc(uxn.dev[0x18], fd), fflush(fd); break; + case 0x19: fd = stderr, fputc(uxn.dev[0x19], fd), fflush(fd); break; } } diff --git a/src/devices/console.h b/src/devices/console.h index 890eded..be8abc2 100644 --- a/src/devices/console.h +++ b/src/devices/console.h @@ -17,4 +17,4 @@ WITH REGARD TO THIS SOFTWARE. int console_input(Uint8 c, int type); void console_listen(int i, int argc, char **argv); Uint8 console_dei(Uint8 addr); -void console_deo(Uint8 port); +void console_deo(Uint8 addr); diff --git a/src/uxn11.c b/src/uxn11.c index eeca546..c3fa990 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -67,7 +67,7 @@ emu_deo(Uint8 addr, Uint8 value) if(p > 0x7 && p < 0xe) screen_palette(); break; - case 0x10: console_deo(p); break; + case 0x10: console_deo(addr); break; case 0x20: screen_deo(p); break; case 0xa0: file_deo(addr); break; case 0xb0: file_deo(addr); break; diff --git a/src/uxncli.c b/src/uxncli.c index 90fb713..e685c96 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -38,7 +38,7 @@ emu_deo(Uint8 addr, Uint8 value) uxn.dev[addr] = value; switch(addr & 0xf0) { case 0x00: system_deo(p); break; - case 0x10: console_deo(p); break; + case 0x10: console_deo(addr); break; case 0xa0: file_deo(addr); break; case 0xb0: file_deo(addr); break; }