Reanimating legacy programs with DOSBox

Techno Dinosaur


Legacy applications and games experience a revival in the DOSBox. The software emulates a PC, including its legacy operating system.

By Tim Schürmann

PatSM, Fotolia

Those were the days! Guybrush Threepwood sailing to "Monkey Island," blocky tires screeching in "Need for Speed" and a square-faced Lara Croft jumping and running through her first adventure (Figure 1). The name MS-DOS awakens nostalgic memories in many an older PC user. DOSBox [1] lets you install the basics for a revival on your Linux PC.

Figure 1: Lara Croft looked fairly blocky in the first version of Tomb Raider on DOS.

The DOS operating system by Microsoft was the predecessor to Windows and was even included with Windows Me up to the year 2000. Not surprisingly, people still launch the occasional MS-DOS program today - whether they need to read documents from a defunct word processor, rescue customer data from a legacy dBase database, or catch up on the latest retro craze to run a classic game.

Doing so on state-of-the-art hardware involves a number of obstacles. First, you need to obtain a copy of MS-DOS or one of the many clones, such as the free FreeDOS [2]. Second, you need to boot it in an emulator such as VirtualBox, set up the system, and find your way around the wacky world of the MS-DOS command line. This can be an obstacle: MS-DOS will only manage 640KB of RAM by default, which doesn't leave much space for various drivers for your mouse, the CD-ROM drive, and so forth.

With filenames like himem.sys or terms such as EMS, readers who are familiar with DOS will still groan today. Additionally, more or less any MS-DOS program needed its very own configuration, thus necessitating a bunch of special boot disks. At the time, some programs and games actually offered to create a matching boot disk so that you could run them.

Artificial World

Before you give up all hope of enjoying a quick round of "Need for Speed" (Figure 2), why not give DOSBox a spin? The small Linux program not only emulates a legacy computer - one that would have been state-of-the-art in the early 90s - it comes complete with the matching operating system. The developers added a couple of convenience functions to this package. For example, most DOS programs or games will launch without the need to tweak a single configuration file, and in many cases, you don't need to be familiar with cryptic DOS commands.

Figure 2: The first version of Need for Speed was regarded as a graphical masterpiece at the time. The resolution of 640x480 pixels was amazingly high.

DOSBox is in the repositories of most major distributions; typically, you can run your package manager to install it. However, make sure you have the latest version 0.73. Besides fixing a number of bugs, it adds some new features. If your distribution only offers an older version, you might prefer to build your own from the source code, as described in the "Up to Date" box.

Up To Date

When this issue went to press, the DOSBox homepage offered an up-to-date binary package for Gentoo and an obsolete package for Fedora. If your distribution does not have the current version of DOSBox, you have no option but to download the source package. After doing so, use your package manager to install the SDL (libsdl), SDL_Sound, and SDL_Net packages, along with the corresponding developer packages (which you can identify by their -dev or -devel name components).

Additionally, you need the G++ program. In a terminal window, change to the directory with the unpacked files, and when you get there, enter the ./configure && make command. After doing so, you will have the complete dosbox binary in your src/ subdirectory, which is all you need for the installation. Just copy the file to a directory that your $PATH variable points to.

Besides DOSBox, you will also need a program or game. The easiest approach is to copy its data into a directory on Linux. The dosbox/<path>/<program>.exe -exit command will launch the application in a terminal. Adding -exit tells DOSBox to quit when you quit the program. The DOS program can use the path folder as its C: drive - or if you prefer, anything you store on drive C: in DOSBox will end up in the path directory on Linux.

If a DOS program needs a mouse, just click the window. DOSBox will then grab the pointer. To return the pointer to Linux, press the Ctrl+F10 keyboard shortcut. Other useful keyboard commands are Ctrl+F9, which quits DOSBox immediately, and Alt+Pause, which interrupts the emulation.

Remember that DOSBox emulates a complete computer. This requires some power, and exactly how much will depend on the program or game you are running. On a Core 2 Duo, the software will achieve speeds comparable to a Pentium III for simple DOS programs. More hardware-intensive programs will reduce this speed to that of an Intel 486 CPU-based machine, such as the computers that were state of the art in 1992. Some games might run too fast or too slow for this reason. One of my favorite examples of this is the "Testdrive" racing game, wherein the cars dash round the track at speeds that humans just can't match. In cases like this, you can slow the emulator down by pressing Ctrl+F11; to speed up again, press Ctrl+F12.

Command Set

