--- BasiliskII/src/MacOSX/Emulator.mm 2002/05/30 12:36:17 1.3 +++ BasiliskII/src/MacOSX/Emulator.mm 2003/03/26 01:45:31 1.5 @@ -2,7 +2,7 @@ * 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.3 2002/05/30 12:36:17 nigel Exp $ + * $Id: Emulator.mm,v 1.5 2003/03/26 01:45:31 nigel Exp $ * * Basilisk II (C) 1997-2002 Christian Bauer * @@ -37,10 +37,10 @@ #import #import -#undef check() // memory.h defines a check macro, which clashes with an OS X one? +#undef check() // memory.h defines a check macro, clashes with an OS X one? #import -#define DEBUG 1 +#define DEBUG 0 #import // NSWindow method, which is invoked via delegation @@ -120,8 +120,6 @@ - (NSSlider *) speed { return speed; } - (NSWindow *) window { return win; } -//#define DEBUG 1 -//#include // Update some UI elements @@ -184,7 +182,7 @@ [emul terminate]; QuitEmuNoExit(); - emul = [[NNThread alloc] init]; + emul = [NNThread new]; [emul perform:@selector(emulThread) of:self]; [emul start]; @@ -314,11 +312,11 @@ uint8 lastXPRAM[XPRAM_SIZE]; // Copy of [NSThread detachNewThreadSelector:(SEL)"" toTarget:nil withObject:nil]; //emul = [[NNThread alloc] initWithAutoReleasePool]; #endif - emul = [[NNThread alloc] init]; - RTC = [[NNTimer alloc] init]; - redraw = [[NNTimer alloc] init]; - tick = [[NNTimer alloc] init]; - xPRAM = [[NNTimer alloc] init]; + emul = [NNThread new]; + RTC = [NNTimer new]; + redraw = [NNTimer new]; + tick = [NNTimer new]; + xPRAM = [NNTimer new]; [emul perform:@selector(emulThread) of:self]; [RTC repeat:@selector(RTCinterrupt) of:self @@ -359,14 +357,14 @@ uint8 lastXPRAM[XPRAM_SIZE]; // Copy of - (void) emulThread { - extern uint8 *RAMBaseHost, *ROMBaseHost; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + 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); @@ -376,19 +374,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