Route errors to stderr
This commit is contained in:
parent
4e8375d8df
commit
2197e35667
|
@ -122,7 +122,7 @@ static const char *errors[] = {"underflow", "overflow", "division by zero"};
|
||||||
int
|
int
|
||||||
haltuxn(Uxn *u, Uint8 error, char *name, int id)
|
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;
|
u->ram.ptr = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -180,11 +180,11 @@ loaduxn(Uxn *u, char *filepath)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
if(!(f = fopen(filepath, "rb"))) {
|
if(!(f = fopen(filepath, "rb"))) {
|
||||||
printf("Halted: Missing input rom.\n");
|
fprintf(stderr, "Halted: Missing input rom.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fread(u->ram.dat + PAGE_PROGRAM, sizeof(u->ram.dat) - PAGE_PROGRAM, 1, f);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +196,6 @@ portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *d, Uint8 b0, Uint8
|
||||||
d->u = u;
|
d->u = u;
|
||||||
d->mem = u->ram.dat;
|
d->mem = u->ram.dat;
|
||||||
d->talk = talkfn;
|
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;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ clamp(int val, int min, int max)
|
||||||
int
|
int
|
||||||
error(char *msg, const char *err)
|
error(char *msg, const char *err)
|
||||||
{
|
{
|
||||||
printf("Error %s: %s\n", msg, err);
|
fprintf(stderr, "Error %s: %s\n", msg, err);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ screencapture(void)
|
||||||
SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
|
SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
|
||||||
SDL_SaveBMP(surface, "screenshot.bmp");
|
SDL_SaveBMP(surface, "screenshot.bmp");
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
printf("Saved screenshot.bmp\n");
|
fprintf(stderr, "Saved screenshot.bmp\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -269,10 +269,10 @@ file_talk(Device *d, Uint8 b0, Uint8 w)
|
||||||
Uint16 addr = mempeek16(d->dat, b0 - 1);
|
Uint16 addr = mempeek16(d->dat, b0 - 1);
|
||||||
FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w"));
|
FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w"));
|
||||||
if(f) {
|
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)
|
if(fseek(f, offset, SEEK_SET) != -1)
|
||||||
result = read ? fread(&d->mem[addr], 1, length, f) : fwrite(&d->mem[addr], 1, length, f);
|
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);
|
fclose(f);
|
||||||
}
|
}
|
||||||
mempoke16(d->dat, 0x2, result);
|
mempoke16(d->dat, 0x2, result);
|
||||||
|
|
Loading…
Reference in New Issue