From 9b94f30f98a320bdf37ff94172628f5e4573dea1 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 5 Feb 2020 19:37:45 +0100 Subject: [PATCH] some more floating point constants --- STATUS.md | 31 +++++++++++--------- c64/basic/math_consts/e2e0.const_HALF_PI.s | 12 ++++++++ c64/basic/math_consts/e2e0.interop | 1 + c64/basic/math_consts/e2e5.const_DOUBLE_PI.s | 12 ++++++++ c64/basic/math_consts/e2e5.interop | 1 + c64/basic/math_consts/e2ea.const_QUARTER.s | 12 ++++++++ c64/basic/math_consts/e2ea.interop | 1 + c64/basic/math_consts/e309.const_DOUBLE_PI.s | 10 +++++++ c64/basic/math_consts/e309.interop | 1 + tools/generate_constants.cc | 3 ++ 10 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 c64/basic/math_consts/e2e0.const_HALF_PI.s create mode 100644 c64/basic/math_consts/e2e0.interop create mode 100644 c64/basic/math_consts/e2e5.const_DOUBLE_PI.s create mode 100644 c64/basic/math_consts/e2e5.interop create mode 100644 c64/basic/math_consts/e2ea.const_QUARTER.s create mode 100644 c64/basic/math_consts/e2ea.interop create mode 100644 c64/basic/math_consts/e309.const_DOUBLE_PI.s create mode 100644 c64/basic/math_consts/e309.interop diff --git a/STATUS.md b/STATUS.md index 33459a52..ddd0274d 100644 --- a/STATUS.md +++ b/STATUS.md @@ -243,20 +243,23 @@ Floating point mathematical routines - not official, but well known and broadly In addition to the routines, the following floating-number constants are available at their original locations: -| Address | Name | Status | Remarks | -| :-------: | :-------------------- | :------: | :------------------------------------------------: | -| `$AEA8` | `const_PI` | DONE | π | -| `$B1A5` | `const_NEG_32768` | DONE | -32768 | -| `$B9BC` | `const_ONE` | DONE | 1.0 | -| `$B9D6` | `const_INV_SQR_2` | DONE | 1 / sqr(2) | -| `$B9DB` | `const_SQR_2` | DONE | sqr(2) | -| `$B9E0` | `const_NEG_HALF` | DONE | -0.5 | -| `$B9E5` | `const_LOG_2` | DONE | log_e(2) | -| `$BAF9` | `const_TEN` | DONE | 10.0 | -| `$BF11` | `const_HALF` | DONE | 0.5 | -| `$BFBF` | `const_INV_LOG_2` | DONE | 1 / log_e(2) | -| `$BFE8` | `const_ONE` duplicate | DONE | 1.0 | - +| Address | Name | Status | Remarks | +| :-------: | :-------------------------- | :------: | :-------------------------------------------: | +| `$AEA8` | `const_PI` | DONE | π | +| `$B1A5` | `const_NEG_32768` | DONE | -32768 | +| `$B9BC` | `const_ONE` | DONE | 1.0 | +| `$B9D6` | `const_INV_SQR_2` | DONE | 1.0 / sqr(2.0) | +| `$B9DB` | `const_SQR_2` | DONE | sqr(2.0) | +| `$B9E0` | `const_NEG_HALF` | DONE | -0.5 | +| `$B9E5` | `const_LOG_2` | DONE | log_e(2.0) | +| `$BAF9` | `const_TEN` | DONE | 10.0 | +| `$BF11` | `const_HALF` | DONE | 0.5 | +| `$BFBF` | `const_INV_LOG_2` | DONE | 1.0 / log_e(2.0) | +| `$BFE8` | `const_ONE` duplicate | DONE | 1.0 | +| `$E2E0` | `const_HALF_PI` | DONE | PI / 2.0 | +| `$E2E5` | `const_DOUBLE_PI` | DONE | PI * 2.0 | +| `$E2EA` | `const_QUARTER` | DONE | 0.25 | +| `$E309` | `const_DOUBLE_PI` duplicate | DONE | PI * 2.0 | ### Other unofficial BASIC routines/locations diff --git a/c64/basic/math_consts/e2e0.const_HALF_PI.s b/c64/basic/math_consts/e2e0.const_HALF_PI.s new file mode 100644 index 00000000..a75efb68 --- /dev/null +++ b/c64/basic/math_consts/e2e0.const_HALF_PI.s @@ -0,0 +1,12 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - a constant, for documentation see: +// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +// + +const_HALF_PI: + + put_const_HALF_PI() diff --git a/c64/basic/math_consts/e2e0.interop b/c64/basic/math_consts/e2e0.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e2e0.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/e2e5.const_DOUBLE_PI.s b/c64/basic/math_consts/e2e5.const_DOUBLE_PI.s new file mode 100644 index 00000000..f8728ef7 --- /dev/null +++ b/c64/basic/math_consts/e2e5.const_DOUBLE_PI.s @@ -0,0 +1,12 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - a constant, for documentation see: +// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +// + +const_DOUBLE_PI: + + put_const_DOUBLE_PI() diff --git a/c64/basic/math_consts/e2e5.interop b/c64/basic/math_consts/e2e5.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e2e5.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/e2ea.const_QUARTER.s b/c64/basic/math_consts/e2ea.const_QUARTER.s new file mode 100644 index 00000000..77962d8a --- /dev/null +++ b/c64/basic/math_consts/e2ea.const_QUARTER.s @@ -0,0 +1,12 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - a constant, for documentation see: +// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +// + +const_QUARTER: + + put_const_QUARTER() \ No newline at end of file diff --git a/c64/basic/math_consts/e2ea.interop b/c64/basic/math_consts/e2ea.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e2ea.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/e309.const_DOUBLE_PI.s b/c64/basic/math_consts/e309.const_DOUBLE_PI.s new file mode 100644 index 00000000..33a01f1b --- /dev/null +++ b/c64/basic/math_consts/e309.const_DOUBLE_PI.s @@ -0,0 +1,10 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - a constant, for documentation see: +// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +// + + put_const_DOUBLE_PI() // duplicated constant - no label diff --git a/c64/basic/math_consts/e309.interop b/c64/basic/math_consts/e309.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e309.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/tools/generate_constants.cc b/tools/generate_constants.cc index b9a11a45..6d27caed 100644 --- a/tools/generate_constants.cc +++ b/tools/generate_constants.cc @@ -43,13 +43,16 @@ std::vector GLOBAL_constants = // - https://www.c64-wiki.com/wiki/BASIC-ROM // Computes Mapping the Commodore 64, pages 103, 105, 113, 114, 116 + ConstEntry( "QUARTER", 0.25 ), ConstEntry( "HALF", 0.5 ), ConstEntry( "NEG_HALF", -0.5 ), ConstEntry( "ONE", 1.0 ), ConstEntry( "TEN", 10.0 ), ConstEntry( "NEG_32768", -32768.0 ), + ConstEntry( "HALF_PI", M_PI / 2.0 ), ConstEntry( "PI", M_PI ), + ConstEntry( "DOUBLE_PI", M_PI * 2.0 ), ConstEntry( "SQR_2", std::sqrt(2.0) ), ConstEntry( "INV_SQR_2", 1.0 / std::sqrt(2.0) ), ConstEntry( "LOG_2", std::log(2.0) ),