mirror of
https://github.com/zeldaret/oot-vc.git
synced 2026-09-26 13:33:20 -04:00
b72530b1a2
* start mk64 * splits, rename dol to wii-vc, match some files * dol apply * format * match system, rom and flash * dol apply & format * match errordisplay (and almost store) * match store * version stuff * build fixes * match banner.c * link soundRVL * match helpRVL * match controller.c and random progress * match library.c * match libraries * dol apply * minor configure.py improvements * name all functions for mk64-j and mk64-e and started splits * complete splits for mk64-j * run dol apply * complete splits for mk64-e * forgot __init_cpp_exceptions.cpp * self-review * add mk64 to CI * add mk64 in the supported versions list from the readme * version improvements * fix build issues * oot-vc -> wii-vc * configure.py improvement * version stuff * initial configs * name all functions * complete splits and symbols for sm64-e * more splits and symbols * more splits and symbols 2 * more splits and symbols 3 * match homebutton differences for jp and us * emulator progress * run dol-apply and format * add sm64 to CI * fix some build issues * library.c progress * library.c progress 2 * library.c progress 3 * frame.c progress Co-authored-by: cadmic <146315916+cadmic@users.noreply.github.com> * cpu progress * frameDrawSetupSP progress * minor rsp progress * review * review 2 + fix match issues * format * review 2 * `VERSION >=` -> `VERSION >` for consistency * add sm64 to the readme * fake match rspParseGBI_F3DEX2 * review 4 * `VERSION >` -> `VERSION >=` * format * fix build issues --------- Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com> Co-authored-by: cadmic <146315916+cadmic@users.noreply.github.com>
75 lines
1.8 KiB
C
75 lines
1.8 KiB
C
#ifndef _MATH_H
|
|
#define _MATH_H
|
|
|
|
#include "fdlibm.h"
|
|
#include "intrinsics.h"
|
|
#include "macros.h"
|
|
#include "revolution/types.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define DONT_INLINE_SQRT
|
|
|
|
#define M_PI 3.1415926535897932
|
|
#define M_SQRT3 1.7320499420166016
|
|
|
|
extern int __float_nan[];
|
|
extern int __float_huge[];
|
|
extern int __double_huge[];
|
|
|
|
#define NAN (*(f32*)__float_nan)
|
|
#define INFINITY (*(f32*)__float_huge)
|
|
#define HUGE_VAL (*(double*)__double_huge)
|
|
|
|
// f64 bit-twiddling macros
|
|
#define __HI(x) (((s32*)&x)[0])
|
|
#define __LO(x) (((s32*)&x)[1])
|
|
|
|
#define FP_NAN 1
|
|
#define FP_INFINITE 2
|
|
#define FP_ZERO 3
|
|
#define FP_NORMAL 4
|
|
#define FP_SUBNORMAL 5
|
|
|
|
int __fpclassifyd(f64 x);
|
|
|
|
#define fpclassify(x) __fpclassifyd(x)
|
|
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
|
|
#define isnan(x) (fpclassify(x) == FP_NAN)
|
|
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
|
#define isfinite(x) (fpclassify(x) > FP_INFINITE)
|
|
|
|
static inline float sinf(float x) { return (float)sin((double)x); }
|
|
|
|
static inline float cosf(float x) { return (float)cos((double)x); }
|
|
|
|
static inline float tanf(float x) { return (float)tan((double)x); }
|
|
|
|
static inline double fabs(double x) { return __fabs(x); }
|
|
|
|
static inline float sqrtf(float x) { return (float)sqrt((double)x); }
|
|
|
|
static inline float _inv_sqrtf(float x) {
|
|
const float _half = .5f;
|
|
const float _three = 3.0f;
|
|
|
|
if (x > 0.0f) {
|
|
float guess = __frsqrte((double)x); /* returns an approximation to */
|
|
guess = _half * guess * (_three - guess * guess * x); /* now have 8 sig bits */
|
|
guess = _half * guess * (_three - guess * guess * x); /* now have 16 sig bits */
|
|
guess = _half * guess * (_three - guess * guess * x); /* now have >24 sig bits */
|
|
return guess;
|
|
} else if (x) {
|
|
return NAN;
|
|
}
|
|
return INFINITY;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|