2020-12-12 15:33:14 -05:00
|
|
|
|
#include <ultra64.h>
|
2020-12-11 22:51:58 -05:00
|
|
|
|
// jk i dont think this file is needed lol
|
|
|
|
|
|
// update: it was needed :(
|
2020-12-12 15:33:14 -05:00
|
|
|
|
// update 2: gu.h already has macros for this :(
|
2020-12-11 22:51:58 -05:00
|
|
|
|
|
|
|
|
|
|
// hopefully I'll only need s15.16
|
|
|
|
|
|
// ^ clueless
|
|
|
|
|
|
|
2020-12-12 15:33:14 -05:00
|
|
|
|
// Q to float
|
|
|
|
|
|
|
|
|
|
|
|
// To convert a number from Qm.n format to floating point:
|
|
|
|
|
|
|
|
|
|
|
|
// Convert the number to floating point as if it were an integer, in other words remove the binary point
|
|
|
|
|
|
// Multiply by 2^−n
|
|
|
|
|
|
|
2020-12-11 22:51:58 -05:00
|
|
|
|
f32 qtof(int q) {
|
2020-12-12 15:33:14 -05:00
|
|
|
|
return ((float)q) * 0.00001525878f;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Float to Q
|
|
|
|
|
|
|
|
|
|
|
|
// To convert a number from floating point to Qm.n format:
|
|
|
|
|
|
|
|
|
|
|
|
// Multiply the floating point number by 2^n
|
|
|
|
|
|
// Round to the nearest integer
|
|
|
|
|
|
int ftoq(f32 f) {
|
|
|
|
|
|
f *= (65536.0f);
|
|
|
|
|
|
return (int)f;
|
2020-12-11 22:51:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-12 15:33:14 -05:00
|
|
|
|
|