From 952d022daa340af53d234cc985de2c391a90b8f1 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 26 Jun 2021 15:52:44 -0700 Subject: [PATCH] Modified console/char --- src/uxn-fast.c | 8 ++++---- src/uxnemu.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/uxn-fast.c b/src/uxn-fast.c index b35b8d4..43c4300 100644 --- a/src/uxn-fast.c +++ b/src/uxn-fast.c @@ -41,7 +41,7 @@ static const char *errors[] = {"underflow", "overflow", "division by zero"}; int haltuxn(Uxn *u, Uint8 error, char *name, int id) { - printf("Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], id, u->ram.ptr); + fprintf(stderr,"Halted: %s %s#%04x, at 0x%04x\n", name, errors[error - 1], id, u->ram.ptr); u->ram.ptr = 0; return 0; } @@ -4052,11 +4052,11 @@ loaduxn(Uxn *u, char *filepath) { FILE *f; if(!(f = fopen(filepath, "rb"))) { - printf("Halted: Missing input rom.\n"); + fprintf(stderr, "Halted: Missing input rom.\n"); return 0; } fread(u->ram.dat + PAGE_PROGRAM, sizeof(u->ram.dat) - PAGE_PROGRAM, 1, f); - printf("Uxn loaded[%s].\n", filepath); + fprintf(stderr, "Uxn loaded[%s].\n", filepath); return 1; } @@ -4068,6 +4068,6 @@ portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *d, Uint8 b0, Uint8 d->u = u; d->mem = u->ram.dat; d->talk = talkfn; - printf("Device added #%02x: %s, at 0x%04x \n", id, name, d->addr); + fprintf(stderr, "Device added #%02x: %s, at 0x%04x \n", id, name, d->addr); return d; } diff --git a/src/uxnemu.c b/src/uxnemu.c index cf0c23e..5543efe 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "uxn.h" #include "devices/ppu.h" @@ -231,10 +232,10 @@ console_talk(Device *d, Uint8 b0, Uint8 w) { if(!w) return; switch(b0) { - case 0x8: printf("%c", d->dat[0x8]); break; - case 0x9: printf("0x%02x", d->dat[0x9]); break; - case 0xb: printf("0x%04x", mempeek16(d->dat, 0xa)); break; - case 0xd: printf("%s", &d->mem[mempeek16(d->dat, 0xc)]); break; + case 0x8: write(1, &d->dat[0x8], 1); break; + case 0x9: fprintf(stdout, "0x%02x", d->dat[0x9]); break; + case 0xb: fprintf(stdout, "0x%04x", mempeek16(d->dat, 0xa)); break; + case 0xd: fprintf(stdout, "%s", &d->mem[mempeek16(d->dat, 0xc)]); break; } fflush(stdout); }