37 |
|
#import <prefs.h> |
38 |
|
#import <timer.h> |
39 |
|
|
40 |
< |
#undef check() // memory.h defines a check macro, which clashes with an OS X one? |
40 |
> |
#undef check() // memory.h defines a check macro, clashes with an OS X one? |
41 |
|
#import <cpu_emulation.h> |
42 |
|
|
43 |
< |
#define DEBUG 1 |
43 |
> |
#define DEBUG 0 |
44 |
|
#import <debug.h> |
45 |
|
|
46 |
|
// NSWindow method, which is invoked via delegation |
120 |
|
- (NSSlider *) speed { return speed; } |
121 |
|
- (NSWindow *) window { return win; } |
122 |
|
|
123 |
– |
//#define DEBUG 1 |
124 |
– |
//#include <debug.h> |
123 |
|
|
124 |
|
// Update some UI elements |
125 |
|
|
182 |
|
|
183 |
|
[emul terminate]; QuitEmuNoExit(); |
184 |
|
|
185 |
< |
emul = [[NNThread alloc] init]; |
185 |
> |
emul = [NNThread new]; |
186 |
|
[emul perform:@selector(emulThread) of:self]; |
187 |
|
[emul start]; |
188 |
|
|
312 |
|
[NSThread detachNewThreadSelector:(SEL)"" toTarget:nil withObject:nil]; |
313 |
|
//emul = [[NNThread alloc] initWithAutoReleasePool]; |
314 |
|
#endif |
315 |
< |
emul = [[NNThread alloc] init]; |
316 |
< |
RTC = [[NNTimer alloc] init]; |
317 |
< |
redraw = [[NNTimer alloc] init]; |
318 |
< |
tick = [[NNTimer alloc] init]; |
319 |
< |
xPRAM = [[NNTimer alloc] init]; |
315 |
> |
emul = [NNThread new]; |
316 |
> |
RTC = [NNTimer new]; |
317 |
> |
redraw = [NNTimer new]; |
318 |
> |
tick = [NNTimer new]; |
319 |
> |
xPRAM = [NNTimer new]; |
320 |
|
|
321 |
|
[emul perform:@selector(emulThread) of:self]; |
322 |
|
[RTC repeat:@selector(RTCinterrupt) of:self |
357 |
|
|
358 |
|
- (void) emulThread |
359 |
|
{ |
360 |
< |
extern uint8 *RAMBaseHost, *ROMBaseHost; |
363 |
< |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
360 |
> |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; |
361 |
|
|
362 |
< |
InitEmulator(); |
362 |
> |
if ( ! InitEmulator() ) |
363 |
> |
{ |
364 |
> |
[redraw suspend]; // Stop the barberpole |
365 |
|
|
366 |
< |
if ( RAMBaseHost == NULL || ROMBaseHost == NULL ) |
367 |
< |
ErrorSheet(@"Cannot start Emulator", |
369 |
< |
@"Emulator memory not allocated", nil, win); |
366 |
> |
ErrorSheet(@"Cannot start Emulator", @"", @"Quit", win); |
367 |
> |
} |
368 |
|
else |
369 |
|
{ |
370 |
|
memcpy(lastXPRAM, XPRAM, XPRAM_SIZE); |
374 |
|
while ( screen == nil ) // If we are still loading from Nib? |
375 |
|
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 1.0]]; |
376 |
|
|
377 |
< |
// [screen readyToDraw]; |
380 |
< |
[self runUpdate]; |
377 |
> |
[self runUpdate]; // Set the window close gadget to dimpled |
378 |
|
|
379 |
|
Start680x0(); // Start 68k and jump to ROM boot routine |
380 |
|
|
381 |
|
puts ("Emulator exited normally"); |
382 |
|
} |
383 |
|
|
387 |
– |
running = NO; |
388 |
– |
uaeCreated = NO; |
389 |
– |
[self runUpdate]; // Update button & dimple |
384 |
|
[pool release]; |
385 |
< |
[self exitThreads]; |
385 |
> |
QuitEmulator(); |
386 |
|
} |
387 |
|
|
388 |
|
- (void) RTCinterrupt |