mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-10 04:46:48 -04:00
MSL_C fully matched / some SSystem cleanup/ obj_rgate OK (#2011)
* cleanup SSystem files * MSL_C fully matched * fix build * remove asm * reorganize MSL_C/Runtime libs into more accurate setup * little more cleanup * cleanup some MSL headers * obj_rgate OK * remove asm * some rgate documentation
This commit is contained in:
@@ -1,26 +1,23 @@
|
||||
//
|
||||
// Generated By: dol2asm
|
||||
// Translation Unit: c_math
|
||||
//
|
||||
/**
|
||||
* c_math.cpp
|
||||
* Math Helper Utilities
|
||||
*/
|
||||
|
||||
#include "SSystem/SComponent/c_math.h"
|
||||
#include "SSystem/SComponent/c_m3d.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
//
|
||||
// Declarations:
|
||||
//
|
||||
|
||||
/* 802675E4-80267640 261F24 005C+00 0/0 23/23 11/11 .text cM_rad2s__Ff */
|
||||
s16 cM_rad2s(float f0) {
|
||||
f32 tmpF = fmod(f0, 6.2831854820251465 /* approx. 2 * PI */);
|
||||
s32 tmp = (tmpF * 10430.378f /* approx. 32768 / PI */);
|
||||
if (tmp < -0x8000) {
|
||||
tmp += 0x10000;
|
||||
} else if (tmp > 0x7FFF) {
|
||||
tmp -= 0x10000;
|
||||
s16 cM_rad2s(float rad) {
|
||||
f32 rad_mod = fmod(rad, 2 * M_PI);
|
||||
|
||||
s32 s = (rad_mod * (0x8000 / M_PI));
|
||||
if (s < -0x8000) {
|
||||
s += 0x10000;
|
||||
} else if (s > 0x7FFF) {
|
||||
s -= 0x10000;
|
||||
}
|
||||
return tmp;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* ############################################################################################## */
|
||||
@@ -116,57 +113,57 @@ static u16 atntable[1025] = {
|
||||
|
||||
/* 80267640-80267674 261F80 0034+00 1/1 0/0 0/0 .text U_GetAtanTable__Fff */
|
||||
u16 U_GetAtanTable(float f0, float f1) {
|
||||
return atntable[(int)(f0 / f1 * 1024)];
|
||||
return atntable[(int)(f0 / f1 * 0x400)];
|
||||
}
|
||||
|
||||
/* 80267674-80267814 261FB4 01A0+00 1/1 82/82 822/822 .text cM_atan2s__Fff */
|
||||
s16 cM_atan2s(float f0, float f1) {
|
||||
u32 retVar;
|
||||
if (fabsf(f0) < G_CM3D_F_ABS_MIN) {
|
||||
if (f1 >= 0.0f) {
|
||||
retVar = 0;
|
||||
s16 cM_atan2s(float y, float x) {
|
||||
u32 ret;
|
||||
if (fabsf(y) < G_CM3D_F_ABS_MIN) {
|
||||
if (x >= 0.0f) {
|
||||
ret = 0;
|
||||
} else {
|
||||
retVar = 0x8000;
|
||||
ret = 0x8000;
|
||||
}
|
||||
} else if (fabsf(f1) < G_CM3D_F_ABS_MIN) {
|
||||
if (f0 >= 0.0f) {
|
||||
retVar = 0x4000;
|
||||
} else if (fabsf(x) < G_CM3D_F_ABS_MIN) {
|
||||
if (y >= 0.0f) {
|
||||
ret = 0x4000;
|
||||
} else {
|
||||
retVar = 0xC000;
|
||||
ret = 0xC000;
|
||||
}
|
||||
} else if (f0 >= 0.0f) {
|
||||
if (f1 >= 0.0f) {
|
||||
if (f1 >= f0) {
|
||||
retVar = U_GetAtanTable(f0, f1);
|
||||
} else if (y >= 0.0f) {
|
||||
if (x >= 0.0f) {
|
||||
if (x >= y) {
|
||||
ret = U_GetAtanTable(y, x);
|
||||
} else {
|
||||
retVar = 0x4000 - U_GetAtanTable(f1, f0);
|
||||
ret = 0x4000 - U_GetAtanTable(x, y);
|
||||
}
|
||||
} else {
|
||||
if (-f1 < f0) {
|
||||
retVar = U_GetAtanTable(-f1, f0) + 0x4000;
|
||||
if (-x < y) {
|
||||
ret = U_GetAtanTable(-x, y) + 0x4000;
|
||||
} else {
|
||||
retVar = 0x8000 - U_GetAtanTable(f0, -f1);
|
||||
ret = 0x8000 - U_GetAtanTable(y, -x);
|
||||
}
|
||||
}
|
||||
} else if (f1 < 0.0f) {
|
||||
if (f1 <= f0) {
|
||||
retVar = U_GetAtanTable(-f0, -f1) + 0x8000;
|
||||
} else if (x < 0.0f) {
|
||||
if (x <= y) {
|
||||
ret = U_GetAtanTable(-y, -x) + 0x8000;
|
||||
} else {
|
||||
retVar = 0xC000 - U_GetAtanTable(-f1, -f0);
|
||||
ret = 0xC000 - U_GetAtanTable(-x, -y);
|
||||
}
|
||||
} else {
|
||||
if (f1 < -f0) {
|
||||
retVar = U_GetAtanTable(f1, -f0) + 0xC000;
|
||||
if (x < -y) {
|
||||
ret = U_GetAtanTable(x, -y) + 0xC000;
|
||||
} else {
|
||||
retVar = -U_GetAtanTable(-f0, f1);
|
||||
ret = -U_GetAtanTable(-y, x);
|
||||
}
|
||||
}
|
||||
return retVar;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 80267814-8026785C 262154 0048+00 0/0 4/4 5/5 .text cM_atan2f__Fff */
|
||||
float cM_atan2f(float f1, float f2) {
|
||||
return 9.58738E-5f * cM_atan2s(f1, f2);
|
||||
float cM_atan2f(float y, float x) {
|
||||
return ((2 * M_PI) / 0x10000) * cM_atan2s(y, x);
|
||||
}
|
||||
|
||||
/* ############################################################################################## */
|
||||
@@ -180,28 +177,42 @@ static s32 r1;
|
||||
static s32 r2;
|
||||
|
||||
/* 8026785C-8026786C 26219C 0010+00 0/0 1/1 0/0 .text cM_initRnd__Fiii */
|
||||
void cM_initRnd(int p0, int p1, int p2) {
|
||||
r0 = p0;
|
||||
r1 = p1;
|
||||
r2 = p2;
|
||||
void cM_initRnd(int s0, int s1, int s2) {
|
||||
r0 = s0;
|
||||
r1 = s1;
|
||||
r2 = s2;
|
||||
}
|
||||
|
||||
/* 8026786C-80267954 2621AC 00E8+00 2/2 15/15 113/113 .text cM_rnd__Fv */
|
||||
float cM_rnd(void) {
|
||||
r0 = (r0 * 0xAB) % 0x763D;
|
||||
r1 = (r1 * 0xAC) % 0x7663;
|
||||
r2 = (r2 * 0xAA) % 0x7673;
|
||||
/**
|
||||
* Gets a random value
|
||||
* @return a random value
|
||||
*/
|
||||
float cM_rnd() {
|
||||
r0 = (r0 * 171) % 30269;
|
||||
r1 = (r1 * 172) % 30307;
|
||||
r2 = (r2 * 170) % 30323;
|
||||
return fabsf(fmod(r0 / 30269.0f + r1 / 30307.0f + r2 / 30323.0f, 1.0));
|
||||
}
|
||||
|
||||
/* 80267954-8026798C 262294 0038+00 0/0 34/34 951/951 .text cM_rndF__Ff */
|
||||
float cM_rndF(float f) {
|
||||
return cM_rnd() * f;
|
||||
/**
|
||||
* Gets a random value between 0 and a given upper bound
|
||||
* @param max The upper bound the random value can be
|
||||
* @return a random value between 0 and `max`
|
||||
*/
|
||||
float cM_rndF(float max) {
|
||||
return cM_rnd() * max;
|
||||
}
|
||||
|
||||
/* 8026798C-802679D4 2622CC 0048+00 0/0 24/24 450/450 .text cM_rndFX__Ff */
|
||||
float cM_rndFX(float f) {
|
||||
return f * (cM_rnd() - 0.5f) * 2.0f;
|
||||
/**
|
||||
* Gets a random value between given bounds
|
||||
* @param max The upper and lower bound the random value can be
|
||||
* @return a random value between -`max` and +`max`
|
||||
*/
|
||||
float cM_rndFX(float max) {
|
||||
return max * (cM_rnd() - 0.5f) * 2.0f;
|
||||
}
|
||||
|
||||
/* ############################################################################################## */
|
||||
@@ -215,26 +226,26 @@ static s32 r12;
|
||||
static s32 r22;
|
||||
|
||||
/* 802679D4-802679E4 262314 0010+00 0/0 0/0 8/8 .text cM_initRnd2__Fiii */
|
||||
void cM_initRnd2(int p0, int p1, int p2) {
|
||||
r02 = p0;
|
||||
r12 = p1;
|
||||
r22 = p2;
|
||||
void cM_initRnd2(int s0, int s1, int s2) {
|
||||
r02 = s0;
|
||||
r12 = s1;
|
||||
r22 = s2;
|
||||
}
|
||||
|
||||
/* 802679E4-80267ACC 262324 00E8+00 2/2 0/0 0/0 .text cM_rnd2__Fv */
|
||||
float cM_rnd2(void) {
|
||||
r02 = (r02 * 0xAB) % 0x763D;
|
||||
r12 = (r12 * 0xAC) % 0x7663;
|
||||
r22 = (r22 * 0xAA) % 0x7673;
|
||||
float cM_rnd2() {
|
||||
r02 = (r02 * 171) % 30269;
|
||||
r12 = (r12 * 172) % 30307;
|
||||
r22 = (r22 * 170) % 30323;
|
||||
return fabsf(fmod(r02 / 30269.0f + r12 / 30307.0f + r22 / 30323.0f, 1.0));
|
||||
}
|
||||
|
||||
/* 80267ACC-80267B04 26240C 0038+00 0/0 0/0 14/14 .text cM_rndF2__Ff */
|
||||
float cM_rndF2(float f) {
|
||||
return cM_rnd2() * f;
|
||||
float cM_rndF2(float max) {
|
||||
return cM_rnd2() * max;
|
||||
}
|
||||
|
||||
/* 80267B04-80267B4C 262444 0048+00 0/0 0/0 7/7 .text cM_rndFX2__Ff */
|
||||
float cM_rndFX2(float f) {
|
||||
return f * (cM_rnd2() - 0.5f) * 2.0f;
|
||||
float cM_rndFX2(float max) {
|
||||
return max * (cM_rnd2() - 0.5f) * 2.0f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user