kid tux logo
Mike Gualtieri Homepage

follow @mlgualtieri on twitter

Build a Raspberry Pi Powered Arcade Machine!

A few months ago I came across the project on Adafuit Retro Gaming with Raspberry Pi, and thought it would make the perfect gift for my brother-in-law.  I finally got around to building it with a few tweaks of my own.

raspberry pi arcade machine

Parts:
  • 1x Raspbery Pi
  • 1x Arcade Joystick
  • 2x Arcade Buttons
  • 1x HDMI to VGA adapter (assuming you don't have an HDMI monitor)
  • 1x USB A / Micro B adapter (for Raspberry Pi power)
  • 1x USB wall wart (for Raspberry Pi power)
Other needs:
  • Monitor or Screen (HDMI or VGA)
  • USB Keyboard (for additional game buttons)
  • A speaker
  • A box/enclosure to mount the controls


Software configuration

If you are familiar with Raspbian, the most popular Raspberry Pi Linux distro, the general setup of the OS is a breeze.  If this is your first go at it, follow the instructions in the Adafruit tutorial above.

Once the base OS is installed, place the Retrogame binary /usr/bin, which will allow you to use the joystick and button controls though the GPIO pins on the Raspberry Pi.  I also edited /etc/rc.local to start the utility on each boot.

Add this line to the bottom of /etc/rc.local:
/usr/bin/retrogame &

Next I set the machine to automatically login on each boot, so it would act more like a kiosk, which requires editing your inittab.

Comment this line and add the following line to your /etc/inittab:
#1:2345:respawn:/sbin/getty 115200 tty1
1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1

I also installed the utility fbi (framebuffer image viewer) so I could display a splash image on boot, and added an init script to load the image.

apt-get update
apt-get install fbi
# To test a splash image:
fbi -a /usr/share/images/desktop-base/default
I got the basic mysplash init script here:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          asplashscreen
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start:     S
# Default-Stop:
# Short-Description: Show custom splashscreen
# Description:       Show custom splashscreen
### END INIT INFO

do_start () {
    /usr/bin/fbi -T 1 -noverbose -a /home/pi/splash.png
    exit 0
}

case "$1" in
  start|"")
    do_start
    ;;
  restart|reload|force-reload)
    echo "Error: argument '$1' not supported" >&2
    exit 3
    ;;
  stop)
    # No-op
    ;;
  status)
    exit 0
    ;;
  *)
    echo "Usage: asplashscreen [start|stop]" >&2
    exit 3
    ;;
esac

:

And we need to make the script executable and add it to the default runlevel so it starts on boot:
chmod 755 /etc/init.d/mysplash
insserv /etc/init.d/mysplash

Next I edited my .bashrc, which is executed upon login (in this case auto-login) to kill the splash image and start up MAME and a basic menu when MAME is exited:

Add to end of /home/pi/.bashrc:
/usr/bin/pkill fbi
/home/pi/mame;/home/pi/menu.sh

This is the basic menu that provides options to restart MAME, halt the system, or exit to a shell.

/home/pi/menu.sh:
#!/bin/bash

clear

echo "Select an option:"
echo "1) Start Jeff-R-Cade"
echo "2) Turn off system"
echo "3) Exit"

read option

if [ "$option" == "1" ]; then
    /home/pi/mame;/home/pi/menu.sh
elif [ "$option" == "2" ]; then
    halt
else
    exit 1
fi
And, don't forget to make it executable:
chmod 755 /home/pi/menu.sh

I also made these general setting changes that you may or may not want/need:


boot/cmdline.txt: Add the parameter "quiet" to kernel command line

boot/config.txt: Uncomment hdmi_force_hotplug=1
This is useful if you are having problems with the HDMI to VGA adapter preventing the screen from being detected.


And you should install MAME (or whatever emulator you choose).  I used a version of MAME built for Raspberry Pi, called MAME4ALL for Pi.  I just downloaded the binary and unpackaged it in /home/pi.  

You will also need ROM's to make the system useful.  I'll leave that to you to find.  Please do not contact me about locating ROMs.


Hardware Configuration

The hardware setup is actually quite simple.  The retrogame utility takes care of all the hardware to software mapping.  If you keep the default setup, then all you need to do is solder some female jumper cables to the joystick and buttons and plug them into the correct GPIO pins on your Raspberry Pi.

This is the default GPIO mapping (graphic courtesy of Adafruit):
raspberry pi arcade gpio pins

And the machine in progress:

raspberry pi arcade

Wrapping Things Up

The hardest part of the project (at least for me) was mounting everything is a nice looking box.  Software is easier for me than woodworking.  But, I like the end result.  I named it Jeff-R-Cade.

mounting raspberry pi arcade machine


raspberry pi arcade box

Posted: Feb 13, 2014

Keyword tags: raspberry piarcademakeelectronics



π