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