diff --git a/src/uxn.c b/src/uxn.c index 7fcd754..2037f66 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -116,7 +116,7 @@ timeout: /* clang-format on */ int -uxn_boot(Uxn *u, Uint8 *ram) +uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo) { Uint32 i; char *cptr = (char *)u; diff --git a/src/uxn.h b/src/uxn.h index dd39bb2..183f8ca 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -49,9 +49,14 @@ typedef struct Uxn { Uint8 *ram; Stack wst, rst; Device dev[16]; + Uint8 (*dei)(struct Uxn *u, Uint8 addr); + void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value); } Uxn; -int uxn_boot(Uxn *u, Uint8 *ram); +typedef Uint8 Dei(Uxn *u, Uint8 addr); +typedef void Deo(Uxn *u, Uint8 addr, Uint8 value); + +int uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo); int uxn_eval(Uxn *u, Uint16 pc); int uxn_interrupt(void); int uxn_halt(Uxn *u, Uint8 error, Uint16 addr); diff --git a/src/uxncli.c b/src/uxncli.c index 1c2ccda..0678fdd 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -24,6 +24,17 @@ error(char *msg, const char *err) return 0; } +static Uint8 +emu_dei(Uxn *u, Uint8 addr) +{ + return 0; +} + +static void +emu_deo(Uxn *u, Uint8 addr, Uint8 v) +{ +} + void system_deo_special(Device *d, Uint8 port) { @@ -83,7 +94,7 @@ uxn_interrupt(void) static int start(Uxn *u) { - if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8)))) + if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8)), emu_dei, emu_deo)) return error("Boot", "Failed"); /* system */ uxn_port(u, 0x0, system_dei, system_deo); /* console */ uxn_port(u, 0x1, nil_dei, console_deo); diff --git a/src/uxnemu.c b/src/uxnemu.c index 0aafa8a..3eb3c25 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -176,6 +176,17 @@ init(void) #pragma mark - Devices +static Uint8 +emu_dei(Uxn *u, Uint8 addr) +{ + return 0; +} + +static void +emu_deo(Uxn *u, Uint8 addr, Uint8 v) +{ +} + void system_deo_special(Device *d, Uint8 port) { @@ -253,7 +264,7 @@ static int start(Uxn *u, char *rom) { free(u->ram); - if(!uxn_boot(u, calloc(0x10000, 1))) + if(!uxn_boot(u, calloc(0x10000, 1), emu_dei, emu_deo)) return error("Boot", "Failed to start uxn."); if(!load(u, rom)) return error("Boot", "Failed to load rom.");