Compiling hi-score saving MAME on Ubuntu


I'll admit it - this is more of a "dig this out in five years when I do it again" post. I'm rolling a copy of MAME to install on my Ubuntu HTPC, to compliment the emulator cabinet I keep on my back deck. If you don't do these things for a living, it is never straightforward.



This post is now quite out of date. Please see a new, April 2016 post for high score MAME on Ubuntu Xenial  that is bigger, and better for you.


The last time I compiled a patched MAME was in about 2007, on Windows. I've grown up since those days, and compiling is the sort of thing Linux is rather good at by comparison.

Obtaining the files

Make sure all version numbers are in sync: the version of MAME to match the patch and the .dat. In my case, that meant MAME v0.147. The latest hiscore.dat file at the time of writing is .143, but that's pretty close.

MAME itself lives at, with both Windows binaries and source packages, which is obviously what we want.

The patch to roll high-score-saving support (plus some other nice things) back into MAME is maintained by MKChamp in this legendary thread over at

A hiscore.dat file is needed so your modified version of MAME will read to know which memory addresses contain the high scores for supported games. This file was taken out of MAME a long time ago because it isn't a good fit with the line that MAME is a preservation exercise and not a toy. Grab it from the Unofficial hiscore.dat page.

Preparing Ubuntu for compiling

I needed to grab a few packages before I could successfully compile MAME on my Ubuntu 12.04 (Precise) HTPC.

Shamelessly adapting what I found on Jack David Baucum's blog entry (which provides a good overview of the general process) I ran these installs:

sudo apt-get install build-essential libgtk2.0-dev libgnome2-dev libsdl1.2-dev

I later found I needed this one as well. Perhaps TTF support came after Jack's post, or perhaps he already had the necessary libs.

sudo apt-get install libghc-sdl-ttf-dev

Pesky Windows strikes again

Applying the patch should have been as easy as dropping the hi_147.txt file in the /src directory after unzipping the (source code) archive, but it wasn't.

A dash of fortuitous Googling led me to Arbee's WIP Emporium, where he linked to a line of bash-fu which changes the line-endings on the Windows-generated source files so they can be manipulated safely by a Linux patch binary.

I'll spoil the ending by pasting the command right in here, and saving the download Arbee linked:

find . -type f -not -name uismall.png | xargs perl -pi -e 's/\r\n?/\n/g'

Run that in the /src directory, and then the patch should take nicely:
~/MAME/compile/src$ patch -p1 < hi_147.txt Finally, the compile can run!
~/MAME/compile$ make

A few minutes further down the track and if you are as lucky as me, you'll have a shiny new mame64 binary sitting in your compilation directory just asking to have ROMs fed to it.