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

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.6 ! root       11: char Dialog_rcsid[] = "Hatari $Id: dialog.c,v 1.40 2004/07/05 20:06:20 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 "debug.h"
                     17: #include "dialog.h"
                     18: #include "file.h"
                     19: #include "floppy.h"
1.1.1.2   root       20: #include "gemdos.h"
                     21: #include "hdc.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: #include "intercept.h"
                     39: 
1.1       root       40: 
1.1.1.5   root       41: CNF_PARAMS DialogParams;   /* List of configuration for dialogs (so the user can also choose 'Cancel') */
1.1.1.2   root       42: 
                     43: 
                     44: /*-----------------------------------------------------------------------*/
1.1       root       45: /*
                     46:   Check if need to warn user that changes will take place after reset
                     47:   Return TRUE if wants to reset
                     48: */
1.1.1.6 ! root       49: static BOOL Dialog_DoNeedReset(void)
1.1       root       50: {
1.1.1.2   root       51:   /* Did we change colour/mono monitor? If so, must reset */
1.1       root       52:   if (ConfigureParams.Screen.bUseHighRes!=DialogParams.Screen.bUseHighRes)
                     53:     return(TRUE);
1.1.1.2   root       54:   /* Did change to GEM VDI display? */
1.1       root       55:   if (ConfigureParams.TOSGEM.bUseExtGEMResolutions!=DialogParams.TOSGEM.bUseExtGEMResolutions)
                     56:     return(TRUE);
1.1.1.2   root       57:   /* Did change GEM resolution or colour depth? */
1.1.1.3   root       58:   if ( DialogParams.TOSGEM.bUseExtGEMResolutions &&
                     59:       ((ConfigureParams.TOSGEM.nGEMResolution!=DialogParams.TOSGEM.nGEMResolution)
                     60:        || (ConfigureParams.TOSGEM.nGEMColours!=DialogParams.TOSGEM.nGEMColours)) )
1.1       root       61:     return(TRUE);
1.1.1.2   root       62:   /* Did change TOS ROM image? */
                     63:   if (strcmp(DialogParams.TOSGEM.szTOSImageFileName, ConfigureParams.TOSGEM.szTOSImageFileName))
                     64:     return(TRUE);
                     65:   /* Did change HD image? */
                     66:   if (strcmp(DialogParams.HardDisc.szHardDiscImage, ConfigureParams.HardDisc.szHardDiscImage))
                     67:     return(TRUE);
                     68:   /* Did change GEMDOS drive? */
                     69:   if (strcmp(DialogParams.HardDisc.szHardDiscDirectories[0], ConfigureParams.HardDisc.szHardDiscDirectories[0]))
                     70:     return(TRUE);
1.1       root       71: 
                     72:   return(FALSE);
                     73: }
                     74: 
1.1.1.2   root       75: 
                     76: /*-----------------------------------------------------------------------*/
1.1       root       77: /*
                     78:   Copy details back to configuration and perform reset
                     79: */
