MAME

A few years ago I built a full-size MAME cabinet. At its core is an old Gateway G6 Pentium 2 running Windows 98. I’m lucky it still powers up. Knowing failure is imminent I needed to find a replacement.

I started experimenting with the Raspberry Pi a few months ago. First I built a XBMC media server but it never performed as well or could steam back as many formats as my HP MicroServer with XBMC. So next I built a music streaming device I could plug into anything and stream music to it from my PC or iPad. Ok well thats cool, but what else is there? Turns out there are lots of working emulators for the Pi, including MAME.

Getting MAME installed on the Pi was too easy. Download Raspbian, fire up the Pi Store, install MAME, copy in a couple of ROMs, done. A couple of Google searches later I had bluetooth working, CWiid installed, and was able to discover Wiimotes.

2013-07-16-20-04-27

What I wasn’t able to find was the magic glue that takes the Wiimote’s output and turns it into a key press that MAME can interprate. In about an hour I had the solution, wminput. wminput lets you map a button on the Wiimote to a keypress in any app. A few tweaks to a config file and I had a fully working Wiimote controller for MAME.

This is my mameplayer1 key definition file:

# mameplayer1
# buttons
Wiimote.A = KEY_LEFTSHIFT
Wiimote.B = KEY_SPACE
Wiimote.Up = KEY_LEFT
Wiimote.Down = KEY_RIGHT
Wiimote.Left = KEY_DOWN
Wiimote.Right = KEY_UP
Wiimote.Minus = KEY_5
Wiimote.Plus = KEY_1
Wiimote.Home = KEY_ESC
Wiimote.1 = KEY_LEFTCTRL
Wiimote.2 = KEY_LEFTALT
Plugin.led.Led1 = 1

And here’s how you kick off wminput:

wminput -c /usr/local/bin/indiecity/InstalledApps/mame4all_pi/Full/mameplayer1 -d &

To sync your Wiimote, just hit buttons 1 + 2 at the same time. All the blinky lights should flash for a few seconds, followed by Led1 staying solid blue.

Then you can fire up MAME:

/usr/local/bin/indiecity/InstalledApps/mame4all_pi/Full/
./mame

and your off. If you used my config, all Wiimote buttons should work inside MAME, even home will get you back to the main screen.

One last step. I like purpose-built stuff. You plug it in, it does a job. Since eventually this rig will live inside a cabinet I need complete automation. In Debian Linux this can be accomplished (somewhat hackingly) by editing /etc/rc.local, and making it executable so Raspbian’s init system will invoke it on boot. This will accomplish 2 things:

1) Start wminput in daemon mode with a config file specifically built for MAME, and

2) Launch directly into MAME4All.

In my /etc/rc.local, I call another script that starts the wminput daemon and fires up MAME. That way MAME is ready and waiting for you to sync your Wiimote and chose a ROM to play:

/usr/local/bin/indiecity/InstalledApps/mame4all_pi/Full/mame-wii.sh

And here’s mame-wii.sh:

#!/bin/bash
wminput -c /usr/local/bin/indiecity/InstalledApps/mame4all_pi/Full/mameplayer1 -d &
cd /usr/local/bin/indiecity/InstalledApps/mame4all_pi/Full/
./mame

So with a little digging I’ve built a really awesome little emulation station that consumes a fraction of the amount of power my PII Gateway does and is completely silent, oh and until it does get moved inside my cabinet, I can use a Wiimote to play Turtles!

2013-07-16-19-59-55