Why ?
- Because it's just too cool !
Instructions
- Make sure that you have all the other parts needed
for your Raspberry Pi: power supply, USB microB cable (for power), HDMI or
composite monitor, USB keyboard, mouse and a network connection (a wired Ethernet connection is easier,
but WiFi with a supported USB adapter is possible
with a few additional steps).
- Download the rasbian wheezy distro from http://www.raspberrypi.org/downloads
a) I used the 2013-09-25-wheezy-raspbian.zip from http://downloads.raspberrypi.org/raspbian_latest
b) Unzip the file and note the location of the img file
(2013-09-25-wheezy-raspbian.img).
- Insert the SD card in the card
reader, connect to your computer and figure out which drive it is mapped
to (e.g. E:, F: etc.)
- Download the fedora installer from : http://fedoraproject.org/wiki/Fedora_ARM_Installer#Windows_Vista_.26_7
- Run the fedora-arm-installer-2.exe, and point the
source to the the raspbian wheezy image (from step 2b above) , and the
destination to the SD card drive (from step 3 above)
- Prepare your Raspberry PI to bootup : Insert the
SD card, connect the USB keyboard, HDMI monitor, and Ethernet cable / usb
wireless adapter and then power on the raspberry pi
- If all is ok, the pi should start booting up and
take you to the final configuration prompt
- When the system is started for the first time,
the raspi-config utility runs automatically.
·
You should select
the following options:
·
Expand root
partition (this lets us use the full capacity the SD card).
·
These steps are
optional but recommended:
·
If using an HDMI
monitor, disable overscan.
·
Change hostname.
I called my system “gaming-pi” to distinguish it from other Raspberry Pis
·
already on the
network.
·
Change password
for "pi" user (I ignored this, as I will change this later)
·
Change memory
split. Allocate at least 64 MB to the GPU (I allocated 128 MB as I want faster
graphics)
·
Enable SSH server
(for administration access to the Raspberry Pi over the network).
·
Make sure that
keyboard layout is selected to US (I had trouble with the @ key, and had to
come back and change it)
·
These options
should NOT be selected:
·
Start desktop on
boot (we’ll run X11 manually when we need it).
·
You can always
change any of these options by running “sudo raspi-config” at a later time
·
- Check your audio (I wanted audio out through
hdmi, and it is not enabled / set by default
·
To test if the
hdmi audio is even working or not,
o
cd
/opt/vc/src/hello_pi/
o
./rebuild.sh
o
/opt/vc/src/hello_pi/hello_audio/
/hello_audio.bin 1
·
Finally, to make
this persistent, and pass through to the mame emulator
o
sudo amixer cset
numid=3 2
- Download and install an emulator.
·
Install winscp
and transfer the zip file to /home/pi and unzip it
·
/home/pi/mame4all_pi/mame
is the executable (you will most likely have to do a chmod +x on it)
·
You can transfer
zips of your roms to the /home/pi/mame4all_pi/mame/roms folder and run “/home/pi/mame4all_pi/mame”
to test it out.
·
The controls and
keyboard mappings etc. are in the /home/pi/mame4all_pi/mame/readme.txt file
- You can edit the file .bashrc in your home
directory (/home/pi) to set up
simpler aliases for this, or add the directories to your PATH (remember to
source ./bashrc or reboot for it to take effect)
- Download retrogame
· Download zip from https://github.com/adafruit/Adafruit-Retrogame and scp it to the pi in /home/pi/Adafruit-Retrogame-master
· Make the wired connections from the controls
to the raspberry pi. I used a common ground for almost all connectors
· On the pi, map the GPIO pin to the
action you need. Refer to http://www.ultimarc.com/ipac2.html
and http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/linux/input.h?v=2.6.11.8
to figure out the mame mappings.
o
cd /home/pi/Adafruit-Retrogame-master
o
Edit
the retrogame.c to define your mappings. I have the following mappings (not
that the #’s are the GPIO pin #’s from the raspberry pi)
{ 2, KEY_LEFT }, // P1 Left
{ 3, KEY_RIGHT }, // P1 Right
{ 4, KEY_UP }, // P1 Up
{ 17, KEY_DOWN }, // P1 Down
{ 27, KEY_LEFTCTRL }, // P1 Action 1 (Fire etc.)
{ 22, KEY_LEFTALT }, // P1 Action 2
{ 10, KEY_1 }, // Start 1 Player
{ 9, KEY_2 }, // Start 2 Player
{ 11, KEY_5 }, // Insert Coin 1 (jumped to coin 2 - KEY_6)
{ 18, KEY_D }, // P2 Left
{ 23, KEY_G }, // P2 Right
{ 24, KEY_R }, // P2 Up
{ 25, KEY_F }, // P2 Down
{ 8, KEY_A }, // P2 Action 1
{ 7, KEY_S } // P2 Action 2
o
make
· To test this out
o
sudo
modprobe uinput
o
sudo
./retrogame
· To make this persistent across reboots
o
sudo
sh -c 'echo uinput >> /etc/modules'
o sudo nano
/etc/rc.local
o
Before
the final “exit 0” line, insert this line:
§ /home/pi/Adafruit-Retrogame-master/retrogame
&
· Setup additional user – mainly for winscp / transfer
in background
o
Check groups for
user pi
§ pi@gamingpi ~ $ sudo groups
§ pi@gamingpi ~ $ sudo su -
§ root@gamingpi:~# groups pi
§ pi : pi adm dialout cdrom sudo audio video plugdev
games users netdev input indiecity spi gpio
o
Add the new user
“pi2”
§ root@gamingpi:~# useradd pi2
o
Add pi2 to all
the groups that pi belongs to
§ root@gamingpi:~# adduser pi2 pi
§ root@gamingpi:~# adduser
pi2 adm
§ Repeat for all groups…
o Change password for user
pi2
§ sudo passwd pi2
o
Create home
directory for user pi2
§ mkdir /home/pi2
§ chown /home/pi2 pi2
13. Setup auto login
· Step
1: Open a terminal session and edit inittab file.
sudo nano
/etc/inittab
· Step 2: Disable the getty program.
Navigate to the following line in inittab
And add a # at the beginning of the line to comment it out
Navigate to the following line in inittab
1:2345:respawn:/sbin/getty 115200 tty1And add a # at the beginning of the line to comment it out
#1:2345:respawn:/sbin/getty 115200 tty1
· Step 3: Add login program to inittab.
Add the following line just below the commented line
This will run the login program with pi user and without any authentication
Add the following line just below the commented line
1:2345:respawn:/bin/login
-f pi tty1 </dev/tty1 >/dev/tty1 2>&1This will run the login program with pi user and without any authentication
14. Do overclocking for better graphics performance
· Overclocking is supported by the Raspberry Foundation.
· My overclocking settings which work well, (/boot/config.txt)
{{{
arm_freq=900
core_freq=300
sdram_freq=500
}}}
15. Start the mame to autolaunch at login
· Step 1: Open a terminal session and edit the file /etc/profilesudo nano /etc/profile
· Step 2: Add the following line to the end of the file #only run the gaming emulator if user pi logs on locally on console
if [ `whoami` == "pi" ] && [ `tty` == '/dev/tty1' ] ; then
/home/pi/mame4all_pi/mame
fi
End Result
Precautions
- Always use a multimeter to check the voltages and inputs vs outputs
- I fried 2 raspberry PI's to get the coin slot working... I kept wiring the leds (which were outputs) to the raspberry pi inputs, and the over voltage kept frying the pi's beofre i got wiser and got to the basics....






