• Please review our updated Terms and Rules here

VGA 320x200 60Hz

Mills32

Experienced Member
Joined
Sep 25, 2018
Messages
149
Location
Spain
Is it possible to get the VGA card to output a full screen 320x200 at 60 hz? (Instead of the default 70hz).

I could get 320x240 60hz with black bars at the top and bottom, but it does not look very good.

Why do I want 60hz?. Because it is more compatible with emulators, and monitors, and it means less work for slow pcs, because my game logic and updates are in sync with vertical blank.

Also I want the EGA mode to
work at 60 hz on VGA, (it also defaults to 70hz).

Thanks.
 
Last edited:
Not being too deep into VGA modes, but VGA uses a fixed vertical frequency of 31 kHz. This pretty much dictates the refresh rates you can use at the various modes.

More freedom came with SVGA/VESA. But I assume you ask for plain VGA cards.
 
> Is it possible to get the VGA card to output a full screen 320x200 at 60 hz?

It is, Jazz Jackrabbit for example does this. As an example case, what it does is it takes the standard INT 10h Mode 13h 320x200x256 video mode, which is

Pixel clock: 12.6 MHz
Horizontal:
- active: 320 pixels,
- border: 8 pixels
- front porch: 6 pixels,
- sync: 48 pixels,
- back porch: 18 pixels
Vertical:
- active: 400 lines, (vertical resolution = 200 lines doubled)
- border: 14 pixels,
- front porch: 6 lines,
- sync: 2 lines,
- back porch: 27 lines

with 12.6 MHz pixel clock, this amounts hsync of 12600000 / (320+8+6+48+16) = 31.66 kHz, and vsync of 12600000 / (320+8+6+48+16) / (400+14+6+2+27) = 70.508 Hz

Then Jazz directly edits the VGA adapter registers with three changes:
1. adjust Vertical front porch from 6 lines to 3 lines, : http://www.osdever.net/FreeVGA/vga/crtcreg.htm#10
2. adjust Vertical active from 400 lines to 450 lines (i.e. to make 320x225 resolution, but the 25 pixels are unused and left black): http://www.osdever.net/FreeVGA/vga/crtcreg.htm#06
3. adjust Vertical back porch from 27 lines to 58 lines. : http://www.osdever.net/FreeVGA/vga/crtcreg.htm#11 and http://www.osdever.net/FreeVGA/vga/crtcreg.htm#12

So in total, Jazz Jackrabbit gets this video mode:

Pixel clock: 12.6 MHz
Horizontal:
- active: 320 pixels,
- border: 8 pixels
- front porch: 6 pixels,
- sync: 48 pixels,
- back porch: 18 pixels
Vertical:
- active: 450 lines, (vertical resolution = 225 lines doubled)
- border: 14 pixels,
- front porch: 3 lines,
- sync: 2 lines,
- back porch: 58 lines

