mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 17:29:50 +00:00
7d453f5e11
git-svn-id: svn://svn.cc65.org/cc65/trunk@4399 b7a2c559-68d2-44c3-8de9-860c34a00d81
49 lines
693 B
ArmAsm
49 lines
693 B
ArmAsm
;
|
|
; 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
|
|
|
|
|