commit 9a7a11003f4a908fe1294e68e124019d211216a8
parent a77434a67108cddf05d1c76f415c7f180d3707b4
Author: neauoire <aliceffekt@gmail.com>
Date: Tue, 15 Aug 2023 15:59:32 -0700
System device handles boot
Diffstat:
6 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/src/devices/system.c b/src/devices/system.c
@@ -94,6 +94,13 @@ system_version(char *name, char *date)
return 0;
}
+int
+system_boot(Uxn *u, Uint8 *ram)
+{
+ u->ram = ram;
+ return 1;
+}
+
/* IO */
void
@@ -103,13 +110,6 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
case 0x3:
system_cmd(u->ram, PEEK2(d + 2));
break;
- case 0x5:
- if(PEEK2(d + 4)) {
- Uxn friend;
- uxn_boot(&friend, u->ram);
- uxn_eval(&friend, PEEK2(d + 4));
- }
- break;
case 0xe:
system_inspect(u);
break;
diff --git a/src/devices/system.h b/src/devices/system.h
@@ -20,4 +20,5 @@ int system_version(char *emulator, char *date);
int system_load(Uxn *u, char *filename);
void system_inspect(Uxn *u);
int system_error(char *msg, const char *err);
+int system_boot(Uxn *u, Uint8 *ram);
void system_deo(Uxn *u, Uint8 *d, Uint8 port);
diff --git a/src/uxn.c b/src/uxn.c
@@ -117,14 +117,3 @@ uxn_eval(Uxn *u, Uint16 pc)
}
}
}
-
-int
-uxn_boot(Uxn *u, Uint8 *ram)
-{
- Uint32 i;
- char *cptr = (char *)u;
- for(i = 0; i < sizeof(*u); i++)
- cptr[i] = 0;
- u->ram = ram;
- return 1;
-}
diff --git a/src/uxn.h b/src/uxn.h
@@ -46,5 +46,4 @@ extern Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
/* built-ins */
-int uxn_boot(Uxn *u, Uint8 *ram);
int uxn_eval(Uxn *u, Uint16 pc);
diff --git a/src/uxncli.c b/src/uxncli.c
@@ -58,7 +58,7 @@ main(int argc, char **argv)
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version("Uxncli - Console Varvara Emulator", "9 Aug 2023");
/* Continue.. */
- if(!uxn_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
+ if(!system_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
return system_error("Boot", "Failed");
/* Load rom */
if(!system_load(&u, argv[i++]))
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -258,7 +258,7 @@ static int
emu_start(Uxn *u, char *rom, int queue)
{
free(u->ram);
- if(!uxn_boot(u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
+ if(!system_boot(u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
return system_error("Boot", "Failed to start uxn.");
if(!system_load(u, rom))
return system_error("Boot", "Failed to load rom.");