Just like their Windows counterparts today, most DOS programs need to be installed. In this case, start by creating a directory on Linux into which you will be copying the program, such as /home/tim/nfs for the Need for Speed racing game. Now launch DOSBox without any parameters. This takes you to a prompt (Figure 3).

Figure 3: DOSBox has an additional function that lets you mount a directory as drive C: or a CD as drive D:.

Old hands will love this: You can control MS-DOS at the command line, just like a Linux terminal: cd changes directory; dir lists its content. The help command gives you a list of commands, and intro takes you to a kind of online help. To navigate the DOSBox command-line history and relaunch commands that you used previously, press the Up arrow and Down arrow keys.

MS-DOS assigns drive letters to each drive it finds. Because Linux only has a directory structure in which partitions are mounted transparently, DOSBox maps Linux directories to drive letters. The special command for this is mount C /home/tim/nfs to mount the /home/tim/nfs directory as drive C:.

To change to that directory, simply type the drive letter, followed by a colon (for example: C:). If you use the mounted directory in Linux, DOSBox will not show you the changes, but pressing Ctrl+F4 updates the view.

Disk by Disk

Like many other games, Need for Speed was supplied on a CD-ROM. To start, mount the CD on Linux and then map a drive letter to it in DOSBox:

Z:\><$$b>mount D /media/cdrom -t cdrom<$$b>
MSCDEX installed.
Drive D is mounted as CDRom /media/cdrom/

This command mounts the /media/cdrom folder as a CD drive (-t cdrom) with a drive letter of D and also tells DOSBox to load the required DOS driver. The MSCDEX installed message shows that this has worked.

If the output line you see does not look like Figure 3, which is what I experienced with openSUSE in our lab, you will need to unmount the drive by typing mount -u D. Then check the CD drives that DOSBox has found by typing mount -cd and use the number to the left of the drive with the additional -usecd parameter:

Z:\>mount D /media/cdrom -t cdrom -usecd 0

This forces DOSBox to use the drive in question. The alternative is to mount a CD image from an ISO file:

Z:\>imgmount D image.iso -t iso

Many legacy DOS programs expect the hard disk to be drive C: and the CD drive to be D: To avoid name collisions with the DOSBox drive Z:, it is a good idea to keep to these conventions (see the box "The Mysterious Z").

The Mysterious Z

Immediately after launching, DOSBox creates a virtual Z: drive that contains a variety of programs a DOS environment typically needs - including the mount command. Incidentally, you can't unmount or change this drive.

This also applies to autoexec.bat, which you can only modify indirectly via the configuration file. The Z: drive is the first entry in the PATH variable. If DOSBox fails to find a program in the current directory, it will look there first. The DOSBox wiki [3] explains how all the built-in commands work.

Interior Designer

After changing to the CD drive D:, look for the installation program and launch it. The file is typically called install.bat, install.exe, or setup.exe. If a game asks you about your sound card, your best option is to choose auto-detect. DOSBox emulates a Soundblaster 16 card by default.

After completing the install, you are taken back to the DOS prompt. Change to drive C: where you can launch the program or game. If you do not know the filename, look for files that end with .exe, or .bat - just as on Windows. Pressing Alt+Enter toggles between full-screen mode and a window view.

Instead of entering the mount commands each time you launch DOSBox, it is a good idea to let the emulator handle this. The original MS-DOS had an autoexec.bat file for precisely this purpose. The system would run all the commands listed in the file on booting. The [autoexec] section in the DOSBox configuration file ( dosbox-0.73.conf) emulates this behavior. This section is at the tail end of the file, and you can just add any mount commands you need, each in a line of its own.

Disk Jockey

In the early days, DOS games and programs were sold on floppy disks, and the first versions of Windows are no exception. If you still have a floppy drive, you can insert the first floppy and mount it on Linux. Alternatively, copy the content to a directory, such as /home/tim/disk. In both cases, you can mount the folder with the floppy content in DOSBox as follows:

Z:\>mount A /home/tim/disk -t floppy

Floppy drives on MS-DOS always had the drive letters A: and B:, and again it makes sense to keep to these conventions.

Many games - and also Windows - required several floppies. Just as on MS-DOS, the setup program will prompt you to change disks during the installation. If you are working with a physical floppy disk drive, unmount the floppy on Linux, insert the next floppy, mount it on Linux, and press Ctrl+F4 in DOSBox to announce the change. If you copied the content of the disk to a directory, empty the directory, copy the content of the next floppy to the directory, and then press Ctrl+F4.

Some desktop managers will grab this keyboard shortcut and use it to change to another (virtual) workspace. In this case, you can change the keyboard assignments. To do so, quit DOSBox and restart by typing:

