/** * 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; }
/** * Command: Set command line and debugger options */ static int DebugUI_SetOptions(int argc, char *argv[]) { CNF_PARAMS current; static const struct { const char name[4]; int base; } bases[] = { { "bin", 2 }, { "dec", 10 }, { "hex", 16 } }; const char *arg; int i; if (argc < 2) { return DebugUI_PrintCmdHelp(argv[0]); } arg = argv[1]; for (i = 0; i < ARRAYSIZE(bases); i++) { if (strcasecmp(bases[i].name, arg) == 0) { if (ConfigureParams.Debugger.nNumberBase != bases[i].base) { fprintf(stderr, "Switched default number base from %d to %d-based (%s) values.\n", ConfigureParams.Debugger.nNumberBase, bases[i].base, bases[i].name); ConfigureParams.Debugger.nNumberBase = bases[i].base; } else { fprintf(stderr, "Already in '%s' mode.\n", bases[i].name); } return DEBUGGER_CMDDONE; } } /* get configuration changes */ current = ConfigureParams; /* Parse and apply options */ if (Opt_ParseParameters(argc, (const char * const *)argv)) { ConfigureParams.Screen.bFullScreen = false; Change_CopyChangedParamsToConfiguration(¤t, &ConfigureParams, false); } else { ConfigureParams = current; } return DEBUGGER_CMDDONE; }
/** * 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; }