diff --git a/ref/uxn.c b/ref/uxn.c index cc5bafb..12b06dc 100644 --- a/ref/uxn.c +++ b/ref/uxn.c @@ -1,12 +1,8 @@ #include -/* clang-format off */ - #define PEEK2(d) (*(d) << 8 | (d)[1]) #define POKE2(d, v) { *(d) = (v) >> 8; (d)[1] = (v); } -/* clang-format on */ - typedef unsigned char Uint8; typedef signed char Sint8; typedef unsigned short Uint16; @@ -30,21 +26,6 @@ console_input(Uxn *u, char c, int type) return uxn_eval(u, PEEK2(d)); } -void -console_deo(Uint8 *d, Uint8 port) -{ - switch(port) { - case 0x8: - fputc(d[port], stdout); - fflush(stdout); - return; - case 0x9: - fputc(d[port], stderr); - fflush(stderr); - return; - } -} - Uint8 emu_dei(Uxn *u, Uint8 addr) { @@ -54,15 +35,13 @@ emu_dei(Uxn *u, Uint8 addr) void emu_deo(Uxn *u, Uint8 addr, Uint8 value) { - Uint8 p = addr & 0x0f, d = addr & 0xf0; u->dev[addr] = value; - switch(d) { - case 0x10: console_deo(&u->dev[d], p); break; + switch(addr) { + case 0x18: fputc(u->dev[0x18], stdout), fflush(stdout); return; + case 0x19: fputc(u->dev[0x19], stderr), fflush(stderr); return; } } -/* clang-format off */ - #define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; } #define JUMP(x) { if(m2) pc = (x); else pc += (Sint8)(x); } #define POP1(o) { o = s->dat[--*sp]; } @@ -132,8 +111,6 @@ uxn_eval(Uxn *u, Uint16 pc) } } -/* clang-format on */ - int main(int argc, char **argv) { @@ -151,7 +128,6 @@ main(int argc, char **argv) } fread(&u.ram[0x0100], 0xff00, 1, f); fclose(f); - /* eval */ u.dev[0x17] = argc - i; if(uxn_eval(&u, 0x0100)) { for(; i < argc; i++) {