|
|
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.11! root 12: const char Dialog_rcsid[] = "Hatari $Id: dialog.c,v 1.66 2008/03/01 22:37:43 eerot 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"
1.1.1.11! root 24: #include "log.h"
1.1 root 25: #include "m68000.h"
26: #include "memorySnapShot.h"
27: #include "printer.h"
1.1.1.3 root 28: #include "reset.h"
1.1 root 29: #include "rs232.h"
30: #include "screen.h"
1.1.1.3 root 31: #include "screenSnapShot.h"
1.1 root 32: #include "sound.h"
33: #include "tos.h"
34: #include "vdi.h"
35: #include "video.h"
1.1.1.2 root 36: #include "sdlgui.h"
1.1.1.11! root 37: #include "hatari-glue.h"
! 38: #if ENABLE_DSP_EMU
! 39: # include "falcon/dsp.h"
! 40: #endif
1.1.1.3 root 41:
1.1 root 42:
1.1.1.5 root 43: CNF_PARAMS DialogParams; /* List of configuration for dialogs (so the user can also choose 'Cancel') */
1.1.1.2 root 44:
45:
46: /*-----------------------------------------------------------------------*/
1.1.1.11! root 47: /**
! 48: * Check if need to warn user that changes will take place after reset.
! 49: * Return TRUE if wants to reset.
! 50: */
1.1.1.10 root 51: BOOL Dialog_DoNeedReset(void)
1.1 root 52: {
1.1.1.11! root 53: /* Did we change monitor type? If so, must reset */
! 54: if (ConfigureParams.Screen.MonitorType != DialogParams.Screen.MonitorType
! 55: && (DialogParams.System.nMachineType == MACHINE_FALCON
! 56: || ConfigureParams.Screen.MonitorType == MONITOR_TYPE_MONO
! 57: || DialogParams.Screen.MonitorType == MONITOR_TYPE_MONO))
1.1.1.9 root 58: return TRUE;
59:
60: /* Did change to GEM VDI display? */
61: if (ConfigureParams.Screen.bUseExtVdiResolutions != DialogParams.Screen.bUseExtVdiResolutions)
62: return TRUE;
63:
1.1.1.11! root 64: /* Did change GEM resolution or color depth? */
1.1.1.9 root 65: if (DialogParams.Screen.bUseExtVdiResolutions &&
1.1.1.11! root 66: (ConfigureParams.Screen.nVdiWidth != DialogParams.Screen.nVdiWidth
! 67: || ConfigureParams.Screen.nVdiHeight != DialogParams.Screen.nVdiHeight
1.1.1.9 root 68: || ConfigureParams.Screen.nVdiColors != DialogParams.Screen.nVdiColors))
69: return TRUE;
70:
71: /* Did change TOS ROM image? */
72: if (strcmp(DialogParams.Rom.szTosImageFileName, ConfigureParams.Rom.szTosImageFileName))
73: return TRUE;
74:
75: /* Did change HD image? */
76: if (DialogParams.HardDisk.bUseHardDiskImage != ConfigureParams.HardDisk.bUseHardDiskImage
77: || (strcmp(DialogParams.HardDisk.szHardDiskImage, ConfigureParams.HardDisk.szHardDiskImage)
78: && DialogParams.HardDisk.bUseHardDiskImage))
79: return TRUE;
80:
81: /* Did change GEMDOS drive? */
82: if (DialogParams.HardDisk.bUseHardDiskDirectories != ConfigureParams.HardDisk.bUseHardDiskDirectories
83: || (strcmp(DialogParams.HardDisk.szHardDiskDirectories[0], ConfigureParams.HardDisk.szHardDiskDirectories[0])
84: && DialogParams.HardDisk.bUseHardDiskDirectories))
85: return TRUE;
1.1 root 86:
1.1.1.11! root 87: /* Did change machine type? */
! 88: if (DialogParams.System.nMachineType != ConfigureParams.System.nMachineType)
! 89: return TRUE;
! 90:
1.1.1.9 root 91: return FALSE;
1.1 root 92: }
93:
1.1.1.2 root 94:
95: /*-----------------------------------------------------------------------*/
1.1.1.11! root 96: /**
! 97: * Copy details back to configuration and perform reset.
! 98: */
1.1.1.10 root 99: void Dialog_CopyDialogParamsToConfiguration(BOOL bForceReset)
1.1 root 100: {
1.1.1.9 root 101: BOOL NeedReset;
102: BOOL bReInitGemdosDrive = FALSE, bReInitAcsiEmu = FALSE;
103: BOOL bReInitIoMem = FALSE;
104:
105: /* Do we need to warn user of that changes will only take effect after reset? */
106: if (bForceReset)
107: NeedReset = bForceReset;
108: else
109: NeedReset = Dialog_DoNeedReset();
110:
111: /* Do need to change resolution? Need if change display/overscan settings */
112: /*(if switch between Colour/Mono cause reset later) */
1.1.1.11! root 113: if (!NeedReset &&
! 114: (DialogParams.Screen.nForceBpp != ConfigureParams.Screen.nForceBpp
! 115: || DialogParams.Screen.bZoomLowRes != ConfigureParams.Screen.bZoomLowRes
! 116: || DialogParams.Screen.bAllowOverscan != ConfigureParams.Screen.bAllowOverscan))
1.1.1.9 root 117: {
1.1.1.11! root 118: ConfigureParams.Screen.nForceBpp = DialogParams.Screen.nForceBpp;
! 119: ConfigureParams.Screen.bZoomLowRes = DialogParams.Screen.bZoomLowRes;
1.1.1.9 root 120: ConfigureParams.Screen.bAllowOverscan = DialogParams.Screen.bAllowOverscan;
1.1.1.11! root 121:
! 122: Screen_ModeChanged();
1.1.1.9 root 123: }
124:
125: /* Did set new printer parameters? */
126: if (DialogParams.Printer.bEnablePrinting != ConfigureParams.Printer.bEnablePrinting
127: || DialogParams.Printer.bPrintToFile != ConfigureParams.Printer.bPrintToFile
128: || strcmp(DialogParams.Printer.szPrintToFileName,ConfigureParams.Printer.szPrintToFileName))
129: {
130: Printer_CloseAllConnections();
131: }
132:
133: /* Did set new RS232 parameters? */
134: if (DialogParams.RS232.bEnableRS232 != ConfigureParams.RS232.bEnableRS232
135: || strcmp(DialogParams.RS232.szOutFileName, ConfigureParams.RS232.szOutFileName)
136: || strcmp(DialogParams.RS232.szInFileName, ConfigureParams.RS232.szInFileName))
137: {
138: RS232_UnInit();
139: }
140:
141: /* Did stop sound? Or change playback Hz. If so, also stop sound recording */
142: if (!DialogParams.Sound.bEnableSound || DialogParams.Sound.nPlaybackQuality != ConfigureParams.Sound.nPlaybackQuality)
143: {
144: if (Sound_AreWeRecording())
145: Sound_EndRecording();
146: Audio_UnInit();
147: }
148:
149: /* Did change GEMDOS drive? */
150: if (DialogParams.HardDisk.bUseHardDiskDirectories != ConfigureParams.HardDisk.bUseHardDiskDirectories
151: || (strcmp(DialogParams.HardDisk.szHardDiskDirectories[0], ConfigureParams.HardDisk.szHardDiskDirectories[0])
152: && DialogParams.HardDisk.bUseHardDiskDirectories))
153: {
154: GemDOS_UnInitDrives();
155: bReInitGemdosDrive = TRUE;
156: }
157:
158: /* Did change HD image? */
159: if (DialogParams.HardDisk.bUseHardDiskImage != ConfigureParams.HardDisk.bUseHardDiskImage
160: || (strcmp(DialogParams.HardDisk.szHardDiskImage, ConfigureParams.HardDisk.szHardDiskImage)
161: && DialogParams.HardDisk.bUseHardDiskImage))
162: {
163: HDC_UnInit();
164: bReInitAcsiEmu = TRUE;
165: }
166:
167: /* Did change blitter, rtc or system type? */
168: if (DialogParams.System.bBlitter != ConfigureParams.System.bBlitter
1.1.1.11! root 169: #if ENABLE_DSP_EMU
! 170: || DialogParams.System.nDSPType != ConfigureParams.System.nDSPType
! 171: #endif
1.1.1.9 root 172: || DialogParams.System.bRealTimeClock != ConfigureParams.System.bRealTimeClock
173: || DialogParams.System.nMachineType != ConfigureParams.System.nMachineType)
174: {
175: IoMem_UnInit();
176: bReInitIoMem = TRUE;
177: }
1.1.1.11! root 178:
! 179: #if ENABLE_DSP_EMU
! 180: /* Disabled DSP? */
! 181: if (DialogParams.System.nDSPType == DSP_TYPE_EMU &&
! 182: (DialogParams.System.nDSPType != ConfigureParams.System.nDSPType))
! 183: {
! 184: DSP_UnInit();
! 185: }
! 186: #endif
1.1.1.9 root 187:
188: /* Copy details to configuration, so can be saved out or set on reset */
189: ConfigureParams = DialogParams;
190:
191: /* Copy details to global, if we reset copy them all */
1.1.1.11! root 192: Configuration_Apply(NeedReset);
! 193:
! 194: #if ENABLE_DSP_EMU
! 195: if (ConfigureParams.System.nDSPType == DSP_TYPE_EMU)
! 196: {
! 197: DSP_Init();
! 198: }
! 199: #endif
1.1.1.9 root 200:
201: /* Set keyboard remap file */
202: if (ConfigureParams.Keyboard.nKeymapType == KEYMAP_LOADED)
203: Keymap_LoadRemapFile(ConfigureParams.Keyboard.szMappingFileName);
204:
205: /* Mount a new HD image: */
206: if (bReInitAcsiEmu && ConfigureParams.HardDisk.bUseHardDiskImage)
207: {
208: HDC_Init(ConfigureParams.HardDisk.szHardDiskImage);
209: }
210:
211: /* Mount a new GEMDOS drive? */
212: if (bReInitGemdosDrive && ConfigureParams.HardDisk.bUseHardDiskDirectories)
213: {
214: GemDOS_InitDrives();
215: }
216:
217: /* Restart audio sub system if necessary: */
218: if (ConfigureParams.Sound.bEnableSound && !bSoundWorking)
219: {
220: Audio_Init();
221: }
222:
223: /* Re-initialize the RS232 emulation: */
224: if (ConfigureParams.RS232.bEnableRS232 && !bConnectedRS232)
225: {
226: RS232_Init();
227: }
228:
229: /* Re-init IO memory map? */
230: if (bReInitIoMem)
231: {
232: IoMem_Init();
233: }
234:
235: /* Do we need to perform reset? */
236: if (NeedReset)
237: {
238: Reset_Cold();
239: }
240:
241: /* Go into/return from full screen if flagged */
242: if (!bInFullScreen && DialogParams.Screen.bFullScreen)
243: Screen_EnterFullScreen();
244: else if (bInFullScreen && !DialogParams.Screen.bFullScreen)
245: Screen_ReturnFromFullScreen();
1.1 root 246: }
247:
248:
1.1.1.2 root 249: /*-----------------------------------------------------------------------*/
1.1.1.11! root 250: /**
! 251: * Open Property sheet Options dialog.
! 252: * Return TRUE if user chooses OK, or FALSE if cancel!
! 253: */
1.1.1.2 root 254: BOOL Dialog_DoProperty(void)
1.1 root 255: {
1.1.1.9 root 256: BOOL bOKDialog; /* Did user 'OK' dialog? */
257: BOOL bForceReset;
1.1 root 258:
1.1.1.9 root 259: Main_PauseEmulation();
1.1 root 260:
1.1.1.9 root 261: /* Copy details to DialogParams (this is so can restore if 'Cancel' dialog) */
262: ConfigureParams.Screen.bFullScreen = bInFullScreen;
263: DialogParams = ConfigureParams;
1.1 root 264:
1.1.1.9 root 265: bForceReset = FALSE;
1.1 root 266:
1.1.1.9 root 267: bOKDialog = Dialog_MainDlg(&bForceReset);
1.1 root 268:
1.1.1.11! root 269: /* Check if reset is required and ask user if he really wants to continue then */
! 270: if (bOKDialog && !bForceReset && Dialog_DoNeedReset()
! 271: && ConfigureParams.Log.nAlertDlgLogLevel >= LOG_INFO) {
! 272: bOKDialog = DlgAlert_Query("The emulated system must be "
! 273: "reset to apply these changes. "
! 274: "Apply changes now and reset "
! 275: "the emulator?");
! 276: }
! 277:
! 278: /* Copy details to configuration */
! 279: if (bOKDialog) {
1.1.1.9 root 280: Dialog_CopyDialogParamsToConfiguration(bForceReset);
1.1.1.11! root 281: }
1.1.1.2 root 282:
1.1.1.9 root 283: Main_UnPauseEmulation();
1.1.1.2 root 284:
1.1.1.9 root 285: if (bQuitProgram)
1.1.1.11! root 286: Main_RequestQuit();
1.1.1.6 root 287:
1.1.1.9 root 288: return bOKDialog;
1.1 root 289: }
1.1.1.10 root 290:
291:
292: /*-----------------------------------------------------------------------*/
1.1.1.11! root 293: /**
! 294: * Loads params from the configuration file into DialogParams
! 295: */
1.1.1.10 root 296: void Dialog_LoadParams(void)
297: {
298: CNF_PARAMS tmpParams;
299: /* Configuration_Load uses the variables from ConfigureParams.
1.1.1.11! root 300: * That's why we have to temporarily back it up here */
! 301: tmpParams = ConfigureParams;
! 302: Configuration_Load(NULL);
! 303: DialogParams = ConfigureParams;
! 304: ConfigureParams = tmpParams;
1.1.1.10 root 305: }
306:
307:
308: /*-----------------------------------------------------------------------*/
1.1.1.11! root 309: /**
! 310: * Saves params in DialogParams to the configuration file
! 311: */
1.1.1.10 root 312: void Dialog_SaveParams(void)
313: {
314: CNF_PARAMS tmpParams;
315: /* Configuration_Save uses the variables from ConfigureParams.
1.1.1.11! root 316: * That's why we have to temporarily back it up here */
! 317: tmpParams = ConfigureParams;
! 318: ConfigureParams = DialogParams;
! 319: Configuration_Save();
! 320: ConfigureParams = tmpParams;
1.1.1.10 root 321: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.