1: /* $Header: tile.c,v 10.3 86/02/01 15:47:46 tony Rel $ */
   2: /* tile.c	Perform a raster operation involving a pattern
   3:  *
   4:  *	TileFill	Patterns a portion of the screen
   5:  *	DrawFilled	Draw a filled generalized line/polygon/combination
   6:  *
   7:  */
   8: 
   9: /****************************************************************************
  10:  *									    *
  11:  *  Copyright (c) 1983, 1984 by						    *
  12:  *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.		    *
  13:  *  All rights reserved.						    *
  14:  * 									    *
  15:  *  This software is furnished on an as-is basis and may be used and copied *
  16:  *  only with inclusion of the above copyright notice. This software or any *
  17:  *  other copies thereof may be provided or otherwise made available to     *
  18:  *  others only for non-commercial purposes.  No title to or ownership of   *
  19:  *  the software is hereby transferred.					    *
  20:  * 									    *
  21:  *  The information in this software is  subject to change without notice   *
  22:  *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
  23:  *  CORPORATION.							    *
  24:  * 									    *
  25:  *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
  26:  *  software on equipment which is not supplied by DIGITAL.		    *
  27:  * 									    *
  28:  *									    *
  29:  ****************************************************************************/
  30: 
  31: #include "vs100.h"
  32: 
  33: extern BitMap screen;
  34: extern int VSReloc;
  35: extern char SSMap[];
  36: 
  37: char *AllocateSpace(), *AllocateCopy(), *Xalloc();
  38: 
  39: TileFill (tile, xoff, yoff, xymask, dstx, dsty, width, height,
  40:       clips, clipcount, func, zmask)
  41:     register PIXMAP *tile;
  42:     register BITMAP *xymask;
  43:     int xoff, yoff, dstx, dsty, width, height, zmask;
  44:     register int func;
  45:     CLIP *clips;
  46: {
  47:     register CopyAreaPacket *cap;
  48: #define h ((PacketHeader *) cap->cap_head)
  49: #define pat ((Halftone *) cap->cap_source.pattern)
  50: #define mask ((SubBitmap *) cap->cap_sourceMask)
  51: #define size ((Extent *) cap->cap_maskSize)
  52: #define destOff ((Point *) cap->cap_destOffset)
  53: #define clip ((RectangleList *) cap->cap_clipping.rectList)
  54: 
  55:     if (!(zmask & 1)) {
  56:         DeallocateSpace ();
  57:         return;
  58:     }
  59: #ifdef HTCROCK
  60:     cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket) + 32);
  61: #else
  62:     cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket));
  63: #endif
  64:     if (cap == NULL) return;
  65: 
  66:     func = SSMap[func | (tile->kind & 0x10)];
  67:     h->ph_copyMod.m_source = tile->kind;
  68:     h->ph_copyMod.m_mask = xymask ? 1 : 0;
  69:     h->ph_copyMod.m_map = MAPTYPE(func);
  70:     h->ph_opcode = COPY_AREA;
  71:     *(long *) h->ph_next = NULL;
  72: 
  73:     if (tile->kind == 0)
  74:         cap->cap_source.const = (int) tile->data;
  75:     else {
  76: #ifdef HTCROCK
  77:         if ((xoff|yoff) & 0xf) {
  78:             *(caddr_t *) pat->ht_address = (caddr_t) cap +
  79:                            sizeof (CopyAreaPacket) +
  80:                            VSReloc;
  81:             Align_Halftone (TDATA(tile)->data,
  82:                     (short *) ((caddr_t) cap + sizeof (CopyAreaPacket)),
  83:                     xoff, yoff);
  84:         } else
  85:             *(caddr_t *) pat->ht_address =
  86:                     BDATA(TDATA(tile)->bitmap)->vsPtr;
  87:         pat->ht_x = pat->ht_y = 0;
  88: #else
  89:         *(caddr_t *) pat->ht_address = BDATA(PDATA(tile))->vsPtr;
  90:         pat->ht_x = xoff;
  91:         pat->ht_y = yoff;
  92: #endif
  93:         pat->ht_height = pat->ht_width = 16;
  94:         pat->ht_bitsPerPixel = 1;
  95:     }
  96: 
  97:     if (xymask) {
  98:         *(caddr_t *) mask->sb_address = BDATA(xymask)->vsPtr;
  99:         mask->sb_height = xymask->height;
 100:         mask->sb_width = xymask->width;
 101:         mask->sb_bitsPerPixel = 1;
 102:         mask->sb_x = mask->sb_y = 0;
 103:     }
 104:     size->e_height = height;
 105:     size->e_width = width;
 106: 
 107:     *(BitMap *) cap->cap_destImage = screen;
 108:     destOff->p_x = dstx;
 109:     destOff->p_y = dsty;
 110: 
 111:     *(short *) cap->cap_map.literal = MAPLIT(func);
 112: 
 113:     if (clipcount == 1) {
 114:         h->ph_copyMod.m_clipping = 1;
 115:         *(CLIP *) cap->cap_clipping.litRect = *clips;
 116:     } else {
 117:         h->ph_copyMod.m_clipping = 2;
 118:         *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
 119:         clip->r_count = clipcount;
 120:     }
 121: 
 122:     WritePacket ((caddr_t) cap);
 123: #undef h
 124: #undef pat
 125: #undef mask
 126: #undef size
 127: #undef destOff
 128: #undef clip
 129: }
 130: 
 131: DrawFilled (verts, vertcount, xbase, ybase, srcpix, tile, xoff, yoff,
 132:         clips, clipcount, func, zmask)
 133:     Vertex *verts;
 134:     register PIXMAP *tile;
 135:     int vertcount, xbase, ybase, srcpix, xoff, yoff, clipcount, zmask;
 136:     register int func;
 137:     CLIP *clips;
 138: {
 139:     register FillAreaPacket *fap;
 140:     char *boxes = NULL;
 141:     Vertex *segs;
 142: #define h ((PacketHeader *) fap->fap_head)
 143: #define pat ((Halftone *) fap->fap_source.pattern)
 144: #define destOff ((Point *) fap->fap_destOffset)
 145: #define path ((SegmentList *) fap->fap_path)
 146: 
 147:     if (!(zmask & 1)) {
 148:         DeallocateSpace ();
 149:         return;
 150:     }
 151:     if (clipcount > 1) {
 152:         boxes = Xalloc (sizeof (CLIP) * clipcount);
 153:         bcopy ((caddr_t) clips, boxes, sizeof (CLIP) * clipcount);
 154:         clips = (CLIP *) boxes;
 155:         DeallocateSpace ();
 156:     }
 157: 
 158:     if (tile && (tile->kind & 0x10))
 159:         func |= 0x10;
 160:     func = SSMap[func];
 161:     while (--clipcount >= 0) {
 162: 
 163: #ifdef HTCROCK
 164:     fap = (FillAreaPacket *) AllocateSpace (sizeof (FillAreaPacket) + 32);
 165: #else
 166:     fap = (FillAreaPacket *) AllocateSpace (sizeof (FillAreaPacket));
 167: #endif
 168:     if (fap == NULL ||
 169:         (segs = (Vertex *) AllocateCopy ((caddr_t) verts, vertcount * sizeof (Vertex))) == NULL)
 170:         break;
 171: 
 172:     if (tile)
 173:         h->ph_fillMod.m_source = tile->kind;
 174:     else
 175:         h->ph_fillMod.m_source = 0;
 176:     h->ph_fillMod.m_map = MAPTYPE(func);
 177:     h->ph_opcode = FILL_AREA;
 178:     *(long *) h->ph_next = NULL;
 179: 
 180:     if (tile == NULL)
 181:         fap->fap_source.const = srcpix & 1;
 182:     else if (tile->kind == 0)
 183:         fap->fap_source.const = (int) tile->data;
 184:     else {
 185: #ifdef HTCROCK
 186:         if ((xoff|yoff) & 0xf) {
 187:             *(caddr_t *) pat->ht_address = (caddr_t) fap +
 188:                            sizeof (FillAreaPacket) +
 189:                            VSReloc;
 190:             Align_Halftone (TDATA(tile)->data,
 191:                     (short *) ((caddr_t) fap + sizeof (FillAreaPacket)),
 192:                     xoff, yoff);
 193:         } else
 194:             *(caddr_t *) pat->ht_address =
 195:                     BDATA(TDATA(tile)->bitmap)->vsPtr;
 196:         pat->ht_x = pat->ht_y = 0;
 197: #else
 198:         *(caddr_t *) pat->ht_address = BDATA(PDATA(tile))->vsPtr;
 199:         pat->ht_x = xoff;
 200:         pat->ht_y = yoff;
 201: #endif
 202:         pat->ht_height = pat->ht_width = 16;
 203:         pat->ht_bitsPerPixel = 1;
 204:     }
 205: 
 206:     *(BitMap *) fap->fap_destImage = screen;
 207:     destOff->p_x = xbase;
 208:     destOff->p_y = ybase;
 209: 
 210:     *(short *) fap->fap_map.literal = MAPLIT(func);
 211: 
 212:     h->ph_fillMod.m_clipping = 1;
 213:     *(CLIP *) fap->fap_clippingRec = *clips;
 214:     clips++;
 215: 
 216:     *(caddr_t *) path->seg_first = (caddr_t) segs + VSReloc;
 217:     path->seg_count = vertcount;
 218: 
 219:     WritePacket ((caddr_t) fap);
 220:     }
 221: 
 222:     if (boxes)
 223:         free (boxes);
 224: #undef h
 225: #undef pat
 226: #undef destOff
 227: #undef path
 228: }
 229: 
 230: #ifdef HTCROCK
 231: Align_Halftone (src, dst, xoff, yoff)
 232:     register short *src, *dst;
 233:     register int xoff, yoff;
 234: {
 235:     register int i;
 236:     int shift, mask;
 237: 
 238:     xoff &= 0xf;
 239:     yoff = (16 - (yoff & 0xf)) & 0xf;
 240:     shift = (16 - xoff) & 0xf;
 241:     mask = (1 << xoff) - 1;
 242:     for (i = 0; i < 16; i++) {
 243:         dst[i] = (src[yoff] << xoff) | ((src[yoff] >> shift) & mask);
 244:         yoff++;
 245:         yoff &= 0xf;
 246:     }
 247: }
 248: #endif

Defined functions

Align_Halftone defined in line 231; used 2 times
DrawFilled defined in line 131; never used
TileFill defined in line 39; never used

Defined macros

clip defined in line 53; used 3 times
destOff defined in line 144; used 6 times
h defined in line 142; used 15 times
mask defined in line 50; used 10 times
pat defined in line 143; used 22 times
path defined in line 145; used 3 times
size defined in line 51; used 3 times
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1277
Valid CSS Valid XHTML 1.0 Strict