Annotation of hatari/src/dialog.c, revision 1.1.1.8

1.1       root        1: /*
1.1.1.4   root        2:   Hatari - dialog.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:   This is normal 'C' code to handle our options dialog. We keep all our configuration details
                      8:   in a variable 'ConfigureParams'. When we open our dialog we copy this and then when we 'OK'
1.1.1.2   root        9:   or 'Cancel' the dialog we can compare and makes the necessary changes.
1.1       root       10: */
1.1.1.8 ! root       11: char Dialog_rcsid[] = "Hatari $Id: dialog.c,v 1.46 2005/05/11 08:09:05 thothy Exp $";
1.1.1.3   root       12: 
1.1       root       13: #include "main.h"
                     14: #include "configuration.h"
                     15: #include "audio.h"
                     16: #include "dialog.h"
                     17: #include "file.h"
                     18: #include "floppy.h"
1.1.1.2   root       19: #include "gemdos.h"
                     20: #include "hdc.h"
1.1.1.8 ! root       21: #include "ioMem.h"
1.1       root       22: #include "joy.h"
                     23: #include "keymap.h"
                     24: #include "m68000.h"
                     25: #include "memorySnapShot.h"
                     26: #include "misc.h"
                     27: #include "printer.h"
1.1.1.3   root       28: #include "reset.h"
1.1       root       29: #include "rs232.h"
                     30: #include "screen.h"
1.1.1.3   root       31: #include "screenSnapShot.h"
1.1       root       32: #include "sound.h"
                     33: #include "tos.h"
                     34: #include "vdi.h"
                     35: #include "video.h"
1.1.1.2   root       36: #include "sdlgui.h"
1.1.1.3   root       37: #include "uae-cpu/hatari-glue.h"
                     38: 
1.1       root       39: 
1.1.1.5   root       40: CNF_PARAMS DialogParams;   /* List of configuration for dialogs (so the user can also choose 'Cancel') */
1.1.1.2   root       41: 
                     42: 
                     43: /*-----------------------------------------------------------------------*/
1.1       root       44: /*
                     45:   Check if need to warn user that changes will take place after reset
                     46:   Return TRUE if wants to reset
                     47: */
1.1.1.6   root       48: static BOOL Dialog_DoNeedReset(void)
1.1       root       49: {
1.1.1.2   root       50:   /* Did we change colour/mono monitor? If so, must reset */
1.1       root       51:   if (ConfigureParams.Screen.bUseHighRes!=DialogParams.Screen.bUseHighRes)
                     52:     return(TRUE);
1.1.1.2   root       53:   /* Did change to GEM VDI display? */
1.1.1.7   root       54:   if (ConfigureParams.Screen.bUseExtVdiResolutions != DialogParams.Screen.bUseExtVdiResolutions)
1.1       root       55:     return(TRUE);
1.1.1.2   root       56:   /* Did change GEM resolution or colour depth? */
1.1.1.7   root       57:   if ( DialogParams.Screen.bUseExtVdiResolutions &&
                     58:       ((ConfigureParams.Screen.nVdiResolution != DialogParams.Screen.nVdiResolution)
                     59:        || (ConfigureParams.Screen.nVdiColors != DialogParams.Screen.nVdiColors)) )
1.1       root       60:     return(TRUE);
1.1.1.2   root       61:   /* Did change TOS ROM image? */
1.1.1.7   root       62:   if (strcmp(DialogParams.Rom.szTosImageFileName, ConfigureParams.Rom.szTosImageFileName))
1.1.1.2   root       63:     return(TRUE);
                     64:   /* Did change HD image? */
                     65:   if (strcmp(DialogParams.HardDisc.szHardDiscImage, ConfigureParams.HardDisc.szHardDiscImage))
                     66:     return(TRUE);
                     67:   /* Did change GEMDOS drive? */
                     68:   if (strcmp(DialogParams.HardDisc.szHardDiscDirectories[0], ConfigureParams.HardDisc.szHardDiscDirectories[0]))
                     69:     return(TRUE);
1.1       root       70: 
                     71:   return(FALSE);
                     72: }
                     73: 
1.1.1.2   root       74: 
                     75: /*-----------------------------------------------------------------------*/
1.1       root       76: /*
                     77:   Copy details back to configuration and perform reset
                     78: */
