Getting VESA information from Protected Mode or Real Mode

VESA Function Calls and Structures

There are two important VESA structures that are required for programmers to be able to write hardware independent applications. The first is a record that contains information about the available modes of the machine, the version, manufacturer, etc.
To get this information you must call Interrupt 10h function 4f00h.
	Input:  AH = 4fh	 Super VGA Support
                AL = 00h	 Return Super VGA information
                ES:DI = Real Mode pointer to buffer

        Output: AX = Status
                (All other registers are preserved)

The information is returned in this record format:

 TWordArray=array[byte] of word;
 TVESARec = record
   VBESignature       : array [0..3] of Char; {'VESA' or 'VBE2'}
   minVersion         : Byte;
   majVersion         : Byte;
   OEMStringPtr       : Pchar;
   Capabilities       : LongInt;
   VideoModePtr       : ^TWordArray;
   TotalMemory        : word;

   {VESA 2.0}
   OemSoftwareRev     : word;
   OemVendorNamePtr   : Pchar;
   OemProductNamePtr  : Pchar;
   OemProductRevPtr   : Pchar;
   Paddington         : array [35..512] of Byte;

For a detailed description of the above record download the VESA 1.2 or VESA 2.0 specification.

The second structure contains information about a specific mode. The function call is Interrupt 10h, function 4f01h.

	Input:  AH = 4fh	 Super VGA Support
                AL = 01h	 Return Super VGA Mode information
                CX = Mode Number
                ES:DI = Real Mode pointer to buffer

        Output: AX = Status
                (All other registers are preserved)

The interrupt call returns info in this format:
 TModeRec = record
   ModeAttributes     : Word;
   WindowAFlags       : Byte;
   WindowBFlags       : Byte;
   Granularity        : Word;
   WindowSize         : Word;
   WindowASeg         : Word;
   WindowBSeg         : Word;
   BankSwitch         : Pointer;
   BytesPerLine       : Word;
   XRes,YRes          : Word;
   CharWidth          : Byte;
   CharHeight         : Byte;
   NumBitplanes       : Byte;
   BitsPerPixel       : Byte;
   NumberOfBanks      : Byte;
   MemoryModel        : Byte;
   BankSize           : Byte;
   NumOfImagePages    : byte;
   Reserved           : byte;
   {Direct Colour fields (required for Direct/6 and YUV/7 memory models}
   RedMaskSize        : byte;
   RedFieldPosition   : Byte;
   GreenMaskSize      : Byte;
   GreenFieldPosition : Byte;
   BlueMaskSize       : Byte;
   BlueFieldPosition  : Byte;
   RsvdMaskSize       : Byte;
   RsvdFieldPosition  : Byte;
   DirectColourMode   : Byte;
   {VESA 2.0 stuff}
   PhysBasePtr        : longint;
   OffScreenMemOffset : pointer;
   OffScreenMemSize   : word;
   paddington         : array [49..512] of Byte;

Protected Mode Considerations

The VBE Interrupt calls are meant for Real-Mode applications. All the pointers that are returned via function calls 4F00h and 4F01h are RM pointers, including the direct bank switch call. There is a DPMI function call that will convert a RM address to a Protected Mode address:

{Input: A Real-Mode pointer;  
 Output: The equivilant Protected-Mode pointer
 Usage: PM_Pointer:=ConvertPtr(RM_Pointer);
 Alternate: MyPointer:=ConvertPtr(MyPointer);
 Restrictions: Must be in Protected Mode; Must have a DPMI host.
function ConvertPtr(RMPointer:Pointer):pointer; assembler;
	mov	ax,0002h
	mov	bx,word ptr RMPointer+2 {Convert the RM segment to PM selector}
	int	31h                     {Call DPMI}
	mov	dx,ax                   {Return pointer in DX:AX}
	mov	ax,word ptr RMPointer   {Offset is the same}


When attempting to code an application that should be universal, there will always be some configuration that won't work. Here are some potential problems with any of the VESA code you download from us: Click on the parchment below to download a sample program that displays VESA information in either RM or PM.
Previous pageUp one levelNext pageDownloadable stuff