By Aaron Severn

(This article is continued from Issue 2. This is all the appendixes and they show you EXACTLY what everything does....also look for an 'svgalib' program at the bottom of this article)

4 Appendices
------------

Appendix A - Required TYPE definitions and descriptions
-------------------------------------------------------

VgaInfoBlock, returned by VESA function &H00.

    TYPE VgaInfoBlock
        VESASignature AS STRING * 4
        VESAVersion AS INTEGER
        OEMStringPtr AS LONG
        Capabilities AS STRING * 4
        VideoModePtr AS LONG
        TotalMemory AS INTEGER
        Reserved AS STRING * 236
    END TYPE


VESASignature - contains the characters "VESA".
VESAVersion - specifies what version of the VESA standard is in use. The higher byte specifies the major version number. The lower byte specifies the minor version number. Features of older versions are guaranteed to work in later versions.
OEMStringPtr - a far pointer to a null terminated OEM-defined string which may be used to identify the video chip, video board, memory configuration, etc. to hardware specific display drivers.
Capabilities - describes what general features are supported. The bits are defined as follows.

                      0    - DAC is switchable
                              0 - DAC is fixed width, with 6-bits per
                                   primary color.
                              1 - DAC width is switchable.
                      1-31 - Reserved
  

VideoModePtr - a far pointer to a list of supported SVGA (VESA defined as well as OEM-specific) mode numbers. Each mode number occupies one word (16 bits). The list of mode numbers is terminated by a -1 (&HFFFF). It is still the applications responsibility to verify the availability of modes in this list with the Return SVGA mode information (VESA function &H01) call.
TotalMemory - indicates the amount of memory installed on the VGA board. Its value represents the number of 64k blocks of memory currently installed.

ModeInfoBlock, returned by VESA function &H01.

    TYPE ModeInfoBlock
        ModeAttributes AS INTEGER
        WinAAttributes AS STRING * 1
        WinBAttributes AS STRING * 1
        WinGranularity AS INTEGER
        WinSize AS INTEGER
        WinASegment AS INTEGER
        WinBSegment AS INTEGER
        WinFuncPtr AS LONG
        BytesPerScanLine AS INTEGER
        XResolution AS INTEGER
        YResolution AS INTEGER
        XCharSize AS STRING * 1
        YCharSize AS STRING * 1
        NumberOfPlanes AS STRING * 1
        BitsPerPixel AS STRING * 1
        NumberOfBanks AS STRING * 1
        MemoryModel AS STRING * 1
        BankSize AS STRING * 1
        NumberOfImagePages AS STRING * 1
        Rsvd AS STRING * 1
        RedMaskSize AS STRING * 1
        RedFieldPosition AS STRING * 1
        GreenMaskSize AS STRING * 1
        GreenFieldPosition AS STRING * 1
        BlueMaskSize AS STRING * 1
        BlueFieldPosition AS STRING * 1
        RsvdMaskSize AS STRING * 1
        DirectColorModeInfo AS STRING * 1
        Reserved AS STRING * 216
    END TYPE

ModeAttributes - describes certain characteristics of the video mode. Bits are defined as follows.

                            0    - Mode supported in hardware
                                    0 - Mode not supported
                                    1 - Mode is supported
                            1    - 1 (Reserved)
                            2    - Output functions supported by BIOS
                                    0 - Output functions not supported
                                    1 - Output functions are supported
                            3    - Monochrome/colour mode
                                    0 - Monochrome mode
                                    1 - Colour mode
                            4    - Mode type
                                    0 - Text mode
                                    1 - Graphics mode
                            5-15 - Reserved

WinAAttributes - describe the characteristics of the CPU windowing scheme such as whether the windows exist and are read/writeable. Bits are as follows.
                            0   - Window supported
                                   0 - Window is not supported
                                   1 - Window is supported
                            1   - Window readable
                                   0 - Window is not readable
                                   1 - Window is readable
                            2   - Window writeable
                                   0 - Window is not writeable
                                   1 - Window is writeable
                            3-7 - Reserved

WinBAttributes - same as WinAAttributes.
WinGranularity - specifies the smallest boundary in KB on which the window can be placed in the video memory.
WinSize - specifies the size of the window in KB.
WinASegment - segment address at where the window is located in CPU address space.
WinBSegment - same as WinASegment
WinFuncPtr - specifies the address of the CPU video memory windowing function. This function is executed by VESA function &H05, calling the function with this pointer can improve performance.
BytesPerScanLine - specifies how many bytes each logical scanline consists of. The logical scanline could be equal to or larger than the displayed scanline.
XResolution - the width of the video mode. In graphics mode this is in pixels, in text modes it is in units of characters.
YResolution - the height of the video mode.
XCharCellSize - the width of the character cell in pixels.
YCharCellSize - the height of the character cell in pixels.
NumberOfPlanes - the number of memory planes available to software in that mode.
BitsPerPixel - specifies the total number of bits that define the colour of one pixel.
NumberOfBanks - specifies the number of banks in which the scan lines are grouped. The remainder from dividing the scan line number by the number of banks is the bank that contains the scan line and the quotient is the scan line number within the bank.
MemoryModel - specifies the general type of memory organization used by the mode, from one of the following.
                            &H00      - Text mode
                            &H01      - CGA graphics
                            &H02      - Hercules graphics
                            &H03      - 4-plane planar
                            &H04      - Packed pixel
                            &H05      - Non-chain 4, 256 colour
                            &H06      - Direct colour
                            &H07      - YUV
                            &H08-&H0F - Reserved, to be defined by VESA
                            &H10-&HFF - To be defined by OEM

