Annotation of hatari/src/gui-osx/PrefsController.m, revision 1.1.1.12

1.1       root        1: /*
                      2:   Hatari - PrefsController.m
                      3: 
1.1.1.10  root        4:   This file is distributed under the GNU General Public License, version 2
                      5:   or at your option any later version. Read the file gpl.txt for details.
1.1       root        6: 
                      7:   Preferences window controller implementation file
                      8: 
                      9:   Feb-Mar 2006, Sébastien Molines - Created
1.1.1.2   root       10:   Jan 2006, Sébastien Molines - Updated for recent emulator updates
1.1.1.11  root       11:   Miguel SARO, J. VERNET
1.1       root       12: */
1.1.1.11  root       13: // bOKDialog = Dialog_MainDlg(&bForceReset, &bLoadedSnapshot);   // prise des préférences
1.1       root       14: // TODO: Set the default paths to MacOS-friendly values
                     15: // TODO: Move hardcoded string to localizable resources (e.g. string "Reset the emulator?")
                     16: 
                     17: 
                     18: #import "PrefsController.h"
                     19: #import "Shared.h"
                     20: 
                     21: #include "main.h"
                     22: #include "configuration.h"
1.1.1.3   root       23: #include "change.h"
1.1       root       24: #include "dialog.h"
                     25: #include "file.h"
                     26: #include "floppy.h"
                     27: #include "screen.h"
                     28: #include "sdlgui.h"
1.1.1.11  root       29: #include "paths.h"
1.1.1.12! root       30: #include "keymap.h"
1.1.1.10  root       31: 
1.1       root       32: // Macros to transfer data between Cocoa controls and Hatari data structures
1.1.1.11  root       33: 
                     34: // de l'affichage vers la structure  (saveAllControls)
                     35: #define EXPORT_TEXTFIELD(mutablStrng, target) [mutablStrng getCString:target maxLength:sizeof((target))-1 encoding:NSASCIIStringEncoding]
1.1.1.6   root       36: #define EXPORT_NTEXTFIELD(nstextfield, target) target = [nstextfield intValue]
1.1       root       37: #define EXPORT_SWITCH(nsbutton, target) target = ([(nsbutton) state] == NSOnState)
                     38: #define EXPORT_RADIO(nsmatrix, target) target = [[(nsmatrix) selectedCell] tag]
                     39: #define EXPORT_DROPDOWN(nspopupbutton, target) target = [[(nspopupbutton) selectedItem] tag]
1.1.1.3   root       40: #define EXPORT_SLIDER(nsslider, target) target = [(nsslider) intValue]
                     41: 
1.1.1.11  root       42: // la structure vers l'affichage (setAllControls)
                     43: #define IMPORT_TEXTFIELD(nstextfield, mutablStrng, source) [mutablStrng setString:[NSString stringWithCString:(source) encoding:NSASCIIStringEncoding]] ; [nstextfield setStringValue:[NSApp pathUser:mutablStrng]]
1.1.1.6   root       44: #define IMPORT_NTEXTFIELD(nstextfield, source) [(nstextfield) setIntValue:(source)]
1.1       root       45: #define IMPORT_SWITCH(nsbutton, source) [(nsbutton) setState:((source))? NSOnState : NSOffState]
                     46: #define IMPORT_RADIO(nsmatrix, source) [(nsmatrix) selectCellWithTag:(source)]
                     47: #define IMPORT_DROPDOWN(nspopupbutton, source) [(nspopupbutton) selectItemAtIndex:[(nspopupbutton) indexOfItemWithTag:(source)]]
1.1.1.3   root       48: #define IMPORT_SLIDER(nsslider,source) [(nsslider) setIntValue:source]
                     49: 
1.1.1.11  root       50: #define INITIAL_DIR(dossier) [dossier length] < 2 ? @"~" : dossier
1.1.1.3   root       51: 
                     52: // Back up of the current configuration parameters
1.1.1.11  root       53: //
1.1.1.3   root       54: CNF_PARAMS CurrentParams;
                     55: 
1.1       root       56: 
                     57: // Keys to be listed in the Joysticks dropdowns
                     58: SDLKey Preferences_KeysForJoysticks[] =
                     59: {
                     60:        SDLK_BACKSPACE,
                     61:        SDLK_TAB,
                     62:        SDLK_CLEAR,
                     63:        SDLK_RETURN,
                     64:        SDLK_PAUSE,
                     65:        SDLK_ESCAPE,
                     66:        SDLK_SPACE,
                     67:        SDLK_EXCLAIM,
                     68:        SDLK_QUOTEDBL,
                     69:        SDLK_HASH,
                     70:        SDLK_DOLLAR,
                     71:        SDLK_AMPERSAND,
                     72:        SDLK_QUOTE,
                     73:        SDLK_LEFTPAREN,
                     74:        SDLK_RIGHTPAREN,
                     75:        SDLK_ASTERISK,
                     76:        SDLK_PLUS,
                     77:        SDLK_COMMA,
                     78:        SDLK_MINUS,
                     79:        SDLK_PERIOD,
                     80:        SDLK_SLASH,
                     81:        SDLK_0,
                     82:        SDLK_1,
                     83:        SDLK_2,
                     84:        SDLK_3,
                     85:        SDLK_4,
                     86:        SDLK_5,
                     87:        SDLK_6,
                     88:        SDLK_7,
                     89:        SDLK_8,
                     90:        SDLK_9,
                     91:        SDLK_COLON,
                     92:        SDLK_SEMICOLON,
                     93:        SDLK_LESS,
                     94:        SDLK_EQUALS,
                     95:        SDLK_GREATER,
                     96:        SDLK_QUESTION,
                     97:        SDLK_AT,
                     98:        SDLK_LEFTBRACKET,
                     99:        SDLK_BACKSLASH,
                    100:        SDLK_RIGHTBRACKET,
                    101:        SDLK_CARET,
                    102:        SDLK_UNDERSCORE,
                    103:        SDLK_BACKQUOTE,
                    104:        SDLK_a,
                    105:        SDLK_b,
                    106:        SDLK_c,
                    107:        SDLK_d,
                    108:        SDLK_e,
                    109:        SDLK_f,
                    110:        SDLK_g,
                    111:        SDLK_h,
                    112:        SDLK_i,
                    113:        SDLK_j,
                    114:        SDLK_k,
                    115:        SDLK_l,
                    116:        SDLK_m,
                    117:        SDLK_n,
                    118:        SDLK_o,
                    119:        SDLK_p,
                    120:        SDLK_q,
                    121:        SDLK_r,
                    122:        SDLK_s,
                    123:        SDLK_t,
                    124:        SDLK_u,
                    125:        SDLK_v,
                    126:        SDLK_w,
                    127:        SDLK_x,
                    128:        SDLK_y,
                    129:        SDLK_z,
                    130:        SDLK_DELETE,
                    131:        SDLK_KP0,
                    132:        SDLK_KP1,
                    133:        SDLK_KP2,
                    134:        SDLK_KP3,
                    135:        SDLK_KP4,
                    136:        SDLK_KP5,
                    137:        SDLK_KP6,
                    138:        SDLK_KP7,
                    139:        SDLK_KP8,
                    140:        SDLK_KP9,
                    141:        SDLK_KP_PERIOD,
                    142:        SDLK_KP_DIVIDE,
                    143:        SDLK_KP_MULTIPLY,
                    144:        SDLK_KP_MINUS,
                    145:        SDLK_KP_PLUS,
                    146:        SDLK_KP_ENTER,
                    147:        SDLK_KP_EQUALS,
                    148:        SDLK_UP,
                    149:        SDLK_DOWN,
                    150:        SDLK_RIGHT,
                    151:        SDLK_LEFT,
                    152:        SDLK_INSERT,
                    153:        SDLK_HOME,
                    154:        SDLK_END,
                    155:        SDLK_PAGEUP,
                    156:        SDLK_PAGEDOWN,
                    157:        SDLK_F1,
                    158:        SDLK_F2,
                    159:        SDLK_F3,
                    160:        SDLK_F4,
                    161:        SDLK_F5,
                    162:        SDLK_F6,
                    163:        SDLK_F7,
                    164:        SDLK_F8,
                    165:        SDLK_F9,
                    166:        SDLK_F10,
                    167:        SDLK_F11,
                    168:        SDLK_F12,
                    169:        SDLK_F13,
                    170:        SDLK_F14,
                    171:        SDLK_F15,
                    172:        SDLK_NUMLOCK,
                    173:        SDLK_CAPSLOCK,
                    174:        SDLK_SCROLLOCK,
                    175:        SDLK_RSHIFT,
                    176:        SDLK_LSHIFT,
                    177:        SDLK_RCTRL,
                    178:        SDLK_LCTRL,
                    179:        SDLK_RALT,
                    180:        SDLK_LALT,
                    181:        SDLK_RMETA,
                    182:        SDLK_LMETA,
1.1.1.12! root      183: #if !WITH_SDL2
1.1       root      184:        SDLK_LSUPER,
                    185:        SDLK_RSUPER,
                    186:        SDLK_COMPOSE,
1.1.1.12! root      187:        SDLK_BREAK,
        !           188:        SDLK_EURO,
        !           189: #endif
        !           190:        SDLK_MODE,
1.1       root      191:        SDLK_HELP,
                    192:        SDLK_PRINT,
                    193:        SDLK_SYSREQ,
                    194:        SDLK_MENU,
                    195:        SDLK_POWER,
                    196:        SDLK_UNDO
                    197: };
                    198: 
                    199: size_t Preferences_cKeysForJoysticks = sizeof(Preferences_KeysForJoysticks) / sizeof(Preferences_KeysForJoysticks[0]);
                    200: 
