diff options
author | GriffinR <griffin.g.richards@gmail.com> | 2021-05-27 06:46:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 06:46:29 -0400 |
commit | c396aaa804543c6950bdef918f3773394da09bdf (patch) | |
tree | a925bd32e0745ddf3ecef23d1ef3e710f3250273 /include/global.h | |
parent | 3dce3407d5f9bca69d61b1cf1b314fb1e921d572 (diff) | |
parent | 1a9ba7bb0aeb27a7d0bca43190edd054e517f27b (diff) |
Merge pull request #431 from PikalaxALT/sync_bery_crush
Sync berry crush from Emerald
Diffstat (limited to 'include/global.h')
-rw-r--r-- | include/global.h | 18 |
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)) |