Try loading rom during system init
This commit is contained in:
parent
9a7a11003f
commit
c0d45d1440
|
@ -95,9 +95,11 @@ system_version(char *name, char *date)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
system_boot(Uxn *u, Uint8 *ram)
|
system_init(Uxn *u, Uint8 *ram, char *rom)
|
||||||
{
|
{
|
||||||
u->ram = ram;
|
u->ram = ram;
|
||||||
|
if(!system_load(u, rom))
|
||||||
|
return system_error("Init", "Failed to load rom.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,5 +20,5 @@ int system_version(char *emulator, char *date);
|
||||||
int system_load(Uxn *u, char *filename);
|
int system_load(Uxn *u, char *filename);
|
||||||
void system_inspect(Uxn *u);
|
void system_inspect(Uxn *u);
|
||||||
int system_error(char *msg, const char *err);
|
int system_error(char *msg, const char *err);
|
||||||
int system_boot(Uxn *u, Uint8 *ram);
|
int system_init(Uxn *u, Uint8 *ram, char *rom);
|
||||||
void system_deo(Uxn *u, Uint8 *d, Uint8 port);
|
void system_deo(Uxn *u, Uint8 *d, Uint8 port);
|
||||||
|
|
|
@ -57,12 +57,8 @@ main(int argc, char **argv)
|
||||||
/* Read flags */
|
/* Read flags */
|
||||||
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
||||||
return system_version("Uxncli - Console Varvara Emulator", "9 Aug 2023");
|
return system_version("Uxncli - Console Varvara Emulator", "9 Aug 2023");
|
||||||
/* Continue.. */
|
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
|
||||||
if(!system_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
|
return system_error("Init", "Failed to initialize uxn.");
|
||||||
return system_error("Boot", "Failed");
|
|
||||||
/* Load rom */
|
|
||||||
if(!system_load(&u, argv[i++]))
|
|
||||||
return system_error("Load", "Failed");
|
|
||||||
/* Game Loop */
|
/* Game Loop */
|
||||||
u.dev[0x17] = argc - i;
|
u.dev[0x17] = argc - i;
|
||||||
if(uxn_eval(&u, PAGE_PROGRAM)) {
|
if(uxn_eval(&u, PAGE_PROGRAM)) {
|
||||||
|
|
14
src/uxnemu.c
14
src/uxnemu.c
|
@ -257,11 +257,6 @@ emu_init(void)
|
||||||
static int
|
static int
|
||||||
emu_start(Uxn *u, char *rom, int queue)
|
emu_start(Uxn *u, char *rom, int queue)
|
||||||
{
|
{
|
||||||
free(u->ram);
|
|
||||||
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.");
|
|
||||||
u->dev[0x17] = queue;
|
u->dev[0x17] = queue;
|
||||||
exec_deadline = SDL_GetPerformanceCounter() + deadline_interval;
|
exec_deadline = SDL_GetPerformanceCounter() + deadline_interval;
|
||||||
screen_resize(WIDTH, HEIGHT);
|
screen_resize(WIDTH, HEIGHT);
|
||||||
|
@ -545,11 +540,12 @@ main(int argc, char **argv)
|
||||||
return system_version("Uxnemu - Graphical Varvara Emulator", "10 Aug 2023");
|
return system_version("Uxnemu - Graphical Varvara Emulator", "10 Aug 2023");
|
||||||
if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
|
if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
|
||||||
set_zoom(argv[i++][1] - '0', 0);
|
set_zoom(argv[i++][1] - '0', 0);
|
||||||
/* Continue.. */
|
|
||||||
if(!emu_init())
|
|
||||||
return system_error("Init", "Failed to initialize emulator.");
|
|
||||||
/* load rom */
|
|
||||||
rom_path = argv[i++];
|
rom_path = argv[i++];
|
||||||
|
if(!emu_init())
|
||||||
|
return system_error("Init", "Failed to initialize varvara.");
|
||||||
|
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom_path))
|
||||||
|
return system_error("Init", "Failed to initialize uxn.");
|
||||||
|
/* load rom */
|
||||||
if(!emu_start(&u, rom_path, argc - i))
|
if(!emu_start(&u, rom_path, argc - i))
|
||||||
return system_error("Start", "Failed");
|
return system_error("Start", "Failed");
|
||||||
/* read arguments */
|
/* read arguments */
|
||||||
|
|
Loading…
Reference in New Issue