1.1.1.6   root      201: #define DLGSOUND_11KHZ      0
                    202: #define DLGSOUND_12KHZ      1
                    203: #define DLGSOUND_16KHZ      2
                    204: #define DLGSOUND_22KHZ      3
                    205: #define DLGSOUND_25KHZ      4
                    206: #define DLGSOUND_32KHZ      5
                    207: #define DLGSOUND_44KHZ      6
                    208: #define DLGSOUND_48KHZ      7
                    209: #define DLGSOUND_50KHZ      8
                    210: 
                    211: static const int nSoundFreqs[] =
                    212: {
                    213:        11025,
                    214:        12517,
                    215:        16000,
                    216:        22050,
                    217:        25033,
                    218:        32000,
                    219:        44100,
                    220:        48000,
                    221:        50066
                    222: };
1.1       root      223: 
1.1.1.11  root      224: 
1.1       root      225: @implementation PrefsController
                    226: 
1.1.1.11  root      227: char szPath[FILENAME_MAX];
                    228: 
                    229: 
                    230: - (IBAction)finished:(id)sender
                    231: {
                    232:        Main_RequestQuit(0) ;
                    233: }
1.1       root      234: 
                    235: /*-----------------------------------------------------------------------*/
1.1.1.11  root      236: /*                                                                       */
                    237: /*  Helper method for Choose buttons                                     */
                    238: /*  Returns: TRUE is the user selected a path, FALSE if he/she aborted   */
                    239: /*-----------------------------------------------------------------------*/
                    240: - (BOOL)choosePathForControl:(NSTextField*)textField chooseDirectories:(BOOL)chooseDirectories defaultInitialDir:(NSString*)defaultInitialDir 
                    241:                                                                                                                                                                        mutString:(NSMutableString *)mutString what:(NSArray *)what
1.1       root      242: {
1.1.1.11  root      243:        NSString *directoryToOpen ;
                    244:        NSString *fileToPreselect ;
                    245:        NSString *newPath ;
                    246: 
                    247:        if ((mutString != nil) && ([mutString length] > 2))
                    248:         {      directoryToOpen = [mutString stringByDeletingLastPathComponent];                        // There is existing path: we use it.
                    249:                fileToPreselect = [mutString lastPathComponent]; }
1.1       root      250:        else
1.1.1.11  root      251:         {      directoryToOpen = [defaultInitialDir stringByExpandingTildeInPath];                     // no path: use user's directory
                    252:                fileToPreselect = nil; } ;
                    253: 
                    254:        newPath = [NSApp hopenfile:chooseDirectories defoDir:directoryToOpen defoFile:fileToPreselect types:what];
                    255:        if ([newPath length] != 0)                                                                                                              // user canceled if empty
1.1       root      256:        {
1.1.1.11  root      257:                [mutString setString:[NSString stringWithString:newPath]] ;                                     // save this path
                    258:                [textField setStringValue:[NSApp pathUser:newPath]];                                            // show localized path
                    259:                return YES;
                    260:        } ;
                    261: 
                    262:        return NO;                                                                                                                                              // Selection aborted
1.1       root      263: }
                    264: 
                    265: 
1.1.1.11  root      266: //-----------------------------------------------------------------------*/
                    267: //
                    268: //  Helper method to insert a floppy image
                    269: //  TODO: Add code to restrict to known file types
                    270: //
1.1       root      271: /*-----------------------------------------------------------------------*/
1.1.1.11  root      272: 
                    273: - (void)insertFloppyImageIntoDrive:(int)drive forTextField:(NSTextField*)floppyTextField  realPath:(NSMutableString *)realPath
1.1       root      274: {
1.1.1.11  root      275:        if ([self choosePathForControl:floppyTextField  chooseDirectories:NO defaultInitialDir:imgeDir
                    276:                                                                                        mutString:realPath  what:[NSArray arrayWithObjects:allF,nil]])
1.1       root      277:                
1.1.1.11  root      278:                Floppy_SetDiskFileName(drive, [realPath cStringUsingEncoding:NSASCIIStringEncoding], NULL);
                    279:                // Insert the floppy image at this path  ????
1.1       root      280: }
                    281: 
                    282: 
1.1.1.11  root      283: //-----------------------------------------------------------------------------
                    284: - (NSString *)initial:(NSString *)route
                    285: {
                    286: BOOL flag1, flag2;
                    287: 
                    288:        if ((route==nil) || ([route length]==0))  return @"~" ;
                    289:        flag1 = [[NSFileManager defaultManager] fileExistsAtPath:route isDirectory:&flag2] ;
                    290:        if (flag1 && !flag2)
                    291:                return route ;
                    292:        return [route stringByDeletingLastPathComponent] ;
                    293: }
                    294: 
                    295: //
                    296: //  Methods for all the "Choose" buttons
                    297: //
1.1       root      298: - (IBAction)chooseCartridgeImage:(id)sender;
                    299: {
1.1.1.11  root      300:        [self choosePathForControl: cartridgeImage chooseDirectories:NO defaultInitialDir:[self initial:cartridge]                      // cartridge
                    301:                                                                                                mutString:cartridge  what:[NSArray arrayWithObjects:allC,nil]];
1.1       root      302: }
                    303: 
1.1.1.11  root      304: 
1.1       root      305: - (IBAction)chooseDefaultImagesLocation:(id)sender
                    306: {
1.1.1.11  root      307:        [self choosePathForControl: defaultImagesLocation chooseDirectories:YES defaultInitialDir:[self initial:imgeDir]        // images location
                    308:                                                                                                mutString:imgeDir  what:nil];
1.1       root      309: }
                    310: 
                    311: - (IBAction)chooseFloppyImageA:(id)sender
                    312: {
1.1.1.11  root      313:        [self insertFloppyImageIntoDrive:0 forTextField:floppyImageA realPath:floppyA];                                                                         // floppy A
1.1       root      314: }
                    315: 
                    316: - (IBAction)chooseFloppyImageB:(id)sender
                    317: {
1.1.1.11  root      318:        [self insertFloppyImageIntoDrive:1 forTextField:floppyImageB realPath:floppyB];                                                                         // floppy B
1.1       root      319: }
                    320: 
