Link sys_math

This commit is contained in:
Cuyler36
2024-04-26 14:03:10 -04:00
parent 2308aea624
commit 38b4315a45
4 changed files with 35 additions and 25 deletions
+3 -3
View File
@@ -362,9 +362,9 @@ sys_math3d.c:
.rodata: [0x806437D0, 0x80643810]
.data: [0x8065F150, 0x8065F168]
.bss: [0x812F54A0, 0x812F5668]
#sys_math.c:
# .text: [0x80408940, 0x80408A44]
# .rodata: [0x806437C0, 0x806437D0]
sys_math.c:
.text: [0x80408940, 0x80408A44]
.rodata: [0x806437C0, 0x806437D0]
sys_math_atan.c:
.text: [0x8040C06C, 0x8040C284]
.rodata: [0x80643810, 0x80643828]
-12
View File
@@ -12,18 +12,6 @@
extern "C" {
#endif
#define SHT_MIN_S -32768 /* 0x8000 */
#define SHT_MAX_S 32767 /* 0x7FFF */
#define SHT_MIN ((f32)SHT_MIN_S)
#define SHT_MAX ((f32)SHT_MAX_S)
#define USHT_MIN_S 0
#define USHT_MAX_S 65535
#define USHT_MIN ((f32)USHT_MIN_S)
#define USHT_MAX ((f32)USHT_MAX_S)
#define SHT_MINV (1.0f / SHT_MAX)
#define ABS(x) (((x) >= 0) ? (x) : -(x))
#define SQ(x) ((x) * (x))
+15
View File
@@ -4,11 +4,26 @@
#include "types.h"
#include "MSL_C/math.h"
#include "libc64/qrand.h"
#include "m_lib.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SHT_MIN_S -32768 /* 0x8000 */
#define SHT_MAX_S 32767 /* 0x7FFF */
#define SHT_MIN ((f32)SHT_MIN_S)
#define SHT_MAX ((f32)SHT_MAX_S)
#define SHT_MINV (1.0f / SHT_MAX)
#define USHT_MIN_S 0
#define USHT_MAX_S 65535
#define USHT_MIN ((f32)USHT_MIN_S)
#define USHT_MAX ((f32)USHT_MAX_S)
/* Macro to generate a random float in the range of [0, n) */
#define RANDOM_F(n) (fqrand() * (f32)(n))
+17 -10
View File
@@ -3,19 +3,26 @@
#include "libc64/qrand.h"
#include "libc/math.h"
void init_rnd(){
extern void init_rnd() {
sqrand(osGetCount());
}
f32 sinf_table(f32 x){
f32 max = 3.05185094476e-05f;
s16 sinf = sins((s16)(10430.0595703f * x));
return sinf * max;
#ifdef MUST_MATCH
FORCESTRIP static f32 _rodata_order(int in) {
return (f32)in;
}
#endif
extern f32 sinf_table(f32 x) {
s16 v = (SHT_MAX / M_PI) * x;
s16 sin = sins(v);
return sin * SHT_MINV;
}
f32 cosf_table(f32 x){
f32 max = 3.05185094476e-05f;
s16 cosf = coss((s16)(10430.0595703f * x));
return cosf * max;
extern f32 cosf_table(f32 x) {
s16 v = (SHT_MAX / M_PI) * x;
s16 cos = coss(v);
return cos * SHT_MINV;
}