home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume14 / cat2deskjet / part01 / bm.c next >
Encoding:
C/C++ Source or Header  |  1990-08-30  |  2.4 KB  |  95 lines

  1. /*
  2.  *  bm.c -- byte tranfer routine, used by the lcat program
  3.  *  Copyright (C) 1990 Vassilis Prevelakis
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation and included with this distribution in the
  8.  *  file named LICENSE.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  Bugs fixes, comments etc. to:
  20.  *       Vasilis Prevelakis
  21.  *       Centre Universitaire d'Informatique (CUI)
  22.  *       12 Rue du Lac, Geneva, Switzerland CH-1207
  23.  *  email: vp@cui.unige.ch
  24.  *  uucp:  ...!mcsun!cui!vp
  25.  */
  26.  
  27. #ifndef UNIX
  28. #pragma inline
  29. #endif
  30. #define LCAT
  31. #include "lcat.h"
  32.  
  33. u_char raster[NLINES][RASTWIDTH];
  34.  
  35. /*
  36.  * bit_move -- move a number of bytes aligned on a byte boundary
  37.  * to a destination that is defined by a byte address plus
  38.  * a bit offset.
  39.  *
  40.  * Note that we are ORing source with destination because the character
  41.  * cells may have a partial overlap (called overhang in tp jargon).
  42.  *
  43.  * Also the #%$#% CAT is printing in both directions so we cannot
  44.  * sure whether the previous character is to our left or to our right.
  45.  *
  46.  * Anyway we can be sure that when we start a new line the raster
  47.  * is cleared to zeros (the printing routine clears the raster
  48.  * as its sending the bytes to the printer.
  49.  */
  50. bit_move(dst_addr, bit, src_addr, nbytes)
  51.  
  52. u_char huge* dst_addr, huge* src_addr;
  53. int bit, nbytes;
  54. {
  55.     u_char a, b;
  56.     int i;
  57.  
  58.     if (bit == 0)
  59.     {
  60.         for(i = 0; i < nbytes; i++)
  61.             *dst_addr++ |= *src_addr++;
  62.         /*    memcpy(dst_addr, src_addr, nbytes);    */
  63.         return;
  64.     }
  65.     bit = 8-bit;
  66.     /*    *dst_addr &= (0xff << bit);    */
  67.     for (i = 0; i < nbytes; i++)
  68.     {
  69. #ifdef USE_C
  70.     /*
  71.      * this is the C version of the assembly code below.
  72.      * note that I haven't tested this!
  73.      */
  74.     register unsigned short a;
  75.  
  76.     a = (*src_addr++) << bit;
  77.     *dst_addr++ |= ((a>>8) & 0xff);
  78.     *dst_addr |= (a & 0xff);
  79. #else
  80.         b = *dst_addr;
  81.         a = *src_addr++;
  82.         _BH = b;
  83.         _AL = a;
  84.         _AH = 0;
  85.         _CL = bit;
  86.         asm shl ax, cl;
  87.         asm or    ah, bh;
  88.         a = _AH;
  89.         b = _AL;
  90.         *dst_addr++ = a;
  91.         *dst_addr |= b;
  92. #endif
  93.     }
  94. }
  95.