From ede186b22684fa6908bfd8c3a33027753ea89d81 Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 11 Jan 2022 11:07:25 -0800 Subject: [PATCH] Minor cleanup --- src/uxncli.c | 16 ++++++++-------- src/uxnemu.c | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/uxncli.c b/src/uxncli.c index 319401f..e879e33 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "uxn.h" @@ -63,8 +62,12 @@ system_deo_special(Device *d, Uint8 port) static void console_deo(Device *d, Uint8 port) { - if(port > 0x7) - write(port - 0x7, (char *)&d->dat[port], 1); + FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr + : 0; + if(fd) { + fputc(d->dat[port], fd); + fflush(fd); + } } static Uint8 @@ -92,12 +95,9 @@ console_input(Uxn *u, char c) static void run(Uxn *u) { - Uint16 vec; Device *d = devconsole; - while((!u->dev[0].dat[0xf]) && (read(0, &devconsole->dat[0x2], 1) > 0)) { - DEVPEEK16(vec, 0); - uxn_eval(u, vec); - } + while((!u->dev[0].dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0)) + uxn_eval(u, GETVECTOR(d)); } static int diff --git a/src/uxnemu.c b/src/uxnemu.c index 00178a4..51aa735 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -434,9 +434,7 @@ run(Uxn *u) /* Audio */ else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) { Device *d = devaudio0 + (event.type - audio0_event); - Uint16 res; - DEVPEEK16(res, 0x00); - uxn_eval(u, res); + uxn_eval(u, GETVECTOR(d)); } /* Mouse */ else if(event.type == SDL_MOUSEMOTION)