home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / EGAVGA / VGADOC01.ZIP / WHATVGA.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-12-06  |  18.6 KB  |  860 lines

  1.  
  2. uses dos,crt;
  3.  
  4. type
  5.   str10=string[10];
  6.  
  7.  
  8. const
  9.   mems:array[0..7] of string[5]=('64 K','128 K','192 K','256 K','512 K','768 K','1 M','2 M');
  10.   mmmask :array[0..7] of byte=(0,0,0,0,1,3,3,7);
  11.   mmbanks:array[0..7] of byte=(1,2,3,4,8,12,16,32);
  12.  
  13.   _64  =0;
  14.   _128 =1;
  15.   _192 =2;
  16.   _256 =3;
  17.   _512 =4;
  18.   _768 =5;
  19.   _1024=6;
  20.   _2048=7;
  21.  
  22.   hx:array[0..15] of char='0123456789ABCDEF';
  23.  
  24.  
  25. type
  26.   CHIPS=(__EGA,__VGA,__chips451,__chips452,__chips453,__paradise,__video7
  27.         ,__tseng3,__tseng4,__tridBR,__tridCS,__trid89,__everex,__ati1,__ati2
  28.         ,__genoa,__oak,__cirrus,__aheadA,__aheadB,__ncr,__yamaha,__poach
  29.         ,__vesa,__none);
  30.  
  31. var
  32.   rp:registers;
  33.   mm:byte;  {in 64k blocks}
  34.   name:string[40];
  35.   base,old,curbank,x:word;
  36.   CHIP:CHIPS;
  37.  
  38.   video:string[5];
  39.   _crt:string[20];
  40.   secondary:string[20];
  41.   extra:string[80];
  42.   bytes:longint;
  43.   ix17,lins,vseg,vgran:word;
  44.  
  45. function istr(w:word):str10;
  46. var s:str10;
  47. begin
  48.   str(w,s);
  49.   istr:=s;
  50. end;
  51.  
  52. procedure vio(ax:word);
  53. begin
  54.   rp.ax:=ax;
  55.   intr(16,rp);
  56. end;
  57.  
  58. function rdinx(pt,inx:word):word;       {read register PT index INX}
  59. begin
  60.   port[pt]:=inx;
  61.   rdinx:=port[pt+1];
  62. end;
  63.  
  64. procedure wrinx(pt,inx,val:word);       {write VAL to register PT index INX}
  65. begin
  66.   port[pt]  :=inx;
  67.   port[pt+1]:=val;
  68. end;
  69.  
  70. procedure modinx(pt,inx,mask,nwv:word);
  71. begin
  72.   port[pt]:=inx;
  73.   port[pt+1]:=(port[pt+1] and not mask)+(nwv and mask);
  74.  
  75. end;
  76.  
  77. procedure setchip23(bank:word);
  78. begin
  79.   if chip=__chips452 then bank:=bank shl 2 else bank:=bank shl 4;
  80.   wrinx(base+2,16,bank);
  81.  { wrinx(base+2,17,bank);}
  82. end;
  83.  
  84. procedure setbank(bank:word);
  85. var x:word;
  86. begin
  87.   vseg:=$a000;
  88.   if odd(port[$3cc]) then base:=$3d4 else base:=$3b4;
  89.   case chip of
  90.     __chips451:wrinx(base+2,11,bank);
  91.     __chips452:wrinx(base+2,16,bank shl 2);
  92.     __chips453:wrinx(base+2,16,bank shl 4);
  93.     __paradise:wrinx($3ce,9,bank shl 4);
  94.     __video7:begin
  95.                x:=port[$3cc] and $df;
  96.                if (bank and 2)>0 then inc(x,32);
  97.                port[$3c2]:=x;
  98.                modinx($3c4,$f9,1,bank);
  99.                modinx($3c4,$f6,$80,(bank shr 2)*5);
  100.  
  101.              end;
  102.     __tseng3:port[$3cd]:=bank*9+64;
  103.     __tseng4:port[$3cd]:=bank*17;
  104.     __tridBR:;
  105.     __tridCS,__poach,__trid89
  106.             :begin
  107.                wrinx($3c4,11,0);
  108.                if rdinx($3c4,11)=0 then;
  109.                modinx($3c4,14,$f,bank xor 2);
  110.              end;
  111.     __everex:begin
  112.                x:=port[$3cc] and $df;
  113.                if (bank and 2)>0 then inc(x,32);
  114.                port[$3c2]:=x;
  115.                modinx($3c4,8,$80,bank shl 7);
  116.              end;
  117.     __ati1:modinx($1ce,$b2,$1e,bank shl 1);
  118.     __ati2:modinx($1ce,$b2,$ee,bank*$22);
  119.     __genoa:wrinx($3c4,6,bank*9+64);
  120.     __oak:wrinx($3de,17,bank*17);
  121.     __aheadA:begin
  122.                wrinx($3ce,13,bank shr 1);
  123.                x:=port[$3cc] and $df;
  124.                if odd(bank) then inc(x,32);
  125.                port[$3c2]:=x;
  126.              end;
  127.     __aheadB:wrinx($3ce,13,bank*17);
  128.     __ncr:wrinx($3c4,$18,bank shl 2);
  129.     __vesa:begin
  130.              rp.bx:=0;
  131.              rp.dx:=bank*longint(64) div vgran;
  132.              vio($4f05);
  133.              rp.bx:=1;
  134.              vio($4f05);
  135.            end;
  136.   end;
  137.   curbank:=bank;
  138. end;
  139.  
  140. procedure setpix(x,y,col:word);
  141. var l:longint;
  142. begin
  143.   l:=y*bytes+x;
  144.   setbank(l shr 16);
  145.   mem[vseg:word(l)]:=col;
  146. end;
  147.  
  148. procedure setvesa(bx:word);
  149. var vesarec:array[0..255] of byte;
  150. begin
  151.   rp.bx:=bx;
  152.   vio($4f02);
  153.   rp.cx:=bx;
  154.   rp.es:=sseg;
  155.   rp.di:=ofs(vesarec);
  156.   vio($4f01);
  157.   vgran:=vesarec[4];
  158. end;
  159.  
  160. procedure setchip(mde:word);
  161. begin
  162.   vio(mde);
  163.   portw[$46e8]:=$1e;
  164.   portw[$103]:=$80;
  165.   portw[$46e8]:=$e;
  166.   modinx(base+2,4,4,4);
  167.   modinx(base+2,11,3,1);
  168. end;
  169.  
  170. procedure setev(mde:word);
  171. begin
  172.   rp.bl:=mde;
  173.   vio($70);
  174. end;
  175.  
  176. procedure setwd(mde:word);
  177. begin
  178.   vio(mde);
  179.   modinx($3ce,15,$17,5);
  180.   wrinx(base,$29,$85);
  181.   modinx(base,$2f,2,0);
  182. end;
  183.  
  184. procedure setvideo(mde:word);
  185. begin
  186.   rp.bl:=mde;
  187.   vio($6f05);
  188. end;
  189.  
  190.  
  191. procedure setmode0;        {Enter 320x200 mode}
  192. begin
  193.   bytes:=320;lins:=200;
  194.   case CHIP of
  195.     __chips451,__chips452,__chips453:setchip($13);
  196.     __paradise:setwd($13);
  197.   else vio($13);
  198.   end;
  199. end;
  200.  
  201. procedure setmode1;        {Enter 640x400 mode}
  202. begin
  203.   bytes:=640;lins:=400;
  204.   case CHIP of
  205.     __chips451,__chips452,__chips453:setchip($78);
  206.     __paradise:setwd($5e);
  207.     __video7:setvideo($66);
  208.     __tseng3:begin vio($2d);lins:=350 end;
  209.     __tseng4:vio($2f);
  210.     __tridBR,__tridCS,__poach,__trid89:vio($5c);
  211.     __everex:setev($14);
  212.     __ati1,__ati2:vio($61);
  213.     __genoa:vio($7e);
  214.     __oak:;
  215.     __cirrus:;
  216.     __aheadA,__aheadB:vio($60);
  217.     __ncr:;
  218.     __vesa:setvesa($100);
  219.   end;
  220. end;
  221.  
  222. procedure setmode2;     {Enter 640x480 mode}
  223. begin
  224.   bytes:=640;lins:=480;
  225.   case CHIP of
  226.     __chips451,__chips452,__chips453:setchip($79);
  227.     __paradise:setwd($5f);
  228.     __video7:setvideo($67);
  229.     __tseng3,__tseng4:vio($2e);
  230.     __tridBR,__tridCS,__poach,__trid89:vio($5d);
  231.     __everex:setev($30);
  232.     __ati1,__ati2:vio($62);
  233.     __genoa:vio($5c);
  234.     __oak:vio($53);
  235.     __cirrus:;
  236.     __aheadA,__aheadB:vio($61);
  237.     __ncr:;
  238.     __vesa:setvesa($101);
  239.   end;
  240. end;
  241.  
  242. procedure setmode3;     {Enter 800x600 mode}
  243. begin
  244.   bytes:=800;lins:=600;
  245.   case CHIP of
  246.     __chips451,__chips452,__chips453:setchip($7b);
  247.     __paradise:setwd($5c);
  248.     __video7:setvideo($69);
  249.     __tseng3,__tseng4:vio($30);
  250.     __tridBR:;
  251.     __tridCS,__poach,__trid89:vio($5e);
  252.     __everex:setev($31);
  253.     __ati1,__ati2:vio($63);
  254.     __genoa:vio($5e);
  255.     __oak:vio($54);
  256.     __cirrus:;
  257.     __aheadA,__aheadB:vio($61);
  258.     __ncr:;
  259.     __vesa:setvesa($101);
  260.   end;
  261. end;
  262.  
  263. procedure setmode4;        {Enter 1024x768 mode}
  264. begin
  265.   bytes:=1024;lins:=768;
  266.   case CHIP of
  267.     __tseng4:vio($38);
  268.     __tridCS,__trid89:vio($61);
  269.     __everex:setev($32);
  270.     __ati2:vio($61);
  271.     __aheadB:vio($63);
  272.     __vesa:setvesa($105);
  273.   end;
  274. end;
  275.  
  276. procedure setvstart(l:longint);       {Set the display start address}
  277. var x,y:word;
  278. begin
  279.   x:=l shr 2;
  280.   y:=(l shr 18) and mmmask[mm];
  281.   wrinx(base,13,lo(x));
  282.   wrinx(base,12,hi(x));
  283.   case chip of
  284.     __tseng3:modinx(base,$23,2,y shl 1);
  285.     __tseng4:modinx(base,$33,3,y);
  286.     __tridcs:modinx(base,$1e,32,y shl 5);
  287.     __trid89:begin
  288.                modinx(base,$1e,$a0,y shl 5+128);
  289.                wrinx($3c4,11,0);
  290.                modinx($3c4,$e,1,y shr 1);
  291.              end;
  292.     __video7:modinx($3c4,$f6,$70,(y shl 4) and $30);
  293.   __paradise:modinx($3ce,$d,$18,y shl 3);
  294.   __chips452,__chips453:
  295.              begin
  296.                wrinx($3d6,12,y);
  297.                modinx($3d6,4,4,4);
  298.              end;
  299.   __aheadb:modinx($3ce,$1c,3,y);
  300.  
  301.   end;
  302. end;
  303.  
  304. procedure wrtxt(x,y:word;txt:string);      {write TXT to pos (X,Y)}
  305. type
  306.   pchar=array[char] of array[0..15] of byte;
  307. var
  308.   p:^pchar;
  309.   c:char;
  310.   i,j,z,b:integer;
  311. begin
  312.   rp.bh:=6;
  313.   vio($1130);
  314.   p:=ptr(rp.es,rp.bp);
  315.   for z:=1 to length(txt) do
  316.   begin
  317.     c:=txt[z];
  318.     for j:=0 to 15 do
  319.     begin
  320.       b:=p^[c][j];
  321.       for i:=x+7 downto x do
  322.       begin
  323.         if odd(b) then setpix(i,y+j,15)
  324.                   else setpix(i,y+j,0);
  325.         b:=b shr 1;
  326.       end;
  327.     end;
  328.     inc(x,8);
  329.   end;
  330. end;
  331.  
  332. procedure testvmode;          {Test pattern}
  333. begin
  334.   for x:=50 to bytes-50 do
  335.   begin
  336.     setpix(x,30,lo(x));
  337.     setpix(x,lins-30,lo(x));
  338.   end;
  339.   for x:=30 to lins-30 do
  340.   begin
  341.     setpix(x+20,x,lo(x));
  342.     setpix(bytes-30-x,x,lo(x));
  343.     setpix(50,x,lo(x));
  344.     setpix(bytes-50,x,lo(x));
  345.   end;
  346.   wrtxt(70,70,name+' with '+mems[mm]+'bytes.');
  347.   wrtxt(70,100,'Mode: '+istr(bytes)+'x'+istr(lins)+' 256 color');
  348.   if readkey=' ' then;
  349.   textmode(3);
  350. end;
  351.  
  352.  
  353. function getbios(offs,lnn:word):string;
  354. var s:string;
  355. begin
  356.   s[0]:=chr(lnn);
  357.   move(mem[$c000:offs],s[1],lnn);
  358.   getbios:=s;
  359. end;
  360.  
  361. function tstrg(pt,msk:word):boolean;       {Returns true if the bits in MSK
  362.                                             of register PT are read/writable}
  363. var old,nw1,nw2:word;
  364. begin
  365.   old:=port[pt];
  366.   port[pt]:=old and not msk;
  367.   nw1:=port[pt] and msk;
  368.   port[pt]:=old or msk;
  369.   nw2:=port[pt] and msk;
  370.   port[pt]:=old;
  371.   tstrg:=(nw1=0) and (nw2>0);
  372. end;
  373.  
  374. function testreg(pt,rg:word):boolean;      {Returns }
  375. var old,nw1,nw2:word;
  376. begin
  377.   port[pt]:=rg;
  378.   testreg:=tstrg(pt+1,$ff);
  379. end;
  380.  
  381. function testreg2(pt,rg,msk:word):boolean;
  382. var old,nw1,nw2:word;
  383. begin
  384.   port[pt]:=rg;
  385.   testreg2:=tstrg(pt+1,msk);
  386. end;
  387.  
  388. function memtst:boolean;
  389. var ar:array[0..1023] of byte;
  390.   x:word;
  391. begin
  392.   move(mem[$a000:0],ar,1024);
  393.   for x:=0 to 1023 do
  394.     inc(mem[$a000:x],x);
  395.  
  396.   memtst:=true;
  397.   for x:=0 to 1023 do
  398.     if mem[$a000:x]<>lo(ar[x]+x) then
  399.       memtst:=false;
  400.   move(ar,mem[$a000:0],1024);
  401. end;
  402.  
  403. function tsengmem(bank:word):boolean;
  404. var old:word;
  405. begin
  406.   old:=port[$3cd];
  407.   port[$3cd]:=bank;
  408.   tsengmem:=memtst;
  409.   port[$3cd]:=old;
  410. end;
  411.  
  412. function tridmem(bank:word):boolean;
  413. var old:word;
  414. begin
  415.   old:=rdinx($3c4,14);
  416.   port[$3c5]:=bank xor 2;
  417.   tridmem:=memtst;
  418.   port[$3c5]:=old;
  419. end;
  420.  
  421. procedure _chipstech;
  422. begin
  423.   vio($5f00);
  424.   if rp.al=$5f then
  425.   begin
  426.     case rp.bl shr 4 of
  427.       0:name:='Chips & Tech 82c451';
  428.       1:name:='Chips & Tech 82c452';
  429.       2:name:='Chips & Tech 82c455';
  430.       3:name:='Chips & Tech 82c453';
  431.       5:name:='Chips & Tech 82c456';
  432.     else name:='Unknown Chips & Tech';
  433.     end;
  434.     case rp.bl shr 4 of
  435.       1:CHIP:=__chips452;
  436.       3:CHIP:=__chips453;
  437.     else chip:=__chips451;
  438.     end;
  439.     case rp.bh of
  440.       1:mm:=_512;
  441.       2:mm:=_1024;
  442.     end;
  443.   end;
  444. end;
  445.  
  446. procedure _paradise;
  447. var old,old2:word;
  448. begin
  449.   if getbios($7d,4)='VGA=' then
  450.   begin
  451.     old:=rdinx($3ce,15);
  452.     port[$3cf]:=old and $e8+5;   {Unlock registers}
  453.     old2:=rdinx(base,$29);
  454.     port[base+1]:=old2 and $60+$85;
  455.     if not testreg(base,$2b) then name:='Paradise PVGA1A'
  456.     else if not testreg2($3c4,18,64) then name:='Western Digital WD90C00'
  457.     else if not testreg2($3c4,16,4) then name:='Western Digital WD90C10'
  458.                                     else name:='Western Digital WD90C11';
  459.     port[$3ce]:=11;
  460.     case port[$3cf] shr 6 of
  461.        2:mm:=_512;
  462.        3:mm:=_1024;
  463.     end;
  464.     wrinx(base,$29,old2);
  465.     wrinx($3ce,15,old);
  466.     chip:=__paradise;
  467.   end;
  468. end;
  469.  
  470. procedure _video7;
  471. begin
  472.   vio($6f00);
  473.   if rp.bx=$5637 then
  474.   begin
  475.     vio($6f07);
  476.     case rp.bl of
  477.       $80..$ff:name:='Video7 VEGA VGA';
  478.       $70..$7f:name:='Video7 FASTWRITE/VRAM';
  479.       $50..$5f:name:='Video7 Version 5';
  480.       $41..$4f:name:='Video7 1024i';
  481.     end;
  482.     case rp.ah and 127 of
  483.       2:mm:=_512;
  484.       4:mm:=_1024;
  485.     end;
  486.     chip:=__video7;
  487.   end
  488. end;
  489.  
  490. procedure _genoa;
  491. var ad:word;
  492. begin
  493.   ad:=memw[$c000:$37];
  494.   if (memw[$c000:ad+2]=$6699) and (mem[$c000:ad]=$77) then
  495.   begin
  496.     case mem[$c000:ad+1] of
  497.       0:name:='Genoa 62/300';
  498.     $11:begin
  499.           name:='Genoa 64/500';
  500.           mm:=_512;
  501.         end;
  502.     $22:name:='Genoa 6100';
  503.     $33:name:='Genoa 51/5200 (Tseng 3000)';
  504.     $55:begin
  505.           name:='Genoa 53/5400 (Tseng 3000)';
  506.           mm:=_512;
  507.         end;
  508.     end;
  509.     if mem[$c000:ad+1]<$33 then chip:=__genoa else chip:=__tseng3;
  510.   end
  511. end;
  512.  
  513. procedure _tseng;
  514. begin
  515.   if tstrg($3cd,$3f) then
  516.   begin
  517.     if testreg2(base,$33,$f) then
  518.     begin
  519.       name:='Tseng ET4000';
  520.       case rdinx(base,$37) and 11 of
  521.        3,9:mm:=_256;
  522.         10:mm:=_512;
  523.         11:mm:=_1024;
  524.       end;
  525.       {if tsengmem($ff) then mm:=_1024
  526.       else if tsengmem($77) then mm:=_512;}
  527.       chip:=__tseng4;
  528.     end
  529.     else begin
  530.       name:='Tseng ET3000';
  531.       if tsengmem($7f) then mm:=_512;
  532.       chip:=__tseng3;
  533.     end;
  534.   end;
  535. end;
  536.  
  537. procedure _trident;
  538. var chp,old,val:word;
  539. begin
  540.   wrinx($3c4,11,0);
  541.   chp:=port[$3c5];
  542.   old:=rdinx($3c4,14);
  543.   port[$3c5]:=0;
  544.   val:=port[$3c5];
  545.   port[$3c5]:=old;
  546.   if val and 15=2 then
  547.   begin
  548.     case chp of
  549.       1:name:='Trident 8800BR';
  550.       2:name:='Trident 8800CS';
  551.       3:name:='Trident 8900';
  552.     else name:='Unknown Trident VGA'
  553.     end;
  554.     case chp of
  555.       1:chip:=__tridbr;
  556.       2:chip:=__tridCS;
  557.       3:chip:=__trid89;
  558.     end;
  559.     if (pos('Zymos Poach 51',getbios(0,255))>0) or
  560.        (pos('Zymos Poach 51',getbios(230,255))>0) then
  561.     begin
  562.       name:=name+' (Zymos Poach)';
  563.       chip:=__poach;
  564.     end;
  565.     if (chp>=3) then mm:=_256+rdinx(base,$1f) and 3
  566.     else if (rdinx(base,$1f) and 2)>0 then mm:=_512;
  567.  
  568.   end;
  569. end;
  570.  
  571. procedure _oak;
  572. begin
  573.   if testreg2($3de,$d,$ff) then
  574.   begin
  575.     name:='OAK 037C';
  576.     if testreg2($3de,$11,$ff) then name:='OAK-067';
  577.     if rdinx($3de,13)>127 then mm:=_512;
  578.     chip:=__oak;
  579.   end;
  580. end;
  581.  
  582. procedure _cirrus;
  583. var old,eagle:word;
  584. begin
  585.   old:=rdinx(base,12);
  586.   port[base+1]:=0;
  587.   eagle:=rdinx(base,$1f);
  588.   wrinx($3c4,6,lo(eagle shr 4) or lo(eagle shl 4));
  589.   if port[$3c5]=0 then
  590.   begin
  591.     port[$3c5]:=eagle;
  592.     if port[$3c5]=1 then
  593.     begin
  594.       case eagle of
  595.         $EC:name:='Cirrus 510/520';
  596.         $CA:name:='Cirrus 610/620';
  597.         $EA:name:='Cirrus Video 7 OEM'
  598.       else name:='Unknown Cirrus Chip';
  599.       end;
  600.       chip:=__cirrus;
  601.     end;
  602.   end;
  603.   wrinx(base,12,old);
  604. end;
  605.  
  606. procedure _ahead;
  607. var old:word;
  608. begin
  609.   portw[$3ce]:=$200f;
  610.   old:=port[$3cf];
  611.   case old of
  612.     $20:begin
  613.           name:='Ahead A';
  614.           chip:=__aheadA;
  615.         end;
  616.     $21:begin
  617.           name:='Ahead B';
  618.           chip:=__aheadB;
  619.         end;
  620.   end;
  621. end;
  622.  
  623. procedure _everex;
  624. var x:word;
  625. begin
  626.   rp.bx:=0;
  627.   vio($7000);
  628.   if rp.al=$70 then
  629.   begin
  630.     x:=rp.dx shr 4;
  631.     if (x<>$678) and (x<>$236) then     {Some Everex boards use Trident chips.}
  632.     begin
  633.       case rp.ch shr 6 of
  634.         1:mm:=_512;
  635.         2:mm:=_1024;
  636.         3:mm:=_2048;
  637.       end;
  638.       name:='Everex Ev'+hx[x shr 8]+hx[(x shr 4) and 15]+hx[x and 15];
  639.       chip:=__everex;
  640.     end;
  641.   end;
  642. end;
  643.  
  644. procedure _ati;
  645. var w:word;
  646. begin
  647.   if getbios($31,9)='761295520' then
  648.   case memw[$c000:$40] of
  649.    $3133:begin
  650.            name:='ATI VGA Wonder';
  651.            w:=rdinx($1ce,$bb);
  652.            if (w and 32)>0 then mm:=_512;
  653.            case w and 15 of
  654.              0:_crt:='EGA';
  655.              1:_crt:='Analog Monochrome';
  656.              2:_crt:='Monochrome';
  657.              3:_crt:='Analog Color';
  658.              4:_crt:='CGA';
  659.              6:_crt:='';
  660.              7:_crt:='IBM 8514/A';
  661.            else _crt:='Multisync';
  662.            end;
  663.            rp.bx:=$5506;
  664.            rp.bp:=$ffff;
  665.            rp.si:=0;
  666.            vio($1255);
  667.            if rp.bp=$ffff then
  668.            begin
  669.              name:=name+' revision 1.';
  670.              chip:=__ati1;
  671.            end
  672.            else begin
  673.              name:=name+' revision 2.';
  674.              chip:=__ati2;
  675.            end;
  676.          end;
  677.    $3233:begin
  678.            name:='ATI EGA Wonder';
  679.            video:='EGA';
  680.            chip:=__ega;
  681.          end;
  682.   end;
  683. end;
  684.  
  685. procedure _vesa;
  686. begin
  687.   vio($4f03);
  688.   if rp.al=$4f then
  689.   begin
  690.     name:='VESA';
  691.     chip:=__vesa;
  692.   end;
  693. end;
  694.  
  695. procedure _yamaha;
  696. begin
  697.   if testreg2($3d4,$7c,$7c) then
  698.   begin
  699.     name:='Yamaha 6388'
  700.   end;
  701. end;
  702.  
  703. procedure _ncr;
  704. begin
  705.   if testreg2($3c4,5,$ff) then
  706.   begin
  707.     portw[$3c4]:=5;        {Disable extended registers}
  708.     if not testreg2($3c4,16,$ff) then
  709.     begin
  710.       portw[$3c4]:=$105;        {Enable extended registers}
  711.       if testreg2($3c4,16,$ff) then
  712.       begin
  713.         chip:=__ncr;
  714.         name:='NCR 77C22E';
  715.       end;
  716.     end;
  717.   end;
  718. end;
  719.  
  720. begin
  721.   extra:='';
  722.   _crt:='';
  723.   chip:=__none;
  724.   secondary:='';
  725.   name:='';
  726.   video:='none';
  727.   rp.ah:=18;
  728.   rp.bx:=$1010;
  729.   intr(16,rp);
  730.   if rp.bh<=1 then
  731.   begin
  732.     video:='EGA';
  733.     chip:=__ega;
  734.     if odd(port[$3cc]) then base:=$3d4 else base:=$3b4;
  735.  
  736.     mm:=rp.bl;
  737.     vio($1a00);
  738.     if rp.al=$1a then
  739.     begin
  740.       if (rp.bl<4) and (rp.bh>3) then
  741.       begin
  742.         old:=rp.bl;
  743.         rp.bl:=rp.bh;
  744.         rp.bh:=old;
  745.       end;
  746.       video:='MCGA';
  747.       case rp.bl of
  748.         2,4,6,10:_crt:='TTL Color';
  749.         1,5,7,11:_crt:='Monochrome';
  750.         8,12:_crt:='Analog Color';
  751.       end;
  752.       case rp.bh of
  753.         1:secondary:='Monochrome';
  754.         2:secondary:='CGA';
  755.       end;
  756.       if (getbios($31,9)='') and (getbios($40,2)='22') then
  757.       begin
  758.         video:='EGA';       {@#%@  lying ATI EGA Wonder !}
  759.         name:='ATI EGA Wonder';
  760.  
  761.       end else
  762.       if (rp.bl<10) or (rp.bl>12) then
  763.       begin
  764.         video:='VGA';
  765.         chip:=__vga;
  766.         mm:=_256;
  767.         vio(19);
  768.         _vesa;
  769.         if name='' then _chipstech;
  770.         if name='' then _paradise;
  771.         if name='' then _video7;
  772.         if name='' then _genoa;
  773.         if name='' then _tseng;
  774.         if name='' then _everex;
  775.         if name='' then _trident;
  776.         if name='' then _ati;
  777.         if name='' then _oak;
  778.         if name='' then _cirrus;
  779.         if name='' then _ahead;
  780.         if name='' then _yamaha;
  781.         if name='' then _ncr;
  782.       end;
  783.     end;
  784.   end;
  785.   textmode(3);
  786.   write('Video system: ',video,' with ',mems[mm]+'bytes.');
  787.   if _crt<>'' then write(' Monitor: '+_crt);
  788.   writeln;
  789.   if secondary<>'' then writeln('Secondary display: '+secondary);
  790.   if name<>'' then writeln('Chipset: '+name);
  791.   if extra<>'' then writeln(extra);
  792.  
  793.   writeln;
  794.   writeln;
  795.   if chip<=__vga then
  796.   begin
  797.     if readkey=' ' then;
  798.   end
  799.   else begin
  800.     write('Run 640x350/400 256 color test (Y/N) ?');
  801.     if upcase(readkey)<>'N' then
  802.     begin
  803.       setmode1;
  804.       testvmode;
  805.     end;
  806.  
  807.     writeln;
  808.     write('Run 640x480 256 color test (Y/N) ?');
  809.     if upcase(readkey)<>'N' then
  810.     begin
  811.       setmode2;
  812.       testvmode;
  813.     end;
  814.  
  815.     writeln;
  816.     write('Run 800x600 256 color test (Y/N) ?');
  817.     if upcase(readkey)<>'N' then
  818.     begin
  819.       setmode3;
  820.       testvmode;
  821.     end;
  822.  
  823.     writeln;
  824.     write('Run 1024x768 256 color test (Y/N) ?');
  825.     if upcase(readkey)<>'N' then
  826.     begin
  827.       setmode4;
  828.       testvmode;
  829.     end;
  830.  
  831.     writeln;
  832.     write('Run scroll test (Y/N) ?');
  833.     if upcase(readkey)<>'N' then
  834.     begin
  835.       setmode0;
  836.       IX17:=RDINX(base,$17);
  837.  
  838.       bytes:=320;
  839.       for x:=0 to pred(mmbanks[mm]) do     {Clear video memory}
  840.       begin
  841.         setbank(x);
  842.         fillchar(mem[$a000:0],$8000,0);
  843.         fillchar(mem[$a800:0],$8000,0);
  844.       end;
  845.  
  846.       for x:=mmbanks[mm]*10 downto 1 do
  847.         wrtxt(20,x*20-15,'Linie '+istr(x)+' scrolling');
  848.  
  849.       for x:=1 to mmbanks[mm]*10-9 do       {Scroll text up}
  850.       begin
  851.         setvstart(pred(x)*20*longint(bytes));
  852.         delay(200);
  853.       end;
  854.     end;
  855.  
  856.  
  857.  
  858.   end;
  859.   textmode(3);
  860. end.