VOGONS


VGA custom resolution

Topic actions

First post, by hyperrmachine

User metadata
Rank Newbie
Rank
Newbie

I have been thinking of making a game for DOS. I want to use VGA so I went through the resolutions.

Traditional VGA modes are: […]
Show full quote

Traditional VGA modes are:

  • 640×480 in 16 colors or monochrome
  • 640×350 or 640×200 in 16 colors or monochrome (EGA compatibility)
  • 320×200 in 256 colors (Mode 13h) <--- This was used for a lot of games.
  • 320×200 in 4 or 16 colors (CGA compatibility)

--------------------------------------
VGA supports custom resolutions, with horizontal resolutions of:

  • 512 to 800 pixels wide, in 16 colors
  • 256 to 400 pixels wide, in 256 colors

And heights of:

  • 200, or 350 to 410 lines (including 400-line) at 70 Hz refresh rate, or
  • 224 to 256, or 448 to 512 lines (including 240 or 480-line) at 60 Hz refresh rate
  • 512 to 600 lines at reduced vertical refresh rates (down to 50 Hz, and including e.g. 528, 544, 552, 560, 576-line), depending on individual monitor compatibility.

For example, high resolution modes with square pixels are available at 768×576 or 704×528 in 16 colors, or medium-low resolution at 320×240 with 256 colors. Alternatively, extended resolution is available with "fat" pixels and 256 colors using, e.g. 400×600 (50 Hz) or 360×480 (60 Hz), and "thin" pixels, 16 colors and the 70 Hz refresh rate with e.g. 736×410 mode.

"Narrow" modes such as 256×224 tend to preserve the same pixel ratio as in e.g. 320×240 mode unless the monitor is adjusted to stretch the image out to fill the screen, as they are derived simply by masking down the wider mode instead of altering pixel or line timings, but can be useful for reducing memory requirements and pixel addressing calculations for arcade game conversions or console emulators. (From Wikipedia)

By the way I have a question. Is 400x256 a valid resolution? Can I use 400x256 (with 256 colors) with square pixels?

Reply 1 of 22, by mkarcher

User metadata
Rank l33t
Rank
l33t
hyperrmachine wrote on 2020-09-26, 03:44:

I have been thinking of making a game for DOS. I want to use VGA so I went through the resolutions.

"Narrow" modes such as 256×224 tend to preserve the same pixel ratio as in e.g. 320×240 mode unless the monitor is adjusted to stretch the image out to fill the screen, as they are derived simply by masking down the wider mode instead of altering pixel or line timings, but can be useful for reducing memory requirements and pixel addressing calculations for arcade game conversions or console emulators. (From Wikipedia)

By the way I have a question. Is 400x256 a valid resolution? Can I use 400x256 (with 256 colors) with square pixels?

Yes, there is no problem with using that mode, but no square pixels, and you are forced to play non-standard memory tricks ("Mode X"), because it has more than 65536 pixels.

The 360x240 mode is widely known and uses standard VGA timings: 720 pixel timing horizontal, just as in all standard VGA text modes and 480 scanlines vertically, just in 640x480x16. 400x256 just adds the further pixels around the 360x240 standard timing pixels. You have no guarantee that the picture stays inside the viewable area of the display, and maybe it gets distorted near the edges due to the onset or exit of the retrace period.

You can get square pixels if you combine the 640-pixel timing horizontally with the 480-pixel timing vertically, the same is obviously true if you use double-width pixels (320 horizontally) and double-scanning (240 vertically). As this mode uses the 720-pixel timing, the pixels are slightly taller than they are wide. The 400x256 mode expands by around 10% from the standard 360 pixels. If you apply the same expansion to 320 pixels, you get something like 352x256 with square pixels.

Reply 2 of 22, by hyperrmachine

