move registering of the ROM region after prepare execbase. rename i386-pc's kernel...
[AROS.git] / rom / graphics / setrpattrsa.c
blob9fc038111a8be68c4b8ff8938953aaf99935f563
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function SetRPAttrsA()
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <proto/utility.h>
11 #include <proto/oop.h>
13 #include "graphics_intern.h"
14 #include "gfxfuncsupport.h"
16 /*****************************************************************************
18 NAME */
19 #include <graphics/rastport.h>
20 #include <graphics/rpattr.h>
21 #include <utility/tagitem.h>
22 #include <proto/graphics.h>
24 AROS_LH2(void, SetRPAttrsA,
26 /* SYNOPSIS */
27 AROS_LHA(struct RastPort *, rp, A0),
28 AROS_LHA(struct TagItem *, tags, A1),
30 /* LOCATION */
31 struct GfxBase *, GfxBase, 173, Graphics)
33 /* FUNCTION
34 Modify rastport with values from a taglist.
36 INPUTS
37 rp - RastPort
38 tags - see below
40 TAGS
41 RPTAG_Font (struct TextFont *) - Font for Text()
42 RPTAG_APen (UBYTE) - Primary rendering pen
43 RPTAG_BPen (UBYTE) - Secondary rendering pen
44 RPTAG_DrMd (UBYTE) - Drawing mode (graphics/rastport.h)
45 RPTAG_OutlinePen (UBYTE) - Area Outline pen
46 RPTAG_WriteMask (ULONG) - Bit mask for writing
48 The following tags are compatible with MorphOS (V51) :
50 RPTAG_FgColor (ULONG) - Primary rendering color in A8R8G8B8
51 format. Only working on
52 hicolor/truecolor bitmaps/screens.
53 RPTAG_BgColor (ULONG) - Secondary rendering color in
54 A8R8G8B8 format. Only working on
55 hicolor/truecolor bitmaps/screens.
56 RPTAG_PenMode (BOOL) - TRUE if traditional pen numbers
57 should be used, FALSE if direct RGB
58 colors should be used. Has no effect
59 on non-RTG displays.
61 The following tags are compatible with AmigaOSv4 (V51) :
63 RPTAG_RemapColorFonts (BOOL) - Automatically remap colorfonts to
64 their color on hicolor/truecolor
65 screens.
67 AROS-specific extensions
69 RPTAG_ClipRectangle (struct Rectangle *) - Clipping rectangle
70 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM
71 (see graphics/rpattrs.h)
73 RESULT
74 None.
76 NOTES
77 Setting one of RPTAG_ClipRectangle or RPTAG_ClipRectangleFlags
78 allocates internal extra data for the RastPort. After finishing using
79 this RastPort, you need to manually deallocate the extra data using
80 FreeVec(rp->RP_Extra).
82 EXAMPLE
84 BUGS
86 SEE ALSO
87 GetRPAttrsA(), graphics/rpattr.h
89 INTERNALS
91 *****************************************************************************/
93 AROS_LIBFUNC_INIT
95 struct TagItem *tag, *tstate = tags;
96 struct gfx_driverdata *driverdata;
98 while ((tag = NextTagItem (&tstate)))
100 switch (tag->ti_Tag)
102 case RPTAG_Font:
103 SetFont (rp, (struct TextFont *)(tag->ti_Data));
104 break;
106 case RPTAG_APen:
107 SetAPen (rp, tag->ti_Data);
108 break;
110 case RPTAG_BPen:
111 SetBPen (rp, tag->ti_Data);
112 break;
114 case RPTAG_DrMd:
115 SetDrMd (rp, tag->ti_Data);
116 break;
118 case RPTAG_OutlinePen:
119 SetOutlinePen (rp, tag->ti_Data);
120 break;
122 case RPTAG_WriteMask:
123 SetWriteMask (rp, tag->ti_Data);
124 break;
126 case RPTAG_MaxPen:
127 break;
129 case RPTAG_DrawBounds:
130 break;
132 case RPTAG_PenMode:
133 D(bug("[SetRPAttrs] RastPort 0x%p, PenMode set to %ld\n", rp, tag->ti_Data));
134 if (tag->ti_Data)
135 rp->Flags &= ~RPF_NO_PENS;
136 else
137 rp->Flags |= RPF_NO_PENS;
138 break;
140 case RPTAG_FgColor:
141 case RPTAG_BgColor:
142 D(bug("[SetRPAttrs] RastPort 0x%p, setting %sColor to 0x%08lX\n", rp, (tag->ti_Tag == RPTAG_FgColor) ? "Fg" : "Bg", tag->ti_Data));
144 if (rp->BitMap && IS_HIDD_BM(rp->BitMap))
146 /* Map ARGB8888 color value to bitmap's format */
147 HIDDT_Color col;
148 HIDDT_Pixel pixval;
149 ULONG rgb = (ULONG)tag->ti_Data;
151 /* HIDDT_ColComp are 16 Bit */
152 col.alpha = (HIDDT_ColComp)((rgb >> 16) & 0x0000FF00);
153 col.red = (HIDDT_ColComp)((rgb >> 8) & 0x0000FF00);
154 col.green = (HIDDT_ColComp)(rgb & 0x0000FF00);
155 col.blue = (HIDDT_ColComp)((rgb << 8) & 0x0000FF00);
157 pixval = HIDD_BM_MapColor(HIDD_BM_OBJ(rp->BitMap), &col);
159 if (tag->ti_Tag == RPTAG_FgColor)
160 RP_FGCOLOR(rp) = pixval;
161 else
162 RP_BGCOLOR(rp) = pixval;
164 break;
166 case RPTAG_ClipRectangle:
167 driverdata = AllocDriverData(rp, tag->ti_Data, GfxBase);
168 if (driverdata)
170 if (tag->ti_Data)
172 driverdata->dd_ClipRectangle = *(struct Rectangle *)tag->ti_Data;
173 driverdata->dd_ClipRectangleFlags |= RPCRF_VALID;
175 else
177 driverdata->dd_ClipRectangleFlags &= ~RPCRF_VALID;
180 break;
182 case RPTAG_ClipRectangleFlags:
183 driverdata = AllocDriverData(rp, TRUE, GfxBase);
184 if (driverdata)
186 driverdata->dd_ClipRectangleFlags &= ~(RPCRF_RELRIGHT | RPCRF_RELBOTTOM);
187 driverdata->dd_ClipRectangleFlags |= (tag->ti_Data & (RPCRF_RELRIGHT | RPCRF_RELBOTTOM));
189 break;
191 case RPTAG_RemapColorFonts:
192 if (tag->ti_Data)
194 rp->Flags |= RPF_REMAP_COLORFONTS;
196 else
198 rp->Flags &= ~RPF_REMAP_COLORFONTS;
200 break;
202 } /* switch (tag) */
204 } /* while (tag) */
206 AROS_LIBFUNC_EXIT
207 } /* SetRPAttrsA */