Reload initial rom when boot.rom is not found

This commit is contained in:
Devine Lu Linvega 2022-06-13 10:43:43 -07:00
parent 245ad452a2
commit eaaed92aeb
1 changed files with 6 additions and 6 deletions

View File

@ -103,13 +103,8 @@ emu_draw(void)
static int static int
emu_start(Uxn *u, char *rom) emu_start(Uxn *u, char *rom)
{ {
free(u->ram);
if(!uxn_boot(u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
return emu_error("Boot", "Failed");
if(!load_rom(u, rom)) if(!load_rom(u, rom))
return emu_error("Load", "Failed"); return 0;
u->dei = emu_dei;
u->deo = emu_deo;
screen_resize(&uxn_screen, WIDTH, HEIGHT); screen_resize(&uxn_screen, WIDTH, HEIGHT);
if(!uxn_eval(u, PAGE_PROGRAM)) if(!uxn_eval(u, PAGE_PROGRAM))
return emu_error("Boot", "Failed to start rom."); return emu_error("Boot", "Failed to start rom.");
@ -232,6 +227,11 @@ main(int argc, char **argv)
rom_path = argv[1]; rom_path = argv[1];
/* start sequence */ /* start sequence */
u.ram = NULL; u.ram = NULL;
/* free(u->ram); */
if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8))))
return emu_error("Boot", "Failed");
u.dei = emu_dei;
u.deo = emu_deo;
if(!emu_start(&u, rom_path)) if(!emu_start(&u, rom_path))
return emu_error("Start", "Failed"); return emu_error("Start", "Failed");
if(!init(rom_path)) if(!init(rom_path))