'===========================================================================
' Subject: Test SVGA modes                    Date: 12-22-02 (  :  )       
'  Author: Michael Webster                    Code: Qbasic, QB, PDS        
'  Origin: mfwebster@pdq.net                Packet: EGAVGA.ABC
'===========================================================================
'Michael Webster
'SVGA test Code
'QB,PDS

DECLARE FUNCTION UInt& (i%) 
DECLARE FUNCTION MemByte% (segment&, offset&) 
DECLARE FUNCTION MemWord% (segment&, offset&) 
DEFINT A-Z 
' This program calls the VESA BIOS Extensions (VBE) 
' Return VBE Controller Information function, copies 
' the information it returns to a text file, and 
' displays the contents of the file. 
' $INCLUDE: 'QB.BI' 
DIM regX AS RegTypeX 
TYPE VbeInfoBlockType 
    vbeSignature            AS STRING * 4 
    vbeVersion              AS INTEGER 
    oemStringOffset         AS INTEGER 
    oemStringSegment        AS INTEGER 
    capabilities            AS LONG 
    videoModeOffset         AS INTEGER 
    videoModeSegment        AS INTEGER 
    totalMemory             AS INTEGER 
    oemSoftwareRev          AS INTEGER 
    oemVendorNameOffset     AS INTEGER 
    oemVendorNameSegment    AS INTEGER 
    oemProductNameOffset    AS INTEGER 
    oemProductNameSegment   AS INTEGER 
    oemProductRevOffset     AS INTEGER 
    oemProductRevSegment    AS INTEGER 
    reserved                AS STRING * 222 
    oemData                 AS STRING * 256 
END TYPE 
DIM vbeInfo AS VbeInfoBlockType 
' Set the vbeSignature element so the function 
' will return the information for VBE2+. 
vbeInfo.vbeSignature = "VBE2" 
CONST cCapDacSwitchableTo8bitsPerPrimary = 1 
CONST cCapControllerNotVgaCompatible = 2 
CONST cCapSetPaletteDataDuringVerticalRetrace = 4 
CLS 
OPEN "vbeinfo.txt" FOR OUTPUT AS 1 
regX.ax = &H4F00 
regX.es = VARSEG(vbeInfo) 
regX.di = VARPTR(vbeInfo) 
INTERRUPTX &H10, regX, regX 
IF regX.ax <> &H4F THEN 
    PRINT 
    PRINT "The function is not supported or the call failed." 
    END 
END IF 
PRINT #1, "VBE signature = '"; vbeInfo.vbeSignature; "'" 
PRINT #1, "VBE version = "; HEX$(vbeInfo.vbeVersion) 
PRINT #1, "OEM name = '"; 
FOR i = 0 TO 255 
    byte = MemByte(UInt(vbeInfo.oemStringSegment), UInt(vbeInfo.oemStringOffset) + i) 
    IF byte = 0 THEN EXIT FOR 
    PRINT #1, CHR$(byte); 
NEXT 
PRINT #1, "'" 
IF vbeInfo.capabilities AND cCapDacSwitchableTo8bitsPerPrimary THEN 
    PRINT #1, "DAC is switchable to 8 bits per primary color." 
ELSE 
    PRINT #1, "DAC is fixed at 6 bits per primary color." 
END IF 
IF vbeInfo.capabilities AND cCapControllerNotVgaCompatible THEN 
    PRINT #1, "Controller is not VGA compatible." 
ELSE 
    PRINT #1, "Controller is VGA compatible." 
END IF 
IF vbeInfo.capabilities AND cCapSetPaletteDataDuringVerticalRetrace THEN 
    PRINT #1, "Palette data should be set during vertical retrace." 
ELSE 
    PRINT #1, "Palette data can be set at any time." 
END IF 
PRINT #1, "Modes supported by this VBE implementation:" 
FOR i = 0 TO 99 STEP 2 
    IF i AND i MOD 5 = 0 THEN PRINT #1, 
    word = MemWord(UInt(vbeInfo.videoModeSegment), UInt(vbeInfo.videoModeOffset) + i) 
    IF word = &HFFFF THEN EXIT FOR 
    PRINT #1, HEX$(word); " "; 
