Main > Linux

Guide to getting MAME up and running in linux

(1/3) > >>

loupg:
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 you
After 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.

Overview
These 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 Ubuntu
I’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:

--- Code: ---$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo reboot now

--- End code ---

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.

--- Code: ---$ screen
--- End code ---

1.)   First, let’s get sound working

--- Code: ---$ sudo apt-get install alsa-utils
--- End code ---
   in the next line, replace <username> with the username you setup when you installed Ubuntu.

--- Code: ---$ sudo usermod -a -G audio <username>
--- End code ---

   By default, your volume will be set at 0, let’s turn it up

--- Code: ---$ sudo alsamixer

--- End code ---
   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

--- Code: ---$ sudo usermod -a -G video <username>
$ sudo apt-get install xserver-xorg xinit

--- End code ---

   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.

--- Code: ---$ sudo apt-get install openbox
$ mkdir ~/.config/openbox

--- End code ---

   Now we want to copy PART of a config file in place.  Run this super ugly command:

--- Code: ---$ sed '/<keyboard>/,/<\/keyboard>/d' /etc/xdg/openbox/rc.xml > ~/.config/openbox/rc.xml
--- End code ---

   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.

--- Code: ---$ vim ~/.config/openbox/autostart
--- End code ---

   Add a single line:

--- Code: ---attract &
--- End code ---

   Let’s just make sure we’re back in our home directory before we move forward

--- Code: ---$ cd
--- End code ---

3.)   Now, let’s get all the tools needed to compile MAME

--- Code: ---$ sudo apt-get install unzip build-essential libsdl2-dev libfontconfig1-dev qt5-default libsdl2-ttf-dev
--- End code ---

Compiling MAME
1.) Download the mame source .zip:

--- Code: ---$ wget [url]https://github.com/mamedev/mame/releases/download/mame0191/mame0191s.zip[/url]
--- End code ---
   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

--- Code: ---$ unzip mame0191s.zip
$ unzip mame.zip -d mame
$ cd mame

--- End code ---

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

--- Code: ---$ cd src/
$ wget http://mamestuff.lowtrucks.net/MKChamp/suppression_0191u0.txt
$ patch -p1 -E < suppression_0191u0.txt
$ cd ../

--- End code ---

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

--- Code: ---$ screen
--- End code ---
   to see the current screen sessions, you can run

--- Code: ---$ screen -ls
--- End code ---
   to reconnect to a screen session, run

--- Code: ---$ screen -r <session ID>
--- End code ---

   on to the compiling

--- Code: ---$ make
--- End code ---
   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.

--- Code: ---$ sudo mv mame64 /usr/games/
--- End code ---
   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

--- Code: ---$ cd
--- End code ---

   if it doesn’t exist, make out mame config folder

--- Code: ---$ mkdir .mame
$ cd .mame
--- End code ---
   
   And, let’s create our mame.ini

--- Code: ---$ mame64 -cc
--- End code ---

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.

--- Code: ---$ vim mame.ini
--- End code ---

   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.

--- Code: --- #
# 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

--- End code ---
   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.

--- Code: ---autoboot_delay            0
plugins                   1
plugin                    hiscore

--- End code ---

   Last, assuming we’ve compiled with the nonag patch, let’s disable the game info screen.  Add these lines to the mame.ini file:

--- Code: ---#
# CORE MKChamp OPTIONS
#
skip_gameinfo             1

--- End code ---

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

--- Code: ---$ sudo apt-get install libopenal-dev libsfml-dev libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev libavresample-dev libjpeg-dev
--- End code ---

2.)   Download the attractmode source

--- Code: ---$ wget [url]https://github.com/mickelson/attract/archive/v2.3.0.tar.gz[/url]
--- End code ---

3.)    Expand it

--- Code: ---$ tar -zxvf v2.3.0.tar.gz
--- End code ---

4.) Let’s go ahead and compile the code

--- Code: ---$ cd attract-2.3.0/
$ make
$ sudo make install

--- End code ---

5.) You shouldn’t need the attract source files anymore

--- Code: ---$ cd ..
$ rm -rf attract-2.3.0/
$ rm v2.3.0.tar.gz

--- End code ---

Final steps!
   We’re in the home stretch now

1.)   Let’s make it so Ubuntu automatically logs in as our user on boot

--- Code: ---$ sudo systemctl edit getty@tty1
--- End code ---

   We want to enter three lines of text here (be sure to replace <USERNAME> with your username):

--- Code: ---[Service]
ExecStart=
ExecStart=-/sbin/agetty -a <USERNAME> --noclear %I $TERM

--- End code ---

2.)   Let’s launch AttractMode for the first time.

--- Code: ---$ startx
--- End code ---

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

--- Code: ---$ vim .profile
--- End code ---
   and add the following lines:

--- Code: ---if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
exec startx
fi

--- End code ---

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!

dauntless:
Thank you. Your guide was very helpful and the best out there.  The information you provided is a gold mine and not easy to come by.

ZoOl007:

--- Quote from: loupg on December 21, 2017, 12:14:44 am ---   on to the compiling

--- Code: ---$ make
--- End code ---
   now go take a break for a while, compiling will take quite some time.

--- End quote ---

Thank you for the good write-up. I just wanted to add that you can significantly speed up compilation time by doing make -j$(nproc) in the multi-core age.
The dependencies are git build-essential libsdl2-dev libsdl2-ttf-dev libfontconfig-dev qt5-default

canussie:
Awesome guide...

I purchased a 1500-in-1 cocktail cabinet a few months back, its basically just a PC with JAMMA joysticks plugged into. It came pre loaded with a really crappy win2k install. Being a linux guy I had to idea to install Linux on the box. Came across your post, followed it for the most part, instead I used a Ubuntu 18 i386 ISO. I had to upgrade the kernel, because the 4.4 had issues with USB keyboards... fun times. Anyways long story short, I configured it all up, got the Attractmode and MAME working together, however when I launch Donkey Kong (only game i've test thus far) it seems to be running at about a quarter speed and the audio is lagging. Searching around for stuff I maybe need to configure etc, thought I would use this thread as first cab off the rank incase anyone had some tips!

I did a bit of a write up about how I went about things if anyone is interested:
https://www.aussiearcade.com/forum/arcade/arcade-technical-and-repair-questions/multi-board-discussion-and-help/2111395-linux-on-a-xxxx-in-1-device

dauntless:
I don't know enough about your setup so I'm going to take a wild guess and state what might be the obvious. The computer came with windows 2000 so it probably is from the Pentium 2 - 3 era. It can have anywhere from 233MHz to 1.4GHz cpu and 64MB to 512MB RAM. Ubuntu server needs a minimum of about 1Ghz & 512MB ram. Your hardware might be too old to run the newest version of Linux at full speed without upgrades. Another thing to consider is the version of Mame you are using. The latest version isn't always the best version to use. Mame becomes more accurate and slower with every new release. The best version for you depends on hardware you are using. You should use a version of Mame that was released around the same time as your hardware. You may need to compile an older version than what was listed in the tutorial. You'll also need to have the matching romset for that version of Mame. You can't mix different versions of romsets with different versions of Mame. I hope this helps point you in the right direction unless I typed out what you already knew :)

Navigation

[0] Message Index

[#] Next page

Go to full version