1.1.1.11  root      321: - (IBAction)chooseGemdosImage:(id)sender                                                                                                                                                               // directory for Gemdos
1.1       root      322: {
1.1.1.11  root      323:        [self choosePathForControl: gemdosImage chooseDirectories:YES defaultInitialDir:INITIAL_DIR(gemdos)                                     // gemdos
                    324:                                                                                                mutString:gemdos  what:nil] ;
                    325:        if ([gemdos length] >2 ) [gemdosImage setStringValue:[NSApp pathUser:gemdos]] ;
1.1       root      326: }
                    327: 
                    328: - (IBAction)chooseHdImage:(id)sender
                    329: {
1.1.1.11  root      330:        [self choosePathForControl: hdImage chooseDirectories:NO defaultInitialDir:[self initial:hrdDisk]                                       // HD image ?
                    331:                                                                                                mutString:hrdDisk  what:[NSArray arrayWithObjects:@"img",@"hdv",nil]] ;
1.1       root      332: }
                    333: 
1.1.1.6   root      334: - (IBAction)chooseIdeMasterHdImage:(id)sender
                    335: {
1.1.1.11  root      336:        [self choosePathForControl: ideMasterHdImage chooseDirectories:NO defaultInitialDir:[self initial:masterIDE]            // IDE master
                    337:                                                                                                mutString:masterIDE  what:[NSArray arrayWithObject:@"hdv"]];
1.1.1.6   root      338: }
                    339: 
                    340: - (IBAction)chooseIdeSlaveHdImage:(id)sender
1.1.1.5   root      341: {
1.1.1.11  root      342:        [self choosePathForControl: ideSlaveHdImage chooseDirectories:NO defaultInitialDir:[self initial:slaveIDE]                      // IDE slave
                    343:                                                                                                mutString:slaveIDE  what:[NSArray arrayWithObject:@"hdv"]];
1.1.1.5   root      344: }
                    345: 
1.1       root      346: - (IBAction)chooseKeyboardMappingFile:(id)sender
                    347: {
1.1.1.11  root      348:        [self choosePathForControl: keyboardMappingFile chooseDirectories:NO defaultInitialDir:[self initial:keyboard]          // keyboard mapping
                    349:                                                                                                mutString:keyboard  what:[NSArray arrayWithObjects:@"txt",@"map",nil]];
1.1       root      350: }
                    351: 
                    352: - (IBAction)chooseMidiOutputFile:(id)sender
                    353: {
1.1.1.11  root      354:        [self choosePathForControl: writeMidiToFile chooseDirectories:NO defaultInitialDir:[self initial:midiOut]                       // midi output 
                    355:                                                                                                mutString:midiOut  what:[NSArray arrayWithObject:@"mid"]];
1.1       root      356: }
                    357: 
                    358: - (IBAction)choosePrintToFile:(id)sender
                    359: {
1.1.1.11  root      360:        [self choosePathForControl: printToFile chooseDirectories:NO defaultInitialDir:[self initial:printit]                           // print to file
                    361:                                                                                                mutString:printit  what:[NSArray arrayWithObject:@"prn"]];
1.1       root      362: }
                    363: 
                    364: - (IBAction)chooseRS232InputFile:(id)sender
                    365: {
1.1.1.11  root      366:        [self choosePathForControl: readRS232FromFile chooseDirectories:NO defaultInitialDir:[self initial:rs232In]                     // RS232 input
                    367:                                                                                                mutString:rs232In  what:nil];
1.1       root      368: }
                    369: 
                    370: - (IBAction)chooseRS232OutputFile:(id)sender
                    371: {
1.1.1.11  root      372:        [self choosePathForControl: writeRS232ToFile chooseDirectories:NO defaultInitialDir:[self initial:rs232Out]                     // RS232 output
                    373:                                                                                                mutString:rs232Out  what:nil];
1.1       root      374: }
                    375: 
                    376: - (IBAction)chooseTosImage:(id)sender;
                    377: {
1.1.1.11  root      378:        [self choosePathForControl: tosImage chooseDirectories:NO defaultInitialDir:[self initial:TOS]                                          // TOS image
                    379:                                                                                                mutString:TOS  what:[NSArray arrayWithObjects:allT,nil]];
1.1       root      380: }
                    381: 
                    382: 
                    383: /*-----------------------------------------------------------------------*/
1.1.1.11  root      384: /*                                                                       */
                    385: /*  Methods for the "Eject" buttons                                      */
                    386: /*-----------------------------------------------------------------------*/
1.1       root      387: - (IBAction)ejectFloppyA:(id)sender
                    388: {
1.1.1.3   root      389:        Floppy_SetDiskFileNameNone(0);
1.1       root      390:        
1.1.1.11  root      391:        // Refresh  control & mutablestring
1.1       root      392:        [floppyImageA setStringValue:@""];
1.1.1.11  root      393:        [floppyA setString:@""] ;
1.1       root      394: }
                    395: 
                    396: - (IBAction)ejectFloppyB:(id)sender
                    397: {
1.1.1.3   root      398:        Floppy_SetDiskFileNameNone(1);
1.1       root      399: 
1.1.1.11  root      400:        // Refresh  control & mutablestring
1.1       root      401:        [floppyImageB setStringValue:@""];
1.1.1.11  root      402:        [floppyB setString:@""] ;
1.1       root      403: }
                    404: 
                    405: - (IBAction)ejectGemdosImage:(id)sender
                    406: {
1.1.1.3   root      407:        // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
1.1       root      408:        [gemdosImage setStringValue:@""];
1.1.1.11  root      409:        [gemdos setString:@""] ;
1.1       root      410: }
                    411: 
                    412: - (IBAction)ejectHdImage:(id)sender
                    413: {
1.1.1.3   root      414:        // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
1.1       root      415:        [hdImage setStringValue:@""];
1.1.1.11  root      416:        [hrdDisk setString:@""] ;
1.1       root      417: }
                    418: 
1.1.1.6   root      419: - (IBAction)ejectIdeMasterHdImage:(id)sender
1.1.1.5   root      420: {
                    421:        // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
1.1.1.6   root      422:        [ideMasterHdImage setStringValue:@""];
1.1.1.11  root      423:        [masterIDE setString:@""] ;
1.1.1.5   root      424: }
                    425: 
1.1.1.6   root      426: - (IBAction)ejectIdeSlaveHdImage:(id)sender
                    427: {
                    428:        // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
                    429:        [ideSlaveHdImage setStringValue:@""];
1.1.1.11  root      430:        [slaveIDE setString:@""] ;
1.1.1.6   root      431: }
1.1       root      432: 
                    433: /*-----------------------------------------------------------------------*/
1.1.1.3   root      434: /**
                    435:  * Methods for the "Load Config" button
                    436:  */
                    437: 
                    438: - (IBAction)loadConfigFrom:(id)sender
                    439: {
1.1.1.11  root      440:        NSArray         *lesURLs  ;
                    441:        NSString        *ru ;
                    442:        BOOL            btOk ;
                    443: 
                    444:        ru = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
                    445:        [opnPanel setAllowedFileTypes:[NSArray arrayWithObject:@"cfg"]] ;
                    446:        [opnPanel setCanChooseDirectories: NO];
                    447:        [opnPanel setCanChooseFiles: YES];
                    448:        [opnPanel setAccessoryView:partage] ;
                    449: 
1.1.1.12! root      450:        if ([opnPanel respondsToSelector:@selector(setDirectoryURL:)])
        !           451:         {      [opnPanel setDirectoryURL:[NSURL fileURLWithPath:ru isDirectory:YES]] ;
        !           452:                [opnPanel setNameFieldStringValue:@"hatari"] ;
        !           453:                btOk = [opnPanel runModal] == NSOKButton ;                                                                              // Ok ?
        !           454:         }
        !           455:        else
        !           456:                btOk = [opnPanel runModalForDirectory:ru file:@"hatari"] == NSOKButton  ;
1.1.1.11  root      457: 
                    458:        if (!btOk)  return ;                                                                                                                            // Cancel
                    459: 
                    460:        lesURLs = [opnPanel URLs] ;
                    461:        if ((lesURLs == nil) || ([lesURLs count] == 0))
                    462:                return ;
                    463: 
                    464:        [configNm setString:[[lesURLs objectAtIndex:0] path]] ;
1.1.1.3   root      465: 
                    466:                // Make a non-const C string out of it
1.1.1.11  root      467:        [configNm getCString:sConfigFileName maxLength:FILENAME_MAX encoding:NSASCIIStringEncoding];
1.1.1.3   root      468: 
                    469:                // Load the config into ConfigureParams
1.1.1.11  root      470:        Configuration_Load(sConfigFileName);
                    471: 
1.1.1.3   root      472:                // Refresh all the controls to match ConfigureParams
1.1.1.11  root      473:        [self setAllControls];
1.1       root      474: }
                    475: 
