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