1.1.1.6 ! root       80: static void Dialog_CopyDialogParamsToConfiguration(BOOL bForceReset)
1.1       root       81: {
                     82:   BOOL NeedReset;
1.1.1.2   root       83:   BOOL newGemdosDrive;
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.5   root       93:   if( (DialogParams.Screen.ChosenDisplayMode!=ConfigureParams.Screen.ChosenDisplayMode)
                     94:       || (DialogParams.Screen.bAllowOverscan!=ConfigureParams.Screen.bAllowOverscan) ) {
                     95:     if(bInFullScreen) Screen_ReturnFromFullScreen();
                     96:     ConfigureParams.Screen.ChosenDisplayMode = DialogParams.Screen.ChosenDisplayMode;
                     97:     ConfigureParams.Screen.bAllowOverscan = DialogParams.Screen.bAllowOverscan;
                     98:     if(bInFullScreen)
1.1       root       99:       Screen_EnterFullScreen();
1.1.1.5   root      100:     else {
                    101:       PrevSTRes = -1;
                    102:       Screen_DidResolutionChange();
1.1       root      103:     }
                    104:   }
1.1.1.2   root      105: 
                    106:   /* Did set new printer parameters? */
                    107:   if( (DialogParams.Printer.bEnablePrinting!=ConfigureParams.Printer.bEnablePrinting)
                    108:      || (DialogParams.Printer.bPrintToFile!=ConfigureParams.Printer.bPrintToFile)
                    109:      || (strcmp(DialogParams.Printer.szPrintToFileName,ConfigureParams.Printer.szPrintToFileName)) )
1.1       root      110:     Printer_CloseAllConnections();
1.1.1.2   root      111: 
                    112:   /* Did set new RS232 parameters? */
                    113:   if( (DialogParams.RS232.bEnableRS232!=ConfigureParams.RS232.bEnableRS232)
1.1.1.6 ! root      114:      || (strcmp(DialogParams.RS232.szOutFileName, ConfigureParams.RS232.szOutFileName))
        !           115:      || (strcmp(DialogParams.RS232.szInFileName, ConfigureParams.RS232.szInFileName)) )
        !           116:     RS232_UnInit();
1.1.1.2   root      117: 
                    118:   /* Did stop sound? Or change playback Hz. If so, also stop sound recording */
1.1.1.6 ! root      119:   if (!DialogParams.Sound.bEnableSound || DialogParams.Sound.nPlaybackQuality != ConfigureParams.Sound.nPlaybackQuality)
1.1.1.2   root      120:   {
1.1.1.6 ! root      121:     if (Sound_AreWeRecording())
        !           122:       Sound_EndRecording();
        !           123:     Audio_UnInit();
1.1       root      124:   }
                    125: 
1.1.1.2   root      126:   /* Did change GEMDOS drive? */
                    127:   if( strcmp(DialogParams.HardDisc.szHardDiscDirectories[0], ConfigureParams.HardDisc.szHardDiscDirectories[0])!=0 )
                    128:   {
                    129:     GemDOS_UnInitDrives();
                    130:     newGemdosDrive = TRUE;
                    131:   }
                    132:   else
                    133:   {
                    134:     newGemdosDrive = FALSE;
                    135:   }
                    136: 
                    137:   /* Did change HD image? */
                    138:   if( strcmp(DialogParams.HardDisc.szHardDiscImage, ConfigureParams.HardDisc.szHardDiscImage)!=0
                    139:      && ACSI_EMU_ON )
                    140:   {
                    141:     HDC_UnInit();
                    142:   }
                    143: 
                    144:   /* Copy details to configuration, so can be saved out or set on reset */
1.1       root      145:   ConfigureParams = DialogParams;
                    146: 
1.1.1.2   root      147:   /* Copy details to global, if we reset copy them all */
1.1       root      148:   Dialog_CopyDetailsFromConfiguration(NeedReset);
                    149: 
1.1.1.2   root      150:   /* Set keyboard remap file */
1.1.1.5   root      151:   if(ConfigureParams.Keyboard.nKeymapType == KEYMAP_LOADED)
                    152:     Keymap_LoadRemapFile(ConfigureParams.Keyboard.szMappingFileName);
1.1.1.2   root      153: 
                    154:   /* Did the user changed the CPU mode? */
1.1.1.3   root      155:   check_prefs_changed_cpu(DialogParams.System.nCpuLevel, DialogParams.System.bCompatibleCpu);
1.1.1.2   root      156: 
                    157:   /* Mount a new HD image: */
                    158:   if( !ACSI_EMU_ON && !File_DoesFileNameEndWithSlash(ConfigureParams.HardDisc.szHardDiscImage)
                    159:       && File_Exists(ConfigureParams.HardDisc.szHardDiscImage) )
                    160:   {
                    161:     HDC_Init(ConfigureParams.HardDisc.szHardDiscImage);
                    162:   }
                    163: 
                    164:   /* Mount a new GEMDOS drive? */
                    165:   if( newGemdosDrive )
                    166:   {
                    167:     GemDOS_InitDrives();
                    168:   }
                    169: 
1.1.1.3   root      170:   /* Did change blitter status? */
                    171:   Intercept_EnableBlitter(ConfigureParams.System.bBlitter);
                    172: 
1.1.1.6 ! root      173:   /* Restart audio sub system if necessary: */
        !           174:   if (ConfigureParams.Sound.bEnableSound && !bSoundWorking)
        !           175:   {
        !           176:     Audio_Init();
        !           177:   }
        !           178: 
        !           179:   /* Re-initialize the RS232 emulation: */
        !           180:   if (ConfigureParams.RS232.bEnableRS232 && !bConnectedRS232)
        !           181:   {
        !           182:     RS232_Init();
        !           183:   }
        !           184: 
1.1.1.2   root      185:   /* Do we need to perform reset? */
                    186:   if (NeedReset)
                    187:   {
1.1       root      188:     Reset_Cold();
                    189:   }
                    190: 
1.1.1.2   root      191:   /* Go into/return from full screen if flagged */
1.1       root      192:   if ( (!bInFullScreen) && (DialogParams.Screen.bFullScreen) )
                    193:     Screen_EnterFullScreen();
                    194:   else if ( bInFullScreen && (!DialogParams.Screen.bFullScreen) )
                    195:     Screen_ReturnFromFullScreen();
                    196: }
                    197: 
                    198: 