1.1.1.3   root      476: /**
1.1.1.11  root      477:  * Methods for the "Save Config" button  (bottom preference window)
1.1.1.3   root      478:  */
                    479: - (IBAction)saveConfigAs:(id)sender
1.1       root      480: {
1.1.1.11  root      481: NSString       *ru ;
                    482: BOOL           btOk ;
1.1.1.3   root      483: 
1.1.1.11  root      484:        ru = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
                    485:        [savPanel setAllowedFileTypes:[NSArray arrayWithObject:@"cfg"]] ;
                    486:        [savPanel setAccessoryView:hartage] ;
1.1       root      487: 
1.1.1.12! root      488:        if ([savPanel respondsToSelector:@selector(setDirectoryURL:)])
        !           489:         {      [savPanel setDirectoryURL:[NSURL fileURLWithPath:ru isDirectory:YES]] ;                 // Since OS X 10.6
        !           490:                [savPanel setNameFieldStringValue:@"hatari"] ;
        !           491:                btOk = [savPanel runModal] == NSOKButton ;                                                                                      // Ok ?
        !           492:         }
        !           493:        else
        !           494:                btOk = [savPanel runModalForDirectory:ru file:@"hatari"] == NSOKButton ;                // avant 10.6
1.1.1.3   root      495: 
1.1.1.11  root      496:        if (!btOk)
                    497:                return ;                                                                        // Cancel
                    498: 
                    499:        [configNm setString:[[savPanel URL] path]];
                    500: 
                    501:                                                                                                                                        // Make a non-const C string out of it
                    502:        [configNm getCString:sConfigFileName maxLength:FILENAME_MAX encoding:NSASCIIStringEncoding];
                    503:        [self saveAllControls] ;                                                                                // Save the config from ConfigureParams         
                    504:        Configuration_Save();                                                                                   // [self configSave:configNm] ;
                    505: }
                    506: 
                    507: - (IBAction)aller:(id)sender
                    508: {
                    509: NSString  *defaultDirectory ;
                    510: 
                    511:        defaultDirectory = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
1.1.1.12! root      512:        if ([opnPanel respondsToSelector:@selector(setDirectoryURL:)])
        !           513:                [opnPanel setDirectoryURL:[NSURL fileURLWithPath:defaultDirectory isDirectory:YES]] ;
        !           514:        else
        !           515:                [opnPanel setDirectory:defaultDirectory] ;
1.1.1.11  root      516: }
                    517: 
                    518: - (IBAction)halle:(id)sender
                    519: {
                    520: NSString  *defaultDirectory ;
                    521: 
                    522:        defaultDirectory = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
1.1.1.12! root      523:        if ([savPanel respondsToSelector:@selector(setDirectoryURL:)])
        !           524:                [savPanel setDirectoryURL:[NSURL fileURLWithPath:defaultDirectory isDirectory:YES]] ;
        !           525:        else 
        !           526:                [savPanel setDirectory:defaultDirectory] ;
1.1       root      527: }
                    528: 
                    529: 
                    530: /*-----------------------------------------------------------------------*/
                    531: /*
1.1.1.11  root      532:   Commits and closes         Ok button in preferences window
1.1       root      533: */
                    534: - (IBAction)commitAndClose:(id)sender
                    535: {
                    536: 
                    537:        // The user clicked OK
                    538:        [self saveAllControls];
                    539:        
1.1.1.11  root      540:        [window close] ;
                    541: 
1.1       root      542: 
                    543: }
                    544: 
1.1.1.11  root      545: // Populate Joystick key dropdown
                    546: 
1.1       root      547: - (void)initKeysDropDown:(NSPopUpButton*)dropDown
                    548: {
                    549:        [dropDown removeAllItems];
1.1.1.7   root      550:        unsigned int i;
1.1       root      551:        for (i = 0; i < Preferences_cKeysForJoysticks; i++)
                    552:        {
                    553:                SDLKey key = Preferences_KeysForJoysticks[i];
                    554:                const char* szKeyName = SDL_GetKeyName(key);
1.1.1.6   root      555:                [dropDown addItemWithTitle:[[NSString stringWithCString:szKeyName encoding:NSASCIIStringEncoding] capitalizedString]];  
1.1       root      556:                [[dropDown lastItem] setTag:key];
                    557:        }
                    558: }
                    559: 
                    560: 
1.1.1.12! root      561: /*--------------------------------------------------------------------------*/
        !           562: /*Displays the Preferences dialog   Ouverture de la fenêtre des préférences */
        !           563: /*--------------------------------------------------------------------------*/
1.1       root      564: - (IBAction)loadPrefs:(id)sender
                    565: {
1.1.1.11  root      566:        [configNm setString:[NSString stringWithCString:sConfigFileName encoding:NSASCIIStringEncoding]] ;
                    567: 
1.1       root      568:        if (!bInitialized)
                    569:        {
                    570:                // Note: These inits cannot be done in awakeFromNib as by this time SDL is not yet initialized.
                    571: 
                    572:                // Fill the keyboard dropdowns
                    573:                [self initKeysDropDown:joystickUp];
                    574:                [self initKeysDropDown:joystickRight];
                    575:                [self initKeysDropDown:joystickDown];
                    576:                [self initKeysDropDown:joystickLeft];           
                    577:                [self initKeysDropDown:joystickFire];
                    578:                
                    579:                // Get and store the number of real joysticks
                    580:                cRealJoysticks = SDL_NumJoysticks();
                    581: 
                    582:                // Fill the real joysticks dropdown, if any are available
                    583:                if (cRealJoysticks > 0)
                    584:                {
                    585:                        [realJoystick removeAllItems];
                    586:                        int i;
                    587:                        for (i = 0; i < cRealJoysticks; i++)
                    588:                        {
                    589:                                const char* szJoystickName = SDL_JoystickName(i);
1.1.1.6   root      590:                                [realJoystick addItemWithTitle:[[NSString stringWithCString:szJoystickName encoding:NSASCIIStringEncoding] capitalizedString]]; 
1.1       root      591:                                [[realJoystick lastItem] setTag:i];     
                    592:                        }
                    593:                }
                    594:                else    // No real joysticks: Disable the controls
                    595:                {
                    596:                        [[joystickMode cellWithTag:1] setEnabled:FALSE];
                    597:                        [realJoystick setEnabled:FALSE];
                    598:                }
                    599:                
1.1.1.5   root      600:                bInitialized = true;
1.1       root      601:        }
                    602: 
                    603: 
1.1.1.3   root      604:        // Backup of configuration settings to CurrentParams (which we will only
                    605:        // commit back to the configuration settings if choosing OK)
                    606:        CurrentParams = ConfigureParams;
1.1.1.11  root      607:        applyChanges=false;
1.1       root      608: 
                    609:        [self setAllControls];
                    610: 
                    611:        // Display the window
1.1.1.9   root      612:        ModalWrapper *mw=[[ModalWrapper alloc] init];
                    613:        
                    614:        [mw runModal:window];
                    615:        
1.1.1.11  root      616:        [mw release];                                                           // */
1.1.1.9   root      617:        
1.1.1.11  root      618:        // solve bug screen-reset: close and kill preference windows before
                    619:        // M. Saro, 2013
1.1.1.9   root      620: 
1.1.1.11  root      621:     //if(Ok button in preferences Windows)
                    622:     {
                    623:         // Check if change need reset
                    624:         if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
                    625:         {
1.1.1.12! root      626:             applyChanges = [NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Don't reset") alternateB:localize(@"Reset")
        !           627:                                                                                        otherB:nil informativeTxt:localize(@"Must be reset") ] == NSAlertAlternateReturn ;
        !           628:                        if (applyChanges)
        !           629:                                Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true) ;
1.1.1.11  root      630:             else
                    631:                 ConfigureParams = CurrentParams;    //Restore backup params
                    632:         }
                    633:         else
                    634:             Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, false); //Apply config without reset
                    635:     }
                    636:     // else // not OK button
                    637:     // {
                    638:     //      ConfigureParams = CurrentParams; //Restore backup params
                    639:     // }
                    640:     
