diff --git a/include/structs.h b/include/structs.h index 4ba4fa2f35..6fa764f136 100644 --- a/include/structs.h +++ b/include/structs.h @@ -56,7 +56,7 @@ typedef struct s800BF9A0_s { /* 000 */ u8 pad0[8]; /* 008 */ UNK_TYPE unk8; /* 012 */ UNK_TYPE unk12; - /* 016 */ UNK_TYPE unk16; + /* 016 */ u32 unk16; /* 020 */ u8 pad1[10]; /* 030 */ s8 unk30; /* 031 */ u8 pad2[1]; diff --git a/include/variables.h b/include/variables.h index 2790d7de9b..ca81562b9a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -2273,7 +2273,7 @@ extern int D_801ADEB0[]; // D_801ADEB0 //extern UNK_TYPE D_801AEFB8; //extern UNK_TYPE D_801AEFBC; //extern UNK_TYPE D_801AEFC0; -extern s800BF9A0_s* D_801AEFD0; // D_801AEFD0 +extern s800BF9A0_s D_801AEFD0; // D_801AEFD0 //extern UNK_TYPE D_801AEFE0; //extern UNK_TYPE D_801AEFE4; //extern UNK_TYPE D_801AEFEE; diff --git a/src/code/code_0x800BF9A0.c b/src/code/code_0x800BF9A0.c index de964f8b8d..1b22f04a4b 100644 --- a/src/code/code_0x800BF9A0.c +++ b/src/code/code_0x800BF9A0.c @@ -4,19 +4,39 @@ UNK_RET func_800BF9A0(UNK_TYPE a0, UNK_TYPE a1) { s32 i; s800BF9A0_s* s0; - + UNK_TYPE v1; + func_8008439C(-2, 0); func_800847CC(&D_801DCBB0, D_801B4610); func_800847CC(&D_801DCBC4); - - for (i = 0, s0 = D_801AEFD0; i < D_801B4610; i++, s0++) { + + for (i = 0, s0 = &D_801AEFD0; i < D_801B4610; i++, s0++) { + v1 = s0->unk12 - s0->unk8; if (s0->unk16 == 0) continue; - func_800847CC(&D_801DCBE4, i, s0->unk16, s0->unk16 + (s0->unk12 - s0->unk8), s0->unk30, &D_801DCBFC); + func_800847CC(&D_801DCBE4, i, s0->unk16, s0->unk16 + v1, s0->unk30, &D_801DCBFC); } } UNK_TYPE func_800BFA78(UNK_TYPE a0, UNK_TYPE a1) { - + s32 i; + s800BF9A0_s* v0 = &D_801AEFD0; + UNK_TYPE t1; + UNK_TYPE a2; + UNK_TYPE a0_2 = a0; + + for (i = 0; i < D_801B4610; i++, v0++) { + t1 = v0->unk8 - v0->unk16; + a2 = v0->unk12 - v0->unk8; + + if (v0->unk16 == 0) continue; + if (a0_2 < v0->unk16) continue; + + if (a0_2 < (v0->unk16 + a2)) { + return a0_2 + t1; + } + } + + return 0; } UNK_RET func_800BFAE8(UNK_ARGS) { diff --git a/variables.py b/variables.py index f6b59af520..512d10cb01 100644 --- a/variables.py +++ b/variables.py @@ -96,14 +96,14 @@ known_vars = { 0x8009E5B0:("__osCurrentTime","UNK_TYPE",False), # 0x8009E5B4:("__osCurrentTime","UNK_TYPE",False), 0x8009E5B8:("__osBaseCounter","UNK_TYPE",False), - 0x8009E5BC:("__osViIntrCount","UNK_TYPE",False), + 0x8009E5BC:("__osViIntrCount","UNK_TYPE",False), # actually an array of structs? 0x8009E5C0:("__osTimerCounter","UNK_TYPE",False), 0x8009E610:("","struct s80092920",False), 0x8009E624:("","UNK_TYPE",False), 0x801ADE80:("","UNK_TYPE",False), 0x801ADEAC:("","UNK_TYPE",False), 0x801ADEB0:("D_801ADEB0","int",True), # TODO better array representation - 0x801AEFD0:("","s800BF9A0_s*",False), + 0x801AEFD0:("","s800BF9A0_s",False), 0x801B4610:("","UNK_TYPE",False), 0x801DCBB0:("","UNK_TYPE",False), 0x801DCBC4:("","UNK_TYPE",False),