diff --git a/src/basic/math_consts/aea8.const_PI.s b/src/basic/math_consts/aea8.const_PI.s index cd7dd5b6..d8ad3b46 100644 --- a/src/basic/math_consts/aea8.const_PI.s +++ b/src/basic/math_consts/aea8.const_PI.s @@ -3,12 +3,23 @@ ;; #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 - The floating point constant PI +; +; This is verified to be identical to the original Microsoft implementation where it was named PIVAL. ; -; Math package - a constant, for documentation see: ; - https://www.c64-wiki.com/wiki/BASIC-ROM ; - Computes Mapping the Commodore 64, page 103 ; const_PI: +; The original BASIC didn't have the most accurate PI. + +!ifdef CONFIG_ORIGINAL_UNPATCHED_BASIC { + +PUT_CONST_PI_MS +} else { +PUT_CONST_PI +} diff --git a/tools/generate_constants.cc b/tools/generate_constants.cc index a3023eef..eea5c723 100644 --- a/tools/generate_constants.cc +++ b/tools/generate_constants.cc @@ -52,6 +52,8 @@ std::vector GLOBAL_constants = ConstEntry( "HALF_PI", M_PI / 2.0 ), ConstEntry( "PI", M_PI ), + ConstEntry( "PI_MS", 3.1415926529 ), // This is the value of PI used in the Microsoft BASIC. It is only the third closest approximation + ConstEntry( "DOUBLE_PI", M_PI * 2.0 ), ConstEntry( "SQR_2", std::sqrt(2.0) ), ConstEntry( "INV_SQR_2", 1.0 / std::sqrt(2.0) ), diff --git a/tools/similarity.c b/tools/similarity.c index 38ba35ea..e5c56e41 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -20,9 +20,10 @@ int matches[MAX_SIZE]; int phase_mask[MAX_SIZE+MAX_SIZE]; -#define NUM_CHUNKS 13 +#define NUM_CHUNKS 14 // Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { + 0xAEA8, 0xAEAC, 0xB248, 0xB24C, 0xB391, 0xB39D, 0xB3A2, 0xB3A5,