Annotation of hatari/src/configuration.c, revision 1.1.1.11

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.11! root       12: const char Configuration_rcsid[] = "Hatari $Id: configuration.c,v 1.52 2006/08/09 08:14:24 eerot Exp $";
1.1.1.10  root       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.11! root      154: /* Used to load/save shortcut key bindings with modifiers options */
        !           155: static const struct Config_Tag configs_ShortCutWithMod[] =
        !           156: {
        !           157:        { "keyOptions",    Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] },
        !           158:        { "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] },
        !           159:        { "keyMouseMode",  Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEMODE] },
        !           160:        { "keyColdReset",  Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] },
        !           161:        { "keyWarmReset",  Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] },
        !           162:        { "keyScreenShot", Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_SCREENSHOT] },
        !           163:        { "keyBossKey",    Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_BOSSKEY] },
        !           164:        { "keyCursorEmu",  Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_CURSOREMU] },
        !           165:        { "keyMaxSpeed",   Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_MAXSPEED] },
        !           166:        { "keyRecAnim",    Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_RECANIM] },
        !           167:        { "keyRecSound",   Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_RECSOUND] },
        !           168:        { "keySound",      Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_SOUND] },
        !           169:        { "keyQuit",       Int_Tag, &ConfigureParams.Shortcut.withModifier[SHORTCUT_QUIT] },
        !           170:        { NULL , Error_Tag, NULL }
        !           171: };
        !           172: 
        !           173: /* Used to load/save shortcut key bindings without modifiers options */
        !           174: static const struct Config_Tag configs_ShortCutWithoutMod[] =
        !           175: {
        !           176:        { "keyOptions",    Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] },
        !           177:        { "keyFullScreen", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] },
        !           178:        { "keyMouseMode",  Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_MOUSEMODE] },
        !           179:        { "keyColdReset",  Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_COLDRESET] },
        !           180:        { "keyWarmReset",  Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_WARMRESET] },
        !           181:        { "keyScreenShot", Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_SCREENSHOT] },
        !           182:        { "keyBossKey",    Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_BOSSKEY] },
        !           183:        { "keyCursorEmu",  Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_CURSOREMU] },
        !           184:        { "keyMaxSpeed",   Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_MAXSPEED] },
        !           185:        { "keyRecAnim",    Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_RECANIM] },
        !           186:        { "keyRecSound",   Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_RECSOUND] },
        !           187:        { "keySound",      Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_SOUND] },
        !           188:        { "keyQuit",       Int_Tag, &ConfigureParams.Shortcut.withoutModifier[SHORTCUT_QUIT] },
        !           189:        { NULL , Error_Tag, NULL }
        !           190: };
        !           191: 
        !           192: 
1.1.1.6   root      193: /* Used to load/save sound options */
1.1.1.9   root      194: static const struct Config_Tag configs_Sound[] =
1.1.1.6   root      195: {
1.1.1.9   root      196:        { "bEnableSound", Bool_Tag, &ConfigureParams.Sound.bEnableSound },
                    197:        { "nPlaybackQuality", Int_Tag, &ConfigureParams.Sound.nPlaybackQuality },
                    198:        { "szYMCaptureFileName", String_Tag, ConfigureParams.Sound.szYMCaptureFileName },
                    199:        { NULL , Error_Tag, NULL }
1.1.1.6   root      200: };
                    201: 
                    202: /* Used to load/save memory options */
1.1.1.9   root      203: static const struct Config_Tag configs_Memory[] =
1.1.1.6   root      204: {
1.1.1.9   root      205:        { "nMemorySize", Int_Tag, &ConfigureParams.Memory.nMemorySize },
                    206:        { "szMemoryCaptureFileName", String_Tag, ConfigureParams.Memory.szMemoryCaptureFileName },
                    207:        { NULL , Error_Tag, NULL }
1.1.1.6   root      208: };
                    209: 
                    210: 
                    211: /* Used to load/save floppy options */
