DOSBox Part 1: Introduction, Startup Scripts and The Keymapper

DOSBox is a great piece of software that allows users to run a huge collection of very old PC software dating back to the 1980s and 1990s on your Linux system. Versions for Windows, MacOS, and others exist as well.

This guide one of a series of articles about what you can do with DOSBox and how to get the best out of it. The focus of this article is to briefly touch on the some of the features of DOSBox before moving on the commands to run when DOSBox has started. The “autoexec” section of the config file will be used quite heavily throughout the series.  

What Can DOSBox Do?

Apart from DOS emulation, it allows you to control how many CPU cycles it emulates, that is, how fast or slow programs run. You can specify other machine settings such as graphics, memory, and sound. It is somewhat equivalent to a virtual machine. The vast majority of software ever written for DOS (including Windows 1.x, 2.x, and 3.x) will run on DOSBox.  

Mounting Drives And Commands To Run On Startup

Mounting drives simply means specifying a directory on the host system (Linux) to act as the root of a drive. For example to mount a C: drive:

Z:\>mount C: /home/unix_allsort/dosbox/C

Two things: the Z drive is the virtual drive that contains all of the commands used by DOSBox. And the directory that has been mounted would have all of the programs you wanted to run.

You can automate this by editing the DOSBox.conf file located in the .dosbox/ folder in your home directory. Since this is a hidden directory (as denoted by the ‘.’ at the start), remember to allow the file manager to display hidden files and folders. You can also make a shortcut to the “.dosbox” directory called “DOSBox” instead in your home folder.

Open the config file and scroll all the way down to the ‘[autoexec]’ section at the bottom of the file. Indeed the comments will tell you that you can put your mount lines here.

DOS systems had a batch script file called AUTOEXEC.BAT that was located at the root of the C: drive. This is what the ‘[autoexec]’ is, the startup script that is run every time the system boots. Therefore, whatever commands we run in this section must be valid commands.

Running Programs On Startup

​DOSBox can absolutely start programs on startup other than the mount command. All that is required is that the location of the program is mounted as a drive first. The script can then navigate its way to the directory containing the executable using ‘cd’, and then run the executable.  

What Else Can Be Achieved?

This guide provides the necessary skills that will be used in each successive guide. The main focus of this series is to provide practical examples and tutorials for achieving certain tasks using DOSBox. Later tutorials will cover handling floppy disk images and booting from them, same with hard drive images, running Windows 3.11, and other advanced tasks.  

A Couple Of Useful Tips

Now, you should be able to put your old games and programs into your “C” drive and navigate your way to them. You can also have more than one drive mounted. Be sure to use different letters, of course:

Z:\>mount D: /home/unix_allsort/dosbox/D
Z:\>mount E: /home/unix_allsort/dosbox/E ​

Also, for certain commands, you may want to change the key combinations used to activate such features. One feature is the video recording tool, which uses Ctrl-Alt-F5. Ctrl-Alt-F5 switches the user to a terminal screen, so this will need to change. The new key combination could be Ctrl-Shift-F5.

With DOSBox open, the welcome screen will tell you to press Ctrl-F1 to activate the keymapper. Once open, press “Mod 3”. The buttons “Mod 1” and “Mod 2” are already defined as “Ctrl” and “Alt” respectively; “Mod 3” needs to be defined as “Left Shift”. Press “Add” to add a key to bind to “Mod 3” and press the left shift button.

​Now select “Video” to deselect “mod2” and select “mod3” so that the keys to record a video become Ctrl-Shift-F5. Save the changes and exit the keymapper.