• Published on | Nov 28, 2012 | by FozzTexx

Attempting MAME 0.147 for Raspberry Pi

I've been on a quest to get a working NES emulator on my Raspberry Pi. By working I mean that it can run full screen and has audio that works both on the analog jack and the HDMI out. I tried out a few and while some can at least display the video, none have working audio.

There have been reports of people getting MAME and MESS to work on the Raspberry Pi, but in digging into it I found out that it's AdvanceMAME and AdvanceMESS, which are over seven years old. If you're much into MAME you'll know that ROMs change often and frequently, and trying to get a romset together that will work with such an ancient MAME could be a challenge.

I decided if I was going to compile MAME from scratch, I might as well attempt the latest version, which right now is 0.147. Unfortunately while I did hack it enough to compile, it doesn't run. Until I get MAME working I don't think there's any point in trying to get MESS working.

While I don't have MAME working yet, I wanted to at least document what I've done to get it to compile and link. When I have time I'll work on it some more, but this might help others to tinker with it too.

I had some issues with compiling on the Raspberry Pi itself, my version only has 256 megs. By adding a ton of swap onto a USB HD I did get a lot further but eventually the swapping crashed the kernel. I ended up setting up a QEMU environment by (mostly) following this guide. If you try it under debian squeeze it won't work because the QEMU is too old to support armhf, but since you're using a static QEMU you can get it from somewhere else and it will work. (I ended up stealing it from an Ubuntu 12 computer.) If you're using a new Raspbian distro, you might get "uncaught target signal 4", you need to comment out the contents of /etc/ld.so.preload.

Get the MAME source from mamedev.org. Unzip the zip inside the zip (Inziption!) and install these packages:

apt-get install libgtk2.0-dev libgconf2-dev libsdl-dev g++-4.7 libsdl-ttf2.0-dev

cd into the mame folder and patch it and then compile it:

patch -p1 < mame.patch
make

It took 3 days to compile it under QEMU. And it still doesn't work. If you run it with no arguments the speakers will pop and the screen will turn black, but I couldn't find a way to exit it and get back to the command line. If you give it the name of a game a ROM, it will just print Segmentation fault and crash.

That's it for now. When I make more progress I'll be sure to update this article.

Join The Discussion

+1  Posted by Adrian Nabarro • Nov.28.2012 at 18.15 • Reply

Hi Chris

I'm following this with a great deal of interest as I await the arrival of my Pi...

I've heard that more recent versions of mame run slower on older hardware as they've massively increased the number of games that they support (but at the expense of performance).

I wonder if you'll have better results working from an older version?

Cheers Adrian

+1  Posted by Sam • Jan.06.2013 at 20.20 • Reply

Some people are saying MAME 0.147 is too intensive to run on Pi but I don't buy it. This machine can play HD video with no problem, surely it can run old games from the 80s and early 90s. I'll be following your progress and will also report any successes I have with this.

+1  Posted by FozzTexx • Jan.06.2013 at 20.27 • Reply

The HD video is actually processed by the Broadcom GPU, not the ARM CPU. The GPU is more powerful than the ARM.

+1  Posted by Sam • Jan.07.2013 at 17.35 • Reply

Bummer. If only someone could hack MAME 0.147 to use the GPU, not the CPU. BTW, I tried compiling on my Raspbian Pi per your instructions, but it eventually bombs out while trying to compile src/emu/cpu/tms57002/tms57002.c. I get assembler error messages saying "undefined local label `.L449'".

+1  Posted by FozzTexx • Jan.07.2013 at 19.29 • Reply

Are you using the correct version of gcc?

+1  Posted by Jeremiah • Feb.01.2013 at 21.04 • Reply

I have had the same result, though I used an altered tiny build to compile support for just one game (seriously improves compile time.)  I compiled on the RPi itself in just a couple hours, IIRC.

To the commenter that said MAME is now slow because of all the supported games; this is not the case.  MAME does not work that way.  Only the drivers needed are loaded at runtime; compiling support for all games does not decrease the speed of any of them.  It is the modern MAME architecture itself that renders modern versions slightly slower.

The single game I wish to emulate isn't even a game that requires lots of CPU: 25pacman.  Certainly the RPi has enough CPU for this.

Anyway, I'm still working on the compile, to determine what is causing the segfault.