Merge pull request #110 from gamemasterplc/main

Various code cleanups
This commit is contained in:
gamemasterplc 2024-01-15 19:49:16 -06:00 committed by GitHub
commit 566a0e8c49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 43 deletions

View file

@ -441,8 +441,8 @@ GetBitMap = .text:0x800285E8; // type:function size:0x64
Hu3DJointMotion = .text:0x8002864C; // type:function size:0xCC
JointModel_Motion = .text:0x80028718; // type:function size:0x124
Hu3DMotionCalc = .text:0x8002883C; // type:function size:0x19C
SearchObjectIndex = .text:0x800289D8; // type:function size:0x90
SearchAttributeIndex = .text:0x80028A68; // type:function size:0x9C
SearchObjectIndex = .text:0x800289D8; // type:function size:0x90 scope:local
SearchAttributeIndex = .text:0x80028A68; // type:function size:0x9C scope:local
Hu3DAnimInit = .text:0x80028B04; // type:function size:0x7C
Hu3DAnimCreate = .text:0x80028B80; // type:function size:0x1D0
Hu3DAnimLink = .text:0x80028D50; // type:function size:0x1C4
@ -4604,7 +4604,7 @@ __destroy_global_chain_reference = .dtors:0x8011DCE0; // type:object size:0x4 sc
__fini_cpp_exceptions_reference = .dtors:0x8011DCE4; // type:object size:0x4 scope:global
lbl_8011DD00 = .rodata:0x8011DD00; // type:object size:0x10 data:4byte
lbl_8011DD10 = .rodata:0x8011DD10; // type:object size:0x10 data:4byte
lbl_8011DD20 = .rodata:0x8011DD20; // type:object size:0x10 data:4byte
lbl_8011DD20 = .rodata:0x8011DD20; // type:object size:0xC data:4byte
lbl_8011DD30 = .rodata:0x8011DD30; // type:object size:0x20 data:byte
lbl_8011DD50 = .rodata:0x8011DD50; // type:object size:0x10 data:4byte
lbl_8011DD60 = .rodata:0x8011DD60; // type:object size:0x24 data:4byte

View file

@ -149,6 +149,18 @@ static inline void GXColor1x8(u8 index) {
GXWGFifo.u8 = index;
}
static inline void GXPosition1x16(u16 index) {
GXWGFifo.u16 = index;
}
static inline void GXColor1x16(u16 index) {
GXWGFifo.u16 = index;
}
static inline void GXTexCoord1x16(u16 index) {
GXWGFifo.u16 = index;
}
static inline void GXEnd(void) {}
#endif

View file

@ -73,6 +73,7 @@ _MATH_INLINE float sinf(float x) { return (float)sin((double)x); }
_MATH_INLINE float cosf(float x) { return (float)cos((double)x); }
_MATH_INLINE float atan2f(float y, float x) { return (float)atan2((double)y, (double)x); }
_MATH_INLINE float atanf(float x) { return (float)atan((double)x); }
_MATH_INLINE float asinf(float x) { return (float)asin((double)x); }
_MATH_INLINE float fmodf(float x, float m) { return (float)fmod((double)x, (double)m); }

View file

