Monday, January 19, 2009

DOSBox is wonderful

I've been using DOSBox for a while to run old DOS-based games on Windows. DOSBox emulates the old DOS environment, allowing games written for that environment to be run. In addition, it abstracts your computer's hardware from its emulated environment, basically allowing you to define the drive letters and what paths they refer to on your computer. It will even let you define a drive letter that points to a .iso, so if you're like me and make isos of all your games so you don't have to track down the disc and risk getting the disc damaged, you can still do that.

It creates a window, and lets you run your games windowed, or even fullscreen if you hit Alt + Enter. It will capture the mouse pointer if you click, so if you want to get it back you'll have to remember to press Ctrl + F10. There are other keyboard shortcuts that do different things, you can read about them in the readme.

DOSBox only has a few minor issues I've seen with the games I've run in it. Descent 1 and Duke Nukem 3D both have weird graphical glitches, usually when there's a fullscreen color flash (i.e. you're getting hit). Bits of that color will get "stuck" on the rest of the game's UI (typically the parts that don't get painted very often). The only way to fix this is to force it to repaint. In Descent, this means bringing up the automap. In Duke Nukem 3D, I believe the only way to fix it is to toggle fullscreen. The 7th Guest runs better in windowed mode than fullscreen, though this may be solvable by tweaking some config options.

DOSBox creates within its environment a special Z: drive. This drive contains various system-critical things like the drive mounting program, and the all-important autoexec.bat. If you look in DOSBox's config file (dosbox.conf, open it in your favorite text editor), all the way at the bottom, you can define what goes into autoexec.bat.

You can also create multiple config files and tell DOSBox which one to use when you start it. This makes it fairly easy to have a general config (dosbox.conf) that you work with to get games installed. Once you get a game installed, you can then copy your general config to a separate file, play around with settings, and set up a specific autoexec.bat to set up a proper environment, start the game, and exit when it ends.

For instance, my autoexec.bat in for The 7th Guest (in my config file t7g.conf) looks like this:
@echo off
mount c e:\games
imgmount d "d:\cd images\t7g-disc1.iso" "d:\cd images\t7g-disc2.iso" -t cdrom
c:
cd id\t7g
v !
exit

In case you're wondering why I run v ! instead of t7g (which is simply a .bat file that runs v !), it's because the exit command didn't seem to take effect when I ran t7g, and it does with v !. I specify both .iso files on one line because that way, I can tell DOSBox to swap between the discs by hitting Ctrl + F4 (and The 7th Guest does require this, once you go through the door to the attic it prompts for disc 2, and after beating the game it prompts for disc 1).

Then to wrap it all up and make it seamless, I made a shortcut and set the target like such:
"C:\Program Files\DOSBox-0.72\dosbox.exe" -noconsole -conf="C:\Program Files\DOSBox-0.72\t7g.conf"

The -noconsole option makes it not pop up a regular command line window (that it normally dumps error information to), and the -conf option tells it to use the config file I specify.

Now, whenever I click this shortcut, it starts The 7th Guest, and when I exit The 7th Guest, the window goes away. Pretty nice.

One thing DOSBox lacks (that's easy enough to fix yourself) is a copy of edit.com, the DOS-based text file editor. Having it around would be really handy for reading readmes and such within DOSBox's environment. Since it's so easy to fix, I might as well tell you my fix for it:
  1. Open up a Windows Explorer window.
  2. Browse to C:\WINDOWS\System32.
  3. Scroll down until you find edit.com and edit.hlp.
  4. Select both of them and press Ctrl + C to copy them.
  5. Navigate back to where you installed DOSBox. (by default, in Program Files)
  6. Make a subdirectory in DOSBox's directory. I called mine 'edit'.
  7. Go into that subdirectory and press Ctrl + V to paste the files.
  8. Go back to DOSBox's directory.
  9. Open dosbox.conf in your favorite text editor.
  10. Scroll all the way down to the bottom.
  11. Add the following lines to the autoexec.bat: (if your install directory is different, substitute that in place of this one)
    mount y "C:\Program Files\DOSBox-0.72\edit\"
    PATH=Z:\;Y:\
  12. Save your changes.
And you're set. Now you can edit text files from within DOSBox just by typing edit textfile.txt.

Whoops, got kinda carried away there. Time to end this post.

The verdict: Awesome. Brag about it to your friends.

No comments:

Post a Comment

I moderate comments because when Blogger originally implemented a spam filter it wouldn't work without comment moderation enabled. So if your comment doesn't show up right away, that would be why.