diff --git a/src/uxn.c b/src/uxn.c index 8f4a74d..60bad6f 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -111,7 +111,6 @@ uxn_boot(Uxn *u, Uint8 *ram) u->ram = ram; u->wst = (Stack*)(ram + 0x10000); u->rst = (Stack*)(ram + 0x10100); - u->dev2 = (Uint8*)(ram + 0x10200); return 1; } diff --git a/src/uxn.h b/src/uxn.h index bb41e23..9a023a7 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -37,7 +37,7 @@ typedef struct Device { } Device; typedef struct Uxn { - Uint8 *ram, *dev2; + Uint8 *ram; Stack *wst, *rst; Uint8 (*dei)(struct Uxn *u, Uint8 address); void (*deo)(struct Uxn *u, Uint8 address, Uint8 value); diff --git a/src/uxn11.c b/src/uxn11.c index 71b7db9..bc5e91a 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -168,6 +168,19 @@ processEvent(void) } } +static Uint8 +nil_dei(Device *d, Uint8 port) +{ + return d->dat[port]; +} + +static void +nil_deo(Device *d, Uint8 port) +{ + (void)d; + (void)port; +} + static int start(Uxn *u, char *rom) { @@ -178,6 +191,24 @@ start(Uxn *u, char *rom) fprintf(stderr, "Loaded %s\n", rom); u->dei = uxn11_dei; u->deo = uxn11_deo; + + /* system */ uxn_port(u, 0x0, nil_dei, system_deo); + /* console */ uxn_port(u, 0x1, nil_dei, console_deo); + /* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo); + /* empty */ uxn_port(u, 0x3, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x4, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x5, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x6, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x7, nil_dei, nil_deo); + /* control */ devctrl = uxn_port(u, 0x8, nil_dei, nil_deo); + /* mouse */ devmouse = uxn_port(u, 0x9, nil_dei, nil_deo); + /* file0 */ uxn_port(u, 0xa, file_dei, file_deo); + /* file1 */ uxn_port(u, 0xb, file_dei, file_deo); + /* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo); + /* empty */ uxn_port(u, 0xd, nil_dei, nil_deo); + /* reserved */ uxn_port(u, 0xe, nil_dei, nil_deo); + /* reserved */ uxn_port(u, 0xf, nil_dei, nil_deo); + screen_resize(&uxn_screen, WIDTH, HEIGHT); if(!uxn_eval(u, PAGE_PROGRAM)) return error("Boot", "Failed to start rom.");