This amounts to hsync of 12600000 / (320+8+6+48+16) = 31.66 kHz (unchanged from above since horizontal parameters didn't change), and vsync of 12600000 / (320+8+6+48+18) / (450+14+3+2+58) = 59.77 Hz.

However, it sounds like you are looking for a solution where this would be applied to all VGA applications? That would be quite a bit trickier. There exists for example a VGA60HZ TSR project from wbc at Vogons: https://www.vogons.org/viewtopic.php?t=86219 , but it is unclear how compatible that will be with different applications. Maybe give that a go?
 
> Is it possible to get the VGA card to output a full screen 320x200 at 60 hz?

It is, Jazz Jackrabbit for example does this. As an example case, what it does is it takes the standard INT 10h Mode 13h 320x200x256 video mode, which is

Pixel clock: 12.6 MHz
Horizontal:
- active: 320 pixels,
- border: 8 pixels
- front porch: 6 pixels,
- sync: 48 pixels,
- back porch: 18 pixels
Vertical:
- active: 400 lines, (vertical resolution = 200 lines doubled)
- border: 14 pixels,
- front porch: 6 lines,
- sync: 2 lines,
- back porch: 27 lines

with 12.6 MHz pixel clock, this amounts hsync of 12600000 / (320+8+6+48+16) = 31.66 kHz, and vsync of 12600000 / (320+8+6+48+16) / (400+14+6+2+27) = 70.508 Hz

Then Jazz directly edits the VGA adapter registers with three changes:
1. adjust Vertical front porch from 6 lines to 3 lines, : http://www.osdever.net/FreeVGA/vga/crtcreg.htm#10
2. adjust Vertical active from 400 lines to 450 lines (i.e. to make 320x225 resolution, but the 25 pixels are unused and left black): http://www.osdever.net/FreeVGA/vga/crtcreg.htm#06
3. adjust Vertical back porch from 27 lines to 58 lines. : http://www.osdever.net/FreeVGA/vga/crtcreg.htm#11 and http://www.osdever.net/FreeVGA/vga/crtcreg.htm#12

So in total, Jazz Jackrabbit gets this video mode:

Pixel clock: 12.6 MHz
Horizontal:
- active: 320 pixels,
- border: 8 pixels
- front porch: 6 pixels,
- sync: 48 pixels,
- back porch: 18 pixels
Vertical:
- active: 450 lines, (vertical resolution = 225 lines doubled)
- border: 14 pixels,
- front porch: 3 lines,
- sync: 2 lines,
- back porch: 58 lines

This amounts to hsync of 12600000 / (320+8+6+48+16) = 31.66 kHz (unchanged from above since horizontal parameters didn't change), and vsync of 12600000 / (320+8+6+48+18) / (450+14+3+2+58) = 59.77 Hz.

However, it sounds like you are looking for a solution where this would be applied to all VGA applications? That would be quite a bit trickier. There exists for example a VGA60HZ TSR project from wbc at Vogons: https://www.vogons.org/viewtopic.php?t=86219 , but it is unclear how compatible that will be with different applications. Maybe give that a go?
That's what I needed :), I want this for a game I'm making, and tweaking the vga registers to get custom modes can be difficult.
 
Oh I see, that's super cool!

Here is a small code snippet to reprogram the VGA registers to such a 60hz mode. I used Tweak 1.6b to find these values.

Screenshot 2023-01-11 22-45-54.png

depending on the #define, you can get either a 5:6 VGA mode 13h nonsquare pixels, or Mode X style 1:1 square pixels.

Screenshot 2023-01-11 22-47-37.png

See copy-pasteable code here: https://gist.github.com/juj/34306e6da02a8a7043e393f01e013f24

Many VGA displays support up to 75hz input, so that would allow making an option to configure the refresh rate up from 70hz as well :)
 
Oh I see, that's super cool!

Here is a small code snippet to reprogram the VGA registers to such a 60hz mode. I used Tweak 1.6b to find these values.

View attachment 1251451

depending on the #define, you can get either a 5:6 VGA mode 13h nonsquare pixels, or Mode X style 1:1 square pixels.

View attachment 1251452

See copy-pasteable code here: https://gist.github.com/juj/34306e6da02a8a7043e393f01e013f24

Many VGA displays support up to 75hz input, so that would allow making an option to configure the refresh rate up from 70hz as well :)
I had trouble understanding the "back porch" thing, and I did not get the 60 hz mode, I'm going to test this code :biggrin:
 
I think I must be missing something:

2. adjust Vertical active from 400 lines to 450 lines (i.e. to make 320x225 resolution, but the 25 pixels are unused and left black): http://www.osdever.net/FreeVGA/vga/crtcreg.htm#06

So isn't any 60hz mode set up like this just going to be using the 640x480 mode's square-pixel framing and thus just give you a "letterboxed" 320x200@60hz, not the "full screen" requested in the OP? Comparing with the standard values for regular VGA the Jazz Jackrabbit "tweaked" values for total frame are identical.


