|
|
1.1 root 1: /*
1.1.1.6 root 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.
1.1 root 6:
7: Configuration File
8:
1.1.1.6 root 9: The configuration file is now stored in an ASCII format to allow the user
10: to edit the file manually.
1.1 root 11: */
1.1.1.10! root 12: char Configuration_rcsid[] = "Hatari $Id: configuration.c,v 1.47 2005/10/04 15:31:52 thothy Exp $";
! 13:
! 14: #include <SDL_keysym.h>
1.1 root 15:
16: #include "main.h"
17: #include "configuration.h"
1.1.1.9 root 18: #include "cfgopts.h"
1.1.1.8 root 19: #include "audio.h"
1.1.1.5 root 20: #include "file.h"
1.1.1.9 root 21: #include "log.h"
22: #include "m68000.h"
23: #include "screen.h"
24: #include "vdi.h"
25: #include "video.h"
1.1.1.6 root 26: #include "uae-cpu/hatari-glue.h"
27:
28:
29: BOOL bFirstTimeInstall = FALSE; /* Has been run before? Used to set default joysticks etc... */
30: CNF_PARAMS ConfigureParams; /* List of configuration for the emulator */
1.1.1.7 root 31: char sConfigFileName[FILENAME_MAX]; /* Stores the name of the configuration file */
1.1.1.6 root 32:
33:
1.1.1.9 root 34: /* Used to load/save logging options */
35: static const struct Config_Tag configs_Log[] =
36: {
37: { "sLogFileName", String_Tag, ConfigureParams.Log.sLogFileName },
38: { "nTextLogLevel", Int_Tag, &ConfigureParams.Log.nTextLogLevel },
39: { "nAlertDlgLogLevel", Int_Tag, &ConfigureParams.Log.nAlertDlgLogLevel },
40: { NULL , Error_Tag, NULL }
41: };
42:
43:
1.1.1.6 root 44: /* Used to load/save screen options */
1.1.1.9 root 45: static const struct Config_Tag configs_Screen[] =
1.1.1.6 root 46: {
1.1.1.9 root 47: { "bFullScreen", Bool_Tag, &ConfigureParams.Screen.bFullScreen },
48: { "bFrameSkip", Bool_Tag, &ConfigureParams.Screen.bFrameSkip },
49: { "bAllowOverscan", Bool_Tag, &ConfigureParams.Screen.bAllowOverscan },
50: { "bInterleavedScreen", Bool_Tag, &ConfigureParams.Screen.bInterleavedScreen },
51: { "ChosenDisplayMode", Int_Tag, &ConfigureParams.Screen.ChosenDisplayMode },
52: { "bUseHighRes", Bool_Tag, &ConfigureParams.Screen.bUseHighRes },
53: { "bUseExtVdiResolutions", Bool_Tag, &ConfigureParams.Screen.bUseExtVdiResolutions },
54: { "nVdiResolution", Int_Tag, &ConfigureParams.Screen.nVdiResolution },
55: { "nVdiColors", Int_Tag, &ConfigureParams.Screen.nVdiColors },
56: { "bCaptureChange", Bool_Tag, &ConfigureParams.Screen.bCaptureChange },
57: { "nFramesPerSecond", Int_Tag, &ConfigureParams.Screen.nFramesPerSecond },
58: { NULL , Error_Tag, NULL }
1.1.1.6 root 59: };
60:
1.1.1.10! root 61: /* Used to load/save joystick 0 options */
1.1.1.9 root 62: static const struct Config_Tag configs_Joystick0[] =
1.1.1.6 root 63: {
1.1.1.10! root 64: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nJoystickMode },
1.1.1.9 root 65: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[0].bEnableAutoFire },
1.1.1.10! root 66: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nJoyId },
! 67: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeUp },
! 68: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeDown },
! 69: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeLeft },
! 70: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeRight },
! 71: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[0].nKeyCodeFire },
1.1.1.9 root 72: { NULL , Error_Tag, NULL }
1.1.1.6 root 73: };
1.1.1.10! root 74:
! 75: /* Used to load/save joystick 1 options */
1.1.1.9 root 76: static const struct Config_Tag configs_Joystick1[] =
1.1.1.6 root 77: {
1.1.1.10! root 78: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nJoystickMode },
1.1.1.9 root 79: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[1].bEnableAutoFire },
1.1.1.10! root 80: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nJoyId },
! 81: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeUp },
! 82: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeDown },
! 83: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeLeft },
! 84: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeRight },
! 85: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[1].nKeyCodeFire },
! 86: { NULL , Error_Tag, NULL }
! 87: };
! 88:
! 89: /* Used to load/save joystick 2 options */
! 90: static const struct Config_Tag configs_Joystick2[] =
! 91: {
! 92: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nJoystickMode },
! 93: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[2].bEnableAutoFire },
! 94: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nJoyId },
! 95: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeUp },
! 96: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeDown },
! 97: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeLeft },
! 98: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeRight },
! 99: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[2].nKeyCodeFire },
! 100: { NULL , Error_Tag, NULL }
! 101: };
! 102:
! 103: /* Used to load/save joystick 3 options */
! 104: static const struct Config_Tag configs_Joystick3[] =
! 105: {
! 106: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nJoystickMode },
! 107: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[3].bEnableAutoFire },
! 108: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nJoyId },
! 109: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeUp },
! 110: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeDown },
! 111: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeLeft },
! 112: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeRight },
! 113: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[3].nKeyCodeFire },
! 114: { NULL , Error_Tag, NULL }
! 115: };
! 116:
! 117: /* Used to load/save joystick 4 options */
! 118: static const struct Config_Tag configs_Joystick4[] =
! 119: {
! 120: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nJoystickMode },
! 121: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[4].bEnableAutoFire },
! 122: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nJoyId },
! 123: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeUp },
! 124: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeDown },
! 125: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeLeft },
! 126: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeRight },
! 127: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[4].nKeyCodeFire },
! 128: { NULL , Error_Tag, NULL }
! 129: };
! 130:
! 131: /* Used to load/save joystick 5 options */
! 132: static const struct Config_Tag configs_Joystick5[] =
! 133: {
! 134: { "nJoystickMode", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nJoystickMode },
! 135: { "bEnableAutoFire", Bool_Tag, &ConfigureParams.Joysticks.Joy[5].bEnableAutoFire },
! 136: { "nJoyId", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nJoyId },
! 137: { "nKeyCodeUp", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeUp },
! 138: { "nKeyCodeDown", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeDown },
! 139: { "nKeyCodeLeft", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeLeft },
! 140: { "nKeyCodeRight", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeRight },
! 141: { "nKeyCodeFire", Int_Tag, &ConfigureParams.Joysticks.Joy[5].nKeyCodeFire },
1.1.1.9 root 142: { NULL , Error_Tag, NULL }
1.1.1.6 root 143: };
1.1.1.5 root 144:
1.1.1.6 root 145: /* Used to load/save keyboard options */
1.1.1.9 root 146: static const struct Config_Tag configs_Keyboard[] =
1.1.1.6 root 147: {
1.1.1.9 root 148: { "bDisableKeyRepeat", Bool_Tag, &ConfigureParams.Keyboard.bDisableKeyRepeat },
149: { "nKeymapType", Int_Tag, &ConfigureParams.Keyboard.nKeymapType },
150: { "szMappingFileName", String_Tag, ConfigureParams.Keyboard.szMappingFileName },
151: { NULL , Error_Tag, NULL }
1.1.1.6 root 152: };
1.1 root 153:
1.1.1.6 root 154: /* Used to load/save sound options */
1.1.1.9 root 155: static const struct Config_Tag configs_Sound[] =
1.1.1.6 root 156: {
1.1.1.9 root 157: { "bEnableSound", Bool_Tag, &ConfigureParams.Sound.bEnableSound },
158: { "nPlaybackQuality", Int_Tag, &ConfigureParams.Sound.nPlaybackQuality },
159: { "szYMCaptureFileName", String_Tag, ConfigureParams.Sound.szYMCaptureFileName },
160: { NULL , Error_Tag, NULL }
1.1.1.6 root 161: };
162:
163: /* Used to load/save memory options */
1.1.1.9 root 164: static const struct Config_Tag configs_Memory[] =
1.1.1.6 root 165: {
1.1.1.9 root 166: { "nMemorySize", Int_Tag, &ConfigureParams.Memory.nMemorySize },
167: { "szMemoryCaptureFileName", String_Tag, ConfigureParams.Memory.szMemoryCaptureFileName },
168: { NULL , Error_Tag, NULL }
1.1.1.6 root 169: };
170:
171:
172: /* Used to load/save floppy options */
1.1.1.9 root 173: static const struct Config_Tag configs_Floppy[] =
1.1.1.6 root 174: {
1.1.1.10! root 175: { "bAutoInsertDiskB", Bool_Tag, &ConfigureParams.DiskImage.bAutoInsertDiskB },
! 176: { "nWriteProtection", Int_Tag, &ConfigureParams.DiskImage.nWriteProtection },
! 177: { "szDiskImageDirectory", String_Tag, ConfigureParams.DiskImage.szDiskImageDirectory },
! 178: { NULL , Error_Tag, NULL }
! 179: };
! 180:
! 181: /* Obsolete - to be removed */
! 182: static const struct Config_Tag configs_OldFloppy[] =
! 183: {
! 184: { "bAutoInsertDiscB", Bool_Tag, &ConfigureParams.DiskImage.bAutoInsertDiskB },
! 185: { "szDiscImageDirectory", String_Tag, ConfigureParams.DiskImage.szDiskImageDirectory },
1.1.1.9 root 186: { NULL , Error_Tag, NULL }
1.1.1.6 root 187: };
188:
189: /* Used to load/save HD options */
1.1.1.10! root 190: static const struct Config_Tag configs_HardDisk[] =
1.1.1.6 root 191: {
1.1.1.10! root 192: { "bBootFromHardDisk", Bool_Tag, &ConfigureParams.HardDisk.bBootFromHardDisk },
! 193: { "bUseHardDiskDirectory", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskDirectories },
! 194: { "szHardDiskDirectory", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_C] },
! 195: /*{ "szHardDiskDirD", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_D] },*/
! 196: /*{ "szHardDiskDirE", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_E] },*/
! 197: /*{ "szHardDiskDirF", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_F] },*/
! 198: { "bUseHardDiskImage", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskImage },
! 199: { "szHardDiskImage", String_Tag, ConfigureParams.HardDisk.szHardDiskImage },
! 200: { NULL , Error_Tag, NULL }
! 201: };
! 202:
! 203: /* Obsolete - to be removed */
! 204: static const struct Config_Tag configs_OldHardDisc[] =
! 205: {
! 206: { "bBootFromHardDisc", Bool_Tag, &ConfigureParams.HardDisk.bBootFromHardDisk },
! 207: { "bUseHardDiscDirectory", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskDirectories },
! 208: { "szHardDiscDirectory", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_C] },
! 209: { "bUseHardDiscImage", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskImage },
! 210: { "szHardDiscImage", String_Tag, ConfigureParams.HardDisk.szHardDiskImage },
1.1.1.9 root 211: { NULL , Error_Tag, NULL }
1.1.1.6 root 212: };
213:
1.1.1.8 root 214: /* Used to load/save ROM options */
1.1.1.9 root 215: static const struct Config_Tag configs_Rom[] =
1.1.1.6 root 216: {
1.1.1.9 root 217: { "szTosImageFileName", String_Tag, ConfigureParams.Rom.szTosImageFileName },
218: { "szCartridgeImageFileName", String_Tag, ConfigureParams.Rom.szCartridgeImageFileName },
219: { NULL , Error_Tag, NULL }
1.1.1.6 root 220: };
221:
222: /* Used to load/save RS232 options */
1.1.1.9 root 223: static const struct Config_Tag configs_Rs232[] =
1.1.1.6 root 224: {
1.1.1.9 root 225: { "bEnableRS232", Bool_Tag, &ConfigureParams.RS232.bEnableRS232 },
226: { "szOutFileName", String_Tag, ConfigureParams.RS232.szOutFileName },
227: { "szInFileName", String_Tag, ConfigureParams.RS232.szInFileName },
228: { NULL , Error_Tag, NULL }
1.1.1.6 root 229: };
230:
231: /* Used to load/save printer options */
1.1.1.9 root 232: static const struct Config_Tag configs_Printer[] =
1.1.1.6 root 233: {
1.1.1.9 root 234: { "bEnablePrinting", Bool_Tag, &ConfigureParams.Printer.bEnablePrinting },
235: { "bPrintToFile", Bool_Tag, &ConfigureParams.Printer.bPrintToFile },
236: { "szPrintToFileName", String_Tag, ConfigureParams.Printer.szPrintToFileName },
237: { NULL , Error_Tag, NULL }
1.1.1.6 root 238: };
239:
1.1.1.7 root 240: /* Used to load/save MIDI options */
1.1.1.9 root 241: static const struct Config_Tag configs_Midi[] =
1.1.1.7 root 242: {
1.1.1.9 root 243: { "bEnableMidi", Bool_Tag, &ConfigureParams.Midi.bEnableMidi },
244: { "szMidiOutFileName", String_Tag, ConfigureParams.Midi.szMidiOutFileName },
245: { NULL , Error_Tag, NULL }
1.1.1.7 root 246: };
247:
1.1.1.6 root 248: /* Used to load/save system options */
1.1.1.9 root 249: static const struct Config_Tag configs_System[] =
1.1.1.6 root 250: {
1.1.1.9 root 251: { "nMinMaxSpeed", Int_Tag, &ConfigureParams.System.nMinMaxSpeed },
252: { "nCpuLevel", Int_Tag, &ConfigureParams.System.nCpuLevel },
253: { "nCpuFreq", Int_Tag, &ConfigureParams.System.nCpuFreq },
254: { "bCompatibleCpu", Bool_Tag, &ConfigureParams.System.bCompatibleCpu },
255: { "nMachineType", Int_Tag, &ConfigureParams.System.nMachineType },
256: { "bBlitter", Bool_Tag, &ConfigureParams.System.bBlitter },
257: { "bRealTimeClock", Bool_Tag, &ConfigureParams.System.bRealTimeClock },
258: { "bPatchTimerD", Bool_Tag, &ConfigureParams.System.bPatchTimerD },
259: { "bSlowFDC", Bool_Tag, &ConfigureParams.System.bSlowFDC },
260: { NULL , Error_Tag, NULL }
1.1.1.6 root 261: };
1.1 root 262:
263:
264: /*-----------------------------------------------------------------------*/
265: /*
1.1.1.4 root 266: Set default configuration values.
1.1.1.2 root 267: */
268: void Configuration_SetDefault(void)
269: {
1.1.1.9 root 270: int i;
271: char *homeDir;
1.1.1.4 root 272:
1.1.1.9 root 273: /* Assume first-time install */
274: bFirstTimeInstall = TRUE;
1.1.1.4 root 275:
1.1.1.9 root 276: /* Clear parameters */
277: memset(&ConfigureParams, 0, sizeof(CNF_PARAMS));
278:
279: /* Set defaults for logging */
280: strcpy(ConfigureParams.Log.sLogFileName, "stderr");
281: ConfigureParams.Log.nTextLogLevel = LOG_INFO;
282: ConfigureParams.Log.nAlertDlgLogLevel = LOG_INFO;
283:
1.1.1.10! root 284: /* Set defaults for floppy disk images */
! 285: ConfigureParams.DiskImage.bAutoInsertDiskB = TRUE;
! 286: ConfigureParams.DiskImage.nWriteProtection = WRITEPROT_OFF;
! 287: strcpy(ConfigureParams.DiskImage.szDiskImageDirectory, szWorkingDir);
! 288: File_AddSlashToEndFileName(ConfigureParams.DiskImage.szDiskImageDirectory);
! 289:
! 290: /* Set defaults for hard disks */
! 291: ConfigureParams.HardDisk.bBootFromHardDisk = FALSE;
! 292: ConfigureParams.HardDisk.nHardDiskDir = DRIVE_C;
! 293: ConfigureParams.HardDisk.bUseHardDiskDirectories = FALSE;
1.1.1.9 root 294: for (i=0; i<MAX_HARDDRIVES; i++)
295: {
1.1.1.10! root 296: strcpy(ConfigureParams.HardDisk.szHardDiskDirectories[i], szWorkingDir);
! 297: File_CleanFileName(ConfigureParams.HardDisk.szHardDiskDirectories[i]);
1.1.1.9 root 298: }
1.1.1.10! root 299: ConfigureParams.HardDisk.bUseHardDiskImage = FALSE;
! 300: strcpy(ConfigureParams.HardDisk.szHardDiskImage, szWorkingDir);
1.1.1.9 root 301:
302: /* Set defaults for Joysticks */
1.1.1.10! root 303: for (i = 0; i < 6; i++)
1.1.1.9 root 304: {
1.1.1.10! root 305: ConfigureParams.Joysticks.Joy[i].nJoystickMode = JOYSTICK_DISABLED;
1.1.1.9 root 306: ConfigureParams.Joysticks.Joy[i].bEnableAutoFire = FALSE;
1.1.1.10! root 307: ConfigureParams.Joysticks.Joy[i].nJoyId = i;
! 308: ConfigureParams.Joysticks.Joy[i].nKeyCodeUp = SDLK_UP;
! 309: ConfigureParams.Joysticks.Joy[i].nKeyCodeDown = SDLK_DOWN;
! 310: ConfigureParams.Joysticks.Joy[i].nKeyCodeLeft = SDLK_LEFT;
! 311: ConfigureParams.Joysticks.Joy[i].nKeyCodeRight = SDLK_RIGHT;
! 312: ConfigureParams.Joysticks.Joy[i].nKeyCodeFire = SDLK_RCTRL;
1.1.1.9 root 313: }
1.1.1.10! root 314: ConfigureParams.Joysticks.Joy[1].nJoyId = 0; /* ST Joystick #1 is default joystick */
! 315: ConfigureParams.Joysticks.Joy[0].nJoyId = 1;
1.1.1.9 root 316:
317: /* Set defaults for Keyboard */
318: ConfigureParams.Keyboard.bDisableKeyRepeat = TRUE;
319: ConfigureParams.Keyboard.nKeymapType = KEYMAP_SYMBOLIC;
320: strcpy(ConfigureParams.Keyboard.szMappingFileName, "");
321:
322: /* Set defaults for Memory */
1.1.1.10! root 323: ConfigureParams.Memory.nMemorySize = 1; /* 1 MiB */
1.1.1.9 root 324: sprintf(ConfigureParams.Memory.szMemoryCaptureFileName, "%s/hatari.sav", szWorkingDir);
325:
326: /* Set defaults for Printer */
327: ConfigureParams.Printer.bEnablePrinting = FALSE;
328: ConfigureParams.Printer.bPrintToFile = TRUE;
329: sprintf(ConfigureParams.Printer.szPrintToFileName, "%s/hatari.prn", szWorkingDir);
330:
331: /* Set defaults for RS232 */
332: ConfigureParams.RS232.bEnableRS232 = FALSE;
333: strcpy(ConfigureParams.RS232.szOutFileName, "/dev/modem");
334: strcpy(ConfigureParams.RS232.szInFileName, "/dev/modem");
335:
336: /* Set defaults for MIDI */
337: ConfigureParams.Midi.bEnableMidi = FALSE;
338: strcpy(ConfigureParams.Midi.szMidiOutFileName, "/dev/midi00");
339:
340: /* Set defaults for Screen */
341: ConfigureParams.Screen.bFullScreen = FALSE;
342: ConfigureParams.Screen.bFrameSkip = FALSE;
343: ConfigureParams.Screen.bAllowOverscan = TRUE;
344: ConfigureParams.Screen.bInterleavedScreen = FALSE;
345: ConfigureParams.Screen.ChosenDisplayMode = DISPLAYMODE_HICOL_LOWRES;
346: ConfigureParams.Screen.bUseHighRes = FALSE;
347: ConfigureParams.Screen.bUseExtVdiResolutions = FALSE;
348: ConfigureParams.Screen.nVdiResolution = GEMRES_640x480;
349: ConfigureParams.Screen.nVdiColors = GEMCOLOUR_16;
350: ConfigureParams.Screen.bCaptureChange = FALSE;
351: ConfigureParams.Screen.nFramesPerSecond = 25;
352:
353: /* Set defaults for Sound */
354: ConfigureParams.Sound.bEnableSound = TRUE;
355: ConfigureParams.Sound.nPlaybackQuality = PLAYBACK_MEDIUM;
356: sprintf(ConfigureParams.Sound.szYMCaptureFileName, "%s/hatari.wav", szWorkingDir);
357:
358: /* Set defaults for Rom */
359: sprintf(ConfigureParams.Rom.szTosImageFileName, "%s/tos.img", DATADIR);
360: strcpy(ConfigureParams.Rom.szCartridgeImageFileName, "");
361:
362: /* Set defaults for System */
363: ConfigureParams.System.nCpuLevel = 0;
364: ConfigureParams.System.nCpuFreq = 8;
365: ConfigureParams.System.bCompatibleCpu = FALSE;
366: /*ConfigureParams.System.bAddressSpace24 = TRUE;*/
367: ConfigureParams.System.nMachineType = MACHINE_ST;
368: ConfigureParams.System.bBlitter = FALSE;
369: ConfigureParams.System.bPatchTimerD = TRUE;
370: ConfigureParams.System.bRealTimeClock = TRUE;
371: ConfigureParams.System.nMinMaxSpeed = MINMAXSPEED_MIN;
372: ConfigureParams.System.bSlowFDC = FALSE;
373:
374: /* Initialize the configuration file name */
375: homeDir = getenv("HOME");
376: if (homeDir != NULL && homeDir[0] != 0 && strlen(homeDir) < sizeof(sConfigFileName)-13)
377: sprintf(sConfigFileName, "%s/.hatari.cfg", homeDir);
378: else
379: strcpy(sConfigFileName, "hatari.cfg");
1.1.1.2 root 380: }
381:
382:
383: /*-----------------------------------------------------------------------*/
384: /*
1.1.1.8 root 385: Copy details from configuration structure into global variables for system,
386: clean file names, etc...
387: */
388: void Configuration_WorkOnDetails(BOOL bReset)
389: {
1.1.1.9 root 390: /* Set resolution change */
391: if (bReset)
392: {
393: bUseVDIRes = ConfigureParams.Screen.bUseExtVdiResolutions;
394: bUseHighRes = (!bUseVDIRes && ConfigureParams.Screen.bUseHighRes)
395: || (bUseVDIRes && ConfigureParams.Screen.nVdiColors==GEMCOLOUR_2);
396: VDI_SetResolution(ConfigureParams.Screen.nVdiResolution, ConfigureParams.Screen.nVdiColors);
397: }
398:
399: /* Set playback frequency */
400: if (ConfigureParams.Sound.bEnableSound)
401: Audio_SetOutputAudioFreq(ConfigureParams.Sound.nPlaybackQuality);
402:
403: /* CPU settings */
404: if (ConfigureParams.System.nCpuFreq < 12)
405: {
406: ConfigureParams.System.nCpuFreq = 8;
407: nCpuFreqShift = 0;
408: }
409: else if (ConfigureParams.System.nCpuFreq > 26)
410: {
411: ConfigureParams.System.nCpuFreq = 32;
412: nCpuFreqShift = 2;
413: }
414: else
415: {
416: ConfigureParams.System.nCpuFreq = 16;
417: nCpuFreqShift = 1;
418: }
419:
420: /* Clean file and directory names */
421: File_MakeAbsoluteName(ConfigureParams.Rom.szTosImageFileName);
422: File_MakeAbsoluteName(ConfigureParams.Rom.szCartridgeImageFileName);
1.1.1.10! root 423: File_MakeAbsoluteName(ConfigureParams.HardDisk.szHardDiskImage);
! 424: File_CleanFileName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
! 425: File_MakeAbsoluteName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
1.1.1.9 root 426: File_MakeAbsoluteName(ConfigureParams.Midi.szMidiOutFileName);
427: File_MakeAbsoluteName(ConfigureParams.RS232.szOutFileName);
428: File_MakeAbsoluteName(ConfigureParams.RS232.szInFileName);
1.1.1.8 root 429: }
430:
431:
432: /*-----------------------------------------------------------------------*/
433: /*
1.1.1.6 root 434: Load a settings section from the configuration file.
1.1 root 435: */
1.1.1.9 root 436: static int Configuration_LoadSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
1.1 root 437: {
1.1.1.9 root 438: int ret;
1.1 root 439:
1.1.1.9 root 440: ret = input_config(pFilename, configs, pSection);
1.1 root 441:
1.1.1.9 root 442: if (ret < 0)
443: fprintf(stderr, "Can not load configuration file %s (section %s).\n",
444: sConfigFileName, pSection);
1.1 root 445:
1.1.1.9 root 446: return ret;
1.1 root 447: }
448:
449:
450: /*-----------------------------------------------------------------------*/
451: /*
1.1.1.9 root 452: Load program setting from configuration file. If psFileName is NULL, use
453: the default (i.e. the users) configuration file.
1.1 root 454: */
1.1.1.9 root 455: void Configuration_Load(const char *psFileName)
1.1 root 456: {
1.1.1.9 root 457: if (psFileName == NULL)
458: psFileName = sConfigFileName;
459:
460: if (!File_Exists(psFileName))
461: {
462: fprintf(stderr, "Configuration file %s not found.\n", psFileName);
463: return;
464: }
465:
466: bFirstTimeInstall = FALSE;
467:
468: Configuration_LoadSection(psFileName, configs_Log, "[Log]");
469: Configuration_LoadSection(psFileName, configs_Screen, "[Screen]");
470: Configuration_LoadSection(psFileName, configs_Joystick0, "[Joystick0]");
471: Configuration_LoadSection(psFileName, configs_Joystick1, "[Joystick1]");
1.1.1.10! root 472: Configuration_LoadSection(psFileName, configs_Joystick2, "[Joystick2]");
! 473: Configuration_LoadSection(psFileName, configs_Joystick3, "[Joystick3]");
! 474: Configuration_LoadSection(psFileName, configs_Joystick4, "[Joystick4]");
! 475: Configuration_LoadSection(psFileName, configs_Joystick5, "[Joystick5]");
1.1.1.9 root 476: Configuration_LoadSection(psFileName, configs_Keyboard, "[Keyboard]");
477: Configuration_LoadSection(psFileName, configs_Sound, "[Sound]");
478: Configuration_LoadSection(psFileName, configs_Memory, "[Memory]");
1.1.1.10! root 479: Configuration_LoadSection(psFileName, configs_OldFloppy, "[Floppy]"); /* <- to be removed */
1.1.1.9 root 480: Configuration_LoadSection(psFileName, configs_Floppy, "[Floppy]");
1.1.1.10! root 481: Configuration_LoadSection(psFileName, configs_OldHardDisc, "[HardDisc]"); /* <- to be removed */
! 482: Configuration_LoadSection(psFileName, configs_HardDisk, "[HardDisk]");
1.1.1.9 root 483: Configuration_LoadSection(psFileName, configs_Rom, "[ROM]");
484: Configuration_LoadSection(psFileName, configs_Rs232, "[RS232]");
485: Configuration_LoadSection(psFileName, configs_Printer, "[Printer]");
486: Configuration_LoadSection(psFileName, configs_Midi, "[Midi]");
487: Configuration_LoadSection(psFileName, configs_System, "[System]");
488:
489: /* Copy details to global variables */
490: cpu_level = ConfigureParams.System.nCpuLevel;
491: cpu_compatible = ConfigureParams.System.bCompatibleCpu;
1.1 root 492:
1.1.1.9 root 493: Configuration_WorkOnDetails(TRUE);
1.1 root 494: }
495:
496:
497: /*-----------------------------------------------------------------------*/
498: /*
1.1.1.6 root 499: Save a settings section to configuration file
1.1 root 500: */
1.1.1.9 root 501: static int Configuration_SaveSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
1.1 root 502: {
1.1.1.9 root 503: int ret;
1.1 root 504:
1.1.1.9 root 505: ret = update_config(pFilename, configs, pSection);
1.1 root 506:
1.1.1.9 root 507: if (ret < 0)
508: fprintf(stderr, "Error while updating section %s\n", pSection);
1.1 root 509:
1.1.1.9 root 510: return ret;
1.1 root 511: }
512:
513:
514: /*-----------------------------------------------------------------------*/
515: /*
1.1.1.6 root 516: Save program setting to configuration file
1.1 root 517: */
1.1.1.6 root 518: void Configuration_Save(void)
1.1 root 519: {
1.1.1.9 root 520: if (Configuration_SaveSection(sConfigFileName, configs_Log, "[Log]") < 0)
521: {
522: fprintf(stderr, "Error saving config file.\n");
523: return;
524: }
525: Configuration_SaveSection(sConfigFileName, configs_Screen, "[Screen]");
526: Configuration_SaveSection(sConfigFileName, configs_Joystick0, "[Joystick0]");
527: Configuration_SaveSection(sConfigFileName, configs_Joystick1, "[Joystick1]");
1.1.1.10! root 528: Configuration_SaveSection(sConfigFileName, configs_Joystick2, "[Joystick2]");
! 529: Configuration_SaveSection(sConfigFileName, configs_Joystick3, "[Joystick3]");
! 530: Configuration_SaveSection(sConfigFileName, configs_Joystick4, "[Joystick4]");
! 531: Configuration_SaveSection(sConfigFileName, configs_Joystick5, "[Joystick5]");
1.1.1.9 root 532: Configuration_SaveSection(sConfigFileName, configs_Keyboard, "[Keyboard]");
533: Configuration_SaveSection(sConfigFileName, configs_Sound, "[Sound]");
534: Configuration_SaveSection(sConfigFileName, configs_Memory, "[Memory]");
535: Configuration_SaveSection(sConfigFileName, configs_Floppy, "[Floppy]");
1.1.1.10! root 536: Configuration_SaveSection(sConfigFileName, configs_HardDisk, "[HardDisk]");
1.1.1.9 root 537: Configuration_SaveSection(sConfigFileName, configs_Rom, "[ROM]");
538: Configuration_SaveSection(sConfigFileName, configs_Rs232, "[RS232]");
539: Configuration_SaveSection(sConfigFileName, configs_Printer, "[Printer]");
540: Configuration_SaveSection(sConfigFileName, configs_Midi, "[Midi]");
541: Configuration_SaveSection(sConfigFileName, configs_System, "[System]");
1.1 root 542: }
1.1.1.6 root 543:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.