diff options
| author | Tyler McGavran <tyler.taggerung@gmail.com> | 2021-11-29 00:44:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-28 21:44:46 -0800 |
| commit | c55c360b71f75a34f50c08d4f99c2a7a33d0b6f5 (patch) | |
| tree | c6f5d850577367a1502edb0f1438eab8db5f1913 /src/code_800AF9B0.c | |
| parent | 6451db9e40df089a42f78e8d3d37bcbd1d427ac1 (diff) | |
Add a structure for accessing save data (#69)
* Added save data struct
Signed-off-by: Taggerung <tyler.taggerung@gmail.com>
Diffstat (limited to 'src/code_800AF9B0.c')
| -rw-r--r-- | src/code_800AF9B0.c | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index c16c55be0..67fc383a9 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -1,10 +1,13 @@ #include <ultra64.h> #include <macros.h> #include <defines.h> +#include "global.h" +#include "common_structs.h" u32 func_802A7B70(u16 x); extern u32 D_8018EDB8; extern u32 D_8018EDBC; +extern SaveData D_8018EB90; void func_800AF9B0(void) { D_8018EDB8 = func_802A7B70(7680); @@ -3213,64 +3216,69 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4DCC.s") #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_800B4DF4(void *arg0) { - return ((arg0->unk1 << 8) + arg0->unk0 + (arg0->unk2 << 0x10)) & 0xFFFFFF; +// Convert time trial record from its little-endian form to big-endian +s32 func_800B4DF4(u8 *arg0) { + return (arg0[0] + (arg0[1] << 8) + (arg0[2] << 0x10)) & 0xFFFFFF; } #else GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4DF4.s") #endif -#ifdef MIPS_TO_C +#if 1 //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_800B4DF4(void *, s32); // extern -extern ? D_8018EB90; -extern s8 gCupSelection; - -void func_800B4E24(s32 arg0) { - s32 temp_v0; - - temp_v0 = (gCupSelection * 4) + gCourseSelection; - func_800B4DF4(((temp_v0 / 4) * 0x60) + ((temp_v0 % 4) * 0x18) + (arg0 * 3) + &D_8018EB90, arg0); +// Get a time trial record, infer course index +s32 func_800B4E24(s32 recordIndex) { + return func_800B4DF4( + D_8018EB90.allCourseTimeTrialRecords \ + .cupRecords[(((gCupSelection * 4) + gCourseSelection) / 4)] \ + .courseRecords[(((gCupSelection * 4) + gCourseSelection) % 4)] \ + .records[recordIndex] + ); } #else GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4E24.s") #endif -#ifdef MIPS_TO_C +#if 1 //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_800B4DF4(void *, s32); // extern -extern ? D_8018EB90; - -void func_800B4EB4(s32 arg0, s32 arg1) { - func_800B4DF4(((arg1 / 4) * 0x60) + ((arg1 % 4) * 0x18) + (arg0 * 3) + &D_8018EB90, arg0); +// Get a time trial record, but take the course index as an argument +s32 func_800B4EB4(s32 recordIndex, s32 courseIndex) { + return func_800B4DF4( + D_8018EB90.allCourseTimeTrialRecords \ + .cupRecords[(courseIndex / 4)] \ + .courseRecords[(courseIndex % 4)] \ + .records[recordIndex] + ); } #else GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4EB4.s") #endif -#ifdef MIPS_TO_C +#if 1 //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_800B4DF4(void *); // extern -extern ? D_8018EB90; -extern s8 gCupSelection; - -void func_800B4F2C(void) { - s32 temp_v0; - - temp_v0 = (gCupSelection * 4) + gCourseSelection; - func_800B4DF4(((temp_v0 / 4) * 0x60) + ((temp_v0 % 4) * 0x18) + 0xF + &D_8018EB90); +// Get Best Lap record of the inferred course index +s32 func_800B4F2C(void) { + return func_800B4DF4( + D_8018EB90.allCourseTimeTrialRecords \ + .cupRecords[(((gCupSelection * 4) + gCourseSelection) / 4)] \ + .courseRecords[(((gCupSelection * 4) + gCourseSelection) % 4)] \ + .records[TIME_TRIAL_1LAP_RECORD] + ); } #else GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4F2C.s") #endif -#ifdef MIPS_TO_C +#if 1 //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_800B4DF4(void *, s32); // extern -extern ? D_8018EB90; - -void func_800B4FB0(s32 arg0) { - func_800B4DF4(((arg0 / 4) * 0x60) + ((arg0 % 4) * 0x18) + 0xF + &D_8018EB90, arg0); +// Get the best single lap time record of the given course index +s32 func_800B4FB0(s32 courseIndex) { + return func_800B4DF4( + D_8018EB90.allCourseTimeTrialRecords \ + .cupRecords[(courseIndex / 4)] \ + .courseRecords[(courseIndex % 4)] \ + .records[TIME_TRIAL_1LAP_RECORD] + ); } #else GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4FB0.s") |
