diff --git a/asminc/tgi-kernel.inc b/asminc/tgi-kernel.inc index 410293e79..012dfdc10 100644 --- a/asminc/tgi-kernel.inc +++ b/asminc/tgi-kernel.inc @@ -181,6 +181,7 @@ TGI_TEXT_VERTICAL = 1 .global _tgi_line .global _tgi_lineto .global _tgi_circle + .global _tgi_ellipse .global _tgi_bar .global _tgi_textscale .global _tgi_textstyle diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 65d797baa..67b6ef633 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -466,7 +466,7 @@ It does not declare any functions.

- + @@ -512,6 +512,7 @@ It does not declare any functions. + @@ -4888,12 +4889,13 @@ be used in presence of a prototype. -tgi_setcolor(COLOR_GREEN); +tgi_setcolor(TGI_COLOR_GREEN); tgi_bar(10, 10, 100, 60); + tgi_circle

@@ -4907,14 +4909,18 @@ tgi_bar(10, 10, 100, 60); be used in presence of a prototype. , +, + -tgi_setcolor(COLOR_BLACK); +tgi_setcolor(TGI_COLOR_BLACK); tgi_circle(50, 40, 40); + tgi_clear

@@ -4938,11 +4944,11 @@ be used in presence of a prototype. / The function is only available as fastcall function, so it may only be used in presence of a prototype. @@ -4953,6 +4959,33 @@ be used in presence of a prototype. + +tgi_ellipse

+ + + +/ + +The function is only available as fastcall function, so it may only +be used in presence of a prototype. + +, +, + + +tgi_setcolor(TGI_COLOR_RED); +tgi_ellipse (50, 40, 40, 20); + + + + + tgi_getcolor

@@ -4962,10 +4995,10 @@ be used in presence of a prototype. The function is only available as fastcall function, so it may only be used in presence of a prototype. @@ -5009,8 +5042,8 @@ if (tgi_getcolorcount() == 2) { / The function is only available as fastcall function, so it may only be used in presence of a prototype. @@ -5303,7 +5336,7 @@ 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(); } @@ -5448,9 +5481,9 @@ be used in presence of a prototype. -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); diff --git a/include/tgi.h b/include/tgi.h index 589ad12cc..ca5a5dc5f 100644 --- a/include/tgi.h +++ b/include/tgi.h @@ -213,6 +213,11 @@ void __fastcall__ tgi_lineto (int x2, int y2); void __fastcall__ tgi_circle (int x, int y, unsigned char radius); /* Draw a circle in the current drawing color. */ +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. + */ + void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2); /* Draw a bar (a filled rectangle) using the current color. */ @@ -228,7 +233,7 @@ void __fastcall__ tgi_textstyle (unsigned width, unsigned height, * dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX * constants. */ - + unsigned __fastcall__ tgi_textwidth (const char* s); /* Calculate the width of the text in pixels according to the current text * style. diff --git a/libsrc/tgi/Makefile b/libsrc/tgi/Makefile index c24b00c52..9a8147436 100644 --- a/libsrc/tgi/Makefile +++ b/libsrc/tgi/Makefile @@ -29,7 +29,8 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include #-------------------------------------------------------------------------- # Object files -C_OBJS = tgi_load.o \ +C_OBJS = tgi_ellipse.o \ + tgi_load.o \ tgi_load_driver.o \ tgi_load_vectorfont.o diff --git a/libsrc/tgi/tgi_circle.s b/libsrc/tgi/tgi_circle.s index 4766e5331..c1d2afaef 100644 --- a/libsrc/tgi/tgi_circle.s +++ b/libsrc/tgi/tgi_circle.s @@ -1,16 +1,21 @@ ; -; Ullrich von Bassewitz, 21.06.2002 +; Ullrich von Bassewitz, 2009-11-05 ; ; void __fastcall__ tgi_circle (int x, int y, unsigned char radius); ; /* Draw a circle in the current drawing color */ .include "tgi-kernel.inc" - .import incsp4 + .import pusha + +;---------------------------------------------------------------------------- +; + +.code .proc _tgi_circle - ; For now - jmp incsp4 + jsr pusha ; Push as rx + jmp _tgi_ellipse ; Draw an ellipse with rx=ry .endproc diff --git a/libsrc/tgi/tgi_ellipse.c b/libsrc/tgi/tgi_ellipse.c new file mode 100644 index 000000000..6f42b1a49 --- /dev/null +++ b/libsrc/tgi/tgi_ellipse.c @@ -0,0 +1,92 @@ +/*****************************************************************************/ +/* */ +/* 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 +#include + + + +/*****************************************************************************/ +/* 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; + } +} + + +