Emulating vintage computer games on Linux

Time Machine


Ever long for some old hardware platform on which you first practiced computing (or gaming) skills - a Commodore 64, a PET, an Atari, an Amiga, a TRS-80, or even an IBM 1130? Join Marcel on a journey to the past.

By Marcel Gagné

ELEN, 123RF

It's good to be king. It's also good to have a quad-core 64-bit processor with processor-based virtualization, a terabyte of storage, 8GB of RAM, and a massive LED display on your notebook. With that kind of power, you can run virtual Linux machines and a hundred different distributions under your favorite virtualization package (e.g., VirtualBox, KVM, etc.) and still watch streaming video from TED. Heck, you could probably even run a virtual Windows machine; I hear there's something called Windows 7 now, and it's supposed to be an improvement over the last version. With lots of disk, lots of processor, and lots of memory, you can do some pretty cool things.

But I don't want to talk about any of those things. My guess is my fellow columnists have those topics pretty well covered. No, I want to take you back in time. So, Sherman, set the WABAC machine [1] for 20, 25, and maybe even 35 years ago. We're going to virtualize the past! And we're going to do it on a modern Linux system. Allow me to be your tour guide on an adventure that will take you into the deepest, darkest, and coolest backwaters of machines long cast onto the sidelines of modern computer architecture.

It's part of the normal human condition to long for things of the past, including the computers on which you first tinkered. Not unlike a fine wine, some of these old platforms seem to mature and take on subtle, elusive qualities that can best be appreciated in a relaxed, open atmosphere. Open meaning open source, of course.

Emulators are common in the Linux world. You can run old DOS applications with DOSEMU and Windows applications with Wine (knowing full well, of course, that Wine Is Not an Emulator). To truly emulate something, you create virtual machines that run on your current machine through virtualization. VirtualBox, VMware, Xen, and KVM are all programs that let you run other operating systems on your Linux system. Emulators are a little different: They aren't running the operating system but are tricking programs that use those operating systems into thinking they are running in their native environment.

Commodore

To start this exploration, I'll look at an old favorite of mine, the Commodore 64 [2] [3]. For those who might still have old programs floating around and long to play a favorite game, complete with sound courtesy of Commodore's SID chip, try a little VICE [4] (Versatile Commodore Emulator), which is indeed versatile. It can emulate the C64, the C128, the VIC20, and most of the PET models. The VICE team distributes the program under the GPL.

Of all the Commodore models, I admit to having been quite attached to my old C64. On a whim, I recently tried a little Basic program for old time's sake. After fiddling with it for a few minutes, I realized that my Commodore Basic is not as sharp as it once was, so I found and typed out "99 Bottles Of Beer," courtesy of Nicholas Kingsley, from the 99 Bottles of Beer website [5], where you can download 1,342 variations of the same program.

Figure 1: "99 Bottles of Beer" sung in Commodore Basic.

To launch a Commodore 64 session, simply execute x64 from the command line, or start a PET session with xpet or a Commodore 128 session with x128.

Should you decide to install VICE from your distribution's distribution, you could get an error like that in Listing 1.

Listing 1: Messages from VICE
01 XRandR: XRandR reports current display: 1600x900@60
02 C128MEM: Error - Couldn't load kernal ROM 'kernal'.
03 Machine initialization failed.

That's because you need the main system (a.k.a. "kernal"), the Basic language (basic), and the character set (chargen). These files are included in the source distribution from the VICE site, but you must also deal with copyright issues (see the "Copyright Concerns" box).

Copyright Concerns

Gather around and heed the following weasel words: In the case of the products I describe here, you must remember that the material is often still copyrighted. Some emulators require that you have the original disks containing the OS or the ROM image. Case in point: The C64 emulator described here requires making software backups of old ROM cartridges, which is beyond the scope of this article; however, emulator sites store this type of information for various platforms. Also, a number of public domain programs are designed for each of these platforms, so you can have the joy of playing a game with 8-bit graphics without the guilt. But use caution and discretion. Thus endeth the weasel words.

