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 / dvi_fbi_hh / INCLUDES / dispchar.h next >
Text File  |  1993-05-06  |  6KB  |  181 lines

  1. /* -*-C-*- dispchar.h */
  2. /*-->dispchar*/
  3. /**********************************************************************/
  4. /****************************** dispchar ******************************/
  5. /**********************************************************************/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /* Modified for use with DVIDECW driver     (30.06.89)              */
  9. /*--------------------------------------------------------------------*/
  10.  
  11.  
  12. void
  13. dispchar(c)
  14. BYTE c;        /* character number in current font */
  15.  
  16. /***********************************************************************
  17.  
  18.    This procedure has the delicate  job of OR'ing the current  character
  19.    raster description into the bitmap,  where the character box  extends
  20.    horizontally from  (xcorner  ..  xcorner+wp-1)  and  vertically  from
  21.    (ycorner  ..   ycorner+hp-1).   The  lower  left  corner  coordinates
  22.    (xcorner, ycorner) are  related to  the current point  (xcp, ycp)  as
  23.    follows:
  24.  
  25.     <------wp------>
  26.     ^    ................
  27.     |    ................
  28.     |    ................
  29.     |    ................
  30.     |    ................
  31.     |    ................
  32.     |    ................
  33.     hp  ................
  34.     |    ................
  35.     |    ................
  36.     |    ................
  37.     |    .....o..........       <-- (xcp,ycp) at "o"
  38.     |    ................ ^
  39.     |    ................ |
  40.     |    ................ |--- (hp - yoffp - 1)
  41.     |    ................ |
  42.     v    +............... v     <-- (xcorner,ycorner) at "+"
  43.     <--->
  44.       |
  45.       |
  46.      xoffp
  47.  
  48.    The current PXL file format stores character rasters in 32-bit words,
  49.    with the rightmost portion of the  last word in each line beyond  the
  50.    edge of  the character  being all  0 bits.    For efficiency,  the  OR
  51.    operation is done a word  at a time, and  in general, each such  word
  52.    contributes to two words in the bitmap line.
  53.  
  54.          line            line           line
  55.    |.........word.........|.........word.........|.........word.........|
  56.  
  57.   32-bit chunks--> |.....chrast.....|.....chrast.....|.....chrast.....|
  58.  
  59.            |<---->|<------->|
  60.                |       |
  61.      bits_to_current---^       ^--- bits_to_next
  62.  
  63.    Thus, each  32-bit  chunk  will  be  right-shifted  (filling  vacated
  64.    positions at the left with 0 bits) leaving "bits_to_current" bits  at
  65.    the low end and then OR'd into the current word of the bitmap line.
  66.  
  67.    Since the C language  right-shift operator may  or may not  propagate
  68.    the sign bit  (which is usually  at the left),  a compile-time  flag,
  69.    ARITHRSHIFT, is necessary to include an extra AND operation to remove
  70.    them  when    the  right-shift   is  implemented   by  an   arithmetic
  71.    (sign-propagating), rather than a logical, shift.
  72.  
  73.    The 32-bit  chunk will  then  be left-shifted  (with 0  bits  filling
  74.    vacated positions on  the right) leaving  "bits_to_next" bits at  the
  75.    high end and OR'd into the next word of the bitmap line.
  76.  
  77.    When the host word  size exceeds 32 bits  (e.g. DEC-10 or -20  36-bit
  78.    word), the  first step  may in  fact require  a left  shift, and  the
  79.    second step is then not needed.   This is detected in the code  below
  80.    by "bits_to_next" being negative.
  81.  
  82. ***********************************************************************/
  83. {
  84.     register struct char_entry *tcharptr;
  85.     COORDINATE x,xcorner,ycorner;
  86.     UNSIGN16 ilimit;
  87.     register INT16 bits_to_next;
  88.     register UNSIGN16 i;
  89.     UNSIGN32 word32;
  90.     register UNSIGN32 *p;
  91.     register UNSIGN32 *raster_word;
  92.     register COORDINATE j;
  93.  
  94.     if ((c < FIRSTPXLCHAR) || (LASTPXLCHAR < c)) /* check character range */
  95.     return;
  96.  
  97.     tcharptr = &(fontptr->ch[c]);
  98.  
  99.     if (tcharptr->rasters == (UNSIGN32*)NULL)/* if rasters still on file */
  100.     loadchar(c);            /* go get them */
  101.  
  102.     if (tcharptr->rasters == (UNSIGN32*)NULL)
  103.     return;    /* character image must be empty */
  104.  
  105.     tcharptr->refcount++;        /* update reference count */
  106.     raster_word = tcharptr->rasters;    /* pointer to first raster word */
  107.  
  108.     xcorner = xcp - tcharptr->xoffp;
  109.  
  110. #if    DECWINDOWS
  111.     ycorner = ycp + (tcharptr->hp - tcharptr->yoffp - 1) - tcharptr->hp;
  112. #else
  113.     ycorner = ycp - (tcharptr->hp - tcharptr->yoffp - 1);
  114. #endif
  115.  
  116.     if (DBGOPT(DBG_CHAR_DUMP))
  117.     {
  118.     NEWLINE(stdout);
  119.         (void)printf(
  120.         "dispchar(): (xcp,ycp) = (%d,%d) (xcorner,ycorner) = (%d,%d)",
  121.         xcp,ycp,xcorner,ycorner);
  122.     NEWLINE(stdout);
  123.     (void)printf("            (wp,hp) = (%d,%d)  (xoffp,yoffp) = (%d,%d)",
  124.         tcharptr->wp,tcharptr->hp,tcharptr->xoffp,tcharptr->yoffp);
  125.     NEWLINE(stdout);
  126.     ilimit = (UNSIGN16)((tcharptr->wp + 31) >> 5);
  127.     for (j = tcharptr->hp; j > 0; --j)
  128.     {
  129.         for (i = 0; i < ilimit; ++i)
  130.             (void)printf(" %08lx",*raster_word++);
  131.         NEWLINE(stdout);
  132.     }
  133.     raster_word = tcharptr->rasters;
  134.     }
  135.  
  136. #if    DECWINDOWS                    /* loop over hp rasters from    */
  137.     for (j=1;j <= tcharptr->hp; ++j)    /* bottom to top        */
  138. #else
  139.     for (j=tcharptr->hp;j > 0;--j)     /* top to bottom        */
  140. #endif
  141.     {        
  142.     x = xcorner;            /* select horizontal position */
  143.     p = BITMAP(ycorner+j-1,x/HOST_WORD_SIZE); /* and find word on line */
  144.     ilimit = (UNSIGN16)((tcharptr->wp + 31) >> 5);
  145.     for (i = 0; i < ilimit; ++i)
  146.     {            /* loop over current line */
  147.         word32 = *raster_word++; /* get 32-bit portion of raster */
  148.         bits_to_next = (INT16)((x % HOST_WORD_SIZE) - HOST_WORD_SIZE + 32);
  149.  
  150. #if    (HOST_WORD_SIZE > 32)
  151.         if (bits_to_next < 0)   /* then must left shift character raster */
  152.         *p |= (word32 << (-bits_to_next));  /* and OR into line */
  153.         else
  154. #endif
  155.  
  156.         {
  157.         *p |=
  158. #if    (IBM_PC_LATTICE | IBM_PC_MICROSOFT | IBM_PC_WIZARD)
  159. /* these compilers correctly use a logical right shift for */
  160. /* unsigned values */
  161. #else
  162. #if    ARITHRSHIFT        /* arithmetic right shift propagates a sign */
  163.                 /* bit which must be cleared by this AND  */
  164.               rightones[bits_to_next] &
  165. #endif /* ARITHRSHIFT */
  166. #endif /* (IBM_PC_LATTICE | IBM_PC_MICROSOFT | IBM_PC_WIZARD) */
  167.  
  168.               (word32 >> bits_to_next);     /* OR into line */
  169.  
  170.         if (bits_to_next > 0)
  171.             *++p |= (word32 << (HOST_WORD_SIZE - bits_to_next));
  172.                 /* OR in any spill into next word */
  173.         else if (bits_to_next == 0)
  174.             ++p;    /* ended at word boundary, so start new one */
  175.         }
  176.         x += 32;        /* and update horizontal position */
  177.     }
  178.     }
  179. }
  180.  
  181.