Skip to main content

Raymii.org Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

Raspberry Pi Arcade Machine

Published: 03-05-2015 | Author: Graham Morrison | Text only version of this article


Table of Contents


This article was originaly published in Linux Voice, issue 2, May 2014.This issue is now available under a Creative Commons BY-SA license. In anutshell: you can modify and share all content from the magazine (apart fromadverts), even for commercial purposes, providing you credit Linux Voice as theoriginal source, and retain the same license.

This remix is converted manually to Markdown and HTML for ease of archiving andcopy-pasting.

If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

Other converted Linux Voice articles can be found here.


Relive the golden majesty of the 80s with a little help from a marvel of thecurrent decade.

Arcade Machine

WHAT YOU'LL NEED

The 1980s were memorable for many things; the end of the cold war, a carbonateddrink called Quatro, the Korg Polysix synthesiser and the Commodore 64. But to acertain teenager, none of these were as potent, or as perhaps familiarlyillicit, as the games arcade. Enveloped by cigarette smoke and a barrage of8-bit sound effects, they were caverns you visited only on borrowed time: 50pence and a portion of chips to see you through lunchtime while you honed yourskills at Galaga, Rampage, Centipede, Asteroids, Ms Pacman, Phoenix, R-Rype,Donkey Kong, Rolling Thunder, Gauntlet, Street Fighter, Outrun, Defender... Thelist is endless.

These games, and the arcade machine form factor that held them, are just ascompelling today as they were 30 years ago. And unlike the teenage version ofyourself, you can now play many of them without needing a pocket full of change,finally giving you an edge over the rich kids and their endless 'Continues'.

It's time to build your own Linux-based arcade machine and beat that old highscore.

We're going to cover all the steps required to turn a cheap shell of an arcademachine into a Linux-powered multi-platform retro games system. But that doesn'tmean you've got to build the whole system at the same scale. You could, forexample, forgo the large, heavy and potentially carcinogenic hulk of the cabinetitself and stuff the controlling innards into an old games console or an evensmaller case. Or you could just as easily forgo the diminutive Raspberry Pi andreplace the brains of your system with a much more capable Linux machine. Thismight make an ideal platform for SteamOS, for example, and for playing some ofits excellent modern arcade games.

Over the next few pages we'll construct a Raspberry Pi-based arcade machine, butyou should be able to see plenty of ideas for your own projects, even if theydon't look just like ours. And because we're building it on the staggeringlypowerful MAME, you'll be able to get it running on almost anything.

Pi Arcade

We did this project before the model B+ came out. It should all work exactly thesame on the newer board, and you should be able to get by without a powered USBHub.

Disclaimer

One again we're messing with electrical components that could cause you a shock.Make sure you get any modifications you make checked by a qualified electrician.We don't go into any details on how to obtain games, but there are legal sourcessuch as old games releases and newer commercial titles based on the MAMEemulator.

Step 1: The Cabinet

The cabinet itself is the biggest challenge. We bought an old two-player BubbleBobble machine from the early 90s from eBay. It cost GPB 220 delivered in theback of an old estate car. The prices for cabinets like these can vary. We'veseen many for less than GPB 100. At the other end of the scale, people paythousands for machines with original decals on the side.

There are two major considerations when it comes to buying a cabinet. The firstis the size: These things are big and heavy. They take up a lot of space and ittakes at least two people to move them around. If you've got the money, you canbuy DIY cabinets or new smaller form-factors, such as cabinets that fit ontables. And cocktail cabinets can be easier to fit, too.

Cabinet

Cabinets can be cheap, but they're heavy. Don't lift them on your own. Olderones may need some TLC, such as a re-spray and some repair work.

One of the best reasons for buying an original cabinet, apart from getting amuch more authentic gaming experience, is being able to use the originalcontrols. Many machines you can buy on eBay will be for two concurrent players,with two joysticks and a variety of buttons for each player, plus the player oneand player two controls. For compatibility with the widest number of games, we'drecommend finding a machine with six buttons for each player, which is a commonconfiguration. You might also want to look into a panel with more than twoplayers, or one with space for other input controllers, such as an arcadetrackball (for games like Marble Madness), or a spinner (Arkanoid). These can beadded without too much difficulty later, as modern USB devices exist.