Copyright concerns now noted, you may be happy to learn that each of these old platforms has one or more sites dedicated to preserving the old, abandoned applications that made them the computers we knew and loved.

Atari

The C64 was an actual computer, in that you had a keyboard on which you could type and do work. Not all the machines of the late 1970s and early 1980s were designed for work, however. One of the most popular systems from that era was the Atari 2600 Video Computer System (VCS); it seemed at the time as if everybody had one. For those longing to relive those days, there is Stella, created by Bradford W. Mott, although currently maintained by Stephen Anthony. Stella is distributed free of charge under the GPL and is probably in your favorite distribution's repositories.

Again, numerous freeware games and demos are out there for the curious [6]. To run a game with Stella, enter:

stella path_to_game

Suddenly, you're playing Chopper Command or some other game for which you have the original ROMs (see Figure 2). For a complete list of keyboard commands, make sure you look at the man page. You'll need them to play.

Figure 2: Lovely Atari 2600 8-bit graphics.

The Atari 2600 was only one of many systems put out by the company over the years. Petr Stehlik's first computer was an Atari 800XL, which he describes as something like a first girlfriend, somebody (or something, as in the case of the 800) that you will never forget. He is the current maintainer of the Atari 800 emulator, originally written by David Firth). Along with the help of others, Stehlik continues to develop the product: a mature emulator that works as an Atari 800, 800XL, 130XE, and 5200 series system (see Figure 3).

Figure 3: The Atari 800 emulator in XL mode running Android - not the phone OS.

If you try to run the Atari 800 package included in your distribution's repositories, odds are pretty good you'll get some error about the ROMs not being included for copyright reasons. As it turns out, Atari granted permission to make the ROMs available, but you'll have to download them (look for the xf25.zip package) and extract them to your system. The default settings can be changed by modifying the atari800.cfg file or by passing command-line arguments. For example,

atari800 -xl -mouse joy -run ~/atari/ANDROID.COM -windowed

tells the emulator to run in XL mode to allow the mouse to emulate a joystick, to load and run the Android program, and to operate in windowed mode (as opposed to taking over your whole display).

Software for the 800 is available many places. Some of the old games are still locked down by copyright, but others are freely available. A large repository of Atari 8-bit programs sits at the University of Michigan software archives [7]. Also, you can search using the New Breed Software XL Search site [8]. A visit to these sites will provide hours of nostalgic fun.

TRS-80

Another computer I was quite fond of in my early days was a TRS-80 Model 1, Level II. On this machine, I first learned Basic and assembly language. Searching through my Ubuntu Linux repositories, I found xtrs, a TRS-80 Model I/III/4/4P emulator originally written by David Gingold and Alec Wolman. The current version was revised and much extended by Timothy Mann (more on Tim in a moment).

The refrain will sound familiar by now, but the xtrs emulator program does require that you have an original TRS-80 ROM to operate. I could tell you that finding one, if you don't already have one, is relatively easy, but you probably already know that. Suffice it to say that xtrs is a full-featured emulator (see Figure 4) that even supports reading from and writing to that old cassette drive.

Figure 4: Exploring TRS-80 Basic.

Tim Mann's TRS-80 pages [9] are a great place to start for any Radio Shack TRS-80 enthusiast; it contains emulators and links to documentation and other TRS-80 sites. In fact, there is a wealth of information about every aspect of this nearly forgotten platform. This is a man who, at one time, was a TRS-80 systems programmer and has never gotten it out of his system.

Another great site worth visiting is Ira Goldklang's TRS-80 Revived site [10]. Also, there's Jeff Vavasour's TRS-80 Emulation page [11]. Jeff has examples of Basic programs and even has a Java-based TRS-80 emulator so you can run these old games.

MAME

If you find yourself looking for emulators that run under Linux and were not mentioned here, consider visiting Freshmeat.net. A search using "emulator" will give you plenty of information. Or, you can fire up your Linux distribution's package manager (e.g., Synaptic) and search for the word "emulator" (see Figure 5).

