Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / graphics / bltpattern.c
bloba21de8b478a9440f21465dcf311a0f1f3c3ac860
1 /*
2 Copyright © 1995-2007, 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>
12 #include "graphics_intern.h"
13 #include "gfxfuncsupport.h"
14 #include <proto/oop.h>
16 static ULONG bltpattern_render(APTR bpr_data, LONG srcx, LONG srcy,
17 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
18 LONG x1, LONG y1, LONG x2, LONG y2,
19 struct GfxBase *GfxBase);
21 struct bp_render_data
23 HIDDT_PixelLUT pixlut;
24 UBYTE *pattern;
25 UBYTE *mask;
26 ULONG maskmodulo;
27 WORD patternheight;
28 WORD patterndepth;
29 WORD renderx1;
30 WORD rendery1;
31 UBYTE invertpattern;
34 /*****************************************************************************
36 NAME */
37 #include <clib/graphics_protos.h>
39 AROS_LH7(void, BltPattern,
41 /* SYNOPSIS */
42 AROS_LHA(struct RastPort *, rp, A1),
43 AROS_LHA(PLANEPTR , mask, A0),
44 AROS_LHA(LONG , xMin, D0),
45 AROS_LHA(LONG , yMin, D1),
46 AROS_LHA(LONG , xMax, D2),
47 AROS_LHA(LONG , yMax, D3),
48 AROS_LHA(ULONG , byteCnt, D4),
50 /* LOCATION */
51 struct GfxBase *, GfxBase, 52, Graphics)
53 /* FUNCTION
54 Blit using drawmode, areafill pattern and mask.
56 INPUTS
57 rp - destination RastPort for blit.
58 mask - Mask bitplane. Set this to NULL for a rectangle.
59 xMin, yMin - upper left corner.
60 xMax, yMax - lower right corner.
61 byteCnt - BytesPerRow for mask.
63 RESULT
65 NOTES
67 EXAMPLE
69 BUGS
71 SEE ALSO
73 INTERNALS
75 HISTORY
76 27-11-96 digulla automatically created from
77 graphics_lib.fd and clib/graphics_protos.h
79 *****************************************************************************/
81 AROS_LIBFUNC_INIT
83 if (rp->AreaPtrn)
85 struct bp_render_data bprd;
86 struct Rectangle rr;
88 FIX_GFXCOORD(xMin);
89 FIX_GFXCOORD(yMin);
91 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
92 return;
94 bprd.pattern = (UBYTE *)rp->AreaPtrn;
95 bprd.mask = mask;
96 bprd.maskmodulo = byteCnt;
97 bprd.patterndepth = (rp->AreaPtSz >= 0) ? 1 : rp->BitMap->Depth;
98 bprd.patternheight = 1L << ((rp->AreaPtSz >= 0) ? rp->AreaPtSz : -rp->AreaPtSz);
99 bprd.renderx1 = xMin - RP_PATORIGINX(rp);
100 bprd.rendery1 = yMin - RP_PATORIGINY(rp);
101 bprd.invertpattern = (rp->DrawMode & INVERSVID) ? TRUE : FALSE;
102 bprd.pixlut.entries = bprd.patterndepth;
103 bprd.pixlut.pixels = IS_HIDD_BM(rp->BitMap) ? HIDD_BM_PIXTAB(rp->BitMap) : NULL;
105 rr.MinX = xMin;
106 rr.MinY = yMin;
107 rr.MaxX = xMax;
108 rr.MaxY = yMax;
110 do_render_func(rp, NULL, &rr, bltpattern_render, &bprd, FALSE, GfxBase);
112 RELEASE_DRIVERDATA(rp, GfxBase);
116 else
118 if (mask)
120 ULONG old_drawmode = GetDrMd(rp);
122 if ((old_drawmode & ~INVERSVID) == JAM2)
123 SetDrMd(rp, JAM1 | (old_drawmode & INVERSVID));
125 BltTemplate(mask, 0, byteCnt, rp, xMin, yMin, xMax - xMin + 1, yMax - yMin + 1);
127 SetDrMd(rp, old_drawmode);
129 else
131 RectFill(rp, xMin, yMin, xMax, yMax);
135 AROS_LIBFUNC_EXIT
137 } /* BltPattern */
139 /****************************************************************************************/
141 static ULONG bltpattern_render(APTR bpr_data, LONG srcx, LONG srcy,
142 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
143 LONG x1, LONG y1, LONG x2, LONG y2,
144 struct GfxBase *GfxBase)
146 struct bp_render_data *bprd;
147 ULONG width, height;
148 WORD patsrcx, patsrcy;
149 UBYTE *mask;
151 width = x2 - x1 + 1;
152 height = y2 - y1 + 1;
154 bprd = (struct bp_render_data *)bpr_data;
156 mask = bprd->mask + bprd->maskmodulo * srcy;
158 patsrcx = (srcx + bprd->renderx1) % 16;
159 patsrcy = (srcy + bprd->rendery1) % bprd->patternheight;
160 if (patsrcx < 0) patsrcx += 16;
161 if (patsrcy < 0) patsrcy += bprd->patternheight;
163 HIDD_BM_PutPattern(dstbm_obj, dst_gc, bprd->pattern,
164 patsrcx,
165 patsrcy,
166 bprd->patternheight, bprd->patterndepth,
167 &bprd->pixlut,
168 bprd->invertpattern,
169 mask,
170 bprd->maskmodulo,
171 srcx,
174 width,
175 height);
178 return width * height;