Controls are the second, and we'd say most important consideration, because it'sthese that transfer your twitches and tweaks into game movement. What you needto consider for when buying a cabinet is something called JAMMA, an acronym forJapan Amusement Machinery Manufacturers. JAMMA is a standard in arcade machinesthat defines how the circuit board containing the game chips connects to thegame controllers and the coin mechanism. It's an interface conduit for all thecables coming from the buttons and the joysticks, for two players, bringing theminto a standard edge connector. The JAMMA part is the size and layout of thisconnector, as it means the buttons and controls will be connected to the samefunctions on whichever board you install so that the arcade owner would onlyhave to change the cabinet artwork to bring in new players.

But first, a word of warning: the JAMMA connector also carries the 12V powersupply, usually from a power unit installed in most arcade machines. Wedisconnecting the power supply completely to avoid damaging anything with awayward short-circuit or dropped screwdriver. We don't use any of the powerconnectors in any further stage of the tutorial.

JAMMA

Step 2: J-PAC

What's brilliant is that you can buy a device that connects to the JAMMAconnector inside your cabinet and a USB port on your computer, transforming allthe buttons presses and keyboard movements into (configurable) keyboard commandsthat you can use from Linux to control any game you wish. This device is calledthe J-Pac (www.ultimarc.com/jpac.html - approximately 54 GPB).

Its best feature isn't the connectivity; it's the way it handles and convertsthe input signals, because it's vastly superior to a standard USB joystick.Every input generates its own interrupt, and there's no limit to the number ofsimultaneous buttons and directions you can press or hold down. This is vitalfor games like Street Fighter, because they rely on chords of buttons beingpressed simultaneously and quickly, but it's also essential when delivering thekilling blow to cheating players who sulk and hold down all their own buttons.Many other controllers, especially those that create keyboard inputs, arerestricted by their USB keyboard controllers to six inputs and a variety of Alt,Shift and Ctrl hacks. The J-Pac can also be connected to a tilt sensor and evensome coin mechanisms, and it works in Linux without any pre-configuration.

Another option is a similar device called an I-Pac. It does the same thing asthe J-Pac, only without the JAMMA connector. That means you can't connect yourJAMMA controls, but it does mean you can design your own controller layout andwire each control to the I-Pac yourself. This might be a little ambitious for afirst project, but it's a route that many arcade aficionados take, especiallywhen they want to design a panel for four players, or one that incorporates manydifferent kinds of controls. Our approach isn't necessarily one we'd recommend,but we re-wired an old X-Arcade Tankstick control panel that suffered from inputcontention, replaced the joysticks and buttons with new units and connected itto a new JAMMA harness, which is an excellent way of buying all the cables youneed plus the edge connector for a low price (GPB 8).

j-pac

Our J-Pac in situ. The blue and red wires on the right connect to the extra 1-and 2-player buttons on our cabinet.

Whether you choose an I-Pac or a J-Pac, all the keys generated by both devicesare the default values for MAME. That means you won't have to make any manualinput changes when you start to run the emulator. Player 1, for example, createscursor up, down, left and right as well as left Ctrl, left ALT, Space and leftShift for fire buttons 1-4. But the really useful feature, for us, is the two-button shortcuts. While holding down the player 1 button, you can generate the Pkey to pause the game by pulling down on the player 1 joystick, adjust thevolume by pressing up and enter MAME's own configuration menu by pushing right.These escape codes are cleverly engineered to not get in the way of playinggames, as they're only activated when holding down the Player 1 button, and theyenable you to do almost anything you need to from within a running game. You cancompletely reconfigure MAME, for example, using its own menus, and change inputassignments and sensitivity while playing the game itself.

Finally, holding down Player 1 and then pressing Player 2 will quit MAME, whichis useful if you're using a launch menu or MAME manager, as these managelaunching games automatically, and let you get on with playing another game asquickly as possible.

We took a rather cowardly route with the screen, removing the original, bulkyand broken CRT that came with the cabinet and replacing it with a low-cost LCDmonitor. This approach has many advantages. First, the screen has HDMI, so itwill interface with a Raspberry Pi or a modern graphics card without anydifficulty. Second, you don't have to configure the low-frequency update modesrequired to drive an arcade machine's screen, nor do you need the specificgraphics hardware that drives it. And third, this is the safest option becausean arcade machine's screen is often unprotected from the rear of a case, leavingvery high voltages inches away from your hands. That's not to say you shouldn'tuse a CRT if that's the experience you're after - it's the most authentic way toget the gaming experience you're after, but we've fined-tuned the CRT emulationenough in software that we're happy with the output, and we're definitelyhappier not to be using an ageing CRT.

You might also want to look into using an older LCD with a 4:3 aspect ratio,rather than the widescreen modern options, because 4:3 is more practical forplaying both vertical and horizontal games. A vertical shooter such as Raiden,for example, will have black bars on either side of the gaming area if you use awidescreen monitor. Those black bars can be used to display the gameinstructions, or you could rotate the screen 90 degrees so that every pixel isused, but this is impractical unless you're only going to play vertical games orhave easy access to a rotating mount.

Mounting a screen is also important. If you've removed a CRT, there's nowherefor an LCD to go. Our solution was to buy some MDF cut to fit the space wherethe CRT was. This was then screwed into position and we fitted a cheap VESAmounting plate into the centre of the new MDF. VESA mounts can be used by thevast majority of screens, big and small. Finally, because our cabinet wasfronted with smoked glass, we had to be sure both the brightness and contrastwere set high enough.

Step 3: Installation

With the large hardware choices now made, and presumably the cabinet close towhere you finally want to install it, putting the physical pieces together isn'tthat difficult. We safely split the power input from the rear of the cabinet andwired a multiple socket into the space at the back. We did this to the cableafter it connects to the power switch.

Power Supply

Nearly all arcade cabinets have a power switch on the top-right surface, butthere's usually plenty of cable to splice into this at a lower point in thecabinet, and it meant we could use normal power connectors for our equipment.Our cabinet has a fluorescent tube, used to backlight the top marquee on themachine, connected directly to the power, and we were able to keep thisconnected by attaching a regular plug. When you turn the power on from thecabinet switch, power flows to the components inside the case - your RaspberryPi and screen will come on, and all will be well with the world.

The J-Pac slides straight into the JAMMA interface, but you may also have to doa little manual wiring. The JAMMA standard only supports up to three buttons foreach player (although many unofficially support four), while the J-Pac canhandle up to six buttons. To get those extra buttons connected, you need toconnect one side of the button's switch to GND fed from the J-Pac with the otherside of the switch going into one of the screw-mounted inputs in the side of theJ-Pac. These are labelled 1SW4, 1SW5, 1SW6, 2SW4, 2SW5 and 2SW6. TheJ-Pac also includes passthrough connections for audio, but we've found this tobe incredibly noisy. Instead, we wired the speaker in our cabinet to an oldSoundBlaster amplifier and connected this to the audio outputs on the RaspberryPi. You don't want audio to be pristine, but you do want it to be loud enough.

Insides

Our Raspberry Pi is now connected to the J-Pac on the left and both the screenand the USB hub.

The J-Pac or I-Pac then connects to your PC or Raspberry Pi using a PS2-to-USBcable, which should also be used to connect to a PS2 port on your PC directly.There is an additional option to use an old PS2 connector, if your PC is oldenough to have one, but we found in testing that the USB performance isidentical. This won't apply to the PS2-less Raspberry Pi, of course, and don'tforget that the Pi will also need powering. We always recommend doing so from acompatible powered hub, as a lack of power is the most common source ofRaspberry Pi errors. You'll also need to get networking to your Raspberry Pi,either through the Ethernet port (perhaps using a powerline adaptor hidden inthe cabinet), or by using a wireless USB device. Networking is essential becauseit enables you to reconfigure your PI while it's tucked away within the cabinet,and it also enables you to change settings and perform administration taskswithout having to connect a keyboard or mouse.

Coin Mechanism

In the emulation community, getting your coin mechanism to work with youremulator was often considered a step too close to commercial production. Itmeant you could potential charge people to use your machine. Not only would thisbe wrong, but considering the provenance of many of the games you run on yourown arcade machine, it could also be illegal. And it's definitely against thespirit of emulation. However, we and many other devotees thinking that a workingcoin mechanism is another step closer to the realism of an arcade machine, andis worth the effort in recreating the nostalgia of an old arcade. There'snothing like dropping a 10p piece into the coin tray and to hear the sound ofthe credits being added to the machine. It's not actually that difficult. Itdepends on the coin mechanism in your arcade machine and how it sends a signalto say how many credits had been inserted. Most coin mechanisms come in twoparts. The large part is the coin acceptor/validator. This is the physical sideof the process that detects whether a coin is authentic, and determines itsvalue. It does this with the help of a credit/logic board, usually attached viaa ribbon cable and featuring lots of DIP switches. These switches are used tochange which coins are accepted and how many credits they generate.

Coins

Our coin mechanism is a Mars MS111, common in the UK in the early 90s.

It's then usually as simple as finding the output switch, which is triggeredwith a credit, and connecting this to the coin input on your JAMMA connector, ordirectly onto the J-Pac. Our coin mechanism is a Mars MS111, common in the UK inthe early 90s, and there's plenty of information online about what each of theDIP switches do, as well as how to programme the controller for newer coins. Wewere also able to wire the 12V connector from the mechanism to a small light forbehind the coin entry slot.

