Section 7.5. Emulators

Modern games with detailed graphics, sophisticated soundtracks, and fast-paced network play are certainly fun, but sometimes you want to hearken back to a simpler time a time with 8- or 16-bit graphics when arguably gameplay was more important than fancy graphics. Linux has a number of emulators so you can take a trip back to the days of plunking quarters into Pacman only, as with Linux, the arcade is free. These emulators work from ROM images that have been extracted from the arcade or console game, and emulate the environment necessary for the ROM to function, so you can use your keyboard or even a joystick and play the games directly from your computer.

7.5.1. MAME

Probably the most famous and popular console emulator is MAME (Multiple Arcade Machine Emulator) . The focus of the MAME project ( is to create an emulator for the various different arcade platforms that have been in use over the years. In this respect the MAME project is much more complicated than many of the other console emulation projects because it supports many different platforms. Currently MAME supports thousands of arcade titles and the list continues to grow. You can view the list of currently supported titles on

MAME was originally a project for the Windows platform only; however, a Linux port, called Xmame , has been created. Xmame is based directly on the MAME source code, with changes being made only when necessary to run under Linux. Because of this you can treat Xmame under Linux like MAME under Windows, and ROMS that work on one will work on the other.

Xmame is a popular program and should already be packaged for your particular distribution, but if it isn't you can download the latest source from the project's site at There are a number of different display options for Xmame , and some distributions package the different display options separately:


The standard Xmame display option is output to a window under X.


Xmame can also use SVGAlib to display to the console, allowing you to use Xmame without running X.


Xmame can output to an X11 display using OpenGL libraries to take advantage of hardware acceleration on your video card.


Xmame can also use SDL libraries for output under an X11 environment. Similar to the OpenGL libraries, SDL lets Xmame take advantage of hardware acceleration where available.


As with OpenGL, Xmame can use the Glide libraries for hardware acceleration both under X and with SVGAlib for 3DFX cards.

To start, you will want to use the X11 display method because it is the default and is most likely to work with your system. The first time, just run xmame from the command line without any arguments. Xmame will search /etc/xmame/xmamerc for system-wide defaults and will create a local configuration directory under ~/.xmame. Copy the /etc/xmame/xmamerc file to ~/.xmame so you can tweak settings specific to your user. This file contains all the different settings for Xmame, but the first setting you will probably want to change is rompath. This setting controls in what directory Xmame looks for ROMs, so if your user has a local folder for MAME ROMs, put it here and save the file. Now you will be able to play any game you have a ROM for simply by passing the name of the ROM as an argument to Xmame. ROMs generally come in .zip files that contain a number of different files the emulator needs all in one package. To play your ROM, you would simply run:

    $ xmame pacman

on the command line (Figure 7-7).

Now that the game is running, what do you do? Xmame uses the same keybindings as the DOS version of MAME. Table 7-1 lists some of the primary key bindings you will find yourself using.

Figure 7-7. Xmame with Pacman

Table 7-1. Xmame key bindings




Pause the game


Reset the game


Reduce frame skip


Increase frame skip (useful to speed up games on slower machines)


Exit emulator

left-Shift + Pgup

Increase scale (makes game larger for higher-resolution displays)

left-Shift + Pgdn

Decrease scale

left-Shift + Insert

Normal window

left-Shift + Home

DGA fullscreen mode

In addition, individual games have their own key bindings. These vary from game to game, but there are some standard key bindings most games use for common buttons (Table 7-2).

Table 7-2. Common button bindings



Arrow keys

Move left, right, up, and down


Select one player


Select two players


Insert a coin


Button 1


Button 2

Because some arcade games just have a joystick, and others have six or more buttons, the button mappings to a keyboard will sometimes vary. For basic games, Ctrl and Alt work as the first and second buttons but more complicated games will require some experimentation to discover the key bindings. By default, Xmame will play a game in its original resolution, so on a high-resolution computer screen you might want to increase the scale of the game once or twice with left-Shift and PageUp.

Xmame can use your mouse for applicable games as well. A good example of using a mouse in an arcade game is Centipede , which by default uses a large trackball mouse. You can either use your mouse or the arrow keys for movement.

Xmame also supports use of a joystick, although this isn't turned on by default. Either change the joytype option in your xmamerc file or pass -joytype number on the command line. The number corresponds to the type of joystick you use (Table 7-3).

Table 7-3. Joystick mapping


Joystick type


No joystick


i386 joystick driver


Fm Town Pad support


X11 input extensions joystick


New i386 Linux joystick driver


NetBSD USB joystick driver


PS2-Linux native pad


SDL joystick driver

7.5.2. Nestra

Arcade games are incredibly fun, but there are some games that seem to only exist on certain game consoles, such as the original Nintendo Entertainment System (NES) . As with the MAME project, there is software you can use to emulate the NES hardware and play ROMs directly on your computer. Under Linux, the software is Nestra .

Nestra will already be packaged for you depending on your distribution, but if it isn't, you can download and build the source directly from nestra Once installed, using Nestra is as simple as running nestra with the path to the ROM you want to play as an argument. So, to play the original Metroid , you would type:

    $ nestra Metroid.nes

See Figure 7-8.

Figure 7-8. Metroid under Nestra

Nestra key bindings are the same across games and correspond to the standard NES controller (Table 7-4).

Table 7-4. Nestra key mappings



Arrow keys

Arrow pad


Button A

z, x

Button B





Pause, Break



Exit Nestra


Adjust the emulation speed. 1 is the normal speed, 2 is double speed, etc.


Run at half speed


Pause the emulator

Some games, such as Zelda, save games on the game cartridge itself. Since you are dealing with ROMs here, Nestra will place saved games in a file in the directory containing the ROM you are running, or will put the saved games in ~/.nestra if the directory exists.

7.5.3. SNES9x

The NES definitely had a lot of fun games, and when the next generation of Nintendo's consoles was released the Super Nintendo Entertainment System, or SNES many of the classics, such as Super Mario Bros, Zelda, and Metroid, found their way onto the new platform. You can play all of your favorite SNES ROMs under Linux using the Snes9x program.

Snes9x is an SNES emulator that runs on Windows, Linux, Mac OSX, and other platforms. The Linux port is packaged by most distributions, or you can download and build the source from the official Snes9x page at

Once installed, running Snes9x is similar to Nestra simply type snes9x followed by the path to the SNES ROM as an argument. To run Zelda 3, for example, you would type

    $ snes9x zelda3.smc

Unlike Nestra, Snes9x has a large number of options you can pass on the command line. For instance, the -y option enables "TV mode," which scales the image by two and inserts an extra blended pixel between each scan line. The end result of TV mode is a larger, easier-to-read screen that looks more like a regular television screen.

Snes9x uses a standard set of key bindings to correspond to the buttons on an SNES controller. The standard key bindings are shown in Table 7-5.

Table 7-5. Snes9x key mappings




Quit the emulator

Pause, Scroll Lock

Pause the emulator

Up arrow, u

Up direction

Down arrow, j, n

Down direction

Left arrow, h

Left direction

Right arrow, k

Right direction

a, v, q

TL button

z, b, w

TR button

s, m, e

X button

x, ',', r

Y button

d, '.', t

A button

c, y

B button


Start button


Select button

Shift F1-F9

Save the game in one of nine different slots


Restore the saved game in the specified slot

Snes9x has support for joysticks, and by default will scan for /dev/js0, or you can specify the joystick device to use with the -joydev1 argument. You can also control the mapping for the eight different SNES buttons with the -joymap1 and -joymap2 options (for joystick 1 and joystick 2, respectively) followed by the eight different buttons in order. For instance, the default is 0 1 2 3 4 5 6 7, which corresponds to A B X Y TL TR Start Select.

There are so many different options to Snes9x, in fact, that a couple of graphical frontends have been created to make the process of configuring Snes9x easier. Snes9express is an easy-to-use frontend that makes it easy to organize your SNES ROMs and experiment with different settings. You can download the latest version from or use the package that comes with your distribution. Snes9express supports skinning and even includes a skin that makes it look like the original SNES console (Figure 7-9).

Figure 7-9. Snes9express

Click Console Preferences and give snes9express the path to your SNES ROM directory, and then you can click the ROM Selector button for a window to pop up with a full list of available games to run. Select the game you want to play and then click Power to start. The Snes9express window will disappear while the game is running, and reappear once you exit the game.

To change Snes9x settings from within Snes9express, click on the different settings tabs in the the main window. Sound, video, controller, and other settings can be configured in these tabs and the GUI makes it easy to toggle an option, or to change your joystick settings quickly.

Part I: Enjoying and Being Productive on Linux
Part II: System Administration