Figure 5: Surfing Synaptic or Freshmeat for emulators is a great way to find old machines.

Of course, every platform, gaming or otherwise, will in time be relegated to the pages of history. I have a Nintendo Wii and a Sony PS3 in my basement, and, although they look cool now, they will join my old Commodore 64 and Atari 2600 and vanish into that place where old hardware goes. It's sad, but with every platform come new games that we learn to love, and at some point, saving all these games and having a different emulation platform for each one seems a little nuts. Would it not be fantastic if one program could just play games from a huge collection of game hardware?

That's where the Multiple Arcade Machine Emulator (MAME) [12] comes into play. I'm not just talking about home game consoles here. Some of us poured more quarters than we want to admit into countless arcade machines. With kxmame (Figure 6), a KDE port of MAME, you can relive that arcade past [13]. To begin, install it from your Linux distribution's repositories, then go to the MAME site, where a number of companies and individuals have donated the original ROMs to arcade classics for personal non-commercial use. To download your favorite, click ROMs in the Downloads section.

Figure 6: kxmame is a graphical front end to MAME.

MAME, and by extension kxmame, knows about literally thousands of games. In the left-hand column of kxmame, games are sorted by genre, manufacturer, age, and many other categories. There you can browse the list of all games, look at those that are unavailable (not currently on your Linux system), or see the ones you do have by clicking Available. Then you can select a game, click the Play button (in the icon bar), and suddenly, you are back in 1977, playing an arcade classic like Exidy's Robot Bowl (see Figure 7).

Figure 7: Robot Bowl, courtesy of MAME.

Where you store the games you download is defined under Settings | Directories. Tell kxmame the folder in which to look for new games. When you download something, just extract the ROMs into that folder. Click View | Refresh. At first start, or any time you choose, kxmame can also Audit or rebuild its list of games. MAME knows a lot of games - 6,166 in the version I'm running.

One thing that threw me when I started working with kxmame was how to configure the keys to emulate the various controls so I could play the games and insert virtual coins into the machine. While a game is running, press the Tab key for the option of selecting whatever input control you want. Also, you can map your mouse controls the same way, assuming you enable the mouse in the kxmame interface. To enable the mouse, click Settings | Configure kxmame to see a comprehensive configuration interface (see Figure 8).

Figure 8: The kxmame configuration interface. Play your way.

On the left, a sidebar covers the various game settings, including sound, controls, and various display options. To enable the mouse (and later map its controls), click the Controllers icon. Another important setting is found under the Rendering section. By default, games are launched in full-screen mode. If you want a windowed display, you can change it here. Then, click on display and adjust the settings for the windowed view (e.g., auto-double the size).

Modern game software can offer impressive graphics and amazing sound and provide an environment that starts to feel like true virtual reality. Immersing yourself in these cutting-edge games can overwhelm your senses, but old favorite games don't lose their appeal either. Sometimes, you just need to revisit them - like visiting with an old friend and discovering that you can pick up where you left off, regardless of how much time has passed. With the right software on your Linux system, you can do just that.

INFO
[1] WABAC Machine: http://en.wikipedia.org/wiki/WABAC_machine
[2] C64 Archives: http://www.c64.com
[3] Gamebase 64: http://www.gb64.com
[4] VICE: http://www.viceteam.org
[5] 99 Bottles of Beer in C64 Basic: http://99-bottles-of-beer.net/language-commodore-64-basic-%28v2%29-1494.html
[6] Atari Archives: http://www.atariarchives.org
[7] U-M software archives: http://www.umich.edu/~archive/
[8] XL Search: http://www.newbreedsoftware.com/xlsearch2/
[9] Tim Mann's TRS-80 Pages: http://www.tim-mann.org/xtrs.html
[10] Ira Goldklang's TRS-80 Revived Site: http://www.trs-80.com/
[11] Jeff Vavasour's TRS-80 Emulation Page: http://www.vavasour.ca/jeff/trs80.html
[12] MAME: http://mamedev.org
[13] kxmame: http://kxmame.sourceforge.net