1.1.1.9   root      212: static const struct Config_Tag configs_Floppy[] =
1.1.1.6   root      213: {
1.1.1.10  root      214:        { "bAutoInsertDiskB", Bool_Tag, &ConfigureParams.DiskImage.bAutoInsertDiskB },
                    215:        { "nWriteProtection", Int_Tag, &ConfigureParams.DiskImage.nWriteProtection },
                    216:        { "szDiskImageDirectory", String_Tag, ConfigureParams.DiskImage.szDiskImageDirectory },
                    217:        { NULL , Error_Tag, NULL }
                    218: };
                    219: 
                    220: /* Obsolete - to be removed */
                    221: static const struct Config_Tag configs_OldFloppy[] =
                    222: {
                    223:        { "bAutoInsertDiscB", Bool_Tag, &ConfigureParams.DiskImage.bAutoInsertDiskB },
                    224:        { "szDiscImageDirectory", String_Tag, ConfigureParams.DiskImage.szDiskImageDirectory },
1.1.1.9   root      225:        { NULL , Error_Tag, NULL }
1.1.1.6   root      226: };
                    227: 
                    228: /* Used to load/save HD options */
1.1.1.10  root      229: static const struct Config_Tag configs_HardDisk[] =
1.1.1.6   root      230: {
1.1.1.10  root      231:        { "bBootFromHardDisk", Bool_Tag, &ConfigureParams.HardDisk.bBootFromHardDisk },
                    232:        { "bUseHardDiskDirectory", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskDirectories },
                    233:        { "szHardDiskDirectory", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_C] },
                    234:        /*{ "szHardDiskDirD", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_D] },*/
                    235:        /*{ "szHardDiskDirE", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_E] },*/
                    236:        /*{ "szHardDiskDirF", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_F] },*/
                    237:        { "bUseHardDiskImage", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskImage },
                    238:        { "szHardDiskImage", String_Tag, ConfigureParams.HardDisk.szHardDiskImage },
                    239:        { NULL , Error_Tag, NULL }
                    240: };
                    241: 
                    242: /* Obsolete - to be removed */
                    243: static const struct Config_Tag configs_OldHardDisc[] =
                    244: {
                    245:        { "bBootFromHardDisc", Bool_Tag, &ConfigureParams.HardDisk.bBootFromHardDisk },
                    246:        { "bUseHardDiscDirectory", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskDirectories },
                    247:        { "szHardDiscDirectory", String_Tag, ConfigureParams.HardDisk.szHardDiskDirectories[DRIVE_C] },
                    248:        { "bUseHardDiscImage", Bool_Tag, &ConfigureParams.HardDisk.bUseHardDiskImage },
                    249:        { "szHardDiscImage", String_Tag, ConfigureParams.HardDisk.szHardDiskImage },
1.1.1.9   root      250:        { NULL , Error_Tag, NULL }
1.1.1.6   root      251: };
                    252: 
1.1.1.8   root      253: /* Used to load/save ROM options */
1.1.1.9   root      254: static const struct Config_Tag configs_Rom[] =
1.1.1.6   root      255: {
1.1.1.9   root      256:        { "szTosImageFileName", String_Tag, ConfigureParams.Rom.szTosImageFileName },
                    257:        { "szCartridgeImageFileName", String_Tag, ConfigureParams.Rom.szCartridgeImageFileName },
                    258:        { NULL , Error_Tag, NULL }
1.1.1.6   root      259: };
                    260: 
                    261: /* Used to load/save RS232 options */
1.1.1.9   root      262: static const struct Config_Tag configs_Rs232[] =
1.1.1.6   root      263: {
1.1.1.9   root      264:        { "bEnableRS232", Bool_Tag, &ConfigureParams.RS232.bEnableRS232 },
                    265:        { "szOutFileName", String_Tag, ConfigureParams.RS232.szOutFileName },
                    266:        { "szInFileName", String_Tag, ConfigureParams.RS232.szInFileName },
                    267:        { NULL , Error_Tag, NULL }
1.1.1.6   root      268: };
                    269: 
                    270: /* Used to load/save printer options */
