|
|
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:
1.1.1.4 root 14: #include <SDL_keyboard.h>
1.1 root 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 "paths.h"
23: #include "screen.h"
24: #include "video.h"
25:
26: CNF_PARAMS ConfigureParams; /* List of configuration for the emulator */
27: char sConfigFileName[FILENAME_MAX]; /* Stores the name of the configuration file */
28:
29:
30: /* Used to load/save logging options */
31: static const struct Config_Tag configs_Log[] =
32: {
33: { "sLogFileName", String_Tag, ConfigureParams.Log.sLogFileName },
34: { "sTraceFileName", String_Tag, ConfigureParams.Log.sTraceFileName },
35: { "nTextLogLevel", Int_Tag, &ConfigureParams.Log.nTextLogLevel },
36: { "nAlertDlgLogLevel", Int_Tag, &ConfigureParams.Log.nAlertDlgLogLevel },
37: { "bConfirmQuit", Bool_Tag, &ConfigureParams.Log.bConfirmQuit },
38: { NULL , Error_Tag, NULL }
39: };
40:
1.1.1.3 root 41: /* Used to load/save configuration dialog options */
42: static const struct Config_Tag configs_ConfigDialog[] =
43: {
44: { "bShowConfigDialogAtStartup", Bool_Tag, &ConfigureParams.ConfigDialog.bShowConfigDialogAtStartup },
45: { NULL , Error_Tag, NULL }
46: };
47:
1.1 root 48: /* Used to load/save debugger options */
49: static const struct Config_Tag configs_Debugger[] =
50: {
51: { "nNumberBase", Int_Tag, &ConfigureParams.Debugger.nNumberBase },
52: { "nDisasmLines", Int_Tag, &ConfigureParams.Debugger.nDisasmLines },
53: { "nMemdumpLines", Int_Tag, &ConfigureParams.Debugger.nMemdumpLines },
54: { NULL , Error_Tag, NULL }
55: };
56:
57: /* Used to load/save screen options */
58: static const struct Config_Tag configs_Screen[] =
59: {
60: { "nMonitorType", Int_Tag, &ConfigureParams.Screen.nMonitorType },
61: { "bFullScreen", Bool_Tag, &ConfigureParams.Screen.bFullScreen },
62: { "bShowStatusbar", Bool_Tag, &ConfigureParams.Screen.bShowStatusbar },
63: { "bShowDriveLed", Bool_Tag, &ConfigureParams.Screen.bShowDriveLed },
64: { NULL , Error_Tag, NULL }
65: };
66:
67: /* Used to load/save keyboard options */
68: static const struct Config_Tag configs_Keyboard[] =
69: {
1.1.1.4 root 70: { "bSwapCmdAlt", Bool_Tag, &ConfigureParams.Keyboard.bSwapCmdAlt },
1.1 root 71: { "nKeymapType", Int_Tag, &ConfigureParams.Keyboard.nKeymapType },
72: { "szMappingFileName", String_Tag, ConfigureParams.Keyboard.szMappingFileName },
73: { NULL , Error_Tag, NULL }
74: };
75:
1.1.1.4 root 76: /* Used to load/save mouse options */
77: static const struct Config_Tag configs_Mouse[] =
78: {
79: { "bEnableAutoGrab", Bool_Tag, &ConfigureParams.Mouse.bEnableAutoGrab },
80: { "fLinSpeedNormal", Float_Tag, &ConfigureParams.Mouse.fLinSpeedNormal },
81: { "fLinSpeedLocked", Float_Tag, &ConfigureParams.Mouse.fLinSpeedLocked },
82: { "fExpSpeedNormal", Float_Tag, &ConfigureParams.Mouse.fExpSpeedNormal },
83: { "fExpSpeedLocked", Float_Tag, &ConfigureParams.Mouse.fExpSpeedLocked },
84: { NULL , Error_Tag, NULL }
85: };
86:
1.1 root 87: /* Used to load/save shortcut key bindings with modifiers options */
88: static const struct Config_Tag configs_ShortCutWithMod[] =
89: {
1.1.1.5 ! root 90: { "keyOptions", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] },
! 91: { "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] },
! 92: { "keyMouseMode", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] },
! 93: { "keyColdReset", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] },
! 94: { "keyWarmReset", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] },
! 95: { "keyCursorEmu", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_CURSOREMU] },
! 96: { "keySound", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_SOUND] },
! 97: { "keyPause", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_PAUSE] },
! 98: { "keyDebuggerM68K",Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG_M68K] },
! 99: { "keyDebuggerI860",Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG_I860] },
! 100: { "keyQuit", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_QUIT] },
! 101: { "keyDimension", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_DIMENSION] },
1.1 root 102: { NULL , Error_Tag, NULL }
103: };
104:
105: /* Used to load/save shortcut key bindings without modifiers options */
106: static const struct Config_Tag configs_ShortCutWithoutMod[] =
107: {
1.1.1.5 ! root 108: { "keyOptions", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] },
! 109: { "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] },
! 110: { "keyMouseMode", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_MOUSEGRAB] },
! 111: { "keyColdReset", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_COLDRESET] },
! 112: { "keyWarmReset", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_WARMRESET] },
! 113: { "keyCursorEmu", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_CURSOREMU] },
! 114: { "keySound", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_SOUND] },
! 115: { "keyPause", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_PAUSE] },
! 116: { "keyDebuggerM68K",Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_DEBUG_M68K] },
! 117: { "keyDebuggerI860",Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_DEBUG_I860] },
! 118: { "keyQuit", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_QUIT] },
! 119: { "keyDimension", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_DIMENSION] },
1.1 root 120: { NULL , Error_Tag, NULL }
121: };
122:
123:
124: /* Used to load/save sound options */
125: static const struct Config_Tag configs_Sound[] =
126: {
1.1.1.2 root 127: { "bEnableMicrophone", Bool_Tag, &ConfigureParams.Sound.bEnableMicrophone },
128: { "bEnableSound", Bool_Tag, &ConfigureParams.Sound.bEnableSound },
1.1 root 129: { NULL , Error_Tag, NULL }
130: };
131:
132: /* Used to load/save memory options */
133: static const struct Config_Tag configs_Memory[] =
134: {
1.1.1.3 root 135: { "nMemoryBankSize0", Int_Tag, &ConfigureParams.Memory.nMemoryBankSize[0] },
136: { "nMemoryBankSize1", Int_Tag, &ConfigureParams.Memory.nMemoryBankSize[1] },
137: { "nMemoryBankSize2", Int_Tag, &ConfigureParams.Memory.nMemoryBankSize[2] },
138: { "nMemoryBankSize3", Int_Tag, &ConfigureParams.Memory.nMemoryBankSize[3] },
139: { "nMemorySpeed", Int_Tag, &ConfigureParams.Memory.nMemorySpeed },
1.1 root 140: { NULL , Error_Tag, NULL }
141: };
142:
1.1.1.3 root 143: /* Used to load/save boot options */
144: static const struct Config_Tag configs_Boot[] =
1.1 root 145: {
1.1.1.3 root 146: { "nBootDevice", Int_Tag, &ConfigureParams.Boot.nBootDevice },
147: { "bEnableDRAMTest", Bool_Tag, &ConfigureParams.Boot.bEnableDRAMTest },
148: { "bEnablePot", Bool_Tag, &ConfigureParams.Boot.bEnablePot },
149: { "bEnableSoundTest", Bool_Tag, &ConfigureParams.Boot.bEnableSoundTest },
150: { "bEnableSCSITest", Bool_Tag, &ConfigureParams.Boot.bEnableSCSITest },
151: { "bLoopPot", Bool_Tag, &ConfigureParams.Boot.bLoopPot },
152: { "bVerbose", Bool_Tag, &ConfigureParams.Boot.bVerbose },
153: { "bExtendedPot", Bool_Tag, &ConfigureParams.Boot.bExtendedPot },
154: { NULL , Error_Tag, NULL }
155: };
156:
157: /* Used to load/save SCSI options */
158: static const struct Config_Tag configs_SCSI[] =
159: {
160: { "szImageName0", String_Tag, ConfigureParams.SCSI.target[0].szImageName },
1.1.1.4 root 161: { "nDeviceType0", Int_Tag, &ConfigureParams.SCSI.target[0].nDeviceType },
162: { "bDiskInserted0", Bool_Tag, &ConfigureParams.SCSI.target[0].bDiskInserted },
163: { "bWriteProtected0", Bool_Tag, &ConfigureParams.SCSI.target[0].bWriteProtected },
1.1.1.3 root 164:
165: { "szImageName1", String_Tag, ConfigureParams.SCSI.target[1].szImageName },
1.1.1.4 root 166: { "nDeviceType1", Int_Tag, &ConfigureParams.SCSI.target[1].nDeviceType },
167: { "bDiskInserted1", Bool_Tag, &ConfigureParams.SCSI.target[1].bDiskInserted },
168: { "bWriteProtected1", Bool_Tag, &ConfigureParams.SCSI.target[1].bWriteProtected },
1.1.1.3 root 169:
170: { "szImageName2", String_Tag, ConfigureParams.SCSI.target[2].szImageName },
1.1.1.4 root 171: { "nDeviceType2", Int_Tag, &ConfigureParams.SCSI.target[2].nDeviceType },
172: { "bDiskInserted2", Bool_Tag, &ConfigureParams.SCSI.target[2].bDiskInserted },
173: { "bWriteProtected2", Bool_Tag, &ConfigureParams.SCSI.target[2].bWriteProtected },
1.1.1.3 root 174:
175: { "szImageName3", String_Tag, ConfigureParams.SCSI.target[3].szImageName },
1.1.1.4 root 176: { "nDeviceType3", Int_Tag, &ConfigureParams.SCSI.target[3].nDeviceType },
177: { "bDiskInserted3", Bool_Tag, &ConfigureParams.SCSI.target[3].bDiskInserted },
178: { "bWriteProtected3", Bool_Tag, &ConfigureParams.SCSI.target[3].bWriteProtected },
1.1.1.3 root 179:
180: { "szImageName4", String_Tag, ConfigureParams.SCSI.target[4].szImageName },
1.1.1.4 root 181: { "nDeviceType4", Int_Tag, &ConfigureParams.SCSI.target[4].nDeviceType },
182: { "bDiskInserted4", Bool_Tag, &ConfigureParams.SCSI.target[4].bDiskInserted },
183: { "bWriteProtected4", Bool_Tag, &ConfigureParams.SCSI.target[4].bWriteProtected },
1.1.1.3 root 184:
185: { "szImageName5", String_Tag, ConfigureParams.SCSI.target[5].szImageName },
1.1.1.4 root 186: { "nDeviceType5", Int_Tag, &ConfigureParams.SCSI.target[5].nDeviceType },
187: { "bDiskInserted5", Bool_Tag, &ConfigureParams.SCSI.target[5].bDiskInserted },
188: { "bWriteProtected5", Bool_Tag, &ConfigureParams.SCSI.target[5].bWriteProtected },
1.1.1.3 root 189:
190: { "szImageName6", String_Tag, ConfigureParams.SCSI.target[6].szImageName },
1.1.1.4 root 191: { "nDeviceType6", Int_Tag, &ConfigureParams.SCSI.target[6].nDeviceType },
192: { "bDiskInserted6", Bool_Tag, &ConfigureParams.SCSI.target[6].bDiskInserted },
193: { "bWriteProtected6", Bool_Tag, &ConfigureParams.SCSI.target[6].bWriteProtected },
194:
1.1.1.5 ! root 195: { "nWriteProtection", Int_Tag, &ConfigureParams.SCSI.nWriteProtection },
! 196:
1.1.1.4 root 197: { NULL , Error_Tag, NULL }
198: };
199:
200: /* Used to load/save MO options */
201: static const struct Config_Tag configs_MO[] =
202: {
203: { "szImageName0", String_Tag, ConfigureParams.MO.drive[0].szImageName },
204: { "bDriveConnected0", Bool_Tag, &ConfigureParams.MO.drive[0].bDriveConnected },
205: { "bDiskInserted0", Bool_Tag, &ConfigureParams.MO.drive[0].bDiskInserted },
206: { "bWriteProtected0", Bool_Tag, &ConfigureParams.MO.drive[0].bWriteProtected },
207:
208: { "szImageName1", String_Tag, ConfigureParams.MO.drive[1].szImageName },
209: { "bDriveConnected1", Bool_Tag, &ConfigureParams.MO.drive[1].bDriveConnected },
210: { "bDiskInserted1", Bool_Tag, &ConfigureParams.MO.drive[1].bDiskInserted },
211: { "bWriteProtected1", Bool_Tag, &ConfigureParams.MO.drive[1].bWriteProtected },
1.1.1.3 root 212:
1.1 root 213: { NULL , Error_Tag, NULL }
214: };
215:
1.1.1.4 root 216: /* Used to load/save floppy options */
217: static const struct Config_Tag configs_Floppy[] =
218: {
219: { "szImageName0", String_Tag, ConfigureParams.Floppy.drive[0].szImageName },
220: { "bDriveConnected0", Bool_Tag, &ConfigureParams.Floppy.drive[0].bDriveConnected },
221: { "bDiskInserted0", Bool_Tag, &ConfigureParams.Floppy.drive[0].bDiskInserted },
222: { "bWriteProtected0", Bool_Tag, &ConfigureParams.Floppy.drive[0].bWriteProtected },
223:
224: { "szImageName1", String_Tag, ConfigureParams.Floppy.drive[1].szImageName },
225: { "bDriveConnected1", Bool_Tag, &ConfigureParams.Floppy.drive[1].bDriveConnected },
226: { "bDiskInserted1", Bool_Tag, &ConfigureParams.Floppy.drive[1].bDiskInserted },
227: { "bWriteProtected1", Bool_Tag, &ConfigureParams.Floppy.drive[1].bWriteProtected },
228:
229: { NULL , Error_Tag, NULL }
230: };
231:
232: /* Used to load/save Ethernet options */
233: static const struct Config_Tag configs_Ethernet[] =
234: {
235: { "bEthernetConnected", Bool_Tag, &ConfigureParams.Ethernet.bEthernetConnected },
1.1.1.5 ! root 236: { "bTwistedPair", Bool_Tag, &ConfigureParams.Ethernet.bTwistedPair },
! 237:
1.1.1.4 root 238: { NULL , Error_Tag, NULL }
239: };
240:
1.1 root 241: /* Used to load/save ROM options */
242: static const struct Config_Tag configs_Rom[] =
243: {
1.1.1.3 root 244: { "szRom030FileName", String_Tag, ConfigureParams.Rom.szRom030FileName },
245: { "szRom040FileName", String_Tag, ConfigureParams.Rom.szRom040FileName },
246: { "szRomTurboFileName", String_Tag, ConfigureParams.Rom.szRomTurboFileName },
1.1 root 247: { NULL , Error_Tag, NULL }
248: };
249:
250: /* Used to load/save printer options */
251: static const struct Config_Tag configs_Printer[] =
252: {
1.1.1.4 root 253: { "bPrinterConnected", Bool_Tag, &ConfigureParams.Printer.bPrinterConnected },
254: { "nPaperSize", Int_Tag, &ConfigureParams.Printer.nPaperSize },
1.1 root 255: { "szPrintToFileName", String_Tag, ConfigureParams.Printer.szPrintToFileName },
256: { NULL , Error_Tag, NULL }
257: };
258:
259: /* Used to load/save system options */
260: static const struct Config_Tag configs_System[] =
261: {
1.1.1.3 root 262: { "nMachineType", Int_Tag, &ConfigureParams.System.nMachineType },
263: { "bColor", Bool_Tag, &ConfigureParams.System.bColor },
264: { "bTurbo", Bool_Tag, &ConfigureParams.System.bTurbo },
1.1.1.4 root 265: { "bNBIC", Bool_Tag, &ConfigureParams.System.bNBIC },
1.1.1.3 root 266: { "nSCSI", Bool_Tag, &ConfigureParams.System.nSCSI },
267: { "nRTC", Bool_Tag, &ConfigureParams.System.nRTC },
268:
1.1 root 269: { "nCpuLevel", Int_Tag, &ConfigureParams.System.nCpuLevel },
270: { "nCpuFreq", Int_Tag, &ConfigureParams.System.nCpuFreq },
271: { "bCompatibleCpu", Bool_Tag, &ConfigureParams.System.bCompatibleCpu },
1.1.1.5 ! root 272: { "bRealtime", Bool_Tag, &ConfigureParams.System.bRealtime },
1.1 root 273: { "nDSPType", Int_Tag, &ConfigureParams.System.nDSPType },
1.1.1.4 root 274: { "bDSPMemoryExpansion", Bool_Tag, &ConfigureParams.System.bDSPMemoryExpansion },
1.1 root 275: { "bRealTimeClock", Bool_Tag, &ConfigureParams.System.bRealTimeClock },
1.1.1.2 root 276: { "n_FPUType", Int_Tag, &ConfigureParams.System.n_FPUType },
277: { "bCompatibleFPU", Bool_Tag, &ConfigureParams.System.bCompatibleFPU },
278: { "bMMU", Bool_Tag, &ConfigureParams.System.bMMU },
279: { NULL , Error_Tag, NULL }
1.1.1.4 root 280: };
281:
282: /* Used to load/save nextdimension options */
283: static const struct Config_Tag configs_Dimension[] =
284: {
1.1.1.5 ! root 285: { "bEnabled", Bool_Tag, &ConfigureParams.Dimension.bEnabled },
! 286: { "bI860Thread", Bool_Tag, &ConfigureParams.Dimension.bI860Thread },
! 287: { "bMainDisplay", Bool_Tag, &ConfigureParams.Dimension.bMainDisplay },
! 288: { "nMemoryBankSize0", Int_Tag, &ConfigureParams.Dimension.nMemoryBankSize[0] },
! 289: { "nMemoryBankSize1", Int_Tag, &ConfigureParams.Dimension.nMemoryBankSize[1] },
! 290: { "nMemoryBankSize2", Int_Tag, &ConfigureParams.Dimension.nMemoryBankSize[2] },
! 291: { "nMemoryBankSize3", Int_Tag, &ConfigureParams.Dimension.nMemoryBankSize[3] },
! 292: { "szRomFileName", String_Tag, ConfigureParams.Dimension.szRomFileName },
1.1.1.4 root 293: { NULL , Error_Tag, NULL }
294: };
1.1.1.2 root 295:
1.1 root 296: /*-----------------------------------------------------------------------*/
297: /**
298: * Set default configuration values.
299: */
300: void Configuration_SetDefault(void)
301: {
302: int i;
303: const char *psHomeDir;
304: const char *psWorkingDir;
305:
306: psHomeDir = Paths_GetHatariHome();
307: psWorkingDir = Paths_GetWorkingDir();
308:
309: /* Clear parameters */
310: memset(&ConfigureParams, 0, sizeof(CNF_PARAMS));
311:
1.1.1.3 root 312:
1.1 root 313: /* Set defaults for logging and tracing */
314: strcpy(ConfigureParams.Log.sLogFileName, "stderr");
315: strcpy(ConfigureParams.Log.sTraceFileName, "stderr");
316: ConfigureParams.Log.nTextLogLevel = LOG_TODO;
317: ConfigureParams.Log.nAlertDlgLogLevel = LOG_ERROR;
318: ConfigureParams.Log.bConfirmQuit = true;
1.1.1.3 root 319:
320: /* Set defaults for config dialog */
321: ConfigureParams.ConfigDialog.bShowConfigDialogAtStartup = true;
1.1 root 322:
323: /* Set defaults for debugger */
324: ConfigureParams.Debugger.nNumberBase = 10;
325: ConfigureParams.Debugger.nDisasmLines = 8;
326: ConfigureParams.Debugger.nMemdumpLines = 8;
327:
1.1.1.3 root 328: /* Set defaults for Boot options */
329: ConfigureParams.Boot.nBootDevice = BOOT_ROM;
330: ConfigureParams.Boot.bEnableDRAMTest = false;
331: ConfigureParams.Boot.bEnablePot = true;
332: ConfigureParams.Boot.bEnableSoundTest = true;
333: ConfigureParams.Boot.bEnableSCSITest = true;
334: ConfigureParams.Boot.bLoopPot = false;
335: ConfigureParams.Boot.bVerbose = true;
336: ConfigureParams.Boot.bExtendedPot = false;
337:
338: /* Set defaults for SCSI disks */
1.1.1.4 root 339: for (i = 0; i < ESP_MAX_DEVS; i++) {
340: strcpy(ConfigureParams.SCSI.target[i].szImageName, psWorkingDir);
341: ConfigureParams.SCSI.target[i].nDeviceType = DEVTYPE_NONE;
342: ConfigureParams.SCSI.target[i].bDiskInserted = false;
343: ConfigureParams.SCSI.target[i].bWriteProtected = false;
1.1.1.3 root 344: }
1.1.1.5 ! root 345: ConfigureParams.SCSI.nWriteProtection = WRITEPROT_OFF;
1.1.1.3 root 346:
1.1.1.4 root 347: /* Set defaults for MO drives */
348: for (i = 0; i < MO_MAX_DRIVES; i++) {
349: strcpy(ConfigureParams.MO.drive[i].szImageName, psWorkingDir);
350: ConfigureParams.MO.drive[i].bDriveConnected = false;
351: ConfigureParams.MO.drive[i].bDiskInserted = false;
352: ConfigureParams.MO.drive[i].bWriteProtected = false;
353: }
354:
355: /* Set defaults for floppy drives */
356: for (i = 0; i < FLP_MAX_DRIVES; i++) {
357: strcpy(ConfigureParams.Floppy.drive[i].szImageName, psWorkingDir);
358: ConfigureParams.Floppy.drive[i].bDriveConnected = false;
359: ConfigureParams.Floppy.drive[i].bDiskInserted = false;
360: ConfigureParams.Floppy.drive[i].bWriteProtected = false;
361: }
362:
363: /* Set defaults for Ethernet */
364: ConfigureParams.Ethernet.bEthernetConnected = false;
1.1.1.5 ! root 365: ConfigureParams.Ethernet.bTwistedPair = false;
1.1.1.4 root 366:
1.1 root 367: /* Set defaults for Keyboard */
1.1.1.4 root 368: ConfigureParams.Keyboard.bSwapCmdAlt = false;
369: ConfigureParams.Keyboard.nKeymapType = KEYMAP_SCANCODE;
1.1 root 370: strcpy(ConfigureParams.Keyboard.szMappingFileName, "");
1.1.1.4 root 371:
372: /* Set defaults for Mouse */
373: ConfigureParams.Mouse.fLinSpeedNormal = 1.0;
374: ConfigureParams.Mouse.fLinSpeedLocked = 1.0;
375: ConfigureParams.Mouse.fExpSpeedNormal = 1.0;
376: ConfigureParams.Mouse.fExpSpeedLocked = 1.0;
377: ConfigureParams.Mouse.bEnableAutoGrab = true;
378:
1.1 root 379: /* Set defaults for Shortcuts */
1.1.1.5 ! root 380: ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] = SDLK_F12;
1.1 root 381: ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] = SDLK_F11;
1.1.1.2 root 382:
1.1.1.5 ! root 383: ConfigureParams.Shortcut.withModifier[SHORTCUT_PAUSE] = SDLK_p;
! 384: ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG_M68K] = SDLK_d;
! 385: ConfigureParams.Shortcut.withModifier[SHORTCUT_DEBUG_I860] = SDLK_i;
! 386:
! 387: ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] = SDLK_o;
! 388: ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] = SDLK_f;
! 389: ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEGRAB] = SDLK_m;
! 390: ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] = SDLK_c;
! 391: ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] = SDLK_r;
! 392: ConfigureParams.Shortcut.withModifier[SHORTCUT_CURSOREMU] = SDLK_j;
! 393: ConfigureParams.Shortcut.withModifier[SHORTCUT_SOUND] = SDLK_s;
! 394: ConfigureParams.Shortcut.withModifier[SHORTCUT_QUIT] = SDLK_q;
! 395: ConfigureParams.Shortcut.withModifier[SHORTCUT_DIMENSION] = SDLK_n;
1.1 root 396:
397: /* Set defaults for Memory */
1.1.1.3 root 398: memset(ConfigureParams.Memory.nMemoryBankSize, 16,
399: sizeof(ConfigureParams.Memory.nMemoryBankSize)); /* 64 MiB */
400: ConfigureParams.Memory.nMemorySpeed = MEMORY_100NS;
1.1 root 401:
402: /* Set defaults for Printer */
1.1.1.4 root 403: ConfigureParams.Printer.bPrinterConnected = false;
404: ConfigureParams.Printer.nPaperSize = PAPER_A4;
405: sprintf(ConfigureParams.Printer.szPrintToFileName, "%s%c",
1.1 root 406: psHomeDir, PATHSEP);
407:
408: /* Set defaults for Screen */
409: ConfigureParams.Screen.bFullScreen = false;
1.1.1.4 root 410: ConfigureParams.Screen.nMonitorType = MONITOR_TYPE_CPU;
1.1 root 411: ConfigureParams.Screen.bShowStatusbar = true;
412: ConfigureParams.Screen.bShowDriveLed = true;
413:
414: /* Set defaults for Sound */
1.1.1.2 root 415: ConfigureParams.Sound.bEnableMicrophone = true;
1.1 root 416: ConfigureParams.Sound.bEnableSound = true;
417:
418: /* Set defaults for Rom */
1.1.1.3 root 419: sprintf(ConfigureParams.Rom.szRom030FileName, "%s%cRev_1.0_v41.BIN",
420: Paths_GetWorkingDir(), PATHSEP);
421: sprintf(ConfigureParams.Rom.szRom040FileName, "%s%cRev_2.5_v66.BIN",
422: Paths_GetWorkingDir(), PATHSEP);
423: sprintf(ConfigureParams.Rom.szRomTurboFileName, "%s%cRev_3.3_v74.BIN",
424: Paths_GetWorkingDir(), PATHSEP);
425:
1.1 root 426:
427: /* Set defaults for System */
1.1.1.3 root 428: ConfigureParams.System.nMachineType = NEXT_CUBE030;
429: ConfigureParams.System.bColor = false;
430: ConfigureParams.System.bTurbo = false;
1.1.1.4 root 431: ConfigureParams.System.bNBIC = true;
1.1.1.3 root 432: ConfigureParams.System.nSCSI = NCR53C90;
433: ConfigureParams.System.nRTC = MC68HC68T1;
434:
435: ConfigureParams.System.nCpuLevel = 3;
436: ConfigureParams.System.nCpuFreq = 25;
1.1 root 437: ConfigureParams.System.bCompatibleCpu = true;
1.1.1.5 ! root 438: ConfigureParams.System.bRealtime = false;
1.1.1.4 root 439: ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
440: ConfigureParams.System.bDSPMemoryExpansion = false;
1.1 root 441: ConfigureParams.System.bRealTimeClock = true;
1.1.1.3 root 442: ConfigureParams.System.n_FPUType = FPU_68882;
1.1.1.2 root 443: ConfigureParams.System.bCompatibleFPU = true;
444: ConfigureParams.System.bMMU = true;
1.1.1.4 root 445:
446: /* Set defaults for Dimension */
1.1.1.5 ! root 447: ConfigureParams.Dimension.bI860Thread = host_num_cpus() > 4;
! 448: ConfigureParams.Dimension.bEnabled = false;
! 449: ConfigureParams.Dimension.bMainDisplay = false;
1.1.1.4 root 450: ConfigureParams.Dimension.nMemoryBankSize[0] = 4;
451: ConfigureParams.Dimension.nMemoryBankSize[1] = 4;
452: ConfigureParams.Dimension.nMemoryBankSize[2] = 4;
453: ConfigureParams.Dimension.nMemoryBankSize[3] = 4;
454: sprintf(ConfigureParams.Dimension.szRomFileName, "%s%cdimension_eeprom.bin",
455: Paths_GetWorkingDir(), PATHSEP);
1.1.1.2 root 456:
1.1 root 457: /* Initialize the configuration file name */
458: if (strlen(psHomeDir) < sizeof(sConfigFileName)-13)
1.1.1.2 root 459: sprintf(sConfigFileName, "%s%cprevious.cfg", psHomeDir, PATHSEP);
1.1 root 460: else
1.1.1.2 root 461: strcpy(sConfigFileName, "previous.cfg");
1.1 root 462:
463: #if defined(__AMIGAOS4__)
464: /* Fix default path names on Amiga OS */
1.1.1.3 root 465: sprintf(ConfigureParams.Rom.szRom030FileName, "%sRev_1.0_v41.BIN", Paths_GetWorkingDir());
466: sprintf(ConfigureParams.Rom.szRom040FileName, "%sRev_2.5_v66.BIN", Paths_GetWorkingDir());
467: sprintf(ConfigureParams.Rom.szRom040FileName, "%sRev_3.3_v74.BIN", Paths_GetWorkingDir());
1.1 root 468: #endif
469: }
470:
471:
472: /*-----------------------------------------------------------------------*/
473: /**
1.1.1.4 root 474: * Helper function for Configuration_Apply, check mouse speed settings
475: * to be in the valid range between minimum and maximum value.
476: */
1.1.1.5 ! root 477: static void Configuration_CheckFloatMinMax(float *val, float min, float max)
1.1.1.4 root 478: {
479: if (*val<min)
480: *val=min;
481: if (*val>max)
482: *val=max;
483: }
484:
485:
486: /*-----------------------------------------------------------------------*/
487: /**
1.1 root 488: * Copy details from configuration structure into global variables for system,
489: * clean file names, etc... Called from main.c and dialog.c files.
490: */
1.1.1.5 ! root 491: void Configuration_Apply(bool bReset) {
1.1.1.4 root 492: /* Mouse settings */
493: Configuration_CheckFloatMinMax(&ConfigureParams.Mouse.fLinSpeedNormal,MOUSE_LIN_MIN,MOUSE_LIN_MAX);
494: Configuration_CheckFloatMinMax(&ConfigureParams.Mouse.fLinSpeedLocked,MOUSE_LIN_MIN,MOUSE_LIN_MAX);
495: Configuration_CheckFloatMinMax(&ConfigureParams.Mouse.fExpSpeedNormal,MOUSE_EXP_MIN,MOUSE_EXP_MAX);
496: Configuration_CheckFloatMinMax(&ConfigureParams.Mouse.fExpSpeedLocked,MOUSE_EXP_MIN,MOUSE_EXP_MAX);
1.1.1.2 root 497:
498: /* Check/constrain CPU settings and change corresponding
1.1.1.4 root 499: * UAE cpu_level & cpu_compatible variables */
1.1.1.2 root 500: M68000_CheckCpuSettings();
501:
1.1.1.3 root 502: /* Check memory size for each bank and change to supported values */
503: Configuration_CheckMemory(ConfigureParams.Memory.nMemoryBankSize);
1.1.1.4 root 504:
505: /* Check nextdimension memory size and screen options */
506: Configuration_CheckDimensionMemory(ConfigureParams.Dimension.nMemoryBankSize);
507: Configuration_CheckDimensionSettings();
1.1.1.5 ! root 508:
! 509: /* Make sure twisted pair ethernet is disabled on 68030 Cube */
! 510: Configuration_CheckEthernetSettings();
1.1.1.4 root 511:
1.1.1.3 root 512: /* Clean file and directory names */
513: File_MakeAbsoluteName(ConfigureParams.Rom.szRom030FileName);
514: File_MakeAbsoluteName(ConfigureParams.Rom.szRom040FileName);
515: File_MakeAbsoluteName(ConfigureParams.Rom.szRomTurboFileName);
1.1.1.4 root 516: File_MakeAbsoluteName(ConfigureParams.Dimension.szRomFileName);
517: File_MakeAbsoluteName(ConfigureParams.Printer.szPrintToFileName);
518:
519: int i;
520: for (i = 0; i < ESP_MAX_DEVS; i++) {
521: File_MakeAbsoluteName(ConfigureParams.SCSI.target[i].szImageName);
522: }
1.1.1.3 root 523:
1.1.1.4 root 524: for (i = 0; i < MO_MAX_DRIVES; i++) {
525: File_MakeAbsoluteName(ConfigureParams.MO.drive[i].szImageName);
526: }
527:
528: for (i = 0; i < FLP_MAX_DRIVES; i++) {
529: File_MakeAbsoluteName(ConfigureParams.Floppy.drive[i].szImageName);
1.1.1.3 root 530: }
531:
1.1 root 532: /* make path names absolute, but handle special file names */
533: File_MakeAbsoluteSpecialName(ConfigureParams.Log.sLogFileName);
534: File_MakeAbsoluteSpecialName(ConfigureParams.Log.sTraceFileName);
1.1.1.4 root 535: }
536:
537:
538: /*-----------------------------------------------------------------------*/
539: /**
540: * Set defaults depending on selected machine type.
541: */
542: void Configuration_SetSystemDefaults(void) {
1.1.1.5 ! root 543: for(int i = 0; i < MO_MAX_DRIVES; i++)
! 544: if(ConfigureParams.MO.drive[i].bDriveConnected)
! 545: ConfigureParams.System.bRealtime = false;
! 546:
1.1.1.4 root 547: switch (ConfigureParams.System.nMachineType) {
548: case NEXT_CUBE030:
549: ConfigureParams.System.bTurbo = false;
550: ConfigureParams.System.bColor = false;
551: ConfigureParams.System.nCpuLevel = 3;
552: ConfigureParams.System.nCpuFreq = 25;
553: ConfigureParams.System.n_FPUType = FPU_68882;
554: ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
555: ConfigureParams.System.bDSPMemoryExpansion = false;
556: ConfigureParams.System.nSCSI = NCR53C90;
557: ConfigureParams.System.nRTC = MC68HC68T1;
558: ConfigureParams.System.bNBIC = true;
559: break;
560:
561: case NEXT_CUBE040:
562: ConfigureParams.System.bColor = false;
563: ConfigureParams.System.nCpuLevel = 4;
564: if (ConfigureParams.System.bTurbo) {
565: ConfigureParams.System.nCpuFreq = 33;
566: ConfigureParams.System.nRTC = MCCS1850;
567: } else {
568: ConfigureParams.System.nCpuFreq = 25;
569: ConfigureParams.System.nRTC = MC68HC68T1;
570: }
571: ConfigureParams.System.n_FPUType = FPU_CPU;
572: ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
573: ConfigureParams.System.bDSPMemoryExpansion = true;
574: ConfigureParams.System.nSCSI = NCR53C90A;
575: ConfigureParams.System.bNBIC = true;
576: break;
577:
578: case NEXT_STATION:
579: ConfigureParams.System.nCpuLevel = 4;
580: if (ConfigureParams.System.bTurbo) {
581: ConfigureParams.System.nCpuFreq = 33;
582: ConfigureParams.System.nRTC = MCCS1850;
583: } else if (ConfigureParams.System.bColor) {
584: ConfigureParams.System.nCpuFreq = 25;
585: ConfigureParams.System.nRTC = MCCS1850;
586: } else {
587: ConfigureParams.System.nCpuFreq = 25;
588: ConfigureParams.System.nRTC = MC68HC68T1;
589: }
590: ConfigureParams.System.n_FPUType = FPU_CPU;
591: ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
592: ConfigureParams.System.bDSPMemoryExpansion = true;
593: ConfigureParams.System.nSCSI = NCR53C90A;
594: ConfigureParams.System.bNBIC = false;
595: break;
596: default:
597: break;
598: }
599:
600: if (ConfigureParams.System.bTurbo) {
601: ConfigureParams.Memory.nMemoryBankSize[0] = 32;
602: ConfigureParams.Memory.nMemoryBankSize[1] = 32;
603: ConfigureParams.Memory.nMemoryBankSize[2] = 32;
604: ConfigureParams.Memory.nMemoryBankSize[3] = 32;
605: } else if (ConfigureParams.System.bColor) {
606: ConfigureParams.Memory.nMemoryBankSize[0] = 8;
607: ConfigureParams.Memory.nMemoryBankSize[1] = 8;
608: ConfigureParams.Memory.nMemoryBankSize[2] = 8;
609: ConfigureParams.Memory.nMemoryBankSize[3] = 8;
610: } else {
611: ConfigureParams.Memory.nMemoryBankSize[0] = 16;
612: ConfigureParams.Memory.nMemoryBankSize[1] = 16;
613: ConfigureParams.Memory.nMemoryBankSize[2] = 16;
614: ConfigureParams.Memory.nMemoryBankSize[3] = 16;
615: }
1.1 root 616: }
617:
618:
619: /*-----------------------------------------------------------------------*/
620: /**
1.1.1.3 root 621: * Check memory bank sizes for compatibility with the selected system.
622: */
623: int Configuration_CheckMemory(int *banksize) {
624: int i;
625:
626: #define RESTRICTIVE_MEMCHECK 0
627: #if RESTRICTIVE_MEMCHECK
628: /* To boot we need at least 4 MB in bank0 */
629: if (banksize[0]<4) {
630: banksize[0]=4;
631: }
632:
633: /* On monochrome non-Turbo NeXTstations only the first
634: * 2 banks are accessible via memory sockets */
635: if (ConfigureParams.System.nMachineType == NEXT_STATION &&
636: !ConfigureParams.System.bTurbo && !ConfigureParams.System.bColor) {
637: banksize[2]=0;
638: banksize[3]=0;
639: }
640: #endif
641:
642: if (ConfigureParams.System.bTurbo) {
643: for (i=0; i<4; i++) {
644: if (banksize[i]<=0)
645: banksize[i]=0;
646: else if (banksize[i]<=2)
647: banksize[i]=2;
648: else if (banksize[i]<=8)
649: banksize[i]=8;
650: else if (banksize[i]<=32)
651: banksize[i]=32;
652: else
653: banksize[i]=32;
654: }
655: } else if (ConfigureParams.System.bColor) {
656: for (i=0; i<4; i++) {
657: if (banksize[i]<=0)
658: banksize[i]=0;
659: else if (banksize[i]<=2)
660: banksize[i]=2;
661: else if (banksize[i]<=8)
662: banksize[i]=8;
663: else
664: banksize[i]=8;
665: }
666: } else {
667: for (i=0; i<4; i++) {
668: if (banksize[i]<=0)
669: banksize[i]=0;
670: else if (banksize[i]<=1)
671: banksize[i]=1;
672: else if (banksize[i]<=4)
673: banksize[i]=4;
674: else if (banksize[i]<=16)
675: banksize[i]=16;
676: else
677: banksize[i]=16;
678: }
679: }
680: return (banksize[0]+banksize[1]+banksize[2]+banksize[3]);
681: }
682:
1.1.1.4 root 683: int Configuration_CheckDimensionMemory(int *banksize) {
684: int i;
685:
686: #if RESTRICTIVE_MEMCHECK
687: /* To boot we need at least 4 MB in bank0 */
688: if (banksize[0]<4) {
689: banksize[0]=4;
690: }
691: #endif
692: for (i=0; i<4; i++) {
693: if (banksize[i]<=0)
694: banksize[i]=0;
695: else if (banksize[i]<=4)
696: banksize[i]=4;
697: else if (banksize[i]<=16)
698: banksize[i]=16;
699: else
700: banksize[i]=16;
701: }
702: return (banksize[0]+banksize[1]+banksize[2]+banksize[3]);
703: }
704:
705: void Configuration_CheckDimensionSettings(void) {
1.1.1.5 ! root 706: if (ConfigureParams.System.nMachineType==NEXT_STATION || !ConfigureParams.Dimension.bEnabled) {
! 707: ConfigureParams.Dimension.bEnabled = false;
1.1.1.4 root 708: ConfigureParams.Screen.nMonitorType = MONITOR_TYPE_CPU;
709: }
710: }
711:
1.1.1.5 ! root 712: void Configuration_CheckEthernetSettings(void) {
! 713: if (ConfigureParams.System.nMachineType == NEXT_CUBE030) {
! 714: ConfigureParams.Ethernet.bTwistedPair = false;
! 715: }
! 716: }
! 717:
1.1.1.3 root 718:
719: /*-----------------------------------------------------------------------*/
720: /**
1.1 root 721: * Load a settings section from the configuration file.
722: */
723: static int Configuration_LoadSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
724: {
725: int ret;
726:
727: ret = input_config(pFilename, configs, pSection);
728:
729: if (ret < 0)
730: fprintf(stderr, "Can not load configuration file %s (section %s).\n",
731: pFilename, pSection);
732:
733: return ret;
734: }
735:
736:
737: /*-----------------------------------------------------------------------*/
738: /**
739: * Load program setting from configuration file. If psFileName is NULL, use
740: * the configuration file given in configuration / last selected by user.
741: */
742: void Configuration_Load(const char *psFileName)
743: {
744: if (psFileName == NULL)
745: psFileName = sConfigFileName;
746:
747: if (!File_Exists(psFileName))
748: {
1.1.1.2 root 749: Log_Printf(LOG_DEBUG, "Configuration file %s not found.\n", psFileName);
1.1 root 750: return;
751: }
752:
753: Configuration_LoadSection(psFileName, configs_Log, "[Log]");
1.1.1.3 root 754: Configuration_LoadSection(psFileName, configs_ConfigDialog, "[ConfigDialog]");
1.1 root 755: Configuration_LoadSection(psFileName, configs_Debugger, "[Debugger]");
756: Configuration_LoadSection(psFileName, configs_Screen, "[Screen]");
757: Configuration_LoadSection(psFileName, configs_Keyboard, "[Keyboard]");
758: Configuration_LoadSection(psFileName, configs_ShortCutWithMod, "[ShortcutsWithModifiers]");
759: Configuration_LoadSection(psFileName, configs_ShortCutWithoutMod, "[ShortcutsWithoutModifiers]");
1.1.1.4 root 760: Configuration_LoadSection(psFileName, configs_Mouse, "[Mouse]");
1.1 root 761: Configuration_LoadSection(psFileName, configs_Sound, "[Sound]");
762: Configuration_LoadSection(psFileName, configs_Memory, "[Memory]");
1.1.1.3 root 763: Configuration_LoadSection(psFileName, configs_Boot, "[Boot]");
764: Configuration_LoadSection(psFileName, configs_SCSI, "[HardDisk]");
1.1.1.4 root 765: Configuration_LoadSection(psFileName, configs_MO, "[MagnetoOptical]");
766: Configuration_LoadSection(psFileName, configs_Floppy, "[Floppy]");
767: Configuration_LoadSection(psFileName, configs_Ethernet, "[Ethernet]");
1.1 root 768: Configuration_LoadSection(psFileName, configs_Rom, "[ROM]");
769: Configuration_LoadSection(psFileName, configs_Printer, "[Printer]");
770: Configuration_LoadSection(psFileName, configs_System, "[System]");
1.1.1.4 root 771: Configuration_LoadSection(psFileName, configs_Dimension, "[Dimension]");
1.1 root 772: }
773:
774:
775: /*-----------------------------------------------------------------------*/
776: /**
777: * Save a settings section to configuration file
778: */
779: static int Configuration_SaveSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
780: {
781: int ret;
782:
783: ret = update_config(pFilename, configs, pSection);
784:
785: if (ret < 0)
786: fprintf(stderr, "Error while updating section %s in %s\n", pSection, pFilename);
787:
788: return ret;
789: }
790:
791:
792: /*-----------------------------------------------------------------------*/
793: /**
794: * Save program setting to configuration file
795: */
796: void Configuration_Save(void)
797: {
798: if (Configuration_SaveSection(sConfigFileName, configs_Log, "[Log]") < 0)
799: {
800: Log_AlertDlg(LOG_ERROR, "Error saving config file.");
801: return;
802: }
1.1.1.3 root 803: Configuration_SaveSection(sConfigFileName, configs_ConfigDialog, "[ConfigDialog]");
1.1 root 804: Configuration_SaveSection(sConfigFileName, configs_Debugger, "[Debugger]");
805: Configuration_SaveSection(sConfigFileName, configs_Screen, "[Screen]");
806: Configuration_SaveSection(sConfigFileName, configs_Keyboard, "[Keyboard]");
807: Configuration_SaveSection(sConfigFileName, configs_ShortCutWithMod, "[ShortcutsWithModifiers]");
808: Configuration_SaveSection(sConfigFileName, configs_ShortCutWithoutMod, "[ShortcutsWithoutModifiers]");
1.1.1.4 root 809: Configuration_SaveSection(sConfigFileName, configs_Mouse, "[Mouse]");
1.1 root 810: Configuration_SaveSection(sConfigFileName, configs_Sound, "[Sound]");
811: Configuration_SaveSection(sConfigFileName, configs_Memory, "[Memory]");
1.1.1.3 root 812: Configuration_SaveSection(sConfigFileName, configs_Boot, "[Boot]");
813: Configuration_SaveSection(sConfigFileName, configs_SCSI, "[HardDisk]");
1.1.1.4 root 814: Configuration_SaveSection(sConfigFileName, configs_MO, "[MagnetoOptical]");
815: Configuration_SaveSection(sConfigFileName, configs_Floppy, "[Floppy]");
816: Configuration_SaveSection(sConfigFileName, configs_Ethernet, "[Ethernet]");
1.1 root 817: Configuration_SaveSection(sConfigFileName, configs_Rom, "[ROM]");
818: Configuration_SaveSection(sConfigFileName, configs_Printer, "[Printer]");
819: Configuration_SaveSection(sConfigFileName, configs_System, "[System]");
1.1.1.4 root 820: Configuration_SaveSection(sConfigFileName, configs_Dimension, "[Dimension]");
1.1 root 821: }
822:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.