home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Pascal / Samples / VGAFONT.ARJ / FONTFIND.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-02-11  |  7.0 KB  |  351 lines

  1.  
  2. program fontfind;
  3.  
  4.   USES
  5.    TpString,TpCRT;
  6.  
  7.  
  8.   Type
  9.    ByteAry = Array [0..65519] of byte;
  10.    ByteAryPtr = ^ByteAry;
  11.    BytePtr = ^Byte;
  12.  
  13.   VAR
  14.    F8x8  : array [0..255,0..7 ] of byte;
  15.    F8x14 : array [0..255,0..13] of byte;
  16.    F8x16 : array [0..255,0..15] of byte;
  17.  
  18.  
  19.  
  20.   (************************************************************************)
  21.  
  22.   VAR
  23.    B : Array [0..255,0..31] of Byte absolute $A000:$0000;
  24.  
  25.    VIDEOBIOS : Array [0..$7fff] of byte absolute $C000:0;
  26.  
  27.   { Enable loading Software font }
  28.  
  29.   procedure EnaLoadFont; assembler;
  30.   asm
  31.                jmp @@0
  32.  
  33.    @@SeqParms:
  34.                DW 0402h           { CPU writes only to map 2    }
  35.                DW 0704h           { sequential addressing       }
  36.  
  37.    @@GCParms:  DW 0204h           { select map 2 for CPU reads  }
  38.                DW 0005h           { disable odd-even addressing }
  39.                DW 0006h           { map starts at A000:0000     }
  40.  
  41.       @@0:
  42.  
  43.                push ds
  44.  
  45.                push cs
  46.                pop  ds
  47.  
  48.                cli
  49.                mov       dx,3C4h  { Sequencer port address }
  50.                mov       si,offset @@SeqParms
  51.                mov       cx,2
  52.  
  53.       @@L01:   lodsw
  54.  
  55.                out       dx,ax
  56.                loop      @@L01
  57.                sti
  58.  
  59.  
  60.  
  61.                mov       dl,0CEh { DX := 3CEH (Graphics Controller port }
  62.  
  63.                mov       si,offset @@GCParms
  64.                mov       cx,3
  65.  
  66.       @@L02:   lodsw
  67.                out       dx,ax
  68.                loop      @@L02
  69.  
  70.                pop ds
  71.   end;
  72.  
  73.  
  74.  
  75.   { Restore back video buffer adressing after font load }
  76.  
  77.   procedure RestoreBack; assembler ;
  78.   asm
  79.                 jmp @@0
  80.  
  81.     @@SeqParms:
  82.                 DW      0302h            { CPU writes to maps 0 and 1 }
  83.                 DW      0304h            { odd-even addressing }
  84.  
  85.     @@GCParms:  DW      0004h
  86.                 DW      1005h
  87.                 DW      0E06h            { Maps at start B800:0000 }
  88.  
  89.     @@0:                                 { Program the Sequencer }
  90.                 push ds
  91.                 push cs
  92.                 pop ds
  93.  
  94.                 cli
  95.                 mov     dx,3C4h
  96.                 mov     si,offset @@SeqParms
  97.                 mov     cx,2
  98.  
  99.     @@L01:      lodsw
  100.  
  101.                 out     dx,ax
  102.                 loop    @@L01
  103.                 sti
  104.  
  105.  
  106.  
  107.                 mov     dl,0CEh
  108.  
  109.                 mov     si,offset @@GCParms
  110.                 mov     cx,3
  111.  
  112.     @@L02:      lodsw
  113.                 out     dx,ax
  114.                 loop    @@L02
  115.  
  116.                 pop     ds
  117.  
  118.   end;
  119.  
  120.   (************************************************************************)
  121.  
  122.  
  123.  
  124.   PROCEDURE GetFontPtr(N:Byte;var FPtr:Pointer;var FontPoints:Word;var ScreenRows:Byte);assembler;
  125.   var Fp : Pointer;
  126.   asm
  127.        cld
  128.        push  es
  129.        push  bp
  130.        mov   ax,1130h
  131.        mov   bh,N
  132.        int   10h
  133.        mov   ax,bp
  134.        pop   bp
  135.        mov   word ptr Fp,ax
  136.        mov   word ptr Fp[2],es
  137.        pop   es
  138.  
  139.        les   di,ScreenRows
  140.        mov   al,dl
  141.        stosb
  142.        les   di,FontPoints
  143.        mov   ax,cx
  144.        stosw
  145.  
  146.        les   di,FPtr
  147.        mov   ax,word ptr Fp
  148.        stosw
  149.        mov   ax,word ptr Fp[2]
  150.        stosw
  151.   end;
  152.  
  153.  
  154.   var
  155.    BReport8x14L : BytePtr;
  156.    BReport8x8L  : BytePtr;
  157.    BReport8x8H  : BytePtr;
  158.    BReport9x14H : BytePtr;
  159.    BReport8x16  : BytePtr;
  160.    BReport9x16  : BytePtr;
  161.  
  162.  
  163.   Function Match(Src,Dest:BytePtr;Size:Word):Boolean;
  164.   begin
  165.    Match := True;
  166.    While Size <> 0 do
  167.     begin
  168.      if Src^<>Dest^ then
  169.        begin
  170.         Match := False; Exit;
  171.        end;
  172.      inc(Src);
  173.      inc(Dest);
  174.      Dec(Size)
  175.     end;
  176.   end;
  177.  
  178.  
  179.   PROCEDURE GetByHardware;
  180.   var c,i : Byte;
  181.   begin
  182.  
  183.    Textmode(3);
  184.  
  185.    { Get Font 8x8 }
  186.  
  187.  
  188.    asm
  189.     mov   ax,1112h
  190.     mov   bl,0
  191.     int   10h
  192.    end;
  193.  
  194.    enaloadfont;
  195.     For c := 0 to 255 do
  196.      for i := 0 to 7 do
  197.       begin
  198.        F8x8[c,i] := B[c,i];
  199.       end;
  200.    restoreback;
  201.  
  202.    { Get Font 8x14 }
  203.  
  204.    asm
  205.     mov   ax,1111h
  206.     mov   bl,0
  207.     int   10h
  208.    end;
  209.  
  210.    enaloadfont;
  211.     For c := 0 to 255 do
  212.      for i := 0 to 13 do
  213.       begin
  214.        F8x14[c,i] := B[c,i];
  215.       end;
  216.    restoreback;
  217.  
  218.    { Get Font 8x16 }
  219.  
  220.    asm
  221.     mov   ax,1114h
  222.     mov   bl,0
  223.     int   10h
  224.    end;
  225.  
  226.    enaloadfont;
  227.     For c := 0 to 255 do
  228.      for i := 0 to 15 do
  229.       begin
  230.        F8x16[c,i] := B[c,i];
  231.       end;
  232.    restoreback;
  233.  
  234.   end;
  235.  
  236.  
  237.   FUNCTION WhatIs(Dest:BytePtr):String;
  238.   var S : String ;
  239.   begin
  240.    S := '';
  241.    if MAtch(@F8x8 [  0,0],Dest,256*8)  then S := S + ' F8x8All' else
  242.     if MAtch(@F8x8 [  0,0],Dest,128*8)  then S := S + ' F8x8Low';
  243.    if MAtch(@F8x8 [128,0],Dest,128*8)  then S := S + ' F8x8High';
  244.  
  245.    if MAtch(@F8x14[  0,0],Dest,256*14) then S := S + ' F8x14All' else
  246.     if MAtch(@F8x14[  0,0],Dest,128*14) then S := S + ' F8x14Low';
  247.    if MAtch(@F8x14[128,0],Dest,128*14) then S := S + ' F8x14High';
  248.  
  249.    if MAtch(@F8x16[  0,0],Dest,256*16) then S := S + ' F8x16All' else
  250.     if MAtch(@F8x16[  0,0],Dest,128*16) then S := S + ' F8x16Low';
  251.    if MAtch(@F8x16[128,0],Dest,128*16) then S := S + ' F8x16High';
  252.  
  253.    if S = '' then S := ' nothing';
  254.    WhatIs := '  Really it is :'+S;
  255.   end;
  256.  
  257.  
  258.   PROCEDURE ScanLetters8x16;
  259.   var Src,Dst : BytePtr;
  260.       C : Word ;
  261.       S : String ;
  262.   begin
  263.    for C := 1 to 254 do
  264.     begin
  265.      Src := @F8x16[C];
  266.      Dst := @VIDEOBIOS;
  267.      S := '';
  268.      while Dst <> Ptr($C000,$7ff0) do
  269.       begin
  270.        if Match(Src,Dst,16) then S := S+' '+HexW(Ofs(Dst^));
  271.        Inc(Dst);
  272.       end;
  273.      Writeln('Char('+Hexb(C)+') found at '+S);
  274.     end;
  275.   end;
  276.  
  277.  
  278.   PROCEDURE CheckIt;
  279.   var C : Word;
  280.   begin
  281.    Writeln('VGA reports that font locations are:');
  282.    writeln(' 8X14L:  at '+HexPtr(Breport8x14L)+WhatIs(Breport8x14L));
  283.    writeln(' 8X8L :  at '+HexPtr(BReport8x8L) +WhatIs(Breport8x8L));
  284.    writeln(' 8X8H :  at '+HexPtr(BReport8x8H) +WhatIs(Breport8x8H));
  285.    writeln(' 9X14H:  at '+HexPtr(BReport9x14H)+WhatIs(Breport9x14H));
  286.    writeln(' 8X16 :  at '+HexPtr(BReport8x16) +WhatIs(Breport8x16));
  287.    writeln(' 9X16 :  at '+HexPtr(BReport9x16) +WhatIs(Breport9x16));
  288.  
  289.  
  290.    {ScanLetters8x16;}
  291.  
  292.  
  293.   end;
  294.  
  295.  
  296.  
  297.   PROCEDURE GetFonts;
  298.   VAR N:Byte;
  299.    FPtr:Pointer;
  300.    FontPoints:Word;
  301.    ScreenRows:Byte;
  302.   begin
  303.    GetFontPtr(2,FPtr,FontPoints,ScreenRows);
  304.    BReport8x14L := FPtr;
  305.  
  306.    GetFontPtr(3,FPtr,FontPoints,ScreenRows);
  307.    BReport8x8L := FPtr;
  308.  
  309.    GetFontPtr(4,FPtr,FontPoints,ScreenRows);
  310.    BReport8x8H := FPtr;
  311.  
  312.    GetFontPtr(5,FPtr,FontPoints,ScreenRows);
  313.    BReport9x14H := FPtr;
  314.  
  315.    GetFontPtr(6,FPtr,FontPoints,ScreenRows);
  316.    BReport8x16 := FPtr;
  317.  
  318.    GetFontPtr(7,FPtr,FontPoints,ScreenRows);
  319.    BReport9x16 := FPtr;
  320.   end;
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327. begin
  328.  
  329.  Writeln('VGA Font Locator. (C) 1993 by KoroSoft Pte Ltd. All rights reserved.'#13#10);
  330.  
  331.  GetFonts;
  332.  GetByHardware;
  333.  CheckIt;
  334.  
  335. { Find8x8;
  336. }
  337.  
  338. end.
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.