uxn

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

commit 8c4b1b0592b41c58f6e6399688cc5ea8066193ba
parent ea0d81a9b126c3b2c7a1c74644cd5b98a1a12253
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Wed,  1 Mar 2023 12:04:05 -0800

Use switch for console_deo

Diffstat:
Msrc/uxncli.c | 19+++++++++----------
Msrc/uxnemu.c | 15++++++++++-----
2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/uxncli.c b/src/uxncli.c @@ -17,8 +17,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#define SUPPORT 0x1c03 /* devices mask */ - static int emu_error(char *msg, const char *err) { @@ -37,11 +35,15 @@ console_input(Uxn *u, char c) static void console_deo(Uint8 *d, Uint8 port) { - FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr - : 0; - if(fd) { - fputc(d[port], fd); - fflush(fd); + switch(port) { + case 0x8: + fputc(d[port], stdout); + fflush(stdout); + return; + case 0x9: + fputc(d[port], stderr); + fflush(stderr); + return; } } @@ -61,7 +63,6 @@ static void emu_deo(Uxn *u, Uint8 addr, Uint8 v) { Uint8 p = addr & 0x0f, d = addr & 0xf0; - Uint16 mask = 0x1 << (d >> 4); u->dev[addr] = v; switch(d) { case 0x00: system_deo(u, &u->dev[d], p); break; @@ -69,8 +70,6 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v) case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; } - if(p == 0x01 && !(SUPPORT & mask)) - fprintf(stderr, "Warning: Incompatible emulation, device: %02x.\n", d); } int diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -70,14 +70,19 @@ console_input(Uxn *u, char c) return uxn_eval(u, PEEK16(d)); } + static void console_deo(Uint8 *d, Uint8 port) { - FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr - : 0; - if(fd) { - fputc(d[port], fd); - fflush(fd); + switch(port) { + case 0x8: + fputc(d[port], stdout); + fflush(stdout); + return; + case 0x9: + fputc(d[port], stderr); + fflush(stderr); + return; } }