frand and messdata.c decompiled

This commit is contained in:
Rainchus 2023-11-29 17:37:09 -06:00
parent 3f15731d18
commit 2533568f4c
4 changed files with 96 additions and 2 deletions

View file

@ -249,10 +249,10 @@ config.libs = [
Object(NonMatching, "game/hsfman.c"),
Object(Matching, "game/objmain.c"),
Object(NonMatching, "game/fault.c"),
Object(NonMatching, "game/frand.c"),
Object(Matching, "game/frand.c"),
Object(Matching, "game/ovllist.c"),
Object(NonMatching, "game/window.c"),
Object(NonMatching, "game/messdata.c"),
Object(Matching, "game/messdata.c"),
Object(NonMatching, "game/card.c"),
Object(NonMatching, "game/armem.c"),
],

View file

@ -187,6 +187,8 @@ void BoardMessCreate(s16, s32, s32);
void BoardMessKill(void);
void BoardMessWait(void);
s32 rand8(void);
void fn_8005D8E8(void);
void fn_8005DB6C(s16, Vec3f*, s32, f32, f32, s32);
void fn_8005E0C0(void);

40
src/game/frand.c Normal file
View file

@ -0,0 +1,40 @@
#include "common.h"
u32 frand_seed;
static inline u32 frandom(void)
{
u32 rand = frand_seed;
s32 rand2, rand3;
if (rand == 0) {
rand = rand8();
rand = rand ^ (s64)OSGetTime();
rand ^= 0xD826BC89;
}
rand2 = rand / (u32)0x1F31D;
rand3 = rand - (rand2 * 0x1F31D);
rand = rand2 * 0xB14;
rand = rand - rand3 * 0x41A7;
return rand;
}
u32 frand(void) {
return frand_seed = frandom();
}
f32 frandf(void) {
u32 value = frand();
f32 ret;
value &= 0x7FFFFFFF;
ret = (f32)value/2147483648;
return ret;
}
u32 frandmod(u32 arg0) {
u32 ret;
frand_seed = frandom();
ret = (frand_seed & 0x7FFFFFFF)%arg0;
return ret;
}

52
src/game/messdata.c Normal file
View file

@ -0,0 +1,52 @@
#include "common.h"
void* MessData_MesPtrGet(s32* arg0, u32 arg1) {
u16 var2;
s32* var_r27;
s32 var_r28;
s32* temp_r31;
s32* var_r26;
s32* var_r25;
u16* var_r29;
s32 var1;
u16 var_r24;
s32* var_r30;
s32 var_r21;
var2 = arg1 >> 16;
temp_r31 = arg0;
var1 = *temp_r31++;
var_r29 = (u16*)((u8*)arg0 + *temp_r31);
var_r28 = var1;
while (var_r28 != 0) {
if (*var_r29 != var2) {
var_r28--;
var_r29 += 2;
continue;
} else {
break;
}
}
if (var_r28 == 0) {
var_r26 = NULL;
} else {
temp_r31 = (s32*)((u32)temp_r31 + var_r29[1] * 4);
var_r26 = (s32*)((u8*)arg0 + *temp_r31);
}
var_r27 = var_r26;
if (var_r27 != 0) {
var_r24 = arg1;
var_r30 = var_r27;
var_r21 = *var_r30;
var_r30++;
if (var_r21 <= var_r24) {
var_r25 = NULL;
} else {
var_r30 = var_r30 + var_r24;
var_r25 = (s32*)((u8*)var_r27 + *var_r30);
}
return var_r25;
}
return 0;
}