aboutsummaryrefslogtreecommitdiff
path: root/include/byte_math.h
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-12-03 10:35:55 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-12-03 10:35:55 -0700
commitf5e15a5a2d55cf0a6fbdbe04e5c49499a6eac642 (patch)
treed9f570c228268dfa0ecc31ad15579d412b953a6f /include/byte_math.h
parenta15656b399689d0c7b12963a718729bea9b6dfcc (diff)
downloadch573-f5e15a5a2d55cf0a6fbdbe04e5c49499a6eac642.tar.gz
ch573-f5e15a5a2d55cf0a6fbdbe04e5c49499a6eac642.tar.bz2
ch573-f5e15a5a2d55cf0a6fbdbe04e5c49499a6eac642.zip
Basic Christmas light implementation!
Diffstat (limited to 'include/byte_math.h')
-rw-r--r--include/byte_math.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/byte_math.h b/include/byte_math.h
new file mode 100644
index 0000000..79f93b8
--- /dev/null
+++ b/include/byte_math.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <stdint.h>
+
+/* Library for doing fast math functions using just uint8_t. */
+
+extern uint8_t sintable[256];
+
+/* Returns ((sin(n) + 1) / 2) * 255 */
+static inline uint8_t byte_sin(uint8_t n)
+{
+ return sintable[n];
+}
+
+uint8_t calc_w(uint8_t n);