mirror of https://github.com/stella-emu/stella.git
Changes to allow for command line execution of Stella on the Macintosh
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@450 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
6706fb41f7
commit
ce294522a7
|
@ -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.1 2005-05-28 01:28:36 markgrebe Exp $
|
||||
// $Id: OSystemMACOSX.cxx,v 1.2 2005-05-28 21:06:41 markgrebe Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -24,6 +24,7 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h> /* for MAXPATHLEN */
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "OSystem.hxx"
|
||||
|
@ -40,8 +41,7 @@ void macOpenConsole(char *romname);
|
|||
|
||||
// Pointer to the main parent osystem object or the null pointer
|
||||
extern OSystem* theOSystem;
|
||||
|
||||
static double Atari_time(void);
|
||||
extern char parentdir[MAXPATHLEN];
|
||||
|
||||
// Allow the SDL main object to pass request to open cartridges from
|
||||
// the OS into the application.
|
||||
|
@ -74,7 +74,8 @@ OSystemMACOSX::OSystemMACOSX()
|
|||
setStateDir(statedir);
|
||||
|
||||
string userPropertiesFile = basedir + "/stella.pro";
|
||||
string systemPropertiesFile = "/etc/stella.pro";
|
||||
strcat(parentdir,"/../../../stella.pro");
|
||||
string systemPropertiesFile = parentdir;
|
||||
setPropertiesFiles(userPropertiesFile, systemPropertiesFile);
|
||||
|
||||
string userConfigFile = basedir + "/stellarc";
|
||||
|
@ -173,11 +174,3 @@ uInt32 OSystemMACOSX::getTicks()
|
|||
return (uInt32) SDL_GetTicks() * 1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
static double Atari_time(void)
|
||||
{
|
||||
struct timeval tp;
|
||||
|
||||
gettimeofday(&tp, NULL);
|
||||
return tp.tv_sec + 1e-6 * tp.tv_usec;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Feel free to customize this file to suit your needs
|
||||
*/
|
||||
/* $Id: SDLMain.m,v 1.3 2005-05-28 01:29:29 markgrebe Exp $ */
|
||||
/* $Id: SDLMain.m,v 1.4 2005-05-28 21:06:41 markgrebe Exp $ */
|
||||
|
||||
#import "SDL.h"
|
||||
#import "SDLMain.h"
|
||||
|
@ -17,10 +17,11 @@ void macOpenConsole(char *romname);
|
|||
|
||||
static int gArgc;
|
||||
static char **gArgv;
|
||||
static BOOL gFinderLaunch;
|
||||
BOOL gFinderLaunch;
|
||||
static BOOL started=NO;
|
||||
static char startupFile[FILENAME_MAX];
|
||||
int fileToLoad = FALSE;
|
||||
char parentdir[MAXPATHLEN];
|
||||
|
||||
/* A helper category for NSString */
|
||||
@interface NSString (ReplaceSubString)
|
||||
|
@ -51,30 +52,6 @@ static SDLMain *sharedInstance = nil;
|
|||
return sharedInstance;
|
||||
}
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||
{
|
||||
char parentdir[MAXPATHLEN];
|
||||
char *c;
|
||||
|
||||
strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
|
||||
c = (char*) parentdir;
|
||||
|
||||
while (*c != '\0') /* go to end */
|
||||
c++;
|
||||
|
||||
while (*c != '/') /* back up to parent */
|
||||
c--;
|
||||
|
||||
*c++ = '\0'; /* cut off last part (binary name) */
|
||||
|
||||
if (shouldChdir)
|
||||
{
|
||||
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
|
||||
assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
|
||||
}
|
||||
}
|
||||
|
||||
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
|
||||
{
|
||||
|
@ -109,9 +86,6 @@ char fileName[FILENAME_MAX];
|
|||
|
||||
started = YES;
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
[self setupWorkingDirectory:gFinderLaunch];
|
||||
|
||||
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||
[self fixMenu:[NSApp mainMenu] withAppName:[[NSProcessInfo processInfo] processName]];
|
||||
|
||||
|
@ -202,6 +176,23 @@ char fileName[FILENAME_MAX];
|
|||
# undef main
|
||||
#endif
|
||||
|
||||
void setupParentDirectory(void)
|
||||
{
|
||||
char *c;
|
||||
|
||||
strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
|
||||
c = (char*) parentdir;
|
||||
|
||||
while (*c != '\0') /* go to end */
|
||||
c++;
|
||||
|
||||
while (*c != '/') /* back up to parent */
|
||||
c--;
|
||||
|
||||
*c++ = '\0'; /* cut off last part (binary name) */
|
||||
|
||||
}
|
||||
|
||||
/* Main entry point to executable - should *not* be SDL_main! */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
|
@ -225,6 +216,8 @@ int main (int argc, char **argv)
|
|||
|
||||
myPrefs = [Preferences sharedInstance];
|
||||
|
||||
setupParentDirectory();
|
||||
|
||||
[SDLApplication poseAsClass:[NSApplication class]];
|
||||
NSApplicationMain (argc, argv);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue