Launcher for SDLMame using AppleScript (Mac OSX)

If like me you use a Mac and mess about with M.A.M.E. then by now you've probably discovered the wanderful port "SDLMame". If you haven't then you SHOULD so head on over to HERE and check it out.

Anyway, SDLMame doesn't come with a front end. Now while there are one or two kicking about in early stages of their life on the whole i am quite happy just working with the command line. I was however starting to get pretty fed up with opening a terminal and typing "cd Projects/Mame/sdlmame0108u4", etc. etc. so i took my first quick look at AppleScript. My result is an icon that sits on my desktop (but it could be anywhere!). When i click it i get a dialogue pop up asking me for the game name (default of "Pacman" is filled in for me) along with three buttons. "Run", "Debug" and "Cancel". Simple, effective and to the point. Here's a little shot of it in action and then how it's done...

launcher_dialog


1. Using script editor add the following code, editing it to suit your needs and your environment. For now I'm assuming if you are messing about with SDLMame then you ought to be able to work out what to change but just changing the path to where your app is should suffice.

launcher_code


2. Save this script (duh!) If, like me you want to end up with an application icon just like any other app (but with the AppleScript icon!) then select the options below. There are other options. I guess they do other things, I've never touched AppleScript before so don't know about them yet. Save it wherever is convenient for you - i chose the desktop but i could just as easily have chosen the Applications folder and then created a symlink, or dragged it to the dock or whatever!

launcher_save


3. This script needs an environment variable called CURRENT_SDLMAME to work. This is so that if i move to a new version i just change the environment variable and i don't need to mess with the script. Sadly, this isn't QUITE as simple as setting an environment variable in a bash ".profile" file but it's not far off!

Using "Property List Editor" (found in the utilities folder on the XCode installation, but may be able to be picked up seperately, i don't know!) create a new property list with a new root and a single variable called "CURRENT_SDLMAME" that has the name of the folder that your executable is sitting in. I follow the standard release layout so the contents of my variable is currently "sdlmame0108u4". Save this properrty list in "~/.MacOSX" as "environment.plist" - case is important.

Note that if this file already exists then DO NOT OVERWRITE IT, ADD TO IT!!!

I logged out and back in again to get the change to the environment variables to take effect. There may be a way to do it without logging out but for the time it took me to log out and back in, I didn't really care!

Of course, it should go without saying that in order for the debug button to actually bring up the internal debugger you will need to have compiled your version of sdlmame with the makefile option "DEBUG=1". By default this is commented out. As of today there is now a native implementation of the debugger that works on OSX without needing GTK+ to be installed or anything however be aware that a bug has been found that is causing some people problems. A fix has also been found so I'm sure this will be implemented in the next release (which is never far away!)

If you have no interest in ever running the internal mame debugger then you obviously don't need to compile it in. In this instance the script above can be modified and made even simpler. Just have only two buttons. The rest of the script could then be tidied up to remove all the bits associated with deciding which debug command line option to use, or it can be left alone since it should work quite happily as is just with one less button!

Well, basically, that's it!

If you came here directly just for that info and found it useful then do me the favour of taking a look around. There's not much here but if you're into arcade games then i guess you MAY find it interesting!!