summaryrefslogtreecommitdiff
path: root/include/global.h
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2021-06-04 09:10:09 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2021-06-04 09:10:09 -0400
commit75ab879fd876d35eac8498296994278e213b6e7a (patch)
treeb9763615e9771ac5dce777031a80b57b12d9cac2 /include/global.h
parente82080d42bbb81b2add8bef5c073cc353dfea307 (diff)
parent2d3210dc1129e3d60a9d138838dc867d8b106b41 (diff)
Merge remote-tracking branch 'origin/master' into modern_ld
Diffstat (limited to 'include/global.h')
-rw-r--r--include/global.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/global.h b/include/global.h
index 04adc82cb..1d12fdae9 100644
--- a/include/global.h
+++ b/include/global.h
@@ -45,9 +45,27 @@
// Converts a number to Q8.8 fixed-point format
#define Q_8_8(n) ((s16)((n) * 256))
+// Converts a number from Q8.8 fixed-point format
+#define Q_8_8_TO_INT(n) ((s16)((n) >> 8))
+
// Converts a number to Q4.12 fixed-point format
#define Q_4_12(n) ((s16)((n) * 4096))
+// Converts a number from Q4.12 fixed-point format
+#define Q_4_12_TO_INT(n) ((s16)((n) >> 12))
+
+// Converts a number to QN.S fixed-point format (16-bits)
+#define Q_N_S(s, n) ((s16)((n) * (1 << (s))))
+
+// converts a number from QN.S fixed-point format (16-bits)
+#define Q_N_S_TO_INT(s, n) ((s16)((n) >> (s)))
+
+// Converts a number to Q24.8 fixed-point format
+#define Q_24_8(n) ((s32)((n) << 8))
+
+// Converts a number from Q24.8 fixed-point format
+#define Q_24_8_TO_INT(n) ((s32)((n) >> 8))
+
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) >= (b) ? (a) : (b))