4 |
|
* |
5 |
|
* $Id$ |
6 |
|
* |
7 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
7 |
> |
* Basilisk II (C) 1997-2003 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 |
30 |
|
self = [super init]; |
31 |
|
|
32 |
|
numItems = 0; |
33 |
< |
col1 = [[NSMutableArray alloc] init]; |
34 |
< |
col2 = [[NSMutableArray alloc] init]; |
33 |
> |
col1 = [NSMutableArray new]; |
34 |
> |
col2 = [NSMutableArray new]; |
35 |
|
|
36 |
|
return self; |
37 |
|
} |
126 |
|
|
127 |
|
devs = @"/dev"; |
128 |
|
home = NSHomeDirectory(); |
129 |
< |
volsDS = [[TableDS alloc] init]; |
130 |
< |
SCSIds = [[TableDS alloc] init]; |
129 |
> |
volsDS = [TableDS new]; |
130 |
> |
SCSIds = [TableDS new]; |
131 |
|
|
132 |
< |
lockCell = [[NSImageCell alloc] init]; |
132 |
> |
lockCell = [NSImageCell new]; |
133 |
|
if ( lockCell == nil ) |
134 |
|
NSLog (@"%s - Can't create NSImageCell?", __PRETTY_FUNCTION__); |
135 |
|
|
136 |
< |
blank = [[NSImage alloc] init]; |
136 |
> |
blank = [NSImage new]; |
137 |
|
locked = [NSImage alloc]; |
138 |
|
if ( [locked initWithContentsOfFile: |
139 |
|
[[NSBundle mainBundle] |
260 |
|
|
261 |
|
- (IBAction) ChangeDisableSound: (NSButton *)sender |
262 |
|
{ |
263 |
< |
PrefsReplaceBool("nosound", [disableSound state]); |
263 |
> |
BOOL noSound = [disableSound state]; |
264 |
> |
|
265 |
> |
if ( ! noSound ) |
266 |
> |
WarningSheet(@"Sound is currently unimplemented", panel); |
267 |
> |
|
268 |
> |
PrefsReplaceBool("nosound", noSound); |
269 |
|
edited = YES; |
270 |
|
} |
271 |
|
|
281 |
|
edited = YES; |
282 |
|
} |
283 |
|
|
279 |
– |
// Screen/window changing stuff |
284 |
|
|
285 |
< |
// This is called when any of the screen/window, width, height or depth is changed |
285 |
> |
// If we are not using the CGIMAGEREF drawing strategy, |
286 |
> |
// then source bitmaps must be 32bits deep. |
287 |
> |
|
288 |
> |
- (short) testWinDepth: (int) newbpp |
289 |
> |
{ |
290 |
> |
#ifdef CGIMAGEREF |
291 |
> |
return newbpp; |
292 |
> |
#else |
293 |
> |
if ( newbpp != 32 ) |
294 |
> |
WarningSheet(@"Sorry - In windowed mode, depth must be 32", panel); |
295 |
> |
return 32 |
296 |
> |
#endif |
297 |
> |
} |
298 |
> |
|
299 |
> |
// This is called when any of the screen/openGL/window, |
300 |
> |
// width, height or depth is clicked. |
301 |
> |
// |
302 |
> |
// Note that sender may not actually be an NSMatrix. |
303 |
|
|
304 |
|
- (IBAction) ChangeScreen: (NSMatrix *)sender |
305 |
|
{ |
306 |
+ |
NSButton *cell = [sender selectedCell]; |
307 |
+ |
|
308 |
|
short newx = [width intValue]; |
309 |
|
short newy = [height intValue]; |
310 |
|
short newbpp = [depth intValue]; |
311 |
< |
short newtype = DISPLAY_WINDOW; |
311 |
> |
short newtype; |
312 |
|
char str[20]; |
313 |
|
|
314 |
< |
if ( [sender selectedCell] == openGL ) |
314 |
> |
if ( cell == openGL ) |
315 |
|
newtype = DISPLAY_OPENGL; |
316 |
< |
if ( [sender selectedCell] == screen ) |
316 |
> |
else if ( cell == screen ) |
317 |
|
newtype = DISPLAY_SCREEN; |
318 |
+ |
else if ( cell == window ) |
319 |
+ |
newtype = DISPLAY_WINDOW; |
320 |
+ |
else |
321 |
+ |
newtype = display_type; |
322 |
|
|
323 |
|
// Check that a field actually changed |
324 |
|
if ( newbpp == init_depth && newx == init_width && |
325 |
|
newy == init_height && newtype == display_type ) |
326 |
+ |
{ |
327 |
+ |
D(NSLog(@"No changed GUI items in ChangeScreen")); |
328 |
|
return; |
329 |
< |
|
329 |
> |
} |
330 |
|
|
331 |
|
// If we are changing type, supply some sensible defaults |
332 |
+ |
|
333 |
+ |
short screenx = CGDisplayPixelsWide(kCGDirectMainDisplay), |
334 |
+ |
screeny = CGDisplayPixelsHigh(kCGDirectMainDisplay), |
335 |
+ |
screenb = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
336 |
+ |
|
337 |
|
if ( newtype != display_type ) |
338 |
|
{ |
339 |
< |
if ( newtype == DISPLAY_SCREEN ) // If changing to full screen |
306 |
< |
{ |
307 |
< |
// supply main screen dimensions as a default |
308 |
< |
NSScreen *s = [NSScreen mainScreen]; |
309 |
< |
NSRect sr = [s frame]; |
310 |
< |
|
311 |
< |
newx = (short) sr.size.width; |
312 |
< |
newy = (short) sr.size.height; |
313 |
< |
// This always returns 24, despite the mode |
314 |
< |
//newbpp = NSBitsPerPixelFromDepth([s depth]); |
315 |
< |
newbpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
316 |
< |
} |
339 |
> |
D(NSLog(@"Changing display type in ChangeScreen")); |
340 |
|
|
341 |
< |
if ( display_type == DISPLAY_SCREEN ) // If changing from full screen |
341 |
> |
// If changing to full screen, supply main screen dimensions as a default |
342 |
> |
if ( newtype == DISPLAY_SCREEN ) |
343 |
> |
newx = screenx, newy = screeny, newbpp = screenb; |
344 |
> |
|
345 |
> |
// If changing from full screen, use minimum screen resolutions |
346 |
> |
if ( display_type == DISPLAY_SCREEN ) |
347 |
> |
{ |
348 |
|
newx = MIN_WIDTH, newy = MIN_HEIGHT; |
349 |
< |
|
350 |
< |
[width setIntValue: newx]; |
322 |
< |
[height setIntValue: newy]; |
323 |
< |
[depth setIntValue: newbpp]; |
349 |
> |
newbpp = [self testWinDepth: newbpp]; |
350 |
> |
} |
351 |
|
} |
352 |
|
else |
353 |
|
{ |
354 |
+ |
newbpp = [self testWinDepth: newbpp]; |
355 |
+ |
|
356 |
|
// Check size is within ranges of MIN_WIDTH ... MAX_WIDTH |
357 |
|
// and MIN_HEIGHT ... MAX_HEIGHT |
358 |
|
// ??? |
359 |
|
} |
360 |
|
|
361 |
+ |
[width setIntValue: newx]; |
362 |
+ |
[height setIntValue: newy]; |
363 |
+ |
[depth setIntValue: newbpp]; |
364 |
+ |
|
365 |
|
|
366 |
|
// Store new prefs |
367 |
|
*str = '\0'; |
393 |
|
edited = YES; |
394 |
|
|
395 |
|
if ( display_type != DISPLAY_SCREEN ) |
396 |
+ |
{ |
397 |
+ |
D(NSLog(@"Display type is not SCREEN (%d), resizing window", |
398 |
+ |
display_type)); |
399 |
|
resizeWinTo(newx, newy); |
400 |
+ |
} |
401 |
|
} |
402 |
|
|
403 |
|
- (IBAction) CreateVolume: (id)sender |
422 |
|
NSString *details = [NSString stringWithFormat: |
423 |
|
@"The dd command failed.\nReturn status %d (%s)", |
424 |
|
retVal, strerror(errno)]; |
425 |
< |
WarningSheet(@"Unable to create volume", details, @"OK", panel); |
425 |
> |
WarningSheet(@"Unable to create volume", details, nil, panel); |
426 |
|
} |
427 |
|
else |
428 |
|
{ |
434 |
|
} |
435 |
|
} |
436 |
|
|
437 |
+ |
- (BOOL) fileManager: (NSFileManager *) manager |
438 |
+ |
shouldProceedAfterError: (NSDictionary *) errorDict |
439 |
+ |
{ |
440 |
+ |
NSRunAlertPanel(@"File operation error", |
441 |
+ |
@"%@ %@, toPath %@", |
442 |
+ |
@"Bugger!", nil, nil, |
443 |
+ |
[errorDict objectForKey:@"Error"], |
444 |
+ |
[errorDict objectForKey:@"Path"], |
445 |
+ |
[errorDict objectForKey:@"ToPath"]); |
446 |
+ |
return NO; |
447 |
+ |
} |
448 |
+ |
|
449 |
|
- (IBAction) DeleteVolume: (id)sender |
450 |
|
{ |
451 |
< |
const char *path = [self RemoveVolumeEntry]; |
452 |
< |
if ( unlink(path) == -1 ) |
451 |
> |
// const char *path = [self RemoveVolumeEntry]; |
452 |
> |
// if ( unlink(path) == -1 ) |
453 |
> |
NSString *Path = [self RemoveVolumeEntry]; |
454 |
> |
|
455 |
> |
if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path |
456 |
> |
handler: self] ) |
457 |
|
{ |
458 |
< |
NSLog(@"%s unlink(%s) failed", __PRETTY_FUNCTION__, path, strerror(errno)); |
458 |
> |
WarningSheet(@"Unable to delete volume", panel); |
459 |
> |
// NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno)); |
460 |
|
} |
461 |
|
} |
462 |
|
|
481 |
|
int B = (int) [bytes floatValue]; |
482 |
|
float M = B / 1024 / 1024; |
483 |
|
|
484 |
< |
NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B); |
484 |
> |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
485 |
|
PrefsReplaceInt32("ramsize", B); |
486 |
|
[MB setFloatValue: M]; |
487 |
|
edited = YES; |
525 |
|
float M = [MB floatValue]; |
526 |
|
int B = (int) (M * 1024 * 1024); |
527 |
|
|
528 |
< |
NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B); |
528 |
> |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
529 |
|
PrefsReplaceInt32("ramsize", B); |
530 |
|
[bytes setIntValue: B]; |
531 |
|
edited = YES; |
539 |
|
edited = YES; |
540 |
|
} |
541 |
|
|
488 |
– |
- (IBAction) EditRAMsize: (NSTextField *)sender |
489 |
– |
{ |
490 |
– |
int B = [bytes intValue]; |
491 |
– |
float M = B / (1024.0 * 1024.0); |
492 |
– |
|
493 |
– |
NSLog(@"%s = %d %f", __PRETTY_FUNCTION__, B, M); |
494 |
– |
PrefsReplaceInt32("ramsize", B); |
495 |
– |
[MB setFloatValue: M]; |
496 |
– |
edited = YES; |
497 |
– |
} |
498 |
– |
|
542 |
|
- (IBAction) EditROMpath: (NSTextField *)sender |
543 |
|
{ |
544 |
|
NSString *path = [ROMfile stringValue]; |
559 |
|
PrefsRemoveItem(pref,0); |
560 |
|
} |
561 |
|
|
562 |
< |
- (const char *) RemoveVolumeEntry |
562 |
> |
//- (const char *) RemoveVolumeEntry |
563 |
> |
- (NSString *) RemoveVolumeEntry |
564 |
|
{ |
565 |
|
int row = [diskImages selectedRow]; |
566 |
|
|
567 |
|
if ( row != -1 ) |
568 |
|
{ |
569 |
< |
const char *path = [[volsDS pathAtRow: row] cString], |
569 |
> |
NSString *Path = [volsDS pathAtRow: row]; |
570 |
> |
const char *path = [Path cString], |
571 |
|
*str; |
572 |
|
int tmp = 0; |
573 |
|
|
576 |
|
if ( strcmp(str, path) == 0 ) |
577 |
|
{ |
578 |
|
PrefsRemoveItem("disk", tmp); |
579 |
< |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", __PRETTY_FUNCTION__, tmp)); |
579 |
> |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", |
580 |
> |
__PRETTY_FUNCTION__, tmp)); |
581 |
|
edited = YES; |
582 |
|
break; |
583 |
|
} |
586 |
|
|
587 |
|
if ( str == NULL ) |
588 |
|
{ |
589 |
< |
NSLog(@"%s - Couldn't find any disk preference to match %s", __PRETTY_FUNCTION__, path); |
589 |
> |
NSLog(@"%s - Couldn't find any disk preference to match %s", |
590 |
> |
__PRETTY_FUNCTION__, path); |
591 |
|
return NULL; |
592 |
|
} |
593 |
|
|
594 |
|
if ( ! [volsDS deleteRow: row] ) |
595 |
|
NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp); |
596 |
|
[diskImages reloadData]; |
597 |
< |
return path; |
597 |
> |
// return path; |
598 |
> |
return Path; |
599 |
|
} |
600 |
|
else |
601 |
|
{ |
602 |
< |
WarningSheet(@"Please select a volume first", @"", @"OK", panel); |
602 |
> |
WarningSheet(@"Please select a volume first", panel); |
603 |
|
return NULL; |
604 |
|
} |
605 |
|
} |
707 |
|
// Window already created by NIB file, just display |
708 |
|
[panel makeKeyAndOrderFront:self]; |
709 |
|
WarningSheet(@"Compiled-in memory model does not support 24bit", |
710 |
< |
@"Disabling Mac Classic emulation", @"OK", panel); |
710 |
> |
@"Disabling Mac Classic emulation", nil, panel); |
711 |
|
cpu = [CPU68030 tag]; |
712 |
|
PrefsReplaceInt32("cpu", cpu); |
713 |
|
tmp = [IIci tag]; |