<sect1><tt/string.h/<label id="string.h"><p>
-
+
<itemize>
<item><ref id="_stroserror" name="_stroserror">
<item><ref id="bzero" name="bzero">
<item><ref id="tgi_getcolorcount" name="tgi_getcolorcount">
<item><ref id="tgi_getdefpalette" name="tgi_getdefpalette">
<item><ref id="tgi_done" name="tgi_done">
+<item><ref id="tgi_ellipse" name="tgi_ellipse">
<item><ref id="tgi_geterror" name="tgi_geterror">
<item><ref id="tgi_geterrormsg" name="tgi_geterrormsg">
<item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor">
<tag/Availability/cc65
<tag/See also/Other tgi function
<tag/Example/<verb>
-tgi_setcolor(COLOR_GREEN);
+tgi_setcolor(TGI_COLOR_GREEN);
tgi_bar(10, 10, 100, 60);
</verb>
</descrip>
</quote>
+
<sect1>tgi_circle<label id="tgi_circle"><p>
<quote>
be used in presence of a prototype.
</itemize>
<tag/Availability/cc65
-<tag/See also/Other tgi functions
+<tag/See also/
+<ref id="tgi_bar" name="tgi_bar">,
+<ref id="tgi_ellipse" name="tgi_ellipse">,
+<ref id="tgi_setcolor" name="tgi_setcolor">
<tag/Example/<verb>
-tgi_setcolor(COLOR_BLACK);
+tgi_setcolor(TGI_COLOR_BLACK);
tgi_circle(50, 40, 40);
</verb>
</descrip>
</quote>
+
<sect1>tgi_clear<label id="tgi_clear"><p>
<quote>
<quote>
<descrip>
<tag/Function/End graphics mode, switch back to text mode.
-Will NOT uninstall or unload the driver!
+Will NOT uninstall or unload the driver!
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/void __fastcall__ tgi_done (void);/
<tag/Description/End graphics mode, switch back to text mode.
-Will NOT uninstall or unload the driver!
+Will NOT uninstall or unload the driver!
<tag/Limits/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
</descrip>
</quote>
+
+<sect1>tgi_ellipse<label id="tgi_ellipse"><p>
+
+<quote>
+<descrip>
+<tag/Function/The function draws an ellipse in the current color.
+<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
+<tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/
+<tag/Description/The function draws an ellipse at position x/y with radii
+rx and ry, using the current drawing color.
+<tag/Limits/<itemize>
+<item>The function is only available as fastcall function, so it may only
+be used in presence of a prototype.
+</itemize>
+<tag/Availability/cc65
+<tag/See also/
+<ref id="tgi_bar" name="tgi_bar">,
+<ref id="tgi_circle" name="tgi_circle">,
+<ref id="tgi_setcolor" name="tgi_setcolor">
+<tag/Example/<verb>
+tgi_setcolor(TGI_COLOR_RED);
+tgi_ellipse (50, 40, 40, 20);
+</verb>
+</descrip>
+</quote>
+
+
<sect1>tgi_getcolor<label id="tgi_getcolor"><p>
<quote>
<tag/Declaration/<tt/unsigned char __fastcall__ tgi_getcolor (void);/
<tag/Description/The actual color is an index to a palette. During tgi_init
you will get a default palette. The number of colors depend on the platform.
-All platforms recognize at least COLOR_BLACK and COLOR_WHITE. But some
-platforms have many more predefined colors. If you paint using COLOR_GREEN
+All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
+platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
and then you change the green of the palette to blue using tgi_setpalette then
-after this painting in COLOR_GREEN will actually be blue.
+after this painting in TGI_COLOR_GREEN will actually be blue.
<tag/Limits/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/const unsigned char* __fastcall__ tgi_getdefpalette (void);/
<tag/Description/The tgi driver has a default palette that is active at startup.
-The named colors COLOR_BLACK, COLOR_WHITE, COLOR_RED... need this palette to
-work correctly.
+The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
+palette to work correctly.
<tag/Limits/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
#define tgi_updatedisplay() tgi_ioctl(4, 1)
if (!tgi_busy()) {
tgi_sprite(&background);
- tgi_setcolor(COLOR_BLUE);
+ tgi_setcolor(TGI_COLOR_BLUE);
tgi_outttextxy(20,40,"Hello World");
tgi_updatedisplay();
}
<tag/Availability/cc65
<tag/See also/Other tgi functions.
<tag/Example/<verb>
-tgi_setcolor(COLOR_BLACK);
+tgi_setcolor(TGI_COLOR_BLACK);
tgi_bar(0,0,30,30);
-tgi_setcolor(COLOR_WHITE);
+tgi_setcolor(TGI_COLOR_WHITE);
tgi_bar(10,10,20,20);
</verb>
</descrip>
--- /dev/null
+/*****************************************************************************/
+/* */
+/* tgi_ellipse.c */
+/* */
+/* Draw a full ellipse */
+/* */
+/* */
+/* */
+/* (C) 2002-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#include <tgi.h>
+#include <cc65.h>
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+static int RoundMul (int rhs, int lhs)
+{
+ long res = cc65_imul16x16r32 (rhs, lhs);
+ if ((unsigned char)res & 0x80) {
+ return (int)(res >> 8) + 1;
+ } else {
+ return (int)(res >> 8);
+ }
+}
+
+
+
+void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry)
+/* Draw a full ellipse with center at x/y and radii rx/ry using the current
+ * drawing color.
+ */
+{
+ int x1, y1, x2, y2;
+ unsigned angle;
+ unsigned char inc;
+ unsigned size = rx + ry;
+
+ if (size >= 128) {
+ inc = 12;
+ } else if (size >= 32) {
+ inc = 15;
+ } else if (size >= 12) {
+ inc = 20;
+ } else {
+ inc = 45;
+ }
+
+ x1 = x + rx;
+ y1 = y;
+ angle = 0;
+ for (angle = 0; angle <= 360; angle += inc) {
+ x2 = x + RoundMul (rx, cc65_cos (angle));
+ y2 = y + RoundMul (ry, cc65_sin (angle));
+ tgi_line (x1, y1, x2, y2);
+ x1 = x2;
+ y1 = y2;
+ }
+}
+
+
+