--- previous/src/gui-osx/SDLMain.m 2018/04/24 19:25:43 1.1.1.2 +++ previous/src/gui-osx/SDLMain.m 2018/04/24 19:31:41 1.1.1.4 @@ -14,15 +14,11 @@ #include "dialog.h" #include "reset.h" -#include "screenSnapShot.h" -#include "memorySnapShot.h" #include "screen.h" #include "PrefsController.h" #include "Shared.h" #include "video.h" -#include "avi_record.h" #include "../debug/debugui.h" -#include "clocks_timings.h" // for Hatari @@ -47,9 +43,9 @@ typedef struct CPSProcessSerNum UInt32 hi; } CPSProcessSerNum; -extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); -extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); +OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); +OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); +OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); #endif /* SDL_USE_CPS */ @@ -81,22 +77,15 @@ static NSString *getApplicationName(void @end #endif -@interface NSApplication (SDLApplication) -@end - -@implementation NSApplication (SDLApplication) +/* The main class of the application, the application's delegate */ +@implementation SDLMain /* Invoked from the Quit menu item */ -- (void)terminate:(id)sender -{ +- (void)applicationWillTerminate:(NSNotification *)aNotification { /* Post a SDL_QUIT event */ SDL_Event event; event.type = SDL_QUIT; SDL_PushEvent(&event); } -@end - -/* The main class of the application, the application's delegate */ -@implementation SDLMain /* Set the working directory to the .app's parent directory */ - (void) setupWorkingDirectory:(BOOL)shouldChdir @@ -302,7 +291,7 @@ static void CustomApplicationMain (int a /* Called when the internal event loop has just started running */ - (void) applicationDidFinishLaunching: (NSNotification *) note { - int status; + int status = 0; /* Set the working directory to the .app's parent directory */ [self setupWorkingDirectory:gFinderLaunch]; @@ -314,7 +303,7 @@ static void CustomApplicationMain (int a /* Hand off to main application code */ gCalledAppMainline = TRUE; - status = SDL_main (gArgc, gArgv); + //status = SDL_main (gArgc, gArgv); /* We're done, thank you for playing */ exit(status); @@ -339,6 +328,7 @@ static void CustomApplicationMain (int a - (IBAction)warmReset:(id)sender { + /* int b; b = NSRunAlertPanel ( @@ -349,10 +339,12 @@ static void CustomApplicationMain (int a //printf("b=%i\n",b); if (b == 1) Reset_Warm(); + */ } - (IBAction)coldReset:(id)sender { + /* int b; b = NSRunAlertPanel ( @@ -363,17 +355,19 @@ static void CustomApplicationMain (int a //printf("b=%i\n",b); if (b == 1) Reset_Cold(); + */ } - (IBAction)insertDiskA:(id)sender { + /* NSString *path = nil; NSOpenPanel *openPanel = [ NSOpenPanel openPanel ]; if ( [ openPanel runModalForDirectory:nil file:@"SavedGame" types:nil ] ) { - path = [ [ openPanel filenames ] objectAtIndex:0 ]; + path = [[ [ openPanel URLs ] objectAtIndex:0 ] path]; } if (path != nil) @@ -387,17 +381,19 @@ static void CustomApplicationMain (int a // Floppy_SetDiskFileName(0, szPath, NULL); // Floppy_InsertDiskIntoDrive(0); } + */ } - (IBAction)insertDiskB:(id)sender { + /* NSString *path = nil; NSOpenPanel *openPanel = [ NSOpenPanel openPanel ]; if ( [ openPanel runModalForDirectory:nil file:@"SavedGame" types:nil ] ) { - path = [ [ openPanel filenames ] objectAtIndex:0 ]; + path = [[ [ openPanel URLs ] objectAtIndex:0 ] path]; } if (path != nil) @@ -411,6 +407,7 @@ static void CustomApplicationMain (int a // Floppy_SetDiskFileName(1, szPath, NULL); // Floppy_InsertDiskIntoDrive(1); } + */ } /*-----------------------------------------------------------------------*/ @@ -441,7 +438,7 @@ static void CustomApplicationMain (int a - (NSString*)displayFileSelection:(const char*)pathInParams preferredFileName:(NSString*)preferredFileName allowedExtensions:(NSArray*)allowedExtensions { - +/* // Get the path from the user settings NSString *preferredPath = [[NSString stringWithCString:(pathInParams) encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath]; @@ -471,13 +468,14 @@ static void CustomApplicationMain (int a // Run the SavePanel, then check if the user clicked OK and selected at least one file if (NSFileHandlingPanelOKButton == [savePanel runModalForDirectory:directoryToOpen file:fileToPreselect] ) return [[savePanel URL] path]; + */ return nil; } - (IBAction)captureScreen:(id)sender { GuiOsx_Pause(); - ScreenSnapShot_SaveScreen(); +// ScreenSnapShot_SaveScreen(); GuiOsx_Resume(); } @@ -512,12 +510,12 @@ static void CustomApplicationMain (int a - (IBAction)captureSound:(id)sender { GuiOsx_Pause(); - NSString* path = [self displayFileSelection:ConfigureParams.Sound.szYMCaptureFileName preferredFileName:@"hatari.wav" - allowedExtensions:[NSArray arrayWithObjects:@"ym", @"wav", nil]]; - if(path) { - GuiOsx_ExportPathString(path, ConfigureParams.Sound.szYMCaptureFileName, sizeof(ConfigureParams.Sound.szYMCaptureFileName)); +// NSString* path = [self displayFileSelection:ConfigureParams.Sound.szYMCaptureFileName preferredFileName:@"hatari.wav" +// allowedExtensions:[NSArray arrayWithObjects:@"ym", @"wav", nil]]; +// if(path) { +// GuiOsx_ExportPathString(path, ConfigureParams.Sound.szYMCaptureFileName, sizeof(ConfigureParams.Sound.szYMCaptureFileName)); // Sound_BeginRecording(ConfigureParams.Sound.szYMCaptureFileName); - } +// } GuiOsx_Resume(); } @@ -530,9 +528,10 @@ static void CustomApplicationMain (int a - (IBAction)saveMemorySnap:(id)sender { + /* GuiOsx_Pause(); - NSString* path = [self displayFileSelection:ConfigureParams.Memory.szMemoryCaptureFileName preferredFileName:@"hatari.sav" + NSString* path = [self displayFileSelection:ConfigureParams.Memory.szMemoryCaptureFileName preferredFileName:@"hatari.sav" allowedExtensions:[NSArray arrayWithObjects:@"sav",nil]]; if(path) { GuiOsx_ExportPathString(path, ConfigureParams.Memory.szMemoryCaptureFileName, sizeof(ConfigureParams.Memory.szMemoryCaptureFileName)); @@ -540,10 +539,12 @@ static void CustomApplicationMain (int a } GuiOsx_Resume(); + */ } - (IBAction)restoreMemorySnap:(id)sender { + /* GuiOsx_Pause(); // Create and configure an OpenPanel @@ -569,17 +570,18 @@ static void CustomApplicationMain (int a } // Run the OpenPanel, then check if the user clicked OK and selected at least one file - if ( (NSOKButton == [openPanel runModalForDirectory:directoryToOpen file:fileToPreselect types:nil] ) - && ([[openPanel filenames] count] > 0) ) + if ( (NSModalResponseOK == [openPanel runModalForDirectory:directoryToOpen file:fileToPreselect types:nil] ) + && ([[openPanel URLs] count] > 0) ) { // Get the path to the selected file - NSString *path = [[openPanel filenames] objectAtIndex:0]; + NSString *path = [[[openPanel URLs] objectAtIndex:0] path]; // Perform the memory snapshot load MemorySnapShot_Restore([path cStringUsingEncoding:NSASCIIStringEncoding], TRUE); } GuiOsx_Resume(); + */ } - (IBAction)doFullScreen:(id)sender @@ -589,7 +591,7 @@ static void CustomApplicationMain (int a SDL_KeyboardEvent event; event.type = SDL_KEYDOWN; - event.which = 0; + //event.which = 0; event.state = SDL_PRESSED; event.keysym.sym = SDLK_F11; SDL_PushEvent((SDL_Event*)&event); // Send the F11 key press @@ -658,7 +660,7 @@ static void CustomApplicationMain (int a # undef main #endif - +#if 0 /* Main entry point to executable - should *not* be SDL_main! */ int main (int argc, char **argv) { @@ -686,4 +688,4 @@ int main (int argc, char **argv) #endif return 0; } - +#endif