summaryrefslogtreecommitdiff
path: root/src/code_800AF9B0.c
diff options
context:
space:
mode:
authorTyler McGavran <tyler.taggerung@gmail.com>2021-12-11 02:34:07 -0500
committerGitHub <noreply@github.com>2021-12-11 00:34:07 -0700
commit7648ec12a78cf8c3324e405c84305cde7d9ef1bc (patch)
tree2deb4159cd4239020154b843238ee88d122ce366 /src/code_800AF9B0.c
parentda5f75188b138df6be2d177d08aa72c99466b0d8 (diff)
Match functions for Grand Prix save data access (#88)
* Match grand prix save data funcs Signed-off-by: Taggerung <tyler.taggerung@gmail.com>
Diffstat (limited to 'src/code_800AF9B0.c')
-rw-r--r--src/code_800AF9B0.c78
1 files changed, 34 insertions, 44 deletions
diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c
index a3e2999d5..383964446 100644
--- a/src/code_800AF9B0.c
+++ b/src/code_800AF9B0.c
@@ -3519,66 +3519,56 @@ void func_800B5404(s32 arg0, s32 arg1) {
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5404.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_800B54EC(u8, s32); // extern
-extern ? D_8018ED10;
+extern u8 D_8018ED10[4]; // Direct reference to the grandPrixPoints section of save data
+u8 func_800B54EC(s32, s32);
+u8 func_800B5508(s32, s32, s32);
-void func_800B54C0(s32 arg1) {
- func_800B54EC(*(&D_8018ED10 + arg1), arg1);
+// Get Grand Prix points for a given cup and CC mode
+u8 func_800B54C0(s32 cup, s32 cc_mode) {
+ return func_800B54EC(cup, D_8018ED10[cc_mode]);
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B54C0.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B54EC(s32 arg0, s32 arg1) {
- s32 temp_v1;
+// Get Grand Prix points scored for a given cup
+u8 func_800B54EC(s32 cup, s32 ccGrandPrixPoints) {
+ s32 cup_index = cup * 2;
+ u32 cup_points = ccGrandPrixPoints;
- temp_v1 = arg0 * 2;
- return ((arg1 & (3 << temp_v1)) >> temp_v1) & 0xFF;
+ cup_points &= (3 << cup_index);
+ cup_points >>= cup_index;
+ cup_points &= 0xFF;
+
+ return cup_points;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B54EC.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B5508(s32 arg0, s32 arg1, s32 arg2) {
- s32 temp_v1;
+// Generate a new CC Grand Prix Points entry with points_scored
+// placed in the given cup's location
+u8 func_800B5508(s32 cup, s32 ccGrandPrixPoints, s32 points_scored) {
+ s32 cup_index = cup * 2;
- temp_v1 = arg0 * 2;
- return ((arg1 & ~(3 << temp_v1)) | (arg2 << temp_v1)) & 0xFF;
-}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5508.s")
-#endif
+ points_scored <<= cup_index;
+ ccGrandPrixPoints &= ~(3 << cup_index);
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern ? D_8018ED10;
+ return (ccGrandPrixPoints | points_scored);
+}
-? func_800B5530(s32 arg0) {
- if (*(&D_8018ED10 + arg0) == 0xFF) {
+// Check if all 4 cups have gold cups scored
+// for a given CC mode
+s32 func_800B5530(s32 cc_mode) {
+ if (D_8018ED10[cc_mode] == 0xFF) {
return 1;
}
return 0;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5530.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_800B5530(?); // extern
+// Check if the 150CC mode has all 4 gold cups
+s32 func_800B555C(void) {
+ return func_800B5530(CC_150);
+}
-void func_800B555C(void) {
- func_800B5530(2);
+// Check if the Extra mode has all 4 gold cups
+s32 func_800B557C(void) {
+ return func_800B5530(CC_EXTRA);
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B555C.s")
-#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307