System device handles boot

This commit is contained in:
neauoire 2023-08-15 15:59:32 -07:00
parent a77434a671
commit 9a7a11003f
6 changed files with 10 additions and 21 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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++]))

View File

@ -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.");