home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 334_01 / bitmap.c < prev    next >
Text File  |  1991-02-05  |  52KB  |  1,052 lines

  1. /* GNUPLOT - bitmap.c */
  2. /*
  3.  * Copyright (C) 1990
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted,
  7.  * provided that the above copyright notice appear in all copies and
  8.  * that both that copyright notice and this permission notice appear
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed
  13.  * as patches to released version.
  14.  *
  15.  * This software  is provided "as is" without express or implied warranty.
  16.  *
  17.  *
  18.  * AUTHORS
  19.  *  Jyrki Yli-Nokari <jty@intrin.UUCP>
  20.  *  Ronald J. Hartranft <rjh2@ns.cc.lehigh.edu>
  21.  *  Russell Lang <rjl@monu1.cc.monash.edu.au>
  22.  *
  23.  * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  24.  *
  25.  */
  26.  
  27. /*
  28. ** General raster plotting routines.
  29. ** Raster routines written and copyrighted 1987 by
  30. ** Jyrki Yli-Nokari (jty@intrin.UUCP)
  31. ** Intrinsic, Ltd.
  32. **
  33. ** You may use this code for anything you like as long as
  34. ** you are not selling it and the credit is given and
  35. ** this message retained.
  36. **
  37. */
  38.  
  39. /* Bitmap plotting routines derived from above raster plotting routines
  40.  * Russell Lang, 1990
  41.  */
  42.  
  43. #include <stdio.h>
  44. #include "plot.h"
  45. #include "bitmap.h"
  46.  
  47. bitmap *b_p = (bitmap *)NULL;    /* global pointer to bitmap */
  48. unsigned int b_currx, b_curry;    /* the current coordinates */
  49. unsigned int b_xsize, b_ysize;    /* the size of the bitmap */
  50. unsigned int b_planes;            /* number of color planes */
  51. unsigned int b_psize;            /* size of each plane */
  52. unsigned int b_rastermode;        /* raster mode rotates -90deg */
  53. unsigned int b_linemask = 0xffff;    /* 16 bit mask for dotted lines */
  54. unsigned int b_value = 1;        /* colour of lines */
  55. unsigned int b_hchar;            /* width of characters */
  56. unsigned int b_hbits;            /* actual bits in char horizontally */
  57. unsigned int b_vchar;            /* height of characters */
  58. unsigned int b_vbits;            /* actual bits in char vertically */
  59. unsigned int b_angle;            /* rotation of text */
  60. char_box b_font[FNT_CHARS];        /* the current font */
  61. unsigned int b_pattern[] = {0xffff, 0x1111,
  62.     0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f};
  63. int b_maskcount = 0;
  64. unsigned int b_lastx, b_lasty;    /* last pixel set - used by b_line */
  65.  
  66. #define IN(i,size)  ((unsigned)i < (unsigned)size)
  67.  
  68. /* 5x9 font, bottom row first, left pixel in lsb */
  69. char_row fnt5x9[FNT_CHARS][FNT5X9_VBITS] = {
  70.   /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000},
  71.   /*!*/  {000000,000000,0x0004,000000,0x0004,0x0004,0x0004,0x0004,0x0004},
  72.   /*"*/  {000000,000000,000000,000000,000000,000000,0x000a,0x000a,0x000a},
  73.   /*#*/  {000000,000000,0x000a,0x000a,0x001f,0x000a,0x001f,0x000a,0x000a},
  74.   /*$*/  {000000,000000,0x0004,0x000f,0x0014,0x000e,0x0005,0x001e,0x0004},
  75.   /*%*/  {000000,000000,0x0018,0x0019,0x0002,0x0004,0x0008,0x0013,0x0003},
  76.   /*&*/  {000000,000000,0x0016,0x0009,0x0015,0x0002,0x0005,0x0005,0x0002},
  77.   /*'*/  {000000,000000,000000,000000,000000,0x0002,0x0004,0x0006,0x0006},
  78.   /*(*/  {000000,000000,0x0008,0x0004,0x0002,0x0002,0x0002,0x0004,0x0008},
  79.   /*)*/  {000000,000000,0x0002,0x0004,0x0008,0x0008,0x0008,0x0004,0x0002},
  80.   /***/  {000000,000000,0x0004,0x0015,0x000e,0x001f,0x000e,0x0015,0x0004},
  81.   /*+*/  {000000,000000,000000,0x0004,0x0004,0x001f,0x0004,0x0004,000000},
  82.   /*,*/  {000000,0x0002,0x0004,0x0006,0x0006,000000,000000,000000,000000},
  83.   /*-*/  {000000,000000,000000,000000,000000,0x001f,000000,000000,000000},
  84.   /*.*/  {000000,000000,0x0006,0x0006,000000,000000,000000,000000,000000},
  85.   /*-/-*/{000000,000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,000000},
  86.   /*0*/  {000000,000000,0x000e,0x0011,0x0013,0x0015,0x0019,0x0011,0x000e},
  87.   /*1*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0006,0x0004},
  88.   /*2*/  {000000,000000,0x001f,0x0001,0x0001,0x000e,0x0010,0x0011,0x000e},
  89.   /*3*/  {000000,000000,0x000e,0x0011,0x0010,0x000c,0x0010,0x0011,0x000e},
  90.   /*4*/  {000000,000000,0x0008,0x0008,0x001f,0x0009,0x000a,0x000c,0x0008},
  91.   /*5*/  {000000,000000,0x000e,0x0011,0x0010,0x0010,0x000f,0x0001,0x001f},
  92.   /*6*/  {000000,000000,0x000e,0x0011,0x0011,0x000f,0x0001,0x0002,0x000c},
  93.   /*7*/  {000000,000000,0x0001,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
  94.   /*8*/  {000000,000000,0x000e,0x0011,0x0011,0x000e,0x0011,0x0011,0x000e},
  95.   /*9*/  {000000,000000,0x0006,0x0008,0x0010,0x001e,0x0011,0x0011,0x000e},
  96.   /*:*/  {000000,000000,000000,0x0006,0x0006,000000,0x0006,0x0006,000000},
  97.   /*;*/  {000000,0x0001,0x0002,0x0006,0x0006,000000,0x0006,0x0006,000000},
  98.   /*<*/  {000000,000000,0x0008,0x0004,0x0002,0x0001,0x0002,0x0004,0x0008},
  99.   /*=*/  {000000,000000,000000,000000,0x001f,000000,0x001f,000000,000000},
  100.   /*>*/  {000000,000000,0x0002,0x0004,0x0008,0x0010,0x0008,0x0004,0x0002},
  101.   /*?*/  {000000,000000,0x0004,000000,0x0004,0x0008,0x0010,0x0011,0x000e},
  102.   /*@*/  {000000,000000,0x000e,0x0015,0x0015,0x0016,0x0010,0x0011,0x000e},
  103.   /*A*/  {000000,000000,0x0011,0x0011,0x001f,0x0011,0x0011,0x000a,0x0004},
  104.   /*B*/  {000000,000000,0x000f,0x0012,0x0012,0x000e,0x0012,0x0012,0x000f},
  105.   /*C*/  {000000,000000,0x000e,0x0011,0x0001,0x0001,0x0001,0x0011,0x000e},
  106.   /*D*/  {000000,000000,0x000f,0x0012,0x0012,0x0012,0x0012,0x0012,0x000f},
  107.   /*E*/  {000000,000000,0x001f,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
  108.   /*F*/  {000000,000000,0x0001,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
  109.   /*G*/  {000000,000000,0x001e,0x0011,0x0011,0x0019,0x0001,0x0001,0x001e},
  110.   /*H*/  {000000,000000,0x0011,0x0011,0x0011,0x001f,0x0011,0x0011,0x0011},
  111.   /*I*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0004,0x000e},
  112.   /*J*/  {000000,000000,0x000e,0x0011,0x0010,0x0010,0x0010,0x0010,0x0010},
  113.   /*K*/  {000000,000000,0x0011,0x0009,0x0005,0x0003,0x0005,0x0009,0x0011},
  114.   /*L*/  {000000,000000,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  115.   /*M*/  {000000,000000,0x0011,0x0011,0x0011,0x0015,0x0015,0x001b,0x0011},
  116.   /*N*/  {000000,000000,0x0011,0x0011,0x0011,0x0019,0x0015,0x0013,0x0011},
  117.   /*O*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x000e},
  118.   /*P*/  {000000,000000,0x0001,0x0001,0x0001,0x000f,0x0011,0x0011,0x000f},
  119.   /*Q*/  {000000,0x0018,0x000e,0x0015,0x0011,0x0011,0x0011,0x0011,0x000e},
  120.   /*R*/  {000000,000000,0x0011,0x0009,0x0005,0x000f,0x0011,0x0011,0x000f},
  121.   /*S*/  {000000,000000,0x000e,0x0011,0x0010,0x000e,0x0001,0x0011,0x000e},
  122.   /*T*/  {000000,000000,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x001f},
  123.   /*U*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x0011},
  124.   /*V*/  {000000,000000,0x0004,0x0004,0x000a,0x000a,0x0011,0x0011,0x0011},
  125.   /*W*/  {000000,000000,0x0011,0x001b,0x0015,0x0011,0x0011,0x0011,0x0011},
  126.   /*X*/  {000000,000000,0x0011,0x0011,0x000a,0x0004,0x000a,0x0011,0x0011},
  127.   /*Y*/  {000000,000000,0x0004,0x0004,0x0004,0x0004,0x000a,0x0011,0x0011},
  128.   /*Z*/  {000000,000000,0x001f,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
  129.   /*[*/  {000000,000000,0x000e,0x0002,0x0002,0x0002,0x0002,0x0002,0x000e},
  130.   /*\*/  {000000,000000,000000,0x0010,0x0008,0x0004,0x0002,0x0001,000000},
  131.   /*]*/  {000000,000000,0x000e,0x0008,0x0008,0x0008,0x0008,0x0008,0x000e},
  132.   /*^*/  {000000,000000,000000,000000,000000,000000,0x0011,0x000a,0x0004},
  133.   /*_*/  {000000,000000,0x001f,000000,000000,000000,000000,000000,000000},
  134.   /*`*/  {000000,000000,000000,000000,000000,0x0008,0x0004,0x000c,0x000c},
  135.   /*a*/  {000000,000000,0x001e,0x0011,0x001e,0x0010,0x000e,000000,000000},
  136.   /*b*/  {000000,000000,0x000d,0x0013,0x0011,0x0013,0x000d,0x0001,0x0001},
  137.   /*c*/  {000000,000000,0x000e,0x0011,0x0001,0x0011,0x000e,000000,000000},
  138.   /*d*/  {000000,000000,0x0016,0x0019,0x0011,0x0019,0x0016,0x0010,0x0010},
  139.   /*e*/  {000000,000000,0x000e,0x0001,0x001f,0x0011,0x000e,000000,000000},
  140.   /*f*/  {000000,000000,0x0004,0x0004,0x0004,0x000e,0x0004,0x0014,0x0008},
  141.   /*g*/  {0x000e,0x0011,0x0016,0x0019,0x0011,0x0019,0x0016,000000,000000},
  142.   /*h*/  {000000,000000,0x0011,0x0011,0x0011,0x0013,0x000d,0x0001,0x0001},
  143.   /*i*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0006,000000,0x0004},
  144.   /*j*/  {0x0006,0x0009,0x0008,0x0008,0x0008,0x0008,0x000c,000000,0x0008},
  145.   /*k*/  {000000,000000,0x0009,0x0005,0x0003,0x0005,0x0009,0x0001,0x0001},
  146.   /*l*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0004,0x0006},
  147.   /*m*/  {000000,000000,0x0015,0x0015,0x0015,0x0015,0x000b,000000,000000},
  148.   /*n*/  {000000,000000,0x0011,0x0011,0x0011,0x0013,0x000d,000000,000000},
  149.   /*o*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x000e,000000,000000},
  150.   /*p*/  {0x0001,0x0001,0x000d,0x0013,0x0011,0x0013,0x000d,000000,000000},
  151.   /*q*/  {0x0010,0x0010,0x0016,0x0019,0x0011,0x0019,0x0016,000000,000000},
  152.   /*r*/  {000000,000000,0x0001,0x0001,0x0001,0x0013,0x000d,000000,000000},
  153.   /*s*/  {000000,000000,0x000f,0x0010,0x000e,0x0001,0x001e,000000,000000},
  154.   /*t*/  {000000,000000,0x0008,0x0014,0x0004,0x0004,0x001f,0x0004,0x0004},
  155.   /*u*/  {000000,000000,0x0016,0x0019,0x0011,0x0011,0x0011,000000,000000},
  156.   /*v*/  {000000,000000,0x0004,0x000a,0x0011,0x0011,0x0011,000000,000000},
  157.   /*w*/  {000000,000000,0x000a,0x0015,0x0015,0x0011,0x0011,000000,000000},
  158.   /*x*/  {000000,000000,0x0011,0x000a,0x0004,0x000a,0x0011,000000,000000},
  159.   /*y*/  {0x000e,0x0010,0x001e,0x0011,0x0011,0x0011,0x0011,000000,000000},
  160.   /*z*/  {000000,000000,0x001f,0x0002,0x0004,0x0008,0x001f,000000,000000},
  161.   /*{*/  {000000,000000,0x0008,0x0004,0x0004,0x0002,0x0004,0x0004,0x0008},
  162.   /*|*/  {000000,000000,0x0004,0x0004,0x0004,000000,0x0004,0x0004,0x0004},
  163.   /*}*/  {000000,000000,0x0002,0x0004,0x0004,0x0008,0x0004,0x0004,0x0002},
  164.   /*~*/  {000000,000000,000000,000000,000000,000000,0x0008,0x0015,0x0002},
  165.   /*DEL*/{000000,000000,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f},
  166. };
  167.  
  168. /* 9x17 font, bottom row first, left pixel in lsb */
  169. char_row fnt9x17[FNT_CHARS][FNT9X17_VBITS] = {
  170.   /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  171.           000000,000000,000000,000000,000000,000000,000000,000000},
  172.   /*!*/  {000000,000000,000000,000000,0x0010,000000,000000,000000,0x0010,
  173.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010},
  174.   /*"*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  175.           000000,000000,000000,0x0044,0x0044,0x0044,0x0044,0x0044},
  176.   /*#*/  {000000,000000,000000,000000,0x0044,0x0044,0x0044,0x0044,0x01ff,
  177.           0x0044,0x0044,0x0044,0x01ff,0x0044,0x0044,0x0044,0x0044},
  178.   /*$*/  {000000,000000,000000,000000,0x0010,0x0010,0x007e,0x0091,0x0110,
  179.           0x0090,0x007c,0x0012,0x0011,0x0112,0x00fc,0x0010,0x0010},
  180.   /*%*/  {000000,000000,000000,000000,0x0080,0x0141,0x0081,0x0002,0x0004,
  181.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0102,0x0105,0x0002},
  182.   /*&*/  {000000,000000,000000,000000,0x011c,0x00a2,0x0041,0x00c1,0x0141,
  183.           0x0022,0x001c,0x0014,0x0022,0x0022,0x001c,000000,000000},
  184.   /*'*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  185.           000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010},
  186.   /*(*/  {000000,000000,000000,000000,0x0040,0x0020,0x0010,0x0008,0x0008,
  187.           0x0004,0x0004,0x0004,0x0008,0x0008,0x0010,0x0020,0x0040},
  188.   /*)*/  {000000,000000,000000,000000,0x0004,0x0008,0x0010,0x0020,0x0020,
  189.           0x0040,0x0040,0x0040,0x0020,0x0020,0x0010,0x0008,0x0004},
  190.   /***/  {000000,000000,000000,000000,0x0010,0x0010,0x0111,0x0092,0x0054,
  191.           0x0038,0x01ff,0x0038,0x0054,0x0092,0x0111,0x0010,0x0010},
  192.   /*+*/  {000000,000000,000000,000000,000000,000000,0x0010,0x0010,0x0010,
  193.           0x0010,0x01ff,0x0010,0x0010,0x0010,0x0010,000000,000000},
  194.   /*,*/  {000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010,000000,
  195.           000000,000000,000000,000000,000000,000000,000000,000000},
  196.   /*-*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  197.           000000,0x01ff,000000,000000,000000,000000,000000,000000},
  198.   /*.*/  {000000,000000,000000,000000,0x0010,0x0038,0x0010,000000,000000,
  199.           000000,000000,000000,000000,000000,000000,000000,000000},
  200.   /*-/-*/{000000,000000,000000,000000,000000,000000,0x0001,0x0002,0x0004,
  201.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,000000,000000},
  202.   /*0*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0103,0x0105,
  203.           0x0109,0x0111,0x0121,0x0141,0x0181,0x0101,0x0082,0x007c},
  204.   /*1*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  205.           0x0010,0x0010,0x0010,0x0010,0x0010,0x001c,0x0018,0x0010},
  206.   /*2*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0001,0x0001,0x0001,
  207.           0x0002,0x007c,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  208.   /*3*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  209.           0x0080,0x0078,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  210.   /*4*/  {000000,000000,000000,000000,0x0040,0x0040,0x0040,0x0040,0x0040,
  211.           0x01ff,0x0041,0x0042,0x0044,0x0048,0x0050,0x0060,0x0040},
  212.   /*5*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  213.           0x0100,0x0080,0x007f,0x0001,0x0001,0x0001,0x0001,0x01ff},
  214.   /*6*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  215.           0x0081,0x007f,0x0001,0x0001,0x0001,0x0002,0x0084,0x0078},
  216.   /*7*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0002,0x0004,
  217.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0100,0x01ff},
  218.   /*8*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  219.           0x0082,0x007c,0x0082,0x0101,0x0101,0x0101,0x0082,0x007c},
  220.   /*9*/  {000000,000000,000000,000000,0x001c,0x0022,0x0040,0x0080,0x0100,
  221.           0x0100,0x01fc,0x0102,0x0101,0x0101,0x0101,0x0082,0x007c},
  222.   /*:*/  {000000,000000,000000,000000,000000,000000,0x0010,0x0038,0x0010,
  223.           000000,000000,000000,0x0010,0x0038,0x0010,000000,000000},
  224.   /*;*/  {000000,000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010,
  225.           000000,000000,000000,0x0010,0x0038,0x0010,000000,000000},
  226.   /*<*/  {000000,000000,000000,000000,0x0040,0x0020,0x0010,0x0008,0x0004,
  227.           0x0002,0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040},
  228.   /*=*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x01ff,
  229.           000000,000000,000000,0x01ff,000000,000000,000000,000000},
  230.   /*>*/  {000000,000000,000000,000000,0x0004,0x0008,0x0010,0x0020,0x0040,
  231.           0x0080,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004},
  232.   /*?*/  {000000,000000,000000,0x0010,0x0038,0x0010,000000,0x0010,0x0010,
  233.           0x0020,0x0040,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  234.   /*@*/  {000000,000000,000000,000000,0x007c,0x0002,0x0001,0x01f9,0x0145,
  235.           0x0145,0x0145,0x0179,0x0101,0x0101,0x0101,0x0082,0x007c},
  236.   /*A*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x01ff,
  237.           0x0101,0x0082,0x0082,0x0044,0x0044,0x0028,0x0028,0x0010},
  238.   /*B*/  {000000,000000,000000,000000,0x007f,0x0084,0x0104,0x0104,0x0104,
  239.           0x0084,0x007c,0x0084,0x0104,0x0104,0x0104,0x0084,0x007f},
  240.   /*C*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0001,0x0001,
  241.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0101,0x0082,0x007c},
  242.   /*D*/  {000000,000000,000000,000000,0x007f,0x0084,0x0104,0x0104,0x0104,
  243.           0x0104,0x0104,0x0104,0x0104,0x0104,0x0104,0x0084,0x007f},
  244.   /*E*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0001,0x0001,0x0001,
  245.           0x0001,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x01ff},
  246.   /*F*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
  247.           0x0001,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x01ff},
  248.   /*G*/  {000000,000000,000000,000000,0x00fc,0x0102,0x0101,0x0101,0x0101,
  249.           0x0101,0x01c1,0x0001,0x0001,0x0001,0x0001,0x0102,0x00fc},
  250.   /*H*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  251.           0x0101,0x01ff,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  252.   /*I*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  253.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x007c},
  254.   /*J*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  255.           0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x0180},
  256.   /*K*/  {000000,000000,000000,000000,0x0101,0x0081,0x0041,0x0021,0x0011,
  257.           0x0009,0x0005,0x000b,0x0011,0x0021,0x0041,0x0081,0x0101},
  258.   /*L*/  {000000,000000,000000,000000,0x01ff,0x0101,0x0001,0x0001,0x0001,
  259.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  260.   /*M*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  261.           0x0101,0x0111,0x0111,0x0129,0x0145,0x0145,0x0183,0x0101},
  262.   /*N*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0181,0x0141,
  263.           0x0141,0x0121,0x0111,0x0109,0x0105,0x0105,0x0103,0x0101},
  264.   /*O*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  265.           0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0082,0x007c},
  266.   /*P*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
  267.           0x0001,0x007f,0x0081,0x0101,0x0101,0x0101,0x0081,0x007f},
  268.   /*Q*/  {000000,000000,0x0180,0x0040,0x007c,0x0092,0x0101,0x0101,0x0101,
  269.           0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0082,0x007c},
  270.   /*R*/  {000000,000000,000000,000000,0x0101,0x0081,0x0041,0x0021,0x0011,
  271.           0x0009,0x007f,0x0081,0x0101,0x0101,0x0101,0x0081,0x007f},
  272.   /*S*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
  273.           0x0080,0x007c,0x0002,0x0001,0x0001,0x0101,0x0082,0x007c},
  274.   /*T*/  {000000,000000,000000,000000,0x0038,0x0010,0x0010,0x0010,0x0010,
  275.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0111,0x01ff},
  276.   /*U*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  277.           0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  278.   /*V*/  {000000,000000,000000,000000,0x0010,0x0010,0x0028,0x0028,0x0044,
  279.           0x0044,0x0082,0x0082,0x0101,0x0101,0x0101,0x0101,0x0101},
  280.   /*W*/  {000000,000000,000000,000000,0x0101,0x0183,0x0145,0x0145,0x0129,
  281.           0x0111,0x0111,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  282.   /*X*/  {000000,000000,000000,000000,0x0101,0x0101,0x0082,0x0082,0x0044,
  283.           0x0028,0x0010,0x0028,0x0044,0x0082,0x0082,0x0101,0x0101},
  284.   /*Y*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
  285.           0x0010,0x0010,0x0028,0x0044,0x0082,0x0082,0x0101,0x0101},
  286.   /*Z*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0002,0x0002,0x0004,
  287.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0080,0x0100,0x01ff},
  288.   /*[*/  {000000,000000,000000,000000,0x007c,0x0004,0x0004,0x0004,0x0004,
  289.           0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x007c},
  290.   /*\*/  {000000,000000,000000,000000,000000,000000,0x0100,0x0080,0x0040,
  291.           0x0020,0x0010,0x0008,0x0004,0x0002,0x0001,000000,000000},
  292.   /*]*/  {000000,000000,000000,000000,0x007c,0x0040,0x0040,0x0040,0x0040,
  293.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x007c},
  294.   /*^*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  295.           000000,000000,000000,0x0101,0x0082,0x0044,0x0028,0x0010},
  296.   /*_*/  {000000,000000,000000,000000,0x01ff,000000,000000,000000,000000,
  297.           000000,000000,000000,000000,000000,000000,000000,000000},
  298.   /*`*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  299.           000000,000000,0x0020,0x0010,0x0008,0x000c,0x001c,0x0008},
  300.   /*a*/  {000000,000000,000000,000000,0x03fc,0x0102,0x0101,0x0102,0x01fc,
  301.           0x0100,0x0100,0x0080,0x007c,000000,000000,000000,000000},
  302.   /*b*/  {000000,000000,000000,000000,0x007d,0x0083,0x0101,0x0101,0x0101,
  303.           0x0101,0x0101,0x0083,0x007d,0x0001,0x0001,0x0001,0x0001},
  304.   /*c*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0001,0x0001,
  305.           0x0001,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  306.   /*d*/  {000000,000000,000000,000000,0x017c,0x0182,0x0101,0x0101,0x0101,
  307.           0x0101,0x0101,0x0182,0x017c,0x0100,0x0100,0x0100,0x0100},
  308.   /*e*/  {000000,000000,000000,000000,0x007c,0x0002,0x0001,0x0001,0x01ff,
  309.           0x0101,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  310.   /*f*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
  311.           0x0010,0x007c,0x0010,0x0010,0x0010,0x0110,0x00a0,0x0040},
  312.   /*g*/  {0x007c,0x0082,0x0101,0x0100,0x017c,0x0182,0x0101,0x0101,0x0101,
  313.           0x0101,0x0101,0x0182,0x017c,000000,000000,000000,000000},
  314.   /*h*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  315.           0x0103,0x0103,0x0085,0x0079,0x0001,0x0001,0x0001,0x0001},
  316.   /*i*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  317.           0x0010,0x0010,0x0018,000000,000000,0x0018,0x0018,000000},
  318.   /*j*/  {0x003c,0x0042,0x0081,0x0080,0x0080,0x0080,0x0080,0x0080,0x0080,
  319.           0x0080,0x0080,0x00c0,000000,000000,0x00c0,0x00c0,000000},
  320.   /*k*/  {000000,000000,000000,000000,0x0082,0x0042,0x0022,0x0012,0x000a,
  321.           0x0016,0x0022,0x0042,0x0002,0x0002,0x0002,0x0002,0x0002},
  322.   /*l*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
  323.           0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x001c},
  324.   /*m*/  {000000,000000,000000,000000,0x0111,0x0111,0x0111,0x0111,0x0111,
  325.           0x0111,0x0111,0x00ab,0x0045,000000,000000,000000,000000},
  326.   /*n*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
  327.           0x0101,0x0101,0x0083,0x007d,000000,000000,000000,000000},
  328.   /*o*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
  329.           0x0101,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  330.   /*p*/  {0x0001,0x0001,0x0001,0x0001,0x007d,0x0003,0x0081,0x0101,0x0101,
  331.           0x0101,0x0101,0x0083,0x007d,000000,000000,000000,000000},
  332.   /*q*/  {0x0100,0x0100,0x0100,0x0100,0x017c,0x0182,0x0101,0x0101,0x0101,
  333.           0x0101,0x0101,0x0182,0x017c,000000,000000,000000,000000},
  334.   /*r*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
  335.           0x0001,0x0103,0x0085,0x0079,000000,000000,000000,000000},
  336.   /*s*/  {000000,000000,000000,000000,0x007e,0x0081,0x0100,0x0080,0x007c,
  337.           0x0002,0x0001,0x0102,0x00fc,000000,000000,000000,000000},
  338.   /*t*/  {000000,000000,000000,000000,0x0040,0x00a0,0x0110,0x0010,0x0010,
  339.           0x0010,0x0010,0x0010,0x00fe,0x0010,0x0010,0x0010,0x0010},
  340.   /*u*/  {000000,000000,000000,000000,0x013c,0x0142,0x0181,0x0101,0x0101,
  341.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  342.   /*v*/  {000000,000000,000000,000000,0x0010,0x0028,0x0044,0x0082,0x0101,
  343.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  344.   /*w*/  {000000,000000,000000,000000,0x0044,0x00aa,0x0111,0x0111,0x0101,
  345.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  346.   /*x*/  {000000,000000,000000,000000,0x0101,0x0082,0x0044,0x0028,0x0010,
  347.           0x0028,0x0044,0x0082,0x0101,000000,000000,000000,000000},
  348.   /*y*/  {0x007c,0x0082,0x0101,0x0100,0x0100,0x01fc,0x0102,0x0101,0x0101,
  349.           0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  350.   /*z*/  {000000,000000,000000,000000,0x01ff,0x0002,0x0004,0x0008,0x0010,
  351.           0x0020,0x0040,0x0080,0x01ff,000000,000000,000000,000000},
  352.   /*{*/  {000000,000000,000000,000000,0x00c0,0x0020,0x0010,0x0010,0x0010,
  353.           0x0008,0x0004,0x0008,0x0010,0x0010,0x0010,0x0020,0x00c0},
  354.   /*|*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
  355.           000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010},
  356.   /*}*/  {000000,000000,000000,000000,0x0006,0x0008,0x0010,0x0010,0x0010,
  357.           0x0020,0x0040,0x0020,0x0010,0x0010,0x0010,0x0008,0x0006},
  358.   /*~*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  359.           000000,000000,000000,0x0040,0x00a0,0x0111,0x000a,0x0004},
  360.   /*DEL*/{000000,000000,000000,000000,0x0155,000000,0x0155,000000,0x0155,
  361.           000000,0x0155,000000,0x0155,000000,0x0155,000000,0x0155},
  362. };
  363.  
  364. /* 13x25 font, bottom row first, left pixel in lsb */
  365. char_row fnt13x25[FNT_CHARS][FNT13X25_VBITS] = {
  366.   /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  367.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  368.           000000,000000,000000,000000,000000,000000,000000},
  369.   /*!*/  {000000,000000,000000,000000,000000,0x00e0,0x00e0,0x00e0,000000,
  370.           000000,000000,0x0040,0x0040,0x0040,0x0040,0x0040,0x00e0,0x00e0,
  371.           0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x0040},
  372.   /*"*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  373.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  374.           0x0208,0x0208,0x0208,0x0208,0x0208,0x0208,0x0208},
  375.   /*#*/  {000000,000000,000000,000000,000000,000000,0x0208,0x0208,0x0208,
  376.           0x0208,0x0208,0x0208,0x1fff,0x0208,0x0208,0x0208,0x0208,0x0208,
  377.           0x1fff,0x0208,0x0208,0x0208,0x0208,0x0208,0x0208},
  378.   /*$*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  379.           0x03f8,0x0444,0x0842,0x0840,0x0840,0x0440,0x03f8,0x0044,0x0042,
  380.           0x0042,0x0842,0x0444,0x03f8,0x0040,0x0040,0x0040},
  381.   /*%*/  {000000,000000,000000,000000,000000,000000,0x0c00,0x1200,0x1201,
  382.           0x0c01,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  383.           0x0200,0x0400,0x0800,0x1006,0x1009,0x0009,0x0006},
  384.   /*&*/  {000000,000000,000000,000000,000000,000000,0x1078,0x1084,0x0902,
  385.           0x0601,0x0601,0x0901,0x1081,0x0042,0x0024,0x0018,0x0018,0x0024,
  386.           0x0042,0x0042,0x0042,0x0042,0x0024,0x0018,000000},
  387.   /*'*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  388.           000000,000000,000000,000000,000000,0x0001,0x0002,0x0004,0x0008,
  389.           0x0010,0x0030,0x0078,0x0078,0x0078,0x0030,000000},
  390.   /*(*/  {000000,000000,000000,000000,000000,000000,0x0080,0x0040,0x0020,
  391.           0x0020,0x0010,0x0008,0x0008,0x0004,0x0004,0x0004,0x0004,0x0004,
  392.           0x0008,0x0008,0x0010,0x0020,0x0020,0x0040,0x0080},
  393.   /*)*/  {000000,000000,000000,000000,000000,000000,0x0020,0x0040,0x0080,
  394.           0x0080,0x0100,0x0200,0x0200,0x0400,0x0400,0x0400,0x0400,0x0400,
  395.           0x0200,0x0200,0x0100,0x0080,0x0080,0x0040,0x0020},
  396.   /***/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  397.           0x1041,0x0842,0x0444,0x0248,0x0150,0x00e0,0x1fff,0x00e0,0x0150,
  398.           0x0248,0x0444,0x0842,0x1041,0x0040,0x0040,0x0040},
  399.   /*+*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  400.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x1fff,0x0040,0x0040,
  401.           0x0040,0x0040,0x0040,0x0040,000000,000000,000000},
  402.   /*,*/  {000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0030,0x0078,
  403.           0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
  404.           000000,000000,000000,000000,000000,000000,000000},
  405.   /*-*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  406.           000000,000000,000000,000000,000000,000000,0x1fff,000000,000000,
  407.           000000,000000,000000,000000,000000,000000,000000},
  408.   /*.*/  {000000,000000,000000,000000,000000,000000,000000,0x0038,0x007c,
  409.           0x007c,0x007c,0x0038,000000,000000,000000,000000,000000,000000,
  410.           000000,000000,000000,000000,000000,000000,000000},
  411.   /*-/-*/{000000,000000,000000,000000,000000,000000,000000,000000,0x0001,
  412.           0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  413.           0x0200,0x0400,0x0800,0x1000,0x1000,000000,000000},
  414.   /*0*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  415.           0x1001,0x1003,0x1005,0x1009,0x1011,0x1021,0x1041,0x1081,0x1101,
  416.           0x1201,0x1401,0x1801,0x1001,0x0802,0x0404,0x03f8},
  417.   /*1*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  418.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  419.           0x0040,0x0040,0x0040,0x0048,0x0070,0x0060,0x0040},
  420.   /*2*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
  421.           0x0001,0x0001,0x0001,0x0001,0x0002,0x03fc,0x0400,0x0800,0x1000,
  422.           0x1000,0x1000,0x1000,0x1001,0x0802,0x0404,0x03f8},
  423.   /*3*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  424.           0x1001,0x1000,0x1000,0x1000,0x0800,0x0400,0x03e0,0x0400,0x0800,
  425.           0x1000,0x1000,0x1000,0x1001,0x0802,0x0404,0x03f8},
  426.   /*4*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0200,0x0200,
  427.           0x0200,0x0200,0x0200,0x0200,0x1fff,0x0201,0x0201,0x0202,0x0204,
  428.           0x0208,0x0210,0x0220,0x0240,0x0280,0x0300,0x0200},
  429.   /*5*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  430.           0x1001,0x1000,0x1000,0x1000,0x1000,0x1000,0x0800,0x0400,0x03ff,
  431.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  432.   /*6*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  433.           0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff,0x0001,0x0001,
  434.           0x0001,0x0001,0x0002,0x0004,0x0808,0x0410,0x03e0},
  435.   /*7*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  436.           0x0002,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  437.           0x0200,0x0400,0x0800,0x0800,0x1000,0x1000,0x1fff},
  438.   /*8*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  439.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8,0x0404,0x0802,
  440.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  441.   /*9*/  {000000,000000,000000,000000,000000,000000,0x00f8,0x0104,0x0202,
  442.           0x0400,0x0800,0x1000,0x1000,0x1000,0x1000,0x1ff8,0x1004,0x1002,
  443.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  444.   /*:*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x0030,
  445.           0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
  446.           0x0030,0x0078,0x0078,0x0030,000000,000000,000000},
  447.   /*;*/  {000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0030,0x0078,
  448.           0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
  449.           0x0030,0x0078,0x0078,0x0030,000000,000000,000000},
  450.   /*<*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0100,0x0080,
  451.           0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001,0x0002,0x0004,
  452.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200},
  453.   /*=*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  454.           000000,000000,000000,0x1fff,000000,000000,000000,000000,000000,
  455.           0x1fff,000000,000000,000000,000000,000000,000000},
  456.   /*>*/  {000000,000000,000000,000000,000000,000000,0x0008,0x0010,0x0020,
  457.           0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,0x1000,0x0800,0x0400,
  458.           0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008},
  459.   /*?*/  {000000,000000,000000,000000,000000,0x0040,0x00e0,0x0040,000000,
  460.           000000,000000,0x0040,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,
  461.           0x1000,0x1000,0x1001,0x1001,0x0802,0x0404,0x03f8},
  462.   /*@*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0002,
  463.           0x0001,0x0001,0x0ee1,0x1111,0x1111,0x1111,0x1111,0x1111,0x12e1,
  464.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  465.   /*A*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  466.           0x1001,0x1001,0x1001,0x1fff,0x1001,0x1001,0x1001,0x1001,0x0802,
  467.           0x0802,0x0404,0x0208,0x0110,0x00a0,0x00a0,0x0040},
  468.   /*B*/  {000000,000000,000000,000000,000000,000000,0x03ff,0x0408,0x0808,
  469.           0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03f8,0x0408,0x0808,
  470.           0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03ff},
  471.   /*C*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  472.           0x1001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
  473.           0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,0x03f8},
  474.   /*D*/  {000000,000000,000000,000000,000000,000000,0x03ff,0x0408,0x0808,
  475.           0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,
  476.           0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03ff},
  477.   /*E*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
  478.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x007f,0x0001,0x0001,
  479.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  480.   /*F*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  481.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x007f,0x0001,0x0001,
  482.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  483.   /*G*/  {000000,000000,000000,000000,000000,000000,0x0ff8,0x1004,0x1002,
  484.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1f01,0x0001,0x0001,
  485.           0x0001,0x0001,0x0001,0x0001,0x0002,0x1004,0x0ff8},
  486.   /*H*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  487.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1fff,0x1001,0x1001,
  488.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  489.   /*I*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  490.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  491.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x03f8},
  492.   /*J*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  493.           0x1001,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
  494.           0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1e00},
  495.   /*K*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0801,0x0401,
  496.           0x0201,0x0101,0x0081,0x0041,0x0021,0x0011,0x000f,0x0009,0x0011,
  497.           0x0021,0x0041,0x0081,0x0101,0x0201,0x0401,0x0801},
  498.   /*L*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x1001,0x1001,
  499.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
  500.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  501.   /*M*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  502.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1041,0x1041,0x10a1,
  503.           0x10a1,0x1111,0x1209,0x1209,0x1405,0x1803,0x1001},
  504.   /*N*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  505.           0x1001,0x1801,0x1401,0x1201,0x1201,0x1101,0x1081,0x1041,0x1041,
  506.           0x1021,0x1011,0x1009,0x1009,0x1005,0x1003,0x1001},
  507.   /*O*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  508.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  509.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  510.   /*P*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  511.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x03ff,0x0401,0x0801,
  512.           0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff},
  513.   /*Q*/  {000000,000000,000000,000000,0x0c00,0x0200,0x03f8,0x0494,0x0862,
  514.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  515.           0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  516.   /*R*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0801,0x0401,
  517.           0x0201,0x0101,0x0081,0x0041,0x0021,0x0011,0x03ff,0x0401,0x0801,
  518.           0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff},
  519.   /*S*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  520.           0x1001,0x1000,0x1000,0x1000,0x0800,0x0400,0x03f8,0x0004,0x0002,
  521.           0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,0x03f8},
  522.   /*T*/  {000000,000000,000000,000000,000000,000000,0x00e0,0x0040,0x0040,
  523.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  524.           0x0040,0x0040,0x0040,0x0040,0x0040,0x1041,0x1fff},
  525.   /*U*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  526.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  527.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  528.   /*V*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x00a0,
  529.           0x00a0,0x0110,0x0110,0x0208,0x0208,0x0404,0x0404,0x0802,0x0802,
  530.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  531.   /*W*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1803,
  532.           0x1405,0x1405,0x1209,0x1209,0x1111,0x1111,0x10a1,0x1041,0x1001,
  533.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  534.   /*X*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  535.           0x0802,0x0802,0x0404,0x0208,0x0110,0x00a0,0x0040,0x00a0,0x0110,
  536.           0x0208,0x0404,0x0802,0x0802,0x1001,0x1001,0x1001},
  537.   /*Y*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  538.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x00a0,0x0110,0x0208,
  539.           0x0404,0x0802,0x0802,0x1001,0x1001,0x1001,0x1001},
  540.   /*Z*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
  541.           0x0002,0x0004,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
  542.           0x0200,0x0400,0x0400,0x0800,0x1000,0x1000,0x1fff},
  543.   /*[*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0008,0x0008,
  544.           0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,
  545.           0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x03f8},
  546.   /*\*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x1000,
  547.           0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,
  548.           0x0008,0x0004,0x0002,0x0001,0x0001,000000,000000},
  549.   /*]*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0200,0x0200,
  550.           0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,
  551.           0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x03f8},
  552.   /*^*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  553.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  554.           0x1001,0x0802,0x0404,0x0208,0x0110,0x00a0,0x0040},
  555.   /*_*/  {000000,000000,000000,000000,000000,000000,0x1fff,000000,000000,
  556.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  557.           000000,000000,000000,000000,000000,000000,000000},
  558.   /*`*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  559.           000000,000000,000000,000000,000000,0x0400,0x0200,0x0100,0x0080,
  560.           0x0040,0x0060,0x00f0,0x00f0,0x00f0,0x0060,000000},
  561.   /*a*/  {000000,000000,000000,000000,000000,000000,0x17f8,0x0804,0x0802,
  562.           0x0802,0x0802,0x0804,0x0ff8,0x0800,0x0800,0x0800,0x0800,0x0404,
  563.           0x03f8,000000,000000,000000,000000,000000,000000},
  564.   /*b*/  {000000,000000,000000,000000,000000,000000,0x03f9,0x0405,0x0803,
  565.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  566.           0x03f9,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  567.   /*c*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  568.           0x1001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,
  569.           0x03f8,000000,000000,000000,000000,000000,000000},
  570.   /*d*/  {000000,000000,000000,000000,000000,000000,0x13f8,0x1404,0x1802,
  571.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
  572.           0x13f8,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000},
  573.   /*e*/  {000000,000000,000000,000000,000000,000000,0x0ff8,0x0004,0x0002,
  574.           0x0001,0x0001,0x0001,0x1fff,0x1001,0x1001,0x1001,0x0802,0x0404,
  575.           0x03f8,000000,000000,000000,000000,000000,000000},
  576.   /*f*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  577.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x03f8,0x0040,0x0040,
  578.           0x0040,0x0040,0x0040,0x1040,0x0880,0x0500,0x0200},
  579.   /*g*/  {0x03f8,0x0404,0x0802,0x1001,0x1000,0x1000,0x13f8,0x1404,0x1802,
  580.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
  581.           0x13f8,000000,000000,000000,000000,000000,000000},
  582.   /*h*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  583.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  584.           0x03f9,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  585.   /*i*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  586.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0070,
  587.           000000,000000,000000,0x00e0,0x00e0,0x00e0,000000},
  588.   /*j*/  {0x00f0,0x0108,0x0204,0x0402,0x0400,0x0400,0x0400,0x0400,0x0400,
  589.           0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0700,
  590.           000000,000000,000000,0x0700,0x0700,0x0700,000000},
  591.   /*k*/  {000000,000000,000000,000000,000000,000000,0x0804,0x0404,0x0204,
  592.           0x0104,0x0084,0x0044,0x0024,0x0014,0x002c,0x0044,0x0084,0x0104,
  593.           0x0204,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004},
  594.   /*l*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
  595.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  596.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0070},
  597.   /*m*/  {000000,000000,000000,000000,000000,000000,0x1041,0x1041,0x1041,
  598.           0x1041,0x1041,0x1041,0x1041,0x1041,0x1041,0x1041,0x08a3,0x0515,
  599.           0x0209,000000,000000,000000,000000,000000,000000},
  600.   /*n*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
  601.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  602.           0x03f9,000000,000000,000000,000000,000000,000000},
  603.   /*o*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
  604.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,
  605.           0x03f8,000000,000000,000000,000000,000000,000000},
  606.   /*p*/  {0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x03f9,0x0405,0x0803,
  607.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
  608.           0x03f9,000000,000000,000000,000000,000000,000000},
  609.   /*q*/  {0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x13f8,0x1404,0x1802,
  610.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
  611.           0x13f8,000000,000000,000000,000000,000000,000000},
  612.   /*r*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
  613.           0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1001,0x0803,0x0405,
  614.           0x03f9,000000,000000,000000,000000,000000,000000},
  615.   /*s*/  {000000,000000,000000,000000,000000,000000,0x03fc,0x0402,0x0800,
  616.           0x0800,0x0800,0x0400,0x03f8,0x0004,0x0002,0x0002,0x0002,0x0804,
  617.           0x07f8,000000,000000,000000,000000,000000,000000},
  618.   /*t*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0500,0x0880,
  619.           0x1040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
  620.           0x07fc,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040},
  621.   /*u*/  {000000,000000,000000,000000,000000,000000,0x13f8,0x1404,0x1802,
  622.           0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  623.           0x1001,000000,000000,000000,000000,000000,000000},
  624.   /*v*/  {000000,000000,000000,000000,000000,000000,0x0040,0x00a0,0x0110,
  625.           0x0208,0x0404,0x0802,0x0802,0x1001,0x1001,0x1001,0x1001,0x1001,
  626.           0x1001,000000,000000,000000,000000,000000,000000},
  627.   /*w*/  {000000,000000,000000,000000,000000,000000,0x0208,0x0514,0x08a2,
  628.           0x08a2,0x1041,0x1041,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  629.           0x1001,000000,000000,000000,000000,000000,000000},
  630.   /*x*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0802,0x0404,
  631.           0x0208,0x0110,0x00a0,0x0040,0x00a0,0x0110,0x0208,0x0404,0x0802,
  632.           0x1001,000000,000000,000000,000000,000000,000000},
  633.   /*y*/  {0x03f8,0x0404,0x0802,0x1001,0x1000,0x1000,0x1000,0x1000,0x1ff8,
  634.           0x1004,0x1002,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
  635.           0x1001,000000,000000,000000,000000,000000,000000},
  636.   /*z*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0002,0x0004,
  637.           0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,
  638.           0x1fff,000000,000000,000000,000000,000000,000000},
  639.   /*{*/  {000000,000000,000000,000000,000000,000000,0x0600,0x0100,0x0080,
  640.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0020,0x0010,0x0020,0x0040,
  641.           0x0040,0x0040,0x0040,0x0040,0x0080,0x0100,0x0600},
  642.   /*|*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
  643.           0x0040,0x0040,0x0040,0x0040,000000,000000,000000,000000,000000,
  644.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040},
  645.   /*}*/  {000000,000000,000000,000000,000000,000000,0x000c,0x0010,0x0020,
  646.           0x0040,0x0040,0x0040,0x0040,0x0040,0x0080,0x0100,0x0080,0x0040,
  647.           0x0040,0x0040,0x0040,0x0040,0x0020,0x0010,0x000c},
  648.   /*~*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
  649.           000000,000000,000000,000000,000000,000000,000000,000000,000000,
  650.           0x0600,0x0900,0x1080,0x1041,0x0021,0x0012,0x000c},
  651.   /*DEL*/{000000,000000,000000,000000,000000,000000,0x1249,000000,000000,
  652.           0x1249,000000,000000,0x1249,000000,000000,0x1249,000000,000000,
  653.           0x1249,000000,000000,0x1249,000000,000000,0x1249},
  654. };
  655.  
  656. /*
  657. ** The plotting area is defined as a huge bitmap.
  658. ** The bitmap is stored in a dynamically allocated pixel array b_p
  659. **
  660. ** The bitmap is allocated (and initialized to zero) with
  661. ** b_makebitmap(xsize, ysize, planes)
  662. ** and freed with b_freebitmap()
  663. ** xsize and ysize will be rounded up to a multiple of 8.
  664. **
  665. ** Valid (int) coordinates range from zero to (xsize-1,ysize-1)
  666. **
  667. ** Plotting is done via b_move(x, y) and b_vector(x, y) functions,
  668. ** where the point (x,y) is the target to go from the current point
  669. ** To set the color use b_setvalue(value) where value is the value 
  670. ** (0 or 1 or a color number) to be stored in every pixel.
  671. ** To get dotted line styles, use b_setlinetype(linetype).
  672. **
  673. ** Internally all plotting goes through b_setpixel(x, y, value).
  674. */
  675.  
  676.  
  677. /*
  678. ** set pixel (x, y, value) to value value (this can be 1/0 or a color number).
  679. */
  680. void
  681. b_setpixel(x, y, value)
  682. unsigned int x, y, value;
  683. {
  684.   register unsigned int row;
  685.   register unsigned char mask;
  686.   int i;
  687.   if (b_rastermode) {
  688.     /* interchange so that new (x,y) is old (y,b_ysize-1-x) */
  689.     row = x;  /* temp storage */
  690.     x = y;
  691.     y = b_ysize-1-row;
  692.   }
  693.   if (IN(x, b_xsize) && IN(y, b_ysize))
  694.   {
  695.     row = y/8;
  696.     mask = 1<<(y%8);
  697.  
  698.     for (i=0; i<b_planes; i++) {
  699.         if (value&1)
  700.             *((*b_p)[row]+x) |= mask;
  701.         else
  702.             *((*b_p)[row]+x) &= ~mask;
  703.         row += b_psize;
  704.         value >>= 1;
  705.     }
  706.   }
  707. #ifdef BITMAPDEBUG
  708.   else
  709.   {
  710.     if (b_rastermode)
  711.       fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n", 
  712.         b_ysize-1-y, x, value);
  713.     else
  714.       fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n",
  715.         x, y, value);
  716.   }
  717. #endif
  718. }
  719.  
  720. /*
  721. ** get pixel (x,y) value----unused
  722. */
  723. /****************************
  724. unsigned int
  725. b_getpixel(x, y)
  726. unsigned int x, y;
  727. {
  728.   register unsigned int row;
  729.   register unsigned char mask;
  730.   register unsigned char value;
  731.   int i;
  732.  
  733.   if (b_rastermode) {
  734.     row = x;
  735.     x = y;
  736.     y = b_ysize-1-row;
  737.   }
  738.   if (IN(x, b_xsize) && IN(y, b_ysize))
  739.   {
  740.     row = y/8 + (b_planes-1)*b_psize;
  741.     mask = 1<<(y%8);
  742.  
  743.     for (i=0; i<b_planes; i++) {
  744.         if ( *((*b_p)[row]+x) & mask )
  745.             value |= 1;
  746.         row -= b_psize;
  747.         value <<= 1;
  748.     }
  749.     return(value);
  750.   }
  751.   else
  752.   {
  753. #ifdef BITMAPDEBUG
  754.     if (b_rastermode)
  755.       fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n",
  756.         b_ysize-1-y, x);
  757.     else
  758.       fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n", x, y);
  759. #endif
  760.     return(0);
  761.   }
  762. }
  763. ********************************/
  764.  
  765. /*
  766. ** allocate the bitmap
  767. */
  768. void
  769. b_makebitmap(x, y, planes)
  770. unsigned int x, y, planes;
  771. {
  772.   register unsigned j;
  773.   unsigned rows;
  774.  
  775.   x = 8 * (unsigned int)(x/8.0+0.9);    /* round up to multiple of 8 */
  776.   y = 8 * (unsigned int)(y/8.0+0.9);    /* round up to multiple of 8 */
  777.   b_psize = y/8;                    /* size of each plane */
  778.   rows = b_psize * planes;            /* total number of rows of 8 pixels high */
  779.   b_xsize = x; b_ysize = y;
  780.   b_currx = b_curry = 0;
  781.   b_planes = planes;
  782.   b_value = 1;
  783.   b_angle = 0;
  784.   b_rastermode = 0;
  785.   /* allocate row pointers */
  786.   b_p = (bitmap *)alloc( rows * sizeof(pixels *), "bitmap row buffer");
  787.   bzero(b_p, rows * sizeof(pixels *));
  788.   for (j = 0; j < rows; j++) {
  789.     /* allocate bitmap buffers */
  790.     (*b_p)[j] = (pixels *)alloc(x * sizeof(pixels),(char *)NULL);
  791.     if ((*b_p)[j] == (pixels *)NULL) {
  792.         b_freebitmap();  /* free what we have already allocated */
  793.         int_error("out of memory for bitmap buffer", NO_CARET);
  794.     }
  795.     bzero((*b_p)[j], x * sizeof(pixels));
  796.   }
  797. }
  798.   
  799. /*
  800. ** free the allocated bitmap
  801. */
  802. void
  803. b_freebitmap()
  804. {
  805.   int j;
  806.   unsigned rows;
  807.  
  808.   rows = b_psize * b_planes;   /* total number of rows of 8 pixels high */
  809.   for (j = 0; j < rows; j++)
  810.   {
  811.     (void) free((char *)(*b_p)[j]);
  812.   }
  813.   (void) free((char *)b_p);
  814.   b_p = (bitmap *)(NULL);
  815. }
  816.  
  817. /*
  818. ** set pixel at (x,y) with color b_value and dotted mask b_linemask.
  819. */
  820. void
  821. b_setmaskpixel(x,y,value)
  822. unsigned int x,y,value;
  823. {
  824.     /* dotted line generator */
  825.     if ((b_linemask>>b_maskcount)&(unsigned int)(1)) {
  826.         b_setpixel(x,y,value);
  827.     }
  828.     b_maskcount= (b_maskcount+1) % 16;
  829.     b_lastx= x;  /* last pixel set with mask */
  830.     b_lasty= y;
  831. }
  832.  
  833. /*
  834. ** draw a line from (x1,y1) to (x2,y2)
  835. ** with color b_value and dotted mask b_linemask.
  836. */
  837. void
  838. b_line(x1,y1,x2,y2)
  839. unsigned int x1,y1,x2,y2;
  840. {
  841. int runcount;
  842. int dx,dy;
  843. int xinc,yinc;
  844. unsigned int xplot,yplot;
  845.  
  846.     runcount=0;
  847.     dx = abs((int)(x1)-(int)(x2));
  848.     if (x2>x1)  xinc=  1;
  849.     if (x2==x1) xinc=  0;
  850.     if (x2<x1)  xinc= -1;
  851.     dy = abs((int)(y1)-(int)(y2));
  852.     if (y2>y1)  yinc=  1;
  853.     if (y2==y1) yinc=  0;
  854.     if (y2<y1)  yinc= -1;
  855.     xplot=x1;
  856.     yplot=y1;
  857.     if (dx>dy) {
  858.         /* iterate x */
  859.         if ( (b_linemask==0xffff) ||
  860.             ((xplot!=b_lastx) && (yplot!=b_lasty)) )
  861.             b_setmaskpixel(xplot,yplot,b_value);
  862.         while (xplot!=x2) {
  863.             xplot+=xinc;
  864.             runcount+=dy;
  865.             if (runcount>=(dx-runcount)) {
  866.                 yplot+=yinc;
  867.                 runcount-=dx;
  868.             }
  869.             b_setmaskpixel(xplot,yplot,b_value);
  870.         }
  871.     } else {
  872.         /* iterate y */
  873.         if ( (b_linemask==0xffff) ||
  874.             ((xplot!=b_lastx) && (yplot!=b_lasty)) )
  875.             b_setmaskpixel(xplot,yplot,b_value);
  876.         while (yplot!=y2) {
  877.             yplot+=yinc;
  878.             runcount+=dx;
  879.             if (runcount>=(dy-runcount)) {
  880.                 xplot+=xinc;
  881.                 runcount-=dy;
  882.             }
  883.             b_setmaskpixel(xplot,yplot,b_value);
  884.         }
  885.     }
  886. }
  887.  
  888. /*
  889. ** set character size
  890. */
  891. void
  892. b_charsize(size)
  893. unsigned int size;
  894. {
  895.     int j;
  896.     switch(size) {
  897.         case FNT5X9:
  898.             b_hchar = FNT5X9_HCHAR;
  899.             b_hbits = FNT5X9_HBITS;
  900.             b_vchar = FNT5X9_VCHAR;
  901.             b_vbits = FNT5X9_VBITS;
  902.             for (j = 0; j < FNT_CHARS; j++ )
  903.                 b_font[j] = &fnt5x9[j][0];
  904.             break;
  905.         case FNT9X17:
  906.             b_hchar = FNT9X17_HCHAR;
  907.             b_hbits = FNT9X17_HBITS;
  908.             b_vchar = FNT9X17_VCHAR;
  909.             b_vbits = FNT9X17_VBITS;
  910.             for (j = 0; j < FNT_CHARS; j++ )
  911.                 b_font[j] = &fnt9x17[j][0];
  912.             break;
  913.         case FNT13X25:
  914.             b_hchar = FNT13X25_HCHAR;
  915.             b_hbits = FNT13X25_HBITS;
  916.             b_vchar = FNT13X25_VCHAR;
  917.             b_vbits = FNT13X25_VBITS;
  918.             for (j = 0; j < FNT_CHARS; j++ )
  919.                 b_font[j] = &fnt13x25[j][0];
  920.             break;
  921.         default:
  922.             int_error("Unknown character size",NO_CARET);
  923.     }
  924. }
  925.  
  926.  
  927. /*
  928. ** put characater c at (x,y) rotated by angle with color b_value.
  929. */
  930. void
  931. b_putc(x,y,c,angle)
  932. unsigned int x,y;
  933. char c;
  934. unsigned int angle;
  935. {
  936.     unsigned int i, j, k;
  937.     char_row fc;
  938.  
  939.     j = c - ' ';
  940.     for ( i = 0; i < b_vbits; i++ ) {
  941.         fc = *( b_font[j] + i );
  942.         if ( c == '_' ) {    /* treat underline specially */
  943.             if ( fc  ) {    /* this this the underline row ? *?
  944.                 /* draw the under line for the full h_char width */
  945.                 for ( k = ( b_hbits - b_hchar )/2;
  946.                     k < ( b_hbits + b_hchar )/2; k++ ) {
  947.                     switch(angle) {
  948.                         case 0 : b_setpixel(x+k+1,y+i,b_value);
  949.                             break;
  950.                         case 1 : b_setpixel(x-i,y+k+1,b_value);
  951.                             break;
  952.                     }
  953.                 }
  954.             }
  955.         }
  956.         else {
  957.             /* draw character */
  958.             for ( k = 0; k < b_hbits; k++ ) {
  959.                 if ( ( fc >> k ) & 1 ) {
  960.                     switch(angle) {
  961.                         case 0 : b_setpixel(x+k+1,y+i,b_value);
  962.                             break;
  963.                         case 1 : b_setpixel(x-i,y+k+1,b_value);
  964.                             break;
  965.                     }
  966.                 }
  967.             }
  968.         }
  969.     }
  970. }
  971.  
  972.  
  973. /*
  974. ** set b_linemask to b_pattern[linetype]
  975. */
  976. int
  977. b_setlinetype(linetype)
  978. int linetype;
  979. {
  980.     if (linetype>=7)
  981.         linetype %= 7;
  982.     b_linemask = b_pattern[linetype+2];
  983.     b_maskcount=0;
  984. }
  985.  
  986. /*
  987. ** set b_value to value
  988. */
  989. void
  990. b_setvalue(value)
  991. unsigned int value;
  992. {
  993.     b_value = value;
  994. }
  995.  
  996. /*
  997. ** move to (x,y)
  998. */
  999. int
  1000. b_move(x, y)
  1001. unsigned int x, y;
  1002. {
  1003.   b_currx = x;
  1004.   b_curry = y;
  1005. }
  1006.  
  1007. /*
  1008. ** draw to (x,y) with color b_value
  1009. */
  1010. int
  1011. b_vector(x, y)
  1012. unsigned int x, y;
  1013. {
  1014.   b_line(b_currx, b_curry, x, y);
  1015.   b_currx = x;
  1016.   b_curry = y;
  1017. }
  1018.  
  1019.  
  1020. /*
  1021. ** put text str at (x,y) with color b_value and rotation b_angle
  1022. */
  1023. int
  1024. b_put_text(x,y,str)
  1025. unsigned int x, y;
  1026. char *str;
  1027. {
  1028.     if (b_angle == 1)
  1029.         x += b_vchar/2;
  1030.     else
  1031.         y -= b_vchar/2;
  1032.    switch (b_angle) {
  1033.       case 0:
  1034.      for (; *str; ++str, x += b_hchar)
  1035.         b_putc (x, y, *str, b_angle);
  1036.                     break;
  1037.       case 1:
  1038.      for (; *str; ++str, y += b_hchar)
  1039.         b_putc (x, y, *str, b_angle);
  1040.                     break;
  1041.     }
  1042. }
  1043.  
  1044.  
  1045. int
  1046. b_text_angle(ang)
  1047. int ang;
  1048. {
  1049.     b_angle=(unsigned int)ang;
  1050.     return TRUE;
  1051. }
  1052.