Squashed commit of 'sdl-hidd' branch
[cake.git] / rom / graphics / setrgb32.c
blob71aa949230a5a3a60bdcc4b0e7e2b81b462ff1e4
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Set one color register for this Viewport
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include "graphics_intern.h"
10 #include "gfxfuncsupport.h"
11 #include <proto/oop.h>
13 /*****************************************************************************
15 NAME */
16 #include <graphics/view.h>
17 #include <proto/graphics.h>
19 AROS_LH5(void, SetRGB32,
21 /* SYNOPSIS */
22 AROS_LHA(struct ViewPort *, vp, A0),
23 AROS_LHA(ULONG , n, D0),
24 AROS_LHA(ULONG , r, D1),
25 AROS_LHA(ULONG , g, D2),
26 AROS_LHA(ULONG , b, D3),
28 /* LOCATION */
29 struct GfxBase *, GfxBase, 142, Graphics)
31 /* FUNCTION
32 Changes a single color of a viewport.
34 INPUTS
35 vp - Modify this viewport
36 n - Change this color. If the color is outside the range of
37 valid colors, it will be ignored.
38 r, g, b - The new values for the red, green and blue. The
39 valid range is from 0x000000 (no intensity) to
40 0xFFFFFFFF (full intensity).
42 RESULT
43 If there is a ColorMap for this viewport, then the value will
44 be stored in the ColorMap.
45 The selected color register is changed to match your specs.
46 If the color value is unused then nothing will happen.
48 NOTES
49 Lower order bits of the palette specification will be discarded,
50 depending on the color palette resolution of the target graphics
51 device. Use 0xffffffff for the full value, 0x7fffffff for 50%,
52 etc. You can find out the palette range for your screen by
53 querying the graphics data base.
55 EXAMPLE
57 BUGS
59 SEE ALSO
61 INTERNALS
63 HISTORY
65 *****************************************************************************/
67 AROS_LIBFUNC_INIT
69 struct BitMap *bm;
70 HIDDT_Color hidd_col;
71 OOP_Object *pf;
72 HIDDT_ColorModel colmod;
74 if (vp->ColorMap) SetRGB32CM(vp->ColorMap, n, r, g, b);
76 /* Get bitmap object */
77 bm = vp->RasInfo->BitMap;
79 if (!IS_HIDD_BM(bm))
81 D(bug("!!!!! Trying to use SetRGB32() call on non-hidd bitmap!!!\n"));
82 return;
85 if (NULL == HIDD_BM_COLMAP(bm))
87 D(bug("!!!!! Trying to use SetRGB32() call on bitmap with no CLUT !!!\n"));
88 return;
92 /* HIDDT_Color entries are UWORD */
93 hidd_col.red = r >> 16;
94 hidd_col.green = g >> 16 ;
95 hidd_col.blue = b >> 16;
96 hidd_col.alpha = 0;
98 OOP_GetAttr(HIDD_BM_OBJ(bm), aHidd_BitMap_PixFmt, (IPTR *)&pf);
99 OOP_GetAttr(pf, aHidd_PixFmt_ColorModel, &colmod);
101 if (vHidd_ColorModel_Palette == colmod || vHidd_ColorModel_TrueColor == colmod)
103 HIDD_BM_SetColors(HIDD_BM_OBJ(bm), &hidd_col, n, 1);
106 bug("SetRGB32: bm %p, hbm %p, col %d (%x %x %x %x) mapped to %x\n"
107 , bm
108 , HIDD_BM_OBJ(bm)
110 , hidd_col.red, hidd_col.green, hidd_col.blue, hidd_col.alpha
111 , hidd_col.pixval);
114 HIDD_BM_PIXTAB(bm)[n] = hidd_col.pixval;
117 AROS_LIBFUNC_EXIT
119 } /* SetRGB32 */