1.1       root      641: }
                    642: 
                    643: /*-----------------------------------------------------------------------*/
                    644: /*
                    645:   Updates the controls following a change in the joystick selection
                    646: */
                    647: - (IBAction)changeViewedJoystick:(id)sender
                    648: {
                    649:        // Save the pre-joystick controls, as we are about to change them
                    650:        [self saveJoystickControls];
                    651:        
                    652:        // Refresh the per-joystick controls
                    653:        [self setJoystickControls];
                    654:        
                    655:        // Update the controls' enabled states
                    656:        [self updateEnabledStates:self];
                    657: }
                    658: 
                    659: 
                    660: /*-----------------------------------------------------------------------*/
                    661: /*
1.1.1.11  root      662:   Initializes all controls, transfert des préférences dans la fenêtre
1.1       root      663: */
                    664: - (void)setAllControls
                    665: {
1.1.1.11  root      666: 
1.1       root      667:        // Import the floppy paths into their controls.
1.1.1.11  root      668:        IMPORT_TEXTFIELD(floppyImageA, floppyA, ConfigureParams.DiskImage.szDiskFileName[0]);                           // le A
                    669:        IMPORT_TEXTFIELD(floppyImageB, floppyB, ConfigureParams.DiskImage.szDiskFileName[1]);                           // le B
                    670: 
1.1       root      671:        // Import all the preferences into their controls
1.1.1.11  root      672:        IMPORT_TEXTFIELD(cartridgeImage, cartridge, ConfigureParams.Rom.szCartridgeImageFileName);
                    673:        IMPORT_TEXTFIELD(defaultImagesLocation, imgeDir, ConfigureParams.DiskImage.szDiskImageDirectory);
                    674:        IMPORT_TEXTFIELD(keyboardMappingFile, keyboard, ConfigureParams.Keyboard.szMappingFileName);
                    675:        IMPORT_TEXTFIELD(printToFile, printit, ConfigureParams.Printer.szPrintToFileName);
                    676:        IMPORT_TEXTFIELD(tosImage, TOS, ConfigureParams.Rom.szTosImageFileName);
                    677:        IMPORT_TEXTFIELD(configFile, configNm, sConfigFileName);
                    678:        IMPORT_TEXTFIELD(readRS232FromFile, rs232In, ConfigureParams.RS232.szInFileName);
                    679:        IMPORT_TEXTFIELD(writeRS232ToFile, rs232Out, ConfigureParams.RS232.szOutFileName);
                    680:        
1.1.1.3   root      681:        IMPORT_SWITCH(autoInsertB, ConfigureParams.DiskImage.bAutoInsertDiskB);
1.1.1.11  root      682:        IMPORT_SWITCH(blitter, ConfigureParams.System.bBlitter);
                    683:        IMPORT_SWITCH(bootFromHD, ConfigureParams.HardDisk.bBootFromHardDisk);
                    684:        IMPORT_SWITCH(captureOnChange, ConfigureParams.Screen.bCrop);
                    685:        IMPORT_RADIO(colorDepth, ConfigureParams.Screen.nVdiColors);
                    686:        IMPORT_SWITCH(compatibleCpu, ConfigureParams.System.bCompatibleCpu);
                    687:        IMPORT_RADIO(cpuClock, ConfigureParams.System.nCpuFreq);
                    688:        IMPORT_RADIO(cpuType, ConfigureParams.System.nCpuLevel);
                    689:        IMPORT_SWITCH(enableMidi, ConfigureParams.Midi.bEnableMidi);
                    690:        IMPORT_SWITCH(enablePrinter, ConfigureParams.Printer.bEnablePrinting);
                    691:        IMPORT_SWITCH(enableRS232, ConfigureParams.RS232.bEnableRS232);
                    692:        IMPORT_SWITCH(enableSound, ConfigureParams.Sound.bEnableSound);
                    693:        IMPORT_DROPDOWN(frameSkip, ConfigureParams.Screen.nFrameSkips);
                    694:        IMPORT_RADIO(keyboardMapping, ConfigureParams.Keyboard.nKeymapType);
                    695:        IMPORT_RADIO(machineType, ConfigureParams.System.nMachineType);
                    696:        IMPORT_RADIO(monitor, ConfigureParams.Screen.nMonitorType);
                    697:        IMPORT_SWITCH(patchTimerD, ConfigureParams.System.bPatchTimerD);
                    698:        IMPORT_RADIO(ramSize, ConfigureParams.Memory.nMemorySize);
                    699:        IMPORT_SWITCH(realTime, ConfigureParams.System.bRealTimeClock);
                    700:        IMPORT_SWITCH(fastFDC, ConfigureParams.DiskImage.FastFloppy);
                    701:        IMPORT_SWITCH(useBorders, ConfigureParams.Screen.bAllowOverscan);
                    702:        IMPORT_SWITCH(useVDIResolution, ConfigureParams.Screen.bUseExtVdiResolutions);
1.1.1.9   root      703:        IMPORT_RADIO(floppyWriteProtection, ConfigureParams.DiskImage.nWriteProtection);
                    704:        IMPORT_RADIO(HDWriteProtection, ConfigureParams.HardDisk.nWriteProtection);
1.1.1.11  root      705:        // IMPORT_SWITCH(zoomSTLowRes, ConfigureParams.Screen.bZoomLowRes);
1.1.1.3   root      706:        IMPORT_SWITCH(showStatusBar, ConfigureParams.Screen.bShowStatusbar);
                    707:        IMPORT_DROPDOWN(enableDSP,ConfigureParams.System.nDSPType);
1.1.1.2   root      708: 
1.1.1.6   root      709:        // 12/04/2010
                    710:        IMPORT_SWITCH(falconTTRatio, ConfigureParams.Screen.bAspectCorrect);
                    711:        IMPORT_SWITCH(fullScreen, ConfigureParams.Screen.bFullScreen);
                    712:        IMPORT_SWITCH(ledDisks, ConfigureParams.Screen.bShowDriveLed);
1.1.1.9   root      713:        IMPORT_SWITCH(keepDesktopResolution, ConfigureParams.Screen.bKeepResolution);
                    714:        
                    715:        //v1.6.1
                    716:        IMPORT_SWITCH(FastBootPatch,ConfigureParams.System.bFastBoot);
                    717:        IMPORT_RADIO(YMVoicesMixing,ConfigureParams.Sound.YmVolumeMixing);
1.1.1.6   root      718:        
                    719:        //deal with the Max Zoomed Stepper
                    720:        IMPORT_NTEXTFIELD(maxZoomedWidth, ConfigureParams.Screen.nMaxWidth);
                    721:        IMPORT_NTEXTFIELD(maxZoomedHeight, ConfigureParams.Screen.nMaxHeight);
                    722:        
1.1.1.9   root      723:        [widthStepper setDoubleValue:[maxZoomedWidth intValue]];
                    724:        [heightStepper setDoubleValue:[maxZoomedHeight intValue]];
1.1.1.6   root      725:        
1.1.1.12! root      726:     //deal with TT RAM Size Stepper
        !           727: #ifdef ENABLE_WINUAE_CPU
        !           728:     IMPORT_NTEXTFIELD(TTRAMSizeValue, ConfigureParams.Memory.nTTRamSize);
        !           729:     [TTRAMSizeStepper setDoubleValue:[TTRAMSizeValue intValue]];
        !           730:     IMPORT_SWITCH(cycleExactCPU, ConfigureParams.System.bCycleExactCpu);
        !           731:     IMPORT_SWITCH(MMU_Emulation, ConfigureParams.System.bMMU);
        !           732:     IMPORT_SWITCH(adressSpace24, ConfigureParams.System.bAddressSpace24);
        !           733:     IMPORT_RADIO(FPUType, ConfigureParams.System.n_FPUType);
        !           734:     IMPORT_SWITCH(CompatibleFPU, ConfigureParams.System.bCompatibleFPU);
        !           735: 
        !           736: #endif
1.1.1.6   root      737:        
1.1.1.3   root      738:        [(force8bpp) setState:((ConfigureParams.Screen.nForceBpp==8))? NSOnState : NSOffState];
1.1.1.2   root      739: 
1.1.1.6   root      740:        
                    741:        int i;
                    742:        
                    743:        for (i = 0; i <= DLGSOUND_50KHZ-DLGSOUND_11KHZ; i++)
                    744:        {
                    745:                if (ConfigureParams.Sound.nPlaybackFreq > nSoundFreqs[i]-500
                    746:                    && ConfigureParams.Sound.nPlaybackFreq < nSoundFreqs[i]+500)
                    747:                {
                    748:                        [playbackQuality selectCellWithTag:(i)];
                    749:                        break;
                    750:                }
                    751:        }
                    752:        
                    753:        
1.1.1.3   root      754:        if (ConfigureParams.Screen.nVdiWidth >= 1024)
1.1.1.2   root      755:                [resolution selectCellWithTag:(2)];
1.1.1.3   root      756:        else if (ConfigureParams.Screen.nVdiWidth >= 768)
1.1.1.2   root      757:                [resolution selectCellWithTag:(1)];
                    758:        else
                    759:                [resolution selectCellWithTag:(0)];
                    760: 
1.1       root      761:        // If the HD flag is set, load the HD path, otherwise make it blank
1.1.1.11  root      762:        if (ConfigureParams.Acsi[0].bUseDevice)
1.1       root      763:        {
1.1.1.11  root      764:                IMPORT_TEXTFIELD(hdImage, hrdDisk, ConfigureParams.Acsi[0].sDeviceFile);
1.1       root      765:        }
                    766:        else
                    767:        {
1.1.1.11  root      768:                [hdImage setStringValue:@""]; [hrdDisk setString:@""] ;
1.1       root      769:        }
                    770:        
1.1.1.5   root      771:        // If the IDE HD flag is set, load the IDE HD path, otherwise make it blank
1.1.1.6   root      772:        //Master
                    773:        if (ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
1.1.1.5   root      774:        {
1.1.1.11  root      775:                IMPORT_TEXTFIELD(ideMasterHdImage, masterIDE, ConfigureParams.HardDisk.szIdeMasterHardDiskImage);
1.1.1.5   root      776:        }
                    777:        else
                    778:        {
1.1.1.11  root      779:                [ideMasterHdImage setStringValue:@""]; [masterIDE setString:@""] ;
1.1.1.6   root      780:        }
                    781:        //Slave
                    782:        if (ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage)
                    783:        {
1.1.1.11  root      784:                IMPORT_TEXTFIELD(ideSlaveHdImage, slaveIDE, ConfigureParams.HardDisk.szIdeSlaveHardDiskImage);
1.1.1.6   root      785:        }
                    786:        else
                    787:        {
1.1.1.11  root      788:                [ideSlaveHdImage setStringValue:@""]; [slaveIDE setString:@""] ;
1.1.1.5   root      789:        }
                    790:        
1.1       root      791:        // If the Gemdos flag is set, load the Gemdos path, otherwise make it blank
1.1.1.3   root      792:        if (ConfigureParams.HardDisk.bUseHardDiskDirectories)
1.1       root      793:        {
1.1.1.11  root      794:                [gemdos setString:[NSString stringWithCString:(ConfigureParams.HardDisk.szHardDiskDirectories[0]) encoding:NSASCIIStringEncoding]] ;
                    795: //             [gemdosImage setStringValue:[NSApp pathUser:[gemdos stringByDeletingLastPathComponent]]] ;
                    796:                [gemdosImage setStringValue:[NSApp pathUser:gemdos]] ;
1.1       root      797:        }
                    798:        else
                    799:        {
1.1.1.11  root      800:                [gemdosImage setStringValue:@""]; [gemdos setString:@""];
1.1       root      801:        }
                    802:        
1.1.1.11  root      803:        // Set the per-joystick controls
1.1       root      804:        [self setJoystickControls];
                    805:        
                    806:        // Update the controls' enabled states
1.1.1.11  root      807:        [self updateEnabledStates:self];
1.1       root      808: }
                    809: 
                    810: 
1.1.1.11  root      811: /*------------------------------------------------------------------------*/
                    812: /* Updates the enabled states of controls who depend on other controls    */
                    813: /**************************************************************************/
                    814: 
1.1       root      815: - (IBAction)updateEnabledStates:(id)sender
                    816: {
                    817:        // Joystick key controls are only enabled if "Use keyboard" is selected
                    818:        int nJoystickMode;
                    819:        EXPORT_RADIO(joystickMode, nJoystickMode);
                    820:        BOOL bUsingKeyboard = (nJoystickMode == JOYSTICK_KEYBOARD);
1.1.1.11  root      821:        [joystickUp setEnabled:bUsingKeyboard];
                    822:        [joystickRight setEnabled:bUsingKeyboard];
                    823:        [joystickDown setEnabled:bUsingKeyboard];
                    824:        [joystickLeft setEnabled:bUsingKeyboard];
                    825:        [joystickFire setEnabled:bUsingKeyboard];
1.1       root      826: 
                    827:        // Resolution and colour depth depend on Extended GEM VDI resolution
                    828:        BOOL bUsingVDI;
                    829:        EXPORT_SWITCH(useVDIResolution, bUsingVDI);
1.1.1.11  root      830:        [resolution setEnabled:bUsingVDI];
1.1       root      831:        [colorDepth setEnabled:bUsingVDI];
                    832:        
                    833:        // Playback quality depends on enable sound
                    834:        BOOL bSoundEnabled;
1.1.1.11  root      835:        EXPORT_SWITCH(enableSound, bSoundEnabled);
1.1       root      836:        [playbackQuality setEnabled:bSoundEnabled];
                    837: }
                    838: 
                    839: 
                    840: /*-----------------------------------------------------------------------*/
1.1.1.11  root      841: /* Updates the joystick controls to match the new joystick selection     */
                    842: /*************************************************************************/
                    843: 
1.1       root      844: - (void)setJoystickControls
                    845: {
                    846:        // Get and persist the ID of the newly selected joystick
                    847:        EXPORT_DROPDOWN(currentJoystick, nCurrentJoystick);
                    848: 
                    849:        // Data validation: If the JoyID is out of bounds, correct it and, if set to use real joystick, change to disabled
1.1.1.3   root      850:        if ( (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId < 0)
                    851:        || (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId >= cRealJoysticks) )
1.1       root      852:        {
1.1.1.3   root      853:                ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId = 0;
                    854:                if (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode == JOYSTICK_REALSTICK)
1.1       root      855:                {
1.1.1.3   root      856:                        ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode = JOYSTICK_DISABLED;
1.1       root      857:                }       
                    858:        }
                    859: 
                    860:        // Don't change the realJoystick dropdown if none is available (to keep "(None available)" selected)
                    861:        if (cRealJoysticks > 0)
                    862:        {
1.1.1.3   root      863:                IMPORT_DROPDOWN(realJoystick, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId);
1.1       root      864:        }
                    865: 
1.1.1.3   root      866:        IMPORT_RADIO(joystickMode, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode);
                    867:        IMPORT_DROPDOWN(joystickUp, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp);
                    868:        IMPORT_DROPDOWN(joystickRight, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight);
                    869:        IMPORT_DROPDOWN(joystickDown, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown);
                    870:        IMPORT_DROPDOWN(joystickLeft, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft);
                    871:        IMPORT_DROPDOWN(joystickFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire);
                    872:        IMPORT_SWITCH(enableAutoFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire);
1.1       root      873: }
                    874: 
                    875: 
                    876: /*-----------------------------------------------------------------------*/
1.1.1.11  root      877: /*   Saves the setting for the joystick currently being viewed           */
1.1       root      878: - (void)saveJoystickControls
                    879: {
1.1.1.3   root      880:        EXPORT_RADIO(joystickMode, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode);      
                    881:        EXPORT_DROPDOWN(realJoystick, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId);
                    882:        EXPORT_DROPDOWN(joystickUp, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp);
                    883:        EXPORT_DROPDOWN(joystickRight, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight);
                    884:        EXPORT_DROPDOWN(joystickDown, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown);
                    885:        EXPORT_DROPDOWN(joystickLeft, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft);
                    886:        EXPORT_DROPDOWN(joystickFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire);
                    887:        EXPORT_SWITCH(enableAutoFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire);
1.1       root      888: }
                    889: 
                    890: 
                    891: /*-----------------------------------------------------------------------*/
1.1.1.11  root      892: /* Saves the settings for all controls                                   */
1.1       root      893: - (void)saveAllControls
                    894: {
                    895:        // Export the preference controls into their vars
1.1.1.11  root      896: 
                    897:        EXPORT_TEXTFIELD(cartridge, ConfigureParams.Rom.szCartridgeImageFileName);
                    898:        EXPORT_TEXTFIELD(imgeDir, ConfigureParams.DiskImage.szDiskImageDirectory);
                    899:        EXPORT_TEXTFIELD(keyboard, ConfigureParams.Keyboard.szMappingFileName);
                    900:        EXPORT_TEXTFIELD(printit, ConfigureParams.Printer.szPrintToFileName);
                    901:        EXPORT_TEXTFIELD(rs232In, ConfigureParams.RS232.szInFileName);
                    902:        EXPORT_TEXTFIELD(TOS, ConfigureParams.Rom.szTosImageFileName);
                    903:        EXPORT_TEXTFIELD(midiOut, ConfigureParams.Midi.sMidiOutFileName);
                    904:        EXPORT_TEXTFIELD(rs232Out, ConfigureParams.RS232.szOutFileName);
                    905: 
                    906:        //EXPORT_TEXTFIELD(cartridgeImage, ConfigureParams.Rom.szCartridgeImageFileName);
                    907:        
1.1.1.3   root      908:        EXPORT_SWITCH(autoInsertB, ConfigureParams.DiskImage.bAutoInsertDiskB);
1.1.1.11  root      909:        EXPORT_SWITCH(blitter, ConfigureParams.System.bBlitter);
1.1.1.3   root      910:        EXPORT_SWITCH(bootFromHD, ConfigureParams.HardDisk.bBootFromHardDisk);
1.1.1.11  root      911:        EXPORT_SWITCH(captureOnChange, ConfigureParams.Screen.bCrop);
                    912:        EXPORT_RADIO(colorDepth, ConfigureParams.Screen.nVdiColors);
                    913:        EXPORT_SWITCH(compatibleCpu, ConfigureParams.System.bCompatibleCpu);
                    914:        EXPORT_RADIO(cpuClock, ConfigureParams.System.nCpuFreq);
                    915:        EXPORT_RADIO(cpuType, ConfigureParams.System.nCpuLevel);
                    916:        EXPORT_SWITCH(enableMidi, ConfigureParams.Midi.bEnableMidi);
                    917:        EXPORT_SWITCH(enablePrinter, ConfigureParams.Printer.bEnablePrinting);
                    918:        EXPORT_SWITCH(enableRS232, ConfigureParams.RS232.bEnableRS232);
                    919:        EXPORT_SWITCH(enableSound, ConfigureParams.Sound.bEnableSound);
                    920:        EXPORT_DROPDOWN(frameSkip, ConfigureParams.Screen.nFrameSkips);
                    921:        EXPORT_RADIO(keyboardMapping, ConfigureParams.Keyboard.nKeymapType);
                    922:        EXPORT_RADIO(machineType, ConfigureParams.System.nMachineType);
                    923:        EXPORT_RADIO(monitor, ConfigureParams.Screen.nMonitorType);
                    924:        EXPORT_SWITCH(patchTimerD, ConfigureParams.System.bPatchTimerD);
                    925:        EXPORT_RADIO(ramSize, ConfigureParams.Memory.nMemorySize);
                    926:        EXPORT_SWITCH(realTime, ConfigureParams.System.bRealTimeClock);
                    927:        EXPORT_SWITCH(fastFDC, ConfigureParams.DiskImage.FastFloppy);
                    928:        EXPORT_SWITCH(useBorders, ConfigureParams.Screen.bAllowOverscan);
                    929:        EXPORT_SWITCH(useVDIResolution, ConfigureParams.Screen.bUseExtVdiResolutions);
1.1.1.9   root      930:        EXPORT_RADIO(floppyWriteProtection, ConfigureParams.DiskImage.nWriteProtection);
1.1.1.11  root      931:        EXPORT_RADIO(HDWriteProtection, ConfigureParams.HardDisk.nWriteProtection);
                    932:        // EXPORT_SWITCH(zoomSTLowRes, ConfigureParams.Screen.bZoomLowRes);
1.1.1.3   root      933:        EXPORT_SWITCH(showStatusBar,ConfigureParams.Screen.bShowStatusbar);
                    934:        EXPORT_DROPDOWN(enableDSP,ConfigureParams.System.nDSPType);
1.1.1.6   root      935:        
                    936:        EXPORT_SWITCH(falconTTRatio, ConfigureParams.Screen.bAspectCorrect);
                    937:        EXPORT_SWITCH(fullScreen, ConfigureParams.Screen.bFullScreen);
1.1.1.9   root      938:        EXPORT_SWITCH(ledDisks, ConfigureParams.Screen.bShowDriveLed);
                    939:        EXPORT_SWITCH(keepDesktopResolution, ConfigureParams.Screen.bKeepResolution);
                    940:        
                    941:        //v1.6.1
                    942:        EXPORT_SWITCH(FastBootPatch,ConfigureParams.System.bFastBoot);
                    943:        EXPORT_RADIO(YMVoicesMixing,ConfigureParams.Sound.YmVolumeMixing);
1.1.1.6   root      944:        
                    945:        EXPORT_NTEXTFIELD(maxZoomedWidth, ConfigureParams.Screen.nMaxWidth);
                    946:        EXPORT_NTEXTFIELD(maxZoomedHeight, ConfigureParams.Screen.nMaxHeight);
1.1.1.12! root      947:     
        !           948: #ifdef ENABLE_WINUAE_CPU
        !           949:     EXPORT_NTEXTFIELD(TTRAMSizeValue, ConfigureParams.Memory.nTTRamSize);
        !           950:     EXPORT_SWITCH(cycleExactCPU, ConfigureParams.System.bCycleExactCpu);
        !           951:     EXPORT_SWITCH(MMU_Emulation, ConfigureParams.System.bMMU);
        !           952:     EXPORT_SWITCH(adressSpace24, ConfigureParams.System.bAddressSpace24);
        !           953:     EXPORT_RADIO(FPUType, ConfigureParams.System.n_FPUType);
        !           954:     EXPORT_SWITCH(CompatibleFPU, ConfigureParams.System.bCompatibleFPU);
        !           955: #endif
        !           956:     
1.1.1.6   root      957:        ConfigureParams.Screen.nForceBpp = ([force8bpp state] == NSOnState) ? 8 : 0;
1.1.1.5   root      958: 
1.1.1.6   root      959:        ConfigureParams.Sound.nPlaybackFreq = nSoundFreqs[[[playbackQuality selectedCell] tag]];
                    960:                        
1.1.1.2   root      961:        switch ([[resolution selectedCell] tag])
                    962:        {
                    963:         case 0:
1.1.1.3   root      964:                ConfigureParams.Screen.nVdiWidth = 640;
                    965:                ConfigureParams.Screen.nVdiHeight = 480;
1.1.1.2   root      966:                break;
                    967:         case 1:
1.1.1.3   root      968:                ConfigureParams.Screen.nVdiWidth = 800;
                    969:                ConfigureParams.Screen.nVdiHeight = 600;
1.1.1.2   root      970:                break;
                    971:         case 2:
1.1.1.3   root      972:                ConfigureParams.Screen.nVdiWidth = 1024;
                    973:                ConfigureParams.Screen.nVdiHeight = 768;
1.1.1.2   root      974:                break;
                    975:        }
1.1       root      976: 
                    977:        // Define the HD flag, and export the HD path if one is selected
1.1.1.11  root      978:        if ([hrdDisk length] > 0)
1.1       root      979:        {
1.1.1.11  root      980:                EXPORT_TEXTFIELD(hrdDisk, ConfigureParams.Acsi[0].sDeviceFile);
                    981:                ConfigureParams.Acsi[0].bUseDevice = true;
1.1.1.5   root      982:        }
                    983:        else
                    984:        {
1.1.1.11  root      985:                ConfigureParams.Acsi[0].bUseDevice = false;
1.1.1.5   root      986:        }
1.1.1.11  root      987: 
1.1.1.5   root      988:        // Define the IDE HD flag, and export the IDE HD path if one is selected
1.1.1.11  root      989:        if ([masterIDE length] > 0)
1.1.1.6   root      990:        {
1.1.1.11  root      991:                EXPORT_TEXTFIELD(masterIDE, ConfigureParams.HardDisk.szIdeMasterHardDiskImage);
                    992:                ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage = YES;
1.1.1.6   root      993:        }
                    994:        else
1.1.1.5   root      995:        {
1.1.1.11  root      996:                ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage = NO;
1.1.1.6   root      997:        }
                    998:        
                    999:        // IDE Slave
1.1.1.11  root     1000:        if ([slaveIDE length] > 0)
1.1.1.6   root     1001:        {
1.1.1.11  root     1002:                EXPORT_TEXTFIELD(slaveIDE, ConfigureParams.HardDisk.szIdeSlaveHardDiskImage);
                   1003:                ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage = YES;
1.1       root     1004:        }
                   1005:        else
                   1006:        {
1.1.1.11  root     1007:                ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage = NO;
1.1       root     1008:        }
                   1009:        
                   1010:        // Define the Gemdos flag, and export the Gemdos path if one is selected
1.1.1.11  root     1011:        if ([gemdos length] > 0)
1.1       root     1012:        {
1.1.1.11  root     1013:                EXPORT_TEXTFIELD(gemdos, ConfigureParams.HardDisk.szHardDiskDirectories[0]);
                   1014:                ConfigureParams.HardDisk.bUseHardDiskDirectories = YES;
1.1       root     1015:        }
                   1016:        else
                   1017:        {
1.1.1.11  root     1018:                ConfigureParams.HardDisk.bUseHardDiskDirectories = NO;
1.1       root     1019:        }
1.1.1.11  root     1020: 
                   1021:        // Save the per-joystick controls
                   1022:        [self saveJoystickControls];
1.1       root     1023: }
                   1024: 
1.1.1.6   root     1025: // Max Zoomed Adjust
                   1026: 
                   1027: - (IBAction) setWidth:(id)sender;
                   1028: {
1.1.1.11  root     1029:        NSLog(@"Change Max Zoom width: %d", [sender intValue]);
1.1.1.6   root     1030:     [maxZoomedWidth setIntValue: [sender intValue]];
                   1031: }
                   1032: 
                   1033: - (IBAction) setHeight:(id)sender;
                   1034: {
1.1.1.11  root     1035:        NSLog(@"Change Max Zoom height: %d", [sender intValue]);
1.1.1.6   root     1036:     [maxZoomedHeight setIntValue: [sender intValue]];
                   1037: }
                   1038: 
1.1.1.12! root     1039: - (IBAction)setTTRAMSize:(id)sender
        !          1040: {
        !          1041:     NSLog(@"Change TTRAMSize: %d", [sender intValue]);
        !          1042:     [TTRAMSizeValue setIntValue: [sender intValue]];
        !          1043:     
        !          1044: }
        !          1045: 
1.1.1.11  root     1046: +(PrefsController *)prefs
1.1.1.9   root     1047: {
1.1.1.11  root     1048:        static PrefsController *prefs = nil;
1.1.1.9   root     1049:        if (!prefs)
                   1050:                prefs = [[PrefsController alloc] init];
                   1051:        
                   1052:        return prefs;
1.1.1.11  root     1053: }                                                                                                                                      // */
1.1.1.9   root     1054: 
1.1.1.11  root     1055: - (void)awakeFromNib
                   1056: {
                   1057:        cartridge = [NSMutableString stringWithCapacity:50] ; [cartridge setString:@""] ; [cartridge retain] ;
                   1058:        imgeDir = [NSMutableString stringWithCapacity:50] ; [imgeDir setString:@""] ; [imgeDir retain] ;
                   1059:        floppyA = [NSMutableString stringWithCapacity:50] ; [floppyA setString:@""] ; [floppyA retain] ;
                   1060:        floppyB = [NSMutableString stringWithCapacity:50] ; [floppyB setString:@""] ; [floppyB retain] ;
                   1061:        gemdos = [NSMutableString stringWithCapacity:50] ; [gemdos setString:@""] ; [gemdos retain] ;
                   1062:        hrdDisk = [NSMutableString stringWithCapacity:50] ; [hrdDisk setString:@""] ; [hrdDisk retain] ;
                   1063:        masterIDE = [NSMutableString stringWithCapacity:50] ; [masterIDE setString:@""] ; [masterIDE retain] ;
                   1064:        slaveIDE = [NSMutableString stringWithCapacity:50] ; [slaveIDE setString:@""] ; [slaveIDE retain] ;
                   1065:        keyboard = [NSMutableString stringWithCapacity:50] ; [keyboard setString:@""] ; [keyboard retain] ;
                   1066:        midiOut = [NSMutableString stringWithCapacity:50] ; [midiOut setString:@""] ; [midiOut retain] ;
                   1067:        printit = [NSMutableString stringWithCapacity:50] ; [printit setString:@""] ; [printit retain] ;
                   1068:        rs232In = [NSMutableString stringWithCapacity:50] ; [rs232In setString:@""] ; [rs232In retain] ;
                   1069:        rs232Out = [NSMutableString stringWithCapacity:50] ; [rs232Out setString:@""] ; [rs232Out retain] ;
                   1070:        TOS = [NSMutableString stringWithCapacity:50] ; [TOS setString:@""] ; [TOS retain] ;
                   1071:        configNm = [NSMutableString stringWithCapacity:50] ; [configNm setString:@""] ; [configNm retain] ;
                   1072:        opnPanel = [NSOpenPanel openPanel]; [opnPanel retain] ;
                   1073:        savPanel = [NSSavePanel savePanel]; [savPanel retain] ;
1.1.1.12! root     1074: #ifdef ENABLE_WINUAE_CPU
        !          1075:     [cycleExactCPU setEnabled:true];
        !          1076:     [MMU_Emulation setEnabled:true];
        !          1077:     [adressSpace24 setEnabled:true];
        !          1078:     [TTRAMSizeValue setEnabled:true];
        !          1079:     [CompatibleFPU setEnabled:true];
        !          1080:     [FPUType setEnabled:true];
        !          1081:     [bCell68060 setEnabled:true];
        !          1082: #endif
        !          1083:     
1.1.1.11  root     1084: }
1.1.1.6   root     1085: 
1.1       root     1086: @end

unix.superglobalmegacorp.com

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