diff --git a/Makefile b/Makefile
index ca6fc45f..02103bbd 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,7 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \
c64/basic/commands \
c64/basic/init \
c64/basic/math \
+ c64/basic/math_consts \
c64/basic/rom_revision
SRCDIR_KERNAL = $(SRCDIR_COMMON) \
diff --git a/STATUS.md b/STATUS.md
index 328b8215..f9c5439f 100644
--- a/STATUS.md
+++ b/STATUS.md
@@ -225,6 +225,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 |
+
+
### Other unofficial BASIC routines/locations
Not all of them - only these we want to have implemented.
diff --git a/c64/basic/math_consts/aea8.const_PI.s b/c64/basic/math_consts/aea8.const_PI.s
new file mode 100644
index 00000000..c5d79808
--- /dev/null
+++ b/c64/basic/math_consts/aea8.const_PI.s
@@ -0,0 +1,13 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+// - Computes Mapping the Commodore 64, page 103
+//
+
+const_PI:
+
+ put_const_PI()
diff --git a/c64/basic/math_consts/aea8.interop b/c64/basic/math_consts/aea8.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/aea8.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/b1a5.const_NEG_32768.s b/c64/basic/math_consts/b1a5.const_NEG_32768.s
new file mode 100644
index 00000000..2319be90
--- /dev/null
+++ b/c64/basic/math_consts/b1a5.const_NEG_32768.s
@@ -0,0 +1,13 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+// - Computes Mapping the Commodore 64, page 105
+//
+
+CONST_NEG_32768:
+
+ put_const_NEG_32768()
diff --git a/c64/basic/math_consts/b1a5.interop b/c64/basic/math_consts/b1a5.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/b1a5.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/b9bc.const_ONE.s b/c64/basic/math_consts/b9bc.const_ONE.s
new file mode 100644
index 00000000..63e4eab9
--- /dev/null
+++ b/c64/basic/math_consts/b9bc.const_ONE.s
@@ -0,0 +1,13 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+// - Computes Mapping the Commodore 64, page 113
+//
+
+const_ONE:
+
+ put_const_ONE()
diff --git a/c64/basic/math_consts/b9bc.interop b/c64/basic/math_consts/b9bc.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/b9bc.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/b9d6.const_INV_SQR_2.s b/c64/basic/math_consts/b9d6.const_INV_SQR_2.s
new file mode 100644
index 00000000..2bd0db76
--- /dev/null
+++ b/c64/basic/math_consts/b9d6.const_INV_SQR_2.s
@@ -0,0 +1,12 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+//
+
+const_INV_SQR_2:
+
+ put_const_INV_SQR_2()
diff --git a/c64/basic/math_consts/b9d6.interop b/c64/basic/math_consts/b9d6.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/b9d6.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/b9db.const_SQR_2.s b/c64/basic/math_consts/b9db.const_SQR_2.s
new file mode 100644
index 00000000..7a4d3def
--- /dev/null
+++ b/c64/basic/math_consts/b9db.const_SQR_2.s
@@ -0,0 +1,12 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+//
+
+const_SQR_2:
+
+ put_const_SQR_2()
diff --git a/c64/basic/math_consts/b9db.interop b/c64/basic/math_consts/b9db.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/b9db.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/b9e0.const_NEG_HALF.s b/c64/basic/math_consts/b9e0.const_NEG_HALF.s
new file mode 100644
index 00000000..08ad27d2
--- /dev/null
+++ b/c64/basic/math_consts/b9e0.const_NEG_HALF.s
@@ -0,0 +1,12 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+//
+
+const_NEG_HALF:
+
+ put_const_NEG_HALF()
diff --git a/c64/basic/math_consts/b9e0.interop b/c64/basic/math_consts/b9e0.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/b9e0.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/b9e5.const_LOG_2.s b/c64/basic/math_consts/b9e5.const_LOG_2.s
new file mode 100644
index 00000000..1d9286a7
--- /dev/null
+++ b/c64/basic/math_consts/b9e5.const_LOG_2.s
@@ -0,0 +1,12 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+//
+
+const_LOG_2:
+
+ put_const_LOG_2()
diff --git a/c64/basic/math_consts/b9e5.interop b/c64/basic/math_consts/b9e5.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/b9e5.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/baf9.const_TEN.s b/c64/basic/math_consts/baf9.const_TEN.s
new file mode 100644
index 00000000..65c8b61b
--- /dev/null
+++ b/c64/basic/math_consts/baf9.const_TEN.s
@@ -0,0 +1,13 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+// - Computes Mapping the Commodore 64, page 114
+//
+
+const_TEN:
+
+ put_const_TEN()
diff --git a/c64/basic/math_consts/baf9.interop b/c64/basic/math_consts/baf9.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/baf9.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/bf11.const_HALF.s b/c64/basic/math_consts/bf11.const_HALF.s
new file mode 100644
index 00000000..8574ee8b
--- /dev/null
+++ b/c64/basic/math_consts/bf11.const_HALF.s
@@ -0,0 +1,13 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+// - Computes Mapping the Commodore 64, page 116
+//
+
+const_HALF:
+
+ put_const_HALF()
diff --git a/c64/basic/math_consts/bf11.interop b/c64/basic/math_consts/bf11.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/bf11.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/bfbf.const_INV_LOG_2.s b/c64/basic/math_consts/bfbf.const_INV_LOG_2.s
new file mode 100644
index 00000000..78cf4362
--- /dev/null
+++ b/c64/basic/math_consts/bfbf.const_INV_LOG_2.s
@@ -0,0 +1,12 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+//
+
+const_INV_LOG_2:
+
+ put_const_INV_LOG_2()
diff --git a/c64/basic/math_consts/bfbf.interop b/c64/basic/math_consts/bfbf.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/bfbf.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/bfe8.const_ONE.s b/c64/basic/math_consts/bfe8.const_ONE.s
new file mode 100644
index 00000000..1f7dab4c
--- /dev/null
+++ b/c64/basic/math_consts/bfe8.const_ONE.s
@@ -0,0 +1,10 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Math package - a constant, for documentation see:
+// - https://www.c64-wiki.com/wiki/BASIC-ROM
+//
+
+ put_const_ONE() // duplicated constant - no label
diff --git a/c64/basic/math_consts/bfe8.interop b/c64/basic/math_consts/bfe8.interop
new file mode 100644
index 00000000..cdf8d0e7
--- /dev/null
+++ b/c64/basic/math_consts/bfe8.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/src/generate_constants.cc b/src/generate_constants.cc
index d6a959aa..b9a11a45 100644
--- a/src/generate_constants.cc
+++ b/src/generate_constants.cc
@@ -43,17 +43,17 @@ std::vector GLOBAL_constants =
// - https://www.c64-wiki.com/wiki/BASIC-ROM
// Computes Mapping the Commodore 64, pages 103, 105, 113, 114, 116
- ConstEntry( "HALF", 0.5 ),
- ConstEntry( "MINUS_HALF", -0.5 ),
- ConstEntry( "1", 1.0 ),
- ConstEntry( "10", 10.0 ),
- ConstEntry( "N32768", -32768.0 ),
+ ConstEntry( "HALF", 0.5 ),
+ ConstEntry( "NEG_HALF", -0.5 ),
+ ConstEntry( "ONE", 1.0 ),
+ ConstEntry( "TEN", 10.0 ),
+ ConstEntry( "NEG_32768", -32768.0 ),
- ConstEntry( "PI", M_PI ),
- ConstEntry( "SQR_2", std::sqrt(2.0) ),
- ConstEntry( "1_OVER_SQR_2", 1.0 / std::sqrt(2.0) ),
- ConstEntry( "LOG_2", std::log(2.0) ),
- ConstEntry( "1_OVER_LOG_2", 1.0 / std::log(2.0) ),
+ ConstEntry( "PI", M_PI ),
+ ConstEntry( "SQR_2", std::sqrt(2.0) ),
+ ConstEntry( "INV_SQR_2", 1.0 / std::sqrt(2.0) ),
+ ConstEntry( "LOG_2", std::log(2.0) ),
+ ConstEntry( "INV_LOG_2", 1.0 / std::log(2.0) ),
};
//
@@ -189,7 +189,7 @@ std::string toAssemblerString(const std::string &constName, double constValue)
outFloat[4],
constValue);
- std::string outDef = std::string("\n.macro putConst_") + constName + "()\n{\n\t.byte " + buf + "\n}\n";
+ std::string outDef = std::string("\n.macro put_const_") + constName + "()\n{\n\t.byte " + buf + "\n}\n";
return outDef;
}