added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / graphics / areaellipse.c
blob710aeaa606ebaf37ddc565f06c10073bf0b3ae45
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() graphics/rastport.h
55 INTERNALS
57 HISTORY
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct AreaInfo * areainfo = rp->AreaInfo;
65 /* Is there still enough storage area in the areainfo-buffer?
66 * We need at least a storage area for two vectors
68 if (areainfo->Count + 2 <= areainfo->MaxCount)
70 FIX_GFXCOORD(cx);
71 FIX_GFXCOORD(cy);
72 FIX_GFXCOORD(a);
73 FIX_GFXCOORD(b);
75 /* is this the very first entry in the vector collection matrix */
76 if (0 == areainfo->Count)
78 areainfo->VctrPtr[0] = cx;
79 areainfo->VctrPtr[1] = cy;
80 areainfo->FlagPtr[0] = AREAINFOFLAG_ELLIPSE;
82 areainfo->VctrPtr[2] = a;
83 areainfo->VctrPtr[3] = b;
84 areainfo->FlagPtr[1] = AREAINFOFLAG_ELLIPSE;
86 areainfo->VctrPtr = &areainfo->VctrPtr[4];
87 areainfo->FlagPtr = &areainfo->FlagPtr[2];
89 areainfo->Count += 2;
91 else
93 areaclosepolygon(areainfo);
95 /* Need to check again, if there is enough room, because
96 areaclosepolygon might have eaten one vector!! */
98 if (areainfo->Count + 2 > areainfo->MaxCount)
99 return -1;
101 /* If the previous command in the vector collection matrix was a move then
102 * erase that one
105 if (AREAINFOFLAG_MOVE == areainfo->FlagPtr[-1])
107 areainfo->VctrPtr = &areainfo->VctrPtr[-2];
108 areainfo->FlagPtr--;
109 areainfo->Count--;
112 /* still enough storage area?? */
113 if (areainfo->Count + 2 <= areainfo->MaxCount)
115 areainfo->VctrPtr[0] = cx;
116 areainfo->VctrPtr[1] = cy;
117 areainfo->FlagPtr[0] = AREAINFOFLAG_ELLIPSE;
119 areainfo->VctrPtr[2] = a;
120 areainfo->VctrPtr[3] = b;
121 areainfo->FlagPtr[1] = AREAINFOFLAG_ELLIPSE;
123 areainfo->VctrPtr = &areainfo->VctrPtr[4];
124 areainfo->FlagPtr = &areainfo->FlagPtr[2];
126 areainfo->Count += 2;
128 return 0;
130 else
131 return -1;
133 } /* else branch of if (0 == areainfo->Count) */
135 /* will never get to this point! */
137 } /* if (areainfo->Count + 2 < areainfo->MaxCount) */
139 return -1;
141 AROS_LIBFUNC_EXIT
143 } /* AreaEllipse */