Saturday, July 3, 2010

How to run DOS in Ubuntu

Anyway, in order to run DOS under Ubuntu you require DOSBOX. You can install it either through the Synaptic Package Manager or by simply running the following command in the Terminal window:

sudo apt-get install dosbox

This installs DOSBOX on your computer. In order to run your DOS programs under Ubuntu now you need to create a folder, preferably using the path:

/home/username/dosprogs

“username” can be your name, or whatever login name you use with your Ubuntu system. Once that’s done, move all your DOS programs to this folder.

You can run DOSBOX using the following command in the Terminal window:

sudo dosbox

Initially you’re in Z: drive and if you try to go to C: drive you cannot go. So every time you launch DOSBOX you’ll need to mount your folder to a drive using this command (in the DOSBOX prompt):

mount h /home/username/dosprogs

This way whatever resides in “dosprogs” whether files or folder, can be accessed once you’ve gone to H: drive.

But it can be tedious to mount your folder to a drive each time you start DOSBOX. You can do it automatically each time you start the DOS utility under Ubuntu.

How to auto-mount a drive in DOSBOX
Start DOSBOX and at the Z: prompt execute

config -writeconf /home/username/dosbox.conf

This creates a DOSBOX configuration file in your home folder. Please note you need to create this file in your username folder and not in dosprogs.

You can quit DOSBOX after this.

Then open this newly-created file in gedit and go to the line that has [autoexec].

Under that line, just add

mount h /home/username/dosprogs

and save the file. The next time you launch DOSBOX this folder will already be mounted on a drive.

