From 5404a40b128aeb89469b03f0814abe08df2c238b Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Mon, 7 Apr 2025 18:54:06 +0200 Subject: [PATCH 1/2] Set flags correctly at return of FCOMP Flags now directly reflect the results of the comparison --- src/basic/math/FCOMP.s | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/basic/math/FCOMP.s b/src/basic/math/FCOMP.s index 1a754efd..9c38d69d 100644 --- a/src/basic/math/FCOMP.s +++ b/src/basic/math/FCOMP.s @@ -12,7 +12,7 @@ ; ; Output: ; - .A - $00 for equal, $01 for FAC1 > RAM, $FF for FAC1 < RAM -; - flags N/Z, depending on whether FAC1 is 0, positive, or negative +; - flags N/Z, Z=1 if equal, N=1 if FAC1 < RAM, Z=0, N=0 if FAC1 > RAM ; ; Notes: ; - uses vector at $24, leaves FAC1 and FAC2 unchanged (Codebase64) @@ -28,9 +28,6 @@ FCOMP: sta INDEX+2 sty INDEX+3 - jsr sgn_FAC1_A ; Set N/Z flag for FAC1 and store on stack - php - ldy #$01 lda (INDEX+2),Y eor FAC1_sign ; Check if signs are different @@ -69,7 +66,6 @@ FCOMP: FCOMP_equal: lda #$00 - plp rts @@ -78,7 +74,6 @@ FCOMP_less_than: bpl FCOMP_FF FCOMP_01: lda #$01 - plp rts FCOMP_greater_than: @@ -86,5 +81,4 @@ FCOMP_greater_than: bpl FCOMP_01 FCOMP_FF: lda #$FF - plp rts From db9af4c19ea3ab10a3bb435c95b98b1541797098 Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Mon, 7 Apr 2025 18:58:43 +0200 Subject: [PATCH 2/2] Add sin_FAC1 --- STATUS.md | 4 +- src/basic/,stubs_math/e26b.sin_FAC1.s | 29 ----------- src/basic/{,stubs_math => math}/e26b.interop | 0 src/basic/math/e26b.sin_FAC1.s | 55 ++++++++++++++++++++ src/basic/math/poly_sin.s | 23 ++++++++ strings/85248425A0 | 3 ++ 6 files changed, 83 insertions(+), 31 deletions(-) delete mode 100644 src/basic/,stubs_math/e26b.sin_FAC1.s rename src/basic/{,stubs_math => math}/e26b.interop (100%) create mode 100644 src/basic/math/e26b.sin_FAC1.s create mode 100644 src/basic/math/poly_sin.s create mode 100644 strings/85248425A0 diff --git a/STATUS.md b/STATUS.md index 53bab291..408f61ae 100644 --- a/STATUS.md +++ b/STATUS.md @@ -253,8 +253,8 @@ Floating point mathematical routines - not official, but well known and broadly | `$E097` | `rnd_FAC1` | DONE | | | `$E09A` | `rnd_A` | DONE | | | `$E0BE` | `rnd_generate` | DONE | | -| `$E264` | `cos_FAC1` | PARTIAL | needs `sin_FAC1` | -| `$E26B` | `sin_FAC1` | NOT DONE | some work already started | +| `$E264` | `cos_FAC1` | PARTIAL | not fully tested yet | +| `$E26B` | `sin_FAC1` | PARTIAL | not fully tested yet | | `$E2B4` | `tan_FAC1` | NOT DONE | | | `$E30E` | `atn_FAC1` | NOT DONE | | diff --git a/src/basic/,stubs_math/e26b.sin_FAC1.s b/src/basic/,stubs_math/e26b.sin_FAC1.s deleted file mode 100644 index f1f2f340..00000000 --- a/src/basic/,stubs_math/e26b.sin_FAC1.s +++ /dev/null @@ -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 diff --git a/src/basic/,stubs_math/e26b.interop b/src/basic/math/e26b.interop similarity index 100% rename from src/basic/,stubs_math/e26b.interop rename to src/basic/math/e26b.interop diff --git a/src/basic/math/e26b.sin_FAC1.s b/src/basic/math/e26b.sin_FAC1.s new file mode 100644 index 00000000..65c48f0f --- /dev/null +++ b/src/basic/math/e26b.sin_FAC1.s @@ -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_QUARTER + lda #sin_three_quarters + lda #const_ONE + lda #const_HALF + lda #poly_sin + lda #