From 3403482de3405d7fa33673420cff15c6d7f1bb53 Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Mon, 14 Feb 2022 00:04:03 -0500 Subject: [PATCH] Match the other D_80189DE0 search functions (#163) * Match the other D_80189DE0 search functions Signed-off-by: Taggerung --- src/code_80091750.c | 88 ++++++++++++++++++++------------------------- src/code_80091750.h | 1 + 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/src/code_80091750.c b/src/code_80091750.c index 21f57c614..33d316cb1 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -14575,60 +14575,48 @@ void func_800AAE18(struct_8018D9E0_entry *arg0) { } } -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern s32 D_8018D9E0; -extern ? D_8018DEE0; +/** + * Similar to find_8018D9E0_entry_dupe, there is potential for a + * hard lock in the function if no appropriate D_8018D9E0 entry + * is found. +**/ +struct_8018D9E0_entry *func_800AAE68(void) { + struct_8018D9E0_entry *entry = D_8018D9E0; + s32 thing = D_8018EDF3 - 1; -s32 *func_800AAE68(void) { - s32 *temp_v1; - s32 *phi_v1; - - phi_v1 = &D_8018D9E0; -loop_1: - if ((D_8018EDF3 - 1 + 0xB) != *phi_v1) { - temp_v1 = phi_v1 + 0x28; - phi_v1 = temp_v1; - if (&D_8018DEE0 < temp_v1) { -loop_3: - goto loop_3; + for(; !(entry > &D_8018D9E0[D_8018D9E0_SIZE]); entry++) { + if ((thing + 0xB) == entry->type) { + goto escape; } - goto loop_1; } - return phi_v1; + + // Something VERY wrong has occurred + while(TRUE); +escape: + return entry; +} + +/** + * Similar to find_8018D9E0_entry_dupe, there is potential for a + * hard lock in the function if no appropriate D_8018D9E0 entry + * is found. +**/ +struct_8018D9E0_entry *func_800AAEB4(s32 arg0) { + struct_8018D9E0_entry *entry = D_8018D9E0; + + for(; !(entry > &D_8018D9E0[D_8018D9E0_SIZE]); entry++) { + if ((arg0 + 0x2B) == entry->type) { + goto escape; + } + } + + // Something VERY wrong has occurred + while(TRUE); +escape: + return entry; } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AAE68.s") -#endif - -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern s32 D_8018D9E0; -extern ? D_8018DEE0; - -s32 *func_800AAEB4(s32 arg0) { - s32 *temp_v1; - s32 *phi_v1; - - phi_v1 = &D_8018D9E0; -loop_1: - if ((arg0 + 0x2B) != *phi_v1) { - temp_v1 = phi_v1 + 0x28; - phi_v1 = temp_v1; - if (&D_8018DEE0 < temp_v1) { -loop_3: - goto loop_3; - } - goto loop_1; - } - return phi_v1; -} -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AAEB4.s") -#endif /** - * @bug * `arg0` is the desired "type" of the 8018D9E0 entry to * search for. If no entry with that "type" is found, this * function will enter a `while(1)` loop, hard-locking the @@ -14646,8 +14634,8 @@ struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32 arg0) { } } - // I don't know why they'd want a function that could potentially hard lock the game... - while(1); + // Something VERY wrong has occurred + while(TRUE); escape: return entry; } diff --git a/src/code_80091750.h b/src/code_80091750.h index fe525cbfe..ce9b2874e 100644 --- a/src/code_80091750.h +++ b/src/code_80091750.h @@ -165,6 +165,7 @@ void func_800A94C8(struct_8018D9E0_entry*, s32, s32); void func_800A954C(struct_8018D9E0_entry*); void func_800AADD4(struct_8018D9E0_entry*); void func_800AAE18(struct_8018D9E0_entry*); +struct_8018D9E0_entry *func_800AAE68(); struct_8018D9E0_entry *func_800AAEB4(s32); struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32); struct_8018D9E0_entry *find_8018D9E0_entry(s32);