Users complained that otherwise the names might clash with their functions.
<itemize>
-<!-- <item><ref id="cos" name="cos"> -->
+<!-- <item><ref id="_cos" name="_cos"> -->
<!-- <item><ref id="idiv32by16r16" name="idiv32by16r16"> -->
<!-- <item><ref id="imul16x16r32" name="imul16x16r32"> -->
<!-- <item><ref id="imul8x8r16" name="imul8x8r16"> -->
-<!-- <item><ref id="sin" name="sin"> -->
+<!-- <item><ref id="_sin" name="_sin"> -->
<!-- <item><ref id="udiv32by16r16" name="udiv32by16r16"> -->
<!-- <item><ref id="umul16x16r32" name="umul16x16r32"> -->
<!-- <item><ref id="umul16x8r32" name="umul16x8r32"> -->
** result
*/
-int __fastcall__ sin (unsigned x);
+int __fastcall__ _sin (unsigned x);
/* Return the sine of the argument, which must be in range 0..360. The result
** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00.
*/
-int __fastcall__ cos (unsigned x);
+int __fastcall__ _cos (unsigned x);
/* Return the cosine of the argument, which must be in range 0..360. The result
** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00.
*/
;
; Fixed point cosine/sine functions.
;
-; int __fastcall__ cc65_sin (unsigned x);
-; int __fastcall__ cc65_cos (unsigned x);
+; int __fastcall__ _sin (unsigned x);
+; int __fastcall__ _cos (unsigned x);
;
; Returns the cosine/sine for the given argument as angular degree.
; Valid argument range is 0..360 for both functions. They will return
; Ullrich von Bassewitz, 2009-10-29
;
- .export _cos, _sin
+ .export __cos, __sin
; ---------------------------------------------------------------------------
; ---------------------------------------------------------------------------
-; Cosine function. Is actually implemented as cos(x) = sin(x+90)
+; Cosine function. Is actually implemented as _cos(x) = _sin(x+90)
.code
-_cos:
+__cos:
-; cos(x) = sin(x+90)
+; _cos(x) = _sin(x+90)
clc
adc #90
@L1: cpx #>360
bne @L2
cmp #<360
-@L2: bcc _sin
+@L2: bcc __sin
sbc #<360
bcs @L3
; Sine function. Uses
;
; table lookup for 0..89°
-; sin(x) = sin(180-x) for 90°..179°
-; sin(x) = -sin(x-180) for 180..360°
+; _sin(x) = _sin(180-x) for 90°..179°
+; _sin(x) = -_sin(x-180) for 180..360°
;
; Plus special handling for the values missing in the table.
-_sin:
+__sin:
; If the high byte is non zero, argument is > 255
cmp #90
bcc L1
-; 90..179°. Value is identical to sin(180-val). Carry is set on entry.
+; 90..179°. Value is identical to _sin(180-val). Carry is set on entry.
;
; 180-val := -val + 180.
; With
lda _sintab,y
rts
-; 180..360°. sin(x) = -sin(x-180). Since the argument is in range 0..180
+; 180..360°. _sin(x) = -_sin(x-180). Since the argument is in range 0..180
; after the subtraction, we don't need to handle the high byte.
L3: sec
cmp #90
bcc L5
-; 270..360°. Value is identical to -sin(180-val). Carry is set on entry.
+; 270..360°. Value is identical to -_sin(180-val). Carry is set on entry.
;
; 180-val := -val + 180.
; With
bcc L7
inx
L7: rts
-
-
}
/* Calculate the start coords */
- x1 = x + tgi_imulround (rx, cos (sa));
- y1 = y - tgi_imulround (ry, sin (sa));
+ x1 = x + tgi_imulround (rx, _cos (sa));
+ y1 = y - tgi_imulround (ry, _sin (sa));
do {
sa += inc;
if (sa >= ea) {
sa = ea;
done = 1;
}
- x2 = x + tgi_imulround (rx, cos (sa));
- y2 = y - tgi_imulround (ry, sin (sa));
+ x2 = x + tgi_imulround (rx, _cos (sa));
+ y2 = y - tgi_imulround (ry, _sin (sa));
tgi_line (x1, y1, x2, y2);
x1 = x2;
y1 = y2;
tgi_arc (x, y, rx, ry, sa, ea);
/* ... and close it */
- tgi_line (x, y, x + tgi_imulround (rx, cos (sa)), y - tgi_imulround (ry, sin (sa)));
- tgi_line (x, y, x + tgi_imulround (rx, cos (ea)), y - tgi_imulround (ry, sin (ea)));
+ tgi_line (x, y, x + tgi_imulround (rx, _cos (sa)), y - tgi_imulround (ry, _sin (sa)));
+ tgi_line (x, y, x + tgi_imulround (rx, _cos (ea)), y - tgi_imulround (ry, _sin (ea)));
}
/* Calculate the next points */
X = (int) (((long) (MaxX - 19) * I) / 360);
- Y = (int) (((long) Amp * -sin (I)) / 256);
+ Y = (int) (((long) Amp * -_sin (I)) / 256);
/* Draw the line */
tgi_lineto (XOrigin + X, YOrigin + Y);