diff --git a/stella/src/macosx/Menus.h b/stella/src/macosx/Menus.h index 0ef24b66d..699672b0a 100755 --- a/stella/src/macosx/Menus.h +++ b/stella/src/macosx/Menus.h @@ -4,40 +4,21 @@ Mark Grebe */ -/* $Id: Menus.h,v 1.4 2005-02-18 05:31:47 markgrebe Exp $ */ +/* $Id: Menus.h,v 1.5 2005-06-03 05:04:56 markgrebe Exp $ */ #import @interface Menus : NSObject { - IBOutlet id limitSpeedMenu; - IBOutlet id paddlesMenu; - IBOutlet id filterMenu; - IBOutlet id videoModeMatrix; - IBOutlet id volumeSlider; - IBOutlet id aspectRatioField; - IBOutlet id romDirField; - int openGlEnabled; - int gameMenusEnabled; } + (Menus *)sharedInstance; -- (NSString *) browseDir; -- (void)setSpeedLimitMenu:(int)limit; -- (void)initVideoMenu:(int)openGl; -- (void)setPaddleMenu:(int)number; -- (void)prefsStart; -- (void)enableGameMenus; -- (void)pushKeyEvent:(int)key:(bool)shift; -- (IBAction) paddleChange:(id) sender; -- (IBAction) prefsOK:(id) sender; -- (IBAction) romdirSelect:(id) sender; -- (IBAction)prefsMenu:(id)sender; +- (void)pushKeyEvent:(int)key:(bool)shift:(bool)cmd; +- (IBAction)paddleChange:(id) sender; - (IBAction)biggerScreen:(id)sender; - (IBAction)smallerScreen:(id)sender; - (IBAction)fullScreen:(id)sender; - (IBAction)openCart:(id)sender; - (IBAction)restartGame:(id)sender; -- (IBAction)speedLimit:(id)sender; - (IBAction)pauseGame:(id)sender; - (IBAction)ntscPalMode:(id)sender; - (IBAction)togglePallette:(id)sender; @@ -51,5 +32,8 @@ - (IBAction)widthMinus:(id)sender; - (IBAction)heightPlus:(id)sender; - (IBAction)heightMinus:(id)sender; +- (IBAction)doPrefs:(id)sender; +- (IBAction)volumePlus:(id)sender; +- (IBAction)volumeMinus:(id)sender; @end diff --git a/stella/src/macosx/Menus.m b/stella/src/macosx/Menus.m index 570c4ae37..0ea96ba7a 100755 --- a/stella/src/macosx/Menus.m +++ b/stella/src/macosx/Menus.m @@ -4,10 +4,11 @@ Mark Grebe */ -/* $Id: Menus.m,v 1.6 2005-05-28 21:50:07 markgrebe Exp $ */ +/* $Id: Menus.m,v 1.7 2005-06-03 05:05:05 markgrebe Exp $ */ #import #import "SDL.h" +#import "Menus.h" #define QZ_m 0x2E #define QZ_o 0x1F @@ -68,3 +69,160 @@ void handleMacOSXKeypress(int key) { break; } } + +@implementation Menus + +static Menus *sharedInstance = nil; + ++ (Menus *)sharedInstance { + return sharedInstance ? sharedInstance : [[self alloc] init]; +} + +- (id)init +{ + sharedInstance = self; + return(self); +} + +-(void)pushKeyEvent:(int)key:(bool)shift:(bool)cmd +{ + SDL_Event theEvent; + + theEvent.key.type = SDL_KEYDOWN; + theEvent.key.state = SDL_PRESSED; + theEvent.key.keysym.scancode = 0; + theEvent.key.keysym.sym = key; + theEvent.key.keysym.mod = 0; + if (cmd) + theEvent.key.keysym.mod = KMOD_LMETA; + if (shift) + theEvent.key.keysym.mod |= KMOD_LSHIFT; + theEvent.key.keysym.unicode = 0; + SDL_PushEvent(&theEvent); +} + +- (IBAction) paddleChange:(id) sender +{ + switch([sender tag]) + { + case 0: + [self pushKeyEvent:SDLK_0:NO:YES]; + break; + case 1: + [self pushKeyEvent:SDLK_1:NO:YES]; + break; + case 2: + [self pushKeyEvent:SDLK_2:NO:YES]; + break; + case 3: + [self pushKeyEvent:SDLK_3:NO:YES]; + break; + } +} + +- (IBAction)biggerScreen:(id)sender +{ + [self pushKeyEvent:SDLK_EQUALS:YES:YES]; +} + +- (IBAction)smallerScreen:(id)sender +{ + [self pushKeyEvent:SDLK_MINUS:YES:YES]; +} + +- (IBAction)fullScreen:(id)sender +{ + [self pushKeyEvent:SDLK_RETURN:NO:YES]; +} + +- (IBAction)openCart:(id)sender +{ + [self pushKeyEvent:SDLK_ESCAPE:NO:NO]; +} + +- (IBAction)restartGame:(id)sender +{ + [self pushKeyEvent:SDLK_r:NO:YES]; +} + +- (IBAction)pauseGame:(id)sender +{ + [self pushKeyEvent:SDLK_PAUSE:NO:NO]; +} + +- (IBAction)ntscPalMode:(id)sender +{ + [self pushKeyEvent:SDLK_f:NO:YES]; +} + +- (IBAction)toggleGlFilter:(id)sender +{ + [self pushKeyEvent:SDLK_f:YES:YES]; +} + +- (IBAction)togglePallette:(id)sender +{ + [self pushKeyEvent:SDLK_p:NO:YES]; +} + +- (IBAction)grabMouse:(id)sender +{ + [self pushKeyEvent:SDLK_g:NO:YES]; +} + +- (IBAction)xStartPlus:(id)sender +{ + [self pushKeyEvent:SDLK_HOME:YES:YES]; +} + +- (IBAction)xStartMinus:(id)sender +{ + [self pushKeyEvent:SDLK_END:YES:YES]; +} + +- (IBAction)yStartPlus:(id)sender +{ + [self pushKeyEvent:SDLK_PAGEUP:YES:YES]; +} + +- (IBAction)yStartMinus:(id)sender +{ + [self pushKeyEvent:SDLK_PAGEDOWN:YES:YES]; +} + +- (IBAction)widthPlus:(id)sender +{ + [self pushKeyEvent:SDLK_END:NO:YES]; +} + +- (IBAction)widthMinus:(id)sender +{ + [self pushKeyEvent:SDLK_HOME:NO:YES]; +} + +- (IBAction)heightPlus:(id)sender +{ + [self pushKeyEvent:SDLK_PAGEUP:NO:YES]; +} + +- (IBAction)heightMinus:(id)sender +{ + [self pushKeyEvent:SDLK_PAGEDOWN:NO:YES]; +} + +- (IBAction)doPrefs:(id)sender +{ + [self pushKeyEvent:SDLK_TAB:NO:NO]; +} + +- (IBAction)volumePlus:(id)sender +{ + [self pushKeyEvent:SDLK_RIGHTBRACKET:YES:YES]; +} + +- (IBAction)volumeMinus:(id)sender +{ + [self pushKeyEvent:SDLK_LEFTBRACKET:YES:YES]; +} + +@end diff --git a/stella/src/macosx/OSystemMACOSX.cxx b/stella/src/macosx/OSystemMACOSX.cxx index 971cd5eee..ac40ec5df 100644 --- a/stella/src/macosx/OSystemMACOSX.cxx +++ b/stella/src/macosx/OSystemMACOSX.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystemMACOSX.cxx,v 1.2 2005-05-28 21:06:41 markgrebe Exp $ +// $Id: OSystemMACOSX.cxx,v 1.3 2005-06-03 05:05:05 markgrebe Exp $ //============================================================================ #include @@ -149,12 +149,12 @@ void OSystemMACOSX::mainLoop() myFrameBuffer->update(); currentTime = getTicks(); - virtualTime += myTimePerFrame; + virtualTime = startTime + myTimePerFrame; if(currentTime < virtualTime) { - SDL_Delay((virtualTime - currentTime)/1000); + SDL_Delay((virtualTime - currentTime)/1000); } - + currentTime = getTicks() - startTime; frameTime += currentTime; ++numberOfFrames; diff --git a/stella/src/macosx/stella.pbproj/project.pbxproj b/stella/src/macosx/stella.pbproj/project.pbxproj index 539c1a9a0..4f3814471 100755 --- a/stella/src/macosx/stella.pbproj/project.pbxproj +++ b/stella/src/macosx/stella.pbproj/project.pbxproj @@ -11,6 +11,7 @@ F5A47A9E01A0483001D3D55B, 2DDBEBE3084582C400812C11, 2DDBEBE4084582C400812C11, + 2D62C40E085011050063A4A3, 2D47A45208491D4500ABFB6A, ); isa = PBXGroup; @@ -428,6 +429,8 @@ bin BIN + rom + ROM zip ZIP @@ -565,6 +568,7 @@ 2DDBEB7F08457B7D00812C11, 2DDBEBE5084582C400812C11, 2DDFFA2B0847EF4E00201CC8, + 2D62C40F085011050063A4A3, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -806,6 +810,20 @@ settings = { }; }; + 2D62C40E085011050063A4A3 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = Menus.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 2D62C40F085011050063A4A3 = { + fileRef = 2D62C40E085011050063A4A3; + isa = PBXBuildFile; + settings = { + }; + }; 2D733D5D062893E7006265D9 = { fileEncoding = 30; isa = PBXFileReference;