1.1.1.6   root       79: static void Dialog_CopyDialogParamsToConfiguration(BOOL bForceReset)
1.1       root       80: {
                     81:   BOOL NeedReset;
1.1.1.2   root       82:   BOOL newGemdosDrive;
1.1.1.8 ! root       83:   BOOL bReInitIoMem = FALSE;
1.1       root       84: 
1.1.1.2   root       85:   /* Do we need to warn user of that changes will only take effect after reset? */
1.1       root       86:   if (bForceReset)
                     87:     NeedReset = bForceReset;
                     88:   else
                     89:     NeedReset = Dialog_DoNeedReset();
                     90: 
1.1.1.2   root       91:   /* Do need to change resolution? Need if change display/overscan settings */
                     92:   /*(if switch between Colour/Mono cause reset later) */
1.1.1.8 ! root       93:   if (DialogParams.Screen.ChosenDisplayMode != ConfigureParams.Screen.ChosenDisplayMode
        !            94:       || DialogParams.Screen.bAllowOverscan != ConfigureParams.Screen.bAllowOverscan)
        !            95:   {
1.1.1.5   root       96:     ConfigureParams.Screen.ChosenDisplayMode = DialogParams.Screen.ChosenDisplayMode;
                     97:     ConfigureParams.Screen.bAllowOverscan = DialogParams.Screen.bAllowOverscan;
1.1.1.8 ! root       98:     PrevSTRes = -1;
        !            99:     Screen_DidResolutionChange();
1.1       root      100:   }
1.1.1.2   root      101: 
                    102:   /* Did set new printer parameters? */
                    103:   if( (DialogParams.Printer.bEnablePrinting!=ConfigureParams.Printer.bEnablePrinting)
                    104:      || (DialogParams.Printer.bPrintToFile!=ConfigureParams.Printer.bPrintToFile)
                    105:      || (strcmp(DialogParams.Printer.szPrintToFileName,ConfigureParams.Printer.szPrintToFileName)) )
1.1       root      106:     Printer_CloseAllConnections();
1.1.1.2   root      107: 
                    108:   /* Did set new RS232 parameters? */
                    109:   if( (DialogParams.RS232.bEnableRS232!=ConfigureParams.RS232.bEnableRS232)
1.1.1.6   root      110:      || (strcmp(DialogParams.RS232.szOutFileName, ConfigureParams.RS232.szOutFileName))
                    111:      || (strcmp(DialogParams.RS232.szInFileName, ConfigureParams.RS232.szInFileName)) )
                    112:     RS232_UnInit();
1.1.1.2   root      113: 
                    114:   /* Did stop sound? Or change playback Hz. If so, also stop sound recording */
1.1.1.6   root      115:   if (!DialogParams.Sound.bEnableSound || DialogParams.Sound.nPlaybackQuality != ConfigureParams.Sound.nPlaybackQuality)
1.1.1.2   root      116:   {
1.1.1.6   root      117:     if (Sound_AreWeRecording())
                    118:       Sound_EndRecording();
                    119:     Audio_UnInit();
1.1       root      120:   }
                    121: 
1.1.1.2   root      122:   /* Did change GEMDOS drive? */
                    123:   if( strcmp(DialogParams.HardDisc.szHardDiscDirectories[0], ConfigureParams.HardDisc.szHardDiscDirectories[0])!=0 )
                    124:   {
                    125:     GemDOS_UnInitDrives();
                    126:     newGemdosDrive = TRUE;
                    127:   }
                    128:   else
                    129:   {
                    130:     newGemdosDrive = FALSE;
                    131:   }
                    132: 
                    133:   /* Did change HD image? */
                    134:   if( strcmp(DialogParams.HardDisc.szHardDiscImage, ConfigureParams.HardDisc.szHardDiscImage)!=0
                    135:      && ACSI_EMU_ON )
                    136:   {
                    137:     HDC_UnInit();
                    138:   }
                    139: 
1.1.1.8 ! root      140:   /* Did change blitter, rtc or system type? */
        !           141:   if (DialogParams.System.bBlitter != ConfigureParams.System.bBlitter
        !           142:       || DialogParams.System.bRealTimeClock != ConfigureParams.System.bRealTimeClock
        !           143:       || DialogParams.System.nMachineType != ConfigureParams.System.nMachineType)
        !           144:   {
        !           145:     IoMem_UnInit();
        !           146:     bReInitIoMem = TRUE;
        !           147:   }
        !           148: 
1.1.1.2   root      149:   /* Copy details to configuration, so can be saved out or set on reset */
1.1       root      150:   ConfigureParams = DialogParams;
                    151: 
1.1.1.2   root      152:   /* Copy details to global, if we reset copy them all */
1.1.1.7   root      153:   Configuration_WorkOnDetails(NeedReset);
1.1       root      154: 
1.1.1.2   root      155:   /* Set keyboard remap file */
1.1.1.5   root      156:   if(ConfigureParams.Keyboard.nKeymapType == KEYMAP_LOADED)
                    157:     Keymap_LoadRemapFile(ConfigureParams.Keyboard.szMappingFileName);
1.1.1.2   root      158: 
                    159:   /* Did the user changed the CPU mode? */
1.1.1.3   root      160:   check_prefs_changed_cpu(DialogParams.System.nCpuLevel, DialogParams.System.bCompatibleCpu);
1.1.1.2   root      161: 
                    162:   /* Mount a new HD image: */
                    163:   if( !ACSI_EMU_ON && !File_DoesFileNameEndWithSlash(ConfigureParams.HardDisc.szHardDiscImage)
                    164:       && File_Exists(ConfigureParams.HardDisc.szHardDiscImage) )
                    165:   {
                    166:     HDC_Init(ConfigureParams.HardDisc.szHardDiscImage);
                    167:   }
                    168: 
                    169:   /* Mount a new GEMDOS drive? */
                    170:   if( newGemdosDrive )
                    171:   {
                    172:     GemDOS_InitDrives();
                    173:   }
                    174: 
1.1.1.6   root      175:   /* Restart audio sub system if necessary: */
                    176:   if (ConfigureParams.Sound.bEnableSound && !bSoundWorking)
                    177:   {
                    178:     Audio_Init();
                    179:   }
                    180: 
                    181:   /* Re-initialize the RS232 emulation: */
                    182:   if (ConfigureParams.RS232.bEnableRS232 && !bConnectedRS232)
                    183:   {
                    184:     RS232_Init();
                    185:   }
                    186: 
1.1.1.8 ! root      187:   /* Re-init IO memory map? */
        !           188:   if (bReInitIoMem)
        !           189:   {
        !           190:     IoMem_Init();
        !           191:   }
        !           192: 
1.1.1.2   root      193:   /* Do we need to perform reset? */
                    194:   if (NeedReset)
                    195:   {
1.1       root      196:     Reset_Cold();
                    197:   }
                    198: 
1.1.1.2   root      199:   /* Go into/return from full screen if flagged */
1.1       root      200:   if ( (!bInFullScreen) && (DialogParams.Screen.bFullScreen) )
                    201:     Screen_EnterFullScreen();
                    202:   else if ( bInFullScreen && (!DialogParams.Screen.bFullScreen) )
                    203:     Screen_ReturnFromFullScreen();
                    204: }
                    205: 
                    206: 