1.1.1.2   root      199: /*-----------------------------------------------------------------------*/
1.1       root      200: /*
                    201:   Copy details from configuration structure into global variables for system
                    202: */
                    203: void Dialog_CopyDetailsFromConfiguration(BOOL bReset)
                    204: {
1.1.1.2   root      205:   /* Set resolution change */
1.1.1.3   root      206:   if (bReset)
                    207:   {
1.1       root      208:     bUseVDIRes = ConfigureParams.TOSGEM.bUseExtGEMResolutions;
1.1.1.3   root      209:     bUseHighRes = (!bUseVDIRes && ConfigureParams.Screen.bUseHighRes)
1.1.1.5   root      210:                    || (bUseVDIRes && ConfigureParams.TOSGEM.nGEMColours==GEMCOLOUR_2);
1.1.1.3   root      211:     VDI_SetResolution(ConfigureParams.TOSGEM.nGEMResolution, ConfigureParams.TOSGEM.nGEMColours);
1.1       root      212:   }
                    213: 
1.1.1.2   root      214:   /* Set playback frequency */
1.1.1.6 ! root      215:   if (ConfigureParams.Sound.bEnableSound)
1.1.1.2   root      216:     Audio_SetOutputAudioFreq(ConfigureParams.Sound.nPlaybackQuality);
                    217: 
1.1.1.3   root      218:   /* Remove slashes, etc.. from names */
1.1       root      219:   File_CleanFileName(ConfigureParams.TOSGEM.szTOSImageFileName);
                    220: }
                    221: 
1.1.1.2   root      222: 
                    223: /*-----------------------------------------------------------------------*/
1.1       root      224: /*
1.1.1.2   root      225:   Open Property sheet Options dialog
                    226:   Return TRUE if user choses OK, or FALSE if cancel!
1.1       root      227: */
1.1.1.2   root      228: BOOL Dialog_DoProperty(void)
1.1       root      229: {
1.1.1.2   root      230:   BOOL bOKDialog;  /* Did user 'OK' dialog? */
                    231:   BOOL bForceReset;
1.1       root      232: 
1.1.1.2   root      233:   Main_PauseEmulation();
1.1       root      234: 
1.1.1.2   root      235:   /* Copy details to DialogParams (this is so can restore if 'Cancel' dialog) */
                    236:   ConfigureParams.Screen.bFullScreen = bInFullScreen;
                    237:   DialogParams = ConfigureParams;
1.1       root      238: 
1.1.1.2   root      239:   bForceReset = FALSE;
1.1       root      240: 
1.1.1.2   root      241:   bOKDialog = Dialog_MainDlg(&bForceReset);
1.1       root      242: 
1.1.1.2   root      243:   /* Copy details to configuration, and ask user if wishes to reset */
                    244:   if (bOKDialog)
                    245:     Dialog_CopyDialogParamsToConfiguration(bForceReset);
                    246: 
                    247:   Main_UnPauseEmulation();
                    248: 
1.1.1.6 ! root      249:   if (bQuitProgram)
        !           250:     set_special(SPCFLAG_BRK);           /* Assure that CPU core shuts down */
        !           251: 
1.1.1.2   root      252:   return(bOKDialog);
1.1       root      253: }

unix.superglobalmegacorp.com

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