Is there a photo of this running on a real monitor? I see that #ifdef SQUARE_PIXELS being set changes the vsync parameters to different numbers than it not being set, but does this really result in an actual monitor changing the framing of the output so one is vertically stretched compared to the other?
 
I think I must be missing something:



So isn't any 60hz mode set up like this just going to be using the 640x480 mode's square-pixel framing and thus just give you a "letterboxed" 320x200@60hz, not the "full screen" requested in the OP? Comparing with the standard values for regular VGA the Jazz Jackrabbit "tweaked" values for total frame are identical.



Is there a photo of this running on a real monitor? I see that #ifdef SQUARE_PIXELS being set changes the vsync parameters to different numbers than it not being set, but does this really result in an actual monitor changing the framing of the output so one is vertically stretched compared to the other?
I just tested the code juj posted, on a real vga + a modern pc monitor, and it is 60hz, but there are still black bands at the top and bottom of the screen, the bottom one is larger.

If I set the square pixels, the image is centered, and the top/bottom bars contain overscan (color 0). Both vga mode 13 and mode 0d ("ega") produce the same output. If I set the monitor to 4:3, like simulating a CRT or an old LCD, pixels are really square.
 
So isn't any 60hz mode set up like this just going to be using the 640x480 mode's square-pixel framing and thus just give you a "letterboxed" 320x200@60hz, not the "full screen" requested in the OP? Comparing with the standard values for regular VGA the Jazz Jackrabbit "tweaked" values for total frame are identical.

Is there a photo of this running on a real monitor? I see that #ifdef SQUARE_PIXELS being set changes the vsync parameters to different numbers than it not being set, but does this really result in an actual monitor changing the framing of the output so one is vertically stretched compared to the other?
You are absolutely right, that is a great point. I've worked so long now on LCD displays with VGA inputs that didn't even think about this part.

Now that I read the original post closer, it did mention wanting to avoid black bars. I was thinking about the 320x240 vs 320x200 distinction being the problem. Sorry my bad.
 
You are absolutely right, that is a great point. I've worked so long now on LCD displays with VGA inputs that didn't even think about this part.

Now that I read the original post closer, it did mention wanting to avoid black bars. I was thinking about the 320x240 vs 320x200 distinction being the problem. Sorry my bad
It looks great anyway, even if it is not possible without the bands. Also this is great for square pixels in 4:3 monitors.
 
You are absolutely right, that is a great point. I've worked so long now on LCD displays with VGA inputs that didn't even think about this part.

Yeah...

