SSBM Decomp
Loading...
Searching...
No Matches
math.c File Reference
#include "math.h"
#include <platform.h>

Data Structures

union  FloatU32
 

Macros

#define EXP_MASK   0x7F800000
 
#define EXP_ZERO   0x3F800000
 
#define MANT_MASK   0x007FFFFF
 
#define SIGN_BIT   0x80000000
 
#define F32_BIT_CAST(raw_x)   (*(float*) &raw_x)
 
#define F32_UNBIASED_EXPONENT(raw_x)    (((raw_x & 0xFF800000) >> 23) - /*exponent bias*/ 127)
 
#define F32_HIGH_MANTISSA_BITS(raw_x)    ((raw_x >> 16) & 0x7F)
 
#define F32_LOW_MANTISSA_BITS(raw_x)    (raw_x & 0xFFFF)
 
#define LN2   0.6931472f
 

Functions

float logf (float x)
 

Variables

float float_nan = 0.0 / 0.0
 
float float_inf = 1.0e100 * 1.0e100
 
const float __ln_F []
 Math lookup tables - defined in math_data.c Keeping them in a separate compilation unit prevents the compiler from hoisting array base addresses, which is needed to match the original code.
 
const float __one_over_F []
 __one_over_F[n] = 1.0 / (1.0 + n/128) for n = 0..128
 
const float __sincos_on_quadrant []
 
const float __sincos_poly []
 
const u32 __logf_C0_bits
 logf Taylor series coefficients - stored as u32 bit patterns in math_data.c to get the right codegen (lwz load from global)
 
const u32 __logf_C1_bits
 

Macro Definition Documentation

◆ EXP_MASK

#define EXP_MASK   0x7F800000

◆ EXP_ZERO

#define EXP_ZERO   0x3F800000

◆ MANT_MASK

#define MANT_MASK   0x007FFFFF

◆ SIGN_BIT

#define SIGN_BIT   0x80000000

◆ F32_BIT_CAST

#define F32_BIT_CAST (   raw_x)    (*(float*) &raw_x)

◆ F32_UNBIASED_EXPONENT

#define F32_UNBIASED_EXPONENT (   raw_x)     (((raw_x & 0xFF800000) >> 23) - /*exponent bias*/ 127)

◆ F32_HIGH_MANTISSA_BITS

#define F32_HIGH_MANTISSA_BITS (   raw_x)     ((raw_x >> 16) & 0x7F)

◆ F32_LOW_MANTISSA_BITS

#define F32_LOW_MANTISSA_BITS (   raw_x)     (raw_x & 0xFFFF)

◆ LN2

#define LN2   0.6931472f

Function Documentation

◆ logf()

float logf ( float  x)

Variable Documentation

◆ float_nan

float float_nan = 0.0 / 0.0
Todo:
use standard library constants, because this definition seems to be platform dependant

◆ float_inf

float float_inf = 1.0e100 * 1.0e100

◆ __ln_F

const float __ln_F[]
extern

Math lookup tables - defined in math_data.c Keeping them in a separate compilation unit prevents the compiler from hoisting array base addresses, which is needed to match the original code.

Math lookup tables - defined in math_data.c Keeping them in a separate compilation unit prevents the compiler from hoisting array base addresses, which is needed to match the original code.

These arrays are kept in a separate compilation unit so that functions like logf() generate separate address loads for each table access, rather than hoisting a shared base pointer. __ln_F[n] = ln(1.0 + n/128) for n = 0 .. 128

◆ __one_over_F

const float __one_over_F[]
extern

__one_over_F[n] = 1.0 / (1.0 + n/128) for n = 0..128

◆ __sincos_on_quadrant

const float __sincos_on_quadrant[]
extern

◆ __sincos_poly

const float __sincos_poly[]
extern

◆ __logf_C0_bits

const u32 __logf_C0_bits
extern

logf Taylor series coefficients - stored as u32 bit patterns in math_data.c to get the right codegen (lwz load from global)

logf Taylor series coefficients - stored as u32 bit patterns in math_data.c to get the right codegen (lwz load from global)

◆ __logf_C1_bits

const u32 __logf_C1_bits
extern