dosbox -startmapper

This will take you to an interface where you can change the mappings (Figure 4). It shows you a virtual keyboard and all the special keys.

Figure 4: With this slightly archaic interface, you can change keyboard assignments. Keyboard shortcuts use a modifier key, Ctrl and Alt, for example, and a normal key.

To begin, click Swap Image (bottom right), then press Add, and press a replacement for F4. Save and Exit take you back. In this way, you can resolve other problems that you experience when running DOSBox (see the "Say Cheese" box).

Say Cheese

By default Ctrl+F5 will grab a screenshot and store it in a hidden directory: ~/.dosbox/capture. Ctrl+Alt+F5 will even grab a screen movie. Pressing the same keys again stops recording, then you can play back the results in a movie player such as MPlayer. Unfortunately, most distributions use this keyboard shortcut to pop up a console, and you will probably want to use the mapper to choose a different combination.

Some programs save you the effort of tinkering with keyboard mappings. Just copy the content of the disks into a directory on Linux and mount it as a hard disk in DOSBox. Then launch the installation program. Windows 3.1 falls for this trick, but many games don't - trial and error is your only approach.

Pitfalls

Talking of Windows 3.1, it's a good idea to let the Redmond veteran auto-detect your hardware. DOSBox emulates an SVGA graphics adapter with a Trio64 chipset by S3. If you enjoy experimenting, you can even download the matching S3 864 driver off the web and install it in Windows. Note that this can cause unstable DOSBox behavior. Creative still offers Windows 3.1 drivers for the emulated Soundblaster 16 [4].

If a game or program refuses to run, tweaking your dosbox-0.73.conf file might help. If you are experiencing problems with graphics, look for the

machine=svga_s3

entry and replace the part after the equals sign with the name of another card or another graphics standard. Your options include hercules (from the first IBM PC), CGA (4 colors), and EGA (16 colors). If you are trying to run VGA games and programs, it might help to replace the S3 card with an ET4000 (svga_et4000); Windows 3.1 has drivers for this. The memsize=16 line sets the memory size to 16MB; no 16-bit program will use more than 64.

If the SoundBlaster 16 is too new for the game you want to run, replace it with another model. Look for the sbtype=sb16 line and replace sb16 with sb1, the value for the first SoundBlaster card, sb2 for the second model, sbpro1 for a SoundBlaster Pro, or sbpro2 for its successor. In the lines below this (sbbase=, irq=, dma=) you can tweak your configuration, but this does assume some knowledge of your hardware.

The DOS version that comes with DOSBox is not a full-fledged substitute for the original MS-DOS because it lacks many applications and utilities that later MS-DOS versions included (such as edit). Additionally, the developers mainly had games in mind. The fact that applications run in DOSBox is just a useful side effect. Many sources on the net still offer applications and games for MS-DOS today (see the "DOS Fodder" box).

DOS Fodder

Once you have tasted blood, you might be asking where you can get more legacy games. Besides used copies from flea markets or on eBay, GOG.com offers legacy games at budget prices [5]. In contrast to many illegal abandonware sites, this vendor offers you licensed programs.

Valve's Steam sales platform also offers classic games that you can bring to life in DOSBox. If you do decide to purchase an application or game, make sure you obtain the right version for your version of MS-DOS.

More Tweaks

If you are prepared to put more effort into tweaking the emulator's configuration file, you can open up more interesting features. For example, if you set DOSBox up to do so, it can use the IPX protocol to talk to other DOSBoxes over the wire. This means that you can use some legacy games on the web, although the makers never intended this to happen. To help set up the DOSBox configuration file (dosbox-0.73.conf), many fans developed graphical interfaces. The DOSBox wiki has a small selection with corresponding links [6].

INFO
[1] DOSBox: http://www.dosbox.com
[2] FreeDOS: http://www.freedos.org
[3] DOSBox wiki: http://www.dosbox.com/wiki/Main_Page
[4] SoundBlaster 16 drivers http://support.creative.com/downloads/download.aspx?nDownloadId=273
[5] gog.com: http://www.gog.com/
[6] Front ends: http://www.dosbox.com/wiki/DOSBoxFrontends
THE AUTHOR

Tim Schürmann is a computer scientist and is currently working as a freelance author. Tim starting working with Linux back in the 1990s and has published several books and articles in various languages on the free operating system. Apart from that, he is absolutely convinced that VI must have been invented by the devil himself. For more information, visit Tim's homepage at www.tim-schuermann.de