home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / DVI_MGR / dvimgr_s.lzh / dvimgr / prxbmap.h < prev    next >
Text File  |  1993-08-06  |  4KB  |  133 lines

  1. /* -*-C-*- prxbmap.h */
  2. /*-->prxbmap*/
  3. /**********************************************************************/
  4. /****************************** prxbmap *******************************/
  5. /**********************************************************************/
  6.  
  7. void
  8. prxbmap()
  9.  
  10. {
  11.     register UNSIGN32 *p;
  12.     register INT16 i,j,k,ybottom,ytop;
  13.  
  14.     /* The Printronix encodes 6 horizontal bits in a single ASCII */
  15.     /* character biased by 64 to make it printable, but requires that */
  16.     /* the bits be reversed.  The following table is indexed by a */
  17.     /* 6-bit pattern (0..63) and was produced automatically by an */
  18.     /* EMACS TECO macro */
  19.     /*  raster       code as */
  20.     /*  123456 -->  654321 */
  21.     static int remap[] =
  22.     {   /* 1000000 --> 1000000 */
  23.     64,
  24.     /* 1000001 --> 1100000 */  96,
  25.     /* 1000010 --> 1010000 */  80,
  26.     /* 1000011 --> 1110000 */  112,
  27.     /* 1000100 --> 1001000 */  72,
  28.     /* 1000101 --> 1101000 */  104,
  29.     /* 1000110 --> 1011000 */  88,
  30.     /* 1000111 --> 1111000 */  120,
  31.     /* 1001000 --> 1000100 */  68,
  32.     /* 1001001 --> 1100100 */  100,
  33.     /* 1001010 --> 1010100 */  84,
  34.     /* 1001011 --> 1110100 */  116,
  35.     /* 1001100 --> 1001100 */  76,
  36.     /* 1001101 --> 1101100 */  108,
  37.     /* 1001110 --> 1011100 */  92,
  38.     /* 1001111 --> 1111100 */  124,
  39.     /* 1010000 --> 1000010 */  66,
  40.     /* 1010001 --> 1100010 */  98,
  41.     /* 1010010 --> 1010010 */  82,
  42.     /* 1010011 --> 1110010 */  114,
  43.     /* 1010100 --> 1001010 */  74,
  44.     /* 1010101 --> 1101010 */  106,
  45.     /* 1010110 --> 1011010 */  90,
  46.     /* 1010111 --> 1111010 */  122,
  47.     /* 1011000 --> 1000110 */  70,
  48.     /* 1011001 --> 1100110 */  102,
  49.     /* 1011010 --> 1010110 */  86,
  50.     /* 1011011 --> 1110110 */  118,
  51.     /* 1011100 --> 1001110 */  78,
  52.     /* 1011101 --> 1101110 */  110,
  53.     /* 1011110 --> 1011110 */  94,
  54.     /* 1011111 --> 1111110 */  126,
  55.     /* 1100000 --> 1000001 */  65,
  56.     /* 1100001 --> 1100001 */  97,
  57.     /* 1100010 --> 1010001 */  81,
  58.     /* 1100011 --> 1110001 */  113,
  59.     /* 1100100 --> 1001001 */  73,
  60.     /* 1100101 --> 1101001 */  105,
  61.     /* 1100110 --> 1011001 */  89,
  62.     /* 1100111 --> 1111001 */  121,
  63.     /* 1101000 --> 1000101 */  69,
  64.     /* 1101001 --> 1100101 */  101,
  65.     /* 1101010 --> 1010101 */  85,
  66.     /* 1101011 --> 1110101 */  117,
  67.     /* 1101100 --> 1001101 */  77,
  68.     /* 1101101 --> 1101101 */  109,
  69.     /* 1101110 --> 1011101 */  93,
  70.     /* 1101111 --> 1111101 */  125,
  71.     /* 1110000 --> 1000011 */  67,
  72.     /* 1110001 --> 1100011 */  99,
  73.     /* 1110010 --> 1010011 */  83,
  74.     /* 1110011 --> 1110011 */  115,
  75.     /* 1110100 --> 1001011 */  75,
  76.     /* 1110101 --> 1101011 */  107,
  77.     /* 1110110 --> 1011011 */  91,
  78.     /* 1110111 --> 1111011 */  123,
  79.     /* 1111000 --> 1000111 */  71,
  80.     /* 1111001 --> 1100111 */  103,
  81.     /* 1111010 --> 1010111 */  87,
  82.     /* 1111011 --> 1110111 */  119,
  83.     /* 1111100 --> 1001111 */  79,
  84.     /* 1111101 --> 1101111 */  111,
  85.     /* 1111110 --> 1011111 */  95,
  86.     /* 1111111 --> 1111111 */  127
  87.     };
  88.  
  89.     ytop = YBIT-1;
  90.  
  91.     k = -1;        /* find bottom non-zero raster */
  92.     for (j = 0; (j < ytop) && (k < 0); ++j) /* loop over raster lines */
  93.     {
  94.     p = BITMAP(j,XBIT-1);
  95.     for (k = XBIT - 1; ((k >= 0) && (*p == 0)); --k)
  96.         --p;        /* trim white space */
  97.     }
  98.     ybottom = MAX(0,j-1);
  99.  
  100.     putchar('\f');    /* start new page with FF */
  101.     for (j = (INT16)(topmargin*((float)YDPI)); j > 0; --j)
  102.     {                /* supply top margin spacing */
  103.     putchar('\005');    /* Printronix graphics prefix */
  104.     NEWLINE(stdout);
  105.     }
  106.     for (j = ytop; (j >= ybottom) ; --j)    /* loop over raster lines */
  107.     {
  108.     p = BITMAP(j,XBIT-1);
  109.     for (k = XBIT - 1; ((k >= 0) && (*p == 0)); --k)
  110.         --p;        /* trim white space */
  111.     putchar('\005');    /* Printronix graphics prefix */
  112.  
  113.     for (i = (5 + (INT16)(leftmargin*((float)XDPI)))/6;
  114.         (i > 0) && (k >= 0); --i)
  115.         putchar('\100');/* left margin spacing if line not empty */
  116.  
  117.     p = BITMAP(j,0);    /* the j-th raster line */
  118.  
  119.     for (i = 0; i <= k; ++i)/* loop over trimmed raster */
  120.     { /* use machine-specific coding here for efficiency */
  121.         putchar(remap[((*p) >> 30) & 077]);
  122.         putchar(remap[((*p) >> 24) & 077]);
  123.         putchar(remap[((*p) >> 18) & 077]);
  124.         putchar(remap[((*p) >> 12) & 077]);
  125.         putchar(remap[((*p) >>  6) & 077]);
  126.         putchar(remap[((*p)      ) & 077]);
  127.         ++p;
  128.     }
  129.     NEWLINE(stdout);
  130.     }
  131.     (void)fflush(stdout);
  132. }
  133.