So just for laughs I translated your CRTC setup code into QBASIC just to see if it would make any difference (I don't think I have a C compiler installed on my Tandy 1000 that has a VGA card wedged in it) and tested the "square" verses "non-square" settings, and the only difference is the "square" setting centers the display and "non-square" has it offset towards the top. Both run at the same 640x480@60hz framing and are identified by the monitor as such when I bring up the OSD.

Off the top of my head the only way I can think of to possibly change the aspect ratio of the pixels from square to maybe something slightly more closely approximating the regular mode 13h pixel shape might be if you could set up this framing but instead of dividing the 25.2mhz pixel clock in half you divide the 28Mhz one that's used for VGA text in half instead? That would give you something like a 360x240 mode you could letterbox 320x200 in the middle of, right? Obviously it would still leave black bars, and I suspect most LCD monitors would scale it really badly.

For laughs here's the basic translation.

Code:
SCREEN 13
square = 0
VADD = &H3D4
VDAT = &H3D5

REM PROGRAM FOR 60 hz
OUT VADD, &H11: OUT VDAT, &H0
OUT VADD, &H6: OUT VDAT, &HB
OUT VADD, &H7: OUT VDAT, &H3E

REM IF not square pixels:
IF square = 0 THEN
OUT VADD, &H16: OUT VDAT, &HB
OUT VADD, &H10: OUT VDAT, &HD7
OUT VADD, &H11: OUT VDAT, &H89
ELSE
OUT VADD, &H10: OUT VDAT, &HB9
OUT VADD, &H12: OUT VDAT, &H8F
OUT VADD, &H15: OUT VDAT, &HB8
OUT VADD, &H16: OUT VDAT, &HE2
OUT VADD, &H11: OUT VDAT, &H85

END IF

REM Kill time until a key is hit

DO
CIRCLE (RND * 320, RND * 200), RND * 100, RND * 255
LOOP UNTIL INKEY$ <> ""
 
Last edited:
Off the top of my head the only way I can think of to possibly change the aspect ratio of the pixels from square to maybe something slightly more closely approximating the regular mode 13h pixel shape might be if you could set up this framing but instead of dividing the 25.2mhz pixel clock in half you divide the 28Mhz one that's used for VGA text in half instead? That would give you something like a 360x240 mode you could letterbox 320x200 in the middle of, right? Obviously it would still leave black bars, and I suspect most LCD monitors would scale it really badly.

Hahaha. I just tested this and it looks like it works, maybe? I modified my crap basic program above like so:

Code:
SCREEN 13
nosquare = 1
VADD = &H3D4
VDAT = &H3D5

REM PROGRAM FOR 60 hz
OUT VADD, &H11: OUT VDAT, &H0
OUT VADD, &H6: OUT VDAT, &HB
OUT VADD, &H7: OUT VDAT, &H3E

REM IF normal square pixels:
IF nosquare = 0 THEN
OUT VADD, &H16: OUT VDAT, &HB
OUT VADD, &H10: OUT VDAT, &HD7
OUT VADD, &H11: OUT VDAT, &H89
ELSE
REM Create letterboxed mode with non-square pixels
OUT VADD, &H10: OUT VDAT, &HB9
OUT VADD, &H12: OUT VDAT, &H8F
OUT VADD, &H15: OUT VDAT, &HB8
OUT VADD, &H16: OUT VDAT, &HE2

REM Increase horizontal character total by 1.125 (96 to 108 - 1)
OUT VADD, &H0: OUT VDAT, &H6B

OUT VADD, &H11: OUT VDAT, &H85

REM Switch to 28Mhz clock
OUT &H3C2, 103
END IF

REM Kill time until a key is hit
PRINT "1234567890123456789012345678901234567890"

DO
CIRCLE (RND * 320, RND * 200), RND * 100, RND * 255
LOOP UNTIL INKEY$ <> ""

Long and short of it, BASIC sets up a 320x200 Mode 13 screen, the tweaks to turn it into 640x480@60hz framing are applied, but then I'm also:

1: Changing the base pixel clock from 25 to 28mhz
2: Changes the total "characters per line" from 96 to 108.

The resulting display is roughly centered vertically (per the settings from the example code) but, because I didn't change anything there other than the total count, is offset to the right horizontally, but the pixels are now roughly 5:6. IE, it's effectively a 360x240 double-scanned matrix.

What's fun, though, is if I hit the "auto adjust" function of my monitor it apparently decides based on the active area to badly readjust itself to center everything and stretch it out, so if your particular monitor is more aggressive than mine when it comes to adjustments it's possible it'll intervene before the difference is visible. It should work as expected on a dumb VGA CRT, though, kind of wish I had one.
 
Last edited:
It looks like any 320x200@60hz mode on VGA has to be "letter-boxed". This is an image from github, in which they show the correct output for jazz jackrabbit (320x199@60):

80284732-106daa80-86d5-11ea-8566-8170580d4f77.jpeg
 
To slow down from 70hz to 60hz without letterboxes, one would have to "sink" time for the duration of those extra 10 frames somewhere. This could theoretically be done in one of three ways:
1. slow down the pixel clock from 12.6 MHz to 10.7 MHz. Unfortunately this would be a soldering job to change the crystal on the VGA card.
2. increase the duration of vertical retrace. The CRT ray would be locked in vertical position for the duration of vertical retrace, so scanning will be effectively "paused" and the geometry would not be affected. In order to get 60hz, reusing the geometry calculations from above, one would need 12600000 / (320+8+6+48+18) / (400+14+6+78+27) = 60.000 hz, i.e. a vertical retrace period of 78 lines. But unfortunately the VGA CRTC registers have a limitation that vertical retrace period can be only at most 15 lines (maybe at a stretch 16 lines, though that may be incompatible with some adapter implementations), since there are only 4 bits of space in the vsync length register.
3. increase the duration of horizontal retrace. Similar to above, the CRT ray will then be locked in horizontal position to "pause", and the scanning geometry would not be affected. In order to get 60hz, calculating the numbers again gives
12600000 / (320+8+6+116+18) / (400+14+6+2+27) = 59.96 hz.

This is actually possible, almost. The horizontal retrace register does have enough bits to express this, but due to the way hretrace and hblank end register scanning works, I needed to transfer 8 clocks from horizontal back porch to horizontal sync to get that mode to work.

This gives the following video mode:
Pixel clock: 12.6 MHz
Horizontal:
- active: 320 pixels,
- border: 8 pixels (standard)
- front porch: 6 pixels, (standard)
- sync: 124 pixels, (modified up from standard VGA 48 pixels)
- back porch: 10 pixels (modified down from standard VGA 18 pixels)
Vertical:
- active: 400 lines, (vertical resolution = 200 lines doubled) (standard)
- border: 14 pixels, (standard)
- front porch: 6 lines, (standard)
- sync: 2 lines, (standard)
- back porch: 27 lines (standard)

But there is then the big drawback that Timo already mentioned above:
Horizontal refresh rate = 12600000 / (320+8+6+116+18) = 26.923 kHz is completely nonstandard, so many VGA monitors will be unable to sync to this mode. Multisync monitors might not care.

Still, trying it out, adjusted the test program to produce this video mode:

Screenshot 2023-01-12 13-57-16.png

Curiously, not even my new 2022 ASUS ProArt PA248QV (1920x1200@75hz display with VGA and HDMI inputs) wants to sync to this video mode via VGA (so even modern digital displays might not like non-31.5 kHz video signal via VGA), but my video capture equipment does not care, and it looks like this:

IMG_4163.jpg

The color moire is from the camera, not visible in reality. I'd be curious to hear if that would have any chance of working.

Apart from that, the only way would be to do it like Pinball Fantasies and Pinball Illusions did, i.e. leave it to the user to adjust the vertical scaling knobs to remove the letterboxes.
 
To slow down from 70hz to 60hz without letterboxes, one would have to "sink" time for the duration of those extra 10 frames somewhere. This could theoretically be done in one of three ways:
1. slow down the pixel clock from 12.6 MHz to 10.7 MHz. Unfortunately this would be a soldering job to change the crystal on the VGA card.
2. increase the duration of vertical retrace. The CRT ray would be locked in vertical position for the duration of vertical retrace, so scanning will be effectively "paused" and the geometry would not be affected. In order to get 60hz, reusing the geometry calculations from above, one would need 12600000 / (320+8+6+48+18) / (400+14+6+78+27) = 60.000 hz, i.e. a vertical retrace period of 78 lines. But unfortunately the VGA CRTC registers have a limitation that vertical retrace period can be only at most 15 lines (maybe at a stretch 16 lines, though that may be incompatible with some adapter implementations), since there are only 4 bits of space in the vsync length register.
3. increase the duration of horizontal retrace. Similar to above, the CRT ray will then be locked in horizontal position to "pause", and the scanning geometry would not be affected. In order to get 60hz, calculating the numbers again gives
12600000 / (320+8+6+116+18) / (400+14+6+2+27) = 59.96 hz.

This is actually possible, almost. The horizontal retrace register does have enough bits to express this, but due to the way hretrace and hblank end register scanning works, I needed to transfer 8 clocks from horizontal back porch to horizontal sync to get that mode to work.

This gives the following video mode:
Pixel clock: 12.6 MHz
Horizontal:
- active: 320 pixels,
- border: 8 pixels (standard)
- front porch: 6 pixels, (standard)
- sync: 124 pixels, (modified up from standard VGA 48 pixels)
- back porch: 10 pixels (modified down from standard VGA 18 pixels)
Vertical:
- active: 400 lines, (vertical resolution = 200 lines doubled) (standard)
- border: 14 pixels, (standard)
- front porch: 6 lines, (standard)
- sync: 2 lines, (standard)
- back porch: 27 lines (standard)

But there is then the big drawback that Timo already mentioned above:
Horizontal refresh rate = 12600000 / (320+8+6+116+18) = 26.923 kHz is completely nonstandard, so many VGA monitors will be unable to sync to this mode. Multisync monitors might not care.

Still, trying it out, adjusted the test program to produce this video mode:

View attachment 1251483

Curiously, not even my new 2022 ASUS ProArt PA248QV (1920x1200@75hz display with VGA and HDMI inputs) wants to sync to this video mode via VGA (so even modern digital displays might not like non-31.5 kHz video signal via VGA), but my video capture equipment does not care, and it looks like this:

View attachment 1251486

The color moire is from the camera, not visible in reality. I'd be curious to hear if that would have any chance of working.

Apart from that, the only way would be to do it like Pinball Fantasies and Pinball Illusions did, i.e. leave it to the user to adjust the vertical scaling knobs to remove the letterboxes.
The first code was working ok for me, I wanted this to be more compatible, so I think it is ok to have the letterbox mode. The "square pixels" mode works better, I just have to be careful not to use any bright color as color 0 on VGA (or EGA).

I'll try this new code later.
 
To slow down from 70hz to 60hz without letterboxes, one would have to "sink" time for the duration of those extra 10 frames somewhere. This could theoretically be done in one of three ways:
1. slow down the pixel clock from 12.6 MHz to 10.7 MHz. Unfortunately this would be a soldering job to change the crystal on the VGA card.
2. increase the duration of vertical retrace. The CRT ray would be locked in vertical position for the duration of vertical retrace, so scanning will be effectively "paused" and the geometry would not be affected. In order to get 60hz, reusing the geometry calculations from above, one would need 12600000 / (320+8+6+48+18) / (400+14+6+78+27) = 60.000 hz, i.e. a vertical retrace period of 78 lines. But unfortunately the VGA CRTC registers have a limitation that vertical retrace period can be only at most 15 lines (maybe at a stretch 16 lines, though that may be incompatible with some adapter implementations), since there are only 4 bits of space in the vsync length register.
3. increase the duration of horizontal retrace. Similar to above, the CRT ray will then be locked in horizontal position to "pause", and the scanning geometry would not be affected. In order to get 60hz, calculating the numbers again gives
12600000 / (320+8+6+116+18) / (400+14+6+2+27) = 59.96 hz.

FWIW, I don't think 2 or 3 are actually possible. (And if they did work you might actually damage a CRT monitor, although I would wager almost any real-world monitor would just lose sync if you tried to just hold horizontal or vertical sync like that.) The CRT trace doesn't actually stop during vertical refresh, it's still sweeping as it bounces back up to the top of the screen. And likewise, it doesn't "stop" during a horizontal refresh, it just "bounces" back over to the other side. If you tried *holding* it in that bounced state, which I think would require a monitor that used a direct drive signal instead of "sync", per se (think some early/primitive TTL monitors, like MDA, or what you'll find built into a black-and-white Macintosh) you'd just burn up the flyback transformer.

In any case, I think the effect of the CRTC parameters you're suggesting there would actually be to effectively increase the "overscan", not "hold the beam". The horizontal solution would lower the line rate so most monitors won't sync with it *and* would probably have the effect of horizontally *squishing* the content. Meanwhile, the "vertical" solution would just force more lines per frame, thus lowering the framerate, which is what you're already doing with the re-framing code. Unless you throw off your monitor to do more overscan it doesn't change anything.

FWIW, "1" would accomplish lowering the framerate without the squishing, but likewise would result in a line rate lower than most VGA monitors can sync to. You'd need a flexible multisync monitor to display it.

Curiously, not even my new 2022 ASUS ProArt PA248QV (1920x1200@75hz display with VGA and HDMI inputs) wants to sync to this video mode via VGA (so even modern digital displays might not like non-31.5 kHz video signal via VGA), but my video capture equipment does not care, and it looks like this:

I'm not sure how useful a video mode that nothing will sync with is, so I mucked with my BASIC program some more to elaborate on that idea of using the 28Mhz pixel clock instead of the 12.6 one, and here are some photos that show it does work to give you more "CGA-ish" aspect ratio pixels on the standard 31.5khz/60hz framing. For reference, here is how normal Mode 13 looks. (I know the monitor I'm using here is kind of crap at displaying DOS video modes, it's unfortunately a common problem and the OAK VGA card I have in my Tandy isn't exactly the highest quality thing in the world.) I have the OSD active to show that this is the standard "720x400x70hz" framing that's used for the "200 line" modes in VGA:

mode13_nomods.jpg

This screenshot is when you apply the tweaks to switch to the 640x480@60hz framing. The pixels are now "square", which you will notice has the effect of making the circles look a bit squished. (QBASIC's CIRCLE command is adjusting for the non-square pixels of mode 13 when it's drawing them, so this is expected behavior.):

mode13_squarepixels.jpg

And this final screenshot shows what I get if I change the base pixel clock from the 25mhz reference to the 28mhz (usually used for VGA text mode), increase the total horizontal character cell count by 12.5%, and tweak the start of horizontal refresh to the "active" area is better centered in what is effectively the increased horizontal overscan. The result is a 320x200 pixel display with non-square pixels centered in what is effectively a 360x240 (double-scanned) video mode that looks to the monitor the same as normal 640x480. (You can see the OSD thinks the same preset as above should apply.) The circles are now almost round again.

mode13_28mhz.jpg

It makes sense that this works as it does because VGA's 28.3mhz text pixel clock is almost exactly twice CGA/EGA's 14.3mhz pixel clock. The framing of VGA's 640x480@60 mode is basically just NTSC but non-interlaced, IE, it's 480p instead of 480i. (Actually 240p, but that of course isn't a real according-to-Hoyle NTSC standard.) Thus using the 28mhz pixel clock is going to result in similarly shaped pixels. (Unless your monitor leaps in and tries to stretch the active area horizontally to fit.)

I could see this possibly actually being useful for an emulator or whatever, given that not only will the aspect ratio be close for an NTSC game that used a pixel clock some multiple of the colorbust frequency (pretty common), but the line frequency is also effectively identical to the original. (Which is not true if you run a hacked mode with fewer than 525 total vertical lines per frame.) Curious what a capture device/TV would think of it.

Here's the BASIC code. The only difference from the previous one in CRTC settings is I changed CRTC register index 0x04, Horizontal Refresh Start, to center the non-square pixel version.

Code:
SCREEN 13
REM Set to 0 for no mods, 1 for square pixels, 2 for letterbox
vidmode = 2
VADD = &H3D4
VDAT = &H3D5

REM Skip it all if vidmod = 0
IF vidmode > 0 THEN

REM PROGRAM FOR 60 hz
OUT VADD, &H11: OUT VDAT, &H0
OUT VADD, &H6: OUT VDAT, &HB
OUT VADD, &H7: OUT VDAT, &H3E

REM IF normal square pixels:
IF vidmode = 1 THEN
OUT VADD, &H16: OUT VDAT, &HB
OUT VADD, &H10: OUT VDAT, &HD7
OUT VADD, &H11: OUT VDAT, &H89
ELSE
REM Create letterboxed mode with non-square pixels
OUT VADD, &H10: OUT VDAT, &HB9
OUT VADD, &H12: OUT VDAT, &H8F
OUT VADD, &H15: OUT VDAT, &HB8
OUT VADD, &H16: OUT VDAT, &HE2

REM Increase horizontal character total by 1.125
OUT VADD, &H0: OUT VDAT, &H6B
REM Change the horizontal refresh start to center screen
OUT VADD, &H4: OUT VDAT, &H5A

OUT VADD, &H11: OUT VDAT, &H85

REM Switch to 28Mhz clock
OUT &H3C2, 103
END IF

REM end of the "set things at all
END IF

REM Kill time until a key is hit
PRINT "1234567890123456789012345678901234567890"
DEFINT A-Z
DO
COL = RND * 255
XCENT = RND * 320
YCENT = RND * 200
CIRCLE (XCENT, YCENT), RND * 100, COL
PAINT (XCENT, YCENT), RND * 255, COL
LOOP UNTIL INKEY$ <> ""
 
For reference, here is how normal Mode 13 looks. (I know the monitor I'm using here is kind of crap at displaying DOS video modes, it's unfortunately a common problem and the OAK VGA card I have in my Tandy isn't exactly the highest quality thing in the world.) I have the OSD active to show that this is the standard "720x400x70hz" framing that's used for the "200 line" modes in VGA:

View attachment 1251518
That vertical lines are a thing of the monitor, not the card (or at least a combination of the card + monitor). I also have an oak VGA, and you can remove that lines only if the monitor has two settings called "phase" and "clock".

This is how the first code posted by juj looks on my monitor + OAK VGA in a 286 (monitor is set to 4:3 from OSD). I can see a little overscan at the bottom (light gray). The square pixels mode shows the overscan color 0 filling the top and the bottom parts of the screen, normally it would be black, but in this case is a light gray. (My cell phone did a very crappy capture, but you can see there are no vertical lines).

20230112_120447.jpg
 
Last edited:
That vertical lines are a thing of the monitor, not the card (or at least a combination of the card + monitor). I also have an oak VGA, and you can remove that lines only if the monitor has two settings called "phase" and "clock".

Yeah, my monitor does have those settings and if I really screw with them I can get it clean, but it's very bad at recalling what you did whenever you switch modes. (It's an HP thing from like 2002 so I try to cut it some slack.)

I have a VGA to HDMI dingus in a box somewhere, so when I have more time maybe I'll pull that out and see if it deals correctly with sizing/proportion when switching the pixel clock like I did. If it works I might try hacking my own version of that 60hz TSR to apply the same adjustments. If it works it might enable video capture of CGA/EGA programs from VGA cards at their "correct" framerate *and* close to the right aspect ratio.
 
Yeah, my monitor does have those settings and if I really screw with them I can get it clean, but it's very bad at recalling what you did whenever you switch modes. (It's an HP thing from like 2002 so I try to cut it some slack.)

I have a VGA to HDMI dingus in a box somewhere, so when I have more time maybe I'll pull that out and see if it deals correctly with sizing/proportion when switching the pixel clock like I did. If it works I might try hacking my own version of that 60hz TSR to apply the same adjustments. If it works it might enable video capture of CGA/EGA programs from VGA cards at their "correct" framerate *and* close to the right aspect ratio.
That's cool, I tested that game I'm making (well is that game engine I posted somewhere in this forum), and the EGA mode is working again at 60 hz on the VGA, like on an original EGA.
 
Back
Top