Play classic arcade games on your favorite open source OS .
Home gaming consoles might be fine for some people, but if you are reading this hack, you are probably one of those old-school arcade wizards that we used to congregate around in smoky pizza joints, hoping for the honor of holding your tokens, as you obliterated the previous high scores on Spy Hunter or Dig-Dug or Sinistar (or maybe you're one of the congregants, hoping to improve your skills so you can finally take on that wizard). You might even be the sort who dreams of filling your den with original arcade cabinets , bringing up your children in the Way of Pac-Man.
This hack is for you. I show you how to emulate a startling variety of arcade hardware on the Linux/Unix platform. In the Unix world, there are two ports of MAME, the Multiple Arcade Machine Emulator, worth worrying about: AdvanceMAME (http://advancemame. sourceforge .net/), a Linux port of MAME; and Xmame (http://x.mame.net/), an X11 port of MAME.
I start with Xmame, which is a port of the MAME program to Unix. It can use native X11R6, SVGAlib, ggi, XF86-DGA, OpenGL, or SDL display drivers. The fact that Xmame supports pretty much every combination of libraries, hardware, and ROMs out there is a definite win for the serious emulation fan on the Unix platform. To build and install Xmame, follow the instructions for your Linux distribution or flavor of Unix.
To install Xmame under Gentoo Linux:
Become root .
To install Xmame under other Linux or Unix distributions, check your installation media or online package repositories to see if it's already available. You should also check the Xmame project's home page (http://x.mame.net/) to see if a binary version is available. If not, you can install it from source:
Visit the Xmame project's home page, click on the Download link in the menu on the left side of the page, and save the latest Xmame source tarball to your / tmp directory (remove any older versions of the Xmame source tarball you may have lying around first). Then, run the following commands:
$ cd /tmp $ tar xvjf xmame-*.tar.bz2 $ rm xmame-*.tar.bz2 $ cd xmame-*
Edit the Makefile in your favorite editor. If you are building Xmame on an x86 (i.e., Intel-compatible) box running Linux, just scroll down until you reach the "Input Devices" section, and skip to the next step. If you are running on different hardware:
Scroll down to the "Architecture; choose your CPU (only one!!)" section and comment out the
MY_CPU = i386
line by inserting a hash character in front of it, so the line reads:
#MY_CPU = i386
Now, find the line that describes your processor type (e.g., if you are building on a Sparc machine, the # MY_CPU = risc line), and uncomment it by deleting the hash and any whitespace before the MY_CPU bit. Follow the same steps if you are using an OS other than Linux, which is the default. Simply comment out the ARCH = linux line and uncomment the line that describes your OS (for example, if your Sparc box is running Solaris, uncomment the # ARCH = solaris line).
Scroll down to the "Input Devices" section, and uncomment any lines that relate to features you want to enable, by removing the hash character and any leading whitespace. You almost certainly want to uncomment JOY_STANDARD = 1 , if you are planning to use a joystick with Xmame. I would also recommend uncommenting JOY_SDL = 1 , as I find that SDL joystick support works best for me.
Scroll down to the "Sound Devices" section, and uncomment lines for features you want to enable. I recommend uncommenting SOUND_ALSA = 1 , SOUND_SDL = 1 , and SOUND_WAVEOUT = 1 . If you are a KDE user , you will probably want to uncomment the two lines pertaining to ARTS. And of course if you are unfortunate enough to have to use ESD, uncomment the SOUND_ESOUND = 1 line as well.
Save the Makefile and exit your editor.
Next, run the following commands (you need to run the second command as root or use sudo ):
$ make # make install
You have just built Xmame using the X11 graphics drivers. If you would like to build versions of Xmame for another display driver, simply run make DISPLAY_METHOD=METHOD (such as make DISPLAY_METHOD=SDL for SDL ). Then run make install as root . (The available values for DISPLAY_METHOD are SDL , svgalib , ggi , svgafx , openstep , and photon2 .)
If you survived this long and arduous process, you will have Xmame installed. To run it, open a terminal as a normal user and run something like this:
$ xmame.SDL -jt 7 -rp rom_dir -s 2 rom_name
Here is an explanation of each option:
This is the SDL version of Xmame (the one I compiled with the make DISPLAY_METHOD=SDL incantation). SDL, or Simple Directmedia Layer, is a cross-platform multimedia library used by many popular games and emulators. You can find out more about it at http://www.libsdl.org.Iam using SDL because it handles video better for my laptop's video hardware than any of the other display methods .
This switch instructs Xmame to use the SDL joystick drivers.
This switch tells Xmame where to find your ROM files (make sure to replace rom_dir with the actual directory in which your MAME ROMs reside [Hack #26] .
This switch causes the display to be scaled by a factor of two in both the X and Y directions.
This is the name of the ROM that you want to run; note that MAME, unlike most other emulators, does not expect a filename here. Instead, use the name of the game (e.g., robby or rotox for "Robby Roto"). If you cannot guess the proper name, search for your game in MAME's official games list (http://www.mame.net/gamelist.html).
Figure 3-11 shows an example of me running the excellent public domain MAME ROM Gridlee [Hack #24] . Here is the appropriate incantation:
$ xmame.SDL -jt 7 -rp /data/roms/mame/ -s 2 gridlee
Once in the game, press the 5 key on your keyboard to insert a credit (you may do this as many times as you likefeel free to dock yourself a quarter or a hyaku-en coin every time, if you want a more realistic arcade experience). When you are sufficiently loaded up with credits, press the 1 key to start the game!
Xmame has tons more command-line options and the ability to store said options in both site-wide and user-specific configuration files. Check out the Xmame man page for more details.
Like almost all command-line emulators, Xmame and a graphical frontend are two great tastes that taste great together. And of all the graphical frontends for Xmame that exist in the Unix world, GXMame seems to me the tastiest. So let us not delay even a fraction of a moment, but instead install this treat:
To install GXMame under Gentoo Linux:
Become root .
Run the command: emerge gxmame
To install GXMame under other Linux or Unix distributions, check your installation media or online package repositories to see if it's already available. You should also check the project home page (http://gxmame.sourceforge.net/) to see if a binary version is available. If not, you can install it from source:
Visit the GXMame project's download page (http://gxmame.sourceforge.net/downloads.php) and save the latest source tarball to your /tmp directory (remove any older versions of the source tarball you happen to have laying around first). Then, run these commands:
$ cd /tmp $ tar xvzf gxmame-*.tar.gz $ rm gxmame-*.tar.gz $ cd gxmame-* $ ./configure enable-joystick
Next, run the following commands (you need to run the second one as root or use sudo ):
$ make # make install
Once GXMame is installed, simply open a shell under X11 as a normal user and run:
$ gxmame &
You will be immediately warned that GXMame could not recognize the gamelist version, and asked if you want to rebuild itthis is expected. Click the Yes button and let GXMame do its thing for a few moments. You will then be presented with the main screen, which displays the very impressive list of all of the games that Xmame can play, helpfully categorized for you. The first order of business, as in any frontend, is to do a little configuration.
Click on the Option menu, and then select Directories in the Xmame Executables section of the GXMame directories tab. You need to add all of the various Xmame versions (e.g., xmame.SDL ). In the bottom of this tab, you may need to change the base Xmame data directory from / usr/lib/games/xmame to wherever your distribution installed Xmame. For Gentoo users, this is / usr/share/games/xmame . If you need to, change / usr/lib/games/xmame to the correct path for all of the paths: Flyers, Cabinets, Marquees, Title screenshots, and Icons.
Now, click on the XMame basic paths tab and add your MAME ROMs directory to the Roms Paths list (you will probably also want to remove the default, as it is unlikely that you want to keep any ROMs in / usr/lib/games/xmame/roms ). In the Samples Paths list and the Artwork Path text box, you may need to change / usr/lib/games/xmame to the correct directory, as in the preceding section. Click on Xmame's Additional Paths tab and change all of the directories, if necessary. Click on the User Resources tab and verify that all of the paths are correctthey should be, since the defaults match my Xmame install. Now, click OK to close the directory configuration dialogue.
Click the Option menu again, then Executable, then select the executable that you plan to use (e.g., xmame.SDL ). Now, click on the Option menu and select Default Option, which will open the Default Properties dialogue to the Display tab. Flip through the tabs, making any changes that you like. Make sure to change the DSP Plugin option on the Sound tab to Alsa Sound System DSP plug-in if you use ALSA instead of OSS.
Also, change Joystick type on the Controllers tab from No joystick to the proper type of joystick driver (again, I recommend the SDL joystick driver), and check any of the applicable boxes to the right (interestingly enough, even though I have a PlayStation DualShock 2 controller, if I check USB PS Game Pads, my controller will not work!). When everything is to your liking, click OK to save your preferences.
You may mess about with the other items in the Option menu if you like, but when you are done, you're ready to actually launch a game! Click the View menu, then Refresh (or hit the F5 key on your keyboard), to re-scan your ROMs directory(s)you will need to do this every time you add or change a ROM path. Now, click on the Available folder in the left pane. The right pane should now display some games as shown in Figure 3-12! To start a game, simply double-click its name (you can also enable the "Allow game selection by a Joystick" option by selecting the Option menu, then clicking Startup Option).
Once in the game, it behaves exactly as if you had started Xmame from the command-line: use 5 to insert credits, 1 to start playing.
If Xmame is not your thing, why not give AdvanceMAME a shot? To build and install it, follow the instructions for your Linux distribution/Unix flavor:
To install AdvanceMAME under Gentoo, perform the following steps:
Become root .
Run the command: emerge advancemame
Check your distribution's package repository as well as the AdvanceMAME project download page (http://advancemame.sourceforge.net/download.html) for a binary version. If one is not available, use the following instructions to install it from source:
Download a source tarball from the AdvanceMAME project download page and save it to your / tmp directory. Be sure to remove any older versions of the source tarball, and then run these commands:
$ cd /tmp $ tar xvzf advancemame-*.tar.gz $ rm advancemame-*.tar.gz $ cd advancemame*/ $ ./configure
Next, run these commands to compile and install AdvanceMAME. You need to run the second command as root :
$ make # make install
If you are building from source, note that AdvanceMAME's configure script should do a good job of auto-detecting which features to turn on or off, but it if does not get things right, run:
$ ./configure --help
This will list all of the features that the configure script can control. The generic pattern is this: to turn on a feature called "foo", use the --enable-foo switch ; to turn it off, use the --disable-foo switch. For example, to configure AdvanceMAME with ALSA (the Advanced Linux Sound Architecture), the expat XML parser, and SDL, but without OSS (the Open Sound System, which is "the old way" to do sound in Linux), you would run:
$ ./configure --enable-alsa --enable-expat --enable-sdl disable-oss
Then proceed with the rest of the build and installation process as described earlier in this section. Once you have AdvanceMAME installed, you will need to run it once with no command-line options so that it will create a configuration file:
$ advmame Creating a standard configuration file Configuration file '/home/jmglov/.advance/advmame.rc' created with all the default options. The default rom search path is '/home/jmglov/.advance/rom:/usr/share/games/advance/rom'. You can change it using the 'dir_rom' option in the configuration file.
The first order of business is editing the ~/. advance/advmame.rc configuration file and changing the dir_rom option to reflect the actual location of your MAME ROMs directory [Hack #26] .
Now, you should be able to fire up AdvanceMAME simply by running:
$ advmame rom_name
Replace rom_name with the name of the game that you want to play. AdvanceMAME is so helpful that if you get the name wrong, it will give you a few possible matches! Here is an example of me firing up Gridlee:
$ advmame gridle Game "gridle" isn't supported. Similar names are: gridlee Gridlee ridleofp Riddle of Pythagoras (Japan) 3stooges The Three Stooges In Brides Is Brides gseeker Grid Seeker: Project Stormhammer (World) gseekerj Grid Seeker: Project Stormhammer (Japan) gseekeru Grid Seeker: Project Stormhammer (US) gprider GP Rider (set 2, FD1094 317-0163) gprider1 GP Rider (set 1, US, FD1094 317-0162) gtmr Great 1000 Miles Rally gtmre Great 1000 Miles Rally (Evolution Model) gtmrusa Great 1000 Miles Rally (USA) gtmr2u Great 1000 Miles Rally 2 USA (95/05/18) $ advmame gridlee AdvanceMAME - Copyright (C) 1999-2003 by Andrea Mazzoleni MAME - Copyright (C) 1997-2003 by Nicola Salmoria and the MAME Team
Once the game starts, just as in Xmame, the 5 key inserts a credit, and the 1 key starts the game. AdvanceMAME has a welcome twist, however: an onscreen menu! To activate it, hit the Tab key on your keyboard. You can now configure pretty much any aspect of the emulator! A good starting point is the "Input (general)" menu shown in Figure 3-13, where you can view the default controls for players 1-8, and change things you do not like!
The menus are quite useful, and configuration changes made in-game will be written to your resource configuration file right away!