1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-26 13:18:31 +00:00

Added a tgi_arc function. Removed the old ellipse code and create a new

ellipse module that calls tgi_arc.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4446 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2009-11-05 19:52:18 +00:00
parent 78070d8bfb
commit de6050f21d
5 changed files with 125 additions and 52 deletions
+2 -1
View File
@@ -29,7 +29,7 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
#--------------------------------------------------------------------------
# Object files
C_OBJS = tgi_ellipse.o \
C_OBJS = tgi_arc.o \
tgi_load.o \
tgi_load_driver.o \
tgi_load_vectorfont.o
@@ -41,6 +41,7 @@ S_OBJS = tgi-kernel.o \
tgi_clipline.o \
tgi_curtoxy.o \
tgi_done.o \
tgi_ellipse.o \
tgi_free_vectorfont.o \
tgi_getcolor.o \
tgi_getcolorcount.o \
@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* tgi_ellipse.c */
/* tgi_arc.c */
/* */
/* Draw a full ellipse */
/* Draw an ellipse arc */
/* */
/* */
/* */
@@ -56,36 +56,45 @@ static int RoundMul (int rhs, int lhs)
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_arc (int x, int y, unsigned char rx, unsigned char ry,
unsigned sa, unsigned ea)
/* Draw an ellipse arc with center at x/y and radii rx/ry using the current
* drawing color. The arc covers the angle between sa and ea (startangle and
* endangle), which must be in the range 0..360 (otherwise the function may
* bevave unextectedly).
*/
{
int x1, y1, x2, y2;
unsigned angle;
unsigned char inc;
unsigned size = rx + ry;
unsigned char done = 0;
if (size >= 128) {
inc = 12;
} else if (size >= 32) {
inc = 15;
} else if (size >= 12) {
inc = 20;
} else {
inc = 45;
/* Bail out if there's nothing to do */
if (sa > ea) {
return;
}
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));
/* Determine the number of segments to use. This may be refined ... */
if (rx + ry >= 25) {
inc = 12;
} else {
inc = 24;
}
/* Calculate the start coords */
x1 = x + RoundMul (rx, cc65_cos (sa));
y1 = y + RoundMul (ry, cc65_sin (sa));
do {
sa += inc;
if (sa >= ea) {
sa = ea;
done = 1;
}
x2 = x + RoundMul (rx, cc65_cos (sa));
y2 = y - RoundMul (ry, cc65_sin (sa));
tgi_line (x1, y1, x2, y2);
x1 = x2;
y1 = y2;
}
} while (!done);
}
+28
View File
@@ -0,0 +1,28 @@
;
; Ullrich von Bassewitz, 2009-11-05
;
; 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.
; */
;
.include "tgi-kernel.inc"
.import pusha, push0
;----------------------------------------------------------------------------
;
.code
.proc _tgi_ellipse
jsr pusha ; Push ry
jsr push0 ; Start angle is 0
lda #<360
ldx #>360 ; End angle is 360
jmp _tgi_arc
.endproc