User metadata
Rank Newbie
Rank
Newbie
mkarcher wrote on 2020-09-26, 06:47:
Yes, there is no problem with using that mode, but no square pixels, and you are forced to play non-standard memory tricks ("Mod […]
Show full quote
hyperrmachine wrote on 2020-09-26, 03:44:

I have been thinking of making a game for DOS. I want to use VGA so I went through the resolutions.

"Narrow" modes such as 256×224 tend to preserve the same pixel ratio as in e.g. 320×240 mode unless the monitor is adjusted to stretch the image out to fill the screen, as they are derived simply by masking down the wider mode instead of altering pixel or line timings, but can be useful for reducing memory requirements and pixel addressing calculations for arcade game conversions or console emulators. (From Wikipedia)

By the way I have a question. Is 400x256 a valid resolution? Can I use 400x256 (with 256 colors) with square pixels?

Yes, there is no problem with using that mode, but no square pixels, and you are forced to play non-standard memory tricks ("Mode X"), because it has more than 65536 pixels.

The 360x240 mode is widely known and uses standard VGA timings: 720 pixel timing horizontal, just as in all standard VGA text modes and 480 scanlines vertically, just in 640x480x16. 400x256 just adds the further pixels around the 360x240 standard timing pixels. You have no guarantee that the picture stays inside the viewable area of the display, and maybe it gets distorted near the edges due to the onset or exit of the retrace period.

You can get square pixels if you combine the 640-pixel timing horizontally with the 480-pixel timing vertically, the same is obviously true if you use double-width pixels (320 horizontally) and double-scanning (240 vertically). As this mode uses the 720-pixel timing, the pixels are slightly taller than they are wide. The 400x256 mode expands by around 10% from the standard 360 pixels. If you apply the same expansion to 320 pixels, you get something like 352x256 with square pixels.

OK, but can you please use images so I can understand this better? I don't know much about hardware.

EDIT: I have a question; What are some custom resolution modes that use square pixels + 256 colors?

Reply 3 of 22, by Grzyb

User metadata
Rank Oldbie
Rank
Oldbie
hyperrmachine wrote on 2020-09-26, 12:19:

EDIT: I have a question; What are some custom resolution modes that use square pixels + 256 colors?

320x240
360x270 - may require V-size adjustment on the monitor

Nie tylko, jak widzicie, w tym trudność, że nie zdołacie wejść na moją górę, lecz i w tym, że ja do was cały zejść nie mogę, gdyż schodząc, gubię po drodze to, co miałem donieść.

Reply 4 of 22, by Benedikt

User metadata
Rank Oldbie
Rank
Oldbie

It's worth pointing out that any 256 color mode with more than 65536 pixels will have to use bit planes, which complicates programming.
However, technically, nothing speaks against using a 320x200 mode with the timings of a 320x240 mode, i.e. with square pixels and letterboxing.

Reply 5 of 22, by mkarcher

User metadata
Rank l33t
Rank
l33t
Benedikt wrote on 2020-09-26, 13:09:

However, technically, nothing speaks against using a 320x200 mode with the timings of a 320x240 mode, i.e. with square pixels and letterboxing.

Except for the refresh rate of 60Hz. It causes noticable flicker on a lot of VGA (or Super-VGA) CRT monitors. But you are right that this mode is perfectly in specifications of the VGA card and the VGA monitor. If we allow V-Size adustment to squeeze 270 lines into 240 lines (as the poster above you suggested), I would also allow V-Size adjustment to artificially letterbox 320x200 to obtain square pixels, without adding the black lines that drop the refresh rate from 70Hz to 60Hz.

Reply 6 of 22, by pan069

User metadata
Rank Oldbie
Rank
Oldbie

My experience is that "exotic" modes/resolutions will run fine in something like DOSBox but many LCD's won't be able to display them. The only 13h based tweaked resolutions that worked for me across the board are 320x400 and 320x240.

Reply 7 of 22, by Benedikt

User metadata
Rank Oldbie
Rank
Oldbie

The 360x200 mode should be similarly compatible, because it essentially shares its timing characteristics with VGA text mode.
It might not sound particularly useful, at first, but will result in almost square pixels on a modern 16:9 screen.

Reply 8 of 22, by hyperrmachine

User metadata
Rank Newbie
Rank
Newbie
Grzyb wrote on 2020-09-26, 12:35:
hyperrmachine wrote on 2020-09-26, 12:19:

EDIT: I have a question; What are some custom resolution modes that use square pixels + 256 colors?

320x240
360x270 - may require V-size adjustment on the monitor

What's a V-size adjustment?

EDIT: Another unrelated question here; can SVGA support custom resolutions?

Reply 9 of 22, by kdr

User metadata
Rank Member
Rank
Member
mkarcher wrote on 2020-09-26, 21:20:

Except for the refresh rate of 60Hz. It causes noticable flicker on a lot of VGA (or Super-VGA) CRT monitors.

Yeah, I was shocked recently at how awful Windows 3.1 looked at 640x480x16 @ 60Hz on my Trinitron CRT. It was a hideous flickering mess! Much worse than what I remembered.

I made haste to get the SVGA drivers installed so I could switch to a nice 640x480 @ 72Hz mode.

On the topic of games, however, a 60Hz refresh might be acceptable if the game has a predominately black background. It's the large areas of solid white that make the flicker so obvious.

Reply 10 of 22, by kdr

User metadata
Rank Member
Rank
Member
hyperrmachine wrote on 2020-09-28, 01:43:

What's a V-size adjustment?

EDIT: Another unrelated question here; can SVGA support custom resolutions?

V-size adjustment means just that: a knob on the CRT that adjusts the vertical size of the picture, stretching/compressing it. It's a common enough control on the front panel of most SVGA monitors.

"SVGA" can mean two things: one meaning is just "a video chipset that can do higher resolutions / more colours than standard VGA". If you have the technical reference for your SVGA chipset, it will detail which registers to program to create whatever kind of video mode you like. The problem is that every SVGA chipset has extended the VGA registers in different and incompatible ways.

So the other meaning of "SVGA" is "VESA BIOS Extensions", which is a standard that many SVGA cards implement to let you request a high-resolution mode. The card's BIOS is then responsible for poking the correct values into all the various registers. VESA selected a list of video modes (not sure what criteria was used) that a VESA-compliant card had to support, and this is where we get the familiar resolutions of 800x600, 1024x768, and 1280x1024. Some cards offer additional non-standard modes that can be set this way as well.

If you're willing to poke at the SVGA chipset registers directly, bypassing the VESA BIOS, you can indeed get whatever custom mode you like.

Reply 11 of 22, by mkarcher

User metadata
Rank l33t
Rank
l33t
hyperrmachine wrote on 2020-09-28, 01:43:

EDIT: Another unrelated question here; can SVGA support custom resolutions?

If you are talking about custom resolution already supported by the VGA card: Yes, most later SVGA cards also support them, because VGA compatibility was of high importance at that time for the general audience.

Graphics cards that were mostly targeted to CAD engineers, that were mostly running only the professional CAD software that used the card in an acceleration mode sometimes included VGA compatibility only as "bonus" to be able to run the BIOS setup and DOS to start the CAD systems. Cards of this type may have mediocre VGA compatibility and fail on custom modes.

Also, laptop chipsets that are designed to drive LCDs with fixed resolution likely fail to properly display these modes on the internal LCD and might also fail to drive them on the external VGA connector, especially in "both LCD and CRT enabled" configurations.

Reply 12 of 22, by Benedikt

User metadata
Rank Oldbie
Rank
Oldbie

One issue that is often overlooked is that different modes might need different pixel clocks.
VGA has 25.175 MHz, only, but higher resolutions typically need a higher frequency to keep the refresh rate acceptable.
PLL-based designs will typically be more flexible than SVGA cards with separate crystal oscillators.

However, the biggest problem is still the absence of an established standard.
This means that you will have to figure out how your card works, first, e.g. by looking at X-server drivers.

Reply 13 of 22, by mkarcher

User metadata
Rank l33t
Rank
l33t
Benedikt wrote on 2020-09-28, 09:38:

One issue that is often overlooked is that different modes might need different pixel clocks.
VGA has 25.175 MHz, only, but higher resolutions typically need a higher frequency to keep the refresh rate acceptable.
PLL-based designs will typically be more flexible than SVGA cards with separate crystal oscillators.

This is true for custom high-resolution modes. Setting higher clocks, and especially programming PLL-based clock chips is different for different cards. It got easier when clock generation, RAMDAC and VGA core were integrated into a single chip (integrating these three chips into one is what named the S3 Trio chips). For cards with dedicated clock-chip and RAMDAC, mode-setting depends on many unknowns, and that's why the X Server worked out-of-the-box only on some video cards in 1995.

This thread, up to now, focussed on custom modes on standard VGA hardware using only the 25.175 MHz and 28.322 MHz clock, as well as the standard VGA-monitor that can synchronize 350 or 400 lines at 70Hz as well as 480 lines at 60Hz. These custom modes (often called tweak modes) can be set on most SVGA hardware without knowledge about the specifics of the card. If you start using the capabilities of SVGA cards, espcecially with programmable PLLs, new possiblilities arise like 1280x960 at 60 Hz interlaced on standard VGA monitors (oh the flicker, but hey, did you ever see that many pixels synced on standard VGA?), or, better suited for the eyes, 1056x792 at 70Hz interlaced with square pixels (using the 640x400 timings). The 1280x960 modes needs 50.350 MHz pixel clock, and the 1056x792 mode needs 41.5 MHz pixel clock. It's quite likely you can find a 40MHz and a 50MHz clock on second-generation Super-VGA cards, while first-generation Super-VGA only offered the standard VGA clockas as well as 36 MHz for 800x600 @ 56Hz and 44.9 MHz for 1024x768 @ 87 interlaced.

Reply 14 of 22, by Grzyb

User metadata
Rank Oldbie
Rank
Oldbie

Once upon a time, I used to play a lot with this ModeLine calculator - https://www.arachnoid.com/modelines/
Then pasted the results into /etc/X11/xorg.conf , so to add support for plenty of resolutions - very convenient for using Dosbox full-screen.

BTW, VGA BIOS only enables DoubleScan for 200-line modes, effectively making them 400-line.
But it's perfectly possible to use DoubleScan with other modes as well, eg. 640x480 can be turned into 960-line, which has a nice effect on big CRT monitors - at 480-line scanlines are clearly visible, but not at 960-line.

Nie tylko, jak widzicie, w tym trudność, że nie zdołacie wejść na moją górę, lecz i w tym, że ja do was cały zejść nie mogę, gdyż schodząc, gubię po drodze to, co miałem donieść.

Reply 15 of 22, by hyperrmachine

User metadata
Rank Newbie
Rank
Newbie
mkarcher wrote on 2020-09-28, 07:27:
If you are talking about custom resolution already supported by the VGA card: Yes, most later SVGA cards also support them, beca […]
Show full quote
hyperrmachine wrote on 2020-09-28, 01:43:

EDIT: Another unrelated question here; can SVGA support custom resolutions?

If you are talking about custom resolution already supported by the VGA card: Yes, most later SVGA cards also support them, because VGA compatibility was of high importance at that time for the general audience.

Graphics cards that were mostly targeted to CAD engineers, that were mostly running only the professional CAD software that used the card in an acceleration mode sometimes included VGA compatibility only as "bonus" to be able to run the BIOS setup and DOS to start the CAD systems. Cards of this type may have mediocre VGA compatibility and fail on custom modes.

Also, laptop chipsets that are designed to drive LCDs with fixed resolution likely fail to properly display these modes on the internal LCD and might also fail to drive them on the external VGA connector, especially in "both LCD and CRT enabled" configurations.

Thank you, but I was not asking about VGA custom resolution compatibility; I was asking if SVGA supports custom resolution (no VGA custom resolution compatibility).

Reply 16 of 22, by vlask

User metadata
Rank Member
Rank
Member

Dunno if it helps, but highest common resolution you can use on every VGA card is 360x480. Its one of my testing resolutions for Quake 1, as every VGA card i tested supports it. Even original IBM VGA...
https://youtu.be/octArwHpaiY

Not only mine graphics cards collection at http://www.vgamuseum.info

Reply 17 of 22, by Grzyb

User metadata
Rank Oldbie
Rank
Oldbie
vlask wrote on 2020-09-28, 14:27:

360x480

Oh yeah, horrible aspect ratio, but provides 256 colors in decent resolution without the need to bother with all those SVGA variations.
So it was supported in Graphics Workshop, Scorched Earth, and many more...

Nie tylko, jak widzicie, w tym trudność, że nie zdołacie wejść na moją górę, lecz i w tym, że ja do was cały zejść nie mogę, gdyż schodząc, gubię po drodze to, co miałem donieść.

Reply 18 of 22, by Jo22

User metadata
Rank l33t++
Rank
l33t++

Yardemo runs in 320x400 256c. "And it's possible on every VGA"

https://youtu.be/F3mikF1bUT4?t=80

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//