diff --git a/src/uxn.c b/src/uxn.c index 6aaa73a..870a361 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -96,7 +96,7 @@ err: /* clang-format on */ int -uxn_boot(Uxn *u, Uint8 *ram) +uxn_boot(Uxn *u, Uint8 *ram, Uint8 (*dei)(struct Uxn *, Uint8), void (*deo)(struct Uxn *, Uint8, Uint8)) { Uint32 i; char *cptr = (char *)u; @@ -106,5 +106,7 @@ uxn_boot(Uxn *u, Uint8 *ram) u->wst = (Stack *)(ram + 0x10000); u->rst = (Stack *)(ram + 0x10100); u->dev = (Uint8 *)(ram + 0x10200); + u->dei = dei; + u->deo = deo; return 1; } diff --git a/src/uxn.h b/src/uxn.h index 58339af..83aec2b 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -36,6 +36,6 @@ typedef struct Uxn { void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value); } Uxn; -int uxn_boot(Uxn *u, Uint8 *ram); +int uxn_boot(Uxn *u, Uint8 *ram, Uint8 (*dei)(struct Uxn *, Uint8), void (*deo)(struct Uxn *, Uint8, Uint8)); int uxn_eval(Uxn *u, Uint16 pc); int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr); diff --git a/src/uxn11.c b/src/uxn11.c index 5475149..7c30b0b 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -227,10 +227,8 @@ main(int argc, char **argv) if(argc < 2) return emu_error("Usage", "uxn11 game.rom args"); rom_path = argv[1]; - if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)))) + if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)), emu_dei, emu_deo)) return emu_error("Boot", "Failed"); - u.dei = emu_dei; - u.deo = emu_deo; /* start sequence */ if(!emu_start(&u, rom_path)) return emu_error("Start", rom_path); diff --git a/src/uxncli.c b/src/uxncli.c index bb98e6e..66f0683 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -75,10 +75,8 @@ main(int argc, char **argv) int i; if(argc < 2) return emu_error("Usage", "uxncli game.rom args"); - if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)))) + if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)), emu_dei, emu_deo)) return emu_error("Boot", "Failed"); - u.dei = emu_dei; - u.deo = emu_deo; if(!load_rom(&u, argv[1])) return emu_error("Load", "Failed"); fprintf(stderr, "Loaded %s\n", argv[1]);