Step 4: Software

PiMAME

PiMAME has a nifty web interface allowing you to remotely install new games

MAME is the only viable emulator for a project of this scale, and it nowsupports many thousands of different games running on countless differentplatforms, from the first arcade machines through to some more recent ones. It'sa project that has also spawned MESS, the multi-emulator super system, whichtargets platforms such as home computers and consoles from the 80s and 90s.

Configuring MAME could take a six-page article in itself. It's a complex,sprawling, magnificent piece of software that emulates so many CPUs, so manysound devices, chips, controllers with so many options, that like MythTV, younever really stop configuring it.

But there's an easier option, and one that's purpose-built for the Raspberry Pi.It's called PiMAME. This is both a distribution download and a script you canrun on top of Raspbian, the Pi's default distribution. Not only does it installMAME on your Raspberry Pi (which is useful because it's not part of any of thedefault repositories), it also installs a selection of other emulators alongwith front-ends to manage them. MAME, for example, is a command-line utilitywith dozens of options. But PiMAME has another clever trick up its sleeve - itinstalls a simple web server that enables you to install new games through abrowser connected to your network. This is a great advantage, because gettinggames into the correct folders is one of the trials of dealing with MAME, and italso enables you to make best use of whatever storage you've got connected toyour Pi. Plus, PiMAME will update itself from the same script you use to installit, so keeping on top of updates couldn't be easier. This could be especiallyuseful at the moment, as at the time of writing the project was on the cusp of amajor upgrade in the form of the 0.8 release. We found it slightly unstable inearly March, but we're sure everything will be sorted by the time you read this.

The best way to install PiMAME is to install Raspbian first. You can do thiseither through NOOBS, using a graphical tool from your desktop, or by using thedd command to copy the contents of the Raspbian image directly onto your SDcard. As we mentioned in last month's BrewPi tutorial, this process has beendocumented many times before, so we won't waste the space here. Just installNOOBS if you want the easy option, following the instructions on the RaspberryPi site. With Raspbian installed and running, make sure you use theconfiguration tool to free the space on your SD card, and that the system is upto date (sudo apt-get update; sudo apt-get upgrade). You then need to makesure you've got the git package already installed. Any recent version ofRaspbian will have installed git already, but you can check by typing sudo apt-get install git just to check.

You then have to type the following command to clone the PiMAME installer fromthe project's GitHub repository:

git clone https://github.com/ssilverm/pimame_installer

After that, you should get the following feedback if the command works:

Cloning into 'pimame_installer'...remote: Reusing existing pack: 2306, done.remote: Total 2306 (delta 0), reused 0 (delta 0)Receiving objects: 100% (2306/2306), 4.61 MiB | 11 KiB/s, done.Resolving deltas: 100% (823/823), done.

This command will create a new folder called 'pimame_installer', and the nextstep is to switch into this and run the script it contains:

cd pimame_installer/sudo ./install.sh

And that's all there is to the installation. After rebooting your Pi, you willbe automatically logged in and the PiMAME launch menu will appear. It's a great-looking interface in version 0.8, with photos of each of the platformssupported, plus small red icons to indicate how many games you've gotinstalled.This should now be navigable through your controller. If you want tomake sure the controller is correctly detected, use SSH to connect to your Piand check for the existence of /dev/input/by-id/usb-UltimarcI-PACUltimarc_I-PAC-event-kbd.

The default keyboard controls will enable you to select what kind of emulatoryou want to run on your arcade machine. The option we're most interested in isthe first, labelled 'AdvMAME', but you might also be surprised to see anotherMAME on offer, MAME4ALL. MAME4ALL is built specifically for the Raspberry Pi,and takes an old version of the MAME source code so that the performance of theROMS that it does support is optimal. This makes a lot of sense, because there'sno way your Pi is going to be able to play anything too demanding, so there's noreason to belabour the emulator with unneeded compatibility. All that's left todo now is get some games onto your system (see the boxout below), and have fun!

Boxout 1 - Copying games to your arcade machine

up1

Open the IP address of your arcade machine in a web browser. You can find the IPaddress from the Pi by selecting the Tools menu.

up2

After clicking on ROM Uploader, choose the destination emulator for your game.This will then open a new upload page.

up3

Dragging the file onto the page didn't work for us, but if you click inside thepage a file requester lets you choose the file.

Tags: arcade, articles, cabinet, emulation, linux-voice, linux-voice-issue-2-2014, mame, raspberry-pi