Make hostlib test build again.
[AROS.git] / rom / graphics / areaellipse.c
blobb4072c4511e4d26d257c237745ea6f987e8983cf
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function AreaEllipse()
6 Lang: english
7 */
8 #include <exec/types.h>
9 #include <graphics/rastport.h>
10 #include "graphics_intern.h"
11 #include "gfxfuncsupport.h"
13 /*****************************************************************************
15 NAME */
16 #include <proto/graphics.h>
18 AROS_LH5(ULONG, AreaEllipse,
20 /* SYNOPSIS */
21 AROS_LHA(struct RastPort *, rp, A1),
22 AROS_LHA(WORD , cx, D0),
23 AROS_LHA(WORD , cy, D1),
24 AROS_LHA(WORD , a , D2),
25 AROS_LHA(WORD , b , D3),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 31, Graphics)
30 /* FUNCTION
31 Add an ellipse to the vector buffer. An ellipse takes up two
32 entries in the buffer.
34 INPUTS
35 rp - pointer to a valid RastPort structure with a pointer to
36 the previously initialized AreaInfo structure.
37 cx - x coordinate of the center point relative to rastport
38 cy - y coordinate of the center point relative to rastport
39 a - horizontal radius of the ellipse (> 0)
40 b - vertical radius of the ellipse (> 0)
42 RESULT
43 error - 0 for success
44 -1 if the vector collection matrix is full
46 NOTES
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 InitArea(), AreaMove(), AreaDraw(), AreaCircle()
54 graphics/rastport.h
56 INTERNALS
58 HISTORY
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 struct AreaInfo * areainfo = rp->AreaInfo;
66 /* Is there still enough storage area in the areainfo-buffer?
67 * We need at least a storage area for two vectors
69 if (areainfo->Count + 2 <= areainfo->MaxCount)
71 FIX_GFXCOORD(cx);
72 FIX_GFXCOORD(cy);
73 FIX_GFXCOORD(a);
74 FIX_GFXCOORD(b);
76 /* is this the very first entry in the vector collection matrix */
77 if (0 == areainfo->Count)
79 areainfo->VctrPtr[0] = cx;
80 areainfo->VctrPtr[1] = cy;
81 areainfo->FlagPtr[0] = AREAINFOFLAG_ELLIPSE;
83 areainfo->VctrPtr[2] = a;
84 areainfo->VctrPtr[3] = b;
85 areainfo->FlagPtr[1] = AREAINFOFLAG_ELLIPSE;
87 areainfo->VctrPtr = &areainfo->VctrPtr[4];
88 areainfo->FlagPtr = &areainfo->FlagPtr[2];
90 areainfo->Count += 2;
92 else
94 areaclosepolygon(areainfo);
96 /* Need to check again, if there is enough room, because
97 areaclosepolygon might have eaten one vector!! */
99 if (areainfo->Count + 2 > areainfo->MaxCount)
100 return -1;
102 /* If the previous command in the vector collection matrix was a move then
103 * erase that one
106 if (AREAINFOFLAG_MOVE == areainfo->FlagPtr[-1])
108 areainfo->VctrPtr = &areainfo->VctrPtr[-2];
109 areainfo->FlagPtr--;
110 areainfo->Count--;
113 /* still enough storage area?? */
114 if (areainfo->Count + 2 <= areainfo->MaxCount)
116 areainfo->VctrPtr[0] = cx;
117 areainfo->VctrPtr[1] = cy;
118 areainfo->FlagPtr[0] = AREAINFOFLAG_ELLIPSE;
120 areainfo->VctrPtr[2] = a;
121 areainfo->VctrPtr[3] = b;
122 areainfo->FlagPtr[1] = AREAINFOFLAG_ELLIPSE;
124 areainfo->VctrPtr = &areainfo->VctrPtr[4];
125 areainfo->FlagPtr = &areainfo->FlagPtr[2];
127 areainfo->Count += 2;
129 return 0;
131 else
132 return -1;
134 } /* else branch of if (0 == areainfo->Count) */
136 /* will never get to this point! */
138 } /* if (areainfo->Count + 2 < areainfo->MaxCount) */
140 return -1;
142 AROS_LIBFUNC_EXIT
144 } /* AreaEllipse */