|
|
1.1.1.12 root 1: /*
2: SDLMain.m - main entry point for our Cocoa-ized SDL app
1.1 root 3: Initial Version: Darrell Walisser <[email protected]>
4: Non-NIB-Code & other changes: Max Horn <[email protected]>
1.1.1.12 root 5: Modifications for Hatari by Miguel Saro and Jerome Vernet
1.1 root 6:
7: Feel free to customize this file to suit your needs
1.1.1.11 root 8: */
1.1 root 9:
1.1.1.11 root 10: /* Use this flag to determine whether we use SDLMain.nib or not */
11: #define SDL_USE_NIB_FILE 1
1.1.1.6 root 12:
1.1.1.11 root 13: /* Use this flag to determine whether we use CPS (docking) or not */
14: #define SDL_USE_CPS 1
1.1.1.6 root 15:
1.1.1.11 root 16: #import "SDL.h"
17: #import "SDLMain.h"
18: #import <sys/param.h> // for MAXPATHLEN
19: #import <unistd.h>
1.1.1.6 root 20:
1.1.1.11 root 21: // for Hatari
22: #import "dialog.h"
23: #import "floppy.h"
24: #import "reset.h"
25: #import "screenSnapShot.h"
26: #import "memorySnapShot.h"
27: #import "sound.h"
28: #import "screen.h"
29: #import "PrefsController.h"
30: #import "Shared.h"
31: #import "video.h"
32: #import "avi_record.h"
33: #import "debugui.h"
34: #import "clocks_timings.h"
35: #import "change.h"
1.1.1.6 root 36:
37:
38: #ifdef SDL_USE_CPS
1.1.1.11 root 39: // Portions of CPS.h
1.1.1.6 root 40: typedef struct CPSProcessSerNum
41: {
42: UInt32 lo;
43: UInt32 hi;
44: } CPSProcessSerNum;
45:
46: extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
47: extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
48: extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
49:
1.1.1.11 root 50: #endif // SDL_USE_CPS
1.1 root 51:
1.1.1.11 root 52: static int gArgc;
53: static char **gArgv;
54: static BOOL gFinderLaunch = NO ;
55: static BOOL gCalledAppMainline = NO ;
1.1.1.6 root 56:
57:
1.1.1.11 root 58: // The main class of the application, the application's delegate
59: //
60: @implementation HatariAppDelegate
1.1 root 61:
1.1.1.11 root 62: char szPath[FILENAME_MAX] ; // for general use
1.1 root 63:
1.1.1.11 root 64: // Set the working directory to the .app's parent directory
1.1.1.6 root 65: - (void) setupWorkingDirectory:(BOOL)shouldChdir
66: {
1.1.1.12 root 67: if (shouldChdir)
1.1.1.13! root 68: chdir([[[NSBundle mainBundle].bundlePath stringByDeletingLastPathComponent] cStringUsingEncoding:NSASCIIStringEncoding]) ;
1.1.1.6 root 69: }
70:
71:
72: /*
73: * Catch document open requests...this lets us notice files when the app
74: * was launched by double-clicking a document, or when a document was
75: * dragged/dropped on the app's icon. You need to have a
76: * CFBundleDocumentsType section in your Info.plist to get this message,
77: * apparently.
78: *
79: * Files are added to gArgv, so to the app, they'll look like command line
80: * arguments. Previously, apps launched from the finder had nothing but
81: * an argv[0].
82: *
83: * This message may be received multiple times to open several docs on launch.
84: *
85: * This message is ignored once the app's mainline has been called.
86: */
87: - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
88: {
1.1.1.12 root 89: const char *temparg;
90: size_t arglen;
91: char *arg;
92: char **newargv;
93:
94: if (!gFinderLaunch) // MacOS is passing command line args.
95: return FALSE;
96:
97: if (gCalledAppMainline) // app has started, ignore this document.
98: return FALSE;
99:
1.1.1.13! root 100: temparg = filename.UTF8String ;
1.1.1.12 root 101: arglen = SDL_strlen(temparg) + 1 ;
102: arg = (char *) SDL_malloc(arglen) ;
103: if (arg == NULL)
104: return FALSE;
105:
106: newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2)) ;
107: if (newargv == NULL)
108: {
109: SDL_free(arg);
110: return FALSE;
111: }
112: gArgv = newargv ;
113:
114: SDL_strlcpy(arg, temparg, arglen) ;
115: gArgv[gArgc++] = arg ;
116: gArgv[gArgc] = NULL ;
117: return TRUE;
1.1.1.6 root 118: }
119:
1.1.1.13! root 120: /*----------------------------------------------------------------------*/
1.1.1.11 root 121: // Called when the internal event loop has just started running
1.1.1.13! root 122: /*----------------------------------------------------------------------*/
1.1.1.6 root 123: - (void) applicationDidFinishLaunching: (NSNotification *) note
124: {
1.1.1.11 root 125: int status;
1.1.1.6 root 126:
1.1.1.11 root 127: // Set the working directory to the .app's parent directory
128: [self setupWorkingDirectory:gFinderLaunch];
1.1.1.6 root 129:
1.1.1.11 root 130: //setenv ("SDL_ENABLEAPPEVENTS", "1", 1) ;
1.1.1.6 root 131:
1.1.1.11 root 132: // Hand off to main application code
1.1.1.13! root 133: emulationPaused=NO;
1.1.1.11 root 134: gCalledAppMainline = TRUE;
135: status = SDL_main (gArgc, gArgv) ;
136:
137: // We're done, thank you for playing
138: exit(status) ;
1.1.1.6 root 139: }
140:
1.1.1.13! root 141: /*----------------------------------------------------------------------*/
1.1.1.6 root 142: // Hatari Stuff
1.1.1.13! root 143: /*----------------------------------------------------------------------*/
1.1 root 144: - (IBAction)prefsMenu:(id)sender
145: {
146: static int in_propdialog = 0;
1.1.1.6 root 147:
1.1 root 148: if (in_propdialog)
1.1.1.11 root 149: return ;
150: ++in_propdialog ;
151: Dialog_DoProperty() ;
1.1 root 152: --in_propdialog;
153: }
154:
1.1.1.11 root 155: /*- (IBAction) openPreferences:(id)sender
1.1.1.9 root 156: {
157: [[PrefsController prefs] loadPrefs:sender];
1.1.1.11 root 158: } // */
1.1.1.9 root 159:
1.1.1.13! root 160: /*----------------------------------------------------------------------*/
1.1.1.6 root 161: - (IBAction)debugUI:(id)sender
162: {
1.1.1.8 root 163: DebugUI(REASON_USER);
1.1.1.6 root 164: }
1.1.1.13! root 165: /*----------------------------------------------------------------------*/
1.1 root 166: - (IBAction)warmReset:(id)sender
167: {
1.1.1.12 root 168: if ([NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Warm reset!") firstB:localize(@"OK") alternateB:localize(@"Cancel")
1.1.1.13! root 169: otherB:nil informativeTxt:localize(@"Really reset the emulator?")] == NSAlertFirstButtonReturn )
1.1 root 170: Reset_Warm();
1.1.1.10 root 171: }
1.1.1.13! root 172: /*----------------------------------------------------------------------*/
1.1 root 173: - (IBAction)coldReset:(id)sender
174: {
1.1.1.12 root 175: if ([NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Cold reset") firstB:localize(@"OK") alternateB:localize(@"Cancel")
1.1.1.13! root 176: otherB:nil informativeTxt:localize(@"Really reset the emulator?")] == NSAlertFirstButtonReturn )
1.1 root 177: Reset_Cold();
178: }
1.1.1.13! root 179: /*----------------------------------------------------------------------*/
1.1 root 180: - (IBAction)insertDiskA:(id)sender
181: {
1.1.1.11 root 182: [self insertDisk:0] ;
1.1 root 183: }
1.1.1.13! root 184: /*----------------------------------------------------------------------*/
1.1 root 185: - (IBAction)insertDiskB:(id)sender
186: {
1.1.1.11 root 187: [self insertDisk:1] ;
188: }
1.1.1.13! root 189: /*----------------------------------------------------------------------*/
1.1.1.11 root 190: - (void)insertDisk:(int)disque
191: {
192: NSString *aDisk ;
1.1.1.6 root 193:
1.1.1.13! root 194: aDisk = [NSApp hopenfile:NO defoDir:nil defoFile:@"" types:@[allF]] ;
! 195: if (aDisk.length == 0) return ; // user canceled
1.1.1.6 root 196:
1.1.1.11 root 197: [aDisk getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ;
198: Floppy_SetDiskFileName(disque, szPath, NULL) ;
199: Floppy_InsertDiskIntoDrive(disque) ;
1.1 root 200: }
1.1.1.13! root 201: /*----------------------------------------------------------------------*/
! 202: - (IBAction)quit:(id)sender
! 203: {
! 204: Main_RequestQuit(0) ;
! 205: }
1.1 root 206:
1.1.1.13! root 207: /*----------------------------------------------------------------------*/
! 208: /*Controls the enabled state of the menu items */
! 209: /*----------------------------------------------------------------------*/
1.1 root 210: - (BOOL)validateMenuItem:(NSMenuItem*)item
211: {
212: if (item == beginCaptureAnim)
213: {
1.1.1.11 root 214: return !Avi_AreWeRecording() ;
1.1 root 215: }
216: if (item == endCaptureAnim)
217: {
1.1.1.11 root 218: return Avi_AreWeRecording() ;
1.1 root 219: }
220: if (item == beginCaptureSound)
221: {
1.1.1.11 root 222: return !Sound_AreWeRecording() ;
1.1 root 223: }
224: if (item == endCaptureSound)
225: {
1.1.1.11 root 226: return Sound_AreWeRecording() ;
1.1 root 227: }
228:
229: return YES;
230: }
231:
1.1.1.13! root 232: /*----------------------------------------------------------------------*/
! 233:
1.1.1.7 root 234: - (NSString*)displayFileSelection:(const char*)pathInParams preferredFileName:(NSString*)preferredFileName allowedExtensions:(NSArray*)allowedExtensions
1.1 root 235: {
1.1.1.11 root 236: // BOOL test ;
237: NSString *directoryToOpen;
238: NSString *fileToPreselect;
239: NSString *preferredPath;
240: NSString *extensionText;
241: NSString *selectFile;
1.1.1.12 root 242:
1.1 root 243: // Get the path from the user settings
1.1.1.11 root 244: preferredPath = [[NSString stringWithCString:pathInParams encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath];
245:
1.1.1.13! root 246: if ((preferredPath != nil) && (preferredPath.length > 0)) // Determine the directory and filename
1.1.1.11 root 247: {
1.1.1.13! root 248: directoryToOpen = preferredPath.stringByDeletingLastPathComponent ; // Existing path: we use it
! 249: fileToPreselect = preferredPath.lastPathComponent;
1.1.1.11 root 250: }
1.1 root 251: else
1.1.1.11 root 252: {
253: directoryToOpen = [@"~" stringByExpandingTildeInPath]; // No path: we use the user's directory
1.1.1.7 root 254: fileToPreselect = preferredFileName;
1.1.1.11 root 255: } ;
1.1.1.12 root 256:
1.1.1.11 root 257: if(bInFullScreen)
258: Screen_ReturnFromFullScreen();
259: // SavePanel for choosing what file to write
260: extensionText = [NSString stringWithFormat:localize(@"Please specify a .%@ file"), [allowedExtensions componentsJoinedByString:localize(@" or a .")] ];
1.1.1.12 root 261:
1.1.1.11 root 262: selectFile = [NSApp hsavefile:YES defoDir:directoryToOpen defoFile:fileToPreselect types:allowedExtensions titre:extensionText ] ;
1.1.1.13! root 263: if (selectFile.length != 0 )
1.1.1.11 root 264: return selectFile ;
1.1.1.12 root 265:
1.1.1.7 root 266: return nil;
267: }
1.1.1.13! root 268: /*----------------------------------------------------------------------*/
1.1.1.7 root 269: - (IBAction)captureScreen:(id)sender
270: {
1.1.1.13! root 271: GuiOsx_Pause(false);
1.1.1.7 root 272: ScreenSnapShot_SaveScreen();
273: GuiOsx_Resume();
274: }
1.1.1.13! root 275: /*----------------------------------------------------------------------*/
1.1.1.7 root 276: - (IBAction)captureAnimation:(id)sender
277: {
1.1.1.13! root 278: GuiOsx_Pause(false);
1.1.1.7 root 279: if(!Avi_AreWeRecording()) {
1.1.1.12 root 280: NSString* path = [self displayFileSelection:ConfigureParams.Video.AviRecordFile preferredFileName:@"hatari.avi"
1.1.1.13! root 281: allowedExtensions:@[@"avi"]];
1.1.1.12 root 282:
1.1.1.7 root 283: if(path) {
284: GuiOsx_ExportPathString(path, ConfigureParams.Video.AviRecordFile, sizeof(ConfigureParams.Video.AviRecordFile));
285: Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop ,
286: ConfigureParams.Video.AviRecordFps == 0 ?
287: ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) :
288: (Uint32)ConfigureParams.Video.AviRecordFps << CLOCKS_TIMINGS_SHIFT_VBL ,
289: 1 << CLOCKS_TIMINGS_SHIFT_VBL ,
290: ConfigureParams.Video.AviRecordVcodec );
291: }
292: } else {
293: Avi_StopRecording();
1.1.1.6 root 294: }
1.1.1.7 root 295: GuiOsx_Resume();
296: }
1.1.1.13! root 297: /*----------------------------------------------------------------------*/
1.1.1.7 root 298: - (IBAction)endCaptureAnimation:(id)sender
299: {
1.1.1.13! root 300: GuiOsx_Pause(false);
1.1.1.11 root 301: Avi_StopRecording();
302: GuiOsx_Resume();
1.1.1.7 root 303: }
1.1.1.13! root 304: /*----------------------------------------------------------------------*/
1.1.1.7 root 305: - (IBAction)captureSound:(id)sender
306: {
1.1.1.13! root 307: GuiOsx_Pause(true);
1.1.1.12 root 308: NSString* path = [self displayFileSelection:ConfigureParams.Sound.szYMCaptureFileName preferredFileName:@"hatari.wav"
1.1.1.13! root 309: allowedExtensions:@[@"ym", @"wav"]];
1.1.1.7 root 310: if(path) {
311: GuiOsx_ExportPathString(path, ConfigureParams.Sound.szYMCaptureFileName, sizeof(ConfigureParams.Sound.szYMCaptureFileName));
312: Sound_BeginRecording(ConfigureParams.Sound.szYMCaptureFileName);
313: }
1.1.1.5 root 314: GuiOsx_Resume();
1.1 root 315: }
1.1.1.13! root 316: /*----------------------------------------------------------------------*/
1.1 root 317: - (IBAction)endCaptureSound:(id)sender
318: {
1.1.1.13! root 319: GuiOsx_Pause(false);
1.1 root 320: Sound_EndRecording();
1.1.1.5 root 321: GuiOsx_Resume();
1.1 root 322: }
1.1.1.13! root 323: /*----------------------------------------------------------------------*/
1.1 root 324: - (IBAction)saveMemorySnap:(id)sender
325: {
1.1.1.13! root 326: GuiOsx_Pause(true);
1.1 root 327:
1.1.1.12 root 328: NSString* path = [self displayFileSelection:ConfigureParams.Memory.szMemoryCaptureFileName preferredFileName:@"hatari.sav"
1.1.1.13! root 329: allowedExtensions:@[@"sav"]];
1.1.1.7 root 330: if(path) {
1.1 root 331: GuiOsx_ExportPathString(path, ConfigureParams.Memory.szMemoryCaptureFileName, sizeof(ConfigureParams.Memory.szMemoryCaptureFileName));
1.1.1.2 root 332: MemorySnapShot_Capture(ConfigureParams.Memory.szMemoryCaptureFileName, TRUE);
1.1.1.6 root 333: }
1.1.1.12 root 334:
1.1.1.5 root 335: GuiOsx_Resume();
1.1 root 336: }
1.1.1.13! root 337: /*----------------------------------------------------------------------*/
1.1 root 338: - (IBAction)restoreMemorySnap:(id)sender
339: {
1.1.1.12 root 340: NSString *directoryToOpen;
341: NSString *fileToPreselect;
342: NSString *oldPath ;
343: NSString *newPath ;
1.1 root 344:
1.1.1.13! root 345: GuiOsx_Pause(true);
1.1 root 346:
347: // Get the path from the user settings
1.1.1.11 root 348: oldPath = [NSString stringWithCString:(ConfigureParams.Memory.szMemoryCaptureFileName) encoding:NSASCIIStringEncoding];
1.1.1.12 root 349:
1.1.1.13! root 350: if ((oldPath != nil) && (oldPath.length > 0)) // Determine directory and filename
! 351: { directoryToOpen = oldPath.stringByDeletingLastPathComponent ; // existing path: we use it.
! 352: fileToPreselect = oldPath.lastPathComponent ; }
1.1 root 353: else
1.1.1.13! root 354: { directoryToOpen = @"~".stringByExpandingTildeInPath ; // Currently no path: we use user's directory
1.1.1.11 root 355: fileToPreselect = nil; } ;
1.1.1.6 root 356:
1.1.1.13! root 357: newPath = [NSApp hopenfile:NO defoDir:directoryToOpen defoFile:fileToPreselect types:@[@"sav"] ] ;
! 358: if (newPath.length != 0) // Perform the memory snapshot load
1.1.1.11 root 359: MemorySnapShot_Restore([newPath cStringUsingEncoding:NSASCIIStringEncoding], TRUE);
1.1.1.6 root 360:
1.1.1.5 root 361: GuiOsx_Resume();
1.1 root 362: }
1.1.1.13! root 363: /*----------------------------------------------------------------------*/
1.1 root 364: - (IBAction)doFullScreen:(id)sender
365: {
1.1.1.12 root 366: // A call to Screen_EnterFullScreen() would be required, but this causes a crash when using
1.1.1.11 root 367: // SDL runtime 1.2.11, probably due to conflicts between Cocoa and SDL.
1.1 root 368: // Therefore we simulate the fullscreen key press instead
1.1.1.12 root 369:
1.1 root 370: SDL_KeyboardEvent event;
1.1.1.12 root 371: memset(&event, 0, sizeof(event));
1.1.1.6 root 372: event.type = SDL_KEYDOWN;
373: event.state = SDL_PRESSED;
374: event.keysym.sym = SDLK_F11;
375: SDL_PushEvent((SDL_Event*)&event); // Send the F11 key press
376: event.type = SDL_KEYUP;
377: event.state = SDL_RELEASED;
378: SDL_PushEvent((SDL_Event*)&event); // Send the F11 key release
1.1 root 379: }
380:
1.1.1.13! root 381: /*----------------------------------------------------------------------*/
1.1 root 382: - (IBAction)help:(id)sender
383: {
1.1.1.11 root 384: NSString *the_help;
1.1.1.12 root 385:
1.1.1.11 root 386: the_help = [[NSBundle mainBundle] pathForResource:@"manual" ofType:@"html" inDirectory:@"HatariHelp"];
1.1.1.12 root 387:
1.1.1.13! root 388: [[NSWorkspace sharedWorkspace] openFile:the_help];
1.1 root 389: }
1.1.1.13! root 390: /*----------------------------------------------------------------------*/
1.1.1.10 root 391: - (IBAction)compat:(id)sender
392: {
1.1.1.13! root 393: NSString *the_help ;
1.1.1.12 root 394:
1.1.1.13! root 395: the_help = [[NSBundle mainBundle] pathForResource:@"compatibility" ofType:@"html" inDirectory:@"HatariHelp"] ;
1.1.1.12 root 396:
1.1.1.13! root 397: [[NSWorkspace sharedWorkspace] openFile:the_help];
1.1.1.10 root 398: }
1.1.1.13! root 399: /*----------------------------------------------------------------------*/
! 400: - (IBAction)PauseMenu:(id)sender {
! 401: if(!emulationPaused)
! 402: {
! 403: GuiOsx_Pause(true);
! 404: emulationPaused=YES;
! 405: [pauseMenuItem setState:NSOnState];
! 406: }
! 407: else
! 408: {
! 409: GuiOsx_Resume();
! 410: emulationPaused=NO;
! 411: [pauseMenuItem setState:NSOffState];
! 412: }
! 413: }
! 414: /*----------------------------------------------------------------------*/
1.1.1.12 root 415: - (IBAction)openConfig:(id)sender
1.1.1.9 root 416: {
1.1.1.12 root 417: BOOL applyChanges ;
418: NSString *ConfigFile, *newCfg ;
419: CNF_PARAMS CurrentParams;
1.1.1.11 root 420:
421: applyChanges = true ;
1.1.1.12 root 422: ConfigFile = [NSString stringWithCString:(sConfigFileName) encoding:NSASCIIStringEncoding];
423:
1.1.1.9 root 424: // Backup of configuration settings to CurrentParams (which we will only
425: // commit back to the configuration settings if choosing user confirm)
426: CurrentParams = ConfigureParams;
1.1.1.12 root 427:
1.1.1.13! root 428: GuiOsx_Pause(true);
1.1.1.12 root 429:
1.1.1.13! root 430: newCfg = [NSApp hopenfile:NO defoDir:nil defoFile:ConfigFile types:@[@"cfg"] ] ;
1.1.1.12 root 431:
1.1.1.13! root 432: if (newCfg.length != 0)
1.1.1.12 root 433: {
1.1.1.11 root 434: [newCfg getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ; // get Cstring szPath
435: Configuration_Load(szPath) ; // Load the config into ConfigureParams
436: strcpy(sConfigFileName,szPath) ;
437:
1.1.1.12 root 438: // Refresh all the controls to match ConfigureParams
1.1.1.9 root 439: if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
1.1.1.12 root 440: applyChanges = [NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Reset the emulator") firstB:localize(@"Don't reset")
1.1.1.13! root 441: alternateB:localize(@"Reset") otherB:nil informativeTxt:@"" ] == NSAlertFirstButtonReturn ;
1.1.1.9 root 442: if (applyChanges)
1.1.1.13! root 443: Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true); // Ok with Reset
1.1.1.12 root 444: else
1.1.1.11 root 445: ConfigureParams = CurrentParams; //Restore previous Params.
1.1.1.12 root 446: } ;
447:
1.1.1.9 root 448: GuiOsx_Resume();
1.1 root 449: }
450:
1.1.1.13! root 451: /*----------------------------------------------------------------------*/
1.1.1.6 root 452: - (IBAction)saveConfig:(id)sender {
1.1 root 453: }
454:
455: @end
1.1.1.13! root 456: /*----------------------------------------------------------------------*/
1.1.1.12 root 457: static int IsRootCwd()
458: {
459: char buf[MAXPATHLEN];
460: char *cwd = getcwd(buf, sizeof (buf));
461: return (cwd && (strcmp(cwd, "/") == 0));
462: }
1.1.1.13! root 463: /*----------------------------------------------------------------------*/
1.1.1.12 root 464: static int IsTenPointNineOrLater()
465: {
1.1.1.13! root 466: // OK for 10.9, but before ??
! 467: NSOperatingSystemVersion systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
! 468: int r=(systemVersion.majorVersion==10) && (systemVersion.minorVersion>=9);
1.1.1.12 root 469:
1.1.1.13! root 470: return r;
! 471: }
! 472: /*----------------------------------------------------------------------*/
1.1.1.12 root 473: static int IsFinderLaunch(const int argc, char **argv)
474: {
475: /* -psn_XXX is passed if we are launched from Finder in 10.8 and earlier */
476: if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
477: return 1;
478: }
479: if (IsTenPointNineOrLater() && argc == 1 && IsRootCwd()) {
480: /* we might still be launched from the Finder; on 10.9+, you might not
481: get the -psn command line anymore. Check version, if there's no
482: command line, and if our current working directory is "/". */
483: return 1;
484: }
1.1.1.13! root 485: return 0; /* not a Finder launch. */
1.1.1.12 root 486: }
487:
1.1 root 488: #ifdef main
489: # undef main
490: #endif
1.1.1.13! root 491: /*----------------------------------------------------------------------*/
1.1.1.12 root 492: // Main entry point to executable - should *not* be SDL_main!
1.1.1.13! root 493: /*----------------------------------------------------------------------*/
1.1 root 494: int main (int argc, char **argv)
495: {
1.1.1.12 root 496: // Copy the arguments into a global variable
497: if (IsFinderLaunch(argc, argv)) {
498: gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
499: gArgv[0] = argv[0];
500: gArgv[1] = NULL;
501: gArgc = 1;
502: gFinderLaunch = YES;
503: } else {
504: int i;
505: gArgc = argc;
506: gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
507: for (i = 0; i <= argc; i++)
508: gArgv[i] = argv[i];
509: gFinderLaunch = NO;
510: }
1.1 root 511:
1.1.1.6 root 512: #if SDL_USE_NIB_FILE
1.1.1.12 root 513: NSApplicationMain (argc, (const char**)argv);
1.1.1.6 root 514: #else
1.1.1.12 root 515: CustomApplicationMain (argc, argv);
1.1.1.6 root 516: #endif
1.1.1.12 root 517: return 0;
518: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.