Added fixpoint sine and cosine functions.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4399 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2009-10-29 23:19:00 +00:00
parent 50c1db0331
commit 7d453f5e11
4 changed files with 188 additions and 0 deletions

48
libsrc/common/cc65_cos.s Normal file
View File

@@ -0,0 +1,48 @@
;
; Fixed point cosine function.
;
; Returns the cosine for the given argument as angular degree.
; Valid argument range is 0..360
;
;
; Ullrich von Bassewitz, 2009-10-29
;
.export _cc65_cos
.import _cc65_sin
; ---------------------------------------------------------------------------
;
.code
.proc _cc65_cos
; cos(x) = sin(x+90)
clc
adc #90
bcc L1
inx
; If x is now larger than 360, we need to subtract 360.
L1: cpx #>360
bne L2
cmp #<360
L2: bcc L4
sbc #<360
bcs L3
dex
L3: dex
L4: jmp _cc65_sin
.endproc