Thursday, February 20, 2014

Monochrome & Hercules Graphics Aspect Ratio and Scaling

The IBM Monochrome Display and Printer Adapter output 80-column text with a 9x14 cell size.  This gives 720x350 pixels.  The Hercules Graphics Card is a clone which adds a 720x348 graphics mode.  The aspect ratio of the graphics mode, with perfectly square pixels, is 2.07 : 1.  However, the IBM Personal Computer (Monochrome) Display 5151 has a less horizontally rectangular tube that measures about 9.5 inches by 6.5 inches from one edge of the screen to the other.  The diagonal display measures about 11.5 inches.  This would give an aspect ratio of 1.46 : 1.

The active display area does not reach the edges of the monitor.  I measure it to be about 8.75 inches by 5.5 inches.  This gives an aspect ratio of 1.59 : 1.  The graphics mode loses two lines and thus the aspect ratio is a sliver wider.  Coincidentally, this is the square pixel ratio of CGA 320x200. There are no horizontal or vertical size or hold adjustment knobs on the monitor, only brightness and contrast.  Here is a screenshot showing, somewhat faintly, the visible screen area on a 5151 :

DOSBox can take screenshots of the Hercules Graphics mode.  Here is one such screenshot, untouched : 

While it is a bit squashed, doubling the vertical resolution (720x696), as some Mobygames screenshots do, is just not appropriate.  If you do that, you will have an aspect ratio of 1.03 :1.  As you can see from the image of the real monitor, the visible screen area is not a nearly-perfect square or anything near it.  

While it is not perfect, the best compromise is to increase the vertical size of a screenshot by 25% using nearest neighbor interpolation.  If you resize the screenshot to 720x435, you get this result :

This gives a 1.66 : 1 aspect ratio, which is far, far closer to the ideal ratio while keeping upscaling artifacts to a minimum.  

Starflight's effective resolution is 160x200, which is fairly common with older games.  If you use a game that has a native 320x200 resolution, the artifacts can be a little more visible : 

Maniac Mansion Enhanced Version - Original
Maniac Mansion Enhanced Version - Resized
Leisure Suit Larry 3 - Original
Leisure Suit Larry 3 - Resized
One issue to note is that most PC games use a native 320x200 resolution, and their Hercules drivers often leave noticeably large borders.  Many, if not most games use double the horizontal resolution to 640 pixels, using an algorithm similar to what they would use for 640x200 CGA graphics.  Starflight's effective resolution with Hercules is 640x200.  The regular 16-color resolution of Maniac Mansion's graphics window is 320x128, so with Hercules they simply doubled it to 640x256.  The text size remains 8x8, so there is an unused section at the bottom of the frame.  Sierra did something similar with their AGI games.  Their graphics window is 320x168, so with Hercules they doubled that to 640x336 and used the extra 12 lines for the status bar.  Instead of keeping the 8x8 font, they used an 8x12 font unique to the Hercules driver.  Typing pauses the action like SCI games, whereas it does not in all other graphics modes.

For Leisure Suit Larry 3 and other SCI0 games, the native graphics area is 320x190 in 16-color modes with the status bar taking up the remaining 10 lines. They could not double up on the graphics because they only have 348 lines to use.  What Sierra did here is to increase the horizontal resolution of the whole screen to 640 and the vertical resolution to 300, effecting a 150% increase in the vertical resolution (including the status bar).  Every other line is repeated.  This may not give the nicest look, this was probably the simplest approach to take, which was important when dealing with taxed 8086 and 286 machines.  Also, there is is no way to decrease the brightness of each individual lit pixel, so traditional filtering techniques will not work.

Here are a few more screenshots showing how non-native Hercules games fit within the screen :


Greg Soravilla said...

Your site is so refreshing!

Trixter said...

By manipulating the 6845, it was possible to create a 640-pixel-wide hercules graphics mode. Have you found any Hercules games that do this, or have the majority simply centered a 640-wide line on the 720-wide graphics page?

Anonymous said...

Hmmm - from the 6845's view you should be able do create a real 640-pixel-wide hercules graphics mode. But wouldn't you need another clock/bandwith to achieve the horizontal scan rate of 18.43 kHz? The standard hercules bandwith of 16.257Mhz would have been to fast, I guess. Or wasn't the 5151 at fixed line frequency?

Great Hierophant said...

All IBM 5151 compatible devices use a 16.257MHz clock. This includes the Monochrome Display Adapter, the Hercules Graphics Card and the Enhanced Graphics Adapter. The EGA has a real 640x350 monochrome graphics mode, and as it uses an enhanced version of the 6845, this should be doable on a Hercules card.
Maybe this is what SIMCGA does.

Anonymous said...

Wow - thanks for your response! After writing my comment I realized that your blog post is already from February. That's why I didn't expect any reaction at all. Thanks for your cool blog, too. It was and is really fun to read- and there's still a lot to read!

And of course you're right: the original EGA had a clock of 16.257 MHz, too, and could be connected to an ibm5151 to show 640x350. I always guessed (!) that EGA would just show a simply centered 640-pixel-wide line on the 720-wide screen. I guessed that from the other guess that an ibm5151 should be fixed at a horizontal scan rate of 18,43 khz because of his age.And because of my information that the ibm5154 (ega monitor) had been the first monitor with variable scan rates.

If you divide the bandwith of 16.257 MHz by the scan rate of 18.43 kHz you get 882 pixels per line (720 visible). If you keep this ratio for a 640-pixel-wide screen you get a total of 784 pixel per line, which needs a 14.449 MHz clock (perhaps EGA uses the 14.318 MHz clock for 640x350 on a 5151?).

That's why I asked the question wether it is really possible to get a real 640x350 with a standard plain HGC. As far as I know the HGC had the 16.257 MHz clock fixed and couldn't use another clock. But probably I am wrong and/or my informations (out of the German book "PC Intern") are wrong.

Anyway, great blog you have! I'm really looking forward for the next entries.
(And sorry for my bad English - it's the first time I try to communicate in this language :-()

Great Hierophant said...

Actually I have to correct myself, a true Hercules card uses a 16.00MHz clock not 16.257MHz. IBMs cards use the 16.257MHz crystal. The relevant discussion is here :