Saturday, February 21, 2009

Arcade Tinkering

Technical content ahead. This is going to be one of those super geeky posts where most people may not follow. Remember, I'm documenting my projects in case I need to revisit them in the future and do things over again or figure out how I did it in the first place. Or maybe someone out there is going through the same thing and is doing research of their own. This post is also very long. You have been warned.


A couple of years ago I built an arcade cabinet. It was a very fun project. I had been researching everything I wanted to build into it for a few years before I began. I was just waiting for the day when I had both the money and the time to build it. It took a little while to complete mainly due to weather (you can't laminate below 60 degrees) but I finally completed it and we've been having lots of fun with it.

Or was it complete? In order to simplify the first install and get things running to thoroughly test the hardware, I installed Windows XP on it and was running Mame32 for arcade emulation. But I was really never happy with that setup. It worked okay. No problems with game play or emulation. But I hated having Windows on it. Now, I'm not anti-Microsoft at all. But the computer I installed in the arcade is older hardware and Windows XP is a bit of a hog. It also requires quite a bit of maintenance just to keep it virus free. And since I've got it hooked up to my network, for security's sake it needs constant updates. Startup times are very poor. From zero to ready-to-play takes 7 minutes, 40 seconds. And that's if there are no updates to apply. It really takes the fun out of playing a quick game of Galaga when you have to turn it on and walk away for 10 minutes waiting for the dinosaur to wake.

Ever since day 1 I've been wanting to use Linux instead. So a few weeks ago I finally decided to just go for it. And this redo took quite a bit of tinkering indeed. Lots of trial and almost an equal amount of error. But after much CD burning, Googling, head scratching, and hacking away I have got it working in much better condition.

(I didn't want to completely lose my Windows install in case things didn't work out with Linux and I wanted to go back to the original setup, so I just swapped hard drives with a spare I had laying around. The old one is standing by if things go wrong.)

Problem #1: Which Linux distribution do I want to use?

One of the great (and sometimes confusing) things about Linux is the availability of a variety of distributions (or distros). Each one is unique in their own way and ultimately caters to a different audience. I've used Ubuntu and Debian before and really like them (Ubuntu is built off Debian). So both of those were a definite option I wanted to try out. I also wanted to give Lincade a try. It's a Linux distro (built off Gentoo) built specifically for arcade emulation, with support for the unique type of arcade hardware I had installed in my cabinet.

Linux pros: Stable. Secure, unlikely to get viruses or other malicious software. Very customizable. Runs great on older hardware without much overhead (faster boot times).

Linux cons: Harder to use than Windows.

When it comes to desktop computing, Linux has come a long way. Distros like Ubuntu and Debian are very easy to install and very easy to use for your regular desktop use. But for non-regular use it's not a simple plug-and-play solution.

One of the big roadblocks I could see ahead of me was the fact that I was using non-standard hardware in my cabinet. Non-standard for a computer desktop that is. I have a monitor built specifically for arcade use. Many arcade games use low resolution graphics and slow scan rates that regular computer monitors cause to appear fuzzy. I wanted sharp, accurate reproduction of the games. Since Windows is a more popular platform there were utilities available for such monitors. But there wasn't anything to my knowledge for Linux.

Since Lincade is supposed to have been built specifically for uses such as mine I was hoping it would be the solution I was looking for.

Problem #2: Faulty USB hub.

While trying to install Lincade I was getting the following error.

hub 1-0:1.0: connect-debounce failed, port 1 disabled


After unplugging the USB hub (a necessary component to use the arcade control panel, trackball, and spinner) I was finally able to complete the installation. I wasn't sure if it was really a USB error or just something wrong with Lincade. So I gave Xubuntu (a variation of Ubuntu) a try.

Xubuntu installed without error, but it wasn't recognizing the trackball (my only current option for a mouse). That's no good. Time to try Debian.

Debian installed perfectly too, but also wasn't recognizing the trackball.

This time I swapped out the USB hub for another I had around and reinstalled Xubuntu. Installed fine, I had a working trackball. Must have been something weird about that hub. Windows doesn't seem to have a problem with it (as I'm using it now with my main office computer running Windows), but Linux just doesn't seem to like it.

During the troubleshooting of the USB hub I tried flashing the computer BIOS thinking that might solve the problem and during that process I discovered...

Problem #3: Dead floppy drive

Or it might be a dead floppy drive cable...or both. Xubuntu had given me the following (occasional) error during install:

Buffer I/O error on device fd0, logical block 0
End request: I/O error, dev fd0, sector 0


In Linux, "dev fd0" is the floppy drive ("device floppy drive zero"). So once I had flashed the BIOS (by temporarily putting in a floppy drive from another computer) I didn't need it anymore and just unplugged it and disabled it in the BIOS.

