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:
48
libsrc/common/cc65_cos.s
Normal file
48
libsrc/common/cc65_cos.s
Normal 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user