diff options
| author | ChiefFruitcake <96551211+ChiefFruitcake@users.noreply.github.com> | 2022-01-09 21:24:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-09 19:24:30 -0700 |
| commit | bc99dedb8bc0d8a1f6fed20e36ed60a3ed70b01b (patch) | |
| tree | 042743f4f487447c0c289f030064f2fa502cc9f4 /src | |
| parent | 7acd1cbc20ad7d5632d006de6c2fae322ca5c8c0 (diff) | |
code_800AF9B0 - ghost data (#133)
* Match functions related to struct at D_8018EE10
* Remove asm for matched functions
* Match func_800B64EC, func_800B6708, and func_800B6798
* Match func_80091EE4. Fix unused variable warnings in code_80091750.c
* Name some of the fields in struct_8018EE10_entry
Diffstat (limited to 'src')
| -rw-r--r-- | src/code_80091750.c | 47 | ||||
| -rw-r--r-- | src/code_800AF9B0.c | 221 | ||||
| -rw-r--r-- | src/code_800AF9B0.h | 15 |
3 files changed, 104 insertions, 179 deletions
diff --git a/src/code_80091750.c b/src/code_80091750.c index 7a5960a17..f49aefb3a 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -371,44 +371,27 @@ extern OSMesgQueue gSIEventMesgQueue; GLOBAL_ASM("asm/non_matchings/code_80091750/func_80091D74.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_800B5F30(); // extern -? func_800B64EC(s32); // extern -? func_800B6708(); // extern -extern s8 D_800E86F8; -extern s8 D_8018EDFB; -extern ? D_8018EE10; -extern s8 gCupSelection; - void func_80091EE4(void) { s32 temp_s0; s32 temp_s2; - void *temp_v0; - s32 phi_s0; - s32 phi_s0_2; + s32 tmp; D_800E86F8 = 0; - if ((D_8018EDFB != 0) && (func_800B5F30() == 0)) { + tmp = func_800B5F30(); + + if ((D_8018EDFB != 0) && (tmp == 0)) { temp_s2 = (gCupSelection * 4) + gCupCourseSelection; func_800B6708(); - phi_s0 = 0; - do { - temp_v0 = &D_8018EE10 + (phi_s0 << 7); - phi_s0_2 = phi_s0; - if ((temp_v0->unk4 != 0) && (temp_s2 == temp_v0->unk5)) { - func_800B64EC(phi_s0); + + for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { + if ((D_8018EE10[temp_s0].ghostDataSaved != 0) && (temp_s2 == D_8018EE10[temp_s0].courseIndex)) { + func_800B64EC(temp_s0); + temp_s0 = 2; D_8018EDFB = 0; - phi_s0_2 = 2; } - temp_s0 = phi_s0_2 + 1; - phi_s0 = temp_s0; - } while (temp_s0 < 2); + } } } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_80091EE4.s") -#endif #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 @@ -9232,7 +9215,7 @@ void func_800A09E0(struct_8018D9E0_entry *arg0) { GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A09E0.s") #endif -void func_800A0AD0(struct_8018D9E0_entry *unused) { +void func_800A0AD0(UNUSED struct_8018D9E0_entry *unused) { struct_8018D9E0_entry *temp_t1; // Find struct_8018D9E0_entry with a type/id of 0xDA temp_t1 = func_800AAEF4(0xDA); @@ -12619,7 +12602,7 @@ void func_800A7258(struct_8018D9E0_entry *arg0) { // Podium scene, top line void func_800A72FC(struct_8018D9E0_entry *arg0) { - s32 pad; + UNUSED s32 pad; s32 cupNameLength = (((f32) get_string_width(D_800E7500[gCupSelection]) * 1) + 10) / 2; s32 ccNameLength = (((f32) get_string_width(D_800E76CC[gCCSelection]) * 1) + 10) / 2; @@ -12630,7 +12613,7 @@ void func_800A72FC(struct_8018D9E0_entry *arg0) { } void func_800A7448(struct_8018D9E0_entry *arg0) { - s32 pad; + UNUSED s32 pad; s32 sp40; s32 sp3C; s32 thing = D_802874F5; @@ -12648,7 +12631,7 @@ void func_800A7448(struct_8018D9E0_entry *arg0) { } void func_800A75A0(struct_8018D9E0_entry *arg0) { - s32 pad; + UNUSED s32 pad; s32 topThree; if (D_802874F5 < 3) { @@ -13676,7 +13659,7 @@ void func_800A8CA4(void *arg0) { GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A8CA4.s") #endif -void func_800A8E14(struct_8018D9E0_entry *unused) { +void func_800A8E14(UNUSED struct_8018D9E0_entry *unused) { set_text_color(TEXT_YELLOW); draw_text(0x98, 0x44, D_800E77A8, 0, 1.0f, 1.0f); func_80093324(0x17, 0x58, D_800E77AC, 0, D_800F24A8, D_800F24AC); diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index b44da0f29..c915f263e 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -3687,14 +3687,12 @@ s32 func_800B6014(void) { return -1; } -void func_800B6088(s32 arg0) { - s32 temp_t6; - u8* temp_v1; - - temp_t6 = arg0 << 7; - temp_v1 = (u8*) &D_8018EE10 + temp_t6; - temp_v1[0x7F] = func_800B6828(); // compute checksum? - osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_WRITE, temp_t6, sizeof(struct_8018EE10_entry), temp_v1); +s32 func_800B6088(s32 arg0) { + struct_8018EE10_entry* temp_v1; + + temp_v1 = &D_8018EE10[arg0]; + temp_v1->checksum = func_800B6828(arg0); + return osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_WRITE, arg0 * 0x80 /* 0x80 == sizeof(struct_8018EE10_entry) */, sizeof(struct_8018EE10_entry), (u8*) temp_v1); } #ifdef MIPS_TO_C @@ -3826,141 +3824,97 @@ s32 func_800B6178(s32 arg0) { GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6178.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern ? D_8018EE10; - -? func_800B6348(s32 arg0) { - if ((D_8018EE10.unk4 != 0) && (arg0 == D_8018EE10.unk5)) { +s32 func_800B6348(s32 arg0) { + if ((D_8018EE10[0].ghostDataSaved != 0) && (arg0 == D_8018EE10[0].courseIndex)) { return 0; } - if ((D_8018EE10.unk84 != 0) && (arg0 == D_8018EE10.unk85)) { + if ((D_8018EE10[1].ghostDataSaved != 0) && (arg0 == D_8018EE10[1].courseIndex)) { return 1; } return 0; } -#else -GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6348.s") -#endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern ? D_8018EE10; - -? func_800B639C(s32 arg0) { - if ((D_8018EE10.unk4 != 0) && (arg0 == D_8018EE10.unk5)) { +s32 func_800B639C(s32 arg0) { + if ((D_8018EE10[0].ghostDataSaved != 0) && (arg0 == D_8018EE10[0].courseIndex)) { return 0; } - if ((D_8018EE10.unk84 != 0) && (arg0 == D_8018EE10.unk85)) { + if ((D_8018EE10[1].ghostDataSaved != 0) && (arg0 == D_8018EE10[1].courseIndex)) { return 1; } return -1; } -#else -GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B639C.s") -#endif - -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_800051C4(); // extern -? func_80005AE8(Player *); // extern -s32 func_800B60E8(s32); // extern -extern s16 D_80162DD6; -extern s32 D_80162DFC; -extern ? D_8018EE10; -extern s8 gCupSelection; -? func_800B63F0(s32 arg0) { +s32 func_800B63F0(s32 arg0) { s32 temp_s0; - void *temp_v0; - s32 phi_s0; - void *phi_s1; - ? phi_s3; + u8* phi_s1; + s32 phi_s3; func_800051C4(); D_80162DD6 = 1; func_80005AE8(gPlayerThree); - temp_v0 = (arg0 << 7) + &D_8018EE10; + phi_s3 = 0; - if (((gCupSelection * 4) + gCupCourseSelection) != temp_v0->unk5) { + if (((gCupSelection * 4) + gCupCourseSelection) != D_8018EE10[arg0].courseIndex) { phi_s3 = 2; - } else if (D_80162DFC != temp_v0->unk0) { + } else if (D_80162DFC != D_8018EE10[arg0].unk_00) { phi_s3 = 3; } else { - phi_s0 = 0; - phi_s1 = temp_v0; - if (D_80162DE0 != temp_v0->unk6) { + if (D_80162DE0 != (u8) D_8018EE10[arg0].characterId) { phi_s3 = 4; } else { -loop_6: - temp_s0 = phi_s0 + 1; - phi_s0 = temp_s0; - if (phi_s1->unk7 != func_800B60E8(phi_s0)) { - phi_s3 = 1; - } else { - phi_s1 += 1; - if (temp_s0 != 0x3C) { - goto loop_6; + temp_s0 = 0; + phi_s1 = (u8*) &D_8018EE10[arg0]; + + while (temp_s0 < 0x3C) + { + if (phi_s1[7] != func_800B60E8(temp_s0)) { + phi_s3 = 1; + break; } + + ++phi_s1; + ++temp_s0; } } } + return phi_s3; } -#else -GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B63F0.s") -#endif - -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8000522C(); // extern -s32 func_800B60E8(s32); // extern -extern u8 *D_800DC714; -extern s32 D_80162DFC; -extern OSPfs D_8018E868; -extern s32 D_8018EB84; -extern ? D_8018EE10; s32 func_800B64EC(s32 arg0) { - s32 sp30; s32 temp_s0; s32 temp_v0; - void *temp_s3; - s32 phi_s0; - void *phi_s1; + u8 *phi_s1; - if ((arg0 != 0) && (arg0 != 1)) { + if ((arg0 != 0) && (arg0 != 1)) + { return -1; } - temp_v0 = osPfsReadWriteFile(&D_8018E868, D_8018EB84, 0, (arg0 * 0x3C00) + 0x100, 0x3C00, D_800DC714); - sp30 = temp_v0; - if (temp_v0 == 0) { - temp_s3 = (arg0 << 7) + &D_8018EE10; - phi_s0 = 0; - phi_s1 = temp_s3; -loop_5: - temp_s0 = phi_s0 + 1; - phi_s0 = temp_s0; - if (phi_s1->unk7 != func_800B60E8(phi_s0)) { - temp_s3->unk4 = 0; - return -2; - } - phi_s1 += 1; - if (temp_s0 == 0x3C) { - func_8000522C(); - *D_80162DD4 = 0; - D_80162DE0 = temp_s3->unk6; - D_80162DFC = temp_s3->unk0; - goto block_9; + + temp_v0 = osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_READ, (arg0 * 0x3C00) + 0x100, 0x3C00, (u8 *) D_800DC714); + if (temp_v0 == 0) + { + phi_s1 = (u8 *) &D_8018EE10[arg0]; temp_s0 = 0; while (1) { + + if (phi_s1[7] != func_800B60E8(temp_s0)) { + D_8018EE10[arg0].ghostDataSaved = 0; + return -2; + } + + ++phi_s1; + if ((++temp_s0) == 0x3C) { + func_8000522C(); + D_80162DD4[0] = 0; + D_80162DE0 = (s32) D_8018EE10[arg0].characterId; + D_80162DFC = D_8018EE10[arg0].unk_00; + break; + } } - goto loop_5; + } -block_9: - return sp30; + + return temp_v0; } -#else -GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B64EC.s") -#endif #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 @@ -4012,62 +3966,35 @@ block_9: GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B65F4.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_800B6828(s32); // extern -extern OSPfs D_8018E868; -extern s32 D_8018EB84; -extern u8 D_8018EE10; - void func_800B6708(void) { s32 temp_s0; - s32 phi_s0; - u8 *phi_s1; - osPfsReadWriteFile(&D_8018E868, D_8018EB84, 0, 0, 0x100, &D_8018EE10); - phi_s0 = 0; - phi_s1 = &D_8018EE10; - do { - temp_s0 = phi_s0 + 1; - phi_s0 = temp_s0; - if (phi_s1->unk7F != func_800B6828(phi_s0)) { - phi_s1->unk4 = 0; + osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, (u8*) &D_8018EE10); + + for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { + if (D_8018EE10[temp_s0].checksum != func_800B6828(temp_s0)) { + D_8018EE10[temp_s0].ghostDataSaved = 0; } - phi_s1 += 0x80; - } while (temp_s0 != 2); + } } -#else -GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6708.s") -#endif - -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_800B68F4(s32); // extern -extern u8 *D_8018D9C0; -extern OSPfs D_8018E8D0; -extern s32 D_8018EB88; void func_800B6798(void) { s32 temp_s0; - u8 *temp_s2; - void *temp_v1; - s32 phi_s0; + u8* tmp; + + tmp = (u8*) D_8018D9C0; - temp_s2 = D_8018D9C0; - osPfsReadWriteFile(&D_8018E8D0, D_8018EB88, 0, 0, 0x100, temp_s2); - phi_s0 = 0; - do { - temp_v1 = temp_s2 + (phi_s0 << 7); - temp_s0 = phi_s0 + 1; - phi_s0 = temp_s0; - if (temp_v1->unk7F != func_800B68F4(phi_s0)) { - temp_v1->unk4 = 0; + osPfsReadWriteFile(&D_8018E8D0, D_8018EB88, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, tmp); + + for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { + // if (D_8018D9C0[temp_s0]->checksum != func_800B68F4(temp_s0)) { + // D_8018D9C0[temp_s0]->ghostDataSaved = 0; + // } + if ( ((struct_8018EE10_entry*) (tmp + (temp_s0 << 7)))->checksum != func_800B68F4(temp_s0)) { + ((struct_8018EE10_entry*) (tmp + (temp_s0 << 7)))->ghostDataSaved = 0; } - } while (temp_s0 != 2); + } } -#else -GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6798.s") -#endif #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 diff --git a/src/code_800AF9B0.h b/src/code_800AF9B0.h index a42e622db..535298cb6 100644 --- a/src/code_800AF9B0.h +++ b/src/code_800AF9B0.h @@ -58,9 +58,17 @@ s32 validate_save_data_checksum_backup(); s32 func_800B5B2C(s32); s32 func_800B5F30(); s32 func_800B6014(); +u8 func_800B60E8(s32); +u8 func_800B6828(s32); +u8 func_800B68F4(s32); void func_800B69BC(s32); s32 func_800B6A68(); +// staff_ghosts.c +s32 func_800051C4(); +void func_8000522C(); +void func_80005AE8(Player*); + // audio/external.c void play_sound2(s32); void func_800CA330(s32); @@ -82,6 +90,7 @@ extern s32 D_800DC540; extern s16 gCurrentCourseId; // D_800DC5A0 extern s32 gIsMirrorMode; // D_800DC5F4 extern s16 gPlaceItemBoxes; // D_800DC638 +extern u32* D_800DC714; extern s8 gGameModeRowSelectionForNumPlayers[SELECTED_PLAYER_DEFINES_TOTAL]; // D_800E869B. 0-4 players, game type row selected for each player amoun extern s8 gGameModeSubMenuRowSelectionForNumPlayers[SELECTED_PLAYER_DEFINES_TOTAL][MAX_NUM_MAIN_MENU_GAME_TYPES]; // D_800E869D. 0-4 players, 3 possible game types per player amouunt extern s32 D_800E86A4; @@ -97,6 +106,10 @@ extern u8 D_800F2E60[]; extern u8 D_800F2E64; extern u8 D_800F2E74; extern OSMesgQueue gSIEventMesgQueue; // D_8014F0B8 +extern u16 D_80162DD6; +extern s32 D_80162DE0; +extern s32 D_80162DFC; +extern struct_8018EE10_entry* D_8018D9C0; extern s32 D_8018E7A8; extern s8 D_8018E7B0; extern OSPfs D_8018E868; @@ -106,6 +119,7 @@ extern s32 D_8018EB38[16]; extern s32 D_8018EB78; extern s32 D_8018EB7C; extern s32 D_8018EB84; +extern s32 D_8018EB88; extern SaveData D_8018EB90; extern union GrandPrixPointsUnion D_8018ED10; // Direct reference to the grandPrixPoints section of save data extern u8 D_8018ED11; @@ -131,6 +145,7 @@ extern u8 gSoundMode; // D_8018EDF2 extern s8 D_8018EDF3; extern s8 gTimeTrialDataCourseIndex; // D_8018EDF7 extern s8 gCourseRecordsMenuSelection; // D_8018EDF8 +extern s8 D_8018EDFB; extern s32 gMenuTimingCounter; // D_8018EE00 extern s8 gCupSelection; // D_8018EE09 extern s8 D_8018EE0A; |
