home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOOL_INC.ZIP / CHARBIT.INC < prev    next >
Encoding:
Text File  |  1988-01-29  |  7.3 KB  |  189 lines

  1.  
  2. {#log Get pixel bit from ROM font}
  3.  
  4. (*
  5.  * Function:     char_bit(char, int, int): boolean
  6.  *
  7.  * Description:  Get the specified pixel bit in a character.
  8.  *               The rom character set is used for all but special
  9.  *               characters (128..255).
  10.  *
  11.  * Inputs:       the ascii character
  12.  *               the scan line number 1..8
  13.  *               the scan column 1..8
  14.  *
  15.  * Outputs:      true if the specified bit is set (lit)
  16.  *
  17.  *)
  18.  
  19. function char_bit(ch:        char;
  20.                   scanline:  integer;
  21.                   scancol:   integer):  boolean;
  22. type
  23.    rom_character = array [1..8] of byte;
  24.    string8       = string[8];
  25.  
  26. var
  27.    char_table:    array[#0..#127] of rom_character  absolute $F000:$FA6E;
  28.                              { this is the character set in the bios
  29.                                rom which is used in text display
  30.                                in graphic video modes.  unfortunately,
  31.                                this table does not include codes > #127 }
  32.  
  33.    function special_char(l1,l2,l3,l4,l5,l6,l7,l8: string8): boolean;
  34.                              { return the pixel bits for a special char
  35.                                that is not in the rom.  this is called with
  36.                                8 strings that give a "picture" of how
  37.                                the character should look on the output }
  38.    var
  39.       line:  string8;
  40.  
  41.    begin
  42.       case scanline of
  43.          1:  line := l1;
  44.          2:  line := l2;
  45.          3:  line := l3;
  46.          4:  line := l4;
  47.          5:  line := l5;
  48.          6:  line := l6;
  49.          7:  line := l7;
  50.          8:  line := l8;
  51.       end;
  52.  
  53.       special_char := (line[scancol] <> ' ');
  54.    end;
  55.  
  56.  
  57. begin  {char_bit}
  58.  
  59.    { look up the special characters that are not in the rom }
  60.  
  61.    case ch of
  62.          '┌','╒','╓','╔':
  63.                char_bit := special_char('        ',
  64.                                         '        ',
  65.                                         '        ',
  66.                                         '   #####',
  67.                                         '   #####',
  68.                                         '   ##   ',
  69.                                         '   ##   ',
  70.                                         '   ##   ');
  71.  
  72.          '┐','╕','╖','╗':
  73.                char_bit := special_char('        ',
  74.                                         '        ',
  75.                                         '        ',
  76.                                         '#####   ',
  77.                                         '#####   ',
  78.                                         '   ##   ',
  79.                                         '   ##   ',
  80.                                         '   ##   ');
  81.  
  82.          '└','╘','╙','╚':
  83.                char_bit := special_char('   ##   ',
  84.                                         '   ##   ',
  85.                                         '   ##   ',
  86.                                         '   #####',
  87.                                         '   #####',
  88.                                         '        ',
  89.                                         '        ',
  90.                                         '        ');
  91.  
  92.          '┘','╛','╜','╝':
  93.                char_bit := special_char('   ##   ',
  94.                                         '   ##   ',
  95.                                         '   ##   ',
  96.                                         '#####   ',
  97.                                         '#####   ',
  98.                                         '        ',
  99.                                         '        ',
  100.                                         '        ');
  101.  
  102.          '│','║':
  103.                char_bit := special_char('   ##   ',
  104.                                         '   ##   ',
  105.                                         '   ##   ',
  106.                                         '   ##   ',
  107.                                         '   ##   ',
  108.                                         '   ##   ',
  109.                                         '   ##   ',
  110.                                         '   ##   ');
  111.  
  112.          '─','═':
  113.                char_bit := special_char('        ',
  114.                                         '        ',
  115.                                         '        ',
  116.                                         '########',
  117.                                         '########',
  118.                                         '        ',
  119.                                         '        ',
  120.                                         '        ');
  121.  
  122.          '┤','╡','╣','╢':
  123.                char_bit := special_char('   ##   ',
  124.                                         '   ##   ',
  125.                                         '   ##   ',
  126.                                         '#####   ',
  127.                                         '#####   ',
  128.                                         '   ##   ',
  129.                                         '   ##   ',
  130.                                         '   ##   ');
  131.  
  132.          '├','╞','╠','╟':
  133.                char_bit := special_char('   ##   ',
  134.                                         '   ##   ',
  135.                                         '   ##   ',
  136.                                         '   #####',
  137.                                         '   #####',
  138.                                         '   ##   ',
  139.                                         '   ##   ',
  140.                                         '   ##   ');
  141.  
  142.          '┴','╨','╧','╩':
  143.                char_bit := special_char('   ##   ',
  144.                                         '   ##   ',
  145.                                         '   ##   ',
  146.                                         '########',
  147.                                         '########',
  148.                                         '        ',
  149.                                         '        ',
  150.                                         '        ');
  151.  
  152.          '┬','╥','╤','╦':
  153.                char_bit := special_char('        ',
  154.                                         '        ',
  155.                                         '        ',
  156.                                         '########',
  157.                                         '########',
  158.                                         '   ##   ',
  159.                                         '   ##   ',
  160.                                         '   ##   ');
  161.  
  162.          '┼','╪','╫','╬':
  163.                char_bit := special_char('   ##   ',
  164.                                         '   ##   ',
  165.                                         '   ##   ',
  166.                                         '########',
  167.                                         '########',
  168.                                         '   ##   ',
  169.                                         '   ##   ',
  170.                                         '   ##   ');
  171.  
  172.          '_':  char_bit := special_char('        ',
  173.                                         '        ',
  174.                                         '        ',
  175.                                         '        ',
  176.                                         '        ',
  177.                                         '        ',
  178.                                         '########',
  179.                                         '########');
  180.  
  181.          ^@..#127:    {these characters are in the rom}
  182.             char_bit := (char_table[ch][scanline] and ($100 shr scancol)) <> 0;
  183.  
  184.          else         {invalid characters will be printed as solid blocks}
  185.             char_bit := true;
  186.    end;
  187. end;
  188.  
  189.