@ -2,26 +2,25 @@
static u32 frand_seed;
static inline u32 frandom(void)
static inline u32 frandom(u32 param)
{
u32 rand = frand_seed;
s32 rand2, rand3;
if (rand == 0) {
rand = rand8();
rand = rand ^ (s64)OSGetTime();
rand ^= 0xD826BC89;
if (param == 0) {
param = rand8();
param = param ^ (s64)OSGetTime();
param ^= 0xD826BC89;
}
rand2 = rand / (u32)0x1F31D;
rand3 = rand - (rand2 * 0x1F31D);
rand = rand2 * 0xB14;
rand = rand - rand3 * 0x41A7;
return rand;
rand2 = param / (u32)0x1F31D;
rand3 = param - (rand2 * 0x1F31D);
param = rand2 * 0xB14;
param = param - rand3 * 0x41A7;
return param;
}
u32 frand(void) {
return frand_seed = frandom();
return frand_seed = frandom(frand_seed);
}
f32 frandf(void) {
@ -34,7 +33,7 @@ f32 frandf(void) {
u32 frandmod(u32 arg0) {
u32 ret;
frand_seed = frandom();
frand_seed = frandom(frand_seed);
ret = (frand_seed & 0x7FFFFFFF)%arg0;
return ret;
}

View file

@ -35,13 +35,6 @@ Hu3DTexAnimDataStruct Hu3DTexAnimData[256];
Hu3DTexScrDataStruct Hu3DTexScrData[16];
static Process *parManProc[64];
// TODO: move to GXVert
static inline void GXUnknownu16(const u16 x, const u16 y, const u16 z) {
GXWGFifo.u16 = x;
GXWGFifo.u16 = y;
GXWGFifo.u16 = z;
}
void Hu3DAnimInit(void) {
Hu3DTexAnimDataStruct *var_r30;
Hu3DTexScrDataStruct *var_r29;
@ -537,10 +530,18 @@ s16 Hu3DParticleCreate(AnimData *arg0, s16 arg1) {
GXBeginDisplayList(temp_r24, 0x20000);
GXBegin(GX_QUADS, GX_VTXFMT0, arg1 * 4);
for (i = 0; i < arg1; i++) {
GXUnknownu16(i * 4, i, 0);
GXUnknownu16(i * 4 + 1, i, 1);
GXUnknownu16(i * 4 + 2, i, 2);
GXUnknownu16(i * 4 + 3, i, 3);
GXPosition1x16(i*4);
GXColor1x16(i);
GXTexCoord1x16(0);
GXPosition1x16((i*4)+1);
GXColor1x16(i);
GXTexCoord1x16(1);
GXPosition1x16((i*4)+2);
GXColor1x16(i);
GXTexCoord1x16(2);
GXPosition1x16((i*4)+3);
GXColor1x16(i);
GXTexCoord1x16(3);
}
temp_r31->unk_40 = GXEndDisplayList();
return temp_r25;

View file

@ -470,15 +470,7 @@ void Hu3DMtxTransGet(Mtx arg0, Vec *arg1) {
arg1->z = arg0[2][3];
}
static inline float Hu3DMtxRotGetInlineFunc01(float arg0, float arg1) {
return atan2(arg0, arg1);
}
static inline float Hu3DMtxRotGetInlineFunc02(float arg0) {
return asin(arg0);
}
static inline float Hu3DMtxRotGetInlineFunc03(float arg0, float arg1) {
static inline float GetAngleXY(float arg0, float arg1) {
if (arg1 == 0.0f) {
if (arg0 >= 0.0f) {
return M_PI / 2;
@ -486,7 +478,7 @@ static inline float Hu3DMtxRotGetInlineFunc03(float arg0, float arg1) {
return -(M_PI / 2);
}
} else {
return Hu3DMtxRotGetInlineFunc01(arg0, arg1);
return atan2f(arg0, arg1);
}
}
@ -516,15 +508,15 @@ void Hu3DMtxRotGet(Mtx arg0, Vec *arg1) {
} else if (temp_f24 <= -1.0f) {
var_f25 = -(M_PI / 2);
} else {
var_f25 = Hu3DMtxRotGetInlineFunc02(temp_f24);
var_f25 = asinf(temp_f24);
}
arg1->y = var_f25;
sp48 = cos(arg1->y);
if (sp48 >= 0.00000001f) {
arg1->x = Hu3DMtxRotGetInlineFunc03(arg0[2][1] / sp3C, arg0[2][2] / sp34);
arg1->z = Hu3DMtxRotGetInlineFunc03(arg0[1][0], arg0[0][0]);
arg1->x = GetAngleXY(arg0[2][1] / sp3C, arg0[2][2] / sp34);
arg1->z = GetAngleXY(arg0[1][0], arg0[0][0]);
} else {
arg1->x = Hu3DMtxRotGetInlineFunc03(arg0[0][1], arg0[1][1]);
arg1->x = GetAngleXY(arg0[0][1], arg0[1][1]);
arg1->z = 0.0f;
}
arg1->x = arg1->x * 57.29578f;

View file

@ -1397,7 +1397,7 @@ void Hu3DMotionCalc(s16 arg0) {
temp_r31->attr |= 0x800;
}
s32 SearchObjectIndex(HsfData *arg0, u32 arg1) {
static s32 SearchObjectIndex(HsfData *arg0, u32 arg1) {
s32 i;
char *temp_r28;
HsfObject *var_r30;
@ -1412,7 +1412,7 @@ s32 SearchObjectIndex(HsfData *arg0, u32 arg1) {
return -1;
}
s32 SearchAttributeIndex(HsfData *arg0, u32 arg1) {
static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1) {
HsfAttribute *var_r31;
size_t temp_r28;
char *temp_r27;