VGA capture is a difficult topic and something I’ve been trying to do for about 7 years now,
yes before I started a Youtube channel. I did a video about this last year and detailed some
aspects of the problem and how I wanted to solve it. I have follow ups to some of the ideas in that
video but at this point I have completely changed my methods using totally different hardware.
My second attempt of getting a capture system put together became much,much,
bigger than I initially intended and I’m going to be making a small series out of it instead of one
massively dense video. Today I want to start it with this video as an introduction to how
VGA works. It is so much more complicated than you might think and became mired with technical
debt as it evolved. And understanding how VGA works can really help get better VGA capture
as we’ll see later. So I want to start from the ground up and tell you how it was introduced,
how it evolved, and what some of the challenging aspects of it are.
[Music]
VGA was a video standard introduced with the IBM PS/2 systems in 1987. But there are a
few things that stemmed from this that could be called VGA and it can get confusing. VGA proper
is a standard that defines resolutions and an interface protocol. It used a DE-15 connector,
but this has become known as the VGA connector with accompanying VGA cables. Then you could
say that this is a VGA CRT because that is the maximum standard it supports. But later
CRTs may only have a DE-15 input and still be called VGA while supporting newer standards.
So to make this as understandable as possible I’m going to define my terms right now.
“VGA” means the standard and the 640x480 resolution. “VGA interface” is the connector and
signaling protocol used for the video data. A “VGA card” or “VGA adapter” is a graphics adapter for a
computer that allows it to output video through a VGA interface. “VGA CRTs” are those designed only
for the original VGA standard. And “MultiMode CRTs” are those that support more than VGA.
I’ll address these more as we get into this, but I don’t want to be bogged down with pedantics.
The VGA interface was designed in a way that made sense for controlling the beam of a CRT
because integrated display logic wasn’t common yet. It doesn’t take much to control a CRT so it
only has 5 signal lines. Red, green, and blue video data lines, and horizontal and vertical
sync signals to synchronize with the display and move the beam. In contrast with its predecessors,
CGA and EGA though, VGA is an analog video standard. CGA and EGA had red, green,
and blue signals that are on or off with different intensity controls to change video brightness.
The VGA interface outputs different voltage levels to change color intensity.
This decoupled the display’s color capabilities from the interface unlike each previous video
standard that required a new monitor when introduced to get full color support. The
VGA interface was not limited to a subset of colors and could produce any mixture of red,
green, and blue that the connected VGA adapter could generate. The only limiting factor was the
capability of that VGA adapter. Original adapters could only display 16 or 256 colors at 4 or 8 bits
depending on what they are doing. But it didn’t take long for better VGA adapters with larger
color varieties to come out and 16M colors at 24 bit was possible. The analog color choice
made displays with a VGA interface both forward and backwards compatible with all VGA cards.
Except, not quite. VGA’s introduction defined specific resolutions for the video standard.
The resolutions were defined as standards with the display interface because the CRT monitors
needed to be able to sync with the signals. If you provided a video signal beyond what a VGA
CRT can match, you will get unexpected and potentially damaging results. We’ll
get into this more later but as clone systems became more dominant than IBM’s own machines
other companies expanded the VGA interface with new resolutions and sync timings. These
were eventually codified as VESA standards, that are called modes, but the signals can have more
variance than you might expect. This is where the real problems with VGA interface devices happen.
I want to visual the signals and am going to use logic analysis equipment to do this.
With this setup we will be able to see these differences between the VGA interface modes
and how they impact the signalling in real time. We can see here the separate red, green, and blue
video signals at the top. And the horizontal and vertical sync signals at the bottom.
First let’s get acquainted with the anatomy of a VGA signal before we start looking at differences.
At the beginning of displaying a frame of video the beam of the CRT starts out at the top left
and sweeps across to the right drawing a single line. As it moves off of the visible area of the
display the beam shuts off and a horizontal sync signal is pulsed. This causes the CRT to move the
beam back past the left of the display, below the first line, and start moving to the right again.
The horizontal pixels only exist for the computer because they are sent as a dynamic analog signal
for each color component to the CRT. This analog signal changes as it switches between the pixel
values the VGA card has in its video memory. So a CRT never has any way of knowing where individual
pixels are as the data is lost in the analog signal. This process of drawing horizontal lines
is repeated for all vertical lines of the display. But there are actually more non-visible vertical
lines in the VGA standard. The rest appear above and below the active video area with the vertical
sync. The vertical sync signal happens after some blank lines after the last active video line
and has a set duration of a number of horizontal signals while the beam moves back to the top of
the display. It then waits though more blank lines before starting to draw the next frame of video.
These blank areas outside of the video are called the front and back porch around both sync pulses.
The amount and size of the blank area will influence the timing of the video signals.
Now the signal I’ve been showing here is plain VGA 640x480. So l et’s compare it to SVGA 800x600 and
XGA 1024x768 and put some values on some of the things as we looked at them. I don’t want to worry
about the exact frequencies these are running at because the differences I want to focus on
are bigger than that. Immediately we can see that the sync pulses are now flipped or inverted for
SVGA compared to VGA. Changing the polarity is used to indicate different modes to a VGA CRT
but is somewhat redundant and became outdated quickly. So I wouldn’t worry too much about it.
The horizontal sync timings are really tight and are down to pixels at microsecond differences.
It’s more helpful to compare them relatively than see numbers. But I’ll still put the values from
the specifications on here though, though they may not perfectly match these for reasons we’ll
get into later. Now again I’m more interested in the differences between signals and the relative
horizontal pulse timings for SVGA and XGA aren’t much different. But VGA has more even front and
back porch areas. The proportions of the spaces in the horizontal timing like this will change the
horizontal position of the viewing area shifting it left or right, so this is good to know. The
vertical sync area has much more variance between resolutions and is easier to quantify using the
horizontal lines. VGA has a 10 line front porch, 2 line pulse, and 33 line back porch. SVGA has a
1 line front porch, 4 line pulse, and 23 line back porch. XGA has a 3 line front porch, 6 line pulse,
and a 29 line back porch. Like with the horizontal timing, differences in these vertical timings will
move the visible area up or down. Now overall with how much the timings differ coupled with
the polarities flipping there are a lot of things that can change constantly with the VGA interface.
There is another problem though, the video standards I showed there weren’t always
respected. Especially with earlier games and some hardware. A more innocent example would
be some Apogee’s early titles that put some visual data in the porch area around the normally active
video frame. For example Commander Keen’s cyan porch areas are outside of the normal resolution
and can cause confusion about the actual resolution of the active video not matching
the timings in later displays. But there are some examples like Jazz Jackrabbit that eschew
the standards and have issues like completely different horizontal timing. This causes it
to be shifted right and can make it difficult or impossible to see the entire frame in some cases.
One more example would be the Voodoo 2 in my Tiny Pentium system. When that is outputting
VGA 640x480 it has too many lines in the vertical front porch shifting the image up.
But it only gets better because the Voodoo 2 only becomes active when in use,
that means the vertical timing will change when switching between the 2D and 3D cards
in the system even if they are outputting the same resolution. These are the types of weird
non-standard things you can expect from this era. CRT’s were, for the most part, capable of handling
these discrepancies because of their forgiving analog nature. But as more video signal timing
standards and displays were introduced this became more complicated and things started to change.
As VESA standards were widely adopted CRTs needed to get a bit smarter and started including logic
for adjusting to match the signals they were sent. These CRTs are known as multi-mode or multi-sync
because they can synchronize with many different signals. This also brought with it EDID which
added an I2C based communication between the display and VGA adapter to negotiate what
resolutions the display could handle. Feeding an unsupported resolution into these Multi-mode CRTs
should have it show an error rather than messily fail to sync like pure VGA CRTs would.
Still being CRTs as long as they could accept the strange variety of sync signals they could show an
image without any issue. But then came along LCDs. Unlike CRTs, LCDs have a finite resolution in the
display area and are crucially, digital. Requiring the analog signal to be reconverted back into a
full video frame before it can be displayed. And it isn’t as easy to align an analog signal to the
grid of LCD pixels as it is the open glass on a tube. As a result, LCDs rely heavily on the VESA
standards being followed and can still have issues with properly locking on to a signal. Frequently
you will have areas cut off or misaligned and especially with poorly behaving hardware
or software. DVI and HDMI don’t suffer from this because they deal directly with pixel information
rather than trying to control an analog device. That’s why you don’t really see any functions
to adjust video size and position for digital inputs, and why HDMI overscan is stupid, but
they are needed for VGA interfaces. It also takes slightly longer for LCDs to adjust to different
video signals over VGA. CRTs had no issue with this, once they resync, they can start moving
the beam around. But LCDs need to resync and then realign the pixels to their internal framebuffer.
This isn’t really a fault of LCDs, it’s just the nature of the analog to digital conversion
process. But because multimode CRTs were by far the standard until the 2000s, software didn’t
need to worry about changing resolutions and it wasn’t uncommon for it to happen when playing
a game during some actions like opening menus. So using LCDs for VGA can come with a few annoyances.
Now I said we weren’t going to talk about frequencies but there is one more thing that
is worth knowing about. The vertical refresh rate. Televisions almost always use a fixed
vertical refresh rate matching the mains power frequency, around 60Hz for NTSC and 50Hz for PAL
as examples. PC monitors though have used a ton of different refresh rates. 50, 60, and 70Hz were all
common before Windows was ever released. These weren’t things you could adjust either. The VGA
standard for 640x480 was fixed at 60Hz and the VGA CRTs could only handle that refresh rate at
that resolution. But it wasn’t a limitation of the vertical sync, it was actually because of
the horizontal sync. The VGA CRTs have a fixed horizontal sync frequency a little over 31kHz.
This is the amount of times a second a new line is drawn to the screen. We can even calculate this
since we know that 640x480 has 525 lines total if you add the vertical porches and sync pulse
while drawing a new frame 60 times a second. If we multiply those numbers together we get 31,500 or
31.5kHz. Now an interesting thing about the fixed frequency VGA CRTs is that, for the most part,
it’s only the horizontal frequency that matters. If you can output a different resolution at the
same horizontal frequency the monitor will accept and display it. And this is exactly how the 70Hz
720x400 mode that DOS uses works. If we do the same math of multiplying the full number of lines,
449 in this case, by the 70Hz refresh rate, it comes out to 31,430 or 31.4kHz and that is
close enough for a VGA CRT to sync to. Older games would frequently run at a lower resolution so they
perform better and this usually meant dropping to 720x400 mode and using a 320x200 video frame.
But this also meant they ran at 70Hz. Now when multi-mode CRTs came out their primary selling
point was that they supported different horizontal sync frequencies and even fully variable support
was eventually possible which allowed arbitrary resolutions and refresh rates to be used, within
some sane limits of course. LCDs by contrast have a different problem though because they typically
run at a fixed 60Hz vertical refresh rate for the panel. They will usually still accept a 70Hz
signal, but they will likely have to drop frames as they display it which may not be desirable.
Okay, I think that’s enough about VGA for now. That covers a lot of the basics
that we’ll need for the next section on actually capturing VGA from a computer.
But for those of you who may not care about VGA capture and are only
watching this out of interest for VGA let me answer a few more potential questions.
“How do I know if a CRT is multi-mode?” Well, SVGA came out one year after VGA. There was
such a short lifespan of pure VGA CRTs that almost all of the VGA interface CRTs you find will be
multi-mode. There are varying levels of multi-mode support, but pretty much all of them will go up to
1024x768 and be good enough for average use for games. If you really want to be sure though, if
it has buttons or any kind of on screen display, it’s basically guaranteed to be multi-mode.
“Do I need a pure VGA CRT?” Definitely not. Any multi-mode
display can sync to anything a VGA CRT can. And VGA CRTs mostly fall into two categories,
old, and cheap. Unless they have some other quality that gives you a reason to use one,
you’re better off avoiding them since they can potentially be damaged by giving them the wrong
signal. And just to get ahead of it, they aren’t faster or have a lower response time
either. All typical VGA interface CRTs, multi-mode or not, are direct analog devices with no delays.
“What about the pixel clock?” This is the measurement of the time
between pixels in the analog signal. It’s kind of a thing that doesn’t actually matter outside
of the VGA adapter and maybe for some LCDs. But even for video capture I’m not that worried about
what the pixel clock is. If you’re making a VGA adapter then it will matter a lot more.
The only thing you should really know is that the signal is very fast at
dozens or hundreds of Mhz and if there are poorly behaving components in the circuit
you could see bleeding or other types of interference because of it.
“What about high refresh rate CRTs?” There are some Multi-mode CRTs that can do
bananas high speed frame rates. And it is cool to see in person. But the VGA interface is
really bad at high speed data and interference protection. 1024X768 @ 85Hz has a pixel clock
around 95MHz. That’s right in the middle of FM radio. 1600X1200 @ 100Hz is around 280MHz.
That’s higher than what a Cat 6 cable used for 10Gb ethernet is rated for.
There are a lot of potential interference sources at these higher speeds that can significantly
reduce the image quality, and most VGA cables probably aren’t rated for frequencies that high.
So yeah, there are some multi-mode CRTs that can go up to super high refresh rates,
but there will likely be video degradation if you run them that fast and it may not be worth it.
Hopefully that answers most of the questions you might have about VGA.
Stay tuned for the next video where I go over how I’m doing VGA capture now and what hardware
I will be recommending for it. And as a teaser, I’ve tested a number of different solutions now.
If you enjoyed this video, you might want to subscribe for the next one. And if you want to
support the channel I am on Patreon. But that’s it for the moment and I’ll see you next time.