Moved fixed point multiplication and rounding into an asm module.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4447 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
|
||||
#include <tgi.h>
|
||||
#include <tgi/tgi-kernel.h>
|
||||
#include <cc65.h>
|
||||
|
||||
|
||||
@@ -44,18 +45,6 @@
|
||||
|
||||
|
||||
|
||||
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_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
|
||||
@@ -81,16 +70,16 @@ void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
|
||||
}
|
||||
|
||||
/* Calculate the start coords */
|
||||
x1 = x + RoundMul (rx, cc65_cos (sa));
|
||||
y1 = y + RoundMul (ry, cc65_sin (sa));
|
||||
x1 = x + tgi_imulround (rx, cc65_cos (sa));
|
||||
y1 = y + tgi_imulround (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));
|
||||
x2 = x + tgi_imulround (rx, cc65_cos (sa));
|
||||
y2 = y - tgi_imulround (ry, cc65_sin (sa));
|
||||
tgi_line (x1, y1, x2, y2);
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
|
||||
Reference in New Issue
Block a user