commit 507a4b8
Devine Lu Linvega
·
2022-06-13 18:59:42 +0000 UTC
parent d118cc3
uxn_boot() now expects dei/deo fn pointers
4 files changed,
+6,
-8
+3,
-1
1@@ -96,7 +96,7 @@ err:
2 /* clang-format on */
3
4 int
5-uxn_boot(Uxn *u, Uint8 *ram)
6+uxn_boot(Uxn *u, Uint8 *ram, Uint8 (*dei)(struct Uxn *, Uint8), void (*deo)(struct Uxn *, Uint8, Uint8))
7 {
8 Uint32 i;
9 char *cptr = (char *)u;
10@@ -106,5 +106,7 @@ uxn_boot(Uxn *u, Uint8 *ram)
11 u->wst = (Stack *)(ram + 0x10000);
12 u->rst = (Stack *)(ram + 0x10100);
13 u->dev = (Uint8 *)(ram + 0x10200);
14+ u->dei = dei;
15+ u->deo = deo;
16 return 1;
17 }
+1,
-1
1@@ -36,6 +36,6 @@ typedef struct Uxn {
2 void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value);
3 } Uxn;
4
5-int uxn_boot(Uxn *u, Uint8 *ram);
6+int uxn_boot(Uxn *u, Uint8 *ram, Uint8 (*dei)(struct Uxn *, Uint8), void (*deo)(struct Uxn *, Uint8, Uint8));
7 int uxn_eval(Uxn *u, Uint16 pc);
8 int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
+1,
-3
1@@ -227,10 +227,8 @@ main(int argc, char **argv)
2 if(argc < 2)
3 return emu_error("Usage", "uxn11 game.rom args");
4 rom_path = argv[1];
5- if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
6+ if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)), emu_dei, emu_deo))
7 return emu_error("Boot", "Failed");
8- u.dei = emu_dei;
9- u.deo = emu_deo;
10 /* start sequence */
11 if(!emu_start(&u, rom_path))
12 return emu_error("Start", rom_path);
+1,
-3
1@@ -75,10 +75,8 @@ main(int argc, char **argv)
2 int i;
3 if(argc < 2)
4 return emu_error("Usage", "uxncli game.rom args");
5- if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
6+ if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)), emu_dei, emu_deo))
7 return emu_error("Boot", "Failed");
8- u.dei = emu_dei;
9- u.deo = emu_deo;
10 if(!load_rom(&u, argv[1]))
11 return emu_error("Load", "Failed");
12 fprintf(stderr, "Loaded %s\n", argv[1]);