--- hatari/src/gui-osx/PrefsController.m 2019/04/01 07:13:04 1.1 +++ hatari/src/gui-osx/PrefsController.m 2019/04/09 08:51:50 1.1.1.9 @@ -7,6 +7,7 @@ Preferences window controller implementation file Feb-Mar 2006, Sébastien Molines - Created + Jan 2006, Sébastien Molines - Updated for recent emulator updates */ // TODO: Set the default paths to MacOS-friendly values @@ -18,6 +19,7 @@ #include "main.h" #include "configuration.h" +#include "change.h" #include "dialog.h" #include "file.h" #include "floppy.h" @@ -26,13 +28,23 @@ // Macros to transfer data between Cocoa controls and Hatari data structures #define EXPORT_TEXTFIELD(nstextfield, target) GuiOsx_ExportPathString([nstextfield stringValue], target, sizeof((target))) +#define EXPORT_NTEXTFIELD(nstextfield, target) target = [nstextfield intValue] #define EXPORT_SWITCH(nsbutton, target) target = ([(nsbutton) state] == NSOnState) #define EXPORT_RADIO(nsmatrix, target) target = [[(nsmatrix) selectedCell] tag] #define EXPORT_DROPDOWN(nspopupbutton, target) target = [[(nspopupbutton) selectedItem] tag] -#define IMPORT_TEXTFIELD(nstextfield, source) [(nstextfield) setStringValue:[[NSString stringWithCString:(source)] stringByAbbreviatingWithTildeInPath]] +#define EXPORT_SLIDER(nsslider, target) target = [(nsslider) intValue] + +#define IMPORT_TEXTFIELD(nstextfield, source) [(nstextfield) setStringValue:[[NSString stringWithCString:(source) encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath]] +#define IMPORT_NTEXTFIELD(nstextfield, source) [(nstextfield) setIntValue:(source)] #define IMPORT_SWITCH(nsbutton, source) [(nsbutton) setState:((source))? NSOnState : NSOffState] #define IMPORT_RADIO(nsmatrix, source) [(nsmatrix) selectCellWithTag:(source)] #define IMPORT_DROPDOWN(nspopupbutton, source) [(nspopupbutton) selectItemAtIndex:[(nspopupbutton) indexOfItemWithTag:(source)]] +#define IMPORT_SLIDER(nsslider,source) [(nsslider) setIntValue:source] + + +// Back up of the current configuration parameters +CNF_PARAMS CurrentParams; + // Keys to be listed in the Joysticks dropdowns SDLKey Preferences_KeysForJoysticks[] = @@ -176,6 +188,28 @@ SDLKey Preferences_KeysForJoysticks[] = size_t Preferences_cKeysForJoysticks = sizeof(Preferences_KeysForJoysticks) / sizeof(Preferences_KeysForJoysticks[0]); +#define DLGSOUND_11KHZ 0 +#define DLGSOUND_12KHZ 1 +#define DLGSOUND_16KHZ 2 +#define DLGSOUND_22KHZ 3 +#define DLGSOUND_25KHZ 4 +#define DLGSOUND_32KHZ 5 +#define DLGSOUND_44KHZ 6 +#define DLGSOUND_48KHZ 7 +#define DLGSOUND_50KHZ 8 + +static const int nSoundFreqs[] = +{ + 11025, + 12517, + 16000, + 22050, + 25033, + 32000, + 44100, + 48000, + 50066 +}; @implementation PrefsController @@ -219,7 +253,7 @@ size_t Preferences_cKeysForJoysticks = s [textField setStringValue:[path stringByAbbreviatingWithTildeInPath]]; // Signal completion - return TRUE; + return true; } // Signal that the selection was aborted @@ -240,50 +274,19 @@ size_t Preferences_cKeysForJoysticks = s NSString *path = [[floppyTextField stringValue] stringByExpandingTildeInPath]; // Make a non-const C string out of it - const char* constSzPath = [path cString]; + const char* constSzPath = [path cStringUsingEncoding:NSASCIIStringEncoding]; size_t cbPath = strlen(constSzPath) + 1; char szPath[cbPath]; strncpy(szPath, constSzPath, cbPath); // Insert the floppy image at this path - Floppy_InsertDiskIntoDrive(drive, szPath); + Floppy_SetDiskFileName(drive, szPath, NULL); } } /*-----------------------------------------------------------------------*/ /* - Helper function to convert display bits to a display mode number -*/ -int DisplayModeFromFlags(BOOL zoomSTLowRes, BOOL force8bpp) -{ - if (zoomSTLowRes) - { - return (force8bpp)? DISPLAYMODE_LOWCOL_HIGHRES : DISPLAYMODE_HICOL_HIGHRES; - } - else - { - return (force8bpp)? DISPLAYMODE_LOWCOL_LOWRES : DISPLAYMODE_HICOL_LOWRES; - } -} - - -/*-----------------------------------------------------------------------*/ -/* - Helper function to convert a display mode number to display bits -*/ -void DisplayModeToFlags(int chosenDisplayMode, BOOL *pZoomSTLowRes, BOOL *pForce8bpp) -{ - *pZoomSTLowRes = ( (chosenDisplayMode == DISPLAYMODE_LOWCOL_HIGHRES) - ||(chosenDisplayMode == DISPLAYMODE_HICOL_HIGHRES) ); - - *pForce8bpp = ( (chosenDisplayMode == DISPLAYMODE_LOWCOL_LOWRES) - ||(chosenDisplayMode == DISPLAYMODE_LOWCOL_HIGHRES) ); -} - - -/*-----------------------------------------------------------------------*/ -/* Methods for all the "Choose" buttons */ - (IBAction)chooseCartridgeImage:(id)sender; @@ -316,6 +319,16 @@ void DisplayModeToFlags(int chosenDispla [self choosePathForControl: hdImage chooseDirectories:FALSE defaultInitialDir:@"~"]; } +- (IBAction)chooseIdeMasterHdImage:(id)sender +{ + [self choosePathForControl: ideMasterHdImage chooseDirectories:FALSE defaultInitialDir:@"~"]; +} + +- (IBAction)chooseIdeSlaveHdImage:(id)sender +{ + [self choosePathForControl: ideSlaveHdImage chooseDirectories:FALSE defaultInitialDir:@"~"]; +} + - (IBAction)chooseKeyboardMappingFile:(id)sender { [self choosePathForControl: keyboardMappingFile chooseDirectories:FALSE defaultInitialDir:@"~"]; @@ -353,7 +366,7 @@ void DisplayModeToFlags(int chosenDispla */ - (IBAction)ejectFloppyA:(id)sender { - Floppy_EjectDiskFromDrive(0, FALSE); + Floppy_SetDiskFileNameNone(0); // Refresh the control [floppyImageA setStringValue:@""]; @@ -361,7 +374,7 @@ void DisplayModeToFlags(int chosenDispla - (IBAction)ejectFloppyB:(id)sender { - Floppy_EjectDiskFromDrive(1, FALSE); + Floppy_SetDiskFileNameNone(1); // Refresh the control [floppyImageB setStringValue:@""]; @@ -369,37 +382,99 @@ void DisplayModeToFlags(int chosenDispla - (IBAction)ejectGemdosImage:(id)sender { - // Clear the control. Later. saveAllControls will set the DialogParams accordingly to signal this is ejected + // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected [gemdosImage setStringValue:@""]; } - (IBAction)ejectHdImage:(id)sender { - // Clear the control. Later. saveAllControls will set the DialogParams accordingly to signal this is ejected + // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected [hdImage setStringValue:@""]; } +- (IBAction)ejectIdeMasterHdImage:(id)sender +{ + // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected + [ideMasterHdImage setStringValue:@""]; +} + +- (IBAction)ejectIdeSlaveHdImage:(id)sender +{ + // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected + [ideSlaveHdImage setStringValue:@""]; +} /*-----------------------------------------------------------------------*/ -/* - Methods for the "Load Config" and "Save Config" buttons -*/ -- (IBAction)loadConfig:(id)sender +/** + * Methods for the "Load Config" button + */ + +- (IBAction)loadConfigFrom:(id)sender { - // Load the config into DialogParams - Dialog_LoadParams(); - - // Refresh all the controls to match DialogParams - [self setAllControls]; + NSString *ConfigFile = [NSString stringWithCString:(sConfigFileName) encoding:NSASCIIStringEncoding]; + NSOpenPanel *openPanel = [ NSOpenPanel openPanel ]; + + if ( [ openPanel runModalForDirectory:nil file:ConfigFile types:nil ] ) + { + ConfigFile = [ [ openPanel filenames ] objectAtIndex:0 ]; + } + else + { + ConfigFile = nil; + } + + if (ConfigFile != nil) + { + // Make a non-const C string out of it + const char* constSzPath = [ConfigFile cStringUsingEncoding:NSASCIIStringEncoding]; + size_t cbPath = strlen(constSzPath) + 1; + char szPath[cbPath]; + strncpy(szPath, constSzPath, cbPath); + + // Load the config into ConfigureParams + Configuration_Load(szPath); + strcpy(sConfigFileName,szPath); + // Refresh all the controls to match ConfigureParams + [self setAllControls]; + } } -- (IBAction)saveConfig:(id)sender +/** + * Methods for the "Load Config" button + */ +- (IBAction)saveConfigAs:(id)sender { - // Update the DialogParams from the controls + char splitpath[FILENAME_MAX], splitname[FILENAME_MAX]; + + // Update the ConfigureParams from the controls [self saveAllControls]; - // Save the DialogParams to the config file - Dialog_SaveParams(); + File_SplitPath(sConfigFileName, splitpath, splitname, NULL); + + NSSavePanel *savePanel = [ NSSavePanel savePanel ]; + + NSString* defaultDir = [NSString stringWithCString:splitpath encoding:NSASCIIStringEncoding]; + NSString *ConfigFile = [NSString stringWithCString:splitname encoding:NSASCIIStringEncoding]; + + if ( ![ savePanel runModalForDirectory:defaultDir file:ConfigFile ] ) + { + return; + } + + ConfigFile = [ savePanel filename ]; + + if (ConfigFile != nil) + { + // Make a non-const C string out of it + const char* constSzPath = [ConfigFile cStringUsingEncoding:NSASCIIStringEncoding]; + size_t cbPath = strlen(constSzPath) + 1; + char szPath[cbPath]; + strncpy(szPath, constSzPath, cbPath); + + // Save the config from ConfigureParams + strcpy(sConfigFileName, szPath); + Configuration_Save(); + } } @@ -409,23 +484,29 @@ void DisplayModeToFlags(int chosenDispla */ - (IBAction)commitAndClose:(id)sender { - BOOL applyChanges = TRUE; + BOOL applyChanges = true; // The user clicked OK [self saveAllControls]; // If a reset is required, ask the user first - if (Dialog_DoNeedReset()) + if (Change_DoNeedReset(&CurrentParams, &ConfigureParams)) { - applyChanges = ( 0 == NSRunAlertPanel (@"Reset the emulator?", - @"The emulator must be reset in order to apply your changes.\nAll current work will be lost.", - @"Don't reset", @"Reset", nil) ); + applyChanges = ( 0 == NSRunAlertPanel ( + NSLocalizedStringFromTable(@"Reset the emulator",@"Localizable",@"comment"), + NSLocalizedStringFromTable(@"Must be reset",@"Localizable",@"comment"), + NSLocalizedStringFromTable(@"Don't reset",@"Localizable",@"comment"), + NSLocalizedStringFromTable(@"Reset",@"Localizable",@"comment"), nil) ); } // Commit the new configuration if (applyChanges) { - Dialog_CopyDialogParamsToConfiguration(FALSE); + Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, false); + } + else + { + ConfigureParams = CurrentParams; } // Close the window @@ -435,12 +516,12 @@ void DisplayModeToFlags(int chosenDispla - (void)initKeysDropDown:(NSPopUpButton*)dropDown { [dropDown removeAllItems]; - int i; + unsigned int i; for (i = 0; i < Preferences_cKeysForJoysticks; i++) { SDLKey key = Preferences_KeysForJoysticks[i]; const char* szKeyName = SDL_GetKeyName(key); - [dropDown addItemWithTitle:[[NSString stringWithCString:szKeyName] capitalizedString]]; + [dropDown addItemWithTitle:[[NSString stringWithCString:szKeyName encoding:NSASCIIStringEncoding] capitalizedString]]; [[dropDown lastItem] setTag:key]; } } @@ -474,7 +555,7 @@ void DisplayModeToFlags(int chosenDispla for (i = 0; i < cRealJoysticks; i++) { const char* szJoystickName = SDL_JoystickName(i); - [realJoystick addItemWithTitle:[[NSString stringWithCString:szJoystickName] capitalizedString]]; + [realJoystick addItemWithTitle:[[NSString stringWithCString:szJoystickName encoding:NSASCIIStringEncoding] capitalizedString]]; [[realJoystick lastItem] setTag:i]; } } @@ -484,17 +565,27 @@ void DisplayModeToFlags(int chosenDispla [realJoystick setEnabled:FALSE]; } - bInitialized = TRUE; + bInitialized = true; } - // Copy configuration settings to DialogParams (which we will only commit back to the configuration settings if choosing OK) - DialogParams = ConfigureParams; + // Backup of configuration settings to CurrentParams (which we will only + // commit back to the configuration settings if choosing OK) + CurrentParams = ConfigureParams; [self setAllControls]; // Display the window - [[ModalWrapper alloc] runModal:window]; + ModalWrapper *mw=[[ModalWrapper alloc] init]; + + [mw runModal:window]; + + [mw release]; + + //GuiOsx_Pause(); + + //[[NSApplication sharedApplication] runModalForWindow:window]; + } @@ -521,67 +612,125 @@ void DisplayModeToFlags(int chosenDispla */ - (void)setAllControls { - // Get the display mode flags - BOOL bZoomSTLowRes, bForce8bpp; - DisplayModeToFlags(DialogParams.Screen.ChosenDisplayMode, &bZoomSTLowRes, &bForce8bpp); - // Import the floppy paths into their controls. - // Note: Floppy images are exposed in the prefs dialog, however they aren't stored with the prefs and won't need to be saved on exit. - IMPORT_TEXTFIELD(floppyImageA, EmulationDrives[0].szFileName); - IMPORT_TEXTFIELD(floppyImageB, EmulationDrives[1].szFileName); + IMPORT_TEXTFIELD(floppyImageA, ConfigureParams.DiskImage.szDiskFileName[0]); + IMPORT_TEXTFIELD(floppyImageB, ConfigureParams.DiskImage.szDiskFileName[1]); // Import all the preferences into their controls - IMPORT_SWITCH(autoInsertB, DialogParams.DiskImage.bAutoInsertDiskB); - IMPORT_SWITCH(blitter, DialogParams.System.bBlitter); - IMPORT_SWITCH(bootFromHD, DialogParams.HardDisk.bBootFromHardDisk); - IMPORT_SWITCH(captureOnChange, DialogParams.Screen.bCaptureChange); - IMPORT_TEXTFIELD(cartridgeImage, DialogParams.Rom.szCartridgeImageFileName); - IMPORT_RADIO(colorDepth, DialogParams.Screen.nVdiColors); - IMPORT_SWITCH(compatibleCpu, DialogParams.System.bCompatibleCpu); - IMPORT_RADIO(cpuClock, DialogParams.System.nCpuFreq); - IMPORT_RADIO(cpuType, DialogParams.System.nCpuLevel); - IMPORT_TEXTFIELD(defaultImagesLocation, DialogParams.DiskImage.szDiskImageDirectory); - IMPORT_SWITCH(enableMidi, DialogParams.Midi.bEnableMidi); - IMPORT_SWITCH(enablePrinter, DialogParams.Printer.bEnablePrinting); - IMPORT_SWITCH(enableRS232, DialogParams.RS232.bEnableRS232); - IMPORT_SWITCH(enableSound, DialogParams.Sound.bEnableSound); - IMPORT_SWITCH(force8bpp, bForce8bpp); - IMPORT_SWITCH(frameSkip, DialogParams.Screen.bFrameSkip); - IMPORT_SWITCH(interleaved, DialogParams.Screen.bInterleavedScreen); - IMPORT_RADIO(keyboardMapping, DialogParams.Keyboard.nKeymapType); - IMPORT_TEXTFIELD(keyboardMappingFile, DialogParams.Keyboard.szMappingFileName); - IMPORT_RADIO(machineType, DialogParams.System.nMachineType); - IMPORT_RADIO(monitor, DialogParams.Screen.bUseHighRes); - IMPORT_SWITCH(patchTimerD, DialogParams.System.bPatchTimerD); - IMPORT_RADIO(playbackQuality, DialogParams.Sound.nPlaybackQuality); - IMPORT_TEXTFIELD(printToFile, DialogParams.Printer.szPrintToFileName); - IMPORT_RADIO(ramSize, DialogParams.Memory.nMemorySize); - IMPORT_TEXTFIELD(readRS232FromFile, DialogParams.RS232.szInFileName); - IMPORT_SWITCH(realTime, DialogParams.System.bRealTimeClock); - IMPORT_RADIO(resolution, DialogParams.Screen.nVdiResolution); - IMPORT_SWITCH(slowFDC, DialogParams.System.bSlowFDC); - IMPORT_TEXTFIELD(tosImage, DialogParams.Rom.szTosImageFileName); - IMPORT_SWITCH(useBorders, DialogParams.Screen.bAllowOverscan); - IMPORT_SWITCH(useVDIResolution, DialogParams.Screen.bUseExtVdiResolutions); - IMPORT_TEXTFIELD(writeMidiToFile, DialogParams.Midi.szMidiOutFileName); - IMPORT_RADIO(writeProtection, DialogParams.DiskImage.nWriteProtection); - IMPORT_TEXTFIELD(writeRS232ToFile, DialogParams.RS232.szOutFileName); - IMPORT_SWITCH(zoomSTLowRes, bZoomSTLowRes); + IMPORT_SWITCH(autoInsertB, ConfigureParams.DiskImage.bAutoInsertDiskB); + IMPORT_SWITCH(blitter, ConfigureParams.System.bBlitter); + IMPORT_SWITCH(bootFromHD, ConfigureParams.HardDisk.bBootFromHardDisk); + IMPORT_SWITCH(captureOnChange, ConfigureParams.Screen.bCrop); + IMPORT_TEXTFIELD(cartridgeImage, ConfigureParams.Rom.szCartridgeImageFileName); + IMPORT_RADIO(colorDepth, ConfigureParams.Screen.nVdiColors); + IMPORT_SWITCH(compatibleCpu, ConfigureParams.System.bCompatibleCpu); + IMPORT_RADIO(cpuClock, ConfigureParams.System.nCpuFreq); + IMPORT_RADIO(cpuType, ConfigureParams.System.nCpuLevel); + IMPORT_TEXTFIELD(defaultImagesLocation, ConfigureParams.DiskImage.szDiskImageDirectory); + IMPORT_SWITCH(enableMidi, ConfigureParams.Midi.bEnableMidi); + IMPORT_SWITCH(enablePrinter, ConfigureParams.Printer.bEnablePrinting); + IMPORT_SWITCH(enableRS232, ConfigureParams.RS232.bEnableRS232); + IMPORT_SWITCH(enableSound, ConfigureParams.Sound.bEnableSound); + IMPORT_DROPDOWN(frameSkip, ConfigureParams.Screen.nFrameSkips); + IMPORT_RADIO(keyboardMapping, ConfigureParams.Keyboard.nKeymapType); + IMPORT_TEXTFIELD(keyboardMappingFile, ConfigureParams.Keyboard.szMappingFileName); + IMPORT_RADIO(machineType, ConfigureParams.System.nMachineType); + IMPORT_RADIO(monitor, ConfigureParams.Screen.nMonitorType); + IMPORT_SWITCH(patchTimerD, ConfigureParams.System.bPatchTimerD); + IMPORT_TEXTFIELD(printToFile, ConfigureParams.Printer.szPrintToFileName); + IMPORT_RADIO(ramSize, ConfigureParams.Memory.nMemorySize); + IMPORT_TEXTFIELD(readRS232FromFile, ConfigureParams.RS232.szInFileName); + IMPORT_SWITCH(realTime, ConfigureParams.System.bRealTimeClock); + IMPORT_SWITCH(fastFDC, ConfigureParams.DiskImage.FastFloppy); + IMPORT_TEXTFIELD(tosImage, ConfigureParams.Rom.szTosImageFileName); + IMPORT_SWITCH(useBorders, ConfigureParams.Screen.bAllowOverscan); + IMPORT_SWITCH(useVDIResolution, ConfigureParams.Screen.bUseExtVdiResolutions); + IMPORT_TEXTFIELD(writeMidiToFile, ConfigureParams.Midi.sMidiOutFileName); + IMPORT_RADIO(floppyWriteProtection, ConfigureParams.DiskImage.nWriteProtection); + IMPORT_RADIO(HDWriteProtection, ConfigureParams.HardDisk.nWriteProtection); + IMPORT_TEXTFIELD(writeRS232ToFile, ConfigureParams.RS232.szOutFileName); + // IMPORT_SWITCH(zoomSTLowRes, ConfigureParams.Screen.bZoomLowRes); + IMPORT_SWITCH(showStatusBar, ConfigureParams.Screen.bShowStatusbar); + IMPORT_DROPDOWN(enableDSP,ConfigureParams.System.nDSPType); + IMPORT_TEXTFIELD(configFile, sConfigFileName); + + // 12/04/2010 + IMPORT_SWITCH(falconTTRatio, ConfigureParams.Screen.bAspectCorrect); + IMPORT_SWITCH(fullScreen, ConfigureParams.Screen.bFullScreen); + IMPORT_SWITCH(ledDisks, ConfigureParams.Screen.bShowDriveLed); + IMPORT_SWITCH(keepDesktopResolution, ConfigureParams.Screen.bKeepResolution); + + //v1.6.1 + IMPORT_SWITCH(FastBootPatch,ConfigureParams.System.bFastBoot); + IMPORT_RADIO(YMVoicesMixing,ConfigureParams.Sound.YmVolumeMixing); + + //deal with the Max Zoomed Stepper + IMPORT_NTEXTFIELD(maxZoomedWidth, ConfigureParams.Screen.nMaxWidth); + IMPORT_NTEXTFIELD(maxZoomedHeight, ConfigureParams.Screen.nMaxHeight); + + [widthStepper setDoubleValue:[maxZoomedWidth intValue]]; + [heightStepper setDoubleValue:[maxZoomedHeight intValue]]; + + + + + [(force8bpp) setState:((ConfigureParams.Screen.nForceBpp==8))? NSOnState : NSOffState]; + + + int i; + for (i = 0; i <= DLGSOUND_50KHZ-DLGSOUND_11KHZ; i++) + { + if (ConfigureParams.Sound.nPlaybackFreq > nSoundFreqs[i]-500 + && ConfigureParams.Sound.nPlaybackFreq < nSoundFreqs[i]+500) + { + [playbackQuality selectCellWithTag:(i)]; + break; + } + } + + + if (ConfigureParams.Screen.nVdiWidth >= 1024) + [resolution selectCellWithTag:(2)]; + else if (ConfigureParams.Screen.nVdiWidth >= 768) + [resolution selectCellWithTag:(1)]; + else + [resolution selectCellWithTag:(0)]; + // If the HD flag is set, load the HD path, otherwise make it blank - if (DialogParams.HardDisk.bUseHardDiskImage) + if (ConfigureParams.HardDisk.bUseHardDiskImage) { - IMPORT_TEXTFIELD(hdImage, DialogParams.HardDisk.szHardDiskImage); + IMPORT_TEXTFIELD(hdImage, ConfigureParams.HardDisk.szHardDiskImage); } else { [hdImage setStringValue:@""]; } + // If the IDE HD flag is set, load the IDE HD path, otherwise make it blank + //Master + if (ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage) + { + IMPORT_TEXTFIELD(ideMasterHdImage, ConfigureParams.HardDisk.szIdeMasterHardDiskImage); + } + else + { + [ideMasterHdImage setStringValue:@""]; + } + //Slave + if (ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage) + { + IMPORT_TEXTFIELD(ideSlaveHdImage, ConfigureParams.HardDisk.szIdeSlaveHardDiskImage); + } + else + { + [ideSlaveHdImage setStringValue:@""]; + } + // If the Gemdos flag is set, load the Gemdos path, otherwise make it blank - if (DialogParams.HardDisk.bUseHardDiskDirectories) + if (ConfigureParams.HardDisk.bUseHardDiskDirectories) { - IMPORT_TEXTFIELD(gemdosImage, DialogParams.HardDisk.szHardDiskDirectories[0]); + IMPORT_TEXTFIELD(gemdosImage, ConfigureParams.HardDisk.szHardDiskDirectories[0]); } else { @@ -635,29 +784,29 @@ void DisplayModeToFlags(int chosenDispla EXPORT_DROPDOWN(currentJoystick, nCurrentJoystick); // Data validation: If the JoyID is out of bounds, correct it and, if set to use real joystick, change to disabled - if ( (DialogParams.Joysticks.Joy[nCurrentJoystick].nJoyId < 0) - || (DialogParams.Joysticks.Joy[nCurrentJoystick].nJoyId >= cRealJoysticks) ) + if ( (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId < 0) + || (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId >= cRealJoysticks) ) { - DialogParams.Joysticks.Joy[nCurrentJoystick].nJoyId = 0; - if (DialogParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode == JOYSTICK_REALSTICK) + ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId = 0; + if (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode == JOYSTICK_REALSTICK) { - DialogParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode = JOYSTICK_DISABLED; + ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode = JOYSTICK_DISABLED; } } // Don't change the realJoystick dropdown if none is available (to keep "(None available)" selected) if (cRealJoysticks > 0) { - IMPORT_DROPDOWN(realJoystick, DialogParams.Joysticks.Joy[nCurrentJoystick].nJoyId); + IMPORT_DROPDOWN(realJoystick, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId); } - IMPORT_RADIO(joystickMode, DialogParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode); - IMPORT_DROPDOWN(joystickUp, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp); - IMPORT_DROPDOWN(joystickRight, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight); - IMPORT_DROPDOWN(joystickDown, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown); - IMPORT_DROPDOWN(joystickLeft, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft); - IMPORT_DROPDOWN(joystickFire, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire); - IMPORT_SWITCH(enableAutoFire, DialogParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire); + IMPORT_RADIO(joystickMode, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode); + IMPORT_DROPDOWN(joystickUp, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp); + IMPORT_DROPDOWN(joystickRight, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight); + IMPORT_DROPDOWN(joystickDown, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown); + IMPORT_DROPDOWN(joystickLeft, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft); + IMPORT_DROPDOWN(joystickFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire); + IMPORT_SWITCH(enableAutoFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire); } @@ -667,14 +816,14 @@ void DisplayModeToFlags(int chosenDispla */ - (void)saveJoystickControls { - EXPORT_RADIO(joystickMode, DialogParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode); - EXPORT_DROPDOWN(realJoystick, DialogParams.Joysticks.Joy[nCurrentJoystick].nJoyId); - EXPORT_DROPDOWN(joystickUp, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp); - EXPORT_DROPDOWN(joystickRight, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight); - EXPORT_DROPDOWN(joystickDown, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown); - EXPORT_DROPDOWN(joystickLeft, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft); - EXPORT_DROPDOWN(joystickFire, DialogParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire); - EXPORT_SWITCH(enableAutoFire, DialogParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire); + EXPORT_RADIO(joystickMode, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode); + EXPORT_DROPDOWN(realJoystick, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId); + EXPORT_DROPDOWN(joystickUp, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp); + EXPORT_DROPDOWN(joystickRight, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight); + EXPORT_DROPDOWN(joystickDown, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown); + EXPORT_DROPDOWN(joystickLeft, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft); + EXPORT_DROPDOWN(joystickFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire); + EXPORT_SWITCH(enableAutoFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire); } @@ -684,73 +833,146 @@ void DisplayModeToFlags(int chosenDispla */ - (void)saveAllControls { - BOOL bZoomSTLowRes, bForce8bpp; - // Export the preference controls into their vars - EXPORT_SWITCH(autoInsertB, DialogParams.DiskImage.bAutoInsertDiskB); - EXPORT_SWITCH(blitter, DialogParams.System.bBlitter); - EXPORT_SWITCH(bootFromHD, DialogParams.HardDisk.bBootFromHardDisk); - EXPORT_SWITCH(captureOnChange, DialogParams.Screen.bCaptureChange); - EXPORT_TEXTFIELD(cartridgeImage, DialogParams.Rom.szCartridgeImageFileName); - EXPORT_RADIO(colorDepth, DialogParams.Screen.nVdiColors); - EXPORT_SWITCH(compatibleCpu, DialogParams.System.bCompatibleCpu); - EXPORT_RADIO(cpuClock, DialogParams.System.nCpuFreq); - EXPORT_RADIO(cpuType, DialogParams.System.nCpuLevel); - EXPORT_TEXTFIELD(defaultImagesLocation, DialogParams.DiskImage.szDiskImageDirectory); - EXPORT_SWITCH(enableMidi, DialogParams.Midi.bEnableMidi); - EXPORT_SWITCH(enablePrinter, DialogParams.Printer.bEnablePrinting); - EXPORT_SWITCH(enableRS232, DialogParams.RS232.bEnableRS232); - EXPORT_SWITCH(enableSound, DialogParams.Sound.bEnableSound); - EXPORT_SWITCH(force8bpp, bForce8bpp); - EXPORT_SWITCH(frameSkip, DialogParams.Screen.bFrameSkip); - EXPORT_SWITCH(interleaved, DialogParams.Screen.bInterleavedScreen); - EXPORT_RADIO(keyboardMapping, DialogParams.Keyboard.nKeymapType); - EXPORT_TEXTFIELD(keyboardMappingFile, DialogParams.Keyboard.szMappingFileName); - EXPORT_RADIO(machineType, DialogParams.System.nMachineType); - EXPORT_RADIO(monitor, DialogParams.Screen.bUseHighRes); - EXPORT_SWITCH(patchTimerD, DialogParams.System.bPatchTimerD); - EXPORT_RADIO(playbackQuality, DialogParams.Sound.nPlaybackQuality); - EXPORT_TEXTFIELD(printToFile, DialogParams.Printer.szPrintToFileName); - EXPORT_RADIO(ramSize, DialogParams.Memory.nMemorySize); - EXPORT_TEXTFIELD(readRS232FromFile, DialogParams.RS232.szInFileName); - EXPORT_SWITCH(realTime, DialogParams.System.bRealTimeClock); - EXPORT_RADIO(resolution, DialogParams.Screen.nVdiResolution); - EXPORT_SWITCH(slowFDC, DialogParams.System.bSlowFDC); - EXPORT_TEXTFIELD(tosImage, DialogParams.Rom.szTosImageFileName); - EXPORT_SWITCH(useBorders, DialogParams.Screen.bAllowOverscan); - EXPORT_SWITCH(useVDIResolution, DialogParams.Screen.bUseExtVdiResolutions); - EXPORT_TEXTFIELD(writeMidiToFile, DialogParams.Midi.szMidiOutFileName); - EXPORT_RADIO(writeProtection, DialogParams.DiskImage.nWriteProtection); - EXPORT_TEXTFIELD(writeRS232ToFile, DialogParams.RS232.szOutFileName); - EXPORT_SWITCH(zoomSTLowRes, bZoomSTLowRes); - - // Set the display mode based on the display flags - DialogParams.Screen.ChosenDisplayMode = DisplayModeFromFlags(bZoomSTLowRes, bForce8bpp); + EXPORT_SWITCH(autoInsertB, ConfigureParams.DiskImage.bAutoInsertDiskB); + EXPORT_SWITCH(blitter, ConfigureParams.System.bBlitter); + EXPORT_SWITCH(bootFromHD, ConfigureParams.HardDisk.bBootFromHardDisk); + EXPORT_SWITCH(captureOnChange, ConfigureParams.Screen.bCrop); + EXPORT_TEXTFIELD(cartridgeImage, ConfigureParams.Rom.szCartridgeImageFileName); + EXPORT_RADIO(colorDepth, ConfigureParams.Screen.nVdiColors); + EXPORT_SWITCH(compatibleCpu, ConfigureParams.System.bCompatibleCpu); + EXPORT_RADIO(cpuClock, ConfigureParams.System.nCpuFreq); + EXPORT_RADIO(cpuType, ConfigureParams.System.nCpuLevel); + EXPORT_TEXTFIELD(defaultImagesLocation, ConfigureParams.DiskImage.szDiskImageDirectory); + EXPORT_SWITCH(enableMidi, ConfigureParams.Midi.bEnableMidi); + EXPORT_SWITCH(enablePrinter, ConfigureParams.Printer.bEnablePrinting); + EXPORT_SWITCH(enableRS232, ConfigureParams.RS232.bEnableRS232); + EXPORT_SWITCH(enableSound, ConfigureParams.Sound.bEnableSound); + EXPORT_DROPDOWN(frameSkip, ConfigureParams.Screen.nFrameSkips); + EXPORT_RADIO(keyboardMapping, ConfigureParams.Keyboard.nKeymapType); + EXPORT_TEXTFIELD(keyboardMappingFile, ConfigureParams.Keyboard.szMappingFileName); + EXPORT_RADIO(machineType, ConfigureParams.System.nMachineType); + EXPORT_RADIO(monitor, ConfigureParams.Screen.nMonitorType); + EXPORT_SWITCH(patchTimerD, ConfigureParams.System.bPatchTimerD); + EXPORT_TEXTFIELD(printToFile, ConfigureParams.Printer.szPrintToFileName); + EXPORT_RADIO(ramSize, ConfigureParams.Memory.nMemorySize); + EXPORT_TEXTFIELD(readRS232FromFile, ConfigureParams.RS232.szInFileName); + EXPORT_SWITCH(realTime, ConfigureParams.System.bRealTimeClock); + EXPORT_SWITCH(fastFDC, ConfigureParams.DiskImage.FastFloppy); + EXPORT_TEXTFIELD(tosImage, ConfigureParams.Rom.szTosImageFileName); + EXPORT_SWITCH(useBorders, ConfigureParams.Screen.bAllowOverscan); + EXPORT_SWITCH(useVDIResolution, ConfigureParams.Screen.bUseExtVdiResolutions); + EXPORT_TEXTFIELD(writeMidiToFile, ConfigureParams.Midi.sMidiOutFileName); + EXPORT_RADIO(floppyWriteProtection, ConfigureParams.DiskImage.nWriteProtection); + EXPORT_RADIO(HDWriteProtection, ConfigureParams.HardDisk.nWriteProtection); + EXPORT_TEXTFIELD(writeRS232ToFile, ConfigureParams.RS232.szOutFileName); + // EXPORT_SWITCH(zoomSTLowRes, ConfigureParams.Screen.bZoomLowRes); + EXPORT_SWITCH(showStatusBar,ConfigureParams.Screen.bShowStatusbar); + EXPORT_DROPDOWN(enableDSP,ConfigureParams.System.nDSPType); + + EXPORT_SWITCH(falconTTRatio, ConfigureParams.Screen.bAspectCorrect); + EXPORT_SWITCH(fullScreen, ConfigureParams.Screen.bFullScreen); + EXPORT_SWITCH(ledDisks, ConfigureParams.Screen.bShowDriveLed); + EXPORT_SWITCH(keepDesktopResolution, ConfigureParams.Screen.bKeepResolution); + + //v1.6.1 + EXPORT_SWITCH(FastBootPatch,ConfigureParams.System.bFastBoot); + EXPORT_RADIO(YMVoicesMixing,ConfigureParams.Sound.YmVolumeMixing); + + EXPORT_NTEXTFIELD(maxZoomedWidth, ConfigureParams.Screen.nMaxWidth); + EXPORT_NTEXTFIELD(maxZoomedHeight, ConfigureParams.Screen.nMaxHeight); + + ConfigureParams.Screen.nForceBpp = ([force8bpp state] == NSOnState) ? 8 : 0; + + ConfigureParams.Sound.nPlaybackFreq = nSoundFreqs[[[playbackQuality selectedCell] tag]]; + + switch ([[resolution selectedCell] tag]) + { + case 0: + ConfigureParams.Screen.nVdiWidth = 640; + ConfigureParams.Screen.nVdiHeight = 480; + break; + case 1: + ConfigureParams.Screen.nVdiWidth = 800; + ConfigureParams.Screen.nVdiHeight = 600; + break; + case 2: + ConfigureParams.Screen.nVdiWidth = 1024; + ConfigureParams.Screen.nVdiHeight = 768; + break; + } // Define the HD flag, and export the HD path if one is selected if ([[hdImage stringValue] length] > 0) { - EXPORT_TEXTFIELD(hdImage, DialogParams.HardDisk.szHardDiskImage); - DialogParams.HardDisk.bUseHardDiskImage = TRUE; + EXPORT_TEXTFIELD(hdImage, ConfigureParams.HardDisk.szHardDiskImage); + ConfigureParams.HardDisk.bUseHardDiskImage = true; + } + else + { + ConfigureParams.HardDisk.bUseHardDiskImage = false; + } + + // Define the IDE HD flag, and export the IDE HD path if one is selected + if ([[ideMasterHdImage stringValue] length] > 0) + { + EXPORT_TEXTFIELD(ideMasterHdImage, ConfigureParams.HardDisk.szIdeMasterHardDiskImage); + ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage = true; } else { - DialogParams.HardDisk.bUseHardDiskImage = FALSE; + ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage = false; + } + + // IDE Slave + if ([[ideSlaveHdImage stringValue] length] > 0) + { + EXPORT_TEXTFIELD(ideSlaveHdImage, ConfigureParams.HardDisk.szIdeSlaveHardDiskImage); + ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage = true; + } + else + { + ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage = false; } // Define the Gemdos flag, and export the Gemdos path if one is selected if ([[gemdosImage stringValue] length] > 0) { - EXPORT_TEXTFIELD(gemdosImage, DialogParams.HardDisk.szHardDiskDirectories[0]); - DialogParams.HardDisk.bUseHardDiskDirectories = TRUE; + EXPORT_TEXTFIELD(gemdosImage, ConfigureParams.HardDisk.szHardDiskDirectories[0]); + ConfigureParams.HardDisk.bUseHardDiskDirectories = true; } else { - DialogParams.HardDisk.bUseHardDiskDirectories = FALSE; + ConfigureParams.HardDisk.bUseHardDiskDirectories = false; } // Save the per-joystick controls [self saveJoystickControls]; } +// Max Zoomed Adjust + +- (IBAction) setWidth:(id)sender; +{ + NSLog(@"Change Max Zoom width: %ld", [sender intValue]); + [maxZoomedWidth setIntValue: [sender intValue]]; +} + +- (IBAction) setHeight:(id)sender; +{ + NSLog(@"Change Max Zoom height: %ld", [sender intValue]); + [maxZoomedHeight setIntValue: [sender intValue]]; +} + ++(PrefsController*)prefs +{ + static PrefsController* prefs = nil; + if (!prefs) + prefs = [[PrefsController alloc] init]; + + return prefs; +} + + + @end