1.1.1.9   root      271: static const struct Config_Tag configs_Printer[] =
1.1.1.6   root      272: {
1.1.1.9   root      273:        { "bEnablePrinting", Bool_Tag, &ConfigureParams.Printer.bEnablePrinting },
                    274:        { "bPrintToFile", Bool_Tag, &ConfigureParams.Printer.bPrintToFile },
                    275:        { "szPrintToFileName", String_Tag, ConfigureParams.Printer.szPrintToFileName },
                    276:        { NULL , Error_Tag, NULL }
1.1.1.6   root      277: };
                    278: 
1.1.1.7   root      279: /* Used to load/save MIDI options */
1.1.1.9   root      280: static const struct Config_Tag configs_Midi[] =
1.1.1.7   root      281: {
1.1.1.9   root      282:        { "bEnableMidi", Bool_Tag, &ConfigureParams.Midi.bEnableMidi },
                    283:        { "szMidiOutFileName", String_Tag, ConfigureParams.Midi.szMidiOutFileName },
                    284:        { NULL , Error_Tag, NULL }
1.1.1.7   root      285: };
                    286: 
1.1.1.6   root      287: /* Used to load/save system options */
1.1.1.9   root      288: static const struct Config_Tag configs_System[] =
1.1.1.6   root      289: {
1.1.1.9   root      290:        { "nMinMaxSpeed", Int_Tag, &ConfigureParams.System.nMinMaxSpeed },
                    291:        { "nCpuLevel", Int_Tag, &ConfigureParams.System.nCpuLevel },
                    292:        { "nCpuFreq", Int_Tag, &ConfigureParams.System.nCpuFreq },
                    293:        { "bCompatibleCpu", Bool_Tag, &ConfigureParams.System.bCompatibleCpu },
                    294:        { "nMachineType", Int_Tag, &ConfigureParams.System.nMachineType },
                    295:        { "bBlitter", Bool_Tag, &ConfigureParams.System.bBlitter },
                    296:        { "bRealTimeClock", Bool_Tag, &ConfigureParams.System.bRealTimeClock },
                    297:        { "bPatchTimerD", Bool_Tag, &ConfigureParams.System.bPatchTimerD },
                    298:        { "bSlowFDC", Bool_Tag, &ConfigureParams.System.bSlowFDC },
                    299:        { NULL , Error_Tag, NULL }
1.1.1.6   root      300: };
1.1       root      301: 
                    302: 
                    303: /*-----------------------------------------------------------------------*/
                    304: /*
1.1.1.4   root      305:   Set default configuration values.
1.1.1.2   root      306: */
                    307: void Configuration_SetDefault(void)
                    308: {
1.1.1.9   root      309:        int i;
                    310:        char *homeDir;
1.1.1.4   root      311: 
1.1.1.9   root      312:        /* Assume first-time install */
                    313:        bFirstTimeInstall = TRUE;
1.1.1.4   root      314: 
1.1.1.9   root      315:        /* Clear parameters */
                    316:        memset(&ConfigureParams, 0, sizeof(CNF_PARAMS));
                    317: 
                    318:        /* Set defaults for logging */
                    319:        strcpy(ConfigureParams.Log.sLogFileName, "stderr");
                    320:        ConfigureParams.Log.nTextLogLevel = LOG_INFO;
                    321:        ConfigureParams.Log.nAlertDlgLogLevel = LOG_INFO;
                    322: 
1.1.1.10  root      323:        /* Set defaults for floppy disk images */
                    324:        ConfigureParams.DiskImage.bAutoInsertDiskB = TRUE;
                    325:        ConfigureParams.DiskImage.nWriteProtection = WRITEPROT_OFF;
                    326:        strcpy(ConfigureParams.DiskImage.szDiskImageDirectory, szWorkingDir);
                    327:        File_AddSlashToEndFileName(ConfigureParams.DiskImage.szDiskImageDirectory);
                    328: 
                    329:        /* Set defaults for hard disks */
                    330:        ConfigureParams.HardDisk.bBootFromHardDisk = FALSE;
                    331:        ConfigureParams.HardDisk.nHardDiskDir = DRIVE_C;
                    332:        ConfigureParams.HardDisk.bUseHardDiskDirectories = FALSE;
1.1.1.9   root      333:        for (i=0; i<MAX_HARDDRIVES; i++)
                    334:        {
1.1.1.10  root      335:                strcpy(ConfigureParams.HardDisk.szHardDiskDirectories[i], szWorkingDir);
                    336:                File_CleanFileName(ConfigureParams.HardDisk.szHardDiskDirectories[i]);
1.1.1.9   root      337:        }
1.1.1.10  root      338:        ConfigureParams.HardDisk.bUseHardDiskImage = FALSE;
                    339:        strcpy(ConfigureParams.HardDisk.szHardDiskImage, szWorkingDir);
1.1.1.9   root      340: 
                    341:        /* Set defaults for Joysticks */
1.1.1.11! root      342:        for (i = 0; i < JOYSTICK_COUNT; i++)
1.1.1.9   root      343:        {
1.1.1.10  root      344:                ConfigureParams.Joysticks.Joy[i].nJoystickMode = JOYSTICK_DISABLED;
1.1.1.9   root      345:                ConfigureParams.Joysticks.Joy[i].bEnableAutoFire = FALSE;
1.1.1.10  root      346:                ConfigureParams.Joysticks.Joy[i].nJoyId = i;
                    347:                ConfigureParams.Joysticks.Joy[i].nKeyCodeUp = SDLK_UP;
                    348:                ConfigureParams.Joysticks.Joy[i].nKeyCodeDown = SDLK_DOWN;
                    349:                ConfigureParams.Joysticks.Joy[i].nKeyCodeLeft = SDLK_LEFT;
                    350:                ConfigureParams.Joysticks.Joy[i].nKeyCodeRight = SDLK_RIGHT;
                    351:                ConfigureParams.Joysticks.Joy[i].nKeyCodeFire = SDLK_RCTRL;
1.1.1.9   root      352:        }
1.1.1.10  root      353:        ConfigureParams.Joysticks.Joy[1].nJoyId = 0;    /* ST Joystick #1 is default joystick */
                    354:        ConfigureParams.Joysticks.Joy[0].nJoyId = 1;
1.1.1.9   root      355: 
                    356:        /* Set defaults for Keyboard */
                    357:        ConfigureParams.Keyboard.bDisableKeyRepeat = TRUE;
                    358:        ConfigureParams.Keyboard.nKeymapType = KEYMAP_SYMBOLIC;
                    359:        strcpy(ConfigureParams.Keyboard.szMappingFileName, "");
1.1.1.11! root      360:   
        !           361:   /* Set defaults for Shortcuts */
        !           362:   ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS] = SDLK_F12;
        !           363:   ConfigureParams.Shortcut.withoutModifier[SHORTCUT_FULLSCREEN] = SDLK_F11;
        !           364:   
        !           365:   ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS] = SDLK_o;
        !           366:   ConfigureParams.Shortcut.withModifier[SHORTCUT_FULLSCREEN] = SDLK_f;
        !           367:   ConfigureParams.Shortcut.withModifier[SHORTCUT_MOUSEMODE] = SDLK_m;
        !           368:   ConfigureParams.Shortcut.withModifier[SHORTCUT_COLDRESET] = SDLK_c;
        !           369:   ConfigureParams.Shortcut.withModifier[SHORTCUT_WARMRESET] = SDLK_r;
        !           370:   ConfigureParams.Shortcut.withModifier[SHORTCUT_SCREENSHOT] = SDLK_g;
        !           371:   ConfigureParams.Shortcut.withModifier[SHORTCUT_BOSSKEY] = SDLK_i;
        !           372:   ConfigureParams.Shortcut.withModifier[SHORTCUT_CURSOREMU] = SDLK_j;
        !           373:   ConfigureParams.Shortcut.withModifier[SHORTCUT_MAXSPEED] = SDLK_x;
        !           374:   ConfigureParams.Shortcut.withModifier[SHORTCUT_RECANIM] = SDLK_a;
        !           375:   ConfigureParams.Shortcut.withModifier[SHORTCUT_RECSOUND] = SDLK_y;
        !           376:   ConfigureParams.Shortcut.withModifier[SHORTCUT_SOUND] = SDLK_s;
        !           377:   ConfigureParams.Shortcut.withModifier[SHORTCUT_QUIT] = SDLK_q;
        !           378:          
