mirror of
https://github.com/cc65/cc65.git
synced 2024-06-07 07:29:33 +00:00
Added '_' prefix to sin and cos.
Users complained that otherwise the names might clash with their functions.
This commit is contained in:
parent
cb7882a202
commit
ac0b452834
|
@ -244,11 +244,11 @@ function.
|
||||||
|
|
||||||
<itemize>
|
<itemize>
|
||||||
|
|
||||||
<!-- <item><ref id="cos" name="cos"> -->
|
<!-- <item><ref id="_cos" name="_cos"> -->
|
||||||
<!-- <item><ref id="idiv32by16r16" name="idiv32by16r16"> -->
|
<!-- <item><ref id="idiv32by16r16" name="idiv32by16r16"> -->
|
||||||
<!-- <item><ref id="imul16x16r32" name="imul16x16r32"> -->
|
<!-- <item><ref id="imul16x16r32" name="imul16x16r32"> -->
|
||||||
<!-- <item><ref id="imul8x8r16" name="imul8x8r16"> -->
|
<!-- <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="udiv32by16r16" name="udiv32by16r16"> -->
|
||||||
<!-- <item><ref id="umul16x16r32" name="umul16x16r32"> -->
|
<!-- <item><ref id="umul16x16r32" name="umul16x16r32"> -->
|
||||||
<!-- <item><ref id="umul16x8r32" name="umul16x8r32"> -->
|
<!-- <item><ref id="umul16x8r32" name="umul16x8r32"> -->
|
||||||
|
|
|
@ -85,12 +85,12 @@ unsigned int __fastcall__ mul40 (unsigned char value);
|
||||||
** result
|
** 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
|
/* 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.
|
** 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
|
/* 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.
|
** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
;
|
;
|
||||||
; Fixed point cosine/sine functions.
|
; Fixed point cosine/sine functions.
|
||||||
;
|
;
|
||||||
; int __fastcall__ cc65_sin (unsigned x);
|
; int __fastcall__ _sin (unsigned x);
|
||||||
; int __fastcall__ cc65_cos (unsigned x);
|
; int __fastcall__ _cos (unsigned x);
|
||||||
;
|
;
|
||||||
; Returns the cosine/sine for the given argument as angular degree.
|
; Returns the cosine/sine for the given argument as angular degree.
|
||||||
; Valid argument range is 0..360 for both functions. They will return
|
; Valid argument range is 0..360 for both functions. They will return
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
; Ullrich von Bassewitz, 2009-10-29
|
; Ullrich von Bassewitz, 2009-10-29
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _cos, _sin
|
.export __cos, __sin
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
@ -37,13 +37,13 @@ _sintab:
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; Cosine function. Is actually implemented as cos(x) = sin(x+90)
|
; Cosine function. Is actually implemented as _cos(x) = _sin(x+90)
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
_cos:
|
__cos:
|
||||||
|
|
||||||
; cos(x) = sin(x+90)
|
; _cos(x) = _sin(x+90)
|
||||||
|
|
||||||
clc
|
clc
|
||||||
adc #90
|
adc #90
|
||||||
|
@ -55,7 +55,7 @@ _cos:
|
||||||
@L1: cpx #>360
|
@L1: cpx #>360
|
||||||
bne @L2
|
bne @L2
|
||||||
cmp #<360
|
cmp #<360
|
||||||
@L2: bcc _sin
|
@L2: bcc __sin
|
||||||
|
|
||||||
sbc #<360
|
sbc #<360
|
||||||
bcs @L3
|
bcs @L3
|
||||||
|
@ -66,12 +66,12 @@ _cos:
|
||||||
; Sine function. Uses
|
; Sine function. Uses
|
||||||
;
|
;
|
||||||
; table lookup for 0..89°
|
; table lookup for 0..89°
|
||||||
; sin(x) = sin(180-x) for 90°..179°
|
; _sin(x) = _sin(180-x) for 90°..179°
|
||||||
; sin(x) = -sin(x-180) for 180..360°
|
; _sin(x) = -_sin(x-180) for 180..360°
|
||||||
;
|
;
|
||||||
; Plus special handling for the values missing in the table.
|
; Plus special handling for the values missing in the table.
|
||||||
|
|
||||||
_sin:
|
__sin:
|
||||||
|
|
||||||
; If the high byte is non zero, argument is > 255
|
; If the high byte is non zero, argument is > 255
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ _sin:
|
||||||
cmp #90
|
cmp #90
|
||||||
bcc L1
|
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.
|
; 180-val := -val + 180.
|
||||||
; With
|
; With
|
||||||
|
@ -117,7 +117,7 @@ L2: tay
|
||||||
lda _sintab,y
|
lda _sintab,y
|
||||||
rts
|
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.
|
; after the subtraction, we don't need to handle the high byte.
|
||||||
|
|
||||||
L3: sec
|
L3: sec
|
||||||
|
@ -126,7 +126,7 @@ L4: sbc #180
|
||||||
cmp #90
|
cmp #90
|
||||||
bcc L5
|
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.
|
; 180-val := -val + 180.
|
||||||
; With
|
; With
|
||||||
|
@ -160,5 +160,3 @@ L6: tay
|
||||||
bcc L7
|
bcc L7
|
||||||
inx
|
inx
|
||||||
L7: rts
|
L7: rts
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,16 +70,16 @@ void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the start coords */
|
/* Calculate the start coords */
|
||||||
x1 = x + tgi_imulround (rx, cos (sa));
|
x1 = x + tgi_imulround (rx, _cos (sa));
|
||||||
y1 = y - tgi_imulround (ry, sin (sa));
|
y1 = y - tgi_imulround (ry, _sin (sa));
|
||||||
do {
|
do {
|
||||||
sa += inc;
|
sa += inc;
|
||||||
if (sa >= ea) {
|
if (sa >= ea) {
|
||||||
sa = ea;
|
sa = ea;
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
x2 = x + tgi_imulround (rx, cos (sa));
|
x2 = x + tgi_imulround (rx, _cos (sa));
|
||||||
y2 = y - tgi_imulround (ry, sin (sa));
|
y2 = y - tgi_imulround (ry, _sin (sa));
|
||||||
tgi_line (x1, y1, x2, y2);
|
tgi_line (x1, y1, x2, y2);
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
|
|
|
@ -57,8 +57,8 @@ void __fastcall__ tgi_pieslice (int x, int y, unsigned char rx, unsigned char ry
|
||||||
tgi_arc (x, y, rx, ry, sa, ea);
|
tgi_arc (x, y, rx, ry, sa, ea);
|
||||||
|
|
||||||
/* ... and close it */
|
/* ... 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 (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 (ea)), y - tgi_imulround (ry, _sin (ea)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ static void DoDiagram (void)
|
||||||
|
|
||||||
/* Calculate the next points */
|
/* Calculate the next points */
|
||||||
X = (int) (((long) (MaxX - 19) * I) / 360);
|
X = (int) (((long) (MaxX - 19) * I) / 360);
|
||||||
Y = (int) (((long) Amp * -sin (I)) / 256);
|
Y = (int) (((long) Amp * -_sin (I)) / 256);
|
||||||
|
|
||||||
/* Draw the line */
|
/* Draw the line */
|
||||||
tgi_lineto (XOrigin + X, YOrigin + Y);
|
tgi_lineto (XOrigin + X, YOrigin + Y);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user