2

I´m starting to learn about low level graphics programming using c with inline assembly. I have found good resources on how to do VGA programming but I need to learn about SVGA. I cannot find that many resources about SVGA and I´m still not clear what the difference between both of them are.

My questions are:

Can someone help me know the difference between VGA and SVGA? Will the resources about programming VGA help me to start programming graphics with SVGA? Are there any good resources to learn SVGA programming with assemble that you guys can share?

Thank you very much

Pablo Estrada
  • 3,182
  • 4
  • 30
  • 74

2 Answers2

5

VGA was a specific video card (designed by IBM). Due to clone manufacturers it became a de-facto standard, and most video cards are still capable of supporting the ancient VGA card's hardware interface (for backward compatibility purposes).

SVGA is a blanket term used to describe "better than VGA". There is no standard (de-facto or otherwise) for these cards; and 20 different "SVGA" cards will have 20 completely different hardware interfaces, resolutions and features; with no compatibility between any of them whatsoever (beyond legacy VGA for backward compatibility).

When someone talks about "SVGA programming" they could mean one of 2 very different things - either writing code for one specific SVGA card (that will not/can not work for any other SVGA cards); or (more likely) writing code that relies on VBE extensions.

Note that VBE extensions are a software interface/API that can be used to find out which video modes the card supports, to set video modes, and to setup a frame buffer. It's typically built into the video card's ROM, and exists so that software can use a generic API instead of supporting many different hardware interfaces.

Brendan
  • 35,656
  • 2
  • 39
  • 66
  • Back in the days I bought an immensely thick "SVGA Programming" book (bright yellow, and thousands of pages). It detailed chip programming for several different SVGA cards (and so *never* up to date), but fortunately also VBE, to which I swiftly adjusted. ...Then Real Mode came along and I've never read it again. – Jongware Sep 22 '15 at 14:20
  • This reminds me of the bad ol' days of proprietary video and sound cards and trying to support them all... A real nightmare for us game programmers. – Frecklefoot Sep 22 '15 at 14:45
3

VGA = Video Graphics Array. SVGA = Super Video Graphics Array. VGA = 640 x 480 pixels (originally in 4 colors). SVGA = 800 x 600 pixels.

Since you're not specifying any target architecture, I assume the architecture is generic.

If you're going to do low-level C programming, just allocate a large buffer of (width * height * bitsPerPixel / 8) bytes, where width would be 640, height would be 480 for VGA. The last one, bitsPerPixel would be of your own choice. -That's the basics on how a 'frame buffer' is usually arranged in memory. You can read/write RGB or indexed pixels as you like inside this buffer.

Handling it in assembly language is no differnt from how it's handled in C or any other language.

If you, on the other hand, want to implement a real-time video interface on a microcontroller, I'll modify my answer.

  • Thank you. So basically I can use the resources on VGA programming and simply change the size of the graphics array to make it SVGA? or is there more to it than that? – Pablo Estrada Sep 22 '15 at 13:35
  • You could do that; I would suggest that you start by allocating one buffer, which is big enough for both resolutions; then you don't have to deallocate the old block and allocate a new block, but you can just copy pixels around. –  Sep 22 '15 at 13:38
  • Let's say you're using SVGA. To draw a green 32-bit RGB pixel on position (17,99), do the following: `myVGABuffer[17 + (767-99)*1024] = 0x00ff00;`. The 0x00ff00 is the pixel value (0xRRGGBB). 17 is the x position, 99 is the Y position, but as Y normally starts at the bottom, we subtract Y from 767, which is the height of the buffer minus one, because it starts at zero. The Y position is then multiplied by the line size. –  Sep 22 '15 at 13:42
  • Thank you very much. This helped me clear my mind on where to get started :) – Pablo Estrada Sep 22 '15 at 13:44
  • -There is of course more, because the above will not show you anything on a computer screen. To do so, you'll have to copy the entire buffer either directly to the screen, or into a window. But basically it's just a huge array. Some architectures allow you to write pixel values directly on the screen, but operating systems like Linux, Mac OS and Windows do not allow you to do this. If you're working with microcontrollers, or computers from the 80's, then you're allowed to write directly to the screen. –  Sep 22 '15 at 13:49
  • 1
    This is all hideously wrong. VGA did not support 640*400 with 256 colours. SVGA does not mean 1024*768. – Brendan Sep 22 '15 at 13:51
  • @Brendan sorry for the misinformation; I cannot correct my comment, but I've corrected SVGA to be 800 x 600. VGA *is* on the other hand 640 x 480 (there are no restrictions on the bit depth; you can make each component whichever size you wish). –  Sep 22 '15 at 13:54
  • @PacMan-- No. The original VGA supported 640*480 with 4 colours, and 320*200 with 256 colours, but did not support 640*480 with 256 colours (it only had 256 KiB of display memory which is simply not enough). SVGA is not anything specific, and is not 800*600 or 1024*768. SVGA is "VGA with random non-standard extensions that could be anything at all". Note that to support 640*480 with 256 colours you have to extend VGA (add more display memory) and if you do that you end up with (one of many possible variants of) SVGA. – Brendan Sep 22 '15 at 14:07
  • Originally VGA --> Video Gate Array. – chux - Reinstate Monica Sep 22 '15 at 14:13
  • 1
    @Brendan - Well, it depends on if you're speaking about graphics cards or monitors. A "VGA monitor" does not have any limits on the number of colours you can make it display, because it receives analogue signals. A video card on the other hand is limited by its RAM. If talking about a D-sub connector, then it really has nothing to do with a resolution, it just tells us that the connector can be used for connecting to a monitor capable of displaying a VGA picture (all VGA monitors are guaranteed to be able to display 640 x 480 @ 59.94 Hz). –  Sep 22 '15 at 14:15