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