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