No more error.

I decided to give Lincade another try and reinstalled it. Unfortunately it doesn't have the slick graphical interface that Ubuntu and Debian have which makes it harder to use. Also, it requires you to boot into a "PC-mode" in order to setup certain options. The PC-mode doesn't display on my main arcade monitor though and requires me to setup a secondary monitor. That's a big pain. So, thinking I'm just going to completely give up on what I thought would be my best option...I set Lincade aside and went back to Xubuntu.

Problem #4: It's a pain in the %#$ to install a MAME emulator in Linux!

I could not for the life of me get this thing working. I did successfully install XMAME and sort of got it working from a command line. But it's no fun having to type "xmame galaga" or "xmame tmnt" or "xmame pacman" every time I (or the kids) want to play a game. That's no easy-to-use option. And the graphics weren't right either. There are frontends available to use so I tried installing WahCade. There's a deb file available for that which I downloaded and tried installing. But for some reason it didn't install all the dependencies. It wasn't until after I installed a totally seperate mp3 player (Rhythmbox...love it) that the dependencies for WahCade got installed.

(Quick Linux for newbies Lesson #1: There's no such thing as a simple "installer" in Linux like there is in Windows...at least not exactly the same thing. You can't just download an executable, run it, and have everything magically install. Sometimes you have to download the source code and compile it. Which wouldn't really be all that bad if the source code doesn't depend on other packages to be installed...which it usually does. Then it's a huge pain trying to track down all the missing packages and compile and install those...and in the proper order...while standing on your head, crossing your eyes, and holding incense in your toes. Fortunately, Debian (and Ubuntu as well) has a package manager called Aptitude that can make installing common packages a breeze. You do have to know the name of the package though, and that's where Google really comes in handy. Just type in the command line (as root):

apt-get install rhythmbox


and you've just installed a fully functioning iTunes clone. Very easy. There are also "deb" files available for Debian and Ubuntu that almost behave like simple installers and are supposed to eliminate the need to satisfy dependencies. Some other Linux distros have their own package managers as well.)


Once I satisfied the WahCade dependencies it seemed to work a little, but I couldn't get it to behave properly for my arcade monitor. Xubuntu wanted to ignore the xorg.conf file and for some reason in Debian the image just squished down.

(Quick Linux for newbies Lesson #2: The graphical display environment in Linux (called "X") is handled by the X server. An important file for configuring the X server is the xorg.conf file located in the /etc/X11 directory. This handles things like the graphics driver, the monitor resolutions available, etc. I really only understand enough to get me in trouble...and sometimes get myself out of trouble.)

I tried to also install AdvanceMame with the AdvanceMenu frontend. That was completely useless. There was no deb file available for that and I couldn't satisfy the dependencies to get it to compile correctly. Too many vague requirements for framebuffer support or SDL libraries. The installation documentation was completely useless. It was a bigger pain than WahCade.

By this point I had spent a good 3 days on the project and had installed Lincade 3 times, Xubuntu 3 or 4 times (I lost count), and Debian something like 5 or 6 (hundred?) times. I was beginning to get fed up and was almost ready to throw in the towel. But that's not me, and I decided to give it a day's rest and see if I can't come to some solution after separating myself from the problem and giving it more thought (see Tinkering Tip #1).

While I was "not thinking about it" I came upon the realization that even though Lincade was lacking the main feature that I was trying to get out of Ubuntu and Debian (an easy to use GUI) I figured that since it can easily handle the hardest parts (installing the correct monitor support and emulation software) I could probably just work around the rest and get it all worked out. It turns out that this was ultimately the easiest solution.

With the previous hardware issues already worked out I forged ahead with one more Lincade install. Everything installed fine. It turns out the PC-mode may not be so bad afterall as I only need to use it for the first time configuration. Everything after that I can modify in Cabinet-mode without having to use a secondary PC monitor.

PC-mode has the option to copy ROMS from a CD or a USB stick. I didn't want to waste burning a CD (and all my ROMS wouldn't fit on one CD anyway), so I just copied them to a USB stick I had. I don't like this option much just because it takes so long. The USB port on this computer is 1.1 so it's slow. And I also don't like that the games are automatically copied to the /usr/share/games/advance/roms directory. I wanted them to go into the /home/mame/.advance/roms directory instead.

I have a NAS on my network running Linux and sharing folders with NFS. I already had all my ROMS on the NAS in a shared directory, so instead of using a USB stick or CD to copy files I figured I'd just do it over the network.

First I had to install NFS support in Lincade. (Gentoo has a package manager called Portage. The command to run is "emerge.")

emerge –av nfs-utils


Then mount the NFS directory. ("pippin" is the name of my NAS.)

mount –t nfs pippin:/home /mnt/nfs/pippin/home


Put a line in the /etc/fstab file for auto mounting on boot.

pippin:/home /mnt/nfs/pippin/home nfs rw,sync 0 0


Now I could copy all the files I needed from one folder to another over the network. Much faster and easier to use later on when there are more to add.

But even though I didn't like PC-mode's ROM loading utility, everything else is really nice. The monitor resolution tool is awesome, automatically loading all the modelines you need in xorg.conf. The sound card setup works perfectly. All other setup in PC-mode was a breeze.

Finally things were all setup and I could run the emulator. It comes with AdvanceMame and AdvanceMenu, as well as MESS and DAPHNE. I primarily use MAME and haven't quite found a use for MESS or DAPHNE yet. And the AdvanceMame and Menu work great...once I got the resolutions figured out.

In xorg.conf I had to set the default resolution to 640x480. It first defaults to 480x480 which doesn't work out to any usable resolution so it defaults to some other higher resolution that causes my arcade monitor to flicker and look really bad. After much trial and error I found 640x480 to be the perfect resolution for my setup. Then if the games aren't displayed in the correct size I can change their individual settings within the game menu.

Press Tab to open the menu -> Move down to VIDEO -> change resize to "fractional"

Now the games play in the proper resolution, frame and scan rates, and have the correct size and proportion.

But there were more issues to be fixed still.

Problem #5: Slow trackball movement

The trackball was moving very slowly. This made games like Centipede completely unplayable. At first I thought it was more USB hardware going wonky on me, but it turned out to be an easy fix. In the BIOS I had to enable legacy USB support. I'm not entirely sure why that made a difference but I tried it on a hunch and it worked.

Problem #6: The spinner wasn't working

Well, actually it worked, but not in the games. I verified that it works because just before the AdvanceMenu comes up there's an "X" cursor that I could indeed move with both the trackball and the spinner. The spinner made it move vertically, just like in Windows. It turns out that AdvanceMame wants it to move horizontally for games that use the spinner. I couldn't figure out any way to switch the Y-axis to the X-axis in the software. But after much more Googling I learned that there's a jumper on the spinner that switches the axis.

So I opened up the control panel (good thing I made this relatively easy to do) and sure enough there's a jumper with one side marked "H" and the other side marked...we'll I actually don't know because I couldn't read it, but I'm going to assume it was marked with a "V" and that's the side that had the jumper. So I moved it to the "H" side and started the computer back up again. And, the spinner works now.

While I was doing some digging around in the documentation directories installed by the Lincade CD I found that some of the documents are HTML formated. So I figured it would be a really easy thing to just install Apache and make this thing into a webserver so I can more easily read the documentation. I've already got SSH running on it (it comes that way "out of the box"). Why not take it one step further?

emerge -av apache
/etc/init.d/apache2 start
rc-update add apache2 default


Problem #7: The font size in AdvanceMenu was too small to read

This was easily fixed (although difficult to figure out) by adding a line to the advmenu.rc file.

ui_fontsize 30


The number indicates how many rows of text to use for the font. The smaller the number, the bigger the font. I found 30 rows to be just right on my 27" monitor at 640x480.

Even though it's now playable and works great I'm sure I'm still not done with it. This is going to be one of those on-going projects that I return to again and again to make a few tweaks and changes now and then. For example, I'd like to make a few personalized modifications to the AdvanceMenu front end.

Since I had several hardware issues during these changes I'm a little worried about the longevity of this computer. I'd like to change it out sometime soon. I don't need a high-end model since it's only running really old arcade games. I just need a computer that can last longer. Also, the special Arcade VGA graphics card I have installed requires an AGP port, which isn't a standard option on newer computers. Ideally the computer I replace it with will also be silent (so I don't hear fans running inside the cabinet) and maybe use a solid-state drive for even faster boot times.

Conclusion

It took a lot of work and a great deal of frustration (which I actually enjoy on projects like this). I learned a lot more through the process and got things working even smoother. I'm pretty sure that when the computer is replaced that I can do the reinstall even easier and faster than this one took.

The new boot time, from zero to ready-to-play has been reduced to 1 minute, 32 seconds. (And that includes a built-in 5 second delay in the Grub menu.) It's not "instant on" but it's pretty good. A faster hard drive will improve that as well.

Relevant Hardware Specs

Betson Monitor 44-4070-RT
Arcade VGA
Tornado Spinner (USB)
Trackball
Opti-Pac (USB)
I-Pac (USB)

Most Helpful Online Resources

http://www.pc2jamma.org/
http://advancemame.sourceforge.net/doc-advmenu.html
http://en.gentoo-wiki.com/wiki/NFS/Client
http://beans.seartipy.com/2006/04/18/apache-php-mysql-on-gentoo/

No comments:

Post a Comment