Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up --- Bug Reports --- Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Guide to getting MAME up and running in linux  (Read 19342 times)

0 Members and 2 Guests are viewing this topic.

loupg

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 51
  • Last login:December 26, 2021, 06:20:34 pm
Guide to getting MAME up and running in linux
« on: December 21, 2017, 12:14:44 am »
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: [Select]
$ 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.
Code: [Select]
$ screen
1.)   First, letís get sound working
Code: [Select]
$ sudo apt-get install alsa-utils   in the next line, replace <username> with the username you setup when you installed Ubuntu.
Code: [Select]
$ sudo usermod -a -G audio <username>
   By default, your volume will be set at 0, letís turn it up
Code: [Select]
$ 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
Code: [Select]
$ 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.
Code: [Select]
$ 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:
Code: [Select]
$ 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.
Code: [Select]
$ vim ~/.config/openbox/autostart
   Add a single line:
Code: [Select]
attract &
   Letís just make sure weíre back in our home directory before we move forward
Code: [Select]
$ cd
3.)   Now, letís get all the tools needed to compile MAME
Code: [Select]
$ sudo apt-get install unzip build-essential libsdl2-dev libfontconfig1-dev qt5-default libsdl2-ttf-dev
Compiling MAME
1.) Download the mame source .zip:
Code: [Select]
$ 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
Code: [Select]
$ 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
Code: [Select]
$ 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
Code: [Select]
$ screen   to see the current screen sessions, you can run
Code: [Select]
$ screen -ls   to reconnect to a screen session, run
Code: [Select]
$ screen -r <session ID>
   on to the compiling
Code: [Select]
$ 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.
Code: [Select]
$ 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
Code: [Select]
$ cd
   if it doesnít exist, make out mame config folder
Code: [Select]
$ mkdir .mame
$ cd .mame
   
   And, letís create our mame.ini
Code: [Select]
$ 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.
Code: [Select]
$ 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.
Code: [Select]
#
# 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.
Code: [Select]
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:
Code: [Select]
#
# 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
Code: [Select]
$ 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
Code: [Select]
$ wget [url]https://github.com/mickelson/attract/archive/v2.3.0.tar.gz[/url]
3.)    Expand it
Code: [Select]
$ tar -zxvf v2.3.0.tar.gz
4.) Letís go ahead and compile the code
Code: [Select]
$ cd attract-2.3.0/
$ make
$ sudo make install

5.) You shouldnít need the attract source files anymore
Code: [Select]
$ 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
Code: [Select]
$ sudo systemctl edit getty@tty1
   We want to enter three lines of text here (be sure to replace <USERNAME> with your username):
Code: [Select]
[Service]
ExecStart=
ExecStart=-/sbin/agetty -a <USERNAME> --noclear %I $TERM

2.)   Letís launch AttractMode for the first time.
Code: [Select]
$ 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
Code: [Select]
$ vim .profile   and add the following lines:
Code: [Select]
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!
« Last Edit: December 27, 2017, 01:58:14 pm by loupg »

dauntless

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:Today at 04:40:39 am
  • I want to build my own arcade controls!
Re: Guide to getting MAME up and running in linux
« Reply #1 on: November 06, 2018, 05:07:29 pm »
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

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 161
  • Last login:August 02, 2020, 12:03:38 pm
    • RGBcommander
Re: Guide to getting MAME up and running in linux
« Reply #2 on: November 09, 2018, 12:33:45 pm »
   on to the compiling
Code: [Select]
$ make   now go take a break for a while, compiling will take quite some time.

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

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 1
  • Last login:February 28, 2020, 05:51:54 pm
  • I want to build my own arcade controls!
Re: Guide to getting MAME up and running in linux
« Reply #3 on: February 27, 2020, 01:03:32 am »
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

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:Today at 04:40:39 am
  • I want to build my own arcade controls!
Re: Guide to getting MAME up and running in linux
« Reply #4 on: June 11, 2020, 07:51:11 pm »
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 :)

ddr

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 6
  • Last login:June 11, 2020, 08:20:09 pm
Re: Guide to getting MAME up and running in linux
« Reply #5 on: June 11, 2020, 08:20:09 pm »
When mine was doing that it was the audio.  My notes are at https://github.com/DanRoscigno/mame-attractmode-cab/blob/master/README.md#setup-sound

keilmillerjr

  • Trade Count: (+5)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1846
  • Last login:January 01, 2021, 09:16:53 pm
  • Web Developer.
Re: Guide to getting MAME up and running in linux
« Reply #6 on: June 13, 2020, 06:44:46 am »
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

Try mame 0.106 or older. Video changes were made that will require more computing power.

dauntless

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:Today at 04:40:39 am
  • I want to build my own arcade controls!