1.1.1.2   root      207: /*-----------------------------------------------------------------------*/
1.1       root      208: /*
1.1.1.2   root      209:   Open Property sheet Options dialog
                    210:   Return TRUE if user choses OK, or FALSE if cancel!
1.1       root      211: */
1.1.1.2   root      212: BOOL Dialog_DoProperty(void)
1.1       root      213: {
1.1.1.2   root      214:   BOOL bOKDialog;  /* Did user 'OK' dialog? */
                    215:   BOOL bForceReset;
1.1       root      216: 
1.1.1.2   root      217:   Main_PauseEmulation();
1.1       root      218: 
1.1.1.2   root      219:   /* Copy details to DialogParams (this is so can restore if 'Cancel' dialog) */
                    220:   ConfigureParams.Screen.bFullScreen = bInFullScreen;
                    221:   DialogParams = ConfigureParams;
1.1       root      222: 
1.1.1.2   root      223:   bForceReset = FALSE;
1.1       root      224: 
1.1.1.2   root      225:   bOKDialog = Dialog_MainDlg(&bForceReset);
1.1       root      226: 
1.1.1.2   root      227:   /* Copy details to configuration, and ask user if wishes to reset */
                    228:   if (bOKDialog)
                    229:     Dialog_CopyDialogParamsToConfiguration(bForceReset);
                    230: 
                    231:   Main_UnPauseEmulation();
                    232: 
1.1.1.6   root      233:   if (bQuitProgram)
                    234:     set_special(SPCFLAG_BRK);           /* Assure that CPU core shuts down */
                    235: 
1.1.1.2   root      236:   return(bOKDialog);
1.1       root      237: }

unix.superglobalmegacorp.com

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