ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/Emulator.mm
(Generate patch)

Comparing BasiliskII/src/MacOSX/Emulator.mm (file contents):
Revision 1.1 by nigel, 2002-03-16T04:00:09Z vs.
Revision 1.6 by nigel, 2003-03-26T23:04:46Z

# Line 37 | Line 37
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
# Line 94 | Line 94
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
# Line 120 | Line 117
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  
# Line 149 | Line 144
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;
# Line 179 | Line 198
198                  NSLog (@"%s - uae_cpu reset not yet supported, will try to fake it",
199                                  __PRETTY_FUNCTION__);
200  
201 < //              [screen blacken];
202 <                [screen setNeedsDisplay: YES];
201 >                [screen clear];
202 >                [screen display];
203  
204                  [emul terminate]; QuitEmuNoExit();
205  
206 <                emul = [[NNThread alloc] init];
206 >
207 >                // OK. We have killed & cleaned up. Now, start afresh:
208 >        #include <sys.h>
209 >                int     argc = 0;
210 >                char **argv;
211 >
212 >                PrefsInit(argc, argv);
213 >                SysInit();
214 >
215 >                emul = [NNThread new];
216                  [emul perform:@selector(emulThread) of:self];
217                  [emul start];
218  
219                  if ( display_type != DISPLAY_SCREEN )
220                          [redraw resume];
193                uaeCreated = YES;
221          }
222   }
223  
# Line 204 | Line 231
231          [xPRAM  resume];
232   }
233  
234 + - (IBAction) ScreenHideShow: (NSButton *)sender;
235 + {
236 +        WarningSheet(@"Nigel doesn't know how to shrink or grow this window",
237 +                                 @"Maybe you can grab the source code and have a go yourself?",
238 +                                 nil, win);
239 + }
240 +
241   - (IBAction) Snapshot: (id) sender
242   {
243          if ( screen == nil || uaeCreated == NO  )
244                  WarningSheet(@"The emulator has not yet started.",
245                                           @"There is no screen output to snapshot",
246 <                                         @"OK", win);
246 >                                         nil, win);
247          else
248          {
249                  NSData  *TIFFdata;
# Line 303 | Line 337 | uint8 lastXPRAM[XPRAM_SIZE];           // Copy of
337   - (void) createThreads
338   {
339   #ifdef USE_PTHREADS
340 <        [NSThread detachNewThreadSelector:(SEL)"" toTarget:nil withObject:nil]; // Make UI threadsafe
340 >        // Make UI threadsafe:
341 >        [NSThread detachNewThreadSelector:(SEL)"" toTarget:nil withObject:nil];
342          //emul   = [[NNThread   alloc] initWithAutoReleasePool];
343   #endif
344 <        emul   = [[NNThread     alloc] init];
345 <        RTC    = [[NNTimer      alloc] init];
346 <        redraw = [[NNTimer  alloc] init];
347 <        tick   = [[NNTimer      alloc] init];
348 <        xPRAM  = [[NNTimer      alloc] init];
344 >        emul   = [NNThread      new];
345 >        RTC    = [NNTimer       new];
346 >        redraw = [NNTimer       new];
347 >        tick   = [NNTimer       new];
348 >        xPRAM  = [NNTimer       new];
349  
350          [emul  perform:@selector(emulThread)    of:self];
351          [RTC    repeat:@selector(RTCinterrupt)  of:self
# Line 345 | Line 380 | uint8 lastXPRAM[XPRAM_SIZE];           // Copy of
380          [redraw invalidate]; [redraw release]; redraw = nil;
381          [RTC    invalidate]; [RTC        release]; RTC    = nil;
382          [xPRAM  invalidate]; [xPRAM      release]; xPRAM  = nil;
348        if ( uaeCreated )
349                QuitEmuNoExit();
383   }
384  
385   - (void) emulThread
386   {
387 <        extern uint8            *RAMBaseHost, *ROMBaseHost;
355 <        NSAutoreleasePool       *pool = [[NSAutoreleasePool alloc] init];
387 >        NSAutoreleasePool       *pool = [NSAutoreleasePool new];
388  
389 < //      [screen allocBitmap];   // Do this first, because InitEmulator() calls VideoInit(), which needs the_bitmap.
390 <
391 <        InitEmulator();
389 >        if ( ! InitEmulator() )
390 >        {
391 >                [redraw suspend];               // Stop the barberpole
392  
393 <        if ( RAMBaseHost == NULL || ROMBaseHost == NULL )
394 <                ErrorSheet(@"Cannot start Emulator.",
363 <                                   @"Emulator memory not allocated", @"OK", win);
393 >                ErrorSheet(@"Cannot start Emulator", @"", @"Quit", win);
394 >        }
395          else
396          {
397                  memcpy(lastXPRAM, XPRAM, XPRAM_SIZE);
398  
399                  uaeCreated = YES;               // Enable timers to access emulated Mac's memory
400  
401 <                while ( screen == nil ) // If init sets running, but we are still loading from Nib?
401 >                while ( screen == nil ) // If we are still loading from Nib?
402                          [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 1.0]];
403  
404 < //              [screen readyToDraw];
374 <                [self   runUpdate];
404 >                [self   runUpdate];             // Set the window close gadget to dimpled
405  
406                  Start680x0();                   // Start 68k and jump to ROM boot routine
407  
408                  puts ("Emulator exited normally");
409          }
410  
381        running = NO;
382        uaeCreated = NO;
383        [self runUpdate];                       // Update button & dimple
411          [pool release];
412 <        [self exitThreads];
412 >        QuitEmulator();
413   }
414  
415   - (void) RTCinterrupt
# Line 395 | Line 422 | uint8 lastXPRAM[XPRAM_SIZE];           // Copy of
422   {
423          if ( display_type == DISPLAY_SCREEN )
424          {
425 <                NSLog(@"Why was redrawScreen() called?");
425 >                NSLog(@"We are in fullscreen mode - why was redrawScreen() called?");
426                  return;
427          }
428          [barberPole animate:self];                      // wobble the pole
429          [screen setNeedsDisplay: YES];          // redisplay next time through runLoop
430          // Or, use a direct method. e.g.
431 <        //      [screen cgDrawInto: ...];
431 >        //      [screen display] or [screen cgDrawInto: ...];
432   }
433  
434   #include <main.h>                               // For #define INTFLAG_60HZ
# Line 427 | Line 454 | uint8 lastXPRAM[XPRAM_SIZE];           // Copy of
454          }
455   }
456  
457 < @end
457 > @end

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines