Added missing properties.
[AROS.git] / rom / graphics / graphics_misc.c
blob3bf2718278c09bbb48cb3979ea26b2559f187fe9
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Code for miscellaneous operations needed bz graphics
6 Lang: english
7 */
9 #include <proto/exec.h>
10 #include <proto/graphics.h>
11 #include <clib/macros.h>
12 #include <exec/memory.h>
13 #include <graphics/text.h>
14 #include <graphics/rastport.h>
15 #include "graphics_intern.h"
19 BOOL pattern_pen(struct RastPort *rp, WORD x, WORD y, ULONG apen, ULONG bpen, ULONG *pixval_ptr, struct GfxBase *GfxBase)
21 ULONG idx, mask;
22 ULONG set_pixel, pixval = 0;
24 ULONG drmd = GetDrMd(rp);
25 ULONG pattern_height = 1L << ABS(rp->AreaPtSz);
26 const UBYTE *apt = (UBYTE *)rp->AreaPtrn;
29 idx = COORD_TO_BYTEIDX(x & 0x0F, y & (pattern_height - 1), 2);
30 mask = XCOORD_TO_MASK( x );
32 /* kprintf("palette_pen: idx=%d, mask=%d,apen=%d, bpen=%d, drmd=%d, apt[idx]=%d\n"
33 , idx, mask, apen, bpen, drmd, apt[idx]);
34 */
35 /* Mono- or multicolor ? */
36 if (rp->AreaPtSz > 0)
38 /* mono */
39 set_pixel = apt[idx] & mask;
40 if (drmd & INVERSVID)
41 set_pixel = ((set_pixel != 0) ? 0UL : 1UL );
43 if (set_pixel)
45 /* Use FGPen to render */
46 pixval = apen;
47 /* kprintf("use apen\n");
48 */ }
49 else
51 if ((drmd & JAM2) != 0)
53 pixval = bpen;
54 set_pixel = TRUE;
55 /* kprintf("use bpen\n");
56 */ }
57 else
59 /* Do not set pixel */
60 set_pixel = FALSE;
67 else
69 UBYTE i, depth;
70 ULONG plane_size, pen_mask = 0;
71 const UBYTE *plane;
73 plane_size = (/* bytesperrow = */ 2 ) * pattern_height;
74 depth = GetBitMapAttr(rp->BitMap, BMA_DEPTH);
76 plane = apt;
78 /* multicolored pattern, get pixel from all planes */
79 for (i = 0; i < depth; i ++)
82 pen_mask <<= 1;
84 if ((plane[idx] & mask) != 0)
85 pixval |= pen_mask;
87 plane += plane_size;
89 set_pixel = TRUE;
92 if (set_pixel)
93 *pixval_ptr = pixval;
95 return set_pixel;