From 99e5e26c7b220dc4c068e8724cbc8559076e7799 Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Sat, 29 Mar 2025 15:00:00 +0100 Subject: [PATCH] Add the polynomial used by exp --- src/,,config_testing_38K.s | 2 +- src/basic/math/poly_exp.s | 19 +++++++++++++++++++ ...2A7C6359580A7E75FDE7C680317218108100000000 | 1 + tools/generate_constants.cc | 11 +++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/basic/math/poly_exp.s create mode 100644 strings/077134583E5674167EB31B772FEEE3857A1D841C2A7C6359580A7E75FDE7C680317218108100000000 diff --git a/src/,,config_testing_38K.s b/src/,,config_testing_38K.s index 38d0a9f5..3371fb6e 100644 --- a/src/,,config_testing_38K.s +++ b/src/,,config_testing_38K.s @@ -97,7 +97,7 @@ ; --- Software features ;; #CONFIG# PANIC_SCREEN YES -;; #CONFIG# DOS_WEDGE YES +;; #CONFIG# DOS_WEDGE NO ;; #CONFIG# TAPE_WEDGE YES ;; #CONFIG# TAPE_HEAD_ALIGN NO ;; #CONFIG# BCD_SAFE_INTERRUPTS YES diff --git a/src/basic/math/poly_exp.s b/src/basic/math/poly_exp.s new file mode 100644 index 00000000..5ee89256 --- /dev/null +++ b/src/basic/math/poly_exp.s @@ -0,0 +1,19 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE + +; Polynomial for the exponential function + +poly_exp: + + !byte $07 ; series length - 1 + + +PUT_CONST_POLY_EXP_1 + +PUT_CONST_POLY_EXP_2 + +PUT_CONST_POLY_EXP_3 + +PUT_CONST_POLY_EXP_4 + +PUT_CONST_POLY_EXP_5 + +PUT_CONST_POLY_EXP_6 + +PUT_CONST_POLY_EXP_7 + +PUT_CONST_POLY_EXP_8 diff --git a/strings/077134583E5674167EB31B772FEEE3857A1D841C2A7C6359580A7E75FDE7C680317218108100000000 b/strings/077134583E5674167EB31B772FEEE3857A1D841C2A7C6359580A7E75FDE7C680317218108100000000 new file mode 100644 index 00000000..956b67e0 --- /dev/null +++ b/strings/077134583E5674167EB31B772FEEE3857A1D841C2A7C6359580A7E75FDE7C680317218108100000000 @@ -0,0 +1 @@ +This is the polyonmial for the exponential function. According to https://www.c64-wiki.com/wiki/POLY1 this was most likely taken from the book "Computer Approximations" by John Fraser Hart et al. (ISBN 0-88275-642-7). This is then a well known polynomial. diff --git a/tools/generate_constants.cc b/tools/generate_constants.cc index b021da2c..c9a4a7e4 100644 --- a/tools/generate_constants.cc +++ b/tools/generate_constants.cc @@ -67,6 +67,17 @@ std::vector GLOBAL_constants = ConstEntry( "POLY_SIN_4", 0.00833332926445715285723741015926085083 ), ConstEntry( "POLY_SIN_5", -0.166666665414391662957238076832950332 ), ConstEntry( "POLY_SIN_6", 0.99999999988985190065414932682350994 ), + + // Constants for exp approximation, taken from https://www.c64-wiki.com/wiki/POLY1 + // original source is probably "Computer Approximations" by John Fraser Hart et al. (ISBN 0-88275-642-7) + ConstEntry( "POLY_EXP_1", 2.1498763701e-5 ), + ConstEntry( "POLY_EXP_2", 1.4352314037e-4 ), + ConstEntry( "POLY_EXP_3", 1.3422634825e-3 ), + ConstEntry( "POLY_EXP_4", 9.6140170135e-3 ), + ConstEntry( "POLY_EXP_5", 5.5505126860e-2 ), + ConstEntry( "POLY_EXP_6", 0.24022638460 ), + ConstEntry( "POLY_EXP_7", 0.69314718618 ), + ConstEntry( "POLY_EXP_8", 1.0 ), }; //