/** * Change given Hatari options * Return false if parsing failed, true otherwise */ static bool Change_Options(int argc, const char *argv[]) { bool bOK; CNF_PARAMS current; Main_PauseEmulation(false); /* get configuration changes */ current = ConfigureParams; ConfigureParams.Screen.bFullScreen = bInFullScreen; bOK = Opt_ParseParameters(argc, argv); /* Check if reset is required and ask user if he really wants to continue */ if (bOK && Change_DoNeedReset(¤t, &ConfigureParams) && current.Log.nAlertDlgLogLevel > LOG_FATAL) { bOK = DlgAlert_Query("The emulated system must be " "reset to apply these changes. " "Apply changes now and reset " "the emulator?"); } /* Copy details to configuration */ if (bOK) { if (!Change_CopyChangedParamsToConfiguration(¤t, &ConfigureParams, false)) { ConfigureParams = current; DlgAlert_Notice("Return to old parameters..."); Reset_Cold(); } } else { ConfigureParams = current; } Main_UnPauseEmulation(); return bOK; }
/** * Open Property sheet Options dialog. * * We keep all our configuration details in a structure called * 'ConfigureParams'. When we open our dialog we make a backup * of this structure. When the user finally clicks on 'OK', * we can compare and makes the necessary changes. * * Return true if user chooses OK, or false if cancel! */ bool Dialog_DoProperty(void) { bool bOKDialog; /* Did user 'OK' dialog? */ bool bForceReset; bool bLoadedSnapshot; CNF_PARAMS current; Main_PauseEmulation(true); bForceReset = false; /* Copy details (this is so can restore if 'Cancel' dialog) */ current = ConfigureParams; ConfigureParams.Screen.bFullScreen = bInFullScreen; bOKDialog = Dialog_MainDlg(&bForceReset, &bLoadedSnapshot); /* If a memory snapshot has been loaded, no further changes are required */ if (bLoadedSnapshot) { Main_UnPauseEmulation(); return true; } /* Check if reset is required and ask user if he really wants to continue then */ if (bOKDialog && !bForceReset && Change_DoNeedReset(¤t, &ConfigureParams) && ConfigureParams.Log.nAlertDlgLogLevel > LOG_FATAL) { bOKDialog = DlgAlert_Query("The emulated system must be " "reset to apply these changes. " "Apply changes now and reset " "the emulator?"); } /* Copy details to configuration */ if (bOKDialog) { Change_CopyChangedParamsToConfiguration(¤t, &ConfigureParams, bForceReset); } else { ConfigureParams = current; } Main_UnPauseEmulation(); if (bQuitProgram) Main_RequestQuit(); return bOKDialog; }
/** * Shorcut to debug interface */ static void ShortCut_Debug(void) { int running; /* Call the debugger */ running = Main_PauseEmulation(true); DebugUI(); if (running) Main_UnPauseEmulation(); }
/** * Main * * Note: 'argv' cannot be declared const, MinGW would then fail to link. */ int main(int argc, char *argv[]) { /* Generate random seed */ srand(time(NULL)); /* Initialize directory strings */ Paths_Init(argv[0]); /* Set default configuration values: */ Configuration_SetDefault(); /* Now load the values from the configuration file */ Main_LoadInitialConfig(); #if 0 /* FIXME: This sometimes causes exits when starting from application bundles */ /* Check for any passed parameters */ if (!Opt_ParseParameters(argc, (const char * const *)argv)) { return 1; } #endif /* monitor type option might require "reset" -> true */ Configuration_Apply(true); #ifdef WIN32 Win_OpenCon(); #endif /* Needed on maemo but useful also with normal X11 window managers * for window grouping when you have multiple Hatari SDL windows open */ #if HAVE_SETENV setenv("SDL_VIDEO_X11_WMCLASS", "previous", 1); #endif /* Init emulator system */ Main_Init(); /* Set initial Statusbar information */ Main_StatusbarSetup(); /* Check if SDL_Delay is accurate */ Main_CheckForAccurateDelays(); /* Run emulation */ Main_UnPauseEmulation(); M68000_Start(); /* Start emulation */ /* Un-init emulation system */ Main_UnInit(); return 0; }
/** * Shorcut to load a disk image */ static void ShortCut_InsertDisk(int drive) { char *selname, *zip_path = NULL; const char *tmpname; char FileNameB[ FILENAME_MAX ]; char ZipPathB[ FILENAME_MAX ]; if (SDLGui_SetScreen(sdlscrn)) return; /* Save current names for drive 1 before checking autoinsert */ strcpy ( FileNameB , ConfigureParams.DiskImage.szDiskFileName[ 1 ] ); strcpy ( ZipPathB , ConfigureParams.DiskImage.szDiskZipPath[ 1 ] ); if (ConfigureParams.DiskImage.szDiskFileName[drive][0]) tmpname = ConfigureParams.DiskImage.szDiskFileName[drive]; else tmpname = ConfigureParams.DiskImage.szDiskImageDirectory; Main_PauseEmulation(true); selname = SDLGui_FileSelect("Floppy image:", tmpname, &zip_path, false); if (selname) { if (File_Exists(selname)) Floppy_SetDiskFileName(drive, selname, zip_path); else Floppy_SetDiskFileNameNone(drive); if (zip_path) free(zip_path); free(selname); Floppy_InsertDiskIntoDrive(0); /* Check if inserting into drive 0 also changed drive 1 with autoinsert */ if ( ( strcmp ( FileNameB , ConfigureParams.DiskImage.szDiskFileName[ 1 ] ) != 0 ) || ( strcmp ( FileNameB , ConfigureParams.DiskImage.szDiskZipPath[ 1 ] ) != 0 ) ) Floppy_InsertDiskIntoDrive(1); } Main_UnPauseEmulation(); }
/** * Return from Full screen mode back to a window */ void Screen_ReturnFromFullScreen(void) { bool bWasRunning; if (bInFullScreen) { /* Hold things... */ bWasRunning = Main_PauseEmulation(false); bInFullScreen = false; if (Screen_UseHostScreen()) { // HostScreen_toggleFullScreen(); } else { SDL_SetWindowFullscreen(sdlWindow, 0); //Screen_SetResolution(); } SDL_Delay(20); /* To give monitor time to switch resolution */ if (bWasRunning) { /* And off we go... */ Main_UnPauseEmulation(); } else { Screen_Refresh(); } if (!bGrabMouse) { /* Un-grab mouse pointer in windowed mode */ SDL_SetRelativeMouseMode(SDL_FALSE); SDL_SetWindowGrab(sdlWindow, SDL_FALSE); } } }
/** * Enter Full screen mode */ void Screen_EnterFullScreen(void) { bool bWasRunning; if (!bInFullScreen) { /* Hold things... */ bWasRunning = Main_PauseEmulation(false); bInFullScreen = true; if (Screen_UseHostScreen()) { // HostScreen_toggleFullScreen(); } else { SDL_SetWindowFullscreen(sdlWindow, SDL_WINDOW_FULLSCREEN_DESKTOP); //Screen_SetResolution(); //Screen_ClearScreen(); /* Black out screen bitmap as will be invalid when return */ } SDL_Delay(20); /* To give monitor time to change to new resolution */ if (bWasRunning) { /* And off we go... */ Main_UnPauseEmulation(); } else { Screen_Refresh(); } SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetWindowGrab(sdlWindow, SDL_TRUE); } }
/** * Check to see if pressed any shortcut keys, and call handling function */ void ShortCut_ActKey(void) { if (ShortCutKey == SHORTCUT_NONE) return; switch (ShortCutKey) { case SHORTCUT_OPTIONS: Dialog_DoProperty(); /* Show options dialog */ break; case SHORTCUT_FULLSCREEN: ShortCut_FullScreen(); /* Switch between fullscreen/windowed mode */ break; case SHORTCUT_MOUSEGRAB: ShortCut_MouseGrab(); /* Toggle mouse grab */ break; case SHORTCUT_COLDRESET: Main_UnPauseEmulation(); Reset_Cold(); /* Reset emulator with 'cold' (clear all) */ break; #if 0 case SHORTCUT_WARMRESET: Main_UnPauseEmulation(); Reset_Warm(); /* Emulator 'warm' reset */ break; case SHORTCUT_SCREENSHOT: ScreenSnapShot_SaveScreen(); /* Grab screenshot */ break; case SHORTCUT_BOSSKEY: ShortCut_BossKey(); /* Boss key */ break; case SHORTCUT_CURSOREMU: /* Toggle joystick emu on/off */ Joy_ToggleCursorEmulation(); break; case SHORTCUT_FASTFORWARD: ShortCut_FastForward(); /* Toggle Min/Max speed */ break; case SHORTCUT_RECANIM: ShortCut_RecordAnimation(); /* Record animation */ break; case SHORTCUT_RECSOUND: ShortCut_RecordSound(); /* Toggle sound recording */ break; #endif case SHORTCUT_SOUND: ShortCut_SoundOnOff(); /* Enable/disable sound */ break; #if 0 case SHORTCUT_DEBUG: ShortCut_Debug(); /* Invoke the Debug UI */ break; #endif case SHORTCUT_PAUSE: ShortCut_Pause(); /* Invoke Pause */ break; case SHORTCUT_QUIT: Main_RequestQuit(); break; #if 0 case SHORTCUT_LOADMEM: MemorySnapShot_Restore(ConfigureParams.Memory.szMemoryCaptureFileName, true); break; case SHORTCUT_SAVEMEM: MemorySnapShot_Capture(ConfigureParams.Memory.szMemoryCaptureFileName, true); break; #endif case SHORTCUT_DIMENSION: ShortCut_Dimension(); break; case SHORTCUT_KEYS: case SHORTCUT_NONE: /* ERROR: cannot happen, just make compiler happy */ default: break; } ShortCutKey = SHORTCUT_NONE; }
/** * Shorcut to pausing */ static void ShortCut_Pause(void) { if (!Main_UnPauseEmulation()) Main_PauseEmulation(true); }