BankSize - specifies the size of a bank in units of 1k.
NumberOfImagePages - specifies the number of additional complete display images that will fit into the VGA's memory in the mode.
Rsvd - defined to support a future VESA BIOS extension feature.
RedMaskSize - defines the size, in bits, of the red component in a direct colour pixel.
RedFieldPosition - defines the bit position within the direct colour pixel or YUV pixel of the least significant bit of the red colour component.
GreenMaskSize - same as RedMaskSize
GreenFieldPosition - same as RedFieldPosition
BlueMaskSize - same as RedMaskSize
BlueFieldPosition - same as RedFieldPosition
RsvdMaskSize - same as RedMaskSize for unused bits.
DirectColorModeInfo - describes characteristics of direct colour modes. Bits are defined as follows.
                            0 - Colour ramp is fixed/programmable
                                 0 - Colour ramp is fixed
                                 1 - Colour ramp is programmable
                            1 - Bits in Rsvd field are usable/reserved
                                 0 - Bits in Rsvd field are reserved
                                 1 - Bits in Rsvd field are usable

Appendix B - VESA defined screen modes
--------------------------------------

             GRAPHICS MODES                           TEXT MODES
  Mode number    Resolution    Colours      Mode number    Columns    Rows
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  &H100          640x400       256          &H108          80         60
  &H101          640x480       256          &H109          132        25
  &H102          800x600       16           &H10A          132        43
  &H103          800x600       256          &H10B          132        50
  &H104          1024x768      16           &H10C          132        60
  &H105          1024x768      256
  &H106          1280x1024     16
  &H107          1280x1024     256

  &H10D          320x200       32k   (1:5:5:5)
  &H10E          320x200       64k   (5:6:5)
  &H10F          320x200       16.8M (8:8:8)
  &H110          640x480       32k   (1:5:5:5)
  &H111          640x480       64k   (5:6:5)
  &H112          640x480       16.8M (8:8:8)
  &H113          800x600       32k   (1:5:5:5)
  &H114          800x600       64k   (5:6:5)
  &H115          800x600       16.8M (8:8:8)
  &H116          1024x768      32k   (1:5:5:5)
  &H117          1024x768      64k   (5:6:5)
  &H118          1024x768      16.8M (8:8:8)
  &H119          1280x1024     32k   (1:5:5:5)
  &H11A          1280x1024     64k   (5:6:5)
  &H11B          1280x1024     16.8M (8:8:8)

Appendix C - VESA VGA BIOS Extension function reference
-------------------------------------------------------

Function &H00 - Return Super VGA Information
Provides information to the calling program about the general capabilities of the SVGA environment. The function fills an information block of type VgaIngoBlock at the address specified by the caller.

      Input - AH = &H4F
              AL = &H00
              ES:DI = Pointer to buffer

      Output - AX = Status (&H4F if successful)
               (All other registers are preserved)

Function &H01 - Return Super VGA Mode Information
Returns information about a specific SVGA video mode. Fills a mode information block of type ModeInfoBlock at the address specified by the caller.

      Input - AH = &H4F
              AL = &H01
              CX = SVGA video mode
              ES:DI = Pointer to buffer

      Output - AX = Status (&H4F if successful)
               (All other registers are preserved)

Function &H02 - Set Super VGA Video Mode

Initializes a video mode.

Input - AH = &H4F
              AL = &H02
              BX = Video mode
                    Bits 0-14 - Video mode
                         15   - Clear memory flag
                                 0 - Clear video memory
                                 1 - Don't clear video memory

      Output - AX = Status (&H4F if successful)
               (All other registers are preserved)

Function &H03 - Return Current Video Mode
Returns the current video mode in BX. Not limited to SVGA modes, will also return any other video mode.

      Input - AH = &H4F
              AL = &H03

      Output - AX = Status (&H4F if successful)
               BX = Current video mode
               (All other registers are preserved)

Function &H04 - Save/Restore Super VGA Video State
Provides a mechanism to save and restore the SVGA video state.

      Input - AH = &H4F
              AL = &H04
              DL = &H00       Return save/restore state buffer size
              CX = Requested states
                    Bit 0 - Save/restore video hardware state
                        1 - Save/restore video BIOS state
                        2 - Save/restore video DAC state
                        3 - Save/restore SVGA state

      Output - AX = Status (&H4F if successful)
               BX = Number of 64 byte blocks to hold the state buffer
               (All other registers are preserved)

      Input - AH = &H4F
              AL = &H04
              DL = &H01       Save SVGA video state
              CX = Requested states (see above)
              ES:BX = Pointer to buffer

      Output - AX = Status (&H4F if successful)
               (All other registers are preserved)

      Input - AH = &H4F
              AL = &H04
              DL = &H02       Restore SVGA video state
              CX = Requested states (see above)
              ES:BX = Pointer to buffer

      Output - AX = Status (&H4F if successful)
               (All other registers are preserved)

Function &H05 - CPU Video Memory Window Control
Sets or gets the position of the specified window in the video memory. The function allows direct access to the hardware paging registers.

      Input - AH = &H4F
              AL = &H05
              BH = &H00       Select SVGA video memory window
              BL = Window number
                    0 - Window A
                    1 - Window B
              DX = Window position in video memory
                    (in window granularity units)

      Output - AX = Status (&H4F if successful)

      Input - AH = &H4F
              AL = &H05
              BH = &H01       Return SVGA video memory window
              BL = Window number (see above)

      Output - AX = Status (&H4F if successful)
               DX = Window position in video memory
                     (in window granularity units)

Function &H06 - Set/Get Logical Scan Line Length
Sets or gets the length of a logical scan line. This function allows an application to set up a logical video memory buffer that is wider than the displayed area.

      Input - AH = &H4F
              AL = &H06
              BL = &H00       Select scan line length
              CX = Desired width in pixels

      Output - AX = Status (&H4F if successful)
               BX = Bytes per scan line
               CX = Actual pixels per scan line
               DX = Maximum number of scan lines

      Input - AH = &H4F
              AL = &H06
              BL = &H01       Return scan line length

      Output - AX = Status (&H4F if successful)
               BX = Bytes per scan line
               CX = Actual pixels per scan line
               DX = Maximum number of scan lines

Function &H07 - Set/Get Display Start
Selects the pixel to be displayed in the upper left corner of the display from the logical page. This function can be used to pan and scroll around logical screens that are larger than the displayed screen. This function can also be used to rapidly switch between two different displayed screens for double buffered animation effects.

      Input - AH = &H4F
              AL = &H07
              BH = &H00
              BL = &H00       Select display start
              CX = First displayed pixel in scan line
              DX = First displayed scan line

      Output - AX = Status (&H4F if successful)

      Input - AH = &H4F
              AL = &H07
              BL = &H01       Return display start

      Output - AX = Status (&H4F if successful)
               BH = &H00 Reserved and will be 0
               CX = First displayed pixel in scan line
               DX = First displayed scan line

Function &H08 - Set/Get DAC Palette Control
Queries and selects the operating mode of the DAC palette. Some DACs are configurable to provide 6-bits, 8-bits, or more of colour definition per red, green, and blue primary colour. The DAC palette width is assumed to be reset to standard VGA 6-bits per primary during a standard or VESA Set SVGA mode call.

      Input - AH = &H4F
              AL = &H08
              BL = &H00       Set DAC palette width
              BH = Desired number of bits of colour per primary

      Output - AX = Status (&H4F if successful)
               BH = Current number of bits of colour per primary

      Input - AH = &H4F
              AL = &H08
              BL = &H01       Get DAC palette width

      Output - AX = Status (&H4F if successful)
               BH = Current number of bits of colour per primary

Appendix E - Suggested sources
------------------------------

The most useful source for programming VESA SVGA is probably the VESA specification. There are many places where you can find it, I have uploaded a copy on my website, use the address below.
http://www.geocities.com/SiliconValley/Peaks/9572/vesasp12.txt

Another good source on SVGA programming in the PC Game Programmers Encyclopedia. It includes the VESA specification listed above. You can get a copy from the following address.
www.qzx.com/pc-gpe

Appendix F - Contact info
-------------------------

If you have questions, I'd prefer that you post them on the www board at my website, rather than e-mail me.

Until September 1998, I can be reached by e-mail at rlsevern@idirect.com After September 1998 I will have a different e-mail, I don't know what it will be yet so I can't tell you.

I can always be reached by posting a message on the www board at my website, the address is www.geocities.com/SiliconValley/Peaks/9572/ Also go there for more demo code on using SVGA in QuickBasic as well as many other useful routines and fun games.

Appendix G - Works Cited
------------------------

Super VGA BIOS Extension, Standard #VS911022, October 22, 1991, Document Version 1.0, VBE Version 1.2.

The moment you've been waiting for!
------------------------

HERE IT IS! the svga library that does all the stuff Aaron has documented the last couple of months.

SVGAlib by Aaron Severn

Back to Top





This tutorial originally appeared in QBasic: The Magazine Issue 3.