================
Step 1: Download and install the latest version of DOSbox. Do that from the DOSbox Website. The file you want is in the downloads section of that site. The latest version of DOSbox as of this writing is .61 so that is what these instructions are based on. Installation is simple. Double click on the file you downloaded and follow the onscreen instructions.
Step 2: Start up DOSbox and you will see two windows open. One says DOSbox at the top, has a version number and tells you what your current CPU cycles and frameskip settings are. When I refer to the main DOSbox window I am referring to the one with the CPU and frame skip information. Leave the other window alone at all times.
Step 3: We will now configure DOSbox to run optimally on your system. Close any programs that are running on your computer except for DOSbox and whatever you are using to view this document. Press control+alt+delete on your keyboard. This will open up the windows task manager (WTM). Most of the stuff here we can ignore. What we are looking for is in the lower right corner of the WTM. You should see something that says CPU usage, measured in percentage. It should say something like CPU usage 55%.
The goal with DOSbox is to get your CPU usage close to 100% while DOSbox is running. To do this, modify the amount of CPU cycles DOSbox emulates and how many frames DOSbox skips before it draws one on your screen. Increasing emulated CPU cycles will use more of your CPU power. Increasing frameskip will reduce usage of your CPU power. Ideal performance may require some of both, because Master of Orion will run poorly if there are not enough emulated CPU cycles, but it will also run poorly if you exceed 100% of your actual CPU usage. So if you raise emulated CPU cycles to the limit of your own machine's performance, and it is not enough, you can compensate with Frameskip to squeeze more performance from the power you have available.
To increase emulated CPU cycles, select the main DOSbox window and press ctrl-F12. At the top of the window you will notice that your CPU cycles went up by 500. If you go back to the WTM you might notice that, depending on the speed of your computer, your CPU usage went up as well. Keep pressing control + F12 until your actual CPU usage, as measured by the WTM, gets close to 100%. Don�t go all the way to 100%. You don�t ever want to add more CPU cycles to DOSbox when your CPU usage is at 100%.
Once you get near 100% CPU usage, you can increase the Frameskip. Go back to your main DOSbox window and press ctrl-F8. You will notice that your frameskip went up by one. Going back to the WTM you will notice that your CPU usage went down. Increase your CPU cycles until your CPU usage gets close to 100% again. Use the WTM's measurements of actual CPU usage to govern the settings you choose for emulated CPU cycles and Frameskip.
Step 4: Decide on a balance of emulated CPU cycles and frameskip settings and note your choices. (You can come back again later and tweak the settings to improve performance. For now, just pick any combination that your WTM reports as near, but not at, 100% of actual CPU usage).
Close DOSbox and open up DOSbox.conf. You can find this file either in the DOSbox directory or in the DOSbox program group in your start menu. This file controls how DOSbox runs, what it emulates and what settings it has when it starts. There are many categories and options. Find the section on [render]. You will probably have to scroll down a bit.
Under [render] you will see a line that says "frameskip=0". Change that to the frameskip setting you've chosen. If your setting was 1 then that line should read "frameskip=1".
Continue down in the config file and find the [cpu] section. You will see a line that says something like "cycles=2000". Set this to the number of emulated CPU cycles you've chosen. So if your cycles were set to 10000, this should read "cycles=10000".
After setting the frameskip and CPU cycles, save the config file and close it.
Step 5: Restart DOSbox. You should notice that DOSbox starts with the CPU and frameskip settings you specified in the config file.
Step 6: You are ready to "mount" your drives. MS-DOS does not include support for modern hard drives, but DOSbox can point the way with the mount command. Mounting is necessary to do anything inside DOSbox.
In your main DOSbox window you will see a line that says Z:\> with a blinking cursor. First, find out the letter of the hard drive where you have installed MOO. For most people it will be C. You can find this information in windows explorer.
To mount your hard drive, go to the Z prompt in your DOSbox window and type "mount (hard drive letter): (hard drive letter):\" then hit enter. Example:
mount C: C:\
If you did everything right you will get a message saying that your drive was mounted.
The mount command creates a "virtual hard drive" within DOSbox. The first letter of the mount command sets the drive letter of the artificial drive, the second letter points to an actual location on your system as Windows XP understands it. These two letters do not have to match. Example:
mount C: D:\
This will lead any command executed from within DOSbox, concerning the "C drive" to point in reality to your physical D drive. You can also mount directly to your MOO directory if you wish:
mount C: C:\mps\orion\
This would set the "root directory" of your virtual drive inside DOSbox to point to your MOO directory on physical drive C. This is not required.
Step 7: If you need to install MOO from CD or floppy, you will also need to mount a second drive. For CDROM, find the letter of your CDROM drive. For most people this will be D or E. You can find this information in windows explorer. Then type "mount (cd letter): (cd letter):\ -t cdrom". Example:
mount D: D:\ -t cdrom
If you did everything correctly you will get a message saying that your drive was mounted.
Step 8: Let's automate the mounting process so you don't have to repeat it manually each time you run DOSbox.
Open the DOSbox config file as you did in Step 4. You don�t need to close DOSbox this time. Scroll down to the very bottom of the file to the [autoexec] section. Find the section, "# Lines in this section will be run at startup." Each line you add here will be automatically carried out each time you start DOSbox.
Enter in the exact commands that you used to mount your drives. This will include the physical hard drive where you've installed Orion, and may include a second drive to provide access to floppy disks or CDROM. Examples:
[autoexec]
# Lines in this section will be run at startup.
mount c c:\
[autoexec]
# Lines in this section will be run at startup.
mount c c:\
mount e e:\ -t cdrom
Add the appropriate commands to the [autoexec] section inside the dosbox.conf file as shown above, then save the file and close it.
Step 9: You're ready to run Master of Orion. Bring up your main DOSbox window. You will need to point DOSbox to your MOO directory.
First type the letter of your mounted drive followed by a colon and press enter. This will select your mounted drive as the current drive within DOSbox. Example:
C:
Once you are on the correct mounted drive, you must select your MOO directory (where the game is installed). If you don't already know the right directory, find this information with Windows Explorer. It will probably be ORION or MPS\ORION. You will now need to switch to that directory. Use the DOS command to change directory. Type "cd (directory name)" Examples:
cd orion
cd mps\orion
You will then get a new line that says something like C:\MPS\ORION>. That is telling you that you are on the mounted C drive in the directory MPS in the subdirectory ORION.
Now type "orion" and the game will run, if you are in the correct directory. Type "install" to configure sound options or choose between keyboard and mouse control. (Goodness help you if you don't have a working mouse!)
Step 10: Master of Orion will now start up. Don�t panic if it loads slowly or runs funky!
Leave MOO running and open up the DOSbox config file again. Below where you entered the mounting commands, type in the commands you used to get to your MOO directory. For example, using the commands used in this guide, this section would now look like this:
[autoexec]
# Lines in this section will be run at startup.
mount c c:\
c:
cd mps\orion
Save the config file and close it. Every time you start up DOSbox, it will mount your drives for you and change directories to start you in your MOO directory. All you will need to do is type "orion" to start the game. Start up a game of MOO and play for a bit. Notice how fast it runs and how well your mouse works. Pay attention to how responsive the mouse is and how quickly the map scrolls when you move it. If everything runs smoothly then you are done! If things run slowly or your mouse acts funky then you may benefit from tweaking your settings.
Step 11: To make MOO run better you can play with your emulated CPU cycles and frameskip settings. We cannot provide you with settings to choose because the optimal settings depend on the speed of your computer. You can change these settings while DOSbox is running MOO, so tweak them until you get things running smoothly. Here are some tips:
1. If the map scrolls slowly or your mouse jerks and skips on the screen, you will probably need to increase your frameskip. Try doing so one level at a time. Don�t forget to open WTM and increase your CPU cycles again, as you want to use almost all of your available power to drive DOSbox and maximize performance.
2. If the game runs too slowly, you will need to increase your CPU cycles. Increase your frameskip setting first and then increase your CPU cycles until you get near 100% CPU usage again. If the game still runs slowly, continue to bump up your frameskip. If your frameskip gets too high, you will start to get decreased performance with skippy/jumping graphics and/or mouse cursor. Look for middle ground where you get the best total perfomance level.
3. If the map scrolls quickly but your mouse is jumpy or jerky then you may need to decrease your frameskip (Control + F7). Don�t forget that you will need to decrease your CPU cycles as well (using ctrl-F11). You should never exceed 100% of actual CPU usage. (If you do, that could be the problem!)
4. The opening movie and main menu screen will probably always run worse then the game itself. You may want to adjust performance from within an active game rather than during the movie or at the main menu.
Once you find settings that work for you write them down and update the settings in your config file to match.