1.1.1.9   root      379:        /* Set defaults for Memory */
1.1.1.10  root      380:        ConfigureParams.Memory.nMemorySize = 1;     /* 1 MiB */
1.1.1.11! root      381:        sprintf(ConfigureParams.Memory.szMemoryCaptureFileName, "%s%chatari.sav", szWorkingDir,PATHSEP);
1.1.1.9   root      382: 
                    383:        /* Set defaults for Printer */
                    384:        ConfigureParams.Printer.bEnablePrinting = FALSE;
                    385:        ConfigureParams.Printer.bPrintToFile = TRUE;
1.1.1.11! root      386:        sprintf(ConfigureParams.Printer.szPrintToFileName, "%s%chatari.prn", szWorkingDir,PATHSEP);
1.1.1.9   root      387: 
                    388:        /* Set defaults for RS232 */
                    389:        ConfigureParams.RS232.bEnableRS232 = FALSE;
                    390:        strcpy(ConfigureParams.RS232.szOutFileName, "/dev/modem");
                    391:        strcpy(ConfigureParams.RS232.szInFileName, "/dev/modem");
                    392: 
                    393:        /* Set defaults for MIDI */
                    394:        ConfigureParams.Midi.bEnableMidi = FALSE;
                    395:        strcpy(ConfigureParams.Midi.szMidiOutFileName, "/dev/midi00");
                    396: 
                    397:        /* Set defaults for Screen */
                    398:        ConfigureParams.Screen.bFullScreen = FALSE;
                    399:        ConfigureParams.Screen.bFrameSkip = FALSE;
                    400:        ConfigureParams.Screen.bAllowOverscan = TRUE;
                    401:        ConfigureParams.Screen.bInterleavedScreen = FALSE;
                    402:        ConfigureParams.Screen.ChosenDisplayMode = DISPLAYMODE_HICOL_LOWRES;
                    403:        ConfigureParams.Screen.bUseHighRes = FALSE;
                    404:        ConfigureParams.Screen.bUseExtVdiResolutions = FALSE;
                    405:        ConfigureParams.Screen.nVdiResolution = GEMRES_640x480;
                    406:        ConfigureParams.Screen.nVdiColors = GEMCOLOUR_16;
                    407:        ConfigureParams.Screen.bCaptureChange = FALSE;
                    408:        ConfigureParams.Screen.nFramesPerSecond = 25;
                    409: 
                    410:        /* Set defaults for Sound */
                    411:        ConfigureParams.Sound.bEnableSound = TRUE;
                    412:        ConfigureParams.Sound.nPlaybackQuality = PLAYBACK_MEDIUM;