Re: Guide to getting MAME up and running in linux
« Reply #7 on: March 11, 2022, 06:36:26 pm »
It's been 4 years since I setup a mame machine from scratch. This guide helped refresh my memory. Double Thanks :)

dauntless

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:Today at 04:40:39 am
  • I want to build my own arcade controls!
Re: Guide to getting MAME up and running in linux
« Reply #8 on: April 08, 2022, 06:48:03 pm »
Updated for Ubuntu 21.10 / MAME 0.240 / Attract-Mode 2.6.2

I built a new system with new hardware for a newer version of MAME (0.240). To support the new hardware I needed new drivers, and thus a more recent version of Ubuntu with a newer kernel. The process is almost the same as the original guide user loupg wrote. However getting this up and running with Ubuntu 21.10 had its own set of new challenges. Most of what I had to do specifically for 21.10 will likely apply to 22.04 when its released. Other than what I detailed below the rest of loupg's guide still applies. I thought I should write this down before I completely forget as it might help you. After figuring it all out everything is working. With a newer MAME there is some additional new games and a lot of bug fixes for existing ones. This kind of setup is great because it gets rid of the windows bloat. Also with Linux you don't have to worry about Window's licensing, or Microsoft phoning home, and killing your system with forced updates.

XORG Installation

Starting with Ubuntu 20.04 Gnome seems to be bundled with Xorg. I want Openbox and not Gnome. I was freaking out when my Openbox looked like Gnome because it wasn't actually Openbox running. What kind of OS gives you Gnome when you want Openbox? The whole point of this setup is to get away from Gnome and not run a full desktop environment. To avoid Gnome you have to install the following packages separately in this exact order.

Code: [Select]
sudo apt-get install xserver-xorg-core
sudo apt-get install openbox
sudo apt-get install xinit

If you dare try and install something else like terminator terminal emulator for your Openbox it will download gnome and the gnome desktop will get installed and you will need to purge it. Be careful. Ubuntu 21.10 likes to install gnome any chance it gets.

Compiling MAME 0.240

MAME source files now come in self extracting 7zip Windows EXEs. Unzip can't handle this. You will need to install p7Zip to extract it.

Code: [Select]
sudo apt-get install p7zip
Download and extract the source code.

Code: [Select]
wget "https://github.com/mamedev/mame/releases/download/mame0240/mame0240s.exe"
7z x mame0240s.exe -omame/

MAME has some missing dependencies. qt5-default is deprecated in 21.10. 20.04 looks like the last version to support it. The way around this is to install all of qt5-default's dependencies with ...

Code: [Select]
sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
You can than install the rest of the prerequisites for compiling the newer MAME 0.240 on Ubuntu 21.10.

Code: [Select]
sudo apt-get install git build-essential python libsdl2-dev libsdl2-ttf-dev libfontconfig-dev libpulse-dev
Compiling Attract-Mode 2.6.2

Attract-Mode needs alternative dependencies. libavresample-dev is deprecated in Ubuntu 21.10. 20.04 looks like the last version to support it. Going forward you will need to use libswresample-dev instead. These are the new dependencies to install and compile Attract-Mode 2.6.2 on Ubuntu 21.10.

Code: [Select]
sudo apt-get -y install git libsfml-dev libopenal-dev libavformat-dev libfontconfig1-dev libfreetype6-dev libswscale-dev libswresample-dev libarchive-dev libjpeg-dev libglu1-mesa-dev libxrandr-dev
Openbox Issues

To stop Openbox from blanking the screen after 10 minutes of idle time add these lines to the top of your autostart file

Code: [Select]
vim ~/.config/openbox/autostart
Code: [Select]
# Keep screen on
xset -dpms     # Disable DPMS (Energy Star) Features
xset s off     # Disable screenasver
xset s noblank # Don't blank video device

Ubuntu 21.10 Server Network Issues

The newer Ubuntu server likes to hang for a couple minutes trying to find a network connection when no Ethernet cable is plugged in. This adds needless startup time for an offline system that doesn't need to be connected to the internet once setup. To avoid this, for a faster startup you need to change netplan and add 'optional: true' to the config. You will need to modify your network config to look something like this. Note: The Ethernet network adapter enp0s31f6 will be a different name based on your hardware.

Code: [Select]
sudo vim /etc/netplan/00-installer-config.yaml
Code: [Select]
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s31f6:
      dhcp4: true
      optional: true
  version: 2
Code: [Select]
sudo netplan generate
sudo netplan apply

Additional Notes

These are things I did slightly different and I may not remember why exactly anymore. Some of it is optional. You may not need to do it exactly the same, but it worked for me.

ē To stop the terminal from blanking the screen when idle add this line to the end of bashrc

Code: [Select]
vim ~/.bashrc
Code: [Select]
#prevent screen blanking when idle
setterm -blank 0

ē When you make your openbox directory for the first time add -p flag to create child & parent directories.

