home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 9 / 1995-08_Disc_9.iso / vesa / samples / testvesa.pas < prev    next >
Pascal/Delphi Source File  |  1990-01-11  |  10KB  |  374 lines

  1. {-----------------------------------------------------------------------}
  2. {TESTVESA                        GL:12/18/89    }
  3. {-----------------------------------------------------------------------}
  4. {Program for testing compatibility and capabilities of VESA BIOS    }
  5. {Extension implementations.                        }
  6. {-----------------------------------------------------------------------}
  7. {The following program is written to loosely conform to the VESA     }
  8. {Super VGA BIOS Extension document VS891001.  The program is intended    }
  9. {as a demonstration and is not intended to be an example of a         }
  10. {high-performance implementations of the VESA standard.            }
  11. {If you find any omissions or errors, please report them to me on the     }
  12. {Everex Systems BBS at (415) 683-2984.                    }
  13. {                        Gary Lorensen        }
  14. {                        Everex Systems, Inc.    }
  15. {                        48571 Milmont Dr. B3    }
  16. {                        Fremont, CA   94538    }
  17. {-----------------------------------------------------------------------}
  18.  
  19. uses
  20.     dos;
  21.  
  22. {-----------------------------------------------------------------------}
  23. {-----------------------------------------------------------------------}
  24.  
  25. type
  26.     s80 = string[80];
  27.     s8  = string[8];
  28.  
  29.     CharString = array [$00..$03] of char;
  30.  
  31.     ModeListType = array [$00..$00] of word;
  32.  
  33.     PageFuncPtrType = pointer;
  34.  
  35.     VgaInfoBlockType = record
  36.         VESASignature    : CharString;
  37.     VESAVersion     : word;
  38.     OEMStringPtr    : ^CharString;
  39.     Capabilities    : array [$00..$03] of byte;
  40.     VideoModePtr    : ^ModeListType;
  41.     reserved    : array [$00..$ED] of byte;    {Pad to 256}
  42.     end;
  43.  
  44.     ModeInfoBlockType = record
  45.                      {mandatory information}
  46.     ModeAttributes    : word;
  47.     WinAAttributes    : byte;
  48.     WinBAttributes    : byte;
  49.     WinGranularity    : word;
  50.     WinSize        : word;
  51.     WinASegment    : word;
  52.     WinBSegment    : word;
  53.     WinFuncPtr    : PageFuncPtrType;
  54.     BytesPerScanLine : word;
  55.  
  56.                     {optional information}
  57.     XResolution    : word;
  58.     YResolution    : word;
  59.     XCharSize    : byte;
  60.     YCharSize    : byte;
  61.     NumberOfPlanes    : byte;
  62.     BitsPerPixel    : byte;
  63.     NumberOfBanks    : byte;
  64.     MemoryModel    : byte;
  65.     BankSize    : byte;
  66.     reserved    : array [$00..$E2] of byte;    {Pad to 256}
  67.     end;
  68.  
  69. {-----------------------------------------------------------------------}
  70. {-----------------------------------------------------------------------}
  71.  
  72. var
  73.     reg : Registers;
  74.     VesaVgaInfo : VgaInfoBlockType;
  75.     VesaModeInfo : ModeInfoBlockType;
  76.     i,j : word;
  77.  
  78. {-----------------------------------------------------------------------}
  79. {-----------------------------------------------------------------------}
  80.  
  81. function decval(ch : char) : byte;
  82.  
  83. begin
  84.     decval := 0;
  85.     if ((ch>='0') and (ch<='9')) then
  86.         decval := ord(ch)-ord('0');
  87.     if ((ch>='A') and (ch<='F')) then
  88.         decval := ord(ch)-ord('A')+$0A;
  89.     if ((ch>='a') and (ch<='f')) then
  90.         decval := ord(ch)-ord('a')+$0A;
  91. end;
  92.  
  93. function hex2dec(s : s80) : word;
  94.  
  95. var
  96.     i     : byte;
  97.     tmp   : word;
  98.     place : word;
  99.  
  100. begin
  101.     i := ord(s[0]);
  102.     place := 1;
  103.     tmp := 0;
  104.     while (i>0) do begin
  105.         tmp := tmp+place*decval(s[i]);
  106.     i:=i-1;
  107.     place := place*$10;
  108.     end;
  109.     hex2dec := tmp;
  110. {    writeln('hex2dec(',s,') = ',tmp);}
  111. end;
  112.  
  113. {-----------------------------------------------------------------------}
  114.  
  115. function hexval(x : byte) : char;
  116.  
  117. begin
  118.     hexval := '0';
  119.     if ((x>=0) and (x<=9)) then
  120.         hexval := chr(x+ord('0'));
  121.     if ((x>=10) and (x<=15)) then
  122.         hexval := chr(x-10+ord('A'));
  123. end;
  124.  
  125. function dec2hex(x : word) : s8;
  126.  
  127. var
  128.     tmp   : s8;
  129.     place : word;
  130.  
  131. begin
  132. {    tmp   := '0';}
  133.     tmp := ' ';
  134.     if (x>=$100) then
  135.         place := $1000
  136.     else
  137.         place := $10;
  138.  
  139.     repeat
  140.         tmp := tmp+hexval(x div place);
  141.     x := x mod place;
  142.     place := place div $10;
  143.     until (place=$0000);
  144.  
  145.     dec2hex := tmp+'h';
  146. end;
  147.  
  148.  
  149. function hex(x : word) : s8;
  150.  
  151. var
  152.     tmp   : s8;
  153.     place : word;
  154.  
  155. begin
  156.     tmp := '0';
  157.     if (x>=$100) then
  158.         place := $1000
  159.     else
  160.         place := $10;
  161.  
  162.     repeat
  163.         tmp := tmp+hexval(x div place);
  164.     x := x mod place;
  165.     place := place div $10;
  166.     until (place=$0000);
  167.  
  168.     hex := tmp+'h';
  169. end;
  170.  
  171. function addrhex(x : word) : s8;
  172.  
  173. var
  174.     tmp   : s8;
  175.     place : word;
  176.  
  177. begin
  178.     tmp := '';
  179.     place := $1000;
  180.  
  181.     repeat
  182.         tmp := tmp+hexval(x div place);
  183.     x := x mod place;
  184.     place := place div $10;
  185.     until (place=$0000);
  186.  
  187.     addrhex := tmp;
  188. end;
  189.  
  190. {-----------------------------------------------------------------------}
  191. {-----------------------------------------------------------------------}
  192.  
  193. begin
  194.     writeln;
  195.     writeln('VESA BIOS Extensions compatibility testing program');
  196.     writeln('1990 Everex Systems, Inc.');
  197.     writeln;
  198.  
  199. {-----------------------------------------------------------------------}
  200.  
  201.     reg.AX := $4F00;
  202.     reg.ES := Seg(VesaVgaInfo);
  203.     reg.DI := Ofs(VesaVgaInfo);
  204.     intr($10,reg);
  205.  
  206.     if (reg.AL<>$4F) then begin
  207.         writeln('ERROR: VESA Function 00h: Return Super VGA Information not supported.');
  208.     halt(1);
  209.     end;
  210.  
  211.     if (reg.AH<>$00) then begin
  212.         writeln('ERROR: VESA Function 00h: Return Super VGA Information failed.');
  213.     halt(2);
  214.     end;
  215.  
  216.     writeln('---------------------------------------');
  217.     writeln;
  218.  
  219.     writeln('VESA VGA Information:');
  220.  
  221.     write('    VESA Signature: ');
  222.     for i := $00 to $03 do
  223.         write(VesaVgaInfo.VesaSignature[i]);
  224.     writeln;
  225.  
  226.     write('    VESA Version  : v');
  227.     write(VesaVgaInfo.VesaVersion div $100);
  228.     write('.');
  229.     write(VesaVgaInfo.VesaVersion mod $100);
  230.     writeln;
  231.  
  232.     write('    OEM String    : ');
  233.     i := $00;
  234.     while (VesaVgaInfo.OEMStringPtr^[i]<>#00) do begin
  235.         write(VesaVgaInfo.OEMStringPtr^[i]);
  236.     i:=i+1;
  237.     end;
  238.     writeln;
  239.  
  240.     write('    Capabilities  : ');
  241.     for j := $00 to $03 do
  242.         for i := $00 to $07 do
  243.         if ((VesaVgaInfo.Capabilities[j] and ($80 shr i))=$00) then
  244.             write('0')
  245.         else
  246.             write('1');
  247.     writeln;
  248.  
  249.     write  ('    Modes         : ');
  250.     i := $00;
  251.     while (VesaVgaInfo.VideoModePtr^[i]<>$FFFF) do begin
  252.         if ((i mod 8)=0) then begin
  253.         writeln;
  254.         write('        ');
  255.     end;
  256.         write(addrhex(VesaVgaInfo.VideoModePtr^[i]),'h ');
  257.     i:=i+1;
  258.     end;
  259.     writeln;
  260.  
  261. {-----------------------------------------------------------------------}
  262.  
  263.     writeln('---------------------------------------');
  264.     writeln;
  265.  
  266.     writeln('Mode Information:');
  267.  
  268.     i := $00;
  269.     while (VesaVgaInfo.VideoModePtr^[i]<>$FFFF) do begin
  270.         write('    ',addrhex(VesaVgaInfo.VideoModePtr^[i]),'h  ');
  271.  
  272.         reg.AX := $4F01;
  273.     reg.CX := VesaVgaInfo.VideoModePtr^[i];
  274.         reg.ES := Seg(VesaModeInfo);
  275.         reg.DI := Ofs(VesaModeInfo);
  276.         intr($10,reg);
  277.  
  278.         if (reg.AL<>$4F) then
  279.             writeln('WARNING: Return Super VGA Mode Information not supported.')
  280.  
  281.     else if (reg.AH<>$00) then
  282.             writeln('WARNING: Return Super VGA Mode Information failed.')
  283.  
  284.     else if ((VesaModeInfo.ModeAttributes and $02)=$00) then
  285.             writeln('WARNING: VESA Mode extended mode information not present.')
  286.     else begin
  287.         write(VesaModeInfo.XResolution:4,'x',VesaModeInfo.YResolution:3);
  288.         if ((VesaModeInfo.ModeAttributes and $10)=$10) then
  289.             write('x',VesaModeInfo.NumberOfPlanes:1)
  290.         else
  291.             write('  ');
  292.         write(' ',VesaModeInfo.BitsPerPixel:1,'bpp');
  293.         write(' ',VesaModeInfo.XCharSize:2,'x',VesaModeInfo.YCharSize:2);
  294.         write(' ');
  295.  
  296.         if ((VesaModeInfo.ModeAttributes and $08)=$08) then
  297.             write('Color ')
  298.         else
  299.             write('Mono  ');
  300.  
  301.         if (VesaModeInfo.BankSize>0) then 
  302.             write(' ',VesaModeInfo.BankSize:2,'Kx',VesaModeInfo.NumberOfBanks:1);
  303.  
  304.         if ((VesaModeInfo.WinAAttributes and $01)=$01) then begin
  305.             write('A:',addrhex(VesaModeInfo.WinASegment),' ');
  306.         if ((VesaModeInfo.WinAAttributes and $02)=$02) then
  307.             write('R')
  308.         else 
  309.             write(' ');
  310.         if ((VesaModeInfo.WinAAttributes and $04)=$04) then
  311.             write('W')
  312.         else 
  313.             write(' ');
  314.         end else
  315.             write('         ');
  316.  
  317.         if ((VesaModeInfo.WinBAttributes and $01)=$01) then begin
  318.             write('B:',addrhex(VesaModeInfo.WinBSegment),' ');
  319.         if ((VesaModeInfo.WinBAttributes and $02)=$02) then
  320.             write('R')
  321.         else 
  322.             write(' ');
  323.         if ((VesaModeInfo.WinBAttributes and $04)=$04) then
  324.             write('W')
  325.         else 
  326.             write(' ');
  327.         end else
  328.             write('         ');
  329.  
  330.         case (VesaModeInfo.MemoryModel) of
  331.             $00 : write('Text');
  332.             $01 : write('CGA Grfx');
  333.             $02 : write('HGC Grfx');
  334.             $03 : write('16 Grfx');
  335.             $04 : write('Packed Pixel Grfx');
  336.             $05 : write('Sequ 256 Grfx');
  337.             $06,$07,$08,$09,$0A,$0B,$0C,$0D,$0E,$0F
  338.             : write('reserved for VESA');
  339.         else
  340.         write('OEM memory model');
  341.         end;
  342.         writeln;
  343.  
  344.         write('            ');
  345.         if ((VesaModeInfo.ModeAttributes and $01)=$01) then
  346.             write('Present.      ')
  347.         else
  348.             write('Not present.  ');
  349.  
  350.         if ((VesaModeInfo.ModeAttributes and $04)=$04) then
  351.             write('BIOS')
  352.         else
  353.             write('    ');
  354.  
  355.         write('  ',VesaModeInfo.BytesPerScanLine:3,' raster.  ');
  356.  
  357.         write('Win: ');
  358.         write(VesaModeInfo.WinSize:2,'Kx');
  359.         write(VesaModeInfo.WinSize:2,'K  ');
  360.         write('WinFunc: ',addrhex(Seg(VesaModeInfo.WinFuncPtr^)));
  361.         write(':',addrhex(Ofs(VesaModeInfo.WinFuncPtr^)));
  362.  
  363.         writeln;
  364.             
  365.     end;
  366.  
  367.     i:=i+1;
  368.     end;
  369.  
  370. end.
  371.  
  372. {-----------------------------------------------------------------------}
  373. {-----------------------------------------------------------------------}
  374.