1.1.1.11! root      413:        sprintf(ConfigureParams.Sound.szYMCaptureFileName, "%s%chatari.wav", szWorkingDir,PATHSEP);
1.1.1.9   root      414: 
                    415:        /* Set defaults for Rom */
1.1.1.11! root      416:        sprintf(ConfigureParams.Rom.szTosImageFileName, "%s%ctos.img", DATADIR,PATHSEP);
1.1.1.9   root      417:        strcpy(ConfigureParams.Rom.szCartridgeImageFileName, "");
                    418: 
                    419:        /* Set defaults for System */
                    420:        ConfigureParams.System.nCpuLevel = 0;
                    421:        ConfigureParams.System.nCpuFreq = 8;
                    422:        ConfigureParams.System.bCompatibleCpu = FALSE;
                    423:        /*ConfigureParams.System.bAddressSpace24 = TRUE;*/
                    424:        ConfigureParams.System.nMachineType = MACHINE_ST;
                    425:        ConfigureParams.System.bBlitter = FALSE;
                    426:        ConfigureParams.System.bPatchTimerD = TRUE;
                    427:        ConfigureParams.System.bRealTimeClock = TRUE;
                    428:        ConfigureParams.System.nMinMaxSpeed = MINMAXSPEED_MIN;
                    429:        ConfigureParams.System.bSlowFDC = FALSE;
                    430: 
                    431:        /* Initialize the configuration file name */
                    432:        homeDir = getenv("HOME");
                    433:        if (homeDir != NULL && homeDir[0] != 0 && strlen(homeDir) < sizeof(sConfigFileName)-13)
