Add sin_FAC1
This commit is contained in:
1 parent
5404a40b12
commit
db9af4c19e
6 files changed
+83
-31
No files matched your search
@@ -253,8 +253,8 @@ Floating point mathematical routines - not official, but well known and broadly
|
|||||||
| `$E097` | `rnd_FAC1` | DONE | |
|
| `$E097` | `rnd_FAC1` | DONE | |
|
||||||
| `$E09A` | `rnd_A` | DONE | |
|
| `$E09A` | `rnd_A` | DONE | |
|
||||||
| `$E0BE` | `rnd_generate` | DONE | |
|
| `$E0BE` | `rnd_generate` | DONE | |
|
||||||
| `$E264` | `cos_FAC1` | PARTIAL | needs `sin_FAC1` |
|
| `$E264` | `cos_FAC1` | PARTIAL | not fully tested yet |
|
||||||
| `$E26B` | `sin_FAC1` | NOT DONE | some work already started |
|
| `$E26B` | `sin_FAC1` | PARTIAL | not fully tested yet |
|
||||||
| `$E2B4` | `tan_FAC1` | NOT DONE | |
|
| `$E2B4` | `tan_FAC1` | NOT DONE | |
|
||||||
| `$E30E` | `atn_FAC1` | NOT DONE | |
|
| `$E30E` | `atn_FAC1` | NOT DONE | |
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
;; #LAYOUT# STD * #TAKE
|
|
||||||
;; #LAYOUT# * BASIC_0 #TAKE
|
|
||||||
;; #LAYOUT# * * #IGNORE
|
|
||||||
|
|
||||||
;
|
|
||||||
; Math package - sine of FAC1 in radians
|
|
||||||
;
|
|
||||||
; See also:
|
|
||||||
; - [CM64] Computes Mapping the Commodore 64 - page 210 - XXX address does not match
|
|
||||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
|
||||||
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
|
||||||
;
|
|
||||||
|
|
||||||
; XXX provide implementation
|
|
||||||
|
|
||||||
sin_FAC1:
|
|
||||||
|
|
||||||
+STUB_IMPLEMENTATION
|
|
||||||
|
|
||||||
poly_sin:
|
|
||||||
|
|
||||||
!byte $05 ; series length - 1
|
|
||||||
|
|
||||||
+PUT_CONST_POLY_SIN_1
|
|
||||||
+PUT_CONST_POLY_SIN_2
|
|
||||||
+PUT_CONST_POLY_SIN_3
|
|
||||||
+PUT_CONST_POLY_SIN_4
|
|
||||||
+PUT_CONST_POLY_SIN_5
|
|
||||||
+PUT_CONST_POLY_SIN_6
|
|
||||||
File renamed without changes.
@@ -0,0 +1,55 @@
|
|||||||
|
;; #LAYOUT# STD * #TAKE
|
||||||
|
;; #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
;; #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
;
|
||||||
|
; Math package - sine of FAC1 in radians
|
||||||
|
;
|
||||||
|
; See also:
|
||||||
|
; - [CM64] Computes Mapping the Commodore 64 - page 210 - XXX address does not match
|
||||||
|
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||||
|
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||||
|
; - https://www.c64-wiki.com/wiki/SIN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sin_FAC1:
|
||||||
|
|
||||||
|
jsr mov_FAC1_FAC2 ; FAC1 <- X / (2*pi) (X2)
|
||||||
|
ldy #>const_DOUBLE_PI
|
||||||
|
lda #<const_DOUBLE_PI
|
||||||
|
jsr mov_MEM_FAC1
|
||||||
|
jsr div_FAC2_FAC1
|
||||||
|
|
||||||
|
jsr mov_FAC1_FAC2 ; FAC2 <- X2
|
||||||
|
jsr int_FAC1 ; FAC1 <- INT(X2)
|
||||||
|
jsr sub_FAC2_FAC1 ; FAC1 <- X2 - INT(X2) (F)
|
||||||
|
|
||||||
|
ldy #>const_QUARTER
|
||||||
|
lda #<const_QUARTER
|
||||||
|
jsr FCOMP
|
||||||
|
bmi sin_next ; FAC1 < 0.25
|
||||||
|
|
||||||
|
ldy #>sin_three_quarters
|
||||||
|
lda #<sin_three_quarters
|
||||||
|
jsr FCOMP
|
||||||
|
bmi sin_q23 ; FAC1 < 0.75
|
||||||
|
|
||||||
|
jsr mov_FAC1_FAC2 ; FAC1 <- FAC1 - 1.0
|
||||||
|
ldy #>const_ONE
|
||||||
|
lda #<const_ONE
|
||||||
|
jsr mov_MEM_FAC1
|
||||||
|
jsr sub_FAC2_FAC1
|
||||||
|
+bra sin_next
|
||||||
|
|
||||||
|
sin_q23:
|
||||||
|
ldy #>const_HALF
|
||||||
|
lda #<const_HALF
|
||||||
|
jsr sub_MEM_FAC1 ; FAC1 <- 0.5 - FAC1
|
||||||
|
|
||||||
|
; FALLTHROUGH
|
||||||
|
|
||||||
|
sin_next:
|
||||||
|
ldy #>poly_sin
|
||||||
|
lda #<poly_sin
|
||||||
|
jmp poly1_FAC1
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
;; #LAYOUT# STD * #TAKE
|
||||||
|
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
||||||
|
;; #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
;; #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
; Polynomial for the sine function
|
||||||
|
|
||||||
|
|
||||||
|
poly_sin:
|
||||||
|
|
||||||
|
!byte $05 ; series length - 1
|
||||||
|
|
||||||
|
+PUT_CONST_POLY_SIN_1
|
||||||
|
+PUT_CONST_POLY_SIN_2
|
||||||
|
+PUT_CONST_POLY_SIN_3
|
||||||
|
+PUT_CONST_POLY_SIN_4
|
||||||
|
+PUT_CONST_POLY_SIN_5
|
||||||
|
+PUT_CONST_POLY_SIN_6
|
||||||
|
|
||||||
|
|
||||||
|
; Constant 0.75 needed for sine calculation
|
||||||
|
sin_three_quarters:
|
||||||
|
!byte $80, $40, $00, $00, $00
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
STA $24 + STY $25 + LDY fragment
|
||||||
|
|
||||||
|
Store YA to well known vector address in the zero page
|
||||||
Reference in new issue
Block a user