ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/PrefsEditor.mm
Revision: 1.10
Committed: 2003-04-02T02:19:53Z (21 years, 8 months ago) by nigel
Branch: MAIN
Changes since 1.9: +43 -5 lines
Log Message:
Extra code for changing preferences file

File Contents

# User Rev Content
1 nigel 1.1 /*
2     * PrefsEditor.m - GUI stuff for Basilisk II preferences
3     * (which is a text file in the user's home directory)
4     *
5 nigel 1.10 * $Id: PrefsEditor.mm,v 1.9 2003/03/25 01:47:37 nigel Exp $
6 nigel 1.1 *
7 nigel 1.7 * Basilisk II (C) 1997-2003 Christian Bauer
8 nigel 1.1 *
9     * This program is free software; you can redistribute it and/or modify
10     * it under the terms of the GNU General Public License as published by
11     * the Free Software Foundation; either version 2 of the License, or
12     * (at your option) any later version.
13     *
14     * This program is distributed in the hope that it will be useful,
15     * but WITHOUT ANY WARRANTY; without even the implied warranty of
16     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     * GNU General Public License for more details.
18     *
19     * You should have received a copy of the GNU General Public License
20     * along with this program; if not, write to the Free Software
21     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22     */
23    
24     #import "PrefsEditor.h"
25    
26     @implementation TableDS
27    
28     - (TableDS *) init
29     {
30     self = [super init];
31    
32     numItems = 0;
33 nigel 1.5 col1 = [NSMutableArray new];
34     col2 = [NSMutableArray new];
35 nigel 1.1
36     return self;
37     }
38    
39     - (void) dealloc
40     {
41     [col1 dealloc];
42     [col2 dealloc];
43     [super dealloc];
44     }
45    
46     - (void) addInt: (int)target
47     withPath: (NSString *)path
48     {
49     [col1 addObject: [NSNumber numberWithInt: target]];
50     [col2 addObject: path];
51     ++numItems;
52     }
53    
54     - (void) addObject: (NSObject *)obj
55     withPath: (NSString *)path
56     {
57     [col1 addObject: obj];
58     [col2 addObject: path];
59     ++numItems;
60     }
61    
62     - (void) deleteAll
63     {
64     numItems = 0;
65     [col1 removeAllObjects];
66     [col2 removeAllObjects];
67     }
68    
69     - (BOOL) deleteRow: (int)row
70     {
71     if ( row > numItems )
72     return NO;
73    
74     [col1 removeObjectAtIndex: row];
75     [col2 removeObjectAtIndex: row];
76     -- numItems;
77    
78     return YES;
79     }
80    
81     - (int)intAtRow: (int)row
82     {
83     return [[col1 objectAtIndex: row] intValue];
84     }
85    
86     - (int) numberOfRowsInTableView: (NSTableView *)tView
87     {
88     return numItems;
89     }
90    
91     - (NSString *)pathAtRow: (int)row
92     {
93     return (NSString *) [col2 objectAtIndex: row];
94     }
95    
96     - (id) tableView: (NSTableView *)tView
97     objectValueForTableColumn: (NSTableColumn *)tColumn
98     row: (int)row
99     {
100     if ( [[tColumn identifier] isEqualToString:@"path"] )
101     return [col2 objectAtIndex: row];
102     else
103     return [col1 objectAtIndex: row];
104     }
105    
106     @end
107    
108     @implementation PrefsEditor
109    
110     #import <AppKit/NSImage.h> // For [NSBundle pathForImageResource:] proto
111    
112 nigel 1.10 #include <string>
113     using std::string;
114     extern string UserPrefsPath; // from prefs_unix.cpp
115    
116 nigel 1.1 #import "sysdeps.h" // Types used in Basilisk C++ code
117     #import "video_macosx.h" // some items that we edit here
118     #import "misc_macosx.h" // WarningSheet() prototype
119    
120     #import <prefs.h>
121    
122 nigel 1.3 #define DEBUG 0
123 nigel 1.1 #import <debug.h>
124    
125     - (PrefsEditor *) init
126     {
127     self = [super init];
128    
129     edited = NO;
130    
131     devs = @"/dev";
132     home = NSHomeDirectory();
133 nigel 1.5 volsDS = [TableDS new];
134     SCSIds = [TableDS new];
135 nigel 1.1
136 nigel 1.5 lockCell = [NSImageCell new];
137 nigel 1.1 if ( lockCell == nil )
138     NSLog (@"%s - Can't create NSImageCell?", __PRETTY_FUNCTION__);
139    
140 nigel 1.5 blank = [NSImage new];
141 nigel 1.1 locked = [NSImage alloc];
142     if ( [locked initWithContentsOfFile:
143     [[NSBundle mainBundle]
144     pathForImageResource: @"nowrite.icns"]] == nil )
145     NSLog(@"%s - Couldn't open write protection image", __PRETTY_FUNCTION__);
146    
147     return self;
148     }
149    
150     - (void) dealloc
151     {
152     [volsDS dealloc];
153     [SCSIds dealloc];
154     [lockCell dealloc];
155     [locked dealloc];
156     [blank dealloc];
157     [super dealloc];
158     }
159    
160     - (void) awakeFromNib
161     {
162     emuFreq = [theEmulator speed];
163     #if DEBUG
164     [self ShowPrefs: self]; // For testing
165     #endif
166     }
167    
168     - (BOOL) hasEdited
169     {
170     return edited;
171     }
172    
173     - (NSWindow *) window
174     {
175     return panel;
176     }
177    
178     - (IBAction) AddSCSI: (id)sender
179     {
180     NSOpenPanel *oP = [NSOpenPanel openPanel];
181    
182     if ( [oP runModalForDirectory:home file:nil types:nil] == NSOKButton )
183     {
184     [SCSIds addInt: -1
185     withPath: [oP filename] ];
186     [SCSIdisks reloadData];
187     edited = YES;
188     }
189     }
190    
191     - (IBAction) AddVolume: (id)sender
192     {
193     NSOpenPanel *oP = [NSOpenPanel openPanel];
194    
195     if ( [oP runModalForDirectory:home file:nil types:nil] == NSOKButton )
196     {
197     [volsDS addObject: (NSObject *) locked
198     withPath: [oP filename] ];
199     PrefsAddString("disk", [[oP filename] cString]);
200     [diskImages reloadData];
201     edited = YES;
202     }
203     }
204    
205     - (IBAction) BrowseExtFS: (id)sender
206     {
207     NSOpenPanel *oP = [NSOpenPanel openPanel];
208    
209     [oP setCanChooseDirectories: YES];
210     [oP setCanChooseFiles: NO];
211     [oP setPrompt: @"Select"];
212     [oP setTitle: @"Select a directory to mount"];
213     D(NSLog(@"%s - home = %@, [extFS stringValue] = %@",
214     __PRETTY_FUNCTION__, home, [extFS stringValue]));
215     if ( [oP runModalForDirectory: ([extFS stringValue] ? [extFS stringValue] : home)
216     file:nil
217     types:nil] == NSOKButton )
218     {
219     [extFS setStringValue: [oP directory] ];
220     PrefsReplaceString("extfs", [[oP directory] cString]);
221     edited = YES;
222     }
223     }
224    
225 nigel 1.10 - (IBAction) BrowsePrefs: (id)sender
226     {
227     NSOpenPanel *oP = [NSOpenPanel openPanel];
228    
229     [oP setCanChooseFiles: YES];
230     [oP setTitle: @"Select a Preferences file"];
231     D(NSLog(@"%s - home = %@", __PRETTY_FUNCTION__, home));
232     if ( [oP runModalForDirectory: ([prefsFile stringValue] ? [prefsFile stringValue] : home)
233     file:nil
234     types:nil] == NSOKButton )
235     {
236     [prefsFile setStringValue: [oP filename] ];
237     UserPrefsPath = [[oP filename] cString];
238     }
239     }
240    
241 nigel 1.1 - (IBAction) BrowseROM: (id)sender
242     {
243     NSOpenPanel *oP = [NSOpenPanel openPanel];
244    
245     [oP setCanChooseFiles: YES];
246     [oP setTitle: @"Open a ROM file"];
247     D(NSLog(@"%s - home = %@", __PRETTY_FUNCTION__, home));
248     if ( [oP runModalForDirectory: ([ROMfile stringValue] ? [ROMfile stringValue] : home)
249     file:nil
250     types:nil] == NSOKButton )
251     {
252     [ROMfile setStringValue: [oP filename] ];
253     PrefsReplaceString("rom", [[oP filename] cString]);
254     edited = YES;
255     }
256     }
257    
258     #include <cdrom.h> // for CDROMRefNum
259    
260     - (IBAction) ChangeBootFrom: (NSMatrix *)sender
261     {
262     if ( [sender selectedCell] == bootFromCD )
263     PrefsReplaceInt32("bootdriver", CDROMRefNum);
264     else
265     PrefsReplaceInt32("bootdriver", 0);
266     edited = YES;
267     }
268    
269     - (IBAction) ChangeCPU: (NSMatrix *)sender
270     {
271     PrefsReplaceInt32("cpu", [[sender selectedCell] tag]);
272     edited = YES;
273     }
274    
275     - (IBAction) ChangeDisableCD: (NSButton *)sender
276     {
277     PrefsReplaceBool("nocdrom", [disableCD state]);
278     edited = YES;
279     }
280    
281     - (IBAction) ChangeDisableSound: (NSButton *)sender
282     {
283 nigel 1.2 BOOL noSound = [disableSound state];
284    
285     if ( ! noSound )
286     WarningSheet(@"Sound is currently unimplemented", panel);
287    
288     PrefsReplaceBool("nosound", noSound);
289 nigel 1.1 edited = YES;
290     }
291    
292     - (IBAction) ChangeFPU: (NSButton *)sender
293     {
294     PrefsReplaceBool("fpu", [FPU state]);
295     edited = YES;
296     }
297    
298     - (IBAction) ChangeModel: (NSMatrix *)sender
299     {
300     PrefsReplaceInt32("modelid", [[sender selectedCell] tag]);
301     edited = YES;
302     }
303    
304 nigel 1.7
305     // If we are not using the CGIMAGEREF drawing strategy,
306     // then source bitmaps must be 32bits deep.
307    
308     - (short) testWinDepth: (int) newbpp
309     {
310     #ifdef CGIMAGEREF
311     return newbpp;
312     #else
313     if ( newbpp != 32 )
314     WarningSheet(@"Sorry - In windowed mode, depth must be 32", panel);
315     return 32
316     #endif
317     }
318    
319 nigel 1.8 // This is called when the screen/window,
320 nigel 1.3 // width, height or depth is clicked.
321     //
322     // Note that sender may not actually be an NSMatrix.
323 nigel 1.1
324 nigel 1.3 - (IBAction) ChangeScreen: (NSMatrix *)sender
325     {
326     NSButton *cell = [sender selectedCell];
327 nigel 1.1
328     short newx = [width intValue];
329     short newy = [height intValue];
330     short newbpp = [depth intValue];
331 nigel 1.2 short newtype;
332 nigel 1.1 char str[20];
333    
334 nigel 1.8 if ( cell == screen )
335 nigel 1.1 newtype = DISPLAY_SCREEN;
336 nigel 1.3 else if ( cell == window )
337 nigel 1.2 newtype = DISPLAY_WINDOW;
338     else
339     newtype = display_type;
340 nigel 1.1
341     // Check that a field actually changed
342     if ( newbpp == init_depth && newx == init_width &&
343     newy == init_height && newtype == display_type )
344 nigel 1.2 {
345 nigel 1.4 D(NSLog(@"No changed GUI items in ChangeScreen"));
346 nigel 1.1 return;
347 nigel 1.2 }
348 nigel 1.1
349     // If we are changing type, supply some sensible defaults
350 nigel 1.7
351     short screenx = CGDisplayPixelsWide(kCGDirectMainDisplay),
352     screeny = CGDisplayPixelsHigh(kCGDirectMainDisplay),
353     screenb = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
354    
355 nigel 1.1 if ( newtype != display_type )
356     {
357 nigel 1.4 D(NSLog(@"Changing display type in ChangeScreen"));
358 nigel 1.1
359 nigel 1.7 // If changing to full screen, supply main screen dimensions as a default
360     if ( newtype == DISPLAY_SCREEN )
361     newx = screenx, newy = screeny, newbpp = screenb;
362    
363     // If changing from full screen, use minimum screen resolutions
364     if ( display_type == DISPLAY_SCREEN )
365 nigel 1.6 {
366 nigel 1.1 newx = MIN_WIDTH, newy = MIN_HEIGHT;
367 nigel 1.7 newbpp = [self testWinDepth: newbpp];
368 nigel 1.6 }
369 nigel 1.1 }
370     else
371     {
372 nigel 1.7 newbpp = [self testWinDepth: newbpp];
373 nigel 1.6
374 nigel 1.1 // Check size is within ranges of MIN_WIDTH ... MAX_WIDTH
375     // and MIN_HEIGHT ... MAX_HEIGHT
376     // ???
377     }
378 nigel 1.7
379     [width setIntValue: newx];
380     [height setIntValue: newy];
381     [depth setIntValue: newbpp];
382 nigel 1.1
383    
384     // Store new prefs
385     *str = '\0';
386     switch ( newtype )
387     {
388     case DISPLAY_WINDOW:
389     if ( newbpp )
390     sprintf(str, "win/%hd/%hd/%hd", newx, newy, newbpp);
391     else
392     sprintf(str, "win/%hd/%hd", newx, newy);
393     break;
394     case DISPLAY_SCREEN:
395     if ( newbpp )
396     sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp);
397     else
398     sprintf(str, "full/%hd/%hd", newx, newy);
399     break;
400     };
401     PrefsReplaceString("screen", str);
402    
403     parse_screen_prefs(str);
404    
405     edited = YES;
406    
407     if ( display_type != DISPLAY_SCREEN )
408 nigel 1.2 {
409 nigel 1.4 D(NSLog(@"Display type is not SCREEN (%d), resizing window",
410     display_type));
411 nigel 1.1 resizeWinTo(newx, newy);
412 nigel 1.2 }
413 nigel 1.1 }
414    
415     - (IBAction) CreateVolume: (id)sender
416     {
417     NSSavePanel *sP = [NSSavePanel savePanel];
418    
419     [sP setAccessoryView: newVolumeView];
420     [sP setPrompt: @"Create"];
421     [sP setTitle: @"Create new volume as"];
422    
423     if ( [sP runModalForDirectory:NSHomeDirectory() file:@"basilisk-II.vol"] == NSOKButton )
424     {
425     char cmd[1024];
426     const char *filename = [[sP filename] cString];
427     int retVal,
428     size = [newVolumeSize intValue];
429    
430     sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", filename, size);
431     retVal = system(cmd);
432     if (retVal != 0)
433     {
434     NSString *details = [NSString stringWithFormat:
435     @"The dd command failed.\nReturn status %d (%s)",
436     retVal, strerror(errno)];
437 nigel 1.2 WarningSheet(@"Unable to create volume", details, nil, panel);
438 nigel 1.1 }
439     else
440     {
441     [volsDS addObject: (NSObject *) blank
442     withPath: [sP filename] ];
443     PrefsAddString("disk", filename);
444     [diskImages reloadData];
445     }
446     }
447     }
448    
449 nigel 1.5 - (BOOL) fileManager: (NSFileManager *) manager
450     shouldProceedAfterError: (NSDictionary *) errorDict
451     {
452     NSRunAlertPanel(@"File operation error",
453     @"%@ %@, toPath %@",
454     @"Bugger!", nil, nil,
455     [errorDict objectForKey:@"Error"],
456     [errorDict objectForKey:@"Path"],
457     [errorDict objectForKey:@"ToPath"]);
458     return NO;
459     }
460    
461 nigel 1.1 - (IBAction) DeleteVolume: (id)sender
462     {
463 nigel 1.5 // const char *path = [self RemoveVolumeEntry];
464     // if ( unlink(path) == -1 )
465     NSString *Path = [self RemoveVolumeEntry];
466    
467     if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path
468     handler: self] )
469 nigel 1.1 {
470 nigel 1.5 WarningSheet(@"Unable to delete volume", panel);
471     // NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno));
472 nigel 1.1 }
473     }
474    
475     - (IBAction) EditDelay: (NSTextField *)sender
476     {
477     int ticks = [delay intValue];
478     float freq;
479    
480     if ( ticks )
481     freq = 60.0 / ticks;
482     else
483     freq = 60.0;
484    
485     [frequency setFloatValue: freq];
486     [emuFreq setFloatValue: freq];
487     PrefsReplaceInt32("frameskip", ticks);
488     edited = YES;
489     }
490    
491     - (IBAction) EditBytes: (NSTextField *)sender
492     {
493     int B = (int) [bytes floatValue];
494     float M = B / 1024 / 1024;
495    
496 nigel 1.2 D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B));
497 nigel 1.1 PrefsReplaceInt32("ramsize", B);
498     [MB setFloatValue: M];
499     edited = YES;
500     }
501    
502     - (IBAction) EditEtherNetDevice: (NSTextField *)sender
503     {
504     NSString *path = [etherNet stringValue];
505    
506     PrefsReplaceString("ether", [path cString]);
507     edited = YES;
508     }
509    
510     - (IBAction) EditExtFS: (NSTextField *)sender
511     {
512     NSString *path = [extFS stringValue];
513    
514     PrefsReplaceString("extfs", [path cString]);
515     edited = YES;
516     }
517    
518     - (IBAction) EditFrequency: (NSTextField *)sender
519     {
520     float freq = [frequency floatValue];
521    
522     [delay setIntValue: frequencyToTickDelay(freq)];
523     [emuFreq setFloatValue: freq];
524     edited = YES;
525     }
526    
527     - (IBAction) EditModemDevice: (NSTextField *)sender
528     {
529     NSString *path = [modem stringValue];
530    
531     PrefsReplaceString("seriala", [path cString]);
532     edited = YES;
533     }
534    
535     - (IBAction) EditMB: (NSTextField *)sender
536     {
537     float M = [MB floatValue];
538     int B = (int) (M * 1024 * 1024);
539    
540 nigel 1.2 D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B));
541 nigel 1.1 PrefsReplaceInt32("ramsize", B);
542     [bytes setIntValue: B];
543     edited = YES;
544     }
545    
546     - (IBAction) EditPrinterDevice: (NSTextField *)sender
547     {
548     NSString *path = [printer stringValue];
549    
550     PrefsReplaceString("serialb", [path cString]);
551     edited = YES;
552     }
553    
554     - (IBAction) EditROMpath: (NSTextField *)sender
555     {
556     NSString *path = [ROMfile stringValue];
557    
558     PrefsReplaceString("rom", [path cString]);
559     }
560    
561     - (IBAction) RemoveSCSI: (id)sender
562     {
563     char pref[6];
564     int row = [SCSIdisks selectedRow],
565     SCSIid = [SCSIds intAtRow: row];
566    
567     if ( ! [SCSIds deleteRow: row] )
568     NSLog (@"%s - [SCSIds deleteRow: %d] failed", __PRETTY_FUNCTION__, row);
569     [SCSIdisks reloadData];
570     sprintf(pref, "scsi%d", SCSIid);
571     PrefsRemoveItem(pref,0);
572     }
573    
574 nigel 1.5 //- (const char *) RemoveVolumeEntry
575     - (NSString *) RemoveVolumeEntry
576 nigel 1.1 {
577     int row = [diskImages selectedRow];
578    
579     if ( row != -1 )
580     {
581 nigel 1.5 NSString *Path = [volsDS pathAtRow: row];
582     const char *path = [Path cString],
583 nigel 1.1 *str;
584     int tmp = 0;
585    
586     while ( (str = PrefsFindString("disk", tmp) ) != NULL )
587     {
588     if ( strcmp(str, path) == 0 )
589     {
590     PrefsRemoveItem("disk", tmp);
591 nigel 1.4 D(NSLog(@"%s - Deleted prefs entry \"disk\", %d",
592     __PRETTY_FUNCTION__, tmp));
593 nigel 1.1 edited = YES;
594     break;
595     }
596     ++tmp;
597     }
598    
599     if ( str == NULL )
600     {
601 nigel 1.4 NSLog(@"%s - Couldn't find any disk preference to match %s",
602     __PRETTY_FUNCTION__, path);
603 nigel 1.1 return NULL;
604     }
605    
606     if ( ! [volsDS deleteRow: row] )
607     NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp);
608     [diskImages reloadData];
609 nigel 1.5 // return path;
610     return Path;
611 nigel 1.1 }
612     else
613     {
614 nigel 1.2 WarningSheet(@"Please select a volume first", panel);
615 nigel 1.1 return NULL;
616     }
617     }
618    
619     - (IBAction) RemoveVolume: (id)sender
620     {
621     [self RemoveVolumeEntry];
622     }
623    
624 nigel 1.10 - (void) loadPrefs: (int) argc
625     args: (char **) argv
626 nigel 1.1 {
627     [panel close]; // Temporarily hide preferences panel
628    
629     PrefsExit(); // Purge all the old pref values
630    
631     PrefsInit(argc, argv);
632     AddPrefsDefaults();
633     AddPlatformPrefsDefaults(); // and only create basic ones
634    
635     [SCSIds deleteAll]; // Clear out datasources for the tables
636     [volsDS deleteAll];
637    
638     [self ShowPrefs: self]; // Reset items in panel, and redisplay
639     edited = NO;
640     }
641    
642 nigel 1.10 - (IBAction) LoadPrefs: (id)sender
643     {
644     int argc = 2;
645     char *argv[2];
646    
647     argv[0] = "--prefs",
648     argv[1] = (char *) [[prefsFile stringValue] cString];
649    
650     [self loadPrefs: argc
651     args: argv];
652     }
653    
654     - (IBAction) ResetPrefs: (id)sender
655     {
656     [self loadPrefs: 0
657     args: NULL];
658     }
659    
660 nigel 1.1 - (void) setStringOf: (NSTextField *) field
661     fromPref: (const char *) prefName
662     {
663     const char *value = PrefsFindString(prefName, 0);
664    
665     if ( value )
666     [field setStringValue: [NSString stringWithCString: value] ];
667     }
668    
669     - (IBAction) SavePrefs: (id)sender
670     {
671     SavePrefs();
672     edited = NO;
673     }
674    
675     - (IBAction) ShowPrefs: (id)sender
676     {
677     NSTableColumn *locks;
678     const char *str;
679     int cpu, tmp;
680    
681    
682     // Set simple single field items
683    
684     tmp = PrefsFindInt32("frameskip");
685     [delay setIntValue: tmp];
686     if ( tmp )
687     [frequency setFloatValue: 60.0 / tmp];
688     else
689     [frequency setFloatValue: 60.0];
690    
691     tmp = PrefsFindInt32("ramsize");
692     [bytes setIntValue: tmp];
693     [MB setFloatValue: tmp / (1024.0 * 1024.0)];
694    
695     [disableCD setState: PrefsFindBool("nocdrom")];
696     [disableSound setState: PrefsFindBool("nosound")];
697     [FPU setState: PrefsFindBool("fpu") ];
698    
699     [self setStringOf: etherNet fromPref: "ether" ];
700     [self setStringOf: extFS fromPref: "extfs" ];
701     [self setStringOf: modem fromPref: "seriala"];
702     [self setStringOf: printer fromPref: "serialb"];
703     [self setStringOf: ROMfile fromPref: "rom" ];
704 nigel 1.10
705     [prefsFile setStringValue: [NSString stringWithCString: UserPrefsPath.c_str()] ];
706 nigel 1.1
707    
708     parse_screen_prefs(PrefsFindString("screen"));
709    
710     [width setIntValue: init_width];
711     [height setIntValue: init_height];
712     [depth setIntValue: init_depth];
713    
714 nigel 1.9 [screen setState: NO];
715 nigel 1.1 switch ( display_type )
716     {
717     case DISPLAY_WINDOW: [window setState: YES]; break;
718     case DISPLAY_SCREEN: [screen setState: YES]; break;
719     }
720    
721     [newVolumeSize setIntValue: 10];
722    
723     // Radio button groups:
724    
725     tmp = PrefsFindInt32("bootdriver");
726     [bootFromAny setState: tmp != CDROMRefNum];
727     [bootFromCD setState: tmp == CDROMRefNum];
728    
729     cpu = PrefsFindInt32("cpu");
730     tmp = PrefsFindInt32("modelid");
731    
732     #if REAL_ADDRESSING || DIRECT_ADDRESSING
733     puts("Current memory model does not support 24bit addressing");
734     if ( tmp == [classic tag] )
735     {
736     // Window already created by NIB file, just display
737     [panel makeKeyAndOrderFront:self];
738     WarningSheet(@"Compiled-in memory model does not support 24bit",
739 nigel 1.2 @"Disabling Mac Classic emulation", nil, panel);
740 nigel 1.1 cpu = [CPU68030 tag];
741     PrefsReplaceInt32("cpu", cpu);
742     tmp = [IIci tag];
743     PrefsReplaceInt32("modelid", tmp);
744     }
745    
746     puts("Disabling 68000 & Mac Classic buttons");
747     [CPU68000 setEnabled:FALSE];
748     [classic setEnabled:FALSE];
749     #endif
750    
751     [CPU68000 setState: [CPU68000 tag] == cpu];
752     [CPU68020 setState: [CPU68020 tag] == cpu];
753     [CPU68030 setState: [CPU68030 tag] == cpu];
754     [CPU68040 setState: [CPU68040 tag] == cpu];
755    
756     [classic setState: [classic tag] == tmp];
757     [IIci setState: [IIci tag] == tmp];
758     [quadra900 setState: [quadra900 tag] == tmp];
759    
760    
761     // Lists of thingies:
762    
763     for ( tmp = 0; tmp < 7; ++tmp)
764     {
765     char pref[6];
766    
767     pref[0] = '\0';
768    
769     sprintf (pref, "scsi%d", tmp);
770     if ( (str = PrefsFindString(pref, 0) ) )
771     [SCSIds addInt: tmp
772     withPath: [NSString stringWithCString: str] ];
773     }
774    
775     [SCSIdisks setDataSource: SCSIds];
776    
777     locks = [diskImages tableColumnWithIdentifier: @"locked"];
778     if ( locks == nil )
779     NSLog (@"%s - Can't find column for lock images", __PRETTY_FUNCTION__);
780     [locks setDataCell: lockCell];
781    
782     tmp = 0;
783     while ( (str = PrefsFindString("disk", tmp++) ) != NULL )
784     {
785     if ( *str == '*' )
786     [volsDS addObject: (NSObject *) locked
787     withPath: [NSString stringWithCString: str+1]];
788     else
789     [volsDS addObject: (NSObject *) blank
790     withPath: [NSString stringWithCString: str]];
791     }
792    
793     [diskImages setDataSource: volsDS];
794    
795    
796     [panel makeKeyAndOrderFront:self]; // Window already created by NIB file, just display
797     }
798    
799     @end