summaryrefslogtreecommitdiff
path: root/src/code_800AF9B0.c
diff options
context:
space:
mode:
authorChiefFruitcake <96551211+ChiefFruitcake@users.noreply.github.com>2022-01-06 22:32:57 -0500
committerGitHub <noreply@github.com>2022-01-06 20:32:57 -0700
commit7acd1cbc20ad7d5632d006de6c2fae322ca5c8c0 (patch)
tree18f524aff55c7cbc9c77e6a54bf9fe04b280d4c7 /src/code_800AF9B0.c
parentd6cbf56537a285a9e904c71715edc5d41be49357 (diff)
More matching in code_800AF9B0 (#131)
* Name variables related to selecting a game from the main menu * Match a couple functions requiring jumptable * Match func_800B4728 * Match func_800B536C, func_800B5888, func_800B5AAC, and func_800B5AD8 * Name functions related to loading and validating SaveData * Match func_800B4CB4 * Update selected player defines * Match func_800B5404 * Match func_800B6088
Diffstat (limited to 'src/code_800AF9B0.c')
-rw-r--r--src/code_800AF9B0.c837
1 files changed, 319 insertions, 518 deletions
diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c
index 0de1cbfe9..b44da0f29 100644
--- a/src/code_800AF9B0.c
+++ b/src/code_800AF9B0.c
@@ -1,10 +1,8 @@
#include <ultra64.h>
#include <macros.h>
#include <defines.h>
-#include <PR/os.h>
-#include <types.h>
#include "global.h"
-#include "common_structs.h"
+
#include "code_80091750.h"
#include "code_800AF9B0.h"
@@ -393,86 +391,61 @@ loop_5:
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B0004.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
-? func_8009E1C0(); /* extern */
-? func_800B053C(struct Controller *, s32); /* extern */
-? func_800B13B0(struct Controller *, s32); /* extern */
-? func_800B15AC(struct Controller *, s32); /* extern */
-? func_800B1C40(struct Controller *, s32); /* extern */
-? func_800B1C90(struct Controller *, s32); /* extern */
-? func_800B20F4(struct Controller *, s32); /* extern */
-? func_800B29D8(struct Controller *, s32); /* extern */
-? func_800B3554(struct Controller *, s32); /* extern */
-? func_800B3B58(struct Controller *, s32); /* extern */
-? func_800CA330(?); /* extern */
-? osViSetSpecialFeatures(s32); /* extern */
-? play_sound2(?); /* extern */
+#if NEEDS_RODATA
void func_800B0350(void) {
- s32 temp_t2_2;
- u32 temp_t2;
- u32 temp_v0;
- s32 phi_s0;
+ u16 controllerIdx;
if (D_800E86A4 == 0) {
- phi_s0 = 0;
- do {
- if ((func_800B4520() == 0) && (gEnableDebugMode != 0) && ((gControllers[phi_s0].buttonPressed & 0x1000) != 0)) {
- temp_v0 = gMenuSelection;
- if ((temp_v0 != MAIN_MENU) && (temp_v0 != PLAYER_SELECT_MENU)) {
- if (temp_v0 == COURSE_SELECT_MENU) {
+ for (controllerIdx = 0; controllerIdx < 4; controllerIdx++) {
+ if ((func_800B4520() == 0) && (gEnableDebugMode != 0) && ((gControllers[controllerIdx].buttonPressed & 0x1000) != 0)) {
+ if ((gMenuSelection != MAIN_MENU) && (gMenuSelection != PLAYER_SELECT_MENU)) {
+ if (gMenuSelection == COURSE_SELECT_MENU) {
func_800CA330(0x19);
- goto block_9;
}
- } else {
-block_9:
- play_sound2(0x49008016);
}
+ play_sound2(0x49008016);
if ((gMenuSelection != CONTROLLER_PAK_MENU) && (gMenuSelection != START_MENU)) {
func_8009E1C0();
}
}
osViSetSpecialFeatures(D_800E86E4);
- temp_t2 = gMenuSelection;
- switch (temp_t2) {
+ switch (gMenuSelection) {
case OPTIONS_MENU:
- func_800B053C(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B053C(&gControllers[controllerIdx], controllerIdx);
break;
case DATA_MENU:
- func_800B13B0(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B13B0(&gControllers[controllerIdx], controllerIdx);
break;
case COURSE_DATA_MENU:
- func_800B15AC(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B15AC(&gControllers[controllerIdx], controllerIdx);
break;
case LOGO_INTRO_MENU:
- func_800B1C40(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B1C40(&gControllers[controllerIdx], controllerIdx);
break;
case CONTROLLER_PAK_MENU:
- if (phi_s0 == 0) {
- func_800B1C90(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ if (controllerIdx == 0) {
+ func_800B1C90(&gControllers[controllerIdx], controllerIdx);
}
break;
case START_MENU_FROM_QUIT:
case START_MENU:
- func_800B20F4(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B20F4(&gControllers[controllerIdx], controllerIdx);
break;
case MAIN_MENU_FROM_QUIT:
case MAIN_MENU:
- func_800B29D8(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B29D8(&gControllers[controllerIdx], controllerIdx);
break;
case PLAYER_SELECT_MENU_FROM_QUIT:
case PLAYER_SELECT_MENU:
- func_800B3554(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B3554(&gControllers[controllerIdx], controllerIdx);
break;
case COURSE_SELECT_MENU_FROM_QUIT:
case COURSE_SELECT_MENU:
- func_800B3B58(&gControllers[phi_s0], phi_s0 & 0xFFFF);
+ func_800B3B58(&gControllers[controllerIdx], controllerIdx);
break;
}
- temp_t2_2 = (phi_s0 + 1) & 0xFFFF;
- phi_s0 = temp_t2_2;
- } while (temp_t2_2 < 4);
+ }
}
}
#else
@@ -484,9 +457,9 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B0350.s")
? func_8009E280(); /* extern */
void *func_800AAEF4(?); /* extern */
? func_800B44BC(); /* extern */
-? func_800B4670(); /* extern */
+? write_save_data_grand_prix_points_and_sound_mode(); /* extern */
? func_800B46D0(?, u16); /* extern */
-? func_800B5948(); /* extern */
+? update_save_data_backup(); /* extern */
? func_800B6088(s32); /* extern */
? func_800B6708(); /* extern */
? func_800B6798(); /* extern */
@@ -610,8 +583,8 @@ void func_800B053C(void *arg0, u16 arg1) {
gSaveDataSoundMode = gSoundMode;
sp20 = phi_a1;
sp38 = temp_t0;
- func_800B4670();
- func_800B5948();
+ write_save_data_grand_prix_points_and_sound_mode();
+ update_save_data_backup();
temp_t0->unk4 = gSoundMode;
phi_t1 = &D_8018EDEC;
}
@@ -623,8 +596,8 @@ void func_800B053C(void *arg0, u16 arg1) {
if (temp_t0->unk4 != gSoundMode) {
gSaveDataSoundMode = gSoundMode;
sp38 = temp_t0;
- func_800B4670();
- func_800B5948();
+ write_save_data_grand_prix_points_and_sound_mode();
+ update_save_data_backup();
temp_t0->unk4 = gSoundMode;
return;
}
@@ -1049,7 +1022,7 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B053C.s")
#endif
// Handle navigating the data menu interface
-void func_800B13B0(struct Controller *controller, s32 arg1) {
+void func_800B13B0(struct Controller *controller, UNUSED u16 arg1) {
u16 buttonAndStickPress = (controller->buttonPressed | controller->stickPressed);
// Make pressing Start have the same effect as pressing A
@@ -1381,197 +1354,156 @@ void func_800B15AC(void *arg0, ? arg1) {
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B15AC.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_8009E1E4(); // extern
-s32 func_800B4520(); // extern
-? func_800CA388(?); // extern
-
-void func_800B1C40(void *arg0, ? arg1) {
- u16 sp1E;
+// Handle controller input during the logo screen
+void func_800B1C40(struct Controller *arg0, UNUSED u16 arg1) {
+ u16 sp1E = arg0->buttonPressed | arg0->stickPressed;
- sp1E = arg0->unk6 | arg0->unkC;
if ((func_800B4520() == 0) && (sp1E != 0)) {
func_800CA388(0x3C);
func_8009E1E4();
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B1C40.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
-? func_8009E1C0(); /* extern */
-s32 osPfsDeleteFile(? *, u16, s32, void *, void *); /* extern */
-? play_sound2(?); /* extern */
-extern ? D_8018E868;
-extern ? D_8018E938;
-extern ? D_8018EB38;
-static ? D_800E86C6; /* unable to generate initializer; const */
-
-void func_800B1C90(void *arg0, s32 arg1) {
- u16 sp36;
- s32 sp2C;
- void *sp20;
- s32 temp_t0;
- s32 temp_v0;
- s8 temp_t9;
- void *temp_v1;
- sp36 = arg0->unk6 | arg0->unkC;
+#ifdef NEEDS_RODATA
+void func_800B1C90(struct Controller* controller, u16 arg1) {
+ u16 buttonAndStickPress;
+ OSPfsState* osPfsState;
+ s32 selectedTableRow;
+ s8 pad;
+
+ buttonAndStickPress = controller->buttonPressed | controller->stickPressed;
if (func_800B4520() == 0) {
- temp_t9 = gControllerPakMenuSelection;
- switch (temp_t9) {
+ switch (gControllerPakMenuSelection) {
case CONTROLLER_PAK_MENU_SELECT_RECORD:
- if ((sp36 & 0x9000) != 0) {
+ if ((buttonAndStickPress & 0x9000) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_TABLE_GAME_DATA;
play_sound2(0x49008001);
return;
}
- if ((sp36 & 0x300) != 0) {
+ if ((buttonAndStickPress & 0x300) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_END;
play_sound2(0x49008000);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
+ break;
case CONTROLLER_PAK_MENU_END:
- if ((sp36 & 0x9000) != 0) {
+ if ((buttonAndStickPress & 0x9000) != 0) {
play_sound2(0x49008001);
func_8009E1C0();
D_800E86F8 = 0;
return;
}
- if ((sp36 & 0x300) != 0) {
+ if ((buttonAndStickPress & 0x300) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_SELECT_RECORD;
play_sound2(0x49008000);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
+ break;
case CONTROLLER_PAK_MENU_TABLE_GAME_DATA:
- if ((sp36 & 0x9000) != 0) {
- if (*(&D_8018EB38 + ((*(&D_800E86C6 + gControllerPakSelectedTableRow) - 1) * 4)) == 0) {
+ if ((buttonAndStickPress & 0x9000) != 0) {
+ selectedTableRow = gDisplayedControllerPakTableRows[gControllerPakSelectedTableRow] - 1;
+ if (D_8018EB38[selectedTableRow] == 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_QUIT;
play_sound2(0x49008001);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
- }
- if ((sp36 & 0x4000) != 0) {
- if (*D_800E86D0 == 0) {
+ } else if ((buttonAndStickPress & 0x4000) != 0) {
+ if (D_800E86D0 == 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_SELECT_RECORD;
play_sound2(0x49008002);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
- }
- if ((sp36 & 0x800) != 0) {
- if (*D_800E86D0 == 0) {
- gControllerPakSelectedTableRow += -1;
+ } else if ((buttonAndStickPress & 0x800) != 0) {
+ if (D_800E86D0 == 0) {
+ --gControllerPakSelectedTableRow;
if (gControllerPakSelectedTableRow < 0) {
gControllerPakSelectedTableRow = 0;
- if (*(&D_800E86C6 + gControllerPakSelectedTableRow) != 1) {
- *D_800E86D0 = 2;
+ if (gDisplayedControllerPakTableRows[gControllerPakSelectedTableRow] != 1) {
+ D_800E86D0 = 2;
play_sound2(0x49008000);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
+ } else {
+ play_sound2(0x49008000);
return;
}
- play_sound2(0x49008000);
- return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
- }
- if (((sp36 & 0x400) != 0) && (*D_800E86D0 == 0)) {
- gControllerPakSelectedTableRow += 1;
- if (gControllerPakSelectedTableRow >= 5) {
- gControllerPakSelectedTableRow = 4;
- if (*(&D_800E86C6 + gControllerPakSelectedTableRow) != 0x10) {
- *D_800E86D0 = 1;
+ } else if (((buttonAndStickPress & 0x400) != 0) && (D_800E86D0 == 0)) {
+ ++gControllerPakSelectedTableRow;
+ if (gControllerPakSelectedTableRow >= CONTROLLER_PAK_MENU_TABLE_GAME_DATA) {
+ gControllerPakSelectedTableRow = CONTROLLER_PAK_MENU_QUIT;
+ if (gDisplayedControllerPakTableRows[gControllerPakSelectedTableRow] != 0x10) {
+ D_800E86D0 = 1;
play_sound2(0x49008000);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
+ } else {
+ play_sound2(0x49008000);
return;
}
- play_sound2(0x49008000);
- return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
+ break;
case CONTROLLER_PAK_MENU_QUIT:
- if ((sp36 & 0xD000) != 0) {
+ if ((buttonAndStickPress & 0xD000) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_TABLE_GAME_DATA;
play_sound2(0x49008002);
return;
}
- if ((sp36 & 0x300) != 0) {
+ if ((buttonAndStickPress & 0x300) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_ERASE;
play_sound2(0x49008000);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
+ break;
case CONTROLLER_PAK_MENU_ERASE:
- if ((sp36 & 0x9000) != 0) {
+ if ((buttonAndStickPress & 0x9000) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_GO_TO_ERASING;
play_sound2(0x49008001);
return;
}
- if ((sp36 & 0x4000) != 0) {
+ if ((buttonAndStickPress & 0x4000) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_TABLE_GAME_DATA;
play_sound2(0x49008002);
return;
}
- if ((sp36 & 0x300) != 0) {
+ if ((buttonAndStickPress & 0x300) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_QUIT;
play_sound2(0x49008000);
return;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
+ break;
case CONTROLLER_PAK_MENU_GO_TO_ERASING:
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_ERASING;
return;
case CONTROLLER_PAK_MENU_ERASING:
- temp_t0 = *(&D_800E86C6 + gControllerPakSelectedTableRow) - 1;
- temp_v1 = (temp_t0 << 5) + &D_8018E938;
- sp20 = temp_v1;
- sp2C = temp_t0;
- temp_v0 = osPfsDeleteFile(&D_8018E868, temp_v1->unk8, temp_v1->unk4, temp_v1 + 0xE, temp_v1 + 0xA);
- if (temp_v0 != 0) {
- if (temp_v0 != PFS_ERR_NOPACK) {
- if (temp_v0 != PFS_ERR_NEW_PACK) {
- gControllerPakMenuSelection = CONTROLLER_PAK_MENU_ERASE_ERROR_NOT_ERASED;
- return;
- }
- gControllerPakMenuSelection = CONTROLLER_PAK_MENU_ERASE_ERROR_PAK_CHANGED;
- return;
- }
+ selectedTableRow = gDisplayedControllerPakTableRows[gControllerPakSelectedTableRow] - 1;
+ osPfsState = &D_8018E938[selectedTableRow];
+
+ switch (osPfsDeleteFile(&D_8018E868, osPfsState->company_code, osPfsState->game_code, &osPfsState->game_name, &osPfsState->ext_name)) {
+ default:
+ gControllerPakMenuSelection = CONTROLLER_PAK_MENU_ERASE_ERROR_NOT_ERASED;
+ return;
+ case 0:
+ D_8018EB38[selectedTableRow] = -1;
+ gControllerPakNumPagesFree += (((osPfsState->file_size + 0xFF) >> 8) & 0xFF);
+ gControllerPakMenuSelection = CONTROLLER_PAK_MENU_TABLE_GAME_DATA;
+ return;
+ case PFS_ERR_NOPACK:
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_ERASE_ERROR_NO_PAK;
return;
+ case PFS_ERR_NEW_PACK: /* switch 1 */
+ gControllerPakMenuSelection = CONTROLLER_PAK_MENU_ERASE_ERROR_PAK_CHANGED;
+ return;
}
- *(&D_8018EB38 + (temp_t0 * 4)) = -1;
- gControllerPakNumPagesFree = gControllerPakNumPagesFree + (((temp_v1->unk0 + 0xFF) >> 8) & 0xFF);
- gControllerPakMenuSelection = CONTROLLER_PAK_MENU_TABLE_GAME_DATA;
- return;
+ break;
case CONTROLLER_PAK_MENU_ERASE_ERROR_NOT_ERASED:
case CONTROLLER_PAK_MENU_ERASE_ERROR_NO_PAK:
case CONTROLLER_PAK_MENU_ERASE_ERROR_PAK_CHANGED:
- if ((sp36 & 0x9000) != 0) {
+ if ((buttonAndStickPress & 0x9000) != 0) {
gControllerPakMenuSelection = CONTROLLER_PAK_MENU_TABLE_GAME_DATA;
}
- /* Duplicate return node #49. Try simplifying control flow for better match */
- return;
+ break;
}
- } else {
- default:
}
}
#else
@@ -1582,10 +1514,10 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B1C90.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
? func_8009E1C0(); /* extern */
? func_800B44BC(); /* extern */
-? func_800B4670(); /* extern */
-? func_800B4820(); /* extern */
+? write_save_data_grand_prix_points_and_sound_mode(); /* extern */
+? reset_save_data_grand_prix_points_and_sound_mode(); /* extern */
? func_800B5404(s32, s32); /* extern */
-? func_800B5948(); /* extern */
+? update_save_data_backup(); /* extern */
? func_800CA330(?); /* extern */
? play_sound2(?, s32); /* extern */
static ? D_800F2B50; /* unable to generate initializer; const */
@@ -1746,8 +1678,8 @@ void func_800B20F4(void *arg0, s32 arg1) {
play_sound2(0x49008000);
func_800B44BC();
gSaveDataSoundMode = gSoundMode;
- func_800B4670();
- func_800B5948();
+ write_save_data_grand_prix_points_and_sound_mode();
+ update_save_data_backup();
}
}
if ((sp2E & 0x200) != 0) {
@@ -1760,7 +1692,7 @@ void func_800B20F4(void *arg0, s32 arg1) {
play_sound2(0x49008000);
func_800B44BC();
gSaveDataSoundMode = gSoundMode;
- func_800B4670();
+ write_save_data_grand_prix_points_and_sound_mode();
}
}
if ((sp2E & 0x800) != 0) {
@@ -1790,7 +1722,7 @@ void func_800B20F4(void *arg0, s32 arg1) {
} while (temp_a1 < 0x10);
play_sound2(0x49008001, temp_a1);
} else if ((sp2E & 0x20) != 0) {
- func_800B4820();
+ reset_save_data_grand_prix_points_and_sound_mode();
phi_a1_2 = 0;
phi_s0_2 = 0;
do {
@@ -1801,7 +1733,7 @@ void func_800B20F4(void *arg0, s32 arg1) {
} while (temp_a1_2 < 0x10);
play_sound2(0x49008001, temp_a1_2);
} else if ((sp2E & 0x200) != 0) {
- func_800B4820();
+ reset_save_data_grand_prix_points_and_sound_mode();
phi_a1_3 = 0;
phi_s0_3 = 0;
do {
@@ -1865,61 +1797,40 @@ void func_800B20F4(void *arg0, s32 arg1) {
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B20F4.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern s16 D_800DC648;
-extern ? D_800E86AB;
-extern ? D_800E86AD;
-extern ? D_800F2B70;
-
void func_800B28C8(void) {
- s32 temp_a1;
- s8 temp_a0;
- s8 temp_v0;
- s8 temp_v1;
-
- temp_v1 = D_8018EDF3;
- temp_a0 = *(&D_800E86AB + temp_v1);
- temp_a1 = *(&D_800F2B70 + ((temp_v1 * 0xC) + (temp_a0 * 4)));
- temp_v0 = *(&D_800E86AD + ((temp_v1 * 3) + temp_a0));
- if (temp_a1 != 0) {
- if (temp_a1 != 1) {
- if (temp_a1 != 2) {
- if (temp_a1 != 3) {
- return;
- }
- D_800DC648 = 1;
- gIsMirrorMode = 0;
- return;
- }
- gCCSelection = temp_v0;
- D_800DC648 = 1;
- if (temp_v0 == CC_EXTRA) {
- gIsMirrorMode = 1;
- return;
- }
- gIsMirrorMode = 0;
- return;
- }
+ // For Grand Prix and Versus, this will be the CC mode selected. For Time Trials, it will
+ // be whether 'Begin' or 'Data' is selected. Not used for Battle.
+ s8 temp_v0 = gGameModeSubMenuRowSelectionForNumPlayers[D_8018EDF3][gGameModeRowSelectionForNumPlayers[D_8018EDF3]];
+
+ // Determine which game mode was selected based on the number of players and the row selected on the main menu
+ switch (gGameModeFromNumPlayersAndRowSelection[D_8018EDF3][gGameModeRowSelectionForNumPlayers[D_8018EDF3]]) {
+ case GRAND_PRIX:
+ gCCSelection = temp_v0;
+ gPlaceItemBoxes = 1;
+ gIsMirrorMode = (temp_v0 == CC_EXTRA) ? 1 : 0;
+ break;
+ case VERSUS:
+ gCCSelection = temp_v0;
+ gPlaceItemBoxes = 1;
+ gIsMirrorMode = (temp_v0 == CC_EXTRA) ? 1 : 0;
+ break;
+ case BATTLE:
+ gPlaceItemBoxes = 1;
+ gIsMirrorMode = 0;
+ break;
+ case TIME_TRIALS:
gCCSelection = CC_100;
gIsMirrorMode = 0;
- D_800DC648 = 0;
- if (temp_v0 != 0) {
+ gPlaceItemBoxes = 0;
+
+ if ((temp_v0 && temp_v0) && temp_v0) {
}
- return;
- }
- gCCSelection = temp_v0;
- D_800DC648 = 1;
- if (temp_v0 == CC_EXTRA) {
- gIsMirrorMode = 1;
- return;
+
+ break;
}
- gIsMirrorMode = 0;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B28C8.s")
-#endif
+
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
@@ -1931,14 +1842,14 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B28C8.s")
? func_800B44AC(s8, u16, u16); /* extern */
? func_800CA330(?); /* extern */
? play_sound2(?, u16, u16); /* extern */
-static ? D_800E86AB; /* unable to generate initializer; const */
+static ? gGameModeRowSelectionForNumPlayers; /* unable to generate initializer; const */
static ? D_800E86AC; /* unable to generate initializer; const */
-static ? D_800E86AD; /* unable to generate initializer; const */
+static ? gGameModeSubMenuRowSelectionForNumPlayers; /* unable to generate initializer; const */
static ? D_800E86B0; /* unable to generate initializer; const */
static ? D_800F2B5F; /* unable to generate initializer; const */
static ? D_800F2B61; /* unable to generate initializer; const */
static ? D_800F2B6D; /* unable to generate initializer; const */
-static ? D_800F2B70; /* unable to generate initializer; const */
+static ? gGameModeFromNumPlayersAndRowSelection; /* unable to generate initializer; const */
void func_800B29D8(void *arg0, u16 arg1) {
u16 sp2E;
@@ -2013,7 +1924,7 @@ void func_800B29D8(void *arg0, u16 arg1) {
switch (temp_t4) {
case BLANK_MAIN_MENU:
temp_t5 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t5 * 0xC) + (*(&D_800E86AB + temp_t5) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t5 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t5) * 4));
break;
case PLAYER_NUM_SELECTION:
phi_a2 = phi_v1;
@@ -2060,27 +1971,27 @@ void func_800B29D8(void *arg0, u16 arg1) {
D_8018EDE0 = 1;
play_sound2(0x49008002);
temp_t7 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t7 * 0xC) + (*(&D_800E86AB + temp_t7) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t7 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t7) * 4));
} else if ((phi_a2 & 0x8000) != 0) {
*phi_t0 = GAME_MODE_SELECTION;
func_800B44AC(phi_a0);
play_sound2(0x49008001);
temp_t4_2 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t4_2 * 0xC) + (*(&D_800E86AB + temp_t4_2) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t4_2 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t4_2) * 4));
} else if ((phi_a2 & 0x20) != 0) {
*phi_t0 = OPTIONS_SELECTION;
func_8009E280(phi_a0);
play_sound2(0x49009010);
temp_t1 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t1 * 0xC) + (*(&D_800E86AB + temp_t1) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t1 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t1) * 4));
} else if ((phi_a2 & 0x10) != 0) {
*phi_t0 = DATA_SELECTION;
func_8009E258(phi_a0);
play_sound2(0x49009011);
temp_t6 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t6 * 0xC) + (*(&D_800E86AB + temp_t6) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t6 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t6) * 4));
} else {
- phi_v1_3 = &D_800F2B70 + ((phi_v0 * 0xC) + (*(&D_800E86AB + phi_v0) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((phi_v0 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + phi_v0) * 4));
}
break;
case GAME_MODE_SELECTION:
@@ -2112,12 +2023,12 @@ void func_800B29D8(void *arg0, u16 arg1) {
func_800B44AC(3);
play_sound2(0x49008002);
temp_t6_2 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t6_2 * 0xC) + (*(&D_800E86AB + temp_t6_2) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t6_2 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t6_2) * 4));
} else {
temp_v0_4 = D_8018EDF3;
- temp_a0_3 = *(&D_800E86AB + temp_v0_4);
+ temp_a0_3 = *(&gGameModeRowSelectionForNumPlayers + temp_v0_4);
if ((phi_v1 & 0x8000) != 0) {
- temp_v1_3 = *(&D_800F2B70 + ((temp_v0_4 * 0xC) + (temp_a0_3 * 4)));
+ temp_v1_3 = *(&gGameModeFromNumPlayersAndRowSelection + ((temp_v0_4 * 0xC) + (temp_a0_3 * 4)));
if (temp_v1_3 != 0) {
if (temp_v1_3 != 1) {
if (temp_v1_3 != 2) {
@@ -2142,20 +2053,20 @@ void func_800B29D8(void *arg0, u16 arg1) {
func_800B44AC();
temp_t7_2 = D_8018EDF3;
gMenuTimingCounter = 0;
- phi_v1_3 = &D_800F2B70 + ((temp_t7_2 * 0xC) + (*(&D_800E86AB + temp_t7_2) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t7_2 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t7_2) * 4));
} else {
- phi_v1_3 = &D_800F2B70 + ((temp_v0_4 * 0xC) + (temp_a0_3 * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_v0_4 * 0xC) + (temp_a0_3 * 4));
}
}
break;
case GAME_MODE_CC_OR_TIME_TRIALS_OPTIONS_SELECTION:
case TIME_TRAILS_DATA_SELECTION_FROM_BACK_OUT:
- if ((arg1 == 0) && ((temp_t7_3 = gMenuTimingCounter + 1, gMenuTimingCounter = temp_t7_3, (temp_t7_3 == 0x64)) || ((temp_t7_3 % 300) == 0)) && ((temp_v0_5 = D_8018EDF3, temp_v1_4 = *(&D_800F2B70 + ((temp_v0_5 * 0xC) + (*(&D_800E86AB + temp_v0_5) * 4))), (temp_v1_4 == 0)) || (temp_v1_4 == 2))) {
+ if ((arg1 == 0) && ((temp_t7_3 = gMenuTimingCounter + 1, gMenuTimingCounter = temp_t7_3, (temp_t7_3 == 0x64)) || ((temp_t7_3 % 300) == 0)) && ((temp_v0_5 = D_8018EDF3, temp_v1_4 = *(&gGameModeFromNumPlayersAndRowSelection + ((temp_v0_5 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_v0_5) * 4))), (temp_v1_4 == 0)) || (temp_v1_4 == 2))) {
sp1C = phi_v1;
play_sound2(0x4900900E, arg1, phi_v1);
}
temp_v0_6 = D_8018EDF3;
- temp_v1_5 = (temp_v0_6 * 3) + *(&D_800E86AB + temp_v0_6) + &D_800E86B0;
+ temp_v1_5 = (temp_v0_6 * 3) + *(&gGameModeRowSelectionForNumPlayers + temp_v0_6) + &D_800E86B0;
temp_a0_4 = temp_v1_5->unk-3;
phi_a1 = temp_a0_4;
if (((phi_v1 & 0x800) != 0) && (temp_a0_4 > 0)) {
@@ -2173,7 +2084,7 @@ void func_800B29D8(void *arg0, u16 arg1) {
phi_v1_2 = sp24;
if (func_800B555C() != 0) {
temp_v0_7 = D_8018EDF3;
- temp_a0_5 = *(&D_800E86AB + temp_v0_7);
+ temp_a0_5 = *(&gGameModeRowSelectionForNumPlayers + temp_v0_7);
phi_v0_2 = temp_v0_7;
phi_a0_2 = temp_a0_5;
phi_v0_2 = temp_v0_7;
@@ -2183,7 +2094,7 @@ void func_800B29D8(void *arg0, u16 arg1) {
}
} else {
temp_v0_8 = D_8018EDF3;
- temp_a0_6 = *(&D_800E86AB + temp_v0_8);
+ temp_a0_6 = *(&gGameModeRowSelectionForNumPlayers + temp_v0_8);
phi_v0_2 = temp_v0_8;
phi_a0_2 = temp_a0_6;
phi_v0_2 = temp_v0_8;
@@ -2202,19 +2113,19 @@ block_64:
}
}
temp_v0_9 = D_8018EDF3;
- temp_a0_7 = *(&D_800E86AB + temp_v0_9);
- temp_a1 = *(&D_800E86AD + ((temp_v0_9 * 3) + temp_a0_7));
+ temp_a0_7 = *(&gGameModeRowSelectionForNumPlayers + temp_v0_9);
+ temp_a1 = *(&gGameModeSubMenuRowSelectionForNumPlayers + ((temp_v0_9 * 3) + temp_a0_7));
if ((phi_v1 & 0x4000) != 0) {
gMainMenuSelectionDepth = GAME_MODE_SELECTION;
func_800B44AC(temp_a0_7, temp_a1, phi_v1);
play_sound2(0x49008002);
temp_t5_2 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t5_2 * 0xC) + (*(&D_800E86AB + temp_t5_2) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t5_2 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t5_2) * 4));
} else if ((phi_v1 & 0x8000) != 0) {
sp28 = temp_a1;
func_800B44AC(temp_a0_7, temp_a1, phi_v1);
temp_v0_10 = D_8018EDF3;
- if ((temp_v0_10 == 1) && (*(&D_800E86AB + temp_v0_10) == 1) && (temp_a1 == 1)) {
+ if ((temp_v0_10 == 1) && (*(&gGameModeRowSelectionForNumPlayers + temp_v0_10) == 1) && (temp_a1 == 1)) {
func_8009E258();
play_sound2(0x49009011);
} else {
@@ -2223,9 +2134,9 @@ block_64:
gMenuTimingCounter = 0;
}
temp_t7_4 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t7_4 * 0xC) + (*(&D_800E86AB + temp_t7_4) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t7_4 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t7_4) * 4));
} else {
- phi_v1_3 = &D_800F2B70 + ((temp_v0_9 * 0xC) + (temp_a0_7 * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_v0_9 * 0xC) + (temp_a0_7 * 4));
}
break;
case CONFIRM_OK_SELECTION:
@@ -2236,7 +2147,7 @@ block_64:
}
if ((phi_v1 & 0x4000) != 0) {
temp_v0_11 = D_8018EDF3;
- temp_v1_7 = *(&D_800F2B70 + ((temp_v0_11 * 0xC) + (*(&D_800E86AB + temp_v0_11) * 4)));
+ temp_v1_7 = *(&gGameModeFromNumPlayersAndRowSelection + ((temp_v0_11 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_v0_11) * 4)));
if ((temp_v1_7 != 0) && (temp_v1_7 != 1) && (temp_v1_7 != 2)) {
if (temp_v1_7 != 3) {
@@ -2249,26 +2160,26 @@ block_64:
play_sound2(0x49008002);
temp_t7_6 = D_8018EDF3;
gMenuTimingCounter = 0;
- phi_v1_3 = &D_800F2B70 + ((temp_t7_6 * 0xC) + (*(&D_800E86AB + temp_t7_6) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t7_6 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t7_6) * 4));
} else if ((phi_v1 & 0x8000) != 0) {
func_8009E1C0();
play_sound2(0x49008016);
func_800B28C8();
temp_t1_2 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t1_2 * 0xC) + (*(&D_800E86AB + temp_t1_2) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t1_2 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t1_2) * 4));
} else {
temp_t4_3 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t4_3 * 0xC) + (*(&D_800E86AB + temp_t4_3) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t4_3 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t4_3) * 4));
}
break;
case OPTIONS_SELECTION:
case DATA_SELECTION:
temp_t2 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t2 * 0xC) + (*(&D_800E86AB + temp_t2) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t2 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t2) * 4));
break;
default:
temp_t8 = D_8018EDF3;
- phi_v1_3 = &D_800F2B70 + ((temp_t8 * 0xC) + (*(&D_800E86AB + temp_t8) * 4));
+ phi_v1_3 = &gGameModeFromNumPlayersAndRowSelection + ((temp_t8 * 0xC) + (*(&gGameModeRowSelectionForNumPlayers + temp_t8) * 4));
break;
}
gModeSelection = *phi_v1_3;
@@ -2519,12 +2430,12 @@ void func_800B3F74(u32 arg0) {
gCupSelection = MUSHROOM_CUP;
gCupCourseSelection = CUP_COURSE_ONE;
gTimeTrialDataCourseIndex = TIME_TRIAL_DATA_LUIGI_RACEWAY;
- if (D_8018EDF3 <= 0) {
- D_8018EDF3 = 1;
+ if (D_8018EDF3 <= ZERO_PLAYERS_SELECTED) {
+ D_8018EDF3 = ONE_PLAYERS_SELECTED;
}
phi_a3 = D_8018EDF3;
- if (D_8018EDF3 >= 5) {
- D_8018EDF3 = 4;
+ if (D_8018EDF3 >= SELECTED_PLAYER_DEFINES_TOTAL) {
+ D_8018EDF3 = FOUR_PLAYERS_SELECTED;
phi_a3 = D_8018EDF3;
}
D_8018EDF1 = *(&D_800F2BDF + phi_a3);
@@ -2570,7 +2481,7 @@ void func_800B3F74(u32 arg0) {
gMainMenuSelectionDepth = PLAYER_NUM_SELECTION;
func_800C8EAC(2, &gMainMenuSelectionDepth, 3);
temp_v0_3 = gScreenModeSelection;
- D_8018EDF3 = 1;
+ D_8018EDF3 = ONE_PLAYERS_SELECTED;
if ((temp_v0_3 >= NUM_SCREEN_MODES) || (temp_v0_3 < SCREEN_MODE_1P)) {
gScreenModeSelection = SCREEN_MODE_1P;
}
@@ -2749,9 +2660,9 @@ void func_800B45E0(s32 arg0) {
osEepromLongWrite(&gSIEventMesgQueue, ((u32)courseTimeTrialRecordsPtr - (u32)&D_8018EB90) >> 3, (u8*) courseTimeTrialRecordsPtr, sizeof(CourseTimeTrialRecords));
}
-void func_800B4670(void) {
- D_8018ED16 = func_800B492C();
- D_8018ED17 = func_800B49E4();
+void write_save_data_grand_prix_points_and_sound_mode(void) {
+ D_8018ED16 = compute_save_data_checksum_1();
+ D_8018ED17 = compute_save_data_checksum_2();
osEepromLongWrite(&gSIEventMesgQueue, (((u32)&D_8018ED10 - (u32)&D_8018EB90) >> 3), (u8*) &D_8018ED10, 8);
}
@@ -2766,71 +2677,46 @@ void func_800B46D0(void) {
temp_s0 = phi_s0 + 1;
phi_s0 = temp_s0;
} while (phi_s0 != 0x10);
- func_800B4820();
- func_800B5948();
+ reset_save_data_grand_prix_points_and_sound_mode();
+ update_save_data_backup();
}
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_800B45E0(s32); // extern
-s8 func_800B4874(s32, s32, s32, void *); // extern
-extern u8 D_800F2E60;
-extern ? D_8018EB90;
-
void func_800B4728(s32 arg0) {
- void *sp18;
s32 temp_a2;
- s32 temp_a2_2;
s32 temp_v0;
- void *temp_a3;
- u8 *phi_v1;
- s32 phi_a2;
- s32 phi_v0;
- u8 *phi_v0_2;
- s32 phi_a2_2;
+ CourseTimeTrialRecords* courseTimeTrialRecords;
- temp_a3 = ((arg0 / 4) * 0x60) + ((arg0 % 4) * 0x18) + &D_8018EB90;
- phi_a2 = 0;
- phi_a2_2 = 0;
- do {
- phi_v1 = &D_800F2E60;
- phi_v0 = 0;
-loop_2:
- temp_v0 = phi_v0 + 1;
- *(temp_a3 + (phi_a2 * 3) + phi_v0) = *phi_v1;
- phi_v1 += 1;
- phi_v0 = temp_v0;
- if (temp_v0 != 3) {
- goto loop_2;
+ courseTimeTrialRecords = &D_8018EB90.allCourseTimeTrialRecords \
+ .cupRecords[arg0 / 4] \
+ .courseRecords[arg0 % 4];
+
+ for (temp_a2 = 0; temp_a2 < 5; ++temp_a2)
+ {
+ for (temp_v0 = 0; temp_v0 < 3; ++temp_v0)
+ {
+ courseTimeTrialRecords->records[temp_a2][temp_v0] = D_800F2E60[temp_v0];
}
- temp_a2 = phi_a2 + 1;
- phi_a2 = temp_a2;
- } while (temp_a2 < 5);
- phi_v0_2 = &D_800F2E60;
- do {
- temp_a2_2 = phi_a2_2 + 1;
- (temp_a3 + phi_a2_2)->unkF = *phi_v0_2;
- phi_v0_2 += 1;
- phi_a2_2 = temp_a2_2;
- } while (temp_a2_2 != 3);
- temp_a3->unk12 = 0;
- sp18 = temp_a3;
- temp_a3->unk17 = func_800B4874(arg0, 3, temp_a2_2, temp_a3);
+ }
+
+ for (temp_a2 = 0; temp_a2 < 3; ++temp_a2)
+ {
+ courseTimeTrialRecords->records[5][temp_a2] = D_800F2E60[temp_a2];
+ }
+
+ courseTimeTrialRecords->unknownBytes[0] = 0;
+ courseTimeTrialRecords->unknownBytes[5] = func_800B4874(arg0);
func_800B45E0(arg0);
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4728.s")
-#endif
-void func_800B4820(void) {
- D_8018ED10[0] = 0;
+void reset_save_data_grand_prix_points_and_sound_mode(void) {
+ D_8018ED10.grandPrixPointsMushroomCup = 0;
D_8018ED11 = 0;
D_8018ED12 = 0;
D_8018ED13 = 0;
gSaveDataSoundMode = SOUND_STEREO;
gSoundMode = SOUND_STEREO;
func_800B44BC();
- func_800B4670();
+ write_save_data_grand_prix_points_and_sound_mode();
}
s32 func_800B4874(s32 arg0) {
@@ -2860,33 +2746,27 @@ s32 func_800B4874(s32 arg0) {
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern u8 D_8018ED10;
+extern union GrandPrixPointsUnion D_8018ED10;
-s32 func_800B492C(void) {
+s32 compute_save_data_checksum_1(void) {
void *temp_a0;
temp_a0 = &D_8018ED10 + 1;
- return ((D_8018ED10 + 1 + ((temp_a0->unk0 + 1) * 2) + 1 + ((temp_a0->unk1 + 1) * 3) + 1 + 1 + ((temp_a0->unk2 + 1) * 4) + 1 + 2 + ((temp_a0->unk3 + 1) * 5) + 1 + 3) % 0x100) & 0xFF;
+ return ((D_8018ED10.grandPrixPointsMushroomCup + 1 + ((temp_a0->unk0 + 1) * 2) + 1 + ((temp_a0->unk1 + 1) * 3) + 1 + 1 + ((temp_a0->unk2 + 1) * 4) + 1 + 2 + ((temp_a0->unk3 + 1) * 5) + 1 + 3) % 0x100) & 0xFF;
}
#else
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B492C.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern u8 D_8018ED16;
-
-s32 func_800B49E4(void) {
- return ((D_8018ED16 + 0x5A) % 0x100) & 0xFF;
+s32 compute_save_data_checksum_2(void) {
+ s32 tmp = D_8018ED16 + 90;
+ return (tmp % 256) & 0xFF;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B49E4.s")
-#endif
-void func_800B4A10(void) {
+void load_save_data(void) {
s32 temp_s0;
- osEepromLongRead(&gSIEventMesgQueue, 0, (u8*) &D_8018EB90, 0x200); //0x200: sizeof(SaveData)?
+ osEepromLongRead(&gSIEventMesgQueue, 0, (u8*) &D_8018EB90, sizeof(SaveData));
temp_s0 = 0;
while (temp_s0 < 16) // 16: 4 cup records * 4 course records?
{
@@ -2894,7 +2774,7 @@ void func_800B4A10(void) {
++temp_s0;
}
- func_800B4CB4();
+ validate_save_data();
gSoundMode = gSaveDataSoundMode;
if (gSoundMode >= NUM_SOUND_MODES) {
@@ -2980,67 +2860,59 @@ void func_800B4A9C(s32 arg0) {
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4A9C.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_800B4820(); // extern
-s32 func_800B492C(); // extern
-s32 func_800B49E4(); // extern
-? func_800B5948(); // extern
-u8 func_800B59F4(); // extern
-u8 func_800B5AAC(); // extern
-s32 func_800B5AD8(); // extern
-extern ? D_8018EB90;
-extern u8 D_8018ED10;
-extern u8 D_8018ED11;
-extern u8 D_8018ED12;
-extern u8 D_8018ED13;
-extern u8 gSaveDataSoundMode;
-extern u8 D_8018ED16;
-extern u8 D_8018ED17;
-extern u8 D_8018ED88;
-extern u8 D_8018ED89;
-extern u8 D_8018ED8A;
-extern u8 D_8018ED8B;
-extern u8 gSaveDataSoundModeBackup;
-extern OSMesgQueue gSIEventMesgQueue;
+void validate_save_data(void) {
+ if ((D_8018ED16 != (compute_save_data_checksum_1() & 0xFFFFFFFF)) || (D_8018ED17 != (compute_save_data_checksum_2() & 0xFFFFFFFF))) {
+
+ reset_save_data_grand_prix_points_and_sound_mode();
+
+ if (validate_save_data_checksum_backup() == 0) {
+ D_8018ED10.grandPrixPointsMushroomCup = D_8018ED88.grandPrixPointsMushroomCup;
+ if ((D_8018ED16 && D_8018ED16) && D_8018ED16)
+ {
+ }
-void func_800B4CB4(void) {
- if ((D_8018ED16 != func_800B492C()) || (D_8018ED17 != func_800B49E4())) {
- func_800B4820();
- if (func_800B5AD8() == 0) {
- D_8018ED10 = D_8018ED88;
D_8018ED11 = D_8018ED89;
+ if ((D_8018ED16 && D_8018ED16) && D_8018ED16)
+ {
+ }
+
D_8018ED12 = D_8018ED8A;
+ if ((D_8018ED16 && D_8018ED16) && D_8018ED16)
+ {
+ }
+
D_8018ED13 = D_8018ED8B;
+ if ((D_8018ED16 && D_8018ED16) && D_8018ED16)
+ {
+ }
+
gSaveDataSoundMode = gSaveDataSoundModeBackup;
- D_8018ED16 = func_800B59F4();
- D_8018ED17 = func_800B5AAC();
- osEepromLongWrite(&gSIEventMesgQueue, ((&D_8018ED10 - &D_8018EB90) >> 3) & 0xFF, &D_8018ED10, 8);
+ D_8018ED16 = compute_save_data_checksum_backup_1();
+ D_8018ED17 = compute_save_data_checksum_backup_2();
+ osEepromLongWrite(&gSIEventMesgQueue, (((u32) &D_8018ED10 - (u32) &D_8018EB90) >> 3), (u8*) &D_8018ED10, 8);
}
- func_800B5948();
+ update_save_data_backup();
return;
}
- if (func_800B5AD8() != 0) {
- func_800B5948();
+
+ if (validate_save_data_checksum_backup() != 0) {
+ update_save_data_backup();
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4CB4.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-void func_800B4DCC(void *arg0, u32 arg1, s32 arg2) {
- u32 temp_t8;
+void populate_time_trial_record(u8 *timeTrialRecord, u32 time, s32 characterId)
+{
+ u32 timeRightShift8 = time >> 8;
+ u32 timeRightShift16 = timeRightShift8 >> 8;
+ s16 timeRightShift8Duplicate;
+ u16 timeRightShift16Duplicate;
+
+ timeRightShift16Duplicate = timeRightShift16;
- temp_t8 = arg1 >> 8;
- arg0->unk0 = arg1;
- arg0->unk1 = temp_t8;
- arg0->unk2 = ((temp_t8 >> 8) & 0xF) + ((arg2 & 7) * 0x10);
+ timeTrialRecord[0] = time & 0xFF;
+ timeTrialRecord[1] = (timeRightShift8Duplicate = timeRightShift8);
+ timeTrialRecord[2] = (timeRightShift16Duplicate & 0xF) + ((characterId & 7) << 4);
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B4DCC.s")
-#endif
#ifdef NON_MATCHING
//generated by mips_to_c commit 99fec197b8c557ea7cc0d78f1b263a0de6e59168
@@ -3094,7 +2966,7 @@ s32 func_800B4FB0(s32 courseIndex) {
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? func_800B45E0(s32); // extern
-? func_800B4DCC(void *, u32, s32, void *); // extern
+? populate_time_trial_record(void *, u32, s32, void *); // extern
s32 func_800B4DF4(void *); // extern
extern ? D_8018EB90;
extern s8 gCupSelection;
@@ -3190,7 +3062,7 @@ block_10:
} while ((phi_s1_2 * 3) != temp_v1);
}
}
- func_800B4DCC(temp_a3, arg0, arg1, temp_a3);
+ populate_time_trial_record(temp_a3, arg0, arg1, temp_a3);
temp_s2->unk12 = 1;
func_800B45E0(sp30);
return phi_s1_2;
@@ -3202,7 +3074,7 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5020.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? func_800B45E0(s32); // extern
-? func_800B4DCC(void *, u32, s32, s32); // extern
+? populate_time_trial_record(void *, u32, s32, s32); // extern
s32 func_800B4F2C(s32, ? *, ? *, s32); // extern
extern ? D_8018CA70;
extern ? D_8018CA74;
@@ -3261,7 +3133,7 @@ s32 func_800B5218(void) {
temp_v0_2 = ((sp38 / 4) * 0x60) + ((sp38 % 4) * 0x18) + &D_8018EB90;
sp20 = temp_v0_2;
sp24 = phi_a3;
- func_800B4DCC(temp_v0_2 + 0xF, temp_a1_2, sp28, phi_a3);
+ populate_time_trial_record(temp_v0_2 + 0xF, temp_a1_2, sp28, phi_a3);
temp_v0_2->unk12 = 1;
func_800B45E0(sp38);
phi_v0_2 = sp24;
@@ -3272,84 +3144,49 @@ s32 func_800B5218(void) {
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5218.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_800B4670(); // extern
-s32 func_800B54EC(s8, u8, s32); // extern
-u8 func_800B5508(s8, u8, s32); // extern
-? func_800B5948(); // extern
-extern ? D_8018EB90;
-extern s8 gCupSelection;
-
void func_800B536C(s32 arg0) {
- u8 *sp1C;
- s32 temp_a2;
- s32 temp_v1;
- u8 *temp_v0;
+ u8* points;
+ u8 tmp;
+ s32 tmp2;
- temp_a2 = arg0;
if (arg0 >= 0) {
- temp_v0 = gCCSelection + 0x180 + &D_8018EB90;
- arg0 = temp_a2;
- sp1C = temp_v0;
- temp_v1 = 3 - arg0;
- if ((arg0 < 3) && (func_800B54EC(gCupSelection, *temp_v0, temp_a2) < temp_v1)) {
- *sp1C = func_800B5508(gCupSelection, *sp1C, temp_v1);
- func_800B4670();
- func_800B5948();
+ points = &D_8018EB90.grandPrixPoints[gCCSelection];
+
+ tmp = func_800B54EC(gCupSelection, *points);
+ tmp2 = 3 - arg0;
+ if ((arg0 < 3) && (tmp < (3-arg0))) {
+ *points = func_800B5508(gCupSelection, *points, tmp2);
+ write_save_data_grand_prix_points_and_sound_mode();
+ update_save_data_backup();
}
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B536C.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_800B4670(); // extern
-s32 func_800B54EC(s32, u8, s32, void *); // extern
-u8 func_800B5508(s32, u8, s32, void *); // extern
-? func_800B5948(); // extern
-extern ? D_8018EB90;
-void func_800B5404(s32 arg0, s32 arg1) {
- s32 sp30;
- s32 sp20;
- void *sp1C;
- u8 *sp18;
+void func_800B5404(s32 arg0, s32 arg1)
+{
+ u8 *points;
s32 temp_a0;
- s32 temp_a2;
- s32 temp_v1;
- u8 *temp_v1_2;
- void *temp_a3;
+ s32 temp;
+ int temp2;
+ UNUSED s32 pad;
- temp_a2 = arg0;
if (arg0 >= 0) {
- temp_a0 = arg1 / 4;
- temp_a3 = (arg1 % 4) + &D_8018EB90;
- sp1C = temp_a3;
- sp20 = temp_a0;
- arg0 = temp_a2;
- if (arg0 < 3) {
- temp_v1 = 3 - arg0;
- sp30 = temp_v1;
- if (func_800B54EC(temp_a0, temp_a3->unk180, temp_a2, temp_a3) < temp_v1) {
- temp_v1_2 = temp_a3 + 0x180;
- sp18 = temp_v1_2;
- *temp_v1_2 = func_800B5508(temp_a0, *temp_v1_2, sp30, temp_a3);
- func_800B4670();
- func_800B5948();
- }
+ temp2 = arg1 / 4;
+ points = &D_8018EB90.grandPrixPoints[arg1 % 4];
+ temp = func_800B54EC(temp2, *points);
+
+ if ((arg0 < 3) && (temp < (temp_a0 = 3 - arg0))) {
+ *points = func_800B5508(temp2, *points, temp_a0);
+
+ write_save_data_grand_prix_points_and_sound_mode();
+ update_save_data_backup();
}
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5404.s")
-#endif
// 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]);
+ return func_800B54EC(cup, D_8018ED10.grandPrixPointsArray[cc_mode]);
}
// Get Grand Prix points scored for a given cup
@@ -3378,7 +3215,7 @@ u8 func_800B5508(s32 cup, s32 ccGrandPrixPoints, s32 points_scored) {
// 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) {
+ if (D_8018ED10.grandPrixPointsArray[cc_mode] == 0xFF) {
return 1;
}
return 0;
@@ -3530,52 +3367,38 @@ loop_2:
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B578C.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern ? D_8018ED4E;
-
s32 func_800B5888(s32 arg0) {
- return ((*(&D_8018ED4E + (arg0 * 0x38)) + 0x5A) % 0x100) & 0xFF;
+ s32 tmp = ((*(&D_8018ED4E + (arg0 * sizeof(OnlyBestTimeTrialRecords))) + 90));
+ return (tmp % 256) & 0xFF;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5888.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B578C(s32, s32); // extern
-s32 func_800B5888(s32); // extern
-extern ? D_8018EB90;
+s32 func_800B58C4(s32 arg0)
+{
+ UNUSED s32 pad1;
+ OnlyBestTimeTrialRecords *temp_v1;
+ UNUSED s32 pad2;
+ UNUSED s32 pad3;
-? func_800B58C4(s32 arg0) {
- s32 sp1C;
- void *sp18;
- s32 temp_a0;
- void *temp_v1;
-
- temp_a0 = arg0 / 8;
- sp1C = temp_a0;
- temp_v1 = (temp_a0 * 0x38) + 0x188 + &D_8018EB90;
- if ((temp_v1->unk36 != func_800B578C(temp_a0, arg0)) || (sp18 = temp_v1, (temp_v1->unk37 != func_800B5888(temp_a0)))) {
+ temp_v1 = &D_8018EB90.onlyBestTimeTrialRecords[arg0 / 8];
+ if ((temp_v1->unknownBytes[6] != (func_800B578C(arg0 / 8) ^ 0)) || (temp_v1->unknownBytes[7] != (func_800B5888(arg0 / 8) ^ 0)))
+ {
return 1;
}
+
return 0;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B58C4.s")
-#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s8 func_800B59F4(); // extern
-s8 func_800B5AAC(); // extern
+s8 compute_save_data_checksum_backup_1(); // extern
+s8 compute_save_data_checksum_backup_2(); // extern
extern ? D_8018EB90;
-extern u8 D_8018ED10;
+extern union GrandPrixPointsUnion D_8018ED10;
extern u8 D_8018ED11;
extern u8 D_8018ED12;
extern u8 D_8018ED13;
extern u8 gSaveDataSoundMode;
-extern u8 D_8018ED88;
+extern union GrandPrixPointsUnion D_8018ED88;
extern u8 D_8018ED89;
extern u8 D_8018ED8A;
extern u8 D_8018ED8B;
@@ -3584,14 +3407,14 @@ extern s8 D_8018ED8E;
extern s8 D_8018ED8F;
extern OSMesgQueue gSIEventMesgQueue;
-void func_800B5948(void) {
- D_8018ED88 = D_8018ED10;
+void update_save_data_backup(void) {
+ D_8018ED88.grandPrixPointsMushroomCup = D_8018ED10.grandPrixPointsMushroomCup;
D_8018ED89 = D_8018ED11;
D_8018ED8A = D_8018ED12;
D_8018ED8B = D_8018ED13;
gSaveDataSoundModeBackup = gSaveDataSoundMode;
- D_8018ED8E = func_800B59F4();
- D_8018ED8F = func_800B5AAC();
+ D_8018ED8E = compute_save_data_checksum_backup_1();
+ D_8018ED8F = compute_save_data_checksum_backup_2();
osEepromLongWrite(&gSIEventMesgQueue, ((&D_8018ED88 - &D_8018EB90) >> 3) & 0xFF, &D_8018ED88, 8);
}
#else
@@ -3600,57 +3423,45 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5948.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern u8 D_8018ED88;
+extern union GrandPrixPointsUnion D_8018ED88;
-s32 func_800B59F4(void) {
+s32 compute_save_data_checksum_backup_1(void) {
void *temp_a0;
temp_a0 = &D_8018ED88 + 1;
- return ((D_8018ED88 + 1 + ((temp_a0->unk0 + 1) * 2) + 1 + ((temp_a0->unk1 + 1) * 3) + 1 + 1 + ((temp_a0->unk2 + 1) * 4) + 1 + 2 + ((temp_a0->unk3 + 1) * 5) + 1 + 3) % 0x100) & 0xFF;
+ return ((D_8018ED88.grandPrixPointsMushroomCup + 1 + ((temp_a0->unk0 + 1) * 2) + 1 + ((temp_a0->unk1 + 1) * 3) + 1 + 1 + ((temp_a0->unk2 + 1) * 4) + 1 + 2 + ((temp_a0->unk3 + 1) * 5) + 1 + 3) % 0x100) & 0xFF;
}
#else
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B59F4.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern u8 D_8018ED8E;
-
-s32 func_800B5AAC(void) {
- return ((D_8018ED8E + 0x5A) % 0x100) & 0xFF;
+s32 compute_save_data_checksum_backup_2(void) {
+ s32 tmp = D_8018ED8E + 90;
+ return (tmp % 256) & 0xFF;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5AAC.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B59F4(); // extern
-s32 func_800B5AAC(); // extern
-extern u8 D_8018ED8E;
-extern u8 D_8018ED8F;
-? func_800B5AD8(void) {
- if ((D_8018ED8E != func_800B59F4()) || (D_8018ED8F != func_800B5AAC())) {
+s32 validate_save_data_checksum_backup(void)
+{
+ if ((D_8018ED8E != (compute_save_data_checksum_backup_1() ^ 0)) || (D_8018ED8F != (compute_save_data_checksum_backup_2() ^ 0))) {
return 1;
}
+
return 0;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5AD8.s")
-#endif
-s32 func_800B5B2C(s32 arg0) {
+// Check if controller has a Controller Pak connected.
+// Return 1 if it does, otherwise return 0.
+s32 check_for_controller_pak(s32 controller) {
u8 sp1F;
- s32 phi_v0;
+ UNUSED s32 phi_v0;
- if ((arg0 >= 4) || (arg0 < 0)) {
+ if ((controller >= 4) || (controller < 0)) {
return 0;
}
osPfsIsPlug(&gSIEventMesgQueue, &sp1F);
- if ((sp1F & (1 << arg0)) != 0) {
+ if ((sp1F & (1 << controller)) != 0) {
return 1;
}
@@ -3659,7 +3470,7 @@ s32 func_800B5B2C(s32 arg0) {
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B5B2C(?); // extern
+s32 check_for_controller_pak(s32); // extern
s32 func_800CE720(? *, OSPfs *, ?); // extern
extern u16 D_800E86F0;
extern u32 D_800E86F4;
@@ -3702,7 +3513,7 @@ block_8:
}
block_9:
if (phi_v0 == 0) {
- if (func_800B5B2C(0) == 0) {
+ if (check_for_controller_pak(0) == 0) {
return 1;
}
temp_v0_3 = func_800CE720(&gSIEventMesgQueue, &D_8018E868, 0);
@@ -3752,7 +3563,7 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B5B94.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B5B2C(?); // extern
+s32 check_for_controller_pak(?); // extern
s32 func_800CE720(? *, OSPfs *, ?); // extern
extern u16 D_800E86F0;
extern u32 D_800E86F4;
@@ -3792,7 +3603,7 @@ block_7:
block_8:
phi_v0_2 = phi_v0;
if (phi_v0 == 0) {
- if (func_800B5B2C(1) == 0) {
+ if (check_for_controller_pak(1) == 0) {
return 1;
}
temp_v0_3 = func_800CE720(&gSIEventMesgQueue, &D_8018E8D0, 1);
@@ -3841,7 +3652,7 @@ s32 func_800B5F30(void) {
if (D_800E86F8 != 0) {
return -4;
}
- if (func_800B5B2C(0) != 0) {
+ if (check_for_controller_pak(0) != 0) {
sp1C = func_800CE720(&gSIEventMesgQueue, &D_8018E868, 0);
if (osPfsNumFiles(&D_8018E868, &D_8018EB78, &D_8018EB7C) != 0) {
D_800E86F8 = 0;
@@ -3866,7 +3677,7 @@ s32 func_800B6014(void) {
if (D_800E86FC != 0) {
return -4;
}
- if (func_800B5B2C(1) != 0) {
+ if (check_for_controller_pak(1) != 0) {
temp_v0 = func_800CE720(&gSIEventMesgQueue, &D_8018E8D0, 1);
if (temp_v0 == 0) {
D_800E86FC = 1;
@@ -3876,25 +3687,15 @@ s32 func_800B6014(void) {
return -1;
}
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s8 func_800B6828(); // extern
-extern OSPfs D_8018E868;
-extern s32 D_8018EB84;
-extern ? D_8018EE10;
-
void func_800B6088(s32 arg0) {
s32 temp_t6;
- u8 *temp_v1;
+ u8* temp_v1;
temp_t6 = arg0 << 7;
- temp_v1 = temp_t6 + &D_8018EE10;
- temp_v1->unk7F = func_800B6828();
- osPfsReadWriteFile(&D_8018E868, D_8018EB84, 1, temp_t6, 0x80, temp_v1);
+ 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);
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6088.s")
-#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
@@ -4371,7 +4172,7 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B69BC.s")
#endif
s32 func_800B6A68(void) {
- s32 pad;
+ UNUSED s32 pad;
s32 sp30;
s32 temp_s0;
@@ -4390,7 +4191,7 @@ s32 func_800B6A68(void) {
#ifdef MIPS_TO_C
//generated by mips_to_c commit cc33060578851a93591ed035e96ffd1f15c765f1
-s32 func_800B5B2C(?); /* extern */
+s32 check_for_controller_pak(?); /* extern */
? func_800B6A68(); /* extern */
s32 func_800CE720(? *, ? *, ?); /* extern */
s32 osPfsFindFile(? *, u16, s32, ? *, ? *, ? *); /* extern */
@@ -4411,7 +4212,7 @@ extern ? gSIEventMesgQueue;
UNUSED void func_800B6AF8(void) {
s32 temp_t1;
- if ((func_800B5B2C(0) != 0) && (func_800CE720(&gSIEventMesgQueue, &D_8018E868, 0) == 0) && (osPfsFindFile(&D_8018E868, D_800E86F0, D_800E86F4, &D_800F2E64, &D_800F2E74, &D_8018EB84) != 0) && (osPfsNumFiles(&D_8018E868, &D_8018EB78, &D_8018EB7C) == 0) && (D_8018EB7C < D_8018EB78) && (osPfsFreeBlocks(&D_8018E868, &gControllerPakNumPagesFree) == 0)) {
+ if ((check_for_controller_pak(0) != 0) && (func_800CE720(&gSIEventMesgQueue, &D_8018E868, 0) == 0) && (osPfsFindFile(&D_8018E868, D_800E86F0, D_800E86F4, &D_800F2E64, &D_800F2E74, &D_8018EB84) != 0) && (osPfsNumFiles(&D_8018E868, &D_8018EB78, &D_8018EB7C) == 0) && (D_8018EB7C < D_8018EB78) && (osPfsFreeBlocks(&D_8018E868, &gControllerPakNumPagesFree) == 0)) {
temp_t1 = (s32) gControllerPakNumPagesFree >> 8;
gControllerPakNumPagesFree = temp_t1;
if (temp_t1 >= 0x79) {