First post, by mothergoose729
I hope I am not overstaying my welcome by creating two threads on the same topic!
A while ago I started asking questions about how to run DOSBox at native resolutions on a CRT monitored. I ended up going down quite the rabbit hole trying to figure it out, and so I wanted to post this to help centralize all the community’s knowledge and hopefully make it easier to find and reference if anyone wants to reproduce my results.
Original thread here: Dosbox without scaling?
The goal of this project is to make DOS on a modern PC look as close to identical as possible as a real DOS machine. This means identical resolution, identical refresh rate, and no software scaling. For example:
Lemmings in DOS on a Voodoo 3 PCI:
Lemmings running in Dosbox on a windows 10 machine:
What do I need?
- An OS + graphics driver that allows you to create custom resolutions
- A graphics card with a VGA output
- A CRT or DOS friendly LCD VGA monitor
Software
Mainline DOSBox (tested on 0.74-3)
Or PCem (v17)
My machine uses Windows 10 with a 980ti graphics card, so that is what I’ll be showing off here.
DOSBox Settings
Locate your DOSBox.conf configuration file or create one.
Change the following settings:
[sdl]
fullscreen=true
fulldouble=true
fullresolution=original
windowresolution=original
output=surface
[render]
aspect=false
scaler=normal2x
The surface ouput worked best for me - other modes could occasional have screen tearing.
If you are using a Nvidia graphics card, within your control panel, make sure "Low Latency" mode is set to "on" or "off" but not “Ultra”, as this can cause screen tearing even when you enable double buffering.
You will want the mainline release of DOSBox. I tried a couple of DOSBox forks and none of them worked quite right – although your mileage may vary.
PCEm Settings
Start your machine, and then under "Video" -> "Resolution" set to "Original"
Fullscreen mode-> Exclusive
Make sure VSYNC is checked.
Output stretch-mode -> None
Output scale->1x
Note* PCem has a problem with a couple of oddball resolution. It only effects a handful of games, but in general DOSBox works a bit more reliably for this setup.
Add Custom Resolutions
You can use the Custom Resolution Tool or your graphics control panel to create custom resolution. In linux you should be able to add custom modelines (not much of a linux guy myself so you’ll have to try it out).
For CRU, the download and instructions are in the link (Windows Only, Vista or newer):
https://www.monitortests.com/forum/Thread-Cus … ion-Utility-CRU
For my Nvidia card, I found that creating resolutions in my graphics control panel allowed me to add many more custom resolutions than I could in CRU, so that is what I recommend.
https://nvidia.custhelp.com/app/answers/detai … tom-resolutions
https://www.amd.com/en/support/kb/faq/dh-032
From what I have read, custom resolutions are not supported on Intel HD graphics. You will need an ATI or Nvidia graphics cards.
No matter what method you use, you need to manually configure your display timing. The custom resolutions you need to add can be found here:
https://docs.google.com/spreadsheets/d/14lErg … dit?usp=sharing
Here is an example using the CRU:
The game or application that uses that resolution are noted in the spreadsheet, so you can use it to check that everything is working. Once each resolution is added, you should be good-to-go.
Ok, now that the tl;dr portion is over, let's discuss some of the nitty gritty details.
DOS Resolutions - A Primer
As many of you know, most DOS games run internally at 320x200 resolution, which is scan doubled by the VGA card to 640x400 with a 70hz refresh rate. That spells all kinds of problems for today’s modern, fixed pixel, 60hz displays.
- 320x200 is a 16:10 aspect ratio that gets squished to 4:3 on analog monitors. To get the correct aspect ratio on modern LCDs you must use software scaling algorithms
- 60hz <> 70hz, so DOS on modern display panels feels juddery and sluggish. Gross.
That isn't the whole story though. The history of DOS includes many display standards, including CGA, EGA, VGA, and SVGA, each generation adding new features and display resolution while supporting legacy modes through backwards compatibility. What is more, the horizontal sync rate of PC monitors changed over the years as well, from 15khz, to 22khz in the EGA era, to 31+ khz on VGA monitors and modern displays.
As if that wasn't enough, DOS programmers could use all kind of tricks to add nonstandard display modes to their games and applications.
Fortunately, a lot of this can be simplified. When it comes right down to it, all but a few DOS game use resolutions that are cousins of the following two:
640x400@70hz - 449 lines
640x480@60hz - 525 lines
And indeed, the vast majority of DOS games run at exactly 320x200 scan doubled to 640x400 (mode 13h) or 320x240 scan doubled to 640x480 (mode x).
Notable exceptions are applications that render in text mode, like the DOS prompt (720x400@70hz or sometimes 720x480@60hz), which in the land of CRTs (where the horizontal resolution changes very little) this just means that text modes have a more active pixels and a slightly higher pixel clock than other graphics modes.
Exceptions to the rule
The following blog post was very helpful in tracking down those rare exceptions. There is a lot of interesting things to explore here:
https://nerdlypleasures.blogspot.com/2014/09/ … tions-when.html
First off, let's start with Lemming. The title screen in VGA mode runs at a none standard 640x350. What gives? Here it is running natively in DOS:
https://imgur.com/UNIzK8O
Notice the blank scanlines and the top and bottom? What is happening here is that Lemmings is using what is essentially the standard 640x400 resolution and choosing not to draw on 50 of the 400-vertical line. This gives you an active vertical resolution of 350 pixels, while actually having the same number of total lines at the standard display modes (which is 449 vertically). If you center the image within those 449 lines you get what we see in DOS. It is a “cousin” of the standard 640x400@70hz resolution that I mentioned before.
So, I copied my 640x400 resolution and changed the active pixels from 400 to 350. This pushed the image to the bottom of the screen instead of the center, so I increased the vertical front porch, which essentially moves the image "up", and got this.
https://imgur.com/HHF4LEC
Hm... close, but not quite right. What is going on here?
This is the probably the most frustrating part about this project. There is no such thing as a "standard" set of display timings for DOS. Every single graphics vendor implemented their own display timings a bit differently, and every single resolution for each piece of software can alter the display timings ever so slightly to get a different result. The exact same game running a different computer could have the title screen shifted a bit further up or down, a bit fatter on the horizontal axis or thinner, and more. What I ended up doing is reducing the total number of horizontal lines a bit, which stretches the image some, and then increased the front porch to re-center the image. It isn't perfect, but its close enough.
https://imgur.com/PGENe4M
Most nonstandard DOS resolutions are of this variety. Basically, take a standard DOS resolution, remove some of the active pixels and then manipulate the total number of pixels and the front porch to position on the screen. Not all DOS games put them dead center - some leave them on the top or bottom. But roughly center was easier, so that is what I did in these cases.
The Same, but Weirder
There were a couple DOS resolution though that look like one display standard but are actually completely different. Let's look at an old classic, Jazz Jack Rabbit. J-J uses mode 13h for the title screen, menus, and loading screen. That is 320x200@70hz, scan doubled to 640x400, with 16:10 aspect ratio squished down to 4:3. Standard fare.
The actual gameplay, however, uses a resolution of 320x199 pixels... at 60hz. Naively, you might thing that this is just another cousin of 640x400, and if you treat the resolution that way this is what you get:
https://imgur.com/brFgt4z
Only, that isn't what Jazz Jack Rabbit is supposed to look like. The secret is in the refresh rate. Jazz Jackrabbit is related to the 640x480@60hz resolution, not 640x400@70hz. It is a 16:10 aspect ratio game that is meant to be drawn with square pixels! Using 525 vertical line instead of 449 vertical line and tweaking the vertical front porch to compensate, we get this:
https://imgur.com/kYHA7WB
Much better!
Ok, noe let’s look at something similar but harder. Sierra’s “The Incredible Machine” is a title that uses resolutions that look like 640x400@70hz but are actually variations on 640x480@60hz. In particular, the title screen uses 320x400 pixel internally displayed as 640x400@60hz exactly! So, all we have to do is create a resolution of 640x400 but with 525 line instead of 449 and 60hz refresh rate instead of 70hz and we should be good to go, right?
https://imgur.com/V14jInX
Unfortunately, no. Neither DOSBox nor PCem are capable of distinguishing between 640x400@60hz and 640x400@70hz, nor can they tell the difference between 525 total lines or 449 total line. Whichever resolution you define first will be the one the emulator uses every time, regardless of the emulated refresh rate.
Fortunately, there is a pretty easy work around. In DOSBox, all you have to do is set the “full Resolution” option to “640x480”, and then DOSBox will just center the 640x400 title screen vertically for you. In PCem, you set the resolution from “Original” to “custom” and 640x480, and then set the output scale = “Integer” and it does the same thing. You can set a per game profile up for this weird odd duck and you are not doing too bad.
https://imgur.com/aZ4S0T1
Similar to this, “Line Wars” in MVGA Mode (but not SVGA Mode!) as well as System Shock CD when using the “320x400” display option are also 16:10 aspect ratio games meant to be displayed with square pixels in DOS! Who knew?!
The Weirdest of them All
By far, the strangest two games on that list are Jump n’ Bump and Earth Worm Jim. Both of them use completely oddball resolutions and refresh rates that, as far as I can tell, bear no resemblance whatsoever to any standard VGA or SVGA display mode.
Jump ‘n Bump has a not-quite 16:10 aspect ratio that is meant to fill an 800x600 frame, but at an oddball 54hz refresh rate. As far as I can tell, 800x600@54hz is not a thing. This shareware title is the only piece of software I know of that uses it. Using emulation, I had no idea what it was doing - I had to load this one on my DOS machine to even get a clue
Weirder still is Earthworm Jim, which uses a variation of 320x224 internal resolution scan doubled to 640x448, but at nonstandard 72hz refresh rate. What’s more, the screen positioning in DOS is also strange, with some margin on both the top and bottom and a not quite 4:3 intended aspect ratio (again, square pixels). Even more bizarre, Earth Worm Jim 1 runs at 72hz, but Earth Worm Jim 2 runs at 60hz internally! Both use the exact same display timing! What for? It makes no sense!
https://imgur.com/mwK6oKE
The Limits of Emulation
While I was able to get DOSBox and PCem to work more than well enough to do some DOS gaming, there are definitely some theoretical scenarios that emulation cannot cover. For one, neither emulator takes into account the total number of lines or refresh rate in a display mode when selecting the appropriate resolution. This can lead to problems, like with “The Incredible Machine”. If a game or a piece of software were to mix 70hz and 60hz display modes in the right way it wouldn’t be possible to emulate it entirely correctly. Also, for some games that transition between display modes quickly, like “Pinball Illusions” does with its intro sequence, some of the graphics can be lost in the delay between transitioning to each resolution - while windows and the emulator struggle to keep up.
I didn’t even bother trying to run any demo software, which, aside from adding a whole heap of new resolutions to my spread sheet, could probably introduce a lot of combinations that would be impossible using this kind of emulation.
I don’t think the problem is severe enough, nor the interest in running DOSBox and PCem in this way widespread enough, to warrant any kind of special attention from the developers. Still, it is worth noting that to completely accurately emulate DOS and all its display capabilities would probably require a dynamic modline setup similar to how “Groovy MAME” does it!
How can this be improved?
I don’t think for second that I have found all the unusual resolutions in commercial DOS software. If anyone knows of some more outlies, please let me know! The spread sheet can stand to grow some more.
I also am aware that many of the display timings I came up with are little more than educated guesswork. I think a better way to do it would be to measure the VGA timings directly from reference VGA cards instead. I think it can be done pretty easily with an Arduino and few wires and resistors, and even though I know basically nothing about circuits (I’m a software guy by trade!) it is a project I am interested in trying someday.
In general, if I got anything wrong in my explanation or in my setup I would be interested to know. If you tried to reproduce what I did and ran into any interesting issues and roadblocks those would be good to document too! What do you know that I don’t? What do you think? Let’s have a discussion 😊.