Code: [Select]
mkdir -p ~/.config/openbox
ē I used a slightly different script for the autologin on the newer ubuntu
Code: [Select]
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin <USERNAME> %I $TERM
Type=idle

ē I added this slightly different script to the .profile file to ensure that X only autostarts on terminal 1 if you should choose to login to other text terminals.

Code: [Select]
vim ~/.profile
Code: [Select]
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
    startx
fi

ē MAME can take an hour to compile. You can speed it up on multi core cpus as mentioned in other posts. On a dual core system use -j3, or -j5 with a quad core cpu.

Code: [Select]
make -j5
« Last Edit: May 08, 2022, 12:38:46 pm by dauntless »

dauntless

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 5
  • Last login:Today at 04:40:39 am
  • I want to build my own arcade controls!
Re: Guide to getting MAME up and running in linux
« Reply #9 on: April 08, 2022, 07:55:08 pm »
How to Manually Patch MAME to get rid of Nag Screens (instructions for mame 0.240 and similar versions)

MKChamp didn't have a patch file for MAME 0.240 to disable the nag screens at the time when I compiled from source. So I looked through the latest previous versions to determine what changes were made and manually changed them myself. If you are compiling a version only a few months apart from .240 the process is likely the same.

There are two files that need to be patched, ui.cpp and mainmenu.cpp. They are located in the directory mame0240s/src/frontend/mame/ui/

Open ui.cpp in a text editor, not a word processor.

At line 217 (unmodified v0.240 file) where it says "draw_text_box(container, messagebox_text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, colors().background_color());" you need to add this line before "if (!machine().options().skip_gameinfo())". The modified block of code should look like this.
Code: [Select]
{
// DISABLE INITIALIZING, LOADING & DECRYPTING MESSAGES
if (!machine().options().skip_gameinfo())
draw_text_box(container, messagebox_text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, colors().background_color());
return 0;
}));

At line 411 (unmodified v0.240 file) where is says "bool video_none = strcmp(downcast<osd_options &>(machine().options()).video(), OSDOPTVAL_NONE) == 0;" you want to add this code right after "first_time = show_gameinfo;". The modified block of code should look like this.
Code: [Select]
bool video_none = strcmp(downcast<osd_options &>(machine().options()).video(), OSDOPTVAL_NONE) == 0;

// FORCE INTERACTIVE WARNING MESSAGES (HARD RESET)
first_time = show_gameinfo;

Save the file and than open mainmenu.cpp.

In mainmenu.cpp at line 193 (unmodified v0.240 file) look for "if (!mame_machine_manager::instance()->favorite().is_favorite(machine()))". This if statement needs to be enclosed by another if statement "if (!machine().options().skip_gameinfo())". The modified block of code should look like this.
Code: [Select]
// DISABLE SELECT NEW MACHINE & FAVORITES
if (!machine().options().skip_gameinfo())
{
if (!mame_machine_manager::instance()->favorite().is_favorite(machine()))
item_append(_("Add To Favorites"), 0, (void *)ADD_FAVORITE);
else
item_append(_("Remove From Favorites"), 0, (void *)REMOVE_FAVORITE);

item_append(menu_item_type::SEPARATOR);

item_append(string_format(_("About %1$s"), emulator_info::get_appname()), 0, (void *)ABOUT);

item_append(menu_item_type::SEPARATOR);
}

Just below at line 212 (unmodified v0.240 file) where it says "item_append(_("Select New Machine"), 0, (void *)SELECT_GAME);" you need to add "if (!machine().options().skip_gameinfo())" just above. The modified block of code should look like this.
Code: [Select]
//  item_append(_("Quit from Machine"), 0, (void *)QUIT_GAME);

if (machine_phase::INIT == m_phase)
{
item_append(_("Start Machine"), 0, (void *)DISMISS);
}
else
{
if (!machine().options().skip_gameinfo())
item_append(_("Select New Machine"), 0, (void *)SELECT_GAME);
item_append(_("Return to Machine"), 0, (void *)DISMISS);
}

Save the file after making the changes and you are ready to compile a nag free version of MAME. If there hasn't been a major ui revision in the version you are using, or user typos in your code, MAME should compile without error provided that you were able to compile the source without error before making any changes.

You will still need to add these lines to the mame.ini file.

Code: [Select]
#
# CORE MKChamp OPTIONS
#
skip_gameinfo             1

or

Run MAME with the -skip_gameinfo flag
Code: [Select]
mame64 <game> -skip_gameinfo

nitrogen_widget

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1654
  • Last login:May 17, 2022, 08:45:24 pm
  • I want to build my own arcade controls!
Re: Guide to getting MAME up and running in linux
« Reply #10 on: April 10, 2022, 01:14:53 pm »
Great writeup.
especially the built in screen blanking on X.

its so annoying.