From 113b3cf7c28904f7cbfa46c4e2424e0835d31e49 Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Tue, 14 Apr 2026 19:28:50 +0200 Subject: [PATCH] Update cos_FAC1 --- STATUS.md | 2 +- src/basic/math_trans/e264.cos_FAC1.s | 11 ++++++++--- tools/similarity.c | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/STATUS.md b/STATUS.md index da4fea08..421b706d 100644 --- a/STATUS.md +++ b/STATUS.md @@ -262,7 +262,7 @@ 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 | not fully tested yet | +| `$E264` | `cos_FAC1` | DONE | From the Microsoft BASIC, original name: COS | | `$E26B` | `sin_FAC1` | PARTIAL | not fully tested yet | | `$E2B4` | `tan_FAC1` | PARTIAL | not fully tested yet | | `$E30E` | `atn_FAC1` | DONE | From the Microsoft BASIC, original name: ATN | diff --git a/src/basic/math_trans/e264.cos_FAC1.s b/src/basic/math_trans/e264.cos_FAC1.s index 9376777b..d6f940ee 100644 --- a/src/basic/math_trans/e264.cos_FAC1.s +++ b/src/basic/math_trans/e264.cos_FAC1.s @@ -2,9 +2,13 @@ ;; #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 - cosine of FAC1 in radians ; +; This is verified to be identical to the original Microsoft implementation where it was named COS +; ; Adds pi/2 to FAC1 and falls through to the sine function ; ; See also: @@ -18,10 +22,11 @@ COS: - ldy #>const_HALF_PI + lda #const_HALF_PI jsr add_MEM_FAC1 - + ; FALLTHROUGH to SIN diff --git a/tools/similarity.c b/tools/similarity.c index e304bede..b32a2c70 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -20,7 +20,7 @@ int matches[MAX_SIZE]; int phase_mask[MAX_SIZE+MAX_SIZE]; -#define NUM_CHUNKS 10 +#define NUM_CHUNKS 11 // 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,6 +32,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { 0xBDB3, 0xBDC1, 0xBDDD, 0xBF51, 0xBFB4, 0xBFEC, + 0xE264, 0xE26A, 0xE30E, 0xE37A, };