Update tan_FAC1
This commit is contained in:
1 parent
1383c70ddc
commit
85f921a172
4 files changed
+34
-16
No files matched your search
@@ -264,7 +264,7 @@ Floating point mathematical routines - not official, but well known and broadly
|
||||
| `$E0BE` | `rnd_generate` | DONE | |
|
||||
| `$E264` | `cos_FAC1` | DONE | From the Microsoft BASIC, original name: COS |
|
||||
| `$E26B` | `sin_FAC1` | DONE | From the Microsoft BASIC, original name: SIN |
|
||||
| `$E2B4` | `tan_FAC1` | PARTIAL | not fully tested yet |
|
||||
| `$E2B4` | `tan_FAC1` | DONE | From the Microsoft BASIC, original name: TAN |
|
||||
| `$E30E` | `atn_FAC1` | DONE | From the Microsoft BASIC, original name: ATN |
|
||||
|
||||
<br />
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
!addr FORPNT = $49 ; $49-$4A -- NOT IMPLEMENTED --
|
||||
!addr OPPTR = $4B ; $4B-$4C helper variable for expression computation, [!] our usage details are different
|
||||
!addr OPMASK = $4D ; -- NOT IMPLEMENTED --
|
||||
!addr DEFPNT = $4E ; $4E-$4F -- NOT IMPLEMENTED --
|
||||
!addr DEFPNT = $4E ; $4E-$4F
|
||||
!addr TEMPF3 = DEFPNT
|
||||
!addr DSCPNT = $50 ; $50-$52 temporary area fro string handling, [!] our usage might differ
|
||||
!addr FOUR6 = $53 ; size of variable content (float = 5, integer = 2, string descriptor = 3)
|
||||
!addr JMPER = $54 ; $54-$56 -- NOT IMPLEMENTED --
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; This file is under the MIT license, it contains code released by Microsoft Corporation.
|
||||
; See LICENSE for more information.
|
||||
|
||||
; Math package - tangent of FAC1 in radians
|
||||
;
|
||||
; This is verified to be almost identical to the original Microsoft implementation where it was named TAN.
|
||||
; The difference is the optimization of the jsr to mov_r_FAC1_MEM
|
||||
;
|
||||
; See also:
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 210
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
@@ -18,17 +23,28 @@
|
||||
|
||||
|
||||
tan_FAC1:
|
||||
jsr mov_r_FAC1_TMP1 ; TMP1 = x
|
||||
jsr sin_FAC1 ; FAC1 = sin(x)
|
||||
jsr mov_r_FAC1_TMP2 ; TMP2 = sin(x)
|
||||
lda #TEMPF1
|
||||
ldy #0
|
||||
jsr mov_MEM_FAC1 ; FAC1 = x
|
||||
jsr COS ; FAC1 = cos(x)
|
||||
lda #TEMPF2
|
||||
ldy #0
|
||||
jsr mov_MEM_FAC2 ; FAC2 = sin(x)
|
||||
jmp div_FAC2_FAC1 ; FAC1 = tan(x)
|
||||
|
||||
jsr mov_r_FAC1_TMP1 ; Mov FAC1 into temporary
|
||||
lda #$00
|
||||
sta TANSGN ; Remember whether to negate
|
||||
jsr sin_FAC1 ; Compute the sin
|
||||
ldx #<TEMPF3
|
||||
ldy #>TEMPF3
|
||||
jsr mov_r_FAC1_MEM ; In the original BASIC this does jsr GMOVMF that jmps to mov_r_FAC1_MEM
|
||||
lda #<TEMPF1
|
||||
ldy #>TEMPF1
|
||||
jsr mov_MEM_FAC1 ; Put this memory loc into FAC1
|
||||
lda #$00
|
||||
sta FAC1_sign ; Start off positive
|
||||
lda TANSGN
|
||||
jsr COSC ; Compute cosine
|
||||
lda #<TEMPF3 ; Address of sine value
|
||||
ldy #>TEMPF3
|
||||
GFDIV:
|
||||
jmp div_MEM_FAC1 ; Divide sine by cosine and return
|
||||
COSC:
|
||||
pha
|
||||
jmp SIN1
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
+3
-2
@@ -20,7 +20,7 @@ int matches[MAX_SIZE];
|
||||
|
||||
int phase_mask[MAX_SIZE+MAX_SIZE];
|
||||
|
||||
#define NUM_CHUNKS 11
|
||||
#define NUM_CHUNKS 12
|
||||
// Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC
|
||||
unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
|
||||
0xB391, 0xB39D,
|
||||
@@ -32,7 +32,8 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
|
||||
0xBDB3, 0xBDC1,
|
||||
0xBDDD, 0xBF51,
|
||||
0xBFB4, 0xBFEC,
|
||||
0xE264, 0xE2B3,
|
||||
0xE264, 0xE2C2, // Two byte gap here is an optimization
|
||||
0xE2C5, 0xE2DF,
|
||||
0xE2EF, 0xE37A,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user