|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
GP Mailing List
ATXGPSIG List
|
The VESA BIOS Extensions 1.2Bob Pendleton If you've ever looked into doing register level programming on an SVGA display the first thing you'll notice is that while all VGA displays are quite compatible with each other SVGA displays made by one manufacturer are not compatible with SVGA displays made by other manufacturers. In fact, SVGA displays made by the SAME manufacturer may not be compatible with each other. This lack of compatibility is a problem for anyone trying to write graphics programs that take advantage of SVGA displays. If you want your program to be usable on all PCs you have to write special code for each of the different SVGA displays on the market. Bennett's UNIVBE documentation lists more than 40 different kinds of SVGA displays made by 18 different manufacturers. It takes a lot of programmer time, which translates into a lot of money, to support 40+ different kinds of displays. That means that only a few very popular software products support all those different displays. It means that individuals and small companies don't even try to write SVGA software. This is a problem that needs a solution. VESA, the Video Electronics Standards Association, is a group of 140+ companies that all have a monetary stake in the PC graphics market. VESA is the organization that developed the VESA Local Bus (VLB) specification that is giving PCs fast 32 bit video displays and peripherals. VESA has developed a number of different standards that affect all current and future PC owners. VESA solved the SVGA compatibility problem by developing a standard set of extensions to the video BIOS that make it easy to write programs for SVGA displays. VBE (VESA BIOS Extensions) is a set of 9 BIOS calls that hide the differences between SVGAs while letting each manufacturer add features that add value to their products. A potentially perfect solution for end users, programmers, and graphic hardware manufacturers. VBE should have been the solution to everyone's SVGA problems. Unfortunately, not all manufacturers support the VBE standard, and those that do support it support different versions. There are 4 different versions (1.0, 1.1, 1.2, and 2.0) of the VBE specification. What was needed was a universal version of the VBE. A single TSR that would recognize what kind of SVGA display was in a system and provide support for the latest version of VBE for all SVGA cards. UNIVBE, written by Kendall Bennett, does exactly that. UNIVBE is a TSR (Terminate and Stay Resident) program that you load from you autoexec.bat file that provides a standard VBE interface for just about all the different SVGA cards in use in the world today. With UNIVBE we can write SVGA graphics programs and expect them to be usable by people all over the world. VESA BIOS ExtensionsThe VBE is an extension to the video BIOS. The video BIOS is called by putting commands in CPU registers and invoking interrupt 10h. The VBE extends and replaces the standard interrupt 10h BIOS calls. What follows is a list of the VBE calls and a brief description of each one. For more details look at the code in vbe.cpp. Function 00h - Return Super VGA Information The first problem you have when programming SVGA graphics is finding out what the SVGA card you are using can do. Function 00h returns a pointer to a vbeInfo record (defined in vbe.h.) Use this call to find out whether or not you have VBE support, which version of the VBE it is, who wrote the VBE you're using, how much video memory you have, and which VESA video modes are supported. Function 01h - Return Super VGA Mode Information This function returns details about a specific video mode. It returns a pointer to a vbeModeInfo record (defined in vbe.h.) This record gives you all the information you need to do graphics in that mode. Function 02h - Set Super VGA Mode This function lets you set the video mode that you want to use. Despite its name, you can use this function to set any of the standard VGA video modes as well as the VESA SVGA video modes. The current VESA video modes are listed in Tables 1 and 2.
Table
1, VESA SVGA Graphic Modes.
Mode Resolution Colors 6Ah 800x600 16 100h 640x400 256 101h 640x480 256 102h 800x600 16 103h 800x600 256 104h 1024x768 16 105h 1024x768 256 106h 1280x1024 16 107h 1280x1024 256 10Dh 320x200 32k 10Eh 320x200 64k 10Fh 320x200 16m 110h 640x480 32k 111h 640x480 64k 112h 640x480 16m 113h 800x600 32k 114h 800x600 64k 115h 800x600 16m 116h 1024x768 32k 117h 1024x768 64k 118h 1024x768 16m 119h 1280x1024 32k 11Ah 1280x1024 64k 11Bh 1280x1024 16m
Table
2, VESA SVGA Text Modes.
Mode Resolution 108h 80 x 60 109h 132 x 25 10Ah 132 x 43 10Bh 132 x 50 10Ch 132 x 60 Function 03h - Return current video mode Use function 03h if you want to know what the current video mode is. I use this one just before I set a high resolution mode so that when my programs are finished they can restore the video mode. It's not nice to leave the display in some weird video mode. Makes users irate. Function 04h - Save/Restore Super VGA video state Multitasking operating systems and TSRs can use this call to save everything in the current display state so they can change to a different mode, use the new mode, and then put everything back the way it was. Function 05h - CPU Video Memory Window Control When the original IBM PC was designed 64k was a lot of memory and a megabyte was so big that slang for a meg was "Moby" as in the size of the great white whale. Designers of the PC allowed for 640k of RAM, 64k for color graphics and 64k for monochrome graphics. They were planning for the future. But, the future came and went and the sizes that seemed huge and very forward looking in the early 1980s seem tiny and short sighted today. We live in the future. We live way past what the designers planned for. VESA video mode 11Bh lets you display 1280 pixels by 1024 pixels with 24 bits (3 bytes) of color per pixel. An SVGA that supports mode 11Bh must have 3.75 megabytes of video memory. That's 6 times the 640k the original PC was designed to support and 60 times the 64k that is allocated for color graphics. Even a simple 1 meg card that supports the 1024x768 256 color mode has 16 times 64k of display memory. So, how do you pack a megabyte of display memory into the 64k allocated for color graphics? You break up the big memory into a bunch of pages that you can map into the 64k you have, one chunk at a time. The VESA document uses the term "memory windows" to describe this technique. I prefer to use the term "memory banks" to avoid confusion with graphics windowing systems like Windows and X. Every SVGA provides some way to map its video memory into the PCs 64k graphics space one or more chunks at a time. The trouble is that they all do it in different ways. This is the most important problem the VBE solves. VBE gives you a way to select which bank is mapped in without having to now how each different SVGA does the mapping. It also tells you how many banks are available. To give an example of how the banks work consider how you draw a pixel at location x=537, y=323 in the 640 x 400 256 color mode. The address of the pixel in video memory is given by (width * y) + x. In this case that's (640 * 323) + 537 = 207,257. Assuming 64k byte banks this pixel is at byte 10649 in bank 3. So, to draw the pixel you use function 05h to map bank 3 into the PCs graphics space and store a byte 10649 bytes into the bank. Look in vg.cpp at the "pixel" function for details of how to do this. Not all SVGA cards support 64k banks. Having to deal with several different sizes and layouts of memory banks complicates programming with banks. But, Bennett's UNIVBE makes all banks look like they are 64k long. This is one of the nice features of UNIVBE. Function 06h - Set/Get Logical Scan Line Length This is a nice feature supported by most SVGA cards. You can select a video mode that displays say 800x600 pixels on the screen and then tell the SVGA that the frame buffer scan lines are actually 1024 pixels long. This means that the 800x600 that you see is actually a window into a larger viewable region. If you have 1 meg of display memory and tell the SVGA that logical scan lines are 1024 bytes long, the 800x600 is a window into a logical screen that is 1024x1024. You can draw into the whole logical display and then use VBE function 07h to make any part of the logical screen viewable in the 800x600 pixels that are displayed on your screen. Function 07h - Set/Get Display Start This function lets you chose which part of the logical display is viewable on the screen. You can use this function to do smooth scrolling or to do "page flipping" to get smooth animation. The setVisiblePage function in vg.cpp uses this function for just that purpose and the pixel and rect demos in demos.cpp use setVisiblepage. Look there for examples of how to use function 07h. Function 08h - Set/Get DAC Palette Control The standard VGA color palette has 6 bits of red, green, and blue per color. Many SVGAs support 8 bits for each of read, green, and blue. Function 08h is used to find out the current width of colors and to select a different width. The DemoAll the code that is included with this article requires an SVGA display with VBE 1.2 support. Use the UNIVBE TSR even if your system already has VBE support. demo.cpp -- VBE demo program demo.exe doit.bat -- batch file to build the programs makefile -- TCC 3.0 makefile used by doit.bat ptypes.h -- portable data types definitions result -- where output from demo get written vbe.cpp -- complete VBE 1.2 interface library vbe.h vbe.obj vg.cpp -- start of a UNIVBE based graphics library vg.h vg.obj Before running the demo program you need to get and install univbe.exe. Installation instructions and other interesting documentation can be found in the document directory that will be created when you unzip UNIVBE. Run the demo program like this: demo query Writes a description of all the VESA video mode support by your system to a file named "result" in the current directory. demo 332 Draws 256 different colored rectangles on your screen. demo pixel Draws random colored pixels on the screen in 640x400 256 color mode. To find out what, if any, VBE support you have in your system. Writes the number of frames/second to the result file. demo rect Draws random colored rectangles on the screen in 640x400 256 color mode. Writes the number of frames/second to the result file. References: VESA Super VGA Standard, Video Electronics Standards Association. http://www.vesa.org "Programmer's Guide to the EGA and VGA Cards", Richard F. Ferraro, 2nd ed. 1990, Addison-Wesley, ISBN 0-201-57025-4 "The Universal VESA BIOS", Kendall Bennett, univbe.doc in the UNIVBE distribution. http://www.scitechsoft.com/ Copyright © 1993, 1997 Robert C. Pendleton. All rights reserved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||