Make hostlib test build again.
[AROS.git] / rom / graphics / bltpattern.c
blob21042bb797f5d5dd06092a8888961e52f296764d
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <proto/graphics.h>
11 #include <proto/oop.h>
13 #include "graphics_intern.h"
14 #include "gfxfuncsupport.h"
16 /****************************************************************************************/
18 struct bp_render_data
20 HIDDT_PixelLUT pixlut;
21 UBYTE *pattern;
22 UBYTE *mask;
23 ULONG maskmodulo;
24 WORD patternheight;
25 WORD patterndepth;
26 WORD renderx1;
27 WORD rendery1;
28 UBYTE invertpattern;
31 static ULONG bltpattern_render(APTR bpr_data, WORD srcx, WORD srcy,
32 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
33 struct Rectangle *rect, struct GfxBase *GfxBase)
35 struct bp_render_data *bprd = bpr_data;
36 WORD width = rect->MaxX - rect->MinX + 1;
37 WORD height = rect->MaxY - rect->MinY + 1;
38 UBYTE *mask = bprd->mask + bprd->maskmodulo * srcy;
39 WORD patsrcx = (srcx + bprd->renderx1) % 16;
40 WORD patsrcy = (srcy + bprd->rendery1) % bprd->patternheight;
42 if (patsrcx < 0)
43 patsrcx += 16;
44 if (patsrcy < 0)
45 patsrcy += bprd->patternheight;
47 HIDD_BM_PutPattern(dstbm_obj, dst_gc, bprd->pattern,
48 patsrcx, patsrcy, bprd->patternheight, bprd->patterndepth,
49 &bprd->pixlut, bprd->invertpattern, mask, bprd->maskmodulo,
50 srcx, rect->MinX, rect->MinY, width, height);
52 return width * height;
55 /*****************************************************************************
57 NAME */
58 #include <clib/graphics_protos.h>
60 AROS_LH7(void, BltPattern,
62 /* SYNOPSIS */
63 AROS_LHA(struct RastPort *, rp, A1),
64 AROS_LHA(PLANEPTR , mask, A0),
65 AROS_LHA(WORD , xMin, D0),
66 AROS_LHA(WORD , yMin, D1),
67 AROS_LHA(WORD , xMax, D2),
68 AROS_LHA(WORD , yMax, D3),
69 AROS_LHA(ULONG , byteCnt, D4),
71 /* LOCATION */
72 struct GfxBase *, GfxBase, 52, Graphics)
74 /* FUNCTION
75 Blit using drawmode, areafill pattern and mask.
77 INPUTS
78 rp - destination RastPort for blit.
79 mask - Mask bitplane. Set this to NULL for a rectangle.
80 xMin, yMin - upper left corner.
81 xMax, yMax - lower right corner.
82 byteCnt - BytesPerRow for mask.
84 RESULT
86 NOTES
88 EXAMPLE
90 BUGS
92 SEE ALSO
94 INTERNALS
96 HISTORY
97 27-11-96 digulla automatically created from
98 graphics_lib.fd and clib/graphics_protos.h
100 *****************************************************************************/
102 AROS_LIBFUNC_INIT
104 if (rp->AreaPtrn)
106 struct bp_render_data bprd;
107 struct Rectangle rr;
109 FIX_GFXCOORD(xMin);
110 FIX_GFXCOORD(yMin);
112 bprd.pattern = (UBYTE *)rp->AreaPtrn;
113 bprd.mask = mask;
114 bprd.maskmodulo = byteCnt;
115 bprd.patterndepth = (rp->AreaPtSz >= 0) ? 1 : rp->BitMap->Depth;
116 bprd.patternheight = 1L << ((rp->AreaPtSz >= 0) ? rp->AreaPtSz : -rp->AreaPtSz);
117 bprd.renderx1 = xMin;
118 bprd.rendery1 = yMin;
119 bprd.invertpattern = (rp->DrawMode & INVERSVID) ? TRUE : FALSE;
120 bprd.pixlut.entries = bprd.patterndepth;
121 bprd.pixlut.pixels = IS_HIDD_BM(rp->BitMap) ? HIDD_BM_PIXTAB(rp->BitMap) : NULL;
123 rr.MinX = xMin;
124 rr.MinY = yMin;
125 rr.MaxX = xMax;
126 rr.MaxY = yMax;
128 do_render_func(rp, NULL, &rr, bltpattern_render, &bprd, TRUE, FALSE, GfxBase);
130 else
132 if (mask)
134 ULONG old_drawmode = GetDrMd(rp);
136 if ((old_drawmode & ~INVERSVID) == JAM2)
137 SetDrMd(rp, JAM1 | (old_drawmode & INVERSVID));
139 BltTemplate(mask, 0, byteCnt, rp, xMin, yMin, xMax - xMin + 1, yMax - yMin + 1);
141 SetDrMd(rp, old_drawmode);
143 else
145 RectFill(rp, xMin, yMin, xMax, yMax);
149 AROS_LIBFUNC_EXIT
151 } /* BltPattern */