NEXT 
PRINT #1, 
PRINT #1, "Total memory in 64KB blocks ="; vbeInfo.totalMemory 
PRINT #1, "Total memory in MB ="; vbeInfo.totalMemory * 64& \ 1024 
IF vbeInfo.vbeVersion < &H200 THEN END 
PRINT #1, "OEM software revision = "; HEX$(vbeInfo.oemSoftwareRev) 
PRINT #1, "OEM vendor name = '"; 
FOR i = 0 TO 255 
    byte = MemByte(UInt(vbeInfo.oemVendorNameSegment), UInt(vbeInfo.oemVendorNameOffset) + i) 
    IF byte = 0 THEN EXIT FOR 
    PRINT #1, CHR$(byte); 
NEXT 
PRINT #1, "'" 
PRINT #1, "OEM product name = '"; 
FOR i = 0 TO 255 
    byte = MemByte(UInt(vbeInfo.oemProductNameSegment), UInt(vbeInfo.oemProductNameOffset) + i) 
    IF byte = 0 THEN EXIT FOR 
    PRINT #1, CHR$(byte); 
NEXT 
PRINT #1, "'" 
PRINT #1, "OEM product revision = '"; 
FOR i = 0 TO 255 
    byte = MemByte(UInt(vbeInfo.oemProductRevSegment), UInt(vbeInfo.oemProductRevOffset) + i) 
    IF byte = 0 THEN EXIT FOR 
    PRINT #1, CHR$(byte); 
NEXT 
PRINT #1, "'" 
CLOSE 1 
OPEN "vbeinfo.txt" FOR INPUT AS 1 
DO WHILE NOT EOF(1) 
    LINE INPUT #1, line$ 
    PRINT line$ 
LOOP 
CLOSE 1 
 
FUNCTION MemByte% (segment&, offset&) 
    ' Returns the byte value stored in 
    ' memory at the location specified 
    ' by <segment&>:<offset&>. 
    DEF SEG = segment& 
    MemByte = PEEK(offset&) 
    DEF SEG 
END FUNCTION 
 
FUNCTION MemWord% (segment&, offset&) 
    ' Returns the 16-bit value stored in 
    ' memory at the location specified 
    ' by <segment&>:<offset&>. 
    DEF SEG = segment& 
    b0 = PEEK(offset& + 0) 
    b1 = PEEK(offset& + 1) 
    DEF SEG 
    POKE VARPTR(MemWord) + 0, b0 
    POKE VARPTR(MemWord) + 1, b1 
END FUNCTION 
 
FUNCTION UInt& (i%) 
    ' Converts <i%> to a LONG without extending 
    ' the sign bit and returns the result. 
    DEF SEG 
    POKE VARPTR(UInt), PEEK(VARPTR(i)) 
    POKE VARPTR(UInt) + 1, PEEK(VARPTR(i) + 1) 
END FUNCTION 
                  ========================
This is a list of the VESA defined graphics modes: 
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 (1:5:5:5) 
10Eh    320x200     64K (5:6:5) 
10Fh    320x200     16.8M (8:8:8) 
110h    640x480     32K (1:5:5:5) 
111h    640x480     64K (5:6:5) 
112h    640x480     16.8M (8:8:8) 
113h    800x600     32K (1:5:5:5) 
114h    800x600     64K (5:6:5) 
115h    800x600     16.8M (8:8:8) 
116h    1024x768    32K (1:5:5:5) 
117h    1024x768    64K (5:6:5) 
118h    1024x768    16.8M (8:8:8) 
119h    1280x1024   32K (1:5:5:5) 
11Ah    1280x1024   64K (5:6:5) 
11Bh    1280x1024   16.8M (8:8:8) 
 
This is a list of the VESA defined text modes: 
108h    80x60 
109h    132x25 
10Ah    132x43 
10Bh    132x50 
10Ch    132x60 
