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 |
94 |
|
//[win setHasShadow: NO]; // This causes view & window to now be drawn correctly |
95 |
|
[win useOptimizedDrawing: YES]; |
96 |
|
|
97 |
– |
// [win center]; |
97 |
|
[win makeKeyAndOrderFront:self]; |
98 |
|
|
100 |
– |
// [self resizeWinToWidth:x Height:y]; |
101 |
– |
|
99 |
|
if ( redrawDelay ) |
100 |
|
[speed setFloatValue: 1.0 / redrawDelay]; |
101 |
|
else |
117 |
|
- (NSSlider *) speed { return speed; } |
118 |
|
- (NSWindow *) window { return win; } |
119 |
|
|
123 |
– |
//#define DEBUG 1 |
124 |
– |
//#include <debug.h> |
120 |
|
|
121 |
|
// Update some UI elements |
122 |
|
|
144 |
|
[self Resume: self]; |
145 |
|
} |
146 |
|
|
147 |
+ |
#ifdef NIGEL |
148 |
+ |
- (IBAction) EjectCD: (id)sender; |
149 |
+ |
{ |
150 |
+ |
NSString *path; |
151 |
+ |
const char *cdrom = PrefsFindString("cdrom"); |
152 |
+ |
|
153 |
+ |
if ( cdrom ) |
154 |
+ |
{ |
155 |
+ |
#include <sys/param.h> |
156 |
+ |
#define KERNEL |
157 |
+ |
#include <sys/mount.h> |
158 |
+ |
|
159 |
+ |
struct statfs buf; |
160 |
+ |
if ( fsstat(path, &buf) < 0 ) |
161 |
+ |
return; |
162 |
+ |
|
163 |
+ |
path = [NSString stringWithCString: cdrom]; |
164 |
+ |
|
165 |
+ |
[[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: path]; |
166 |
+ |
// [path release]; |
167 |
+ |
} |
168 |
+ |
} |
169 |
+ |
#endif |
170 |
+ |
|
171 |
|
- (IBAction) Interrupt: (id)sender; |
172 |
|
{ |
173 |
< |
WarningSheet (@"Interrupt action not yet supported", @"", @"OK", win); |
173 |
> |
WarningSheet (@"Interrupt action not yet supported", win); |
174 |
|
} |
175 |
|
|
176 |
|
- (IBAction) PowerKey: (id)sender; |
190 |
|
|
191 |
|
- (IBAction) Restart: (id)sender |
192 |
|
{ |
193 |
+ |
if ( ! running ) |
194 |
+ |
{ |
195 |
+ |
running = YES; // Start emulator |
196 |
+ |
[self runUpdate]; |
197 |
+ |
[self Resume: nil]; |
198 |
+ |
} |
199 |
+ |
|
200 |
|
if ( running ) |
201 |
< |
// reset680x0(); |
201 |
> |
#ifdef UAE_CPU_HAS_RESET |
202 |
> |
reset680x0(); |
203 |
> |
#else |
204 |
|
{ |
205 |
|
uaeCreated = NO; |
206 |
|
[redraw suspend]; |
207 |
|
NSLog (@"%s - uae_cpu reset not yet supported, will try to fake it", |
208 |
|
__PRETTY_FUNCTION__); |
209 |
|
|
210 |
< |
// [screen blacken]; |
211 |
< |
[screen setNeedsDisplay: YES]; |
210 |
> |
[screen clear]; |
211 |
> |
[screen display]; |
212 |
|
|
213 |
|
[emul terminate]; QuitEmuNoExit(); |
214 |
|
|
215 |
< |
emul = [[NNThread alloc] init]; |
215 |
> |
|
216 |
> |
// OK. We have killed & cleaned up. Now, start afresh: |
217 |
> |
#include <sys.h> |
218 |
> |
int argc = 0; |
219 |
> |
char **argv; |
220 |
> |
|
221 |
> |
PrefsInit(argc, argv); |
222 |
> |
SysInit(); |
223 |
> |
|
224 |
> |
emul = [NNThread new]; |
225 |
|
[emul perform:@selector(emulThread) of:self]; |
226 |
|
[emul start]; |
227 |
|
|
228 |
|
if ( display_type != DISPLAY_SCREEN ) |
229 |
|
[redraw resume]; |
193 |
– |
uaeCreated = YES; |
230 |
|
} |
231 |
+ |
#endif |
232 |
|
} |
233 |
|
|
234 |
|
- (IBAction) Resume: (id)sender |
241 |
|
[xPRAM resume]; |
242 |
|
} |
243 |
|
|
244 |
+ |
- (IBAction) ScreenHideShow: (NSButton *)sender; |
245 |
+ |
{ |
246 |
+ |
WarningSheet(@"Nigel doesn't know how to shrink or grow this window", |
247 |
+ |
@"Maybe you can grab the source code and have a go yourself?", |
248 |
+ |
nil, win); |
249 |
+ |
} |
250 |
+ |
|
251 |
|
- (IBAction) Snapshot: (id) sender |
252 |
|
{ |
253 |
|
if ( screen == nil || uaeCreated == NO ) |
254 |
|
WarningSheet(@"The emulator has not yet started.", |
255 |
|
@"There is no screen output to snapshot", |
256 |
< |
@"OK", win); |
256 |
> |
nil, win); |
257 |
|
else |
258 |
|
{ |
259 |
|
NSData *TIFFdata; |
347 |
|
- (void) createThreads |
348 |
|
{ |
349 |
|
#ifdef USE_PTHREADS |
350 |
< |
[NSThread detachNewThreadSelector:(SEL)"" toTarget:nil withObject:nil]; // Make UI threadsafe |
350 |
> |
// Make UI threadsafe: |
351 |
> |
[NSThread detachNewThreadSelector:(SEL)"" toTarget:nil withObject:nil]; |
352 |
|
//emul = [[NNThread alloc] initWithAutoReleasePool]; |
353 |
|
#endif |
354 |
< |
emul = [[NNThread alloc] init]; |
355 |
< |
RTC = [[NNTimer alloc] init]; |
356 |
< |
redraw = [[NNTimer alloc] init]; |
357 |
< |
tick = [[NNTimer alloc] init]; |
358 |
< |
xPRAM = [[NNTimer alloc] init]; |
354 |
> |
emul = [NNThread new]; |
355 |
> |
RTC = [NNTimer new]; |
356 |
> |
redraw = [NNTimer new]; |
357 |
> |
tick = [NNTimer new]; |
358 |
> |
xPRAM = [NNTimer new]; |
359 |
|
|
360 |
|
[emul perform:@selector(emulThread) of:self]; |
361 |
|
[RTC repeat:@selector(RTCinterrupt) of:self |
390 |
|
[redraw invalidate]; [redraw release]; redraw = nil; |
391 |
|
[RTC invalidate]; [RTC release]; RTC = nil; |
392 |
|
[xPRAM invalidate]; [xPRAM release]; xPRAM = nil; |
348 |
– |
if ( uaeCreated ) |
349 |
– |
QuitEmuNoExit(); |
393 |
|
} |
394 |
|
|
395 |
|
- (void) emulThread |
396 |
|
{ |
397 |
< |
extern uint8 *RAMBaseHost, *ROMBaseHost; |
355 |
< |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
356 |
< |
|
357 |
< |
// [screen allocBitmap]; // Do this first, because InitEmulator() calls VideoInit(), which needs the_bitmap. |
397 |
> |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; |
398 |
|
|
399 |
< |
InitEmulator(); |
399 |
> |
if ( ! InitEmulator() ) |
400 |
> |
{ |
401 |
> |
[redraw suspend]; // Stop the barberpole |
402 |
|
|
403 |
< |
if ( RAMBaseHost == NULL || ROMBaseHost == NULL ) |
404 |
< |
ErrorSheet(@"Cannot start Emulator.", |
363 |
< |
@"Emulator memory not allocated", @"OK", win); |
403 |
> |
ErrorSheet(@"Cannot start Emulator", @"", @"Quit", win); |
404 |
> |
} |
405 |
|
else |
406 |
|
{ |
407 |
|
memcpy(lastXPRAM, XPRAM, XPRAM_SIZE); |
408 |
|
|
409 |
|
uaeCreated = YES; // Enable timers to access emulated Mac's memory |
410 |
|
|
411 |
< |
while ( screen == nil ) // If init sets running, but we are still loading from Nib? |
411 |
> |
while ( screen == nil ) // If we are still loading from Nib? |
412 |
|
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 1.0]]; |
413 |
|
|
414 |
< |
// [screen readyToDraw]; |
374 |
< |
[self runUpdate]; |
414 |
> |
[self runUpdate]; // Set the window close gadget to dimpled |
415 |
|
|
416 |
|
Start680x0(); // Start 68k and jump to ROM boot routine |
417 |
|
|
418 |
|
puts ("Emulator exited normally"); |
419 |
|
} |
420 |
|
|
381 |
– |
running = NO; |
382 |
– |
uaeCreated = NO; |
383 |
– |
[self runUpdate]; // Update button & dimple |
421 |
|
[pool release]; |
422 |
< |
[self exitThreads]; |
422 |
> |
QuitEmulator(); |
423 |
|
} |
424 |
|
|
425 |
|
- (void) RTCinterrupt |
432 |
|
{ |
433 |
|
if ( display_type == DISPLAY_SCREEN ) |
434 |
|
{ |
435 |
< |
NSLog(@"Why was redrawScreen() called?"); |
435 |
> |
NSLog(@"We are in fullscreen mode - why was redrawScreen() called?"); |
436 |
|
return; |
437 |
|
} |
438 |
|
[barberPole animate:self]; // wobble the pole |
439 |
|
[screen setNeedsDisplay: YES]; // redisplay next time through runLoop |
440 |
|
// Or, use a direct method. e.g. |
441 |
< |
// [screen cgDrawInto: ...]; |
441 |
> |
// [screen display] or [screen cgDrawInto: ...]; |
442 |
|
} |
443 |
|
|
444 |
|
#include <main.h> // For #define INTFLAG_60HZ |
464 |
|
} |
465 |
|
} |
466 |
|
|
467 |
< |
@end |
467 |
> |
@end |