Minor fixes to comments.
[AROS.git] / rom / graphics / setrgb32.c
blob4f89136f4d42622bfb3ac47606366a0a47a73593
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Set one color register for this Viewport
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <proto/oop.h>
12 #include "graphics_intern.h"
13 #include "gfxfuncsupport.h"
15 /*****************************************************************************
17 NAME */
18 #include <graphics/view.h>
19 #include <proto/graphics.h>
21 AROS_LH5(void, SetRGB32,
23 /* SYNOPSIS */
24 AROS_LHA(struct ViewPort *, vp, A0),
25 AROS_LHA(ULONG , n, D0),
26 AROS_LHA(ULONG , r, D1),
27 AROS_LHA(ULONG , g, D2),
28 AROS_LHA(ULONG , b, D3),
30 /* LOCATION */
31 struct GfxBase *, GfxBase, 142, Graphics)
33 /* FUNCTION
34 Changes a single color of a viewport.
36 INPUTS
37 vp - Modify this viewport
38 n - Change this color. If the color is outside the range of
39 valid colors, it will be ignored.
40 r, g, b - The new values for the red, green and blue. The
41 valid range is from 0x000000 (no intensity) to
42 0xFFFFFFFF (full intensity).
44 RESULT
45 If there is a ColorMap for this viewport, then the value will
46 be stored in the ColorMap.
47 The selected color register is changed to match your specs.
48 If the color value is unused then nothing will happen.
50 NOTES
51 Lower order bits of the palette specification will be discarded,
52 depending on the color palette resolution of the target graphics
53 device. Use 0xffffffff for the full value, 0x7fffffff for 50%,
54 etc. You can find out the palette range for your screen by
55 querying the graphics data base.
57 EXAMPLE
59 BUGS
61 SEE ALSO
63 INTERNALS
65 HISTORY
67 *****************************************************************************/
69 AROS_LIBFUNC_INIT
71 struct ViewPortExtra *vpe = NULL;
72 HIDDT_Color hidd_col;
73 OOP_Object *bm;
74 OOP_Object *pf;
75 HIDDT_ColorModel colmod;
77 if (vp->ColorMap)
79 SetRGB32CM(vp->ColorMap, n, r, g, b);
80 /* If we have a colormap, we can find ViewPortExtra faster */
81 vpe = vp->ColorMap->cm_vpe;
85 * SetRGB32() can be called before MakeVPort().
86 * In order to make it working in such a situation we get bitmap object
87 * pointer from the bitmap itself, if possible.
88 * VPE_DATA is built and attached by MakeVPort(), until this it doesn't exist.
89 * Taking into account comments in SetRGB4(), perhaps order of things
90 * should be changed. It's likely MakeVPort()'s job to load ColorMap
91 * data into the driver.
93 if (IS_HIDD_BM(vp->RasInfo->BitMap))
94 /* HIDD bitmap, just take object pointer */
95 bm = HIDD_BM_OBJ(vp->RasInfo->BitMap);
96 else
98 /* Planar bitmap. Take object from ViewPortExtra (if present). */
99 if (!vpe)
100 vpe = (struct ViewPortExtra *)GfxLookUp(vp);
102 if ((!vpe) || (!VPE_DATA(vpe)))
103 return;
105 bm = VPE_DATA(vpe)->Bitmap;
108 /* HIDDT_Color entries are UWORD */
109 hidd_col.red = r >> 16;
110 hidd_col.green = g >> 16;
111 hidd_col.blue = b >> 16;
112 hidd_col.alpha = 0;
114 OOP_GetAttr(bm, aHidd_BitMap_PixFmt, (IPTR *)&pf);
115 OOP_GetAttr(pf, aHidd_PixFmt_ColorModel, &colmod);
117 if (vHidd_ColorModel_Palette == colmod || vHidd_ColorModel_TrueColor == colmod)
119 HIDD_BM_SetColors(bm, &hidd_col, n, 1);
121 D(bug("SetRGB32: bm %p, hbm %p, col %d (%x %x %x %x) mapped to %x\n"
122 , vp->RasInfo->BitMap
123 , bm
125 , hidd_col.red, hidd_col.green, hidd_col.blue, hidd_col.alpha
126 , hidd_col.pixval));
129 * Store the actual pixel value in associated LUT.
130 * This LUT is used by graphics.library for blitting LUT images
131 * to direct-color screens.
133 if (IS_HIDD_BM(vp->RasInfo->BitMap))
134 HIDD_BM_PIXTAB(vp->RasInfo->BitMap)[n] = hidd_col.pixval;
137 AROS_LIBFUNC_EXIT
139 } /* SetRGB32 */