HeroShot2

The Raspberry Pi is great for all sorts of small computing applications — 3D printing servers, in-car computing, and more. But the Pi can also be the beating heart of a classic video arcade machine. And who doesn’t want one of those?

Using a distribution of Raspbian maintained by Shea Silverman called PiPlay, this Weekend Project will have you up and running some of your favorite, classic games of the 8-bit era on your a $35 ARM-based computer in no time.

To keep things simple, we’ll use the Arduino Esplora as our game controller. The Esplora is a unique entry into the Arduino family of microcontrollers. It has a number of control inputs preinstalled on the board, and the layout is familiar to anyone who has held a modern game controller. What’s more, the Esplora shares the same chipset as the Arduino Leonardo, which allows it to emulate a keyboard when plugged into a computer. This makes it pretty ideal for fast, simple gaming.

YouTube player

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Project Steps

Download PiPlay and flash an SD card

PiPlay is a custom distribution of Linux, specifically designed to play arcade and classic ROM images. Head over to the PiPlay software repository http://sourceforge.net/projects/pimame/ and download the latest disk image.

While you’re waiting for the download to complete, it’s a great time to review SD card formatting steps. Many options exist to flash an SDCard, from the command line tool dd to GUI disk utilities. Here are a few options I like:

Windows

Win32 Disk Imager, available at http://sourceforge.net/projects/win32diskimager.

OSX or Linux

Use dd from a terminal window, or if you prefer a GUI, you can use ApplePi-Baker. Of course if you are on Linux, you can also use dd.

Burn the image to your card, and get ready to set up your Pi Arcade!

NOTE: For more documentation on PiPlay, check out their main site — http://pimame.org — though this project tutorial should cover most of your needs.

Configure the Raspberry Pi

The first time you boot your Pi with a PiPlay flashed SD Card, the system boots straight into the emulation hub, bypassing raspi-config. If you’re not familiar, raspi-config is the ncurses-based configuration tool which is ordinarily run at first-boot on the Raspbian distribution.

You’ll still want to take a moment to set up your Pi, ensuring that your keyboard is set up properly for your region, and that you have the full size of your SD Card available to the partition. Thankfully there’s a link straight to the raspi-config in the emulation hub. With a keyboard, use the arrow keys to navigate to the last page to launch it.

First, expand the file system — it’s the first thing you see in the config menu. Next you’ll want to configure your region, so that your keyboard behaves the way you need it to. Go to into internationalization options and set your locale and keyboard settings. Exit the raspi-config dialog, confirm that you want to reboot, and make sure you have a working network connection before heading to the next step.

Install MAME

One of the most robust programs for a home arcade is MAME — Multiple Arcade Machine Emulator.

Navigate to the “Install MAME” icon from the PiPlay menu and select it. Installation will take a few minutes, and then the PiPlay interface will reload.

Set up game ROMs

Once MAME is installed, you’ll be able to load games onto your Raspberry Pi. For MAME and other gaming consoles, the game files are stored in ROM images. These images constitute the software found on an arcade machine’s integrated circuits or a home game console’s cartridge.

CAUTION: While MAME is free to download and use, ROM images are not necessarily free or legal to use. Depending on where you live, owning the original arcade board might put you legally in the clear to download and use the specific ROM image. It is your responsibility to make sure it is legal for you to download and use ROM images.

Fortunately, a small repository of free (to download and use) ROMs is available from MAME’s website. You can find it over at http://mamedev.org.

Once you’ve downloaded a few ROMs to your computer, look at PiPlay in the upper righthand corner of the interface to find the IP address of your Pi. On your computer, type in this address to a web browser to bring up the PiPlay remote manager.

Click on ROM Uploader and select the uploader for AdvMAME. Drop your ROM zip files into the drop window, and allow them to upload.

Finally, you’ll need to scrape the ROMs you just uploaded. This properly installs them for use in the emulator and builds a nice menu interface for them. You can find the ROM scraper in the PiPlay interface on the last page. You can opt to have it search for unscraped ROMs in every emulator, or just the ones of your choosing.

Set up the Esplora as a MAME controller

On your computer, open the Arduino IDE and load the modified Esplora sketch found at http://cdn.makezine.com/make/PiPlayControl.ino. If this is the first time you’re using the Esplora, don’t forget to select it as the target board in the Tools–>Board dropdown menu.

NOTE: If you need to download the Arduino IDE or just a refresher on it, head over to http://arduino.cc/en/Guide/HomePage

The Arduino sketch is an adaptation of the Esplora Kart example sketch; it remaps a few keys to ones commonly used in the MAME and PiPlay interface. Additionally, you’ll custom-map a few of the Esplora’s buttons, which are not mapped in the example sketch.

The joystick control maps to the arrow cursor keys on your keyboard.

The bottom button acts as the Left CTRL key, and the right button is mapped to Left ALT. The left button is the space key, and the top button is the Enter/Return key.

To press Escape (and quit out of a game) flip the Esplora over and right it quickly.

Finally, to press the Tab key, which will allow you to customize the controls for each game in the emulator, slide the linear potentiometer to the right, then quickly back to the left.

Combining the Pi and Esplora

To get started gaming, plug your Esplora into one of the Pi’s USB ports, using a USB A-to-B cable. Select AdvMAME, and load up the game you want to play.

You’ll want to take a moment to configure the game you just loaded by rotating the potentiometer. Make sure you have keys mapped for inserting a coin, Player 1 start, and any critical gameplay controls. Once that’s all sorted, press start and game on!

NOTE: You’ll need to configure the controls for each ROM image.

How could you take this project further? Add a second Esplora for two-player action? Maybe replace the Esplora with an Arduino Leonardo, and wire it up with an arcade stick and buttons? Build your own arcade cabinet? There’s a ton of potential here. Whatever you do, have fun and game on!