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 ( 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 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.


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)
Opti-Pac (USB)
I-Pac (USB)

Most Helpful Online Resources

Thursday, February 19, 2009

Tinkering Tip #1

If you get stuck and are feeling frustrated, walk away.

No, don't give up. Just do something else for a little while and take your mind off of it. I'm always surprised at how taking my mind off the problem will actually help to come up with new and creative solutions.

Thursday, February 12, 2009

Why DIY? - Part 5 - Making Connections

Things are little slow right now on the tinkering front. So during this period of downtime I'm going to spend the next few posts exploring the "whys" and the "what fors" of tinkering around.

When I was in high school I hated studying history. It seemed like nothing but a bunch of dates and places involving people and events I just didn't understand. Even though I knew the concept of "those who don't understand history are doomed to repeat it," it still seemed irrelevant. I suffered through it each day and dreaded every homework assignment.

It didn't get much better in college. In fact, it only got worse when I had a teacher that gave the most boring lectures, only to be out-bored by the boringest text to ever bore (authored by this very same teacher of course). The only class in which I ever received an F. It was a much deserved F too. You should have read my 300 word essay on the final exam. We were supposed to have written it on how ancient Egypt has influenced other cultures, but instead I wrote an eloquent diatribe on how awful the class, text, teacher, and test was. Oh, it was a thing of beauty.

Of course I couldn't graduate with that F on my record so I was forced to retake. This time I took it during an "off" semester where the class size was sure to be smaller and I could hope to get more out of it. I was very fortunate the second time to get a teacher who made the subject of history very interesting to me. Instead of treating history like a bunch of dates and moving through the time line like a snail in molasses, he would address a single subject in each lecture and cover the entire time line of that subject in a "big picture" fashion. Women in history, technology in history, etc. This really worked for me and opened up an all new appreciation for the subject. I actually enjoyed the class and the homework and earned a B. The highest history grade I ever earned.

And now I find myself interested in the past and those who have gone before me. I like to learn about how things used to be and how far things have come. I've even found it fun to try to do some things the "old fashioned way." Making home made bread, pickles, outdoor cooking, etc. I know others who sew, quilt, bake, and garden just like in "olden" days. I often feel like tinkering helps me to make a connection to the past. As if showing an interest in the things my ancestors were interested in could help me to feel like they were real instead of just a picture in an album. Or sometimes while I'm tinkering around with technology unavailable to them at the time I wonder if they would have been interested in it too and how well they would have enjoyed tinkering with it.

I usually try to prioritize the projects that are appropriate and fun for the kids to help me with. This gives me an opportunity to spend time with them instead of just holing away and missing out on their lives. It also allows for me to share some of my interests with them and hopefully get them interested too. I can also learn more about the things they are interested in and try to incorporate their interests in the project with an effort to help bring out their talents. In this way I can also make connections with them.

Perhaps Malachi was speaking of tinkering and the DIY movement when he said, "And he shall turn the heart of the fathers to the children, and the heart of the children to their fathers, lest I come and smite the earth with a curse. " (Malachi 4:6)

Tinkering is a great opportunity to turn the heart of the fathers to the children and the heart of the children to the fathers as we share in one another's hobbies and pass on those interests from generation to generation. And a non-industrious society, only consuming and not producing would indeed be a curse on the earth.

Part 1 - Fun!
Part 2 - Economics
Part 3 - Reduce, Reuse, Recycle
Part 4 - Education

Sunday, February 1, 2009

Why DIY? - Part 4 - Education

Things are little slow right now on the tinkering front. So during this period of downtime I'm going to spend the next few posts exploring the "whys" and the "what fors" of tinkering around.

I enjoy a good mind bender. Anything that challenges me and forces me to put my brain into overdrive. I'll even spend a great deal more time than I probably should on such things and even if I get nowhere I'll still feel like I accomplished something. And this is because during these times I'm researching and educating myself on the subject. Sometimes picking up a few tangential bits of knowledge as I go that I hadn't intended on discovering.

As a tinkerer I'm often up against such challenges. Most, if not all, projects I take on I have no previous knowledge or experience and I need to train and educate myself on how to succeed at the task. And being a bit of a perfectionist too I'll spend a lot of time upfront researching how others have done it and the things they learned through the process. Much of this research is just to see what I'm up against and exactly how much work I'm setting myself up for. But at the same time I'm slowly building up enough knowledge to feel like I can take it on and feel like I know what I'm doing, even if I'm not an expert.

My favorite thing about college was learning. In fact, the greatest thing I learned in college was learning how much I don't know. It seemed that the more I discovered, the more I studied, the more my eyes were opened to the vast amounts of knowledge still out there for the learning. Tinkering and taking on DIY projects gives me the opportunity to once again tap into some of that knowledge. To continue to further my education even if it's not in a formal manner. These hands-on labs can teach us more than just studying a book. The book knowledge can give us a starting point, but trying things out for ourselves really drives the lesson home. Even mistakes can be good teachers too. Nothing can teach us more about the need of resisters in a circuit than plugging a 3V LED directly into a 9V battery and watching it burn out in a blaze of glory.

Part 1 - Fun!
Part 2 - Economics
Part 3 - Reduce, Reuse, Recycle
Part 5 - Making Connections