EDIT: You may prefer to read this post , for an updated version of MAME, or maybe this page for detailed compile instructions.

Ever since the Raspberry Pi2 came out I’ve been wondering about how it would handle MAME. Not MAME4ALL or AdvanceMAME but the full latest version of MAME (Currently 0.164) I’ve heard people asking about it on various forums and on Reddit. It may be a lot slower they say, but maybe it will be fast enough on the Pi2 that the classics will play?

Got to be worth a shot, I thought. How hard can it be?

I Googled. I found two attempts back in 2012 both fails with no updates. Hmm, maybe not as simple as I thought.

OK lets give it a go…

wget https://github.com/mamedev/mame/releases/download/mame0164/mame0164s.zip mkdir mamepi unzip mame0164s.zip -d mamepi cd mamepi unzip mame.zip make NOWERROR=1 SUBTARGET=arcade NO_X11=1 NO_OPENGL=1

Fail! It seems we need SDL2 and the first version to support Pi2 is 2.0.4 which isn’t released yet, but it’s close so lets grab the RC.

cd sudo apt-get install build-essential libfreeimage-dev libopenal-dev libpango1.0-dev libsndfile-dev libudev-dev libasound2-dev libjpeg8-dev libtiff5-dev libwebp-dev automake wget http://www.libsdl.org/tmp/release/SDL2-2.0.4.tar.gz tar zxvf SDL2-2.0.4.tar.gz cd SDL2-2.0.4 ./autogen.sh ./configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl --host=armv7l-raspberry-linux-gnueabihf make -j 4 sudo make install

That went OK, lets try MAME again

cd cd mamepi make clean make NOWERROR=1 SUBTARGET=arcade NO_X11=1 NO_OPENGL=1

Fail! It needs SDL2_ttf as well sigh, here we go again.

cd wget http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12.tar.gz tar zxvf SDL2_ttf-2.0.12.tar.gz cd SDL2_ttf-2.0.12 ./autogen.sh ./configure make -j 4 sudo make install

That went OK, lets try MAME again

cd cd mamepi make clean make NOWERROR=1 SUBTARGET=arcade NO_X11=1 NO_OPENGL=1

Now we’re getting somewhere, it seems to be compiling ok, but slowly. So I leave it for a few hours and come back to Fail!

Looks like a memory problem, duh!

sudo nano /boot/config.txt

Change gpu_mem=256 to gpu_mem=16

sudo reboot

OK…

cd mamepi make NOWERROR=1 SUBTARGET=arcade NO_X11=1 NO_OPENGL=1

Yes! that did it, it’s going again. Let’s leave it until tomorrow morning.

And…

Fail! Looks like it compiled ok but failed to link

sudo nano /etc/dphys-swapfile

Change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=2048 (The maximum). Now this is going to be in /var/swap and if you are using an SD card, that’s not good, don’t forget to change it back after you are done or you can dramatically shorten the life of your SD card.

sudo reboot

OK…

cd mamepi make NOWERROR=1 SUBTARGET=arcade NO_X11=1 NO_OPENGL=1

Success! It worked! So first the good news, it works. Sound, controller config, every game I tried, all worked.

Now the bad. It’s slow. I was expecting that but wow! even invaders and puckman didn’t run full speed. With overlays and artwork turned on they were unplayable even with auto frameskip. Turning off the artwork stuff and some games are playable if auto frameskip is enabled. adding -sr 11025 to the command line improves a few of the older games and -mt didn’t seem to have any appreciable effect at all.

OK here are the screenshots I took while testing:

Space invaders is slow but it’s playable with frameskip on.

Puckman is almost fast enough to play without frameskip.

Gauntlet II is unplayable.

R-Type is ok with frameskip on but its getting jerky.

R-Type Leo is unplayable.

And just for laughs…

As an exercise it was interesting and it was awesome seeing the Soul Caliber attract mode in slow motion on a $30 computer, but I haven’t ended up with some awesome new emulator for the Raspberry Pi2, sorry guys!

If you want to mess around with it for yourself and save a couple of days of compile time, here is the precompiled binary for MAME. You will still need to compile SDL2.0.4 and SDL2_ttf.