1.1.1.11! root      434:                sprintf(sConfigFileName, "%s%c.hatari.cfg", homeDir,PATHSEP);
1.1.1.9   root      435:        else
                    436:                strcpy(sConfigFileName, "hatari.cfg");
1.1.1.2   root      437: }
                    438: 
                    439: 
                    440: /*-----------------------------------------------------------------------*/
                    441: /*
1.1.1.8   root      442:   Copy details from configuration structure into global variables for system,
                    443:   clean file names, etc...
                    444: */
                    445: void Configuration_WorkOnDetails(BOOL bReset)
                    446: {
1.1.1.9   root      447:        /* Set resolution change */
                    448:        if (bReset)
                    449:        {
                    450:                bUseVDIRes = ConfigureParams.Screen.bUseExtVdiResolutions;
                    451:                bUseHighRes = (!bUseVDIRes && ConfigureParams.Screen.bUseHighRes)
                    452:                                          || (bUseVDIRes && ConfigureParams.Screen.nVdiColors==GEMCOLOUR_2);
                    453:                VDI_SetResolution(ConfigureParams.Screen.nVdiResolution, ConfigureParams.Screen.nVdiColors);
                    454:        }
                    455: 
                    456:        /* Set playback frequency */
                    457:        if (ConfigureParams.Sound.bEnableSound)
                    458:                Audio_SetOutputAudioFreq(ConfigureParams.Sound.nPlaybackQuality);
                    459: 
                    460:        /* CPU settings */
                    461:        if (ConfigureParams.System.nCpuFreq < 12)
                    462:        {
                    463:                ConfigureParams.System.nCpuFreq = 8;
                    464:                nCpuFreqShift = 0;
                    465:        }
                    466:        else if (ConfigureParams.System.nCpuFreq > 26)
                    467:        {
                    468:                ConfigureParams.System.nCpuFreq = 32;
                    469:                nCpuFreqShift = 2;
                    470:        }
                    471:        else
                    472:        {
                    473:                ConfigureParams.System.nCpuFreq = 16;
                    474:                nCpuFreqShift = 1;
                    475:        }
                    476: 
                    477:        /* Clean file and directory names */
                    478:        File_MakeAbsoluteName(ConfigureParams.Rom.szTosImageFileName);
1.1.1.11! root      479:        if (strlen(ConfigureParams.Rom.szCartridgeImageFileName) > 0)
        !           480:                File_MakeAbsoluteName(ConfigureParams.Rom.szCartridgeImageFileName);
1.1.1.10  root      481:        File_MakeAbsoluteName(ConfigureParams.HardDisk.szHardDiskImage);
                    482:        File_CleanFileName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
                    483:        File_MakeAbsoluteName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
1.1.1.9   root      484:        File_MakeAbsoluteName(ConfigureParams.Midi.szMidiOutFileName);
                    485:        File_MakeAbsoluteName(ConfigureParams.RS232.szOutFileName);
                    486:        File_MakeAbsoluteName(ConfigureParams.RS232.szInFileName);
1.1.1.8   root      487: }
                    488: 
                    489: 
                    490: /*-----------------------------------------------------------------------*/
                    491: /*
1.1.1.6   root      492:   Load a settings section from the configuration file.
1.1       root      493: */
1.1.1.9   root      494: static int Configuration_LoadSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
1.1       root      495: {
1.1.1.9   root      496:        int ret;
1.1       root      497: 
1.1.1.9   root      498:        ret = input_config(pFilename, configs, pSection);
1.1       root      499: 
1.1.1.9   root      500:        if (ret < 0)
                    501:                fprintf(stderr, "Can not load configuration file %s (section %s).\n",
                    502:                        sConfigFileName, pSection);
1.1       root      503: 
1.1.1.9   root      504:        return ret;
1.1       root      505: }
                    506: 
                    507: 
                    508: /*-----------------------------------------------------------------------*/
                    509: /*
1.1.1.9   root      510:   Load program setting from configuration file. If psFileName is NULL, use
                    511:   the default (i.e. the users) configuration file.
1.1       root      512: */
1.1.1.9   root      513: void Configuration_Load(const char *psFileName)
1.1       root      514: {
1.1.1.9   root      515:        if (psFileName == NULL)
                    516:                psFileName = sConfigFileName;
                    517: 
                    518:        if (!File_Exists(psFileName))
                    519:        {
                    520:                fprintf(stderr, "Configuration file %s not found.\n", psFileName);
                    521:                return;
                    522:        }
                    523: 
                    524:        bFirstTimeInstall = FALSE;
                    525: 
                    526:        Configuration_LoadSection(psFileName, configs_Log, "[Log]");
                    527:        Configuration_LoadSection(psFileName, configs_Screen, "[Screen]");
                    528:        Configuration_LoadSection(psFileName, configs_Joystick0, "[Joystick0]");
                    529:        Configuration_LoadSection(psFileName, configs_Joystick1, "[Joystick1]");
1.1.1.10  root      530:        Configuration_LoadSection(psFileName, configs_Joystick2, "[Joystick2]");
                    531:        Configuration_LoadSection(psFileName, configs_Joystick3, "[Joystick3]");
                    532:        Configuration_LoadSection(psFileName, configs_Joystick4, "[Joystick4]");
                    533:        Configuration_LoadSection(psFileName, configs_Joystick5, "[Joystick5]");
1.1.1.9   root      534:        Configuration_LoadSection(psFileName, configs_Keyboard, "[Keyboard]");
1.1.1.11! root      535:        Configuration_LoadSection(psFileName, configs_ShortCutWithMod, "[ShortcutsWithModifiers]");
        !           536:        Configuration_LoadSection(psFileName, configs_ShortCutWithoutMod, "[ShortcutsWithoutModifiers]");
1.1.1.9   root      537:        Configuration_LoadSection(psFileName, configs_Sound, "[Sound]");
                    538:        Configuration_LoadSection(psFileName, configs_Memory, "[Memory]");
1.1.1.10  root      539:        Configuration_LoadSection(psFileName, configs_OldFloppy, "[Floppy]");  /* <- to be removed */
1.1.1.9   root      540:        Configuration_LoadSection(psFileName, configs_Floppy, "[Floppy]");
1.1.1.10  root      541:        Configuration_LoadSection(psFileName, configs_OldHardDisc, "[HardDisc]");  /* <- to be removed */
                    542:        Configuration_LoadSection(psFileName, configs_HardDisk, "[HardDisk]");
1.1.1.9   root      543:        Configuration_LoadSection(psFileName, configs_Rom, "[ROM]");
                    544:        Configuration_LoadSection(psFileName, configs_Rs232, "[RS232]");
                    545:        Configuration_LoadSection(psFileName, configs_Printer, "[Printer]");
                    546:        Configuration_LoadSection(psFileName, configs_Midi, "[Midi]");
                    547:        Configuration_LoadSection(psFileName, configs_System, "[System]");
                    548: 
                    549:        /* Copy details to global variables */
                    550:        cpu_level = ConfigureParams.System.nCpuLevel;
                    551:        cpu_compatible = ConfigureParams.System.bCompatibleCpu;
1.1       root      552: 
1.1.1.9   root      553:        Configuration_WorkOnDetails(TRUE);
1.1       root      554: }
                    555: 
                    556: 
                    557: /*-----------------------------------------------------------------------*/
                    558: /*
1.1.1.6   root      559:   Save a settings section to configuration file
1.1       root      560: */
1.1.1.9   root      561: static int Configuration_SaveSection(const char *pFilename, const struct Config_Tag configs[], const char *pSection)
1.1       root      562: {
1.1.1.9   root      563:        int ret;
1.1       root      564: 
1.1.1.9   root      565:        ret = update_config(pFilename, configs, pSection);
1.1       root      566: 
1.1.1.9   root      567:        if (ret < 0)
                    568:                fprintf(stderr, "Error while updating section %s\n", pSection);
1.1       root      569: 
1.1.1.9   root      570:        return ret;
1.1       root      571: }
                    572: 
                    573: 
                    574: /*-----------------------------------------------------------------------*/
                    575: /*
1.1.1.6   root      576:   Save program setting to configuration file
1.1       root      577: */
1.1.1.6   root      578: void Configuration_Save(void)
1.1       root      579: {
1.1.1.9   root      580:        if (Configuration_SaveSection(sConfigFileName, configs_Log, "[Log]") < 0)
                    581:        {
                    582:                fprintf(stderr, "Error saving config file.\n");
                    583:                return;
                    584:        }
                    585:        Configuration_SaveSection(sConfigFileName, configs_Screen, "[Screen]");
                    586:        Configuration_SaveSection(sConfigFileName, configs_Joystick0, "[Joystick0]");
                    587:        Configuration_SaveSection(sConfigFileName, configs_Joystick1, "[Joystick1]");
1.1.1.10  root      588:        Configuration_SaveSection(sConfigFileName, configs_Joystick2, "[Joystick2]");
                    589:        Configuration_SaveSection(sConfigFileName, configs_Joystick3, "[Joystick3]");
                    590:        Configuration_SaveSection(sConfigFileName, configs_Joystick4, "[Joystick4]");
                    591:        Configuration_SaveSection(sConfigFileName, configs_Joystick5, "[Joystick5]");
1.1.1.9   root      592:        Configuration_SaveSection(sConfigFileName, configs_Keyboard, "[Keyboard]");
1.1.1.11! root      593:        Configuration_SaveSection(sConfigFileName, configs_ShortCutWithMod, "[ShortcutsWithModifiers]");
        !           594:        Configuration_SaveSection(sConfigFileName, configs_ShortCutWithoutMod, "[ShortcutsWithoutModifiers]");
1.1.1.9   root      595:        Configuration_SaveSection(sConfigFileName, configs_Sound, "[Sound]");
                    596:        Configuration_SaveSection(sConfigFileName, configs_Memory, "[Memory]");
                    597:        Configuration_SaveSection(sConfigFileName, configs_Floppy, "[Floppy]");
1.1.1.10  root      598:        Configuration_SaveSection(sConfigFileName, configs_HardDisk, "[HardDisk]");
1.1.1.9   root      599:        Configuration_SaveSection(sConfigFileName, configs_Rom, "[ROM]");
                    600:        Configuration_SaveSection(sConfigFileName, configs_Rs232, "[RS232]");
                    601:        Configuration_SaveSection(sConfigFileName, configs_Printer, "[Printer]");
                    602:        Configuration_SaveSection(sConfigFileName, configs_Midi, "[Midi]");
                    603:        Configuration_SaveSection(sConfigFileName, configs_System, "[System]");
1.1       root      604: }
1.1.1.6   root      605: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.