added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / graphics / setrpattrsa.c
blobd845789a514d9cf5355bcd940abd8a7c1acae5ed
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function SetRPAttrsA()
6 Lang: english
7 */
8 #include "graphics_intern.h"
9 #include <proto/utility.h>
10 #include <proto/oop.h>
11 #include "gfxfuncsupport.h"
13 /*****************************************************************************
15 NAME */
16 #include <graphics/rastport.h>
17 #include <graphics/rpattr.h>
18 #include <utility/tagitem.h>
19 #include <proto/graphics.h>
21 AROS_LH2(void, SetRPAttrsA,
23 /* SYNOPSIS */
24 AROS_LHA(struct RastPort *, rp, A0),
25 AROS_LHA(struct TagItem *, tags, A1),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 173, Graphics)
30 /* FUNCTION
31 Modify rastport with values from a taglist.
33 INPUTS
34 rp - RastPort
35 tags - tagarray
36 - RPTAG_Font: text font
37 - RPTAG_APen: primary pen
38 - RPTAG_BPen: secondary pen
39 - RPTAG_DrMd: draw mode
40 - RPTAG_OutlinePen: outline pen
41 - RPTAG_WriteMask: bit mask
42 - RPTAG_MaxPen: see SetMaxPen()
44 AROS extensions
45 - RPTAG_DrawBounds:
46 - RPTAG_FgColor:
47 - RPTAG_BgColor:
48 - RPTAG_PatternOriginX:
49 - RPTAG_PatternOriginY:
50 - RPTAG_ClipRectangle: (struct Rectangle *)
51 - RPTAG_ClipRectangleFlags: RPCRF_RELRIGHT | RPCRF_RELBOTTOM
52 - RPTAG_RemapColorFonts: (BOOL)
54 RESULT
56 NOTES
58 EXAMPLE
60 BUGS
62 SEE ALSO
64 INTERNALS
66 HISTORY
67 29-10-95 digulla automatically created from
68 graphics_lib.fd and clib/graphics_protos.h
70 *****************************************************************************/
72 AROS_LIBFUNC_INIT
74 struct TagItem *tag, *tstate = tags;
75 BOOL havedriverdata = FALSE;
77 while ((tag = NextTagItem ((const struct TagItem **)&tstate)))
79 switch (tag->ti_Tag)
81 case RPTAG_Font:
82 SetFont (rp, (struct TextFont *)(tag->ti_Data));
83 break;
85 case RPTAG_APen:
86 SetAPen (rp, tag->ti_Data);
87 break;
89 case RPTAG_BPen:
90 SetBPen (rp, tag->ti_Data);
91 break;
93 case RPTAG_DrMd:
94 SetDrMd (rp, tag->ti_Data);
95 break;
97 case RPTAG_OutlinePen:
98 SetOutlinePen (rp, tag->ti_Data);
99 break;
101 case RPTAG_WriteMask:
102 SetWriteMask (rp, tag->ti_Data);
103 break;
105 case RPTAG_MaxPen:
106 break;
108 case RPTAG_DrawBounds:
109 break;
111 case RPTAG_FgColor:
112 case RPTAG_BgColor:
114 IPTR attr;
116 if (tag->ti_Tag == RPTAG_FgColor)
118 attr = aHidd_GC_Foreground;
119 RP_FGCOLOR(rp) = (ULONG)tag->ti_Data;
121 else
123 attr = aHidd_GC_Background;
124 RP_BGCOLOR(rp) = (ULONG)tag->ti_Data;
127 if (!rp->BitMap) break;
128 if (!IS_HIDD_BM(rp->BitMap)) break;
130 if (!havedriverdata)
132 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
135 if (havedriverdata)
137 struct TagItem col_tags[] =
139 { attr, 0 },
140 { TAG_DONE }
142 HIDDT_Color col;
143 ULONG rgb = (ULONG)tag->ti_Data;
145 /* HIDDT_ColComp are 16 Bit */
146 col.alpha = (HIDDT_ColComp)((rgb >> 16) & 0x0000FF00);
147 col.red = (HIDDT_ColComp)((rgb >> 8) & 0x0000FF00);
148 col.green = (HIDDT_ColComp)(rgb & 0x0000FF00);
149 col.blue = (HIDDT_ColComp)((rgb << 8) & 0x0000FF00);
151 col_tags[0].ti_Data = HIDD_BM_MapColor(HIDD_BM_OBJ(rp->BitMap), &col);
152 OOP_SetAttrs(RP_DRIVERDATA(rp)->dd_GC, col_tags);
154 break;
156 } /**/
158 case RPTAG_PatternOriginX:
159 RP_PATORIGINX(rp) = (WORD)tag->ti_Data;
160 break;
162 case RPTAG_PatternOriginY:
163 RP_PATORIGINY(rp) = (WORD)tag->ti_Data;
164 break;
166 case RPTAG_ClipRectangle:
167 if (!havedriverdata)
169 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
172 if (havedriverdata)
174 if (tag->ti_Data)
176 RP_DRIVERDATA(rp)->dd_ClipRectangle = *(struct Rectangle *)tag->ti_Data;
177 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags |= RPCRF_VALID;
179 else
181 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags &= ~RPCRF_VALID;
184 break;
186 case RPTAG_ClipRectangleFlags:
187 if (!havedriverdata)
189 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
192 if (havedriverdata)
194 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags &= ~(RPCRF_RELRIGHT | RPCRF_RELBOTTOM);
195 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags |= (tag->ti_Data & (RPCRF_RELRIGHT | RPCRF_RELBOTTOM));
197 break;
199 case RPTAG_RemapColorFonts:
200 if (tag->ti_Data)
202 rp->Flags |= RPF_REMAP_COLORFONTS;
204 else
206 rp->Flags &= ~RPF_REMAP_COLORFONTS;
208 break;
210 } /* switch (tag) */
212 } /* while (tag) */
214 if (havedriverdata)
216 RELEASE_DRIVERDATA(rp, GfxBase);
219 AROS_LIBFUNC_EXIT
220 } /* SetRPAttrsA */