From: Oliver Schmidt
Date: Sat, 13 Apr 2019 09:25:54 +0000 (+0200)
Subject: Added '_' prefix to sin and cos.
X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ac0b452834265d7f4287e9d6e10f2631fbd66dd0;p=cc65
Added '_' prefix to sin and cos.
Users complained that otherwise the names might clash with their functions.
---
diff --git a/doc/funcref.sgml b/doc/funcref.sgml
index 89a8eb13c..030c726cc 100644
--- a/doc/funcref.sgml
+++ b/doc/funcref.sgml
@@ -244,11 +244,11 @@ function.
-
+
-
+
diff --git a/include/cc65.h b/include/cc65.h
index a30bad247..7e9c2cae2 100644
--- a/include/cc65.h
+++ b/include/cc65.h
@@ -85,12 +85,12 @@ unsigned int __fastcall__ mul40 (unsigned char value);
** 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.
*/
diff --git a/libsrc/common/sincos.s b/libsrc/common/sincos.s
index 7cdcb7167..6bbc151f4 100644
--- a/libsrc/common/sincos.s
+++ b/libsrc/common/sincos.s
@@ -1,8 +1,8 @@
;
; 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
@@ -13,7 +13,7 @@
; 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
-_cos:
+__cos:
-; cos(x) = sin(x+90)
+; _cos(x) = _sin(x+90)
clc
adc #90
@@ -55,7 +55,7 @@ _cos:
@L1: cpx #>360
bne @L2
cmp #<360
-@L2: bcc _sin
+@L2: bcc __sin
sbc #<360
bcs @L3
@@ -66,12 +66,12 @@ _cos:
; 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
@@ -85,7 +85,7 @@ _sin:
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
@@ -117,7 +117,7 @@ L2: tay
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
@@ -126,7 +126,7 @@ L4: sbc #180
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
@@ -160,5 +160,3 @@ L6: tay
bcc L7
inx
L7: rts
-
-
diff --git a/libsrc/tgi/tgi_arc.c b/libsrc/tgi/tgi_arc.c
index 94cc593ce..c0baabbde 100644
--- a/libsrc/tgi/tgi_arc.c
+++ b/libsrc/tgi/tgi_arc.c
@@ -70,16 +70,16 @@ void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
}
/* 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;
diff --git a/libsrc/tgi/tgi_pieslice.c b/libsrc/tgi/tgi_pieslice.c
index b119b9b2d..748d1819a 100644
--- a/libsrc/tgi/tgi_pieslice.c
+++ b/libsrc/tgi/tgi_pieslice.c
@@ -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);
/* ... 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)));
}
diff --git a/samples/tgidemo.c b/samples/tgidemo.c
index 1d76fee2e..de743314e 100644
--- a/samples/tgidemo.c
+++ b/samples/tgidemo.c
@@ -151,7 +151,7 @@ static void DoDiagram (void)
/* 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);