Indentation fix, cleanup.
[AROS.git] / rom / graphics / setmaxpen.c
blobfe7e5765b9eaadd5784f00b2339b847ba6fe541f
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function SetMaxPen()
6 Lang: english
7 */
8 #include <graphics/rastport.h>
9 #include "graphics_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <proto/graphics.h>
16 AROS_LH2(void, SetMaxPen,
18 /* SYNOPSIS */
19 AROS_LHA(struct RastPort *, rp , A0),
20 AROS_LHA(ULONG , maxpen, D0),
22 /* LOCATION */
23 struct GfxBase *, GfxBase, 165, Graphics)
25 /* FUNCTION
26 Set the maximum pen value for a rastport. This will instruct the
27 graphics.library that the owner of the rastport will not be rendering
28 in any colors whose index is >maxpen. Therefore speed optimizations
29 on certain operations are possible and will be done.
31 Basically this call sets the rastport mask, if this would improve speed.
32 On devices where masking would slow things down (chunky pixels), it will
33 be a no-op.
35 INPUTS
36 rp = pointer to a valid RastPort structure
37 maxpen = longword pen value
39 RESULT
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 SetWriteMask()
50 INTERNALS
52 HISTORY
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
58 BYTE Mask;
60 /* maxpen==0 is nonsense */
61 if (0 == maxpen)
62 return;
64 /* calculate the Mask */
65 /* maxpen | Mask | highest bit
66 * 1 | 1 | 0
67 * 2..3 | 3 | 1
68 * 4..7 | 7 | 2
69 * 8..15 | 15 | 3
70 * 16..31 | 31 | 4
71 * 31..63 | 63 | 5
72 * 63..127 | 127 | 6
73 * 128..255 | 255 | 7
76 /* look for the highest bit */
77 Mask = 0x0;
78 while ((BYTE)maxpen != 0)
80 maxpen >>= 1;
81 Mask = (Mask << 1) | 0x01;
84 rp->Mask = Mask;
86 AROS_LIBFUNC_EXIT
87 } /* SetMaxPen */