--- BasiliskII/src/MacOSX/Emulator.mm 2002/12/18 11:50:12 1.4 +++ BasiliskII/src/MacOSX/Emulator.mm 2004/01/12 15:29:24 1.8 @@ -2,9 +2,9 @@ * Emulator.mm - Class whose actions are attached to GUI widgets in a window, * used to control a single Basilisk II emulated Macintosh. * - * $Id: Emulator.mm,v 1.4 2002/12/18 11:50:12 nigel Exp $ + * $Id: Emulator.mm,v 1.8 2004/01/12 15:29:24 cebix Exp $ * - * Basilisk II (C) 1997-2002 Christian Bauer + * Basilisk II (C) 1997-2004 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,11 +94,8 @@ //[win setHasShadow: NO]; // This causes view & window to now be drawn correctly [win useOptimizedDrawing: YES]; -// [win center]; [win makeKeyAndOrderFront:self]; -// [self resizeWinToWidth:x Height:y]; - if ( redrawDelay ) [speed setFloatValue: 1.0 / redrawDelay]; else @@ -147,6 +144,30 @@ [self Resume: self]; } +#ifdef NIGEL +- (IBAction) EjectCD: (id)sender; +{ + NSString *path; + const char *cdrom = PrefsFindString("cdrom"); + + if ( cdrom ) + { + #include + #define KERNEL + #include + + struct statfs buf; + if ( fsstat(path, &buf) < 0 ) + return; + + path = [NSString stringWithCString: cdrom]; + + [[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: path]; +// [path release]; + } +} +#endif + - (IBAction) Interrupt: (id)sender; { WarningSheet (@"Interrupt action not yet supported", win); @@ -169,27 +190,45 @@ - (IBAction) Restart: (id)sender { + if ( ! running ) + { + running = YES; // Start emulator + [self runUpdate]; + [self Resume: nil]; + } + if ( running ) -// reset680x0(); +#ifdef UAE_CPU_HAS_RESET + reset680x0(); +#else { uaeCreated = NO; [redraw suspend]; NSLog (@"%s - uae_cpu reset not yet supported, will try to fake it", __PRETTY_FUNCTION__); -// [screen blacken]; - [screen setNeedsDisplay: YES]; + [screen clear]; + [screen display]; [emul terminate]; QuitEmuNoExit(); + + // OK. We have killed & cleaned up. Now, start afresh: + #include + int argc = 0; + char **argv; + + PrefsInit(argc, argv); + SysInit(); + emul = [NNThread new]; [emul perform:@selector(emulThread) of:self]; [emul start]; if ( display_type != DISPLAY_SCREEN ) [redraw resume]; - uaeCreated = YES; } +#endif } - (IBAction) Resume: (id)sender @@ -351,20 +390,18 @@ uint8 lastXPRAM[XPRAM_SIZE]; // Copy of [redraw invalidate]; [redraw release]; redraw = nil; [RTC invalidate]; [RTC release]; RTC = nil; [xPRAM invalidate]; [xPRAM release]; xPRAM = nil; - if ( uaeCreated ) - QuitEmuNoExit(); } - (void) emulThread { - extern uint8 *RAMBaseHost, *ROMBaseHost; NSAutoreleasePool *pool = [NSAutoreleasePool new]; - InitEmulator(); + if ( ! InitEmulator() ) + { + [redraw suspend]; // Stop the barberpole - if ( RAMBaseHost == NULL || ROMBaseHost == NULL ) - ErrorSheet(@"Cannot start Emulator", - @"Emulator memory not allocated", nil, win); + ErrorSheet(@"Cannot start Emulator", @"", @"Quit", win); + } else { memcpy(lastXPRAM, XPRAM, XPRAM_SIZE); @@ -374,19 +411,15 @@ uint8 lastXPRAM[XPRAM_SIZE]; // Copy of while ( screen == nil ) // If we are still loading from Nib? [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 1.0]]; -// [screen readyToDraw]; - [self runUpdate]; + [self runUpdate]; // Set the window close gadget to dimpled Start680x0(); // Start 68k and jump to ROM boot routine puts ("Emulator exited normally"); } - running = NO; - uaeCreated = NO; - [self runUpdate]; // Update button & dimple [pool release]; - [self exitThreads]; + QuitEmulator(); } - (void) RTCinterrupt @@ -399,13 +432,13 @@ uint8 lastXPRAM[XPRAM_SIZE]; // Copy of { if ( display_type == DISPLAY_SCREEN ) { - NSLog(@"Why was redrawScreen() called?"); + NSLog(@"We are in fullscreen mode - why was redrawScreen() called?"); return; } [barberPole animate:self]; // wobble the pole [screen setNeedsDisplay: YES]; // redisplay next time through runLoop // Or, use a direct method. e.g. - // [screen cgDrawInto: ...]; + // [screen display] or [screen cgDrawInto: ...]; } #include // For #define INTFLAG_60HZ