(uxnemu) Simplified boot sequence

This commit is contained in:
Devine Lu Linvega 2023-04-17 09:48:27 -07:00
parent d1dc143912
commit 72e23f0260
1 changed files with 14 additions and 14 deletions

View File

@ -490,29 +490,29 @@ main(int argc, char **argv)
{ {
SDL_DisplayMode DM; SDL_DisplayMode DM;
Uxn u = {0}; Uxn u = {0};
int i = 1, loaded = 0; int i = 1;
if(!init()) if(!init())
return error("Init", "Failed to initialize emulator."); return error("Init", "Failed to initialize emulator.");
/* default resolution */
screen_resize(&uxn_screen, WIDTH, HEIGHT); screen_resize(&uxn_screen, WIDTH, HEIGHT);
/* set default zoom */ /* default zoom */
if(strcmp(argv[i], "-1x") == 0 || strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0) if(strcmp(argv[i], "-1x") == 0 || strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
set_zoom(argv[i++][1] - '0'); set_zoom(argv[i++][1] - '0');
else if(SDL_GetCurrentDisplayMode(0, &DM) == 0) else if(SDL_GetCurrentDisplayMode(0, &DM) == 0)
set_zoom(DM.w / 1280); set_zoom(DM.w / 1280);
for(; i < argc; i++) { /* load rom */
if(!loaded++) {
if(!start(&u, argv[i])) if(!start(&u, argv[i]))
return error("Boot", "Failed to boot."); return error("usage", "uxnemu [-s scale] file.rom");
rom_path = argv[i]; rom_path = argv[i++];
} else { /* read arguments */
for(; i < argc; i++) {
char *p = argv[i]; char *p = argv[i];
while(*p) console_input(&u, *p++, CONSOLE_ARG); while(*p) console_input(&u, *p++, CONSOLE_ARG);
console_input(&u, '\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA); console_input(&u, '\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA);
} }
} /* start rom */
if(!loaded && !start(&u, "launcher.rom"))
return error("usage", "uxnemu [-s scale] file.rom");
run(&u); run(&u);
/* finished */
#ifdef _WIN32 #ifdef _WIN32
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" #pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
TerminateThread((HANDLE)SDL_GetThreadID(stdin_thread), 0); TerminateThread((HANDLE)SDL_GetThreadID(stdin_thread), 0);