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.