Indentation fix, cleanup.
[AROS.git] / rom / graphics / videocontrol.c
blobfe5dfc2d4eb434183e604c3f71deb571f2e28d39
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function VideoControl()
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <graphics/videocontrol.h>
10 #include <graphics/view.h>
11 #include <utility/tagitem.h>
12 #include <proto/utility.h>
14 #include "graphics_intern.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/graphics.h>
21 AROS_LH2(ULONG, VideoControl,
23 /* SYNOPSIS */
24 AROS_LHA(struct ColorMap *, cm, A0),
25 AROS_LHA(struct TagItem *, tags, A1),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 118, Graphics)
30 /* FUNCTION
32 INPUTS
33 cm - pointer to struct ColorMap obtained via GetColorMap()
34 tags - pointer to a table of videocontrol tagitems
36 RESULT
37 error - 0 if no error ocurred in the control operation
38 non-0 if bad colormap pointer, no tagitems or bad tag
39 NOTES
40 Not implemented
42 EXAMPLE
44 BUGS
46 SEE ALSO
48 INTERNALS
50 HISTORY
53 ******************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct TagItem *tag, *tstate = tags;
58 LONG *immediate = NULL;
59 ULONG res = 0;
61 while ((tag = NextTagItem(&tstate))) {
62 switch(tag->ti_Tag) {
64 case VTAG_ATTACH_CM_SET:
65 cm->cm_vp = (struct ViewPort *)tag->ti_Data;
66 break;
68 case VTAG_ATTACH_CM_GET:
69 tag->ti_Tag = VTAG_ATTACH_CM_SET;
70 tag->ti_Data = (STACKIPTR)cm->cm_vp;
71 break;
73 case VTAG_VIEWPORTEXTRA_SET:
74 cm->cm_vpe = (struct ViewPortExtra *)tag->ti_Data;
75 GfxAssociate(cm->cm_vp, &cm->cm_vpe->n);
76 break;
78 case VTAG_VIEWPORTEXTRA_GET:
79 tag->ti_Tag = VTAG_VIEWPORTEXTRA_SET;
80 tag->ti_Data = (STACKIPTR)cm->cm_vpe;
81 break;
83 case VTAG_NORMAL_DISP_SET:
84 cm->NormalDisplayInfo = (APTR)tag->ti_Data;
85 break;
87 case VTAG_NORMAL_DISP_GET:
88 tag->ti_Tag = VTAG_NORMAL_DISP_SET;
89 tag->ti_Data = (STACKIPTR)cm->NormalDisplayInfo;
90 break;
92 case VTAG_COERCE_DISP_SET:
93 cm->CoerceDisplayInfo = (APTR)tag->ti_Data;
94 break;
96 case VTAG_COERCE_DISP_GET:
97 tag->ti_Tag = VTAG_COERCE_DISP_SET;
98 tag->ti_Data = (STACKIPTR)cm->CoerceDisplayInfo;
99 break;
101 case VTAG_PF1_BASE_SET:
102 cm->Bp_0_base = tag->ti_Data;
103 break;
105 case VTAG_PF1_BASE_GET:
106 tag->ti_Tag = VTAG_PF1_BASE_SET;
107 tag->ti_Data = cm->Bp_0_base;
108 break;
110 case VTAG_PF2_BASE_SET:
111 cm->Bp_1_base = tag->ti_Data;
112 break;
114 case VTAG_PF2_BASE_GET:
115 tag->ti_Tag = VTAG_PF2_BASE_SET;
116 tag->ti_Data = cm->Bp_1_base;
117 break;
119 case VTAG_SPODD_BASE_SET:
120 cm->SpriteBase_Odd = tag->ti_Data;
121 break;
123 case VTAG_SPODD_BASE_GET:
124 tag->ti_Tag = VTAG_SPODD_BASE_SET;
125 tag->ti_Data = cm->SpriteBase_Odd;
126 break;
128 case VTAG_SPEVEN_BASE_SET:
129 cm->SpriteBase_Even = tag->ti_Data;
130 /* TODO: propagate this value to the display driver */
131 break;
133 case VTAG_SPEVEN_BASE_GET:
134 tag->ti_Tag = VTAG_SPEVEN_BASE_SET;
135 tag->ti_Data = cm->SpriteBase_Even;
136 break;
138 case VTAG_BORDERSPRITE_SET:
139 cm->Flags |= BORDERSPRITES;
140 break;
142 case VTAG_BORDERSPRITE_CLR:
143 cm->Flags &= ~BORDERSPRITES;
144 break;
146 case VTAG_BORDERSPRITE_GET:
147 /* FIXME: Does AmigaOS do the same? */
148 if (cm->Flags & BORDERSPRITES) {
149 tag->ti_Tag = VTAG_BORDERSPRITE_SET;
150 tag->ti_Data = TRUE;
151 } else {
152 tag->ti_Tag = VTAG_BORDERSPRITE_CLR;
153 tag->ti_Data = FALSE;
155 break;
157 case VTAG_SPRITERESN_SET:
158 cm->SpriteResolution = tag->ti_Data;
159 break;
161 case VTAG_SPRITERESN_GET:
162 tag->ti_Tag = VTAG_SPRITERESN_SET;
163 tag->ti_Data = cm->SpriteResolution;
164 break;
166 /* TODO: Implement these */
167 case VTAG_PF1_TO_SPRITEPRI_SET:
168 break;
170 case VTAG_PF1_TO_SPRITEPRI_GET:
171 tag->ti_Tag = VTAG_PF1_TO_SPRITEPRI_SET;
172 tag->ti_Data = 0;
173 break;
175 case VTAG_PF2_TO_SPRITEPRI_SET:
176 break;
178 case VTAG_PF2_TO_SPRITEPRI_GET:
179 tag->ti_Tag = VTAG_PF2_TO_SPRITEPRI_SET;
180 tag->ti_Data = 0;
181 break;
183 case VTAG_BORDERBLANK_SET:
184 cm->Flags |= BORDER_BLANKING;
185 break;
187 case VTAG_BORDERBLANK_CLR:
188 cm->Flags &= ~BORDER_BLANKING;
189 break;
191 case VTAG_BORDERBLANK_GET:
192 if (cm->Flags & BORDER_BLANKING) {
193 tag->ti_Tag = VTAG_BORDERBLANK_SET;
194 tag->ti_Data = TRUE;
195 } else {
196 tag->ti_Tag = VTAG_BORDERBLANK_CLR;
197 tag->ti_Data = FALSE;
199 break;
201 case VTAG_BORDERNOTRANS_SET:
202 cm->Flags |= BORDER_NOTRANSPARENCY;
203 break;
205 case VTAG_BORDERNOTRANS_CLR:
206 cm->Flags &= ~BORDER_NOTRANSPARENCY;
207 break;
209 case VTAG_BORDERNOTRANS_GET:
210 if (cm->Flags & BORDER_NOTRANSPARENCY) {
211 tag->ti_Tag = VTAG_BORDERNOTRANS_SET;
212 tag->ti_Data = TRUE;
213 } else {
214 tag->ti_Tag = VTAG_BORDERNOTRANS_CLR;
215 tag->ti_Data = FALSE;
217 break;
219 /* TODO: implement these */
220 case VTAG_CHROMAKEY_SET:
221 break;
223 case VTAG_CHROMAKEY_CLR:
224 break;
226 case VTAG_CHROMAKEY_GET:
227 tag->ti_Tag = VTAG_CHROMAKEY_CLR;
228 tag->ti_Data = 0;
229 break;
231 case VTAG_BITPLANEKEY_SET:
232 break;
234 case VTAG_BITPLANEKEY_CLR:
235 break;
237 case VTAG_BITPLANEKEY_GET:
238 tag->ti_Tag = VTAG_BITPLANEKEY_CLR;
239 tag->ti_Data = 0;
240 break;
242 case VTAG_CHROMA_PEN_SET:
243 break;
245 case VTAG_CHROMA_PEN_CLR:
246 break;
248 case VTAG_CHROMA_PEN_GET:
249 tag->ti_Tag = VTAG_CHROMA_PEN_CLR;
250 tag->ti_Data = 0;
251 break;
253 case VTAG_CHROMA_PLANE_SET:
254 break;
256 case VTAG_CHROMA_PLANE_GET:
257 tag->ti_Tag = VTAG_CHROMA_PLANE_SET;
258 tag->ti_Data = 0;
259 break;
261 case VTAG_IMMEDIATE:
262 immediate = (LONG *)tag->ti_Data;
263 break;
265 case VTAG_FULLPALETTE_SET:
266 cm->AuxFlags |= CMAF_FULLPALETTE;
267 break;
269 case VTAG_FULLPALETTE_CLR:
270 cm->AuxFlags &= ~CMAF_FULLPALETTE;
271 break;
273 case VTAG_FULLPALETTE_GET:
274 if (cm->AuxFlags & CMAF_FULLPALETTE) {
275 tag->ti_Tag = VTAG_FULLPALETTE_SET;
276 tag->ti_Data = TRUE;
277 } else {
278 tag->ti_Tag = VTAG_FULLPALETTE_CLR;
279 tag->ti_Data = FALSE;
281 break;
283 case VC_IntermediateCLUpdate:
284 if (tag->ti_Data)
285 cm->AuxFlags &= ~CMAF_NO_INTERMED_UPDATE;
286 else
287 cm->AuxFlags |= CMAF_NO_INTERMED_UPDATE;
288 break;
290 case VC_IntermediateCLUpdate_Query:
291 *(ULONG *)tag->ti_Data = (cm->AuxFlags & CMAF_NO_INTERMED_UPDATE) ? FALSE : TRUE;
292 break;
294 case VC_NoColorPaletteLoad:
295 if (tag->ti_Data)
296 cm->AuxFlags |= CMAF_NO_COLOR_LOAD;
297 else
298 cm->AuxFlags &= ~CMAF_NO_COLOR_LOAD;
299 break;
301 case VC_NoColorPaletteLoad_Query:
302 *(ULONG *)tag->ti_Data = (cm->AuxFlags & CMAF_NO_COLOR_LOAD) ? TRUE : FALSE;
303 break;
305 case VC_DUALPF_Disable:
306 if (tag->ti_Data)
307 cm->AuxFlags |= CMAF_DUALPF_DISABLE;
308 else
309 cm->AuxFlags &= ~CMAF_DUALPF_DISABLE;
310 break;
312 case VC_DUALPF_Disable_Query:
313 *(ULONG *)tag->ti_Data = (cm->AuxFlags & CMAF_DUALPF_DISABLE) ? TRUE : FALSE;
314 break;
316 case VTAG_USERCLIP_SET:
317 cm->Flags |= USER_COPPER_CLIP;
318 break;
320 case VTAG_USERCLIP_CLR:
321 cm->Flags &= ~USER_COPPER_CLIP;
322 break;
324 case VTAG_USERCLIP_GET:
325 if (cm->Flags & USER_COPPER_CLIP) {
326 tag->ti_Tag = VTAG_USERCLIP_SET;
327 tag->ti_Data = TRUE;
328 } else {
329 tag->ti_Tag = VTAG_USERCLIP_CLR;
330 tag->ti_Data = FALSE;
332 break;
334 case VTAG_NEXTBUF_CM:
335 tstate = (struct TagItem *)tag->ti_Data;
336 break;
338 case VTAG_BATCH_CM_SET:
339 cm->Flags |= VIDEOCONTROL_BATCH;
340 break;
342 case VTAG_BATCH_CM_CLR:
343 cm->Flags &= ~VIDEOCONTROL_BATCH;
344 break;
346 case VTAG_BATCH_CM_GET:
347 if (cm->Flags & VIDEOCONTROL_BATCH) {
348 tag->ti_Tag = VTAG_BATCH_CM_SET;
349 tag->ti_Data = TRUE;
350 } else {
351 tag->ti_Tag = VTAG_BATCH_CM_CLR;
352 tag->ti_Data = FALSE;
354 break;
356 case VTAG_BATCH_ITEMS_SET:
357 cm->cm_batch_items = (struct TagItem *)tag->ti_Data;
358 break;
360 /* TODO: implement this */
361 case VTAG_BATCH_ITEMS_ADD:
362 break;
364 case VTAG_BATCH_ITEMS_GET:
365 tag->ti_Tag = VTAG_BATCH_ITEMS_SET;
366 tag->ti_Data = (STACKIPTR)cm->cm_batch_items;
367 break;
369 case VTAG_VPMODEID_SET:
370 cm->VPModeID = tag->ti_Data;
371 break;
373 case VTAG_VPMODEID_CLR:
374 cm->VPModeID = INVALID_ID;
375 break;
377 case VTAG_VPMODEID_GET:
378 tag->ti_Tag = (cm->VPModeID == INVALID_ID) ? VTAG_VPMODEID_CLR : VTAG_VPMODEID_SET;
379 tag->ti_Data = cm->VPModeID;
380 break;
382 default:
383 res = 1;
387 if (immediate) {
389 /* TODO: update SpriteBase in the graphics driver here */
391 *immediate = 0;
394 return res;
396 AROS_LIBFUNC_EXIT
397 } /* VideoControl */