Merge pull request #5 from neuschaefer/headless

Headless Mode
This commit is contained in:
Ry 2023-01-26 17:08:36 -08:00 committed by GitHub
commit c492194360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 20 deletions

View File

@ -58,6 +58,7 @@ typedef struct {
bool halted; bool halted;
bool debug; bool debug;
bool headless;
bool mmu_enabled; bool mmu_enabled;

View File

@ -40,13 +40,6 @@ void main_loop(void);
void load_rom(const char *filename); void load_rom(const char *filename);
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "unable to initialize SDL: %s", SDL_GetError());
return 1;
}
SDL_ShowCursor(SDL_DISABLE);
fox32_init(&vm); fox32_init(&vm);
vm.io_read = bus_io_read; vm.io_read = bus_io_read;
vm.io_write = bus_io_write; vm.io_write = bus_io_write;
@ -65,6 +58,7 @@ int main(int argc, char *argv[]) {
" --disk DISK Specify a disk image to use\n" " --disk DISK Specify a disk image to use\n"
" --rom ROM Specify a ROM image to use\n" " --rom ROM Specify a ROM image to use\n"
" --debug Enable debug output\n" " --debug Enable debug output\n"
" --headless Headless mode: don't open a window\n"
, argv[0]); , argv[0]);
return 0; return 0;
} else if (strcmp(argv[i], "--disk") == 0) { } else if (strcmp(argv[i], "--disk") == 0) {
@ -85,12 +79,22 @@ int main(int argc, char *argv[]) {
} }
} else if (strcmp(argv[i], "--debug") == 0) { } else if (strcmp(argv[i], "--debug") == 0) {
vm.debug = true; vm.debug = true;
} else if (strcmp(argv[i], "--headless") == 0) {
vm.headless = true;
} else { } else {
fprintf(stderr, "unrecognized option %s\n", argv[i]); fprintf(stderr, "unrecognized option %s\n", argv[i]);
return 1; return 1;
} }
} }
if (!vm.headless) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "unable to initialize SDL: %s", SDL_GetError());
return 1;
}
SDL_ShowCursor(SDL_DISABLE);
ScreenCreate( ScreenCreate(
FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
draw_framebuffer, draw_framebuffer,
@ -104,6 +108,7 @@ int main(int argc, char *argv[]) {
ScreenInit(); ScreenInit();
ScreenDraw(); ScreenDraw();
}
tick_start = SDL_GetTicks(); tick_start = SDL_GetTicks();
tick_end = SDL_GetTicks(); tick_end = SDL_GetTicks();
@ -159,6 +164,7 @@ void main_loop(void) {
} }
if ((ticks % TPF) == 0) { if ((ticks % TPF) == 0) {
if (!vm.headless)
ScreenDraw(); ScreenDraw();
fox32_raise(&vm, VSYNC_INTERRUPT_VECTOR); fox32_raise(&vm, VSYNC_INTERRUPT_VECTOR);
vm.halted = false; vm.halted = false;