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 the screen/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 ) |
292 |
< |
newtype = DISPLAY_OPENGL; |
293 |
< |
if ( [sender selectedCell] == screen ) |
314 |
> |
if ( cell == screen ) |
315 |
|
newtype = DISPLAY_SCREEN; |
316 |
+ |
else if ( cell == window ) |
317 |
+ |
newtype = DISPLAY_WINDOW; |
318 |
+ |
else |
319 |
+ |
newtype = display_type; |
320 |
|
|
321 |
|
// Check that a field actually changed |
322 |
|
if ( newbpp == init_depth && newx == init_width && |
323 |
|
newy == init_height && newtype == display_type ) |
324 |
+ |
{ |
325 |
+ |
D(NSLog(@"No changed GUI items in ChangeScreen")); |
326 |
|
return; |
327 |
< |
|
327 |
> |
} |
328 |
|
|
329 |
|
// If we are changing type, supply some sensible defaults |
330 |
+ |
|
331 |
+ |
short screenx = CGDisplayPixelsWide(kCGDirectMainDisplay), |
332 |
+ |
screeny = CGDisplayPixelsHigh(kCGDirectMainDisplay), |
333 |
+ |
screenb = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
334 |
+ |
|
335 |
|
if ( newtype != display_type ) |
336 |
|
{ |
337 |
< |
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 |
< |
} |
337 |
> |
D(NSLog(@"Changing display type in ChangeScreen")); |
338 |
|
|
339 |
< |
if ( display_type == DISPLAY_SCREEN ) // If changing from full screen |
339 |
> |
// If changing to full screen, supply main screen dimensions as a default |
340 |
> |
if ( newtype == DISPLAY_SCREEN ) |
341 |
> |
newx = screenx, newy = screeny, newbpp = screenb; |
342 |
> |
|
343 |
> |
// If changing from full screen, use minimum screen resolutions |
344 |
> |
if ( display_type == DISPLAY_SCREEN ) |
345 |
> |
{ |
346 |
|
newx = MIN_WIDTH, newy = MIN_HEIGHT; |
347 |
< |
|
348 |
< |
[width setIntValue: newx]; |
322 |
< |
[height setIntValue: newy]; |
323 |
< |
[depth setIntValue: newbpp]; |
347 |
> |
newbpp = [self testWinDepth: newbpp]; |
348 |
> |
} |
349 |
|
} |
350 |
|
else |
351 |
|
{ |
352 |
+ |
newbpp = [self testWinDepth: newbpp]; |
353 |
+ |
|
354 |
|
// Check size is within ranges of MIN_WIDTH ... MAX_WIDTH |
355 |
|
// and MIN_HEIGHT ... MAX_HEIGHT |
356 |
|
// ??? |
357 |
|
} |
358 |
|
|
359 |
+ |
[width setIntValue: newx]; |
360 |
+ |
[height setIntValue: newy]; |
361 |
+ |
[depth setIntValue: newbpp]; |
362 |
+ |
|
363 |
|
|
364 |
|
// Store new prefs |
365 |
|
*str = '\0'; |
371 |
|
else |
372 |
|
sprintf(str, "win/%hd/%hd", newx, newy); |
373 |
|
break; |
343 |
– |
case DISPLAY_OPENGL: |
344 |
– |
if ( newbpp ) |
345 |
– |
sprintf(str, "opengl/%hd/%hd/%hd", newx, newy, newbpp); |
346 |
– |
else |
347 |
– |
sprintf(str, "opengl/%hd/%hd", newx, newy); |
348 |
– |
break; |
374 |
|
case DISPLAY_SCREEN: |
375 |
|
if ( newbpp ) |
376 |
|
sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp); |
385 |
|
edited = YES; |
386 |
|
|
387 |
|
if ( display_type != DISPLAY_SCREEN ) |
388 |
+ |
{ |
389 |
+ |
D(NSLog(@"Display type is not SCREEN (%d), resizing window", |
390 |
+ |
display_type)); |
391 |
|
resizeWinTo(newx, newy); |
392 |
+ |
} |
393 |
|
} |
394 |
|
|
395 |
|
- (IBAction) CreateVolume: (id)sender |
414 |
|
NSString *details = [NSString stringWithFormat: |
415 |
|
@"The dd command failed.\nReturn status %d (%s)", |
416 |
|
retVal, strerror(errno)]; |
417 |
< |
WarningSheet(@"Unable to create volume", details, @"OK", panel); |
417 |
> |
WarningSheet(@"Unable to create volume", details, nil, panel); |
418 |
|
} |
419 |
|
else |
420 |
|
{ |
426 |
|
} |
427 |
|
} |
428 |
|
|
429 |
+ |
- (BOOL) fileManager: (NSFileManager *) manager |
430 |
+ |
shouldProceedAfterError: (NSDictionary *) errorDict |
431 |
+ |
{ |
432 |
+ |
NSRunAlertPanel(@"File operation error", |
433 |
+ |
@"%@ %@, toPath %@", |
434 |
+ |
@"Bugger!", nil, nil, |
435 |
+ |
[errorDict objectForKey:@"Error"], |
436 |
+ |
[errorDict objectForKey:@"Path"], |
437 |
+ |
[errorDict objectForKey:@"ToPath"]); |
438 |
+ |
return NO; |
439 |
+ |
} |
440 |
+ |
|
441 |
|
- (IBAction) DeleteVolume: (id)sender |
442 |
|
{ |
443 |
< |
const char *path = [self RemoveVolumeEntry]; |
444 |
< |
if ( unlink(path) == -1 ) |
443 |
> |
// const char *path = [self RemoveVolumeEntry]; |
444 |
> |
// if ( unlink(path) == -1 ) |
445 |
> |
NSString *Path = [self RemoveVolumeEntry]; |
446 |
> |
|
447 |
> |
if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path |
448 |
> |
handler: self] ) |
449 |
|
{ |
450 |
< |
NSLog(@"%s unlink(%s) failed", __PRETTY_FUNCTION__, path, strerror(errno)); |
450 |
> |
WarningSheet(@"Unable to delete volume", panel); |
451 |
> |
// NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno)); |
452 |
|
} |
453 |
|
} |
454 |
|
|
473 |
|
int B = (int) [bytes floatValue]; |
474 |
|
float M = B / 1024 / 1024; |
475 |
|
|
476 |
< |
NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B); |
476 |
> |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
477 |
|
PrefsReplaceInt32("ramsize", B); |
478 |
|
[MB setFloatValue: M]; |
479 |
|
edited = YES; |
517 |
|
float M = [MB floatValue]; |
518 |
|
int B = (int) (M * 1024 * 1024); |
519 |
|
|
520 |
< |
NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B); |
520 |
> |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
521 |
|
PrefsReplaceInt32("ramsize", B); |
522 |
|
[bytes setIntValue: B]; |
523 |
|
edited = YES; |
531 |
|
edited = YES; |
532 |
|
} |
533 |
|
|
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 |
– |
|
534 |
|
- (IBAction) EditROMpath: (NSTextField *)sender |
535 |
|
{ |
536 |
|
NSString *path = [ROMfile stringValue]; |
551 |
|
PrefsRemoveItem(pref,0); |
552 |
|
} |
553 |
|
|
554 |
< |
- (const char *) RemoveVolumeEntry |
554 |
> |
//- (const char *) RemoveVolumeEntry |
555 |
> |
- (NSString *) RemoveVolumeEntry |
556 |
|
{ |
557 |
|
int row = [diskImages selectedRow]; |
558 |
|
|
559 |
|
if ( row != -1 ) |
560 |
|
{ |
561 |
< |
const char *path = [[volsDS pathAtRow: row] cString], |
561 |
> |
NSString *Path = [volsDS pathAtRow: row]; |
562 |
> |
const char *path = [Path cString], |
563 |
|
*str; |
564 |
|
int tmp = 0; |
565 |
|
|
568 |
|
if ( strcmp(str, path) == 0 ) |
569 |
|
{ |
570 |
|
PrefsRemoveItem("disk", tmp); |
571 |
< |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", __PRETTY_FUNCTION__, tmp)); |
571 |
> |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", |
572 |
> |
__PRETTY_FUNCTION__, tmp)); |
573 |
|
edited = YES; |
574 |
|
break; |
575 |
|
} |
578 |
|
|
579 |
|
if ( str == NULL ) |
580 |
|
{ |
581 |
< |
NSLog(@"%s - Couldn't find any disk preference to match %s", __PRETTY_FUNCTION__, path); |
581 |
> |
NSLog(@"%s - Couldn't find any disk preference to match %s", |
582 |
> |
__PRETTY_FUNCTION__, path); |
583 |
|
return NULL; |
584 |
|
} |
585 |
|
|
586 |
|
if ( ! [volsDS deleteRow: row] ) |
587 |
|
NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp); |
588 |
|
[diskImages reloadData]; |
589 |
< |
return path; |
589 |
> |
// return path; |
590 |
> |
return Path; |
591 |
|
} |
592 |
|
else |
593 |
|
{ |
594 |
< |
WarningSheet(@"Please select a volume first", @"", @"OK", panel); |
594 |
> |
WarningSheet(@"Please select a volume first", panel); |
595 |
|
return NULL; |
596 |
|
} |
597 |
|
} |
677 |
|
switch ( display_type ) |
678 |
|
{ |
679 |
|
case DISPLAY_WINDOW: [window setState: YES]; break; |
640 |
– |
case DISPLAY_OPENGL: [openGL setState: YES]; break; |
680 |
|
case DISPLAY_SCREEN: [screen setState: YES]; break; |
681 |
|
} |
682 |
|
|
698 |
|
// Window already created by NIB file, just display |
699 |
|
[panel makeKeyAndOrderFront:self]; |
700 |
|
WarningSheet(@"Compiled-in memory model does not support 24bit", |
701 |
< |
@"Disabling Mac Classic emulation", @"OK", panel); |
701 |
> |
@"Disabling Mac Classic emulation", nil, panel); |
702 |
|
cpu = [CPU68030 tag]; |
703 |
|
PrefsReplaceInt32("cpu", cpu); |
704 |
|
tmp = [IIci tag]; |