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
- `F2` toggle on-screen debugger
- `F4` load boot.rom, or reload rom
- `F1` toggle zoom
- `F2` toggle debugger
- `F3` quit
- `F4` reboot
- `F5` reboot(soft)
### Buttons

View File

@ -268,7 +268,7 @@ main(int argc, char **argv)
int i = 1;
char *rom;
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++;
}
rom = i == argc ? "boot.rom" : argv[i++];
@ -278,9 +278,7 @@ main(int argc, char **argv)
return !fprintf(stdout, "Could not open display.\n");
/* Event Loop */
uxn.dev[0x17] = argc - i;
if(uxn_eval(PAGE_PROGRAM)) {
console_listen(i, argc, argv);
emu_run();
}
if(uxn_eval(PAGE_PROGRAM))
console_listen(i, argc, argv), emu_run();
return emu_end();
}

View File

@ -43,30 +43,41 @@ emu_deo(Uint8 addr, Uint8 value)
}
}
static void
emu_run(void)
{
while(!uxn.dev[0x0f]) {
int c = fgetc(stdin);
if(c == EOF) {
console_input(0x00, CONSOLE_END);
break;
}
console_input(c, CONSOLE_STD);
}
}
static int
emu_end(void)
{
free(uxn.ram);
return uxn.dev[0x0f] & 0x7f;
}
int
main(int argc, char **argv)
{
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]) {
int c = fgetc(stdin);
if(c == EOF) {
console_input(0x00, CONSOLE_END);
break;
}
console_input(c, CONSOLE_STD);
}
char *rom;
if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') {
fprintf(stdout, "Uxncli - Console Varvara Emulator, 15 Jul 2024.\n");
i++;
}
free(uxn.ram);
return uxn.dev[0x0f] & 0x7f;
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();
}