|
|
1.1 root 1: /*
2: Hatari - configuration.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.
6:
7: Configuration File
8:
9: The configuration file is now stored in an ASCII format to allow the user
10: to edit the file manually.
11: */
12: const char Configuration_fileid[] = "Hatari configuration.c : " __DATE__ " " __TIME__;
13:
14: #include <SDL_keysym.h>
15:
16: #include "main.h"
17: #include "configuration.h"
18: #include "cfgopts.h"
19: #include "file.h"
20: #include "log.h"
21: #include "m68000.h"
22: #include "memorySnapShot.h"
23: #include "paths.h"
24: #include "screen.h"
25: #include "video.h"
26:
27:
28: CNF_PARAMS ConfigureParams; /* List of configuration for the emulator */
29: char sConfigFileName[FILENAME_MAX]; /* Stores the name of the configuration file */
30:
31:
32: /* Used to load/save logging options */
33: static const struct Config_Tag configs_Log[] =
34: {
35: { "sLogFileName", String_Tag, ConfigureParams.Log.sLogFileName },
36: { "sTraceFileName", String_Tag, ConfigureParams.Log.sTraceFileName },
37: { "nTextLogLevel", Int_Tag, &ConfigureParams.Log.nTextLogLevel },
38: { "nAlertDlgLogLevel", Int_Tag, &ConfigureParams.Log.nAlertDlgLogLevel },
39: { "bConfirmQuit", Bool_Tag, &ConfigureParams.Log.bConfirmQuit },
40: { NULL , Error_Tag, NULL }
41: };
42:
43: /* Used to load/save debugger options */
44: static const struct Config_Tag configs_Debugger[] =
45: {
46: { "nNumberBase", Int_Tag, &ConfigureParams.Debugger.nNumberBase },
47: { "nDisasmLines", Int_Tag, &ConfigureParams.Debugger.nDisasmLines },
48: { "nMemdumpLines", Int_Tag, &ConfigureParams.Debugger.nMemdumpLines },
49: { NULL , Error_Tag, NULL }
50: };
51:
52: /* Used to load/save screen options */
53: static const struct Config_Tag configs_Screen[] =
54: {
55: { "nMonitorType", Int_Tag, &ConfigureParams.Screen.nMonitorType },
56: { "nFrameSkips", Int_Tag, &ConfigureParams.Screen.nFrameSkips },
57: { "bFullScreen", Bool_Tag, &ConfigureParams.Screen.bFullScreen },
58: { "bAllowOverscan", Bool_Tag, &ConfigureParams.Screen.bAllowOverscan },
59: { "nSpec512Threshold", Int_Tag, &ConfigureParams.Screen.nSpec512Threshold },
60: { "nForceBpp", Int_Tag, &ConfigureParams.Screen.nForceBpp },
61: { "bAspectCorrect", Bool_Tag, &ConfigureParams.Screen.bAspectCorrect },
62: { "bUseExtVdiResolutions", Bool_Tag, &ConfigureParams.Screen.bUseExtVdiResolutions },
63: { "nVdiWidth", Int_Tag, &ConfigureParams.Screen.nVdiWidth },
64: { "nVdiHeight", Int_Tag, &ConfigureParams.Screen.nVdiHeight },
65: { "nVdiColors", Int_Tag, &ConfigureParams.Screen.nVdiColors },
66: { "bShowStatusbar", Bool_Tag, &ConfigureParams.Screen.bShowStatusbar },
67: { "bShowDriveLed", Bool_Tag, &ConfigureParams.Screen.bShowDriveLed },
68: { "bCaptureChange", Bool_Tag, &ConfigureParams.Screen.bCaptureChange },
69: { "nMaxWidth", Int_Tag, &ConfigureParams.Screen.nMaxWidth },
70: { "nMaxHeight", Int_Tag, &ConfigureParams.Screen.nMaxHeight },
71: { NULL , Error_Tag, NULL }
72: };
73:
74: /* Used to load/save joystick 0 options */
75: static const struct Config_Tag configs_Joystick0[] =
76: {
77: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nJoystickMode },
78: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[0].bEnableAutoFire },
79: { "bEnableJumpOnFire2", Bool_Tag, &ConfigureParams.Joysticks.Joy[0].bEnableJumpOnFire2 },
80: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nJoyId },
81: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeUp },
82: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeDown },
83: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeLeft },
84: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeRight },
85: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeFire },
86: { NULL , Error_Tag, NULL }
87: };
88:
89: /* Used to load/save joystick 1 options */
90: static const struct Config_Tag configs_Joystick1[] =
91: {
92: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nJoystickMode },
93: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[1].bEnableAutoFire },
94: { "bEnableJumpOnFire2", Bool_Tag, &ConfigureParams.Joysticks.Joy[1].bEnableJumpOnFire2 },
95: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nJoyId },
96: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeUp },
97: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeDown },
98: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeLeft },
99: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeRight },
100: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeFire },
101: { NULL , Error_Tag, NULL }
102: };
103:
104: /* Used to load/save joystick 2 options */
105: static const struct Config_Tag configs_Joystick2[] =
106: {
107: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nJoystickMode },
108: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[2].bEnableAutoFire },
109: { "bEnableJumpOnFire2", Bool_Tag, &ConfigureParams.Joysticks.Joy[2].bEnableJumpOnFire2 },
110: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nJoyId },
111: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeUp },
112: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeDown },
113: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeLeft },
114: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeRight },
115: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeFire },
116: { NULL , Error_Tag, NULL }
117: };
118:
119: /* Used to load/save joystick 3 options */
120: static const struct Config_Tag configs_Joystick3[] =
121: {
122: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nJoystickMode },
123: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[3].bEnableAutoFire },
124: { "bEnableJumpOnFire2", Bool_Tag, &ConfigureParams.Joysticks.Joy[3].bEnableJumpOnFire2 },
125: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nJoyId },
126: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeUp },
127: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeDown },
128: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeLeft },
129: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeRight },
130: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeFire },
131: { NULL , Error_Tag, NULL }
132: };
133:
134: /* Used to load/save joystick 4 options */
135: static const struct Config_Tag configs_Joystick4[] =
136: {
137: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nJoystickMode },
138: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[4].bEnableAutoFire },
139: { "bEnableJumpOnFire2", Bool_Tag, &ConfigureParams.Joysticks.Joy[4].bEnableJumpOnFire2 },
140: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nJoyId },
141: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeUp },
142: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeDown },
143: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeLeft },
144: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeRight },
145: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeFire },
146: { NULL , Error_Tag, NULL }
147: };
148:
149: /* Used to load/save joystick 5 options */
150: static const struct Config_Tag configs_Joystick5[] =
151: {
152: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nJoystickMode },
153: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[5].bEnableAutoFire },
154: { "bEnableJumpOnFire2", Bool_Tag, &ConfigureParams.Joysticks.Joy[5].bEnableJumpOnFire2 },
155: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nJoyId },
156: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeUp },
157: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeDown },
158: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeLeft },
159: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeRight },
160: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeFire },
161: { NULL , Error_Tag, NULL }
162: };
163:
164: /* Used to load/save keyboard options */
165: static const struct Config_Tag configs_Keyboard[] =
166: {
167: { "bDisableKeyRepeat", Bool_Tag, &ConfigureParams.Keyboard.bDisableKeyRepeat },
168: { "nKeymapType", Int_Tag, &ConfigureParams.Keyboard.nKeymapType },
169: { "szMappingFileName", String_Tag, ConfigureParams.Keyboard.szMappingFileName },
170: { NULL , Error_Tag, NULL }
171: };
172:
173: /* Used to load/save shortcut key bindings with modifiers options */
174: static const struct Config_Tag configs_ShortCutWithMod[] =
175: {
176: { "keyOptions", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] },
177: { "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] },
178: { "keyMouseMode", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] },
179: { "keyColdReset", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] },
180: { "keyWarmReset", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] },
181: { "keyScreenShot", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_SCREENSHOT] },
182: { "keyBossKey", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_BOSSKEY] },
183: { "keyCursorEmu", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_CURSOREMU] },
184: { "keyFastForward",Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_FASTFORWARD] },
185: { "keyRecAnim", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_RECANIM] },
186: { "keyRecSound", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_RECSOUND] },
187: { "keySound", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_SOUND] },
188: { "keyPause", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_PAUSE] },
189: { "keyDebugger", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG] },
190: { "keyQuit", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_QUIT] },
191: { "keyLoadMem", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_LOADMEM] },
192: { "keySaveMem", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_SAVEMEM] },
193: { "keyInsertDiskA",Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_INSERTDISKA] },
194: { NULL , Error_Tag, NULL }
195: };
196:
197: /* Used to load/save shortcut key bindings without modifiers options */
198: static const struct Config_Tag configs_ShortCutWithoutMod[] =
199: {
200: { "keyOptions", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] },
201: { "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] },
202: { "keyMouseMode", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_MOUSEGRAB] },
203: { "keyColdReset", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_COLDRESET] },
204: { "keyWarmReset", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_WARMRESET] },
205: { "keyScreenShot", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_SCREENSHOT] },
206: { "keyBossKey", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_BOSSKEY] },
207: { "keyCursorEmu", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_CURSOREMU] },
208: { "keyFastForward",Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FASTFORWARD] },
209: { "keyRecAnim", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_RECANIM] },
210: { "keyRecSound", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_RECSOUND] },
211: { "keySound", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_SOUND] },
212: { "keyPause", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_PAUSE] },
213: { "keyDebugger", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_DEBUG] },
214: { "keyQuit", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_QUIT] },
215: { "keyLoadMem", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_LOADMEM] },
216: { "keySaveMem", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_SAVEMEM] },
217: { "keyInsertDiskA",Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_INSERTDISKA] },
218: { NULL , Error_Tag, NULL }
219: };
220:
221:
222: /* Used to load/save sound options */
223: static const struct Config_Tag configs_Sound[] =
224: {
225: { "bEnableSound", Bool_Tag, &ConfigureParams.Sound.bEnableSound },
226: { "nPlaybackFreq", Int_Tag, &ConfigureParams.Sound.nPlaybackFreq },
227: { "szYMCaptureFileName", String_Tag, ConfigureParams.Sound.szYMCaptureFileName },
228: { "nSdlAudioBufferSize", Int_Tag, &ConfigureParams.Sound.SdlAudioBufferSize },
229: { NULL , Error_Tag, NULL }
230: };
231:
232: /* Used to load/save memory options */
233: static const struct Config_Tag configs_Memory[] =
234: {
235: { "nMemorySize", Int_Tag, &ConfigureParams.Memory.nMemorySize },
236: { "bAutoSave", Bool_Tag, &ConfigureParams.Memory.bAutoSave },
237: { "szMemoryCaptureFileName", String_Tag, ConfigureParams.Memory.szMemoryCaptureFileName },
238: { "szAutoSaveFileName", String_Tag, ConfigureParams.Memory.szAutoSaveFileName },
239: { NULL , Error_Tag, NULL }
240: };
241:
242:
243: /* Used to load/save floppy options */
244: static const struct Config_Tag configs_Floppy[] =
245: {
246: { "bAutoInsertDiskB", Bool_Tag, &ConfigureParams.DiskImage.bAutoInsertDiskB },
247: { "bSlowFloppy", Bool_Tag, &ConfigureParams.DiskImage.bSlowFloppy },
248: { "nWriteProtection", Int_Tag, &ConfigureParams.DiskImage.nWriteProtection },
249: { "szDiskAZipPath", String_Tag, ConfigureParams.DiskImage.szDiskZipPath[0] },
250: { "szDiskAFileName", String_Tag, ConfigureParams.DiskImage.szDiskFileName[0] },
251: { "szDiskBZipPath", String_Tag, ConfigureParams.DiskImage.szDiskZipPath[1] },
252: { "szDiskBFileName", String_Tag, ConfigureParams.DiskImage.szDiskFileName[1] },
253: { "szDiskImageDirectory", String_Tag, ConfigureParams.DiskImage.szDiskImageDirectory },
254: { NULL , Error_Tag, NULL }
255: };
256:
257: /* Used to load/save HD options */
258: static const struct Config_Tag configs_HardDisk[] =
259: {
260: { "bBootFromHardDisk", Bool_Tag, &ConfigureParams.HardDisk.bBootFromHardDisk },
261: { "bUseHardDiskDirectory", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskDirectories },
262: { "szHardDiskDirectory", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_C] },
263: { "nWriteProtection", Int_Tag, &ConfigureParams.HardDisk.nWriteProtection },
264: { "bUseHardDiskImage", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskImage },
265: { "szHardDiskImage", String_Tag, ConfigureParams.HardDisk.szHardDiskImage },
266: { "bUseIdeMasterHardDiskImage", Bool_Tag, &ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage },
267: { "bUseIdeSlaveHardDiskImage", Bool_Tag, &ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage },
268: { "szIdeMasterHardDiskImage", String_Tag, ConfigureParams.HardDisk.szIdeMasterHardDiskImage },
269: { "szIdeSlaveHardDiskImage", String_Tag, ConfigureParams.HardDisk.szIdeSlaveHardDiskImage },
270: { NULL , Error_Tag, NULL }
271: };
272:
273: /* Used to load/save ROM options */
274: static const struct Config_Tag configs_Rom[] =
275: {
276: { "szTosImageFileName", String_Tag, ConfigureParams.Rom.szTosImageFileName },
277: { "szCartridgeImageFileName", String_Tag, ConfigureParams.Rom.szCartridgeImageFileName },
278: { NULL , Error_Tag, NULL }
279: };
280:
281: /* Used to load/save RS232 options */
282: static const struct Config_Tag configs_Rs232[] =
283: {
284: { "bEnableRS232", Bool_Tag, &ConfigureParams.RS232.bEnableRS232 },
285: { "szOutFileName", String_Tag, ConfigureParams.RS232.szOutFileName },
286: { "szInFileName", String_Tag, ConfigureParams.RS232.szInFileName },
287: { NULL , Error_Tag, NULL }
288: };
289:
290: /* Used to load/save printer options */
291: static const struct Config_Tag configs_Printer[] =
292: {
293: { "bEnablePrinting", Bool_Tag, &ConfigureParams.Printer.bEnablePrinting },
294: { "bPrintToFile", Bool_Tag, &ConfigureParams.Printer.bPrintToFile },
295: { "szPrintToFileName", String_Tag, ConfigureParams.Printer.szPrintToFileName },
296: { NULL , Error_Tag, NULL }
297: };
298:
299: /* Used to load/save MIDI options */
300: static const struct Config_Tag configs_Midi[] =
301: {
302: { "bEnableMidi", Bool_Tag, &ConfigureParams.Midi.bEnableMidi },
303: { "sMidiInFileName", String_Tag, ConfigureParams.Midi.sMidiInFileName },
304: { "sMidiOutFileName", String_Tag, ConfigureParams.Midi.sMidiOutFileName },
305: { NULL , Error_Tag, NULL }
306: };
307:
308: /* Used to load/save system options */
309: static const struct Config_Tag configs_System[] =
310: {
311: { "nCpuLevel", Int_Tag, &ConfigureParams.System.nCpuLevel },
312: { "nCpuFreq", Int_Tag, &ConfigureParams.System.nCpuFreq },
313: { "bCompatibleCpu", Bool_Tag, &ConfigureParams.System.bCompatibleCpu },
314: { "nMachineType", Int_Tag, &ConfigureParams.System.nMachineType },
315: { "bBlitter", Bool_Tag, &ConfigureParams.System.bBlitter },
316: { "nDSPType", Int_Tag, &ConfigureParams.System.nDSPType },
317: { "bRealTimeClock", Bool_Tag, &ConfigureParams.System.bRealTimeClock },
318: { "bPatchTimerD", Bool_Tag, &ConfigureParams.System.bPatchTimerD },
319: { "bFastForward", Bool_Tag, &ConfigureParams.System.bFastForward },
320: { NULL , Error_Tag, NULL }
321: };
322:
323:
324: /*-----------------------------------------------------------------------*/
325: /**
326: * Set default configuration values.
327: */
328: void Configuration_SetDefault(void)
329: {
330: int i;
331: const char *psHomeDir;
332: const char *psWorkingDir;
333:
334: psHomeDir = Paths_GetHatariHome();
335: psWorkingDir = Paths_GetWorkingDir();
336:
337: /* Clear parameters */
338: memset(&ConfigureParams, 0, sizeof(CNF_PARAMS));
339:
340: /* Set defaults for logging and tracing */
341: strcpy(ConfigureParams.Log.sLogFileName, "stderr");
342: strcpy(ConfigureParams.Log.sTraceFileName, "stderr");
343: ConfigureParams.Log.nTextLogLevel = LOG_TODO;
344: ConfigureParams.Log.nAlertDlgLogLevel = LOG_ERROR;
345: ConfigureParams.Log.bConfirmQuit = true;
346:
347: /* Set defaults for debugger */
348: ConfigureParams.Debugger.nNumberBase = 10;
349: ConfigureParams.Debugger.nDisasmLines = 8;
350: ConfigureParams.Debugger.nMemdumpLines = 8;
351:
352: /* Set defaults for floppy disk images */
353: ConfigureParams.DiskImage.bAutoInsertDiskB = true;
354: ConfigureParams.DiskImage.bSlowFloppy = false;
355: ConfigureParams.DiskImage.nWriteProtection = WRITEPROT_OFF;
356: for (i = 0; i < 2; i++)
357: {
358: ConfigureParams.DiskImage.szDiskZipPath[i][0] = '\0';
359: ConfigureParams.DiskImage.szDiskFileName[i][0] = '\0';
360: }
361: strcpy(ConfigureParams.DiskImage.szDiskImageDirectory, psWorkingDir);
362: File_AddSlashToEndFileName(ConfigureParams.DiskImage.szDiskImageDirectory);
363:
364: /* Set defaults for hard disks */
365: ConfigureParams.HardDisk.bBootFromHardDisk = false;
366: ConfigureParams.HardDisk.nWriteProtection = WRITEPROT_OFF;
367: ConfigureParams.HardDisk.nHardDiskDir = DRIVE_C;
368: ConfigureParams.HardDisk.bUseHardDiskDirectories = false;
369: for (i = 0; i < MAX_HARDDRIVES; i++)
370: {
371: strcpy(ConfigureParams.HardDisk.szHardDiskDirectories[i], psWorkingDir);
372: File_CleanFileName(ConfigureParams.HardDisk.szHardDiskDirectories[i]);
373: }
374: ConfigureParams.HardDisk.bUseHardDiskImage = false;
375: strcpy(ConfigureParams.HardDisk.szHardDiskImage, psWorkingDir);
376: ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage = false;
377: strcpy(ConfigureParams.HardDisk.szIdeMasterHardDiskImage, psWorkingDir);
378: ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage = false;
379: strcpy(ConfigureParams.HardDisk.szIdeSlaveHardDiskImage, psWorkingDir);
380:
381: /* Set defaults for Joysticks */
382: for (i = 0; i < JOYSTICK_COUNT; i++)
383: {
384: ConfigureParams.Joysticks.Joy[i].nJoystickMode = JOYSTICK_DISABLED;
385: ConfigureParams.Joysticks.Joy[i].bEnableAutoFire = false;
386: ConfigureParams.Joysticks.Joy[i].bEnableJumpOnFire2 = false;
387: ConfigureParams.Joysticks.Joy[i].nJoyId = i;
388: ConfigureParams.Joysticks.Joy[i].nKeyCodeUp = SDLK_UP;
389: ConfigureParams.Joysticks.Joy[i].nKeyCodeDown = SDLK_DOWN;
390: ConfigureParams.Joysticks.Joy[i].nKeyCodeLeft = SDLK_LEFT;
391: ConfigureParams.Joysticks.Joy[i].nKeyCodeRight = SDLK_RIGHT;
392: ConfigureParams.Joysticks.Joy[i].nKeyCodeFire = SDLK_RCTRL;
393: }
394: ConfigureParams.Joysticks.Joy[1].nJoyId = 0; /* ST Joystick #1 is default joystick */
395: ConfigureParams.Joysticks.Joy[0].nJoyId = 1;
396: ConfigureParams.Joysticks.Joy[1].nJoystickMode = JOYSTICK_REALSTICK;
397:
398: /* Set defaults for Keyboard */
399: ConfigureParams.Keyboard.bDisableKeyRepeat = false;
400: ConfigureParams.Keyboard.nKeymapType = KEYMAP_SYMBOLIC;
401: strcpy(ConfigureParams.Keyboard.szMappingFileName, "");
402:
403: /* Set defaults for Shortcuts */
404: ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] = SDLK_F12;
405: ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] = SDLK_F11;
406: ConfigureParams.Shortcut.withoutModifier[SHORTCUT_PAUSE] = SDLK_PAUSE;
407:
408: ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG] = SDLK_PAUSE;
409: ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] = SDLK_o;
410: ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] = SDLK_f;
411: ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] = SDLK_m;
412: ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] = SDLK_c;
413: ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] = SDLK_r;
414: ConfigureParams.Shortcut.withModifier[SHORTCUT_SCREENSHOT] = SDLK_g;
415: ConfigureParams.Shortcut.withModifier[SHORTCUT_BOSSKEY] = SDLK_i;
416: ConfigureParams.Shortcut.withModifier[SHORTCUT_CURSOREMU] = SDLK_j;
417: ConfigureParams.Shortcut.withModifier[SHORTCUT_FASTFORWARD] = SDLK_x;
418: ConfigureParams.Shortcut.withModifier[SHORTCUT_RECANIM] = SDLK_a;
419: ConfigureParams.Shortcut.withModifier[SHORTCUT_RECSOUND] = SDLK_y;
420: ConfigureParams.Shortcut.withModifier[SHORTCUT_SOUND] = SDLK_s;
421: ConfigureParams.Shortcut.withModifier[SHORTCUT_QUIT] = SDLK_q;
422: ConfigureParams.Shortcut.withModifier[SHORTCUT_LOADMEM] = SDLK_l;
423: ConfigureParams.Shortcut.withModifier[SHORTCUT_SAVEMEM] = SDLK_k;
424: ConfigureParams.Shortcut.withModifier[SHORTCUT_INSERTDISKA] = SDLK_d;
425:
426: /* Set defaults for Memory */
427: ConfigureParams.Memory.nMemorySize = 1; /* 1 MiB */
428: ConfigureParams.Memory.bAutoSave = false;
429: sprintf(ConfigureParams.Memory.szMemoryCaptureFileName, "%s%chatari.sav",
430: psHomeDir, PATHSEP);
431: sprintf(ConfigureParams.Memory.szAutoSaveFileName, "%s%cauto.sav",
432: psHomeDir, PATHSEP);
433:
434: /* Set defaults for Printer */
435: ConfigureParams.Printer.bEnablePrinting = false;
436: ConfigureParams.Printer.bPrintToFile = true;
437: sprintf(ConfigureParams.Printer.szPrintToFileName, "%s%chatari.prn",
438: psHomeDir, PATHSEP);
439:
440: /* Set defaults for RS232 */
441: ConfigureParams.RS232.bEnableRS232 = false;
442: strcpy(ConfigureParams.RS232.szOutFileName, "/dev/modem");
443: strcpy(ConfigureParams.RS232.szInFileName, "/dev/modem");
444:
445: /* Set defaults for MIDI */
446: ConfigureParams.Midi.bEnableMidi = false;
447: strcpy(ConfigureParams.Midi.sMidiInFileName, "/dev/snd/midiC1D0");
448: strcpy(ConfigureParams.Midi.sMidiOutFileName, "/dev/snd/midiC1D0");
449:
450: /* Set defaults for Screen */
451: ConfigureParams.Screen.bFullScreen = false;
452: ConfigureParams.Screen.nFrameSkips = AUTO_FRAMESKIP_LIMIT;
453: ConfigureParams.Screen.bAllowOverscan = true;
454: ConfigureParams.Screen.nSpec512Threshold = 16;
455: ConfigureParams.Screen.nForceBpp = 0;
456: ConfigureParams.Screen.bAspectCorrect = true;
457: ConfigureParams.Screen.nMonitorType = MONITOR_TYPE_RGB;
458: ConfigureParams.Screen.bUseExtVdiResolutions = false;
459: ConfigureParams.Screen.bShowStatusbar = true;
460: ConfigureParams.Screen.bShowDriveLed = true;
461: ConfigureParams.Screen.bCaptureChange = false;
462: /* target 800x600 screen with statusbar out of screen */
463: ConfigureParams.Screen.nMaxWidth = 1024;
464: ConfigureParams.Screen.nMaxHeight = 768;
465:
466: /* Set defaults for Sound */
467: ConfigureParams.Sound.bEnableSound = true;
468: ConfigureParams.Sound.nPlaybackFreq = 44100;
469: sprintf(ConfigureParams.Sound.szYMCaptureFileName, "%s%chatari.wav",
470: psWorkingDir, PATHSEP);
471: ConfigureParams.Sound.SdlAudioBufferSize = 0;
472:
473: /* Set defaults for Rom */
474: sprintf(ConfigureParams.Rom.szTosImageFileName, "%s%ctos.img",
475: Paths_GetDataDir(), PATHSEP);
476: strcpy(ConfigureParams.Rom.szCartridgeImageFileName, "");
477:
478: /* Set defaults for System */
479: ConfigureParams.System.nCpuLevel = 4;
480: ConfigureParams.System.nCpuFreq = 8;
481: ConfigureParams.System.bCompatibleCpu = true;
482: /*ConfigureParams.System.bAddressSpace24 = true;*/
483: ConfigureParams.System.nMachineType = MACHINE_ST;
484: ConfigureParams.System.bBlitter = false;
485: ConfigureParams.System.nDSPType = DSP_TYPE_NONE;
486: ConfigureParams.System.bPatchTimerD = true;
487: ConfigureParams.System.bRealTimeClock = true;
488: ConfigureParams.System.bFastForward = false;
489:
490: /* Initialize the configuration file name */
491: if (strlen(psHomeDir) < sizeof(sConfigFileName)-13)
492: sprintf(sConfigFileName, "%s%chatari.cfg", psHomeDir, PATHSEP);
493: else
494: strcpy(sConfigFileName, "hatari.cfg");
495:
496: #if defined(__AMIGAOS4__)
497: /* Fix default path names on Amiga OS */
498: sprintf(ConfigureParams.Rom.szTosImageFileName, "%stos.img", Paths_GetDataDir());
499: #endif
500: }
501:
502:
503: /*-----------------------------------------------------------------------*/
504: /**
505: * Copy details from configuration structure into global variables for system,
506: * clean file names, etc... Called from main.c and dialog.c files.
507: */
508: void Configuration_Apply(bool bReset)
509: {
510: if (bReset)
511: {
512: /* Set resolution change */
513: }
514: if (ConfigureParams.Screen.nFrameSkips < AUTO_FRAMESKIP_LIMIT)
515: {
516: // nFrameSkips = ConfigureParams.Screen.nFrameSkips;
517: }
518:
519: /* Sound settings */
520: /* SDL sound buffer in ms */
521: // SdlAudioBufferSize = ConfigureParams.Sound.SdlAudioBufferSize;
522: // if ( SdlAudioBufferSize == 0 ) /* use default setting for SDL */
523: // ;
524: // else if ( SdlAudioBufferSize < 10 ) /* min of 10 ms */
525: // SdlAudioBufferSize = 10;
526: // else if ( SdlAudioBufferSize > 100 ) /* max of 100 ms */
527: // SdlAudioBufferSize = 100;
528:
529: /* Set playback frequency */
530: // Audio_SetOutputAudioFreq(ConfigureParams.Sound.nPlaybackFreq);
531:
532: /* CPU settings */
533: if (ConfigureParams.System.nCpuFreq < 12)
534: {
535: ConfigureParams.System.nCpuFreq = 8;
536: nCpuFreqShift = 0;
537: }
538: else if (ConfigureParams.System.nCpuFreq > 26)
539: {
540: ConfigureParams.System.nCpuFreq = 32;
541: nCpuFreqShift = 2;
542: }
543: else
544: {
545: ConfigureParams.System.nCpuFreq = 16;
546: nCpuFreqShift = 1;
547: }
548: /* Change UAE cpu_level and cpu_compatible accordingly */
549: M68000_CheckCpuLevel();
550:
551: /* Clean file and directory names */
552: File_MakeAbsoluteName(ConfigureParams.Rom.szTosImageFileName);
553: if (strlen(ConfigureParams.Rom.szCartridgeImageFileName) > 0)
554: File_MakeAbsoluteName(ConfigureParams.Rom.szCartridgeImageFileName);
555: File_MakeAbsoluteName(ConfigureParams.HardDisk.szHardDiskImage);
556: File_CleanFileName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
557: File_MakeAbsoluteName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
558: File_MakeAbsoluteName(ConfigureParams.Memory.szMemoryCaptureFileName);
559: File_MakeAbsoluteName(ConfigureParams.Sound.szYMCaptureFileName);
560: if (strlen(ConfigureParams.Keyboard.szMappingFileName) > 0)
561: File_MakeAbsoluteName(ConfigureParams.Keyboard.szMappingFileName);
562:
563: /* make path names absolute, but handle special file names */
564: File_MakeAbsoluteSpecialName(ConfigureParams.Log.sLogFileName);
565: File_MakeAbsoluteSpecialName(ConfigureParams.Log.sTraceFileName);
566: File_MakeAbsoluteSpecialName(ConfigureParams.RS232.szInFileName);
567: File_MakeAbsoluteSpecialName(ConfigureParams.RS232.szOutFileName);
568: File_MakeAbsoluteSpecialName(ConfigureParams.Midi.sMidiInFileName);
569: File_MakeAbsoluteSpecialName(ConfigureParams.Midi.sMidiOutFileName);
570: File_MakeAbsoluteSpecialName(ConfigureParams.Printer.szPrintToFileName);
571: }
572:
573:
574: /*-----------------------------------------------------------------------*/
575: /**
576: * Load a settings section from the configuration file.
577: */
578: static int Configuration_LoadSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
579: {
580: int ret;
581:
582: ret = input_config(pFilename, configs, pSection);
583:
584: if (ret < 0)
585: fprintf(stderr, "Can not load configuration file %s (section %s).\n",
586: pFilename, pSection);
587:
588: return ret;
589: }
590:
591:
592: /*-----------------------------------------------------------------------*/
593: /**
594: * Load program setting from configuration file. If psFileName is NULL, use
595: * the configuration file given in configuration / last selected by user.
596: */
597: void Configuration_Load(const char *psFileName)
598: {
599: if (psFileName == NULL)
600: psFileName = sConfigFileName;
601:
602: if (!File_Exists(psFileName))
603: {
604: fprintf(stderr, "Configuration file %s not found.\n", psFileName);
605: return;
606: }
607:
608: Configuration_LoadSection(psFileName, configs_Log, "[Log]");
609: Configuration_LoadSection(psFileName, configs_Debugger, "[Debugger]");
610: Configuration_LoadSection(psFileName, configs_Screen, "[Screen]");
611: Configuration_LoadSection(psFileName, configs_Joystick0, "[Joystick0]");
612: Configuration_LoadSection(psFileName, configs_Joystick1, "[Joystick1]");
613: Configuration_LoadSection(psFileName, configs_Joystick2, "[Joystick2]");
614: Configuration_LoadSection(psFileName, configs_Joystick3, "[Joystick3]");
615: Configuration_LoadSection(psFileName, configs_Joystick4, "[Joystick4]");
616: Configuration_LoadSection(psFileName, configs_Joystick5, "[Joystick5]");
617: Configuration_LoadSection(psFileName, configs_Keyboard, "[Keyboard]");
618: Configuration_LoadSection(psFileName, configs_ShortCutWithMod, "[ShortcutsWithModifiers]");
619: Configuration_LoadSection(psFileName, configs_ShortCutWithoutMod, "[ShortcutsWithoutModifiers]");
620: Configuration_LoadSection(psFileName, configs_Sound, "[Sound]");
621: Configuration_LoadSection(psFileName, configs_Memory, "[Memory]");
622: Configuration_LoadSection(psFileName, configs_Floppy, "[Floppy]");
623: Configuration_LoadSection(psFileName, configs_HardDisk, "[HardDisk]");
624: Configuration_LoadSection(psFileName, configs_Rom, "[ROM]");
625: Configuration_LoadSection(psFileName, configs_Rs232, "[RS232]");
626: Configuration_LoadSection(psFileName, configs_Printer, "[Printer]");
627: Configuration_LoadSection(psFileName, configs_Midi, "[Midi]");
628: Configuration_LoadSection(psFileName, configs_System, "[System]");
629: }
630:
631:
632: /*-----------------------------------------------------------------------*/
633: /**
634: * Save a settings section to configuration file
635: */
636: static int Configuration_SaveSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
637: {
638: int ret;
639:
640: ret = update_config(pFilename, configs, pSection);
641:
642: if (ret < 0)
643: fprintf(stderr, "Error while updating section %s in %s\n", pSection, pFilename);
644:
645: return ret;
646: }
647:
648:
649: /*-----------------------------------------------------------------------*/
650: /**
651: * Save program setting to configuration file
652: */
653: void Configuration_Save(void)
654: {
655: if (Configuration_SaveSection(sConfigFileName, configs_Log, "[Log]") < 0)
656: {
657: Log_AlertDlg(LOG_ERROR, "Error saving config file.");
658: return;
659: }
660: Configuration_SaveSection(sConfigFileName, configs_Debugger, "[Debugger]");
661: Configuration_SaveSection(sConfigFileName, configs_Screen, "[Screen]");
662: Configuration_SaveSection(sConfigFileName, configs_Joystick0, "[Joystick0]");
663: Configuration_SaveSection(sConfigFileName, configs_Joystick1, "[Joystick1]");
664: Configuration_SaveSection(sConfigFileName, configs_Joystick2, "[Joystick2]");
665: Configuration_SaveSection(sConfigFileName, configs_Joystick3, "[Joystick3]");
666: Configuration_SaveSection(sConfigFileName, configs_Joystick4, "[Joystick4]");
667: Configuration_SaveSection(sConfigFileName, configs_Joystick5, "[Joystick5]");
668: Configuration_SaveSection(sConfigFileName, configs_Keyboard, "[Keyboard]");
669: Configuration_SaveSection(sConfigFileName, configs_ShortCutWithMod, "[ShortcutsWithModifiers]");
670: Configuration_SaveSection(sConfigFileName, configs_ShortCutWithoutMod, "[ShortcutsWithoutModifiers]");
671: Configuration_SaveSection(sConfigFileName, configs_Sound, "[Sound]");
672: Configuration_SaveSection(sConfigFileName, configs_Memory, "[Memory]");
673: Configuration_SaveSection(sConfigFileName, configs_Floppy, "[Floppy]");
674: Configuration_SaveSection(sConfigFileName, configs_HardDisk, "[HardDisk]");
675: Configuration_SaveSection(sConfigFileName, configs_Rom, "[ROM]");
676: Configuration_SaveSection(sConfigFileName, configs_Rs232, "[RS232]");
677: Configuration_SaveSection(sConfigFileName, configs_Printer, "[Printer]");
678: Configuration_SaveSection(sConfigFileName, configs_Midi, "[Midi]");
679: Configuration_SaveSection(sConfigFileName, configs_System, "[System]");
680: }
681:
682:
683: /*-----------------------------------------------------------------------*/
684: /**
685: * Save/restore snapshot of configuration variables
686: * ('MemorySnapShot_Store' handles type)
687: */
688: void Configuration_MemorySnapShot_Capture(bool bSave)
689: {
690: MemorySnapShot_Store(ConfigureParams.Rom.szTosImageFileName, sizeof(ConfigureParams.Rom.szTosImageFileName));
691: MemorySnapShot_Store(ConfigureParams.Rom.szCartridgeImageFileName, sizeof(ConfigureParams.Rom.szCartridgeImageFileName));
692:
693: MemorySnapShot_Store(&ConfigureParams.Memory.nMemorySize, sizeof(ConfigureParams.Memory.nMemorySize));
694:
695: MemorySnapShot_Store(&ConfigureParams.HardDisk.bUseHardDiskDirectories, sizeof(ConfigureParams.HardDisk.bUseHardDiskDirectories));
696: MemorySnapShot_Store(ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_C], sizeof(ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_C]));
697: MemorySnapShot_Store(&ConfigureParams.HardDisk.bUseHardDiskImage, sizeof(ConfigureParams.HardDisk.bUseHardDiskImage));
698: MemorySnapShot_Store(ConfigureParams.HardDisk.szHardDiskImage, sizeof(ConfigureParams.HardDisk.szHardDiskImage));
699:
700: MemorySnapShot_Store(&ConfigureParams.Screen.nMonitorType, sizeof(ConfigureParams.Screen.nMonitorType));
701: MemorySnapShot_Store(&ConfigureParams.Screen.bUseExtVdiResolutions, sizeof(ConfigureParams.Screen.bUseExtVdiResolutions));
702: MemorySnapShot_Store(&ConfigureParams.Screen.nVdiWidth, sizeof(ConfigureParams.Screen.nVdiWidth));
703: MemorySnapShot_Store(&ConfigureParams.Screen.nVdiHeight, sizeof(ConfigureParams.Screen.nVdiHeight));
704: MemorySnapShot_Store(&ConfigureParams.Screen.nVdiColors, sizeof(ConfigureParams.Screen.nVdiColors));
705:
706: MemorySnapShot_Store(&ConfigureParams.System.nCpuLevel, sizeof(ConfigureParams.System.nCpuLevel));
707: MemorySnapShot_Store(&ConfigureParams.System.nCpuFreq, sizeof(ConfigureParams.System.nCpuFreq));
708: MemorySnapShot_Store(&ConfigureParams.System.bCompatibleCpu, sizeof(ConfigureParams.System.bCompatibleCpu));
709: MemorySnapShot_Store(&ConfigureParams.System.nMachineType, sizeof(ConfigureParams.System.nMachineType));
710: MemorySnapShot_Store(&ConfigureParams.System.bBlitter, sizeof(ConfigureParams.System.bBlitter));
711: MemorySnapShot_Store(&ConfigureParams.System.nDSPType, sizeof(ConfigureParams.System.nDSPType));
712: MemorySnapShot_Store(&ConfigureParams.System.bRealTimeClock, sizeof(ConfigureParams.System.bRealTimeClock));
713: MemorySnapShot_Store(&ConfigureParams.System.bPatchTimerD, sizeof(ConfigureParams.System.bPatchTimerD));
714: MemorySnapShot_Store(&ConfigureParams.DiskImage.bSlowFloppy, sizeof(ConfigureParams.DiskImage.bSlowFloppy));
715:
716: if (!bSave)
717: Configuration_Apply(true);
718: }
719:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.