Add headless mode
This commit is contained in:
parent
c1652c34b0
commit
17f452bacf
|
@ -58,6 +58,7 @@ typedef struct {
|
|||
bool halted;
|
||||
|
||||
bool debug;
|
||||
bool headless;
|
||||
|
||||
bool mmu_enabled;
|
||||
|
||||
|
|
47
src/main.c
47
src/main.c
|
@ -58,6 +58,7 @@ int main(int argc, char *argv[]) {
|
|||
" --disk DISK Specify a disk image to use\n"
|
||||
" --rom ROM Specify a ROM image to use\n"
|
||||
" --debug Enable debug output\n"
|
||||
" --headless Headless mode: don't open a window\n"
|
||||
, argv[0]);
|
||||
return 0;
|
||||
} else if (strcmp(argv[i], "--disk") == 0) {
|
||||
|
@ -78,32 +79,37 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
} else if (strcmp(argv[i], "--debug") == 0) {
|
||||
vm.debug = true;
|
||||
} else if (strcmp(argv[i], "--headless") == 0) {
|
||||
vm.headless = true;
|
||||
} else {
|
||||
fprintf(stderr, "unrecognized option %s\n", argv[i]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
fprintf(stderr, "unable to initialize SDL: %s", SDL_GetError());
|
||||
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(
|
||||
FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
|
||||
draw_framebuffer,
|
||||
key_pressed,
|
||||
key_released,
|
||||
mouse_pressed,
|
||||
mouse_released,
|
||||
mouse_moved,
|
||||
drop_file
|
||||
);
|
||||
|
||||
ScreenInit();
|
||||
ScreenDraw();
|
||||
}
|
||||
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
ScreenCreate(
|
||||
FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
|
||||
draw_framebuffer,
|
||||
key_pressed,
|
||||
key_released,
|
||||
mouse_pressed,
|
||||
mouse_released,
|
||||
mouse_moved,
|
||||
drop_file
|
||||
);
|
||||
|
||||
ScreenInit();
|
||||
ScreenDraw();
|
||||
|
||||
tick_start = SDL_GetTicks();
|
||||
tick_end = SDL_GetTicks();
|
||||
|
||||
|
@ -158,7 +164,8 @@ void main_loop(void) {
|
|||
}
|
||||
|
||||
if ((ticks % TPF) == 0) {
|
||||
ScreenDraw();
|
||||
if (!vm.headless)
|
||||
ScreenDraw();
|
||||
fox32_raise(&vm, VSYNC_INTERRUPT_VECTOR);
|
||||
vm.halted = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user