Standardized boot sequence

This commit is contained in:
Devine Lu Linvega 2024-07-15 11:42:00 -07:00
parent f6c66d53d1
commit 6b335197da
3 changed files with 40 additions and 28 deletions

View File

@ -46,8 +46,11 @@ The file device is _sandboxed_, meaning that it should not be able to read or wr
## Emulator Controls ## Emulator Controls
- `F2` toggle on-screen debugger - `F1` toggle zoom
- `F4` load boot.rom, or reload rom - `F2` toggle debugger
- `F3` quit
- `F4` reboot
- `F5` reboot(soft)
### Buttons ### Buttons

View File

@ -268,7 +268,7 @@ main(int argc, char **argv)
int i = 1; int i = 1;
char *rom; char *rom;
if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') { if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') {
fprintf(stdout, "Uxn11 - Varvara Emulator, 2 Jul 2024.\n"); fprintf(stdout, "Uxn11 - Varvara Emulator, 15 Jul 2024.\n");
i++; i++;
} }
rom = i == argc ? "boot.rom" : argv[i++]; rom = i == argc ? "boot.rom" : argv[i++];
@ -278,9 +278,7 @@ main(int argc, char **argv)
return !fprintf(stdout, "Could not open display.\n"); return !fprintf(stdout, "Could not open display.\n");
/* Event Loop */ /* Event Loop */
uxn.dev[0x17] = argc - i; uxn.dev[0x17] = argc - i;
if(uxn_eval(PAGE_PROGRAM)) { if(uxn_eval(PAGE_PROGRAM))
console_listen(i, argc, argv); console_listen(i, argc, argv), emu_run();
emu_run();
}
return emu_end(); return emu_end();
} }

View File

@ -43,21 +43,9 @@ emu_deo(Uint8 addr, Uint8 value)
} }
} }
int static void
main(int argc, char **argv) emu_run(void)
{ {
int i = 1;
if(i == argc)
return system_error("usage", "uxncli [-v] file.rom [args..]");
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return !printf("Uxncli - Console Varvara Emulator, 2 Jul 2024\n");
if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
return system_error("Init", "Failed to initialize uxn.");
/* Game Loop */
uxn.dev[0x17] = argc - i;
if(uxn_eval(PAGE_PROGRAM) && PEEK2(uxn.dev + 0x10)) {
console_listen(i, argc, argv);
while(!uxn.dev[0x0f]) { while(!uxn.dev[0x0f]) {
int c = fgetc(stdin); int c = fgetc(stdin);
if(c == EOF) { if(c == EOF) {
@ -67,6 +55,29 @@ main(int argc, char **argv)
console_input(c, CONSOLE_STD); console_input(c, CONSOLE_STD);
} }
} }
static int
emu_end(void)
{
free(uxn.ram); free(uxn.ram);
return uxn.dev[0x0f] & 0x7f; return uxn.dev[0x0f] & 0x7f;
} }
int
main(int argc, char **argv)
{
int i = 1;
char *rom;
if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') {
fprintf(stdout, "Uxncli - Console Varvara Emulator, 15 Jul 2024.\n");
i++;
}
rom = i == argc ? "boot.rom" : argv[i++];
if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom))
return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
/* Event Loop */
uxn.dev[0x17] = argc - i;
if(uxn_eval(PAGE_PROGRAM) && PEEK2(uxn.dev + 0x10))
console_listen(i, argc, argv), emu_run();
return emu_end();
}