A few years ago I was looking for instructions on how to properly get MAME running in Linux, and most of the information out there is incomplete, out of date, or just difficult to find. I spent a lot of my time simply having to research individual parts of the process, because there wasn’t a single walkthrough on getting everything up and running.
As I went along, I decided to document the process to hopefully make it easier for myself and other. Unfortunately, I lost the instructions I originally wrote up, and didn’t have a lot of desire to go through the entire process again to try to cover every step reasonably thoroughly.
I wrote up my original instructions with Ubuntu 14.04, and MAME 0.16x (don’t remember the exact revision), and was looking at whether or not I wanted to upgrade my MAME machine to 16.04 (yeah, I know, 18.04 is just a few months away,) so I figured this was a good of a time as any to rewrite the instructions.
What these instructions will do for youAfter following these instructions, you should have a reasonably lightweight OS running with MAME and a frontend. The system will be reasonably static, so there should be no need to update anything unless you’re looking to utilize a new feature. Booting the computer will bring you straight into your frontend, with no need to login, or launch anything manually.
Why linux?I spent some time looking at various ways to make the mame machine as lightweight and maintenance free as possible, while still being reasonably easy to implement. My choice came down between taking Windows XP and stripping it down to its bare bones, or starting with a fairly barebones Linux OS and adding what I wanted to actually use. Philosophically, linux worked better for me.
Why Ubuntu Server LTS?I mentioned lightweight, yes, there are far more lightweight ways to go than Ubuntu Server LTS, but I was looking at the tradeoff of lightweight, ease of use, and broad base of support. My first exposure to Linux was Debian, and I like the package management system. I find that Ubuntu is more user friendly than straight Debian, and the server versions are still relatively lightweight. The desktop versions of Ubuntu have far more unneeded stuff built in, and actively tries to keep you from doing things that they don’t think the average user should be doing, so rather than battling against the intended purpose of the desktop version, I’d rather build on top of the server version.
OverviewThese instructions are specifically for installing MAME 0.191, with AttractMode 2.3 on Ubuntu 16.04.3. Other versions of the software will be pretty similar, but you may need to modify things here and there. These steps can also be used as a rough outline on how to get it working for other distros as well, but if you’re using a different distro, then you’ll need to adjust any of the commands and steps to fit your specific environment.
I will try to periodically update these instructions, but don’t expect them to be updated every single time there is an Ubuntu, MAME or AttractMode release. I’ll probably update them when I decide to do an update on my own MAME machine, or when I decide to roll another one.
Installing UbuntuI’m not going to cover every possible screen and option during the Ubuntu install, but I’ll touch on anything that I think might potentially be confusing, or important to choose specific options. Anyone with any Linux experience should be able to rush through the install with ease, and for anyone new to Linux, I think this will make for a fairly good foray into Linux, and introduce you to a lot of the basic concepts of Debian based distros.
I really, really recommend going with an LTS server version, not a desktop version. The desktop version may be very tempting because it has a graphical desktop, but the desktop versions of most linux distros have a lot of extra applications installed that just slow down the computer and take up space, and most of the time it can be really difficult to effectively turn off things like auto-updating. Installing a server version with no desktop environment will allow you to make a lean, mean mame machine that can be left pretty static once you have everything setup. Ideally, you’re going to get everything setup and not really worry about updating mame or the frontend unless there’s a new feature you want to take advantage of.
1.) Get a copy of Ubuntu Server 16.4.3 LTS
https://www.ubuntu.com/download/server, put it on some form of installable media
https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-windows#0, and boot the computer you wish to use for your MAME machine.
2.) Select Install Ubuntu Server from the menu.
3.) Pick the appropriate localization options. I recommend manually picking your keyboard layout as I’ve found Ubuntu sometimes has issues auto-detecting
4.) enter a computer name, username and password when prompted. Don’t bother encrypting your home directory, this isn’t exactly a high security situation.
5.) OK, we’re at the first point where we should pay at least a little attention, partitioning the disks.
I’m going to assume the only OS being installed on this computer is Ubuntu, and that you can use the whole disk. If you’re doing something else, that’s beyond the scope of these instructions.
The default should be “Guided - use entire disk and set up LVM”. This is generally the best option to use, but I have run into a computer where for some reason it just would not work if you used LVM. LVM is nice to use in certain situations, so certainly not 100% necessary. I would go with the default unless you have a specific reason not to do so.
At the time of this writing, I believe the full MAME rom set, with CHDs was somewhere north of 500GB, so using a 1TB drive is probably a good idea. If you plan to have your roms on a separate disk, that’s fine, but I’ll recommend going with at least a 40GB hard drive, to ensure you have enough space for updates, logs, etc.
Be sure to read the screens as you go through this section. Most of them are fine to pick the defaults, but there are two points where it asks you to confirm you really want to proceed, be sure to select yes, as no is the default selection.
6.) For the HTTP proxy, this is generally fine to leave blank unless you need to use a proxy for some reason.
7.) When it asks if you want automatic updates, select “No automatic updates”. We want this system to be as static as possible, automatically installing updates is most likely to cause problems in the future, which we don’t want. We want this whole thing to be “set it and forget it”.
8.) For software selection, I recommend installing the OpenSSH server, and leaving the rest at their defaults (the only other one that should be selected is “standard system utilities”. You can always install the OpenSSH server later if you skip it here, but it gets everything configured for you if you do it at this point. If you install it later, you’ll need to configure OpenSSH yourself.
9.) You want to choose “Yes” when asked about installing GRUB on the master boot record.
10.) Congrats! You’ve just finished installing Ubuntu. Look at you go!
11.) Just one final step before we finish this section. Let’s update our OS to make sure we’re as shiny and new as possible:
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo reboot now
Getting sound and video working, along with setting up our compilers We’ve got some packages that will need to be installed before we can start installing MAME and AttractMode.
I recommend doing the remaining tasks over SSH if you can, I just find it more convenient, but it isn’t 100% necessary.
I really, really recommend using screen for the remaining tasks as well, even if you’re not using ssh. It gives you a persistent session that can run commands even after you walk away from the computer, and certain steps, such as compiling, will take hours.
$ screen
1.) First, let’s get sound working
$ sudo apt-get install alsa-utils
in the next line, replace <username> with the username you setup when you installed Ubuntu.
$ sudo usermod -a -G audio <username>
By default, your volume will be set at 0, let’s turn it up
$ sudo alsamixer
Go through all the audio volume options and turn up anything that needs to be turned up. I actually went with about 50 for the master volume, otherwise I got distortion on the playback, but you can always come back to this and adjust the volumes later.
2.) Let’s get video working
$ sudo usermod -a -G video <username>
$ sudo apt-get install xserver-xorg xinit
Boo, this is stupid, but there appears to be a bug in the current release of Xorg. Apparently we can fix it by using Open Box as a window manager. I will absolutely replace this if I find a better workaround, as this one is annoying.
$ sudo apt-get install openbox
$ mkdir ~/.config/openbox
Now we want to copy PART of a config file in place. Run this super ugly command:
$ sed '/<keyboard>/,/<\/keyboard>/d' /etc/xdg/openbox/rc.xml > ~/.config/openbox/rc.xml
Last but not least, we want attractmode to launch automatically when openbox launches.
You can use any text editor you like, I personally like vim, but a lot of people like nano, or other editors.
$ vim ~/.config/openbox/autostart
Add a single line:
attract &
Let’s just make sure we’re back in our home directory before we move forward
$ cd
3.) Now, let’s get all the tools needed to compile MAME
$ sudo apt-get install unzip build-essential libsdl2-dev libfontconfig1-dev qt5-default libsdl2-ttf-dev
Compiling MAME1.) Download the mame source .zip:
$ wget [url]https://github.com/mamedev/mame/releases/download/mame0191/mame0191s.zip[/url]
NOTE: this command will specifically download MAME v.0.191, be sure to change this command to match the version you want to actually download. You can find the versions at mame.net
2.) Next, extract the .zip files we just downloaded
NOTE: again, modify the commands to match the version of mame you’re compiling
$ unzip mame0191s.zip
$ unzip mame.zip -d mame
$ cd mame
3.) Let’s get rid of the nag screens. I like to get rid of the nag screens because I feel they detract from the arcade experience, but the nag screens do have important information on them, so you may want to keep them intact. If you want to keep the nag screens, skip this step.
NOTE: again, modify the commands to match the version of mame you’re compiling
$ cd src/
$ wget http://mamestuff.lowtrucks.net/MKChamp/suppression_0191u0.txt
$ patch -p1 -E < suppression_0191u0.txt
$ cd ../
4.) Now to compile MAME
NOTE: If you aren’t yet running a screen session for this, I really recommend doing so, as the compile time is really long, and you may need to walk away from the computer for a while, or if you’re doing this over SSH, the SSH session may be interrupted.
To start a screen session, the command is just
$ screen
to see the current screen sessions, you can run
$ screen -ls
to reconnect to a screen session, run
$ screen -r <session ID>
on to the compiling
$ make
now go take a break for a while, compiling will take quite some time.
Hopefully it compiles fine, if not read the error message and use that to figure out what went wrong, usually you need an additional package you don’t yet have installed.
5.) Time to move our mame (or mame64) binary into the correct location.
$ sudo mv mame64 /usr/games/
if you’re running running an x86 system, it will be called mame instead of mame64, so alter the command as needed
Let’s go back to our home directory
$ cd
if it doesn’t exist, make out mame config folder
$ mkdir .mame
$ cd .mame
And, let’s create our mame.ini
$ mame64 -cc
6.) Let’s modify some of the mame.ini options to make mame run the way we want.
I’m not going to go into how to use a command line text editor in ubuntu, so for that, you’re on your own. I prefer vim, but a lot of people like nano.
$ vim mame.ini
First, let’s make sure our paths are correct. You don’t need to use the specific paths I used, but here is how I have mine setup.
#
# CORE SEARCH PATH OPTIONS
#
homepath $HOME
rompath $HOME/mame/roms
hashpath $HOME/.mame/hash
samplepath $HOME/mame/samples
artpath $HOME/mame/artwork
ctrlrpath $HOME/mame/ctrlr
inipath $HOME/.mame;.;ini
fontpath .
cheatpath $HOME/mame/cheat
crosshairpath $HOME/mame/crosshair
pluginspath $HOME/mame/plugins
languagepath $HOME/mame/language
swpath $HOME/mame/software
#
# CORE OUTPUT DIRECTORY OPTIONS
#
cfg_directory $HOME/.mame/cfg
nvram_directory $HOME/.mame/nvram
input_directory $HOME/.mame/inp
state_directory $HOME/.mame/sta
snapshot_directory $HOME/.mame/snap
diff_directory $HOME/.mame/diff
comment_directory $HOME/.mame/comments
#
# CORE OUTPUT DIRECTORY OPTIONS
#
hiscore_directory $HOME/.mame/hi
Next, let’s enable hiscore support. This allows us to save the high scores in games that don’t normally support that. Go down to the CORE MISC OPTIONS section and change the following values (you may not need to change them all, some may already be set correctly.
autoboot_delay 0
plugins 1
plugin hiscore
Last, assuming we’ve compiled with the nonag patch, let’s disable the game info screen. Add these lines to the mame.ini file:
#
# CORE MKChamp OPTIONS
#
skip_gameinfo 1
7.) last but not least
Put your roms in the ~/mame/roms folder
Installing AttractMode Now that we’ve got MAME running, let’s slap a frontend on it.
1.) We need a few more things to be able to properly compile attractmode
$ sudo apt-get install libopenal-dev libsfml-dev libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev libavresample-dev libjpeg-dev
2.) Download the attractmode source
$ wget [url]https://github.com/mickelson/attract/archive/v2.3.0.tar.gz[/url]
3.) Expand it
$ tar -zxvf v2.3.0.tar.gz
4.) Let’s go ahead and compile the code
$ cd attract-2.3.0/
$ make
$ sudo make install
5.) You shouldn’t need the attract source files anymore
$ cd ..
$ rm -rf attract-2.3.0/
$ rm v2.3.0.tar.gz
Final steps! We’re in the home stretch now
1.) Let’s make it so Ubuntu automatically logs in as our user on boot
$ sudo systemctl edit getty@tty1
We want to enter three lines of text here (be sure to replace <USERNAME> with your username):
[Service]
ExecStart=
ExecStart=-/sbin/agetty -a <USERNAME> --noclear %I $TERM
2.) Let’s launch AttractMode for the first time.
$ startx
3.) At this point, you’ll want to configure AttractMode, you should be able to follow the documentation on their website in order to get it all configured for use.
The only one piece I will add to configuring AttractMode is under General > Exit Command, enter “killall openbox” to make sure you can exit back to a command line when you quit out of attract mode.
4.) and last, but not least, let’s make it so we launch X on login. This will essentially allow us to turn on the computer, have it automatically login and start our AttractMode frontend, so no user interaction is required to get into AttractMode after pushing the power button.
One word on editing this last file, I would wait until you’re 100% certain you’re done with making changes to the system.
I also set a static IP on my MAME machine so I can SSH in whenever I need to make changes. This is done in /etc/network/interfaces
Edit the .profile file in your home directory
$ vim .profile
and add the following lines:
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
exec startx
fi
I’m not SUPER happy with the way this works in 16.04, in 14.04 I’m able to get this working a little smoother so you can exit attractmode and have it exit to a command prompt, but that isn’t working in 16.04. I’m also not happy about having to use OpenBox, but it is what it is for now. If/when I figure out a way to make it work a little nicer in 16.04, I’ll update this documentation to reflect that.
Let me know if you run into any typos or mistakes with these instructions. If you see something that could be done in a better way than I outlined, let me know about that too, I’m certainly not perfect, and am always happy to learn.
If you have any questions about any of this, ask away, and good luck!