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.5 |
* $Id: PrefsEditor.mm,v 1.4 2002/06/05 09:41:27 nigel Exp $ |
6 |
nigel |
1.1 |
* |
7 |
|
|
* Basilisk II (C) 1997-2001 Christian Bauer |
8 |
|
|
* |
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 |
|
|
#import "sysdeps.h" // Types used in Basilisk C++ code |
113 |
|
|
#import "video_macosx.h" // some items that we edit here |
114 |
|
|
#import "misc_macosx.h" // WarningSheet() prototype |
115 |
|
|
|
116 |
|
|
#import <prefs.h> |
117 |
|
|
|
118 |
nigel |
1.3 |
#define DEBUG 0 |
119 |
nigel |
1.1 |
#import <debug.h> |
120 |
|
|
|
121 |
|
|
- (PrefsEditor *) init |
122 |
|
|
{ |
123 |
|
|
self = [super init]; |
124 |
|
|
|
125 |
|
|
edited = NO; |
126 |
|
|
|
127 |
|
|
devs = @"/dev"; |
128 |
|
|
home = NSHomeDirectory(); |
129 |
nigel |
1.5 |
volsDS = [TableDS new]; |
130 |
|
|
SCSIds = [TableDS new]; |
131 |
nigel |
1.1 |
|
132 |
nigel |
1.5 |
lockCell = [NSImageCell new]; |
133 |
nigel |
1.1 |
if ( lockCell == nil ) |
134 |
|
|
NSLog (@"%s - Can't create NSImageCell?", __PRETTY_FUNCTION__); |
135 |
|
|
|
136 |
nigel |
1.5 |
blank = [NSImage new]; |
137 |
nigel |
1.1 |
locked = [NSImage alloc]; |
138 |
|
|
if ( [locked initWithContentsOfFile: |
139 |
|
|
[[NSBundle mainBundle] |
140 |
|
|
pathForImageResource: @"nowrite.icns"]] == nil ) |
141 |
|
|
NSLog(@"%s - Couldn't open write protection image", __PRETTY_FUNCTION__); |
142 |
|
|
|
143 |
|
|
return self; |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
- (void) dealloc |
147 |
|
|
{ |
148 |
|
|
[volsDS dealloc]; |
149 |
|
|
[SCSIds dealloc]; |
150 |
|
|
[lockCell dealloc]; |
151 |
|
|
[locked dealloc]; |
152 |
|
|
[blank dealloc]; |
153 |
|
|
[super dealloc]; |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
- (void) awakeFromNib |
157 |
|
|
{ |
158 |
|
|
emuFreq = [theEmulator speed]; |
159 |
|
|
#if DEBUG |
160 |
|
|
[self ShowPrefs: self]; // For testing |
161 |
|
|
#endif |
162 |
|
|
} |
163 |
|
|
|
164 |
|
|
- (BOOL) hasEdited |
165 |
|
|
{ |
166 |
|
|
return edited; |
167 |
|
|
} |
168 |
|
|
|
169 |
|
|
- (NSWindow *) window |
170 |
|
|
{ |
171 |
|
|
return panel; |
172 |
|
|
} |
173 |
|
|
|
174 |
|
|
- (IBAction) AddSCSI: (id)sender |
175 |
|
|
{ |
176 |
|
|
NSOpenPanel *oP = [NSOpenPanel openPanel]; |
177 |
|
|
|
178 |
|
|
if ( [oP runModalForDirectory:home file:nil types:nil] == NSOKButton ) |
179 |
|
|
{ |
180 |
|
|
[SCSIds addInt: -1 |
181 |
|
|
withPath: [oP filename] ]; |
182 |
|
|
[SCSIdisks reloadData]; |
183 |
|
|
edited = YES; |
184 |
|
|
} |
185 |
|
|
} |
186 |
|
|
|
187 |
|
|
- (IBAction) AddVolume: (id)sender |
188 |
|
|
{ |
189 |
|
|
NSOpenPanel *oP = [NSOpenPanel openPanel]; |
190 |
|
|
|
191 |
|
|
if ( [oP runModalForDirectory:home file:nil types:nil] == NSOKButton ) |
192 |
|
|
{ |
193 |
|
|
[volsDS addObject: (NSObject *) locked |
194 |
|
|
withPath: [oP filename] ]; |
195 |
|
|
PrefsAddString("disk", [[oP filename] cString]); |
196 |
|
|
[diskImages reloadData]; |
197 |
|
|
edited = YES; |
198 |
|
|
} |
199 |
|
|
} |
200 |
|
|
|
201 |
|
|
- (IBAction) BrowseExtFS: (id)sender |
202 |
|
|
{ |
203 |
|
|
NSOpenPanel *oP = [NSOpenPanel openPanel]; |
204 |
|
|
|
205 |
|
|
[oP setCanChooseDirectories: YES]; |
206 |
|
|
[oP setCanChooseFiles: NO]; |
207 |
|
|
[oP setPrompt: @"Select"]; |
208 |
|
|
[oP setTitle: @"Select a directory to mount"]; |
209 |
|
|
D(NSLog(@"%s - home = %@, [extFS stringValue] = %@", |
210 |
|
|
__PRETTY_FUNCTION__, home, [extFS stringValue])); |
211 |
|
|
if ( [oP runModalForDirectory: ([extFS stringValue] ? [extFS stringValue] : home) |
212 |
|
|
file:nil |
213 |
|
|
types:nil] == NSOKButton ) |
214 |
|
|
{ |
215 |
|
|
[extFS setStringValue: [oP directory] ]; |
216 |
|
|
PrefsReplaceString("extfs", [[oP directory] cString]); |
217 |
|
|
edited = YES; |
218 |
|
|
} |
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
- (IBAction) BrowseROM: (id)sender |
222 |
|
|
{ |
223 |
|
|
NSOpenPanel *oP = [NSOpenPanel openPanel]; |
224 |
|
|
|
225 |
|
|
[oP setCanChooseFiles: YES]; |
226 |
|
|
[oP setTitle: @"Open a ROM file"]; |
227 |
|
|
D(NSLog(@"%s - home = %@", __PRETTY_FUNCTION__, home)); |
228 |
|
|
if ( [oP runModalForDirectory: ([ROMfile stringValue] ? [ROMfile stringValue] : home) |
229 |
|
|
file:nil |
230 |
|
|
types:nil] == NSOKButton ) |
231 |
|
|
{ |
232 |
|
|
[ROMfile setStringValue: [oP filename] ]; |
233 |
|
|
PrefsReplaceString("rom", [[oP filename] cString]); |
234 |
|
|
edited = YES; |
235 |
|
|
} |
236 |
|
|
} |
237 |
|
|
|
238 |
|
|
#include <cdrom.h> // for CDROMRefNum |
239 |
|
|
|
240 |
|
|
- (IBAction) ChangeBootFrom: (NSMatrix *)sender |
241 |
|
|
{ |
242 |
|
|
if ( [sender selectedCell] == bootFromCD ) |
243 |
|
|
PrefsReplaceInt32("bootdriver", CDROMRefNum); |
244 |
|
|
else |
245 |
|
|
PrefsReplaceInt32("bootdriver", 0); |
246 |
|
|
edited = YES; |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
- (IBAction) ChangeCPU: (NSMatrix *)sender |
250 |
|
|
{ |
251 |
|
|
PrefsReplaceInt32("cpu", [[sender selectedCell] tag]); |
252 |
|
|
edited = YES; |
253 |
|
|
} |
254 |
|
|
|
255 |
|
|
- (IBAction) ChangeDisableCD: (NSButton *)sender |
256 |
|
|
{ |
257 |
|
|
PrefsReplaceBool("nocdrom", [disableCD state]); |
258 |
|
|
edited = YES; |
259 |
|
|
} |
260 |
|
|
|
261 |
|
|
- (IBAction) ChangeDisableSound: (NSButton *)sender |
262 |
|
|
{ |
263 |
nigel |
1.2 |
BOOL noSound = [disableSound state]; |
264 |
|
|
|
265 |
|
|
if ( ! noSound ) |
266 |
|
|
WarningSheet(@"Sound is currently unimplemented", panel); |
267 |
|
|
|
268 |
|
|
PrefsReplaceBool("nosound", noSound); |
269 |
nigel |
1.1 |
edited = YES; |
270 |
|
|
} |
271 |
|
|
|
272 |
|
|
- (IBAction) ChangeFPU: (NSButton *)sender |
273 |
|
|
{ |
274 |
|
|
PrefsReplaceBool("fpu", [FPU state]); |
275 |
|
|
edited = YES; |
276 |
|
|
} |
277 |
|
|
|
278 |
|
|
- (IBAction) ChangeModel: (NSMatrix *)sender |
279 |
|
|
{ |
280 |
|
|
PrefsReplaceInt32("modelid", [[sender selectedCell] tag]); |
281 |
|
|
edited = YES; |
282 |
|
|
} |
283 |
|
|
|
284 |
nigel |
1.3 |
// This is called when any of the screen/openGL/window, |
285 |
|
|
// width, height or depth is clicked. |
286 |
|
|
// |
287 |
|
|
// Note that sender may not actually be an NSMatrix. |
288 |
nigel |
1.1 |
|
289 |
nigel |
1.3 |
- (IBAction) ChangeScreen: (NSMatrix *)sender |
290 |
|
|
{ |
291 |
|
|
NSButton *cell = [sender selectedCell]; |
292 |
nigel |
1.1 |
|
293 |
|
|
short newx = [width intValue]; |
294 |
|
|
short newy = [height intValue]; |
295 |
|
|
short newbpp = [depth intValue]; |
296 |
nigel |
1.2 |
short newtype; |
297 |
nigel |
1.1 |
char str[20]; |
298 |
|
|
|
299 |
nigel |
1.3 |
if ( cell == openGL ) |
300 |
nigel |
1.1 |
newtype = DISPLAY_OPENGL; |
301 |
nigel |
1.3 |
else if ( cell == screen ) |
302 |
nigel |
1.1 |
newtype = DISPLAY_SCREEN; |
303 |
nigel |
1.3 |
else if ( cell == window ) |
304 |
nigel |
1.2 |
newtype = DISPLAY_WINDOW; |
305 |
|
|
else |
306 |
|
|
newtype = display_type; |
307 |
nigel |
1.1 |
|
308 |
|
|
// Check that a field actually changed |
309 |
|
|
if ( newbpp == init_depth && newx == init_width && |
310 |
|
|
newy == init_height && newtype == display_type ) |
311 |
nigel |
1.2 |
{ |
312 |
nigel |
1.4 |
D(NSLog(@"No changed GUI items in ChangeScreen")); |
313 |
nigel |
1.1 |
return; |
314 |
nigel |
1.2 |
} |
315 |
nigel |
1.1 |
|
316 |
|
|
// If we are changing type, supply some sensible defaults |
317 |
|
|
if ( newtype != display_type ) |
318 |
|
|
{ |
319 |
nigel |
1.4 |
D(NSLog(@"Changing display type in ChangeScreen")); |
320 |
nigel |
1.1 |
if ( newtype == DISPLAY_SCREEN ) // If changing to full screen |
321 |
|
|
{ |
322 |
|
|
// supply main screen dimensions as a default |
323 |
nigel |
1.3 |
newx = CGDisplayPixelsWide (kCGDirectMainDisplay); |
324 |
|
|
newy = CGDisplayPixelsHigh (kCGDirectMainDisplay); |
325 |
nigel |
1.1 |
newbpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
if ( display_type == DISPLAY_SCREEN ) // If changing from full screen |
329 |
|
|
newx = MIN_WIDTH, newy = MIN_HEIGHT; |
330 |
|
|
|
331 |
|
|
[width setIntValue: newx]; |
332 |
|
|
[height setIntValue: newy]; |
333 |
|
|
[depth setIntValue: newbpp]; |
334 |
|
|
} |
335 |
|
|
else |
336 |
|
|
{ |
337 |
|
|
// Check size is within ranges of MIN_WIDTH ... MAX_WIDTH |
338 |
|
|
// and MIN_HEIGHT ... MAX_HEIGHT |
339 |
|
|
// ??? |
340 |
|
|
} |
341 |
|
|
|
342 |
|
|
|
343 |
|
|
// Store new prefs |
344 |
|
|
*str = '\0'; |
345 |
|
|
switch ( newtype ) |
346 |
|
|
{ |
347 |
|
|
case DISPLAY_WINDOW: |
348 |
|
|
if ( newbpp ) |
349 |
|
|
sprintf(str, "win/%hd/%hd/%hd", newx, newy, newbpp); |
350 |
|
|
else |
351 |
|
|
sprintf(str, "win/%hd/%hd", newx, newy); |
352 |
|
|
break; |
353 |
|
|
case DISPLAY_OPENGL: |
354 |
|
|
if ( newbpp ) |
355 |
|
|
sprintf(str, "opengl/%hd/%hd/%hd", newx, newy, newbpp); |
356 |
|
|
else |
357 |
|
|
sprintf(str, "opengl/%hd/%hd", newx, newy); |
358 |
|
|
break; |
359 |
|
|
case DISPLAY_SCREEN: |
360 |
|
|
if ( newbpp ) |
361 |
|
|
sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp); |
362 |
|
|
else |
363 |
|
|
sprintf(str, "full/%hd/%hd", newx, newy); |
364 |
|
|
break; |
365 |
|
|
}; |
366 |
|
|
PrefsReplaceString("screen", str); |
367 |
|
|
|
368 |
|
|
parse_screen_prefs(str); |
369 |
|
|
|
370 |
|
|
edited = YES; |
371 |
|
|
|
372 |
|
|
if ( display_type != DISPLAY_SCREEN ) |
373 |
nigel |
1.2 |
{ |
374 |
nigel |
1.4 |
D(NSLog(@"Display type is not SCREEN (%d), resizing window", |
375 |
|
|
display_type)); |
376 |
nigel |
1.1 |
resizeWinTo(newx, newy); |
377 |
nigel |
1.2 |
} |
378 |
nigel |
1.1 |
} |
379 |
|
|
|
380 |
|
|
- (IBAction) CreateVolume: (id)sender |
381 |
|
|
{ |
382 |
|
|
NSSavePanel *sP = [NSSavePanel savePanel]; |
383 |
|
|
|
384 |
|
|
[sP setAccessoryView: newVolumeView]; |
385 |
|
|
[sP setPrompt: @"Create"]; |
386 |
|
|
[sP setTitle: @"Create new volume as"]; |
387 |
|
|
|
388 |
|
|
if ( [sP runModalForDirectory:NSHomeDirectory() file:@"basilisk-II.vol"] == NSOKButton ) |
389 |
|
|
{ |
390 |
|
|
char cmd[1024]; |
391 |
|
|
const char *filename = [[sP filename] cString]; |
392 |
|
|
int retVal, |
393 |
|
|
size = [newVolumeSize intValue]; |
394 |
|
|
|
395 |
|
|
sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", filename, size); |
396 |
|
|
retVal = system(cmd); |
397 |
|
|
if (retVal != 0) |
398 |
|
|
{ |
399 |
|
|
NSString *details = [NSString stringWithFormat: |
400 |
|
|
@"The dd command failed.\nReturn status %d (%s)", |
401 |
|
|
retVal, strerror(errno)]; |
402 |
nigel |
1.2 |
WarningSheet(@"Unable to create volume", details, nil, panel); |
403 |
nigel |
1.1 |
} |
404 |
|
|
else |
405 |
|
|
{ |
406 |
|
|
[volsDS addObject: (NSObject *) blank |
407 |
|
|
withPath: [sP filename] ]; |
408 |
|
|
PrefsAddString("disk", filename); |
409 |
|
|
[diskImages reloadData]; |
410 |
|
|
} |
411 |
|
|
} |
412 |
|
|
} |
413 |
|
|
|
414 |
nigel |
1.5 |
- (BOOL) fileManager: (NSFileManager *) manager |
415 |
|
|
shouldProceedAfterError: (NSDictionary *) errorDict |
416 |
|
|
{ |
417 |
|
|
NSRunAlertPanel(@"File operation error", |
418 |
|
|
@"%@ %@, toPath %@", |
419 |
|
|
@"Bugger!", nil, nil, |
420 |
|
|
[errorDict objectForKey:@"Error"], |
421 |
|
|
[errorDict objectForKey:@"Path"], |
422 |
|
|
[errorDict objectForKey:@"ToPath"]); |
423 |
|
|
return NO; |
424 |
|
|
} |
425 |
|
|
|
426 |
nigel |
1.1 |
- (IBAction) DeleteVolume: (id)sender |
427 |
|
|
{ |
428 |
nigel |
1.5 |
// const char *path = [self RemoveVolumeEntry]; |
429 |
|
|
// if ( unlink(path) == -1 ) |
430 |
|
|
NSString *Path = [self RemoveVolumeEntry]; |
431 |
|
|
|
432 |
|
|
if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path |
433 |
|
|
handler: self] ) |
434 |
nigel |
1.1 |
{ |
435 |
nigel |
1.5 |
WarningSheet(@"Unable to delete volume", panel); |
436 |
|
|
// NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno)); |
437 |
nigel |
1.1 |
} |
438 |
|
|
} |
439 |
|
|
|
440 |
|
|
- (IBAction) EditDelay: (NSTextField *)sender |
441 |
|
|
{ |
442 |
|
|
int ticks = [delay intValue]; |
443 |
|
|
float freq; |
444 |
|
|
|
445 |
|
|
if ( ticks ) |
446 |
|
|
freq = 60.0 / ticks; |
447 |
|
|
else |
448 |
|
|
freq = 60.0; |
449 |
|
|
|
450 |
|
|
[frequency setFloatValue: freq]; |
451 |
|
|
[emuFreq setFloatValue: freq]; |
452 |
|
|
PrefsReplaceInt32("frameskip", ticks); |
453 |
|
|
edited = YES; |
454 |
|
|
} |
455 |
|
|
|
456 |
|
|
- (IBAction) EditBytes: (NSTextField *)sender |
457 |
|
|
{ |
458 |
|
|
int B = (int) [bytes floatValue]; |
459 |
|
|
float M = B / 1024 / 1024; |
460 |
|
|
|
461 |
nigel |
1.2 |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
462 |
nigel |
1.1 |
PrefsReplaceInt32("ramsize", B); |
463 |
|
|
[MB setFloatValue: M]; |
464 |
|
|
edited = YES; |
465 |
|
|
} |
466 |
|
|
|
467 |
|
|
- (IBAction) EditEtherNetDevice: (NSTextField *)sender |
468 |
|
|
{ |
469 |
|
|
NSString *path = [etherNet stringValue]; |
470 |
|
|
|
471 |
|
|
PrefsReplaceString("ether", [path cString]); |
472 |
|
|
edited = YES; |
473 |
|
|
} |
474 |
|
|
|
475 |
|
|
- (IBAction) EditExtFS: (NSTextField *)sender |
476 |
|
|
{ |
477 |
|
|
NSString *path = [extFS stringValue]; |
478 |
|
|
|
479 |
|
|
PrefsReplaceString("extfs", [path cString]); |
480 |
|
|
edited = YES; |
481 |
|
|
} |
482 |
|
|
|
483 |
|
|
- (IBAction) EditFrequency: (NSTextField *)sender |
484 |
|
|
{ |
485 |
|
|
float freq = [frequency floatValue]; |
486 |
|
|
|
487 |
|
|
[delay setIntValue: frequencyToTickDelay(freq)]; |
488 |
|
|
[emuFreq setFloatValue: freq]; |
489 |
|
|
edited = YES; |
490 |
|
|
} |
491 |
|
|
|
492 |
|
|
- (IBAction) EditModemDevice: (NSTextField *)sender |
493 |
|
|
{ |
494 |
|
|
NSString *path = [modem stringValue]; |
495 |
|
|
|
496 |
|
|
PrefsReplaceString("seriala", [path cString]); |
497 |
|
|
edited = YES; |
498 |
|
|
} |
499 |
|
|
|
500 |
|
|
- (IBAction) EditMB: (NSTextField *)sender |
501 |
|
|
{ |
502 |
|
|
float M = [MB floatValue]; |
503 |
|
|
int B = (int) (M * 1024 * 1024); |
504 |
|
|
|
505 |
nigel |
1.2 |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
506 |
nigel |
1.1 |
PrefsReplaceInt32("ramsize", B); |
507 |
|
|
[bytes setIntValue: B]; |
508 |
|
|
edited = YES; |
509 |
|
|
} |
510 |
|
|
|
511 |
|
|
- (IBAction) EditPrinterDevice: (NSTextField *)sender |
512 |
|
|
{ |
513 |
|
|
NSString *path = [printer stringValue]; |
514 |
|
|
|
515 |
|
|
PrefsReplaceString("serialb", [path cString]); |
516 |
|
|
edited = YES; |
517 |
|
|
} |
518 |
|
|
|
519 |
|
|
- (IBAction) EditROMpath: (NSTextField *)sender |
520 |
|
|
{ |
521 |
|
|
NSString *path = [ROMfile stringValue]; |
522 |
|
|
|
523 |
|
|
PrefsReplaceString("rom", [path cString]); |
524 |
|
|
} |
525 |
|
|
|
526 |
|
|
- (IBAction) RemoveSCSI: (id)sender |
527 |
|
|
{ |
528 |
|
|
char pref[6]; |
529 |
|
|
int row = [SCSIdisks selectedRow], |
530 |
|
|
SCSIid = [SCSIds intAtRow: row]; |
531 |
|
|
|
532 |
|
|
if ( ! [SCSIds deleteRow: row] ) |
533 |
|
|
NSLog (@"%s - [SCSIds deleteRow: %d] failed", __PRETTY_FUNCTION__, row); |
534 |
|
|
[SCSIdisks reloadData]; |
535 |
|
|
sprintf(pref, "scsi%d", SCSIid); |
536 |
|
|
PrefsRemoveItem(pref,0); |
537 |
|
|
} |
538 |
|
|
|
539 |
nigel |
1.5 |
//- (const char *) RemoveVolumeEntry |
540 |
|
|
- (NSString *) RemoveVolumeEntry |
541 |
nigel |
1.1 |
{ |
542 |
|
|
int row = [diskImages selectedRow]; |
543 |
|
|
|
544 |
|
|
if ( row != -1 ) |
545 |
|
|
{ |
546 |
nigel |
1.5 |
NSString *Path = [volsDS pathAtRow: row]; |
547 |
|
|
const char *path = [Path cString], |
548 |
nigel |
1.1 |
*str; |
549 |
|
|
int tmp = 0; |
550 |
|
|
|
551 |
|
|
while ( (str = PrefsFindString("disk", tmp) ) != NULL ) |
552 |
|
|
{ |
553 |
|
|
if ( strcmp(str, path) == 0 ) |
554 |
|
|
{ |
555 |
|
|
PrefsRemoveItem("disk", tmp); |
556 |
nigel |
1.4 |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", |
557 |
|
|
__PRETTY_FUNCTION__, tmp)); |
558 |
nigel |
1.1 |
edited = YES; |
559 |
|
|
break; |
560 |
|
|
} |
561 |
|
|
++tmp; |
562 |
|
|
} |
563 |
|
|
|
564 |
|
|
if ( str == NULL ) |
565 |
|
|
{ |
566 |
nigel |
1.4 |
NSLog(@"%s - Couldn't find any disk preference to match %s", |
567 |
|
|
__PRETTY_FUNCTION__, path); |
568 |
nigel |
1.1 |
return NULL; |
569 |
|
|
} |
570 |
|
|
|
571 |
|
|
if ( ! [volsDS deleteRow: row] ) |
572 |
|
|
NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp); |
573 |
|
|
[diskImages reloadData]; |
574 |
nigel |
1.5 |
// return path; |
575 |
|
|
return Path; |
576 |
nigel |
1.1 |
} |
577 |
|
|
else |
578 |
|
|
{ |
579 |
nigel |
1.2 |
WarningSheet(@"Please select a volume first", panel); |
580 |
nigel |
1.1 |
return NULL; |
581 |
|
|
} |
582 |
|
|
} |
583 |
|
|
|
584 |
|
|
- (IBAction) RemoveVolume: (id)sender |
585 |
|
|
{ |
586 |
|
|
[self RemoveVolumeEntry]; |
587 |
|
|
} |
588 |
|
|
|
589 |
|
|
- (IBAction) ResetPrefs: (id)sender |
590 |
|
|
{ |
591 |
|
|
int argc = 0; |
592 |
|
|
char **argv = NULL; |
593 |
|
|
|
594 |
|
|
[panel close]; // Temporarily hide preferences panel |
595 |
|
|
|
596 |
|
|
PrefsExit(); // Purge all the old pref values |
597 |
|
|
|
598 |
|
|
PrefsInit(argc, argv); |
599 |
|
|
AddPrefsDefaults(); |
600 |
|
|
AddPlatformPrefsDefaults(); // and only create basic ones |
601 |
|
|
|
602 |
|
|
[SCSIds deleteAll]; // Clear out datasources for the tables |
603 |
|
|
[volsDS deleteAll]; |
604 |
|
|
|
605 |
|
|
[self ShowPrefs: self]; // Reset items in panel, and redisplay |
606 |
|
|
edited = NO; |
607 |
|
|
} |
608 |
|
|
|
609 |
|
|
- (void) setStringOf: (NSTextField *) field |
610 |
|
|
fromPref: (const char *) prefName |
611 |
|
|
{ |
612 |
|
|
const char *value = PrefsFindString(prefName, 0); |
613 |
|
|
|
614 |
|
|
if ( value ) |
615 |
|
|
[field setStringValue: [NSString stringWithCString: value] ]; |
616 |
|
|
} |
617 |
|
|
|
618 |
|
|
- (IBAction) SavePrefs: (id)sender |
619 |
|
|
{ |
620 |
|
|
SavePrefs(); |
621 |
|
|
edited = NO; |
622 |
|
|
} |
623 |
|
|
|
624 |
|
|
- (IBAction) ShowPrefs: (id)sender |
625 |
|
|
{ |
626 |
|
|
NSTableColumn *locks; |
627 |
|
|
const char *str; |
628 |
|
|
int cpu, tmp; |
629 |
|
|
|
630 |
|
|
|
631 |
|
|
// Set simple single field items |
632 |
|
|
|
633 |
|
|
tmp = PrefsFindInt32("frameskip"); |
634 |
|
|
[delay setIntValue: tmp]; |
635 |
|
|
if ( tmp ) |
636 |
|
|
[frequency setFloatValue: 60.0 / tmp]; |
637 |
|
|
else |
638 |
|
|
[frequency setFloatValue: 60.0]; |
639 |
|
|
|
640 |
|
|
tmp = PrefsFindInt32("ramsize"); |
641 |
|
|
[bytes setIntValue: tmp]; |
642 |
|
|
[MB setFloatValue: tmp / (1024.0 * 1024.0)]; |
643 |
|
|
|
644 |
|
|
[disableCD setState: PrefsFindBool("nocdrom")]; |
645 |
|
|
[disableSound setState: PrefsFindBool("nosound")]; |
646 |
|
|
[FPU setState: PrefsFindBool("fpu") ]; |
647 |
|
|
|
648 |
|
|
[self setStringOf: etherNet fromPref: "ether" ]; |
649 |
|
|
[self setStringOf: extFS fromPref: "extfs" ]; |
650 |
|
|
[self setStringOf: modem fromPref: "seriala"]; |
651 |
|
|
[self setStringOf: printer fromPref: "serialb"]; |
652 |
|
|
[self setStringOf: ROMfile fromPref: "rom" ]; |
653 |
|
|
|
654 |
|
|
|
655 |
|
|
parse_screen_prefs(PrefsFindString("screen")); |
656 |
|
|
|
657 |
|
|
[width setIntValue: init_width]; |
658 |
|
|
[height setIntValue: init_height]; |
659 |
|
|
[depth setIntValue: init_depth]; |
660 |
|
|
|
661 |
|
|
[window setState: NO]; |
662 |
|
|
switch ( display_type ) |
663 |
|
|
{ |
664 |
|
|
case DISPLAY_WINDOW: [window setState: YES]; break; |
665 |
|
|
case DISPLAY_OPENGL: [openGL setState: YES]; break; |
666 |
|
|
case DISPLAY_SCREEN: [screen setState: YES]; break; |
667 |
|
|
} |
668 |
|
|
|
669 |
|
|
[newVolumeSize setIntValue: 10]; |
670 |
|
|
|
671 |
|
|
// Radio button groups: |
672 |
|
|
|
673 |
|
|
tmp = PrefsFindInt32("bootdriver"); |
674 |
|
|
[bootFromAny setState: tmp != CDROMRefNum]; |
675 |
|
|
[bootFromCD setState: tmp == CDROMRefNum]; |
676 |
|
|
|
677 |
|
|
cpu = PrefsFindInt32("cpu"); |
678 |
|
|
tmp = PrefsFindInt32("modelid"); |
679 |
|
|
|
680 |
|
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
681 |
|
|
puts("Current memory model does not support 24bit addressing"); |
682 |
|
|
if ( tmp == [classic tag] ) |
683 |
|
|
{ |
684 |
|
|
// Window already created by NIB file, just display |
685 |
|
|
[panel makeKeyAndOrderFront:self]; |
686 |
|
|
WarningSheet(@"Compiled-in memory model does not support 24bit", |
687 |
nigel |
1.2 |
@"Disabling Mac Classic emulation", nil, panel); |
688 |
nigel |
1.1 |
cpu = [CPU68030 tag]; |
689 |
|
|
PrefsReplaceInt32("cpu", cpu); |
690 |
|
|
tmp = [IIci tag]; |
691 |
|
|
PrefsReplaceInt32("modelid", tmp); |
692 |
|
|
} |
693 |
|
|
|
694 |
|
|
puts("Disabling 68000 & Mac Classic buttons"); |
695 |
|
|
[CPU68000 setEnabled:FALSE]; |
696 |
|
|
[classic setEnabled:FALSE]; |
697 |
|
|
#endif |
698 |
|
|
|
699 |
|
|
[CPU68000 setState: [CPU68000 tag] == cpu]; |
700 |
|
|
[CPU68020 setState: [CPU68020 tag] == cpu]; |
701 |
|
|
[CPU68030 setState: [CPU68030 tag] == cpu]; |
702 |
|
|
[CPU68040 setState: [CPU68040 tag] == cpu]; |
703 |
|
|
|
704 |
|
|
[classic setState: [classic tag] == tmp]; |
705 |
|
|
[IIci setState: [IIci tag] == tmp]; |
706 |
|
|
[quadra900 setState: [quadra900 tag] == tmp]; |
707 |
|
|
|
708 |
|
|
|
709 |
|
|
// Lists of thingies: |
710 |
|
|
|
711 |
|
|
for ( tmp = 0; tmp < 7; ++tmp) |
712 |
|
|
{ |
713 |
|
|
char pref[6]; |
714 |
|
|
|
715 |
|
|
pref[0] = '\0'; |
716 |
|
|
|
717 |
|
|
sprintf (pref, "scsi%d", tmp); |
718 |
|
|
if ( (str = PrefsFindString(pref, 0) ) ) |
719 |
|
|
[SCSIds addInt: tmp |
720 |
|
|
withPath: [NSString stringWithCString: str] ]; |
721 |
|
|
} |
722 |
|
|
|
723 |
|
|
[SCSIdisks setDataSource: SCSIds]; |
724 |
|
|
|
725 |
|
|
locks = [diskImages tableColumnWithIdentifier: @"locked"]; |
726 |
|
|
if ( locks == nil ) |
727 |
|
|
NSLog (@"%s - Can't find column for lock images", __PRETTY_FUNCTION__); |
728 |
|
|
[locks setDataCell: lockCell]; |
729 |
|
|
|
730 |
|
|
tmp = 0; |
731 |
|
|
while ( (str = PrefsFindString("disk", tmp++) ) != NULL ) |
732 |
|
|
{ |
733 |
|
|
if ( *str == '*' ) |
734 |
|
|
[volsDS addObject: (NSObject *) locked |
735 |
|
|
withPath: [NSString stringWithCString: str+1]]; |
736 |
|
|
else |
737 |
|
|
[volsDS addObject: (NSObject *) blank |
738 |
|
|
withPath: [NSString stringWithCString: str]]; |
739 |
|
|
} |
740 |
|
|
|
741 |
|
|
[diskImages setDataSource: volsDS]; |
742 |
|
|
|
743 |
|
|
|
744 |
|
|
[panel makeKeyAndOrderFront:self]; // Window already created by NIB file, just display |
745 |
|
|
} |
746 |
|
|
|
747 |
|
|
@end |