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