When an Australian who goes by the internet name "Sparcie" decided to review some of my games (I guess he found it via a GitHub search), I noticed he did it on an MS-DOS emulator named DosBox.
(Sparcie has a treasure of awesome videos on various BASIC programs, games and legacy hardware. Check out his channel and blog)
I thought I'd give it a try too, and although it was a bit hard to understand at first, it's easy once you understand why it was created as such.
Installing dosbox
To run it on Ubuntu, first install it using:
sudo apt-get install -y dosbox
Then start it by typing "dosbox" (without the quotes) in a terminal. That'll create a config file that you can find in a hidden folder in your home folder, named ".dosbox".
ls -altrh will show you the folder. In Nautilus (the graphical file manager that's the equivalent of Windows Explorer), you can press Ctrl+H to see the file, since it's a hidden file.
Initial configuration
To be able to access files from Ubuntu on dosbox, you can create a shared folder named DOS. I'll assume you've created the folder in the home folder ~/DOS. The tilde (~) is a shortcut for the home folder in Ubuntu.
The hidden folder is in Ubuntu's home folder, and contains a configuration file named dosbox-<version>.conf.
Similar to the autoexec.bat file in MS-DOS which used to be run on startup (same as startup scripts for Ubuntu), the dosbox conf file has an autoexec section where you can type DOS commands to execute when dosbox starts. So search at the bottom of the conf file to find "[autoexec]", and below it you can type your commands. I typed the following:
[autoexec]
mount C ~/DOS
echo "~/DOS is mounted onto the C drive"
C:
Remember that the folder names are case sensitive. This ensured that the DOS folder was mounted onto the C drive and the current drive was automatically shifted from the default dosbox Z drive to the C drive.
Now, once you start dosbox from the Ubuntu terminal, you'll see an emulated MS-DOS command prompt from where you can run "dir" and you'll see the files you've placed in the ~/DOS folder.
Adjusting program execution speed:
If your plan was to run DOS games, you can do so. However, you'll notice that some games run slower than they are supposed to, and some run too fast. To adjust this, you can search the conf file for the line containing "cycles=auto", and do some trial and error with various values like:
cycles=normal 1000
or
cycles=normal 5000
For a more specific value, see these tables which show which CPU type the values represent.
The conf file shows there are a lot of other settings that can be emulated. See the FAQ for more info on dosbox. Wish you a happy trip down the memory lane.
Update:
As Sparcie mentioned in the comments, you can use Ctrl+F11 to reduce the cycles while dosbox is running (the cycle value will be shown at the top of the window. Ctrl+F12 speeds it up). However, if dosbox is using just one core, taking the cycle count too high will simply put one CPU core at 100% and slow down the program in dosbox. Adjusting the core's setting might help, but I haven't tried that yet. Perhaps a simpler option would be to just use a virtualbox with an older version of Windows installed. Or, use one of the modern QBasic interpreters.
Turns out there's an official QBasic for Windows 10, from Microsoft, there's a QBasic64 for Windows, Linux and Mac! (with source code). Nice to see people maintaing QBasic even after all these decades. Similarly, there's even a modern Logo.
2 comments:
Hi Nav,
Nice post about Dosbox, One thing I'd like to add is you can speed up or slow down the emulation at run time by pressing Ctrl+12 to speed up and Ctrl+11 to slow down. This depends on the settings in your dosbox.conf to a degree but will allow for adjustment on the fly.
I ended up with a fairly high cycle count for capturing your game, I also found that running it in the QuickBasic interpreter (as opposed to QBasic) made it run a bit smoother. Compiling it into a native DOS executable with QuickBasic would probably also speed it up quite a bit.
An option for modern machines is to use QB64 which should be able to run and compile it for modern systems. However it might have the opposite problem of running too fast!
Anyhow keep up the good work :-)
Sparcie
Hey, the keyboard shortcuts are cool! I had seen it earlier, but didn't try it. I'm both surprised and impressed to see QB64 (and even Microsoft has released an official QBasic for Windows10). Many years back I had tried compiling Digger forever, but it didn't get compiled due to some error. Some of my other games had got compiled. This was with an old QBasic compiler. Hopefully the newer compilers would do a better job. I don't recollect a drastic change in speed though...probably because of the timer loop. At least in Digger Forever, you can change the speed of the game during runtime by pressing the + or - keys. In most of my games you should be able to find a short WHILE timer loop that serves as the tiny pause the game requires in each cycle. Altering the timer value will change the game speed. Glad to see your comment here, and thanks for the info on the newer QBasic interpreters :-)
Post a Comment