diff --git a/asm/round.s b/asm/round.s new file mode 100644 index 00000000..69166c54 --- /dev/null +++ b/asm/round.s @@ -0,0 +1,10 @@ +.include "macros.inc" +.section .text +.set noreorder + +.set abi_arg0, $f12 + +glabel roundf +round.w.s $f0, abi_arg0 +jr $ra + mfc1 $v0, $f0 diff --git a/sm64.ld b/sm64.ld index 6208d3ab..f66ab89c 100755 --- a/sm64.ld +++ b/sm64.ld @@ -160,6 +160,7 @@ SECTIONS #ifdef EEP KEEP(BUILD_DIR/asm/vc_bin.o(.text*)); #endif + KEEP(BUILD_DIR/asm/round.o(.text*)); BUILD_DIR/src/boot*.o(.text*); BUILD_DIR/src/hvqm*.o(.text*); diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 38a82979..a9ca7229 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -451,27 +451,13 @@ extern f32 gSineTable[]; #define ABS(x) (((x) > 0) ? (x) : -(x)) -/// From Wiseguy -ALWAYS_INLINE s32 roundf(f32 in) { - f32 tmp; - s32 out; - __asm__("round.w.s %0,%1" : "=f" (tmp) : "f" (in )); - __asm__("mfc1 %0,%1" : "=r" (out) : "f" (tmp)); - return out; -} +extern s32 roundf(f32); // backwards compatibility #define round_float(in) roundf(in) -/// Absolute value -ALWAYS_INLINE f32 absf(f32 in) { - f32 out; - __asm__("abs.s %0,%1" : "=f" (out) : "f" (in)); - return out; -} -ALWAYS_INLINE s32 absi(s32 in) { - return ABS(in); -} -#define abss absi +#define absf ABS +#define absi ABS +#define abss ABS #define FLT_IS_NONZERO(x) (absf(x) > NEAR_ZERO)