Modified console/char

This commit is contained in:
neauoire 2021-06-26 15:52:44 -07:00
parent 2197e35667
commit 952d022daa
2 changed files with 9 additions and 8 deletions

View File

@ -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;
}

View File

@ -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);
}