uxn

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

commit 952d022daa340af53d234cc985de2c391a90b8f1
parent 2197e356671d50a0aba5f250b548e29b48d1298f
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 26 Jun 2021 15:52:44 -0700

Modified console/char

Diffstat:
Msrc/uxn-fast.c | 8++++----
Msrc/uxnemu.c | 9+++++----
2 files changed, 9 insertions(+), 8 deletions(-)

diff --git 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 @@ -1,5 +1,6 @@ #include <SDL.h> #include <stdio.h> +#include <unistd.h> #include <time.h> #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); }