|
|
1.1 root 1: /*
1.1.1.4 root 2: Hatari - dialog.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
1.1 root 6:
1.1.1.9 ! root 7: This is normal 'C' code to handle our options dialog. We keep all our
! 8: configuration details in a structure called 'ConfigureParams'. When we
! 9: open our dialog we make a backup of this structure. When the user finally
! 10: clicks on 'OK', we can compare and makes the necessary changes.
1.1 root 11: */
1.1.1.9 ! root 12: char Dialog_rcsid[] = "Hatari $Id: dialog.c,v 1.49 2005/10/04 21:44:22 thothy Exp $";
1.1.1.3 root 13:
1.1 root 14: #include "main.h"
15: #include "configuration.h"
16: #include "audio.h"
17: #include "dialog.h"
18: #include "floppy.h"
1.1.1.2 root 19: #include "gemdos.h"
20: #include "hdc.h"
1.1.1.8 root 21: #include "ioMem.h"
1.1 root 22: #include "joy.h"
23: #include "keymap.h"
24: #include "m68000.h"
25: #include "memorySnapShot.h"
26: #include "printer.h"
1.1.1.3 root 27: #include "reset.h"
1.1 root 28: #include "rs232.h"
29: #include "screen.h"
1.1.1.3 root 30: #include "screenSnapShot.h"
1.1 root 31: #include "sound.h"
32: #include "tos.h"
33: #include "vdi.h"
34: #include "video.h"
1.1.1.2 root 35: #include "sdlgui.h"
1.1.1.3 root 36: #include "uae-cpu/hatari-glue.h"
37:
1.1 root 38:
1.1.1.5 root 39: CNF_PARAMS DialogParams; /* List of configuration for dialogs (so the user can also choose 'Cancel') */
1.1.1.2 root 40:
41:
42: /*-----------------------------------------------------------------------*/
1.1 root 43: /*
1.1.1.9 ! root 44: Check if need to warn user that changes will take place after reset.
! 45: Return TRUE if wants to reset.
1.1 root 46: */
1.1.1.6 root 47: static BOOL Dialog_DoNeedReset(void)
1.1 root 48: {
1.1.1.9 ! root 49: /* Did we change colour/mono monitor? If so, must reset */
! 50: if (ConfigureParams.Screen.bUseHighRes!=DialogParams.Screen.bUseHighRes)
! 51: return TRUE;
! 52:
! 53: /* Did change to GEM VDI display? */
! 54: if (ConfigureParams.Screen.bUseExtVdiResolutions != DialogParams.Screen.bUseExtVdiResolutions)
! 55: return TRUE;
! 56:
! 57: /* Did change GEM resolution or colour depth? */
! 58: if (DialogParams.Screen.bUseExtVdiResolutions &&
! 59: (ConfigureParams.Screen.nVdiResolution != DialogParams.Screen.nVdiResolution
! 60: || ConfigureParams.Screen.nVdiColors != DialogParams.Screen.nVdiColors))
! 61: return TRUE;
! 62:
! 63: /* Did change TOS ROM image? */
! 64: if (strcmp(DialogParams.Rom.szTosImageFileName, ConfigureParams.Rom.szTosImageFileName))
! 65: return TRUE;
! 66:
! 67: /* Did change HD image? */
! 68: if (DialogParams.HardDisk.bUseHardDiskImage != ConfigureParams.HardDisk.bUseHardDiskImage
! 69: || (strcmp(DialogParams.HardDisk.szHardDiskImage, ConfigureParams.HardDisk.szHardDiskImage)
! 70: && DialogParams.HardDisk.bUseHardDiskImage))
! 71: return TRUE;
! 72:
! 73: /* Did change GEMDOS drive? */
! 74: if (DialogParams.HardDisk.bUseHardDiskDirectories != ConfigureParams.HardDisk.bUseHardDiskDirectories
! 75: || (strcmp(DialogParams.HardDisk.szHardDiskDirectories[0], ConfigureParams.HardDisk.szHardDiskDirectories[0])
! 76: && DialogParams.HardDisk.bUseHardDiskDirectories))
! 77: return TRUE;
1.1 root 78:
1.1.1.9 ! root 79: return FALSE;
1.1 root 80: }
81:
1.1.1.2 root 82:
83: /*-----------------------------------------------------------------------*/
1.1 root 84: /*
1.1.1.9 ! root 85: Copy details back to configuration and perform reset.
1.1 root 86: */
1.1.1.6 root 87: static void Dialog_CopyDialogParamsToConfiguration(BOOL bForceReset)
1.1 root 88: {
1.1.1.9 ! root 89: BOOL NeedReset;
! 90: BOOL bReInitGemdosDrive = FALSE, bReInitAcsiEmu = FALSE;
! 91: BOOL bReInitIoMem = FALSE;
! 92:
! 93: /* Do we need to warn user of that changes will only take effect after reset? */
! 94: if (bForceReset)
! 95: NeedReset = bForceReset;
! 96: else
! 97: NeedReset = Dialog_DoNeedReset();
! 98:
! 99: /* Do need to change resolution? Need if change display/overscan settings */
! 100: /*(if switch between Colour/Mono cause reset later) */
! 101: if (DialogParams.Screen.ChosenDisplayMode != ConfigureParams.Screen.ChosenDisplayMode
! 102: || DialogParams.Screen.bAllowOverscan != ConfigureParams.Screen.bAllowOverscan)
! 103: {
! 104: ConfigureParams.Screen.ChosenDisplayMode = DialogParams.Screen.ChosenDisplayMode;
! 105: ConfigureParams.Screen.bAllowOverscan = DialogParams.Screen.bAllowOverscan;
! 106: PrevSTRes = -1;
! 107: Screen_DidResolutionChange();
! 108: }
! 109:
! 110: /* Did set new printer parameters? */
! 111: if (DialogParams.Printer.bEnablePrinting != ConfigureParams.Printer.bEnablePrinting
! 112: || DialogParams.Printer.bPrintToFile != ConfigureParams.Printer.bPrintToFile
! 113: || strcmp(DialogParams.Printer.szPrintToFileName,ConfigureParams.Printer.szPrintToFileName))
! 114: {
! 115: Printer_CloseAllConnections();
! 116: }
! 117:
! 118: /* Did set new RS232 parameters? */
! 119: if (DialogParams.RS232.bEnableRS232 != ConfigureParams.RS232.bEnableRS232
! 120: || strcmp(DialogParams.RS232.szOutFileName, ConfigureParams.RS232.szOutFileName)
! 121: || strcmp(DialogParams.RS232.szInFileName, ConfigureParams.RS232.szInFileName))
! 122: {
! 123: RS232_UnInit();
! 124: }
! 125:
! 126: /* Did stop sound? Or change playback Hz. If so, also stop sound recording */
! 127: if (!DialogParams.Sound.bEnableSound || DialogParams.Sound.nPlaybackQuality != ConfigureParams.Sound.nPlaybackQuality)
! 128: {
! 129: if (Sound_AreWeRecording())
! 130: Sound_EndRecording();
! 131: Audio_UnInit();
! 132: }
! 133:
! 134: /* Did change GEMDOS drive? */
! 135: if (DialogParams.HardDisk.bUseHardDiskDirectories != ConfigureParams.HardDisk.bUseHardDiskDirectories
! 136: || (strcmp(DialogParams.HardDisk.szHardDiskDirectories[0], ConfigureParams.HardDisk.szHardDiskDirectories[0])
! 137: && DialogParams.HardDisk.bUseHardDiskDirectories))
! 138: {
! 139: GemDOS_UnInitDrives();
! 140: bReInitGemdosDrive = TRUE;
! 141: }
! 142:
! 143: /* Did change HD image? */
! 144: if (DialogParams.HardDisk.bUseHardDiskImage != ConfigureParams.HardDisk.bUseHardDiskImage
! 145: || (strcmp(DialogParams.HardDisk.szHardDiskImage, ConfigureParams.HardDisk.szHardDiskImage)
! 146: && DialogParams.HardDisk.bUseHardDiskImage))
! 147: {
! 148: HDC_UnInit();
! 149: bReInitAcsiEmu = TRUE;
! 150: }
! 151:
! 152: /* Did change blitter, rtc or system type? */
! 153: if (DialogParams.System.bBlitter != ConfigureParams.System.bBlitter
! 154: || DialogParams.System.bRealTimeClock != ConfigureParams.System.bRealTimeClock
! 155: || DialogParams.System.nMachineType != ConfigureParams.System.nMachineType)
! 156: {
! 157: IoMem_UnInit();
! 158: bReInitIoMem = TRUE;
! 159: }
! 160:
! 161: /* Copy details to configuration, so can be saved out or set on reset */
! 162: ConfigureParams = DialogParams;
! 163:
! 164: /* Copy details to global, if we reset copy them all */
! 165: Configuration_WorkOnDetails(NeedReset);
! 166:
! 167: /* Set keyboard remap file */
! 168: if (ConfigureParams.Keyboard.nKeymapType == KEYMAP_LOADED)
! 169: Keymap_LoadRemapFile(ConfigureParams.Keyboard.szMappingFileName);
! 170:
! 171: /* Did the user changed the CPU mode? */
! 172: check_prefs_changed_cpu(DialogParams.System.nCpuLevel, DialogParams.System.bCompatibleCpu);
! 173:
! 174: /* Mount a new HD image: */
! 175: if (bReInitAcsiEmu && ConfigureParams.HardDisk.bUseHardDiskImage)
! 176: {
! 177: HDC_Init(ConfigureParams.HardDisk.szHardDiskImage);
! 178: }
! 179:
! 180: /* Mount a new GEMDOS drive? */
! 181: if (bReInitGemdosDrive && ConfigureParams.HardDisk.bUseHardDiskDirectories)
! 182: {
! 183: GemDOS_InitDrives();
! 184: }
! 185:
! 186: /* Restart audio sub system if necessary: */
! 187: if (ConfigureParams.Sound.bEnableSound && !bSoundWorking)
! 188: {
! 189: Audio_Init();
! 190: }
! 191:
! 192: /* Re-initialize the RS232 emulation: */
! 193: if (ConfigureParams.RS232.bEnableRS232 && !bConnectedRS232)
! 194: {
! 195: RS232_Init();
! 196: }
! 197:
! 198: /* Re-init IO memory map? */
! 199: if (bReInitIoMem)
! 200: {
! 201: IoMem_Init();
! 202: }
! 203:
! 204: /* Do we need to perform reset? */
! 205: if (NeedReset)
! 206: {
! 207: Reset_Cold();
! 208: }
! 209:
! 210: /* Go into/return from full screen if flagged */
! 211: if (!bInFullScreen && DialogParams.Screen.bFullScreen)
! 212: Screen_EnterFullScreen();
! 213: else if (bInFullScreen && !DialogParams.Screen.bFullScreen)
! 214: Screen_ReturnFromFullScreen();
1.1 root 215: }
216:
217:
1.1.1.2 root 218: /*-----------------------------------------------------------------------*/
1.1 root 219: /*
1.1.1.9 ! root 220: Open Property sheet Options dialog.
1.1.1.2 root 221: Return TRUE if user choses OK, or FALSE if cancel!
1.1 root 222: */
1.1.1.2 root 223: BOOL Dialog_DoProperty(void)
1.1 root 224: {
1.1.1.9 ! root 225: BOOL bOKDialog; /* Did user 'OK' dialog? */
! 226: BOOL bForceReset;
1.1 root 227:
1.1.1.9 ! root 228: Main_PauseEmulation();
1.1 root 229:
1.1.1.9 ! root 230: /* Copy details to DialogParams (this is so can restore if 'Cancel' dialog) */
! 231: ConfigureParams.Screen.bFullScreen = bInFullScreen;
! 232: DialogParams = ConfigureParams;
1.1 root 233:
1.1.1.9 ! root 234: bForceReset = FALSE;
1.1 root 235:
1.1.1.9 ! root 236: bOKDialog = Dialog_MainDlg(&bForceReset);
1.1 root 237:
1.1.1.9 ! root 238: /* Copy details to configuration, and ask user if wishes to reset */
! 239: if (bOKDialog)
! 240: Dialog_CopyDialogParamsToConfiguration(bForceReset);
1.1.1.2 root 241:
1.1.1.9 ! root 242: Main_UnPauseEmulation();
1.1.1.2 root 243:
1.1.1.9 ! root 244: if (bQuitProgram)
! 245: set_special(SPCFLAG_BRK); /* Assure that CPU core shuts down */
1.1.1.6 root 246:
1.1.1.9 ! root 247: return bOKDialog;
1.1 root 248: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.