From ee6b3c1acf4805d6df72b291b8c0f79635e6341a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 5 May 2021 13:03:39 -0400 Subject: Sync berry crush from Emerald --- include/math_util.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/math_util.h') diff --git a/include/math_util.h b/include/math_util.h index 9f9677463..1ccde1ef5 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -1,11 +1,11 @@ #ifndef GUARD_MATH_UTIL_H #define GUARD_MATH_UTIL_H -s16 MathUtil_Inv16(s16 y); -s16 MathUtil_Mul16(s16 x, s16 y); -s32 MathUtil_Div32(s32 x, s32 y); -s32 MathUtil_Mul32(s32 x, s32 y); -s16 MathUtil_Div16Shift(u8 s, s16 x, s16 y); -s16 MathUtil_Mul16Shift(u8 s, s16 x, s16 y); +s16 invfx16(s16 y); +s16 mulfx16(s16 x, s16 y); +s32 divfx32(s32 x, s32 y); +s32 mulfx32(s32 x, s32 y); +s16 divfxn16(u8 s, s16 x, s16 y); +s16 mulfxn16(u8 s, s16 x, s16 y); #endif //GUARD_MATH_UTIL_H -- cgit v1.2.3 From f2847354f42e7bc62279a713f9331a900f9c7c75 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 6 May 2021 09:27:56 -0400 Subject: Improve documentation of math_util --- include/math_util.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'include/math_util.h') diff --git a/include/math_util.h b/include/math_util.h index 1ccde1ef5..b1243df56 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -1,11 +1,26 @@ #ifndef GUARD_MATH_UTIL_H #define GUARD_MATH_UTIL_H -s16 invfx16(s16 y); -s16 mulfx16(s16 x, s16 y); -s32 divfx32(s32 x, s32 y); -s32 mulfx32(s32 x, s32 y); -s16 divfxn16(u8 s, s16 x, s16 y); -s16 mulfxn16(u8 s, s16 x, s16 y); +// Fixed-point arithmetic library. + +// Proposed TODO: Move the macros here from global.h +typedef s16 fx16; // Fixed-point Q8.8 +typedef s16 fxn16; // Fixed-point with arbitrary precision (QN.S) +typedef s32 fx32; // Fixed-point Q24.8 + +// x * y +fx16 mulfx16(fx16 x, fx16 y); +fxn16 mulfxn16(u8 s, fxn16 x, fxn16 y); +fx32 mulfx32(fx32 x, fx32 y); + +// x / y +fx16 divfx16(fx16 x, fx16 y); +fxn16 divfxn16(u8 s, fxn16 x, fxn16 y); +fx32 divfx32(fx32 x, fx32 y); + +// 1.0 / y +fx16 invfx16(fx16 y); +fxn16 invfxn16(u8 s, fxn16 y); +fx32 invfx32(fx32 y); #endif //GUARD_MATH_UTIL_H -- cgit v1.2.3 From 5c965f5357c09a9eaaad029441401498e0877966 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 24 May 2021 14:59:35 -0400 Subject: Rename fixed point math routines again --- include/math_util.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include/math_util.h') diff --git a/include/math_util.h b/include/math_util.h index b1243df56..29fa8f59d 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -9,18 +9,18 @@ typedef s16 fxn16; // Fixed-point with arbitrary precision (QN.S) typedef s32 fx32; // Fixed-point Q24.8 // x * y -fx16 mulfx16(fx16 x, fx16 y); -fxn16 mulfxn16(u8 s, fxn16 x, fxn16 y); -fx32 mulfx32(fx32 x, fx32 y); +fx16 Q_8_8_mul(fx16 x, fx16 y); +fxn16 Q_N_S_mul(u8 s, fxn16 x, fxn16 y); +fx32 Q_24_8_mul(fx32 x, fx32 y); // x / y -fx16 divfx16(fx16 x, fx16 y); -fxn16 divfxn16(u8 s, fxn16 x, fxn16 y); -fx32 divfx32(fx32 x, fx32 y); +fx16 Q_8_8_div(fx16 x, fx16 y); +fxn16 Q_N_S_div(u8 s, fxn16 x, fxn16 y); +fx32 Q_24_8_div(fx32 x, fx32 y); // 1.0 / y -fx16 invfx16(fx16 y); -fxn16 invfxn16(u8 s, fxn16 y); -fx32 invfx32(fx32 y); +fx16 Q_8_8_inv(fx16 y); +fxn16 Q_N_S_inv(u8 s, fxn16 y); +fx32 Q_24_8_inv(fx32 y); #endif //GUARD_MATH_UTIL_H -- cgit v1.2.3 From 1a9ba7bb0aeb27a7d0bca43190edd054e517f27b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 26 May 2021 09:59:32 -0400 Subject: Revert typedefs in math_util --- include/math_util.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'include/math_util.h') diff --git a/include/math_util.h b/include/math_util.h index 29fa8f59d..1f8edc5d9 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -3,24 +3,19 @@ // Fixed-point arithmetic library. -// Proposed TODO: Move the macros here from global.h -typedef s16 fx16; // Fixed-point Q8.8 -typedef s16 fxn16; // Fixed-point with arbitrary precision (QN.S) -typedef s32 fx32; // Fixed-point Q24.8 - // x * y -fx16 Q_8_8_mul(fx16 x, fx16 y); -fxn16 Q_N_S_mul(u8 s, fxn16 x, fxn16 y); -fx32 Q_24_8_mul(fx32 x, fx32 y); +s16 Q_8_8_mul(s16 x, s16 y); +s16 Q_N_S_mul(u8 s, s16 x, s16 y); +s32 Q_24_8_mul(s32 x, s32 y); // x / y -fx16 Q_8_8_div(fx16 x, fx16 y); -fxn16 Q_N_S_div(u8 s, fxn16 x, fxn16 y); -fx32 Q_24_8_div(fx32 x, fx32 y); +s16 Q_8_8_div(s16 x, s16 y); +s16 Q_N_S_div(u8 s, s16 x, s16 y); +s32 Q_24_8_div(s32 x, s32 y); // 1.0 / y -fx16 Q_8_8_inv(fx16 y); -fxn16 Q_N_S_inv(u8 s, fxn16 y); -fx32 Q_24_8_inv(fx32 y); +s16 Q_8_8_inv(s16 y); +s16 Q_N_S_inv(u8 s, s16 y); +s32 Q_24_8_inv(s32 y); #endif //GUARD_MATH_UTIL_H -- cgit v1.2.3