uxn

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

commit 2197e356671d50a0aba5f250b548e29b48d1298f
parent 4e8375d8dfa5a90fe03f956ce863204b41c7fb18
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 26 Jun 2021 13:22:01 -0700

Route errors to stderr

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

diff --git a/src/uxn.c b/src/uxn.c @@ -122,7 +122,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; } @@ -180,11 +180,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; } @@ -196,6 +196,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 @@ -38,7 +38,7 @@ clamp(int val, int min, int max) int error(char *msg, const char *err) { - printf("Error %s: %s\n", msg, err); + fprintf(stderr, "Error %s: %s\n", msg, err); return 0; } @@ -93,7 +93,7 @@ screencapture(void) SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch); SDL_SaveBMP(surface, "screenshot.bmp"); SDL_FreeSurface(surface); - printf("Saved screenshot.bmp\n"); + fprintf(stderr, "Saved screenshot.bmp\n"); } void @@ -269,10 +269,10 @@ file_talk(Device *d, Uint8 b0, Uint8 w) Uint16 addr = mempeek16(d->dat, b0 - 1); FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w")); if(f) { - printf("%s %04x %s %s: ", read ? "Loading" : "Saving", addr, read ? "from" : "to", name); + fprintf(stderr, "%s %04x %s %s: ", read ? "Loading" : "Saving", addr, read ? "from" : "to", name); if(fseek(f, offset, SEEK_SET) != -1) result = read ? fread(&d->mem[addr], 1, length, f) : fwrite(&d->mem[addr], 1, length, f); - printf("%04x bytes\n", result); + fprintf(stderr, "%04x bytes\n", result); fclose(f); } mempoke16(d->dat, 0x2, result);