A perfect Linux MAME cab installation
Debian
First, the Debian installation. Wherever possible I've taken the simplest options, such as using ftpd
and telnetd
rather than more elaborate remote administration tools. Any hacks have been done in the correct Debian fashion and are on show for anyone to see and adapt.
Installation
This example uses Debian Linux 4.0 (etch). Whatever method you choose to install with, choose defaults throughout except with the below:
- Hostname can be whatever you like, I choose mame
- Domain should normally be set to example, test, or invalid. If you want to know why, read RFC 2606. You'll know if it needs to be set to anything else!
- When partitioning, change the mount options to
noatime,sync
. - Create a new user account called mame.
- When asked about "Software selection" unselect everything.
Customisation
After the forced reboot, we run through the steps needed to tweak the OS for our needs.
- Get our system bang up to date: aptitude update && aptitude dist-upgrade
- Install tools we'll need: aptitude install telnetd ftpd fbset mingetty
- Move the installed
/etc/fb.modes
somewhere safe: mv /etc/fb.modes /etc/fb.modes.sample - Enable the framebuffer. This can be done in three ways: compiling one or more drivers into the kernel and loading the appropriate one at boot (hardest), by adding one or more as modules to the initial RAM disk and loading at boot (easier), or by loading them in the startup scripts (easiest). I add them all to the startup scripts, it's the quickest and easiest to fix.
- You'll need to identify what modules are available: ls -R /lib/modules/`uname -r`/kernel/drivers/video/ | grep .ko | sed s/.ko// | sort. Currently, the list I use is:
arcfb aty128fb atyfb cirrusfb cyber2000fb cyblafb gx1fb gxfb hgafb i810fb intelfb kyrofb matroxfb neofb nvidiafb pm2fb radeonfb s1d13xxxfb savagefb sisfb sstfb tdfxfb tridentfb
. Not all of these have been tested on an arcade monitor, but all should be suitable for PC use. - This will help you identify what hardware is in the machine: lspci | grep VGA
- To load modules via the initial RAM disk (initrd):
- nano -w /etc/initramfs-tools/modules
- update-initramfs -u
- To load modules from the startup scripts: nano -w /etc/modules.
- You'll need to identify what modules are available: ls -R /lib/modules/`uname -r`/kernel/drivers/video/ | grep .ko | sed s/.ko// | sort. Currently, the list I use is:
- Logging in automatically as the mame user is accomplished by editing
/etc/inittab
(we're replacinggetty
withmingetty
fortty1
- the first console - and setting themame
user to automatically login): sed -ie 's,getty 38400 tty1,mingetty --autologin=mame tty1,g' /etc/inittab - Giving
root
telnet and ftp access is bad security practice - but it makes our lives a bit easier when setting up the system. You could always skip this and usesu
, or reverse the changes once you're happy with everything.- nano -w/etc/securetty and add the following:
# Telnet
pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
pts/6
pts/7
pts/8
pts/9 - Allow root ftp access: sed -i 's/\#root/root/g' /etc/ftpusers
- nano -w/etc/securetty and add the following:
- To stop DHCP taking an age when not connected to a network, edit
/etc/network/interfaces
and replace the keyword "auto" with "allow-hotplug" except on the loopback interface (lo) - We want to add some fake kernel parameters to our grub menu. This tells update-grub to add extra boot options other than the standard and single user.
/proc/cmdline
contains the boot parameters and we can run scripts based on this to configure the system automatically.- Edit
/boot/grub/menu.lst
. add extra #altoptions = lines as follows:
# altoptions=(15.75kHz Horizontal) hclock=15.75 fbcon=rotate_all:0
# altoptions=(15.75kHz Vertical) hclock=15.75 fbcon=rotate_all:1
# altoptions=(16.5kHz Horizontal) hclock=16.5 fbcon=rotate_all:0
# altoptions=(16.5kHz Vertical) hclock=16.5 fbcon=rotate_all:1
# altoptions=(25kHz Horizontal) hclock=25 fbcon=rotate_all:0
# altoptions=(25kHz Vertical) hclock=25 fbcon=rotate_all:1
# altoptions=(31.5kHz Horizontal) hclock=31.5 fbcon=rotate_all:0
# altoptions=(31.5kHz Vertical) hclock=31.5 fbcon=rotate_all:1
# altoptions=(15.75+25+31.5kHz Horizontal) hclock=15.75+25+31.5 fbcon=rotate_all:0
# altoptions=(15.75+25+31.5kHz Vertical) hclock=15.75+25.31.5 fbcon=rotate_all:1 - Change the "default" line to read "saved" instead of "0". This will remember our previous selection and use this for the next boot.
- Add a line right at the top of the file that reads:
setkey enter control
This maps the Enter key to the standard MAME entry for P1B1 - the Left Control key. Enter is still found at it's default position. We can now change the boot option using a keyboard or a MAME mapped joystick! - Save the file, then run update-grub to commit the changes.
- Edit
- Create
arcade
script:- nano -w /etc/init.d/arcade
#! /bin/bash
case "$1" in
start)
# Modelines
if grep hclock=15.75+25+31.5 /proc/cmdline > /dev/null ; then
echo "Using 15.75+25+31.5kHz modelines..."
ln -sf /etc/fb.modes.15.75+25+31.5 /etc/fb.modes
elif grep hclock=15.75 /proc/cmdline > /dev/null ; then
echo "Using 15.75kHz modelines..."
ln -sf /etc/fb.modes.15.75 /etc/fb.modes
elif grep hclock=16.5 /proc/cmdline > /dev/null ; then
echo "Using 16.5kHz modelines..."
ln -sf /etc/fb.modes.16.5 /etc/fb.modes
elif grep hclock=25 /proc/cmdline > /dev/null ; then
echo "Using 25kHz modelines..."
ln -sf /etc/fb.modes.25 /etc/fb.modes
elif grep hclock=31.5 /proc/cmdline > /dev/null ; then
echo "Using 31.5kHz modelines..."
ln -sf /etc/fb.modes.31.5 /etc/fb.modes
else
echo "No monitor type chosen, using generic PC VGA..."
fbset --all -match -xres 640 -yres 480
ln -sf /etc/fb.modes.sample /etc/fb.modes
fi
# Rotation
if grep fbcon=rotate_all:0 /proc/cmdline > /dev/null ; then
echo "Using horizontal monitor..."
# Console
echo 0 > /sys/class/graphics/fbcon/rotate_all
# MAME
sed -i 's/^rotate *0/rotate 1/g' /home/mame/.mame/mame.ini
sed -i 's/^ror *1/ror 0/g' /home/mame/.mame/mame.ini
# AdvanceMENU
sed -i 's/vertical include$/vertical exclude$/g' /home/mame/.advance/advmenu.rc
sed -i 's/vertical exclude_not$/vertical exclude$/g' /home/mame/.advance/advmenu.rc
elif grep fbcon=rotate_all:1 /proc/cmdline > /dev/null ; then
echo "Using vertical monitor..."
# Console
echo 1 > /sys/class/graphics/fbcon/rotate_all
# MAME
sed -i 's/^rotate *0/rotate 1/g' /home/mame/.mame/mame.ini
sed -i 's/^ror *0/ror 1/g' /home/mame/.mame/mame.ini
# AdvanceMENU
sed -i 's/vertical include$/vertical exclude_not$/g' /home/mame/.advance/advmenu.rc
sed -i 's/vertical exclude$/vertical exclude_not$/g' /home/mame/.advance/advmenu.rc
else
echo "Using rotate mode (vertical on horizontal)..."
# MAME
sed -i 's/^rotate *0/rotate 1/g' /home/mame/.mame/mame.ini
sed -i 's/^ror *1/ror 0/g' /home/mame/.mame/mame.ini
# AdvanceMENU
sed -i 's/vertical exclude_not$/vertical include$/g' /home/mame/.advance/advmenu.rc
sed -i 's/vertical exclude$/vertical include$/g' /home/mame/.advance/advmenu.rc
fi
;;
stop)
echo "Clearing fb.modes..."
ln -sf /etc/fb.modes.sample /etc/fb.modes
echo "Clearing rotation..."
# MAME
sed -i 's/^rotate *0/rotate 1/g' /home/mame/.mame/mame.ini
sed -i 's/^ror *1/ror 0/g' /home/mame/.mame/mame.ini
# AdvanceMENU
sed -i 's/vertical exclude_not$/vertical include$/g' /home/mame/.advance/advmenu.rc
sed -i 's/vertical exclude$/vertical include$/g' /home/mame/.advance/advmenu.rc
# Console
echo 0 > /sys/class/graphics/fbcon/rotate_all
;;
*)
echo "Usage: /etc/init.d/jamma {start|stop}"
exit 1
;;
esac
exit 0- Make it executable: chmod +x /etc/init.d/arcade
- Run automatically on boot: update-rc.d arcade defaults 50
- Edit udev permissions so that any user can write to the framebuffer tty
- nano -w /etc/udev/permissions
KERNEL=="tty0", MODE="0666", GROUP="root"
KERNEL=="tty[1-9]*", GROUP="root"
- Edit the mame user login script
- nano -w /home/mame/.bash_profile
- Add the following lines:
export SDL_VIDEO_YUV_DIRECT=1
export SDL_VIDEODRIVER=directfb
export SDLMAME_DESKTOPDIM=640x480
export DFBARGS=depth=16,no-debug,no-trace,desktop-buffer-mode=frontonly,no-cursor,no-banner,quiet,dma,sync,no-vt-switch,disable-module=x11,disable-module=joystick,disable-module=linux_input,bg-color=000000
advmenu
SDLMAME
- Install SDL: aptitude install make libsdl-dev libgconf2-dev Sadly the development libraries for SDL in Debian depend on huge amounts of other packages, but these are only needed for compiling! Once compiled, you can happily purge the above packages, and install libsdl by itself.
- Grab the source from http://rbelmont.mameworld.info/?page_id=163.
- Decompress: 7z x sdlmame*.zip
- cd sdlmame*
- A small change is needed to the source to get it to compile on Debian:
- nano -w src/osd/sdl/sdlsync.h
- Change
#define THREAD_COOPERATIVE (1)
to#define THREAD_COOPERATIVE (0)
.
- Compile:
- make clean
- make NO_X11=1 NO_OPENGL=1
Notes
- Enable switchres in
mame.ini
. Enable window inmame.ini
- You can optimize disk performance with
hdparm
. Be careful and read the documentation!- aptitude install hdparm
- Check performance with: hdparm -Tt /dev/hda
- nano -w /etc/conf.d/hdparm
- invoke-rc.d hdparm start
- Check performance again
- Changing the system volume is done with the tool alsamixer. Use the m key to unmute a channel and set a sensible volume. AdvanceMAME normalises game volume so you don't need to touch volume inside it.
- Trimming down disk usage:
- aptitude install localepurge
- aptitude purge tasksel tasksel-data cron logrotate info man-db manpages ed vim-common vim-tiny installation-report iptables netcat libsasl2 dictionaries-common ispell usbutils laptop-detect dmidecode eject ibritish myspell-en-gb wbritish util-linux-locales groff-base bsdmainutils
- If the install was done with a netinst CD, or you simply want to use internet sources only, comment out the CD-ROM entry in
/etc/apt/sources.list
- Compiling a custom kernel
- Install tools necessary to recompile the kernel: aptitude install kernel-package linux-source build-essential libncurses5-dev bzip2
- Decompress kernel sources:
- tar jxf /usr/src/linux-source-*.tar.bz2
- cd /usr/src/linux-source*
- Edit
/etc/kernel-pkg.conf
with your personal details if desired - Clean up any old compile data and use the current kernel configuration:
- make-kpkg clean
- cp /boot/config-`uname -r` ./.config
- Make changes to the kernel configuration: make menuconfig
- Compile your custom kernel: make-kpkg --initrd kernel_image kernel_headers
- Install custom kernel: dpkg -i kernel-image-x.y.z.yy.mm.dd_10.00.Custom_i386.deb
1 Comments:
Hi there, I'm trying to get my arcade monitor working but I'm hitting a stumbling block. All I get on the screen is a garbled mess. I think I'm missing some files:
in the line:
ln -sf /etc/fb.modes.15.75+25+31.5 /etc/fb.modes
I don't have any fb.modes.15... files there al I had was fb.modes which I moved as suggested.
Any ideas?
Post a Comment
Subscribe to Post Comments [Atom]
<< Home