summaryrefslogtreecommitdiff
path: root/src/code_800AF9B0.c
diff options
context:
space:
mode:
authorTyler McGavran <tyler.taggerung@gmail.com>2022-02-13 02:17:34 -0500
committerGitHub <noreply@github.com>2022-02-13 00:17:34 -0700
commit5205b09751cca102840eab64efd0212c206095d7 (patch)
tree97b26ba89e00b2fd40a97001c60cf693ff7d4b7f /src/code_800AF9B0.c
parent5badb9e49c3fc36b1795240a1334c735ffbc8a7b (diff)
Name functions that search for 8018D9E0 entries (#161)
* Name functions that search for 8018D9E0 entries The one with "_dupe" in its name is the one that has the potential hard lock laying around * Add comment for bug in find_8018D9E0_entry_dupe Signed-off-by: Taggerung <tyler.taggerung@gmail.com>
Diffstat (limited to 'src/code_800AF9B0.c')
-rw-r--r--src/code_800AF9B0.c785
1 files changed, 378 insertions, 407 deletions
diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c
index 71e3543eb..4aa937ea2 100644
--- a/src/code_800AF9B0.c
+++ b/src/code_800AF9B0.c
@@ -453,30 +453,34 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B0350.s")
#endif
#ifdef MIPS_TO_C
-//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
+//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda
? func_8009E280(); /* extern */
-void *func_800AAEF4(?); /* extern */
-? func_800B44BC(); /* extern */
-? write_save_data_grand_prix_points_and_sound_mode(); /* extern */
-? func_800B46D0(?, u16); /* extern */
-? update_save_data_backup(); /* extern */
+s32 func_800B5B94(); /* extern */
+s32 func_800B5DA4(); /* extern */
? func_800B6088(s32); /* extern */
+s32 func_800B6178(s32); /* extern */
+s32 func_800B65F4(s32, s32); /* extern */
? func_800B6708(); /* extern */
? func_800B6798(); /* extern */
s32 osPfsFindFile(? *, u16, s32, ? *, ? *, ? *); /* extern */
? play_sound2(?, u16, u16); /* extern */
+extern void *D_8018D9C0;
extern ? D_8018E868;
extern ? D_8018EB84;
extern ? D_8018EE10;
extern ? D_8018EE14;
extern ? D_8018EE15;
+extern u8 D_8018EE94;
+extern s8 D_8018EE95;
+static s32 D_800DC5AC = 0;
+static u16 D_800E86F0; /* unable to generate initializer; const */
+static s32 D_800E86F4 = 0x4E4B544A; /* const */
static ? D_800F2E64; /* unable to generate initializer; const */
static ? D_800F2E74; /* unable to generate initializer; const */
-u16 D_800E86F0; /* unable to generate initializer; const */
-void func_800B053C(void *arg0, u16 arg1) {
+void func_800B053C(struct Controller *arg0, u16 arg1) {
u16 sp3E;
- void *sp38;
+ struct_8018D9E0_entry *sp38;
void *sp30;
s32 sp2C;
s32 sp20;
@@ -494,8 +498,8 @@ void func_800B053C(void *arg0, u16 arg1) {
s32 temp_t9_2;
s32 temp_v0_10;
s32 temp_v0_11;
- s32 temp_v0_5;
- s32 temp_v0_6;
+ s32 temp_v0_7;
+ s32 temp_v0_8;
s8 temp_v0_4;
s8 temp_v0_9;
s8 temp_v1;
@@ -504,15 +508,15 @@ void func_800B053C(void *arg0, u16 arg1) {
s8 temp_v1_4;
s8 temp_v1_5;
s8 temp_v1_6;
+ struct_8018D9E0_entry *temp_t0;
+ struct_8018D9E0_entry *temp_v0;
u16 temp_t8;
u32 temp_t9;
u8 temp_v0_2;
u8 temp_v0_3;
- u8 temp_v0_7;
- u8 temp_v0_8;
+ u8 temp_v0_5;
+ u8 temp_v0_6;
void *temp_a0;
- void *temp_t0;
- void *temp_v0;
u16 phi_a2;
s32 phi_a1;
s8 *phi_t1;
@@ -521,22 +525,22 @@ void func_800B053C(void *arg0, u16 arg1) {
s32 phi_a1_3;
s8 *phi_t1_3;
u16 phi_a1_4;
- void *phi_t0;
+ struct_8018D9E0_entry *phi_t0;
s8 *phi_t1_4;
s32 phi_a1_5;
s8 *phi_t1_5;
s32 phi_v0;
s32 phi_v0_2;
- temp_t8 = (arg0->unk6 | arg0->unkC) & 0xFFFF;
+ temp_t8 = (arg0->buttonPressed | arg0->stickPressed) & 0xFFFF;
phi_a2 = temp_t8;
if ((gEnableDebugMode == 0) && ((temp_t8 & 0x1000) != 0)) {
phi_a2 = (temp_t8 | 0x8000) & 0xFFFF;
}
sp3E = phi_a2;
- if (func_800B4520(arg0) == 0) {
+ if (func_800B4520(phi_a2) == 0) {
sp3E = phi_a2;
- temp_v0 = func_800AAEF4(0xF0);
+ temp_v0 = find_8018D9E0_entry_dupe(0xF0);
temp_v1 = D_8018EDEC;
temp_t0 = temp_v0;
sp30 = D_8018D9C0;
@@ -547,16 +551,16 @@ void func_800B053C(void *arg0, u16 arg1) {
case 0x17: /* switch 1 */
case 0x18: /* switch 1 */
sp2C = 0;
- phi_a1 = phi_a2;
- if (((phi_a2 & 0x400) != 0) && (temp_v1 < 0x18)) {
+ phi_a1 = (s32) phi_a2;
+ if (((phi_a2 & 0x400) != 0) && ((s32) temp_v1 < 0x18)) {
D_8018EDEC = temp_v1 + 1;
- sp20 = phi_a2;
+ sp20 = (s32) phi_a2;
sp38 = temp_t0;
play_sound2(0x49008000, phi_a2, phi_a2);
- temp_f0 = temp_t0->unk24;
+ temp_f0 = (f64) temp_t0->unk24;
phi_a1 = sp20;
if (temp_f0 < 4.2) {
- temp_t0->unk24 = temp_f0 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0 + 4.0);
}
temp_t0->unk8 = 1;
sp2C = 1;
@@ -564,257 +568,247 @@ void func_800B053C(void *arg0, u16 arg1) {
phi_t1 = &D_8018EDEC;
if ((phi_a1 & 0x800) != 0) {
temp_v1_2 = D_8018EDEC;
- if (temp_v1_2 >= 0x16) {
+ if ((s32) temp_v1_2 >= 0x16) {
D_8018EDEC = temp_v1_2 - 1;
sp2C = 1;
sp20 = phi_a1;
sp38 = temp_t0;
- play_sound2(0x49008000, phi_a1);
- temp_f0_2 = temp_t0->unk24;
+ play_sound2(0x49008000, (u16) phi_a1);
+ temp_f0_2 = (f64) temp_t0->unk24;
phi_t1 = &D_8018EDEC;
if (temp_f0_2 < 4.2) {
- temp_t0->unk24 = temp_f0_2 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_2 + 4.0);
}
temp_t0->unk8 = -1;
}
}
if (sp2C != 0) {
- if (temp_t0->unk4 != gSoundMode) {
- gSaveDataSoundMode = gSoundMode;
+ temp_v0_2 = gSoundMode;
+ if (temp_t0->unk4 != temp_v0_2) {
+ gSaveDataSoundMode = temp_v0_2;
sp20 = phi_a1;
sp38 = temp_t0;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
- temp_t0->unk4 = gSoundMode;
+ temp_t0->unk4 = (s32) gSoundMode;
phi_t1 = &D_8018EDEC;
}
}
- if ((phi_a1 & 0x4000) != 0) {
+ if (((u16) phi_a1 & 0x4000) != 0) {
sp38 = temp_t0;
func_8009E280();
play_sound2(0x49008002);
- if (temp_t0->unk4 != gSoundMode) {
- gSaveDataSoundMode = gSoundMode;
+ temp_v0_3 = gSoundMode;
+ if (temp_t0->unk4 != temp_v0_3) {
+ gSaveDataSoundMode = temp_v0_3;
sp38 = temp_t0;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
- temp_t0->unk4 = gSoundMode;
+ temp_t0->unk4 = (s32) gSoundMode;
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
- }
- if ((phi_a1 & 0x8000) != 0) {
+ } else if (((u16) phi_a1 & 0x8000) != 0) {
temp_v0_4 = *phi_t1;
- if (temp_v0_4 != 0x15) {
- if (temp_v0_4 != 0x16) {
- if (temp_v0_4 != 0x17) {
- if (temp_v0_4 != 0x18) {
- return;
- }
- *phi_t1 = 0x1E;
- play_sound2(0x49008001, phi_a1);
+ switch (temp_v0_4) { /* switch 3; irregular */
+ case 22: /* switch 3 */
+ temp_v0_5 = gSoundMode;
+ if ((s32) temp_v0_5 < 3) {
+ gSoundMode = temp_v0_5 + 1;
+ } else {
+ gSoundMode = 0;
+ }
+ if (gSoundMode == 2) {
+ gSoundMode = 3;
+ }
+ func_800B44BC();
+ temp_v0_6 = gSoundMode;
+ switch (temp_v0_6) { /* switch 4; irregular */
+ case 0: /* switch 4 */
+ play_sound2(0x49008024);
+ return;
+ case 1: /* switch 4 */
+ play_sound2(0x49008025);
+ return;
+ case 3: /* switch 4 */
+ play_sound2(0x49008029);
+ return;
+ }
+ break;
+ case 23: /* switch 3 */
+ sp38 = temp_t0;
+ temp_v0_7 = func_800B5DA4();
+ switch (temp_v0_7) { /* switch 5; irregular */
+ case -1: /* switch 5 */
+ D_8018EDEC = 0x2B;
+ play_sound2(0x4900FF07);
+ return;
+ case 0: /* switch 5 */
+ sp38 = temp_t0;
+ func_800B6798();
+ temp_v0_8 = func_800B5B94();
+ temp_t9 = temp_v0_8 + 1;
+ sp2C = temp_v0_8;
+ switch (temp_t9) { /* switch 2 */
+ case 0: /* switch 2 */
+ D_8018EDEC = 0x46;
+ temp_t0->unk4 = 0;
+ play_sound2(0x49008001);
+ break;
+ case 1: /* switch 2 */
+ func_800B6708();
+ break;
+ case 2: /* switch 2 */
+ D_8018EDEC = 0x34;
+ play_sound2(0x4900FF07);
+ break;
+ case 5: /* switch 2 */
+ D_8018EDEC = 0x37;
+ play_sound2(0x4900FF07);
+ break;
+ default: /* switch 2 */
+ D_8018EDEC = 0x35;
+ play_sound2(0x4900FF07);
+ break;
+ }
+ if ((sp2C == -1) && (sp30->unk4 == 0) && (sp30->unk84 == 0)) {
+ D_8018EDEC = 0x2A;
+ play_sound2(0x4900FF07);
return;
}
- sp38 = temp_t0;
- temp_v0_5 = func_800B5DA4();
- if (temp_v0_5 != -1) {
- if (temp_v0_5 != 0) {
- if (temp_v0_5 != 1) {
- if (temp_v0_5 != 2) {
-
- }
- D_8018EDEC = 0x2D;
- play_sound2(0x4900FF07);
- return;
- }
- D_8018EDEC = 0x2C;
- play_sound2(0x4900FF07);
- return;
- }
- sp38 = temp_t0;
- func_800B6798();
- temp_v0_6 = func_800B5B94();
- temp_t9 = temp_v0_6 + 1;
- sp2C = temp_v0_6;
- switch (temp_t9) { /* switch 2 */
- case 0: /* switch 2 */
- D_8018EDEC = 0x46;
- temp_t0->unk4 = 0;
+ if (sp2C == 0) {
+ if (sp30->unk4 != 0) {
+ D_8018EDEC = 0x28;
play_sound2(0x49008001);
- break;
- case 1: /* switch 2 */
- func_800B6708();
- break;
- case 2: /* switch 2 */
- D_8018EDEC = 0x34;
- play_sound2(0x4900FF07);
- break;
- case 5: /* switch 2 */
- D_8018EDEC = 0x37;
- play_sound2(0x4900FF07);
- break;
- default: /* switch 2 */
- D_8018EDEC = 0x35;
- play_sound2(0x4900FF07);
- break;
- }
- if ((sp2C == -1) && (sp30->unk4 == 0) && (sp30->unk84 == 0)) {
- D_8018EDEC = 0x2A;
- play_sound2(0x4900FF07);
return;
}
- if (sp2C == 0) {
- if (sp30->unk4 != 0) {
- D_8018EDEC = 0x28;
- play_sound2(0x49008001);
- return;
- }
- if (sp30->unk84 != 0) {
- D_8018EDEC = 0x29;
- play_sound2(0x49008001);
- return;
- }
- D_8018EDEC = 0x2A;
- play_sound2(0x4900FF07);
+ if (sp30->unk84 != 0) {
+ D_8018EDEC = 0x29;
+ play_sound2(0x49008001);
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
+ D_8018EDEC = 0x2A;
+ play_sound2(0x4900FF07);
return;
}
- D_8018EDEC = 0x2B;
+ break;
+ case 1: /* switch 5 */
+ D_8018EDEC = 0x2C;
+ play_sound2(0x4900FF07);
+ return;
+ default: /* switch 5 */
+ case 2: /* switch 5 */
+ D_8018EDEC = 0x2D;
play_sound2(0x4900FF07);
return;
}
- if (gSoundMode < SOUND_MONO) {
- gSoundMode += 1;
- } else {
- gSoundMode = SOUND_STEREO;
- }
- if (gSoundMode == SOUND_UNUSED) {
- gSoundMode = SOUND_MONO;
- }
- func_800B44BC();
- switch(gSoundMode){
- case SOUND_STEREO:
- play_sound2(0x49008024);
- break;
- case SOUND_HEADPHONES:
- play_sound2(0x49008025);
- break;
- case SOUND_MONO:
- play_sound2(0x49008029);
- break;
- default:
- break;
- }
+ break;
+ case 24: /* switch 3 */
+ *phi_t1 = 0x1E;
+ play_sound2(0x49008001, (u16) phi_a1);
+ return;
+ case 21: /* switch 3 */
+ func_8009E280();
+ play_sound2(0x49008002);
return;
}
- func_8009E280();
- play_sound2(0x49008002);
- return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x1E: /* switch 1 */
case 0x1F: /* switch 1 */
- phi_a1_2 = phi_a2;
- if (((phi_a2 & 0x400) != 0) && (temp_v1 < 0x1F)) {
+ phi_a1_2 = (s32) phi_a2;
+ if (((phi_a2 & 0x400) != 0) && ((s32) temp_v1 < 0x1F)) {
D_8018EDEC = temp_v1 + 1;
- sp20 = phi_a2;
+ sp20 = (s32) phi_a2;
sp38 = temp_t0;
play_sound2(0x49008000, phi_a2, phi_a2);
- temp_f0_3 = temp_t0->unk24;
+ temp_f0_3 = (f64) temp_t0->unk24;
phi_a1_2 = sp20;
if (temp_f0_3 < 4.2) {
- temp_t0->unk24 = temp_f0_3 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_3 + 4.0);
}
temp_t0->unk8 = 1;
}
phi_t1_2 = &D_8018EDEC;
if ((phi_a1_2 & 0x800) != 0) {
temp_v1_3 = D_8018EDEC;
- if (temp_v1_3 >= 0x1F) {
+ if ((s32) temp_v1_3 >= 0x1F) {
D_8018EDEC = temp_v1_3 - 1;
sp20 = phi_a1_2;
sp38 = temp_t0;
- play_sound2(0x49008000, phi_a1_2);
- temp_f0_4 = temp_t0->unk24;
+ play_sound2(0x49008000, (u16) phi_a1_2);
+ temp_f0_4 = (f64) temp_t0->unk24;
phi_t1_2 = &D_8018EDEC;
if (temp_f0_4 < 4.2) {
- temp_t0->unk24 = temp_f0_4 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_4 + 4.0);
}
temp_t0->unk8 = -1;
}
}
- if ((phi_a1_2 & 0x4000) != 0) {
+ if (((u16) phi_a1_2 & 0x4000) != 0) {
*phi_t1_2 = 0x18;
- play_sound2(0x49008002, phi_a1_2);
+ play_sound2(0x49008002, (u16) phi_a1_2);
return;
}
- if ((phi_a1_2 & 0x8000) != 0) {
+ if (((u16) phi_a1_2 & 0x8000) != 0) {
temp_v0_9 = *phi_t1_2;
- if (temp_v0_9 != 0x1E) {
- if (temp_v0_9 != 0x1F) {
- return;
- }
+ switch (temp_v0_9) { /* switch 6; irregular */
+ case 30: /* switch 6 */
+ *phi_t1_2 = 0x18;
+ play_sound2(0x49008002, (u16) phi_a1_2);
+ return;
+ case 31: /* switch 6 */
*phi_t1_2 = 0x20;
- func_800B46D0(0x49000000, phi_a1_2);
+ func_800B46D0(0x49000000, (u16) phi_a1_2);
D_800DC5AC = 0;
play_sound2(0x4900801D);
return;
}
- *phi_t1_2 = 0x18;
- play_sound2(0x49008002, phi_a1_2);
- return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x20: /* switch 1 */
if ((phi_a2 & 0xD000) != 0) {
D_8018EDEC = 0x18;
play_sound2(0x49008002);
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x28: /* switch 1 */
case 0x29: /* switch 1 */
- phi_a1_3 = phi_a2;
- if (((phi_a2 & 0x400) != 0) && (temp_v1 < 0x29) && (sp30->unk84 != 0)) {
+ phi_a1_3 = (s32) phi_a2;
+ if (((phi_a2 & 0x400) != 0) && ((s32) temp_v1 < 0x29) && (sp30->unk84 != 0)) {
D_8018EDEC = temp_v1 + 1;
- sp20 = phi_a2;
+ sp20 = (s32) phi_a2;
sp38 = temp_t0;
play_sound2(0x49008000, phi_a2, phi_a2);
- temp_f0_5 = temp_t0->unk24;
+ temp_f0_5 = (f64) temp_t0->unk24;
phi_a1_3 = sp20;
if (temp_f0_5 < 4.2) {
- temp_t0->unk24 = temp_f0_5 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_5 + 4.0);
}
temp_t0->unk8 = 1;
}
phi_t1_3 = &D_8018EDEC;
if ((phi_a1_3 & 0x800) != 0) {
temp_v1_4 = D_8018EDEC;
- if ((temp_v1_4 >= 0x29) && (sp30->unk4 != 0)) {
+ if (((s32) temp_v1_4 >= 0x29) && (sp30->unk4 != 0)) {
D_8018EDEC = temp_v1_4 - 1;
sp20 = phi_a1_3;
sp38 = temp_t0;
- play_sound2(0x49008000, phi_a1_3);
- temp_f0_6 = temp_t0->unk24;
+ play_sound2(0x49008000, (u16) phi_a1_3);
+ temp_f0_6 = (f64) temp_t0->unk24;
phi_t1_3 = &D_8018EDEC;
if (temp_f0_6 < 4.2) {
- temp_t0->unk24 = temp_f0_6 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_6 + 4.0);
}
temp_t0->unk8 = -1;
}
}
- if ((phi_a1_3 & 0x4000) != 0) {
+ if (((u16) phi_a1_3 & 0x4000) != 0) {
*phi_t1_3 = 0x17;
- play_sound2(0x49008002, phi_a1_3);
+ play_sound2(0x49008002, (u16) phi_a1_3);
return;
}
- if ((phi_a1_3 & 0x8000) != 0) {
+ if (((u16) phi_a1_3 & 0x8000) != 0) {
temp_t9_2 = *phi_t1_3 - 0x28;
temp_t0->unk20 = temp_t9_2;
if (((sp30 + (temp_t9_2 << 7))->unk5 == D_8018EE95) && (D_8018EE94 != 0)) {
@@ -822,43 +816,42 @@ void func_800B053C(void *arg0, u16 arg1) {
} else {
*phi_t1_3 = 0x32;
}
- play_sound2(0x49008001, phi_a1_3);
+ play_sound2(0x49008001, (u16) phi_a1_3);
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x32: /* switch 1 */
case 0x33: /* switch 1 */
temp_a0 = ((temp_v1 - 0x32) << 7) + &D_8018EE10;
phi_a1_4 = phi_a2;
if (((sp30 + (temp_v0->unk20 << 7))->unk5 != temp_a0->unk5) || (phi_t0 = temp_t0, (temp_a0->unk4 == 0))) {
- if (((phi_a2 & 0x400) != 0) && (temp_v1 < 0x33)) {
+ if (((phi_a2 & 0x400) != 0) && ((s32) temp_v1 < 0x33)) {
D_8018EDEC = temp_v1 + 1;
- sp20 = phi_a2;
+ sp20 = (s32) phi_a2;
sp38 = temp_t0;
play_sound2(0x49008000, phi_a2, phi_a2);
- temp_f0_7 = temp_t0->unk24;
+ temp_f0_7 = (f64) temp_t0->unk24;
if (temp_f0_7 < 4.2) {
- temp_t0->unk24 = temp_f0_7 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_7 + 4.0);
}
temp_t0->unk8 = 1;
}
- phi_a1_4 = phi_a2;
+ phi_a1_4 = (u16) (s32) phi_a2;
phi_t0 = temp_t0;
phi_t1_4 = &D_8018EDEC;
- if ((phi_a2 & 0x800) != 0) {
+ if (((s32) phi_a2 & 0x800) != 0) {
temp_v1_5 = D_8018EDEC;
- if (temp_v1_5 >= 0x33) {
+ if ((s32) temp_v1_5 >= 0x33) {
D_8018EDEC = temp_v1_5 - 1;
- sp20 = phi_a2;
+ sp20 = (s32) phi_a2;
sp38 = temp_t0;
- play_sound2(0x49008000, phi_a2);
- temp_f0_8 = temp_t0->unk24;
- phi_a1_4 = phi_a2;
+ play_sound2(0x49008000, (u16) (s32) phi_a2);
+ temp_f0_8 = (f64) temp_t0->unk24;
+ phi_a1_4 = (u16) (s32) phi_a2;
phi_t0 = temp_t0;
phi_t1_4 = &D_8018EDEC;
if (temp_f0_8 < 4.2) {
- temp_t0->unk24 = temp_f0_8 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_8 + 4.0);
}
temp_t0->unk8 = -1;
}
@@ -881,8 +874,7 @@ void func_800B053C(void *arg0, u16 arg1) {
play_sound2(0x49008001, phi_a1_4);
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x2A: /* switch 1 */
case 0x2B: /* switch 1 */
case 0x2C: /* switch 1 */
@@ -898,68 +890,65 @@ void func_800B053C(void *arg0, u16 arg1) {
play_sound2(0x49008002);
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x38: /* switch 1 */
case 0x39: /* switch 1 */
- phi_a1_5 = phi_a2;
- if (((phi_a2 & 0x100) != 0) && (temp_v1 < 0x39)) {
+ phi_a1_5 = (s32) phi_a2;
+ if (((phi_a2 & 0x100) != 0) && ((s32) temp_v1 < 0x39)) {
D_8018EDEC = temp_v1 + 1;
- sp20 = phi_a2;
+ sp20 = (s32) phi_a2;
sp38 = temp_t0;
play_sound2(0x49008000, phi_a2, phi_a2);
- temp_f0_9 = temp_t0->unk24;
+ temp_f0_9 = (f64) temp_t0->unk24;
phi_a1_5 = sp20;
if (temp_f0_9 < 4.2) {
- temp_t0->unk24 = temp_f0_9 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_9 + 4.0);
}
temp_t0->unk8 = 1;
}
phi_t1_5 = &D_8018EDEC;
if ((phi_a1_5 & 0x200) != 0) {
temp_v1_6 = D_8018EDEC;
- if (temp_v1_6 >= 0x39) {
+ if ((s32) temp_v1_6 >= 0x39) {
D_8018EDEC = temp_v1_6 - 1;
sp20 = phi_a1_5;
sp38 = temp_t0;
- play_sound2(0x49008000, phi_a1_5);
- temp_f0_10 = temp_t0->unk24;
+ play_sound2(0x49008000, (u16) phi_a1_5);
+ temp_f0_10 = (f64) temp_t0->unk24;
phi_t1_5 = &D_8018EDEC;
if (temp_f0_10 < 4.2) {
- temp_t0->unk24 = temp_f0_10 + 4.0;
+ temp_t0->unk24 = (f32) (temp_f0_10 + 4.0);
}
temp_t0->unk8 = -1;
}
}
- if ((phi_a1_5 & 0x4000) != 0) {
+ if (((u16) phi_a1_5 & 0x4000) != 0) {
*phi_t1_5 = temp_t0->unk1C + 0x32;
- play_sound2(0x49008002, phi_a1_5);
+ play_sound2(0x49008002, (u16) phi_a1_5);
return;
}
- if ((phi_a1_5 & 0x8000) != 0) {
+ if (((u16) phi_a1_5 & 0x8000) != 0) {
if (*phi_t1_5 == 0x38) {
*phi_t1_5 = 0x17;
- play_sound2(0x49008002, phi_a1_5);
+ play_sound2(0x49008002, (u16) phi_a1_5);
return;
}
*phi_t1_5 = 0x3A;
sp38 = temp_t0;
- play_sound2(0x49008001, phi_a1_5);
+ play_sound2(0x49008001, (u16) phi_a1_5);
temp_t0->unk4 = 0;
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x3A: /* switch 1 */
if (arg1 == 0) {
- temp_v0->unk4 = temp_v0->unk4 + 1;
+ temp_v0->unk4 += 1;
}
if (temp_v0->unk4 >= 3) {
D_8018EDEC = 0x3B;
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x3B: /* switch 1 */
sp38 = temp_t0;
temp_v0_10 = func_800B5DA4();
@@ -991,14 +980,13 @@ void func_800B053C(void *arg0, u16 arg1) {
return;
case 0x46: /* switch 1 */
if (arg1 == 0) {
- temp_v0->unk4 = temp_v0->unk4 + 1;
+ temp_v0->unk4 += 1;
}
if (temp_v0->unk4 >= 3) {
D_8018EDEC = 0x47;
return;
}
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
case 0x47: /* switch 1 */
if (func_800B6A68() != 0) {
D_8018EDEC = 0x36;
@@ -1010,8 +998,7 @@ void func_800B053C(void *arg0, u16 arg1) {
return;
}
D_8018EDEC = 0x29;
- /* Duplicate return node #166. Try simplifying control flow for better match */
- return;
+ break;
}
} else {
default: /* switch 1 */
@@ -1083,30 +1070,14 @@ void func_800B13B0(struct Controller *controller, UNUSED u16 arg1) {
}
#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_8009E208(?); // extern
-void *func_800AAEF4(?, s8); // extern
-s32 func_800B4520(); // extern
-? func_800B4728(s8, s8, void *, s32); // extern
-? func_800B559C(s8); // extern
-s32 func_800B639C(s8, s8, void *, s32); // extern
-s32 func_800B69BC(s32, s32); // extern
-? play_sound2(?, s32); // extern
-extern f64 D_800F2D90;
-extern f64 D_800F2D98;
-extern f64 D_800F2DA0;
-extern f64 D_800F2DA8;
-extern f64 D_800F2DB0;
-extern ? D_8018EB90;
-extern s8 D_8018EDEC;
-extern s8 gTimeTrialDataCourseIndex;
-extern s8 gCourseRecordsMenuSelection;
+//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda
+? play_sound2(?, s32); /* extern */
extern s8 D_8018EDF9;
-void func_800B15AC(void *arg0, ? arg1) {
+void func_800B15AC(struct Controller *arg0, u16 arg1) {
u16 sp2E;
- void *sp28;
- void *sp24;
+ struct_8018D9E0_entry *sp28;
+ u8 *sp24;
s32 sp20;
s32 sp18;
f64 temp_f0;
@@ -1114,33 +1085,35 @@ void func_800B15AC(void *arg0, ? arg1) {
f64 temp_f0_3;
f64 temp_f0_4;
f64 temp_f0_5;
- s32 temp_a1;
+ s32 temp_a1_4;
s32 temp_t4;
- s32 temp_v0_5;
+ s32 temp_v0_11;
+ s8 temp_a1;
s8 temp_a1_2;
s8 temp_a1_3;
- s8 temp_a1_4;
s8 temp_v0;
s8 temp_v0_10;
- s8 temp_v0_2;
s8 temp_v0_3;
s8 temp_v0_4;
+ s8 temp_v0_5;
s8 temp_v0_6;
s8 temp_v0_7;
s8 temp_v0_8;
s8 temp_v0_9;
+ struct_8018D9E0_entry *temp_a2;
+ struct_8018D9E0_entry *temp_a2_2;
+ struct_8018D9E0_entry *temp_v0_2;
u16 temp_t8;
- void *temp_a2;
- void *temp_a2_2;
u16 phi_v1;
- s8 phi_a1;
+ s32 phi_a1;
s32 phi_a3;
+ struct_8018D9E0_entry *phi_a2;
s8 *phi_v1_2;
s32 phi_a3_2;
- void *phi_a2;
+ struct_8018D9E0_entry *phi_a2_2;
s8 *phi_v1_3;
- temp_t8 = (arg0->unk6 | arg0->unkC) & 0xFFFF;
+ temp_t8 = (arg0->buttonPressed | arg0->stickPressed) & 0xFFFF;
phi_v1 = temp_t8;
if ((gEnableDebugMode == 0) && ((temp_t8 & 0x1000) != 0)) {
phi_v1 = (temp_t8 | 0x8000) & 0xFFFF;
@@ -1148,45 +1121,148 @@ void func_800B15AC(void *arg0, ? arg1) {
sp2E = phi_v1;
if (func_800B4520() == 0) {
temp_v0 = D_8018EDEC;
- if (temp_v0 != 0xB) {
- if (temp_v0 != 0xC) {
- if (temp_v0 != 0xD) {
- return;
+ switch (temp_v0) { /* irregular */
+ case 11:
+ phi_a3 = (s32) phi_v1;
+ if ((phi_v1 & 0x200) != 0) {
+ temp_a1 = gTimeTrialDataCourseIndex;
+ if ((s32) temp_a1 > 0) {
+ gTimeTrialDataCourseIndex = temp_a1 - 1;
+ sp18 = (s32) phi_v1;
+ play_sound2(0x49008000, (s32) temp_a1);
+ phi_a3 = sp18;
}
- if ((phi_v1 & 0xD000) != 0) {
- D_8018EDEC = 0xB;
+ }
+ if ((phi_a3 & 0x100) != 0) {
+ temp_a1_2 = gTimeTrialDataCourseIndex;
+ if ((s32) temp_a1_2 < 0xF) {
+ gTimeTrialDataCourseIndex = temp_a1_2 + 1;
+ sp18 = phi_a3;
+ play_sound2(0x49008000, (s32) temp_a1_2);
+ }
+ }
+ sp18 = phi_a3;
+ temp_v0_2 = find_8018D9E0_entry_dupe(0xE8);
+ temp_a1_3 = gTimeTrialDataCourseIndex;
+ temp_t4 = (((s32) temp_a1_3 / 4) * 0x60) + (((s32) temp_a1_3 % 4) * 0x18);
+ phi_a2 = temp_v0_2;
+ if (gCourseRecordsMenuSelection == 2) {
+ sp28 = temp_v0_2;
+ sp18 = phi_a3;
+ sp24 = &D_8018EB90.allCourseTimeTrialRecords.cupRecords[0].courseRecords[0].records[0][temp_t4];
+ temp_a2 = temp_v0_2;
+ phi_a2 = temp_a2;
+ if (func_800B639C((s32) temp_a1_3) < 0) {
+ gCourseRecordsMenuSelection += -1;
+ }
+ }
+ temp_v0_3 = gCourseRecordsMenuSelection;
+ phi_v1_2 = &gCourseRecordsMenuSelection;
+ if ((temp_v0_3 == 1) && (D_8018EB90.allCourseTimeTrialRecords.cupRecords[0].courseRecords[0].records[0][temp_t4].unk12 == 0)) {
+ gCourseRecordsMenuSelection = temp_v0_3 - 1;
+ }
+ if ((phi_a3 & 0x800) != 0) {
+ temp_v0_4 = gCourseRecordsMenuSelection;
+ if ((s32) temp_v0_4 > 0) {
+ gCourseRecordsMenuSelection = temp_v0_4 - 1;
+ temp_v0_5 = gCourseRecordsMenuSelection;
+ if ((temp_v0_5 == 1) && (D_8018EB90.allCourseTimeTrialRecords.cupRecords[0].courseRecords[0].records[0][temp_t4].unk12 == 0)) {
+ gCourseRecordsMenuSelection = temp_v0_5 - 1;
+ }
+ sp28 = phi_a2;
+ sp18 = phi_a3;
+ sp24 = &D_8018EB90.allCourseTimeTrialRecords.cupRecords[0].courseRecords[0].records[0][temp_t4];
+ play_sound2(0x49008000);
+ temp_f0 = (f64) phi_a2->unk24;
+ phi_v1_2 = &gCourseRecordsMenuSelection;
+ if (temp_f0 < 4.2) {
+ phi_a2->unk24 = (f32) (temp_f0 + 4.0);
+ }
+ phi_a2->unk8 = -1;
+ }
+ }
+ phi_a3_2 = phi_a3;
+ phi_a2_2 = phi_a2;
+ phi_v1_3 = phi_v1_2;
+ if ((phi_a3 & 0x400) != 0) {
+ temp_v0_6 = *phi_v1_2;
+ if ((s32) temp_v0_6 < 2) {
+ *phi_v1_2 = temp_v0_6 + 1;
+ temp_v0_7 = *phi_v1_2;
+ if ((temp_v0_7 == 1) && (D_8018EB90.allCourseTimeTrialRecords.cupRecords[0].courseRecords[0].records[0][temp_t4].unk12 == 0)) {
+ *phi_v1_2 = temp_v0_7 + 1;
+ }
+ if ((*phi_v1_2 == 2) && (sp28 = phi_a2, sp18 = phi_a3, sp24 = &D_8018EB90.allCourseTimeTrialRecords.cupRecords[0].courseRecords[0].records[0][temp_t4], phi_a3_2 = phi_a3, phi_a2_2 = phi_a2, phi_v1_3 = &gCourseRecordsMenuSelection, (func_800B639C((s32) gTimeTrialDataCourseIndex) < 0))) {
+ if (D_8018EB90.allCourseTimeTrialRecords.cupRecords[0].courseRecords[0].records[0][temp_t4].unk12 == 0) {
+ gCourseRecordsMenuSelection = 0;
+ } else {
+ gCourseRecordsMenuSelection = 1;
+ }
+ } else {
+ sp28 = phi_a2;
+ sp18 = phi_a3;
+ play_sound2(0x49008000);
+ temp_f0_2 = (f64) phi_a2->unk24;
+ phi_a3_2 = phi_a3;
+ phi_a2_2 = phi_a2;
+ phi_v1_3 = &gCourseRecordsMenuSelection;
+ if (temp_f0_2 < 4.2) {
+ phi_a2->unk24 = (f32) (temp_f0_2 + 4.0);
+ }
+ phi_a2->unk8 = 1;
+ }
+ }
+ }
+ if ((phi_a3_2 & 0x4000) != 0) {
+ func_8009E208();
+ play_sound2(0x49008002);
+ return;
+ }
+ if ((phi_a3_2 & 0x8000) != 0) {
+ temp_f0_3 = (f64) phi_a2_2->unk24;
+ if (temp_f0_3 < 4.2) {
+ phi_a2_2->unk24 = (f32) (temp_f0_3 + 4.0);
}
- // Duplicate return node #76. Try simplifying control flow for better match
+ if (*phi_v1_3 == 0) {
+ func_8009E208(0x49008001);
+ play_sound2(0x49008002);
+ return;
+ }
+ D_8018EDEC = 0xC;
+ D_8018EDF9 = 0;
+ play_sound2(0x49008001);
return;
}
- sp18 = phi_v1;
- temp_a2 = func_800AAEF4(0xE9, 0xB);
+ break;
+ case 12:
+ sp18 = (s32) phi_v1;
+ temp_a2_2 = find_8018D9E0_entry_dupe(0xE9);
if ((sp18 & 0x800) != 0) {
- temp_v0_2 = D_8018EDF9;
- if (temp_v0_2 > 0) {
- D_8018EDF9 = temp_v0_2 - 1;
- sp28 = temp_a2;
+ temp_v0_8 = D_8018EDF9;
+ if ((s32) temp_v0_8 > 0) {
+ D_8018EDF9 = temp_v0_8 - 1;
+ sp28 = temp_a2_2;
sp18 = sp18;
play_sound2(0x49008000);
- temp_f0 = temp_a2->unk24;
- if (temp_f0 < D_800F2DA8) {
- temp_a2->unk24 = temp_f0 + 4.0;
+ temp_f0_4 = (f64) temp_a2_2->unk24;
+ if (temp_f0_4 < 4.2) {
+ temp_a2_2->unk24 = (f32) (temp_f0_4 + 4.0);
}
- temp_a2->unk8 = -1;
+ temp_a2_2->unk8 = -1;
}
}
if ((sp18 & 0x400) != 0) {
- temp_v0_3 = D_8018EDF9;
- if (temp_v0_3 <= 0) {
- D_8018EDF9 = temp_v0_3 + 1;
- sp28 = temp_a2;
+ temp_v0_9 = D_8018EDF9;
+ if ((s32) temp_v0_9 <= 0) {
+ D_8018EDF9 = temp_v0_9 + 1;
+ sp28 = temp_a2_2;
sp18 = sp18;
play_sound2(0x49008000);
- temp_f0_2 = temp_a2->unk24;
- if (temp_f0_2 < D_800F2DB0) {
- temp_a2->unk24 = temp_f0_2 + 4.0;
+ temp_f0_5 = (f64) temp_a2_2->unk24;
+ if (temp_f0_5 < 4.2) {
+ temp_a2_2->unk24 = (f32) (temp_f0_5 + 4.0);
}
- temp_a2->unk8 = 1;
+ temp_a2_2->unk8 = 1;
}
}
if ((sp18 & 0x4000) != 0) {
@@ -1196,158 +1272,53 @@ void func_800B15AC(void *arg0, ? arg1) {
}
if ((sp18 & 0x8000) != 0) {
if (D_8018EDF9 != 0) {
- temp_v0_4 = gCourseRecordsMenuSelection;
+ temp_v0_10 = gCourseRecordsMenuSelection;
phi_a1 = 0;
- if (temp_v0_4 != 1) {
- if (temp_v0_4 != 2) {
-
- } else {
- temp_v0_5 = func_800B639C(gTimeTrialDataCourseIndex, 0, temp_a2, sp18);
- phi_a1 = temp_v0_5;
- if (temp_v0_5 >= 0) {
- sp20 = temp_v0_5;
- temp_a1 = sp20;
- if (func_800B69BC(temp_v0_5, temp_v0_5) != 0) {
- D_8018EDEC = 0xD;
- sp20 = temp_a1;
- play_sound2(0x4900FF07, temp_a1);
- phi_a1 = temp_a1;
- } else {
- sp20 = temp_a1;
- play_sound2(0x4900801D, temp_a1);
- D_8018EDEC = 0xB;
- phi_a1 = temp_a1;
- }
- }
- }
- } else {
- func_800B4728(gTimeTrialDataCourseIndex, 0, temp_a2, sp18);
- func_800B559C(gTimeTrialDataCourseIndex);
+ switch (temp_v0_10) { /* switch 1; irregular */
+ case 1: /* switch 1 */
+ func_800B4728((s32) gTimeTrialDataCourseIndex);
+ func_800B559C((s32) gTimeTrialDataCourseIndex);
play_sound2(0x4900801D);
phi_a1 = -1;
+ break;
+ case 2: /* switch 1 */
+ temp_v0_11 = func_800B639C((s32) gTimeTrialDataCourseIndex);
+ phi_a1 = temp_v0_11;
+ if (temp_v0_11 >= 0) {
+ sp20 = temp_v0_11;
+ func_800B69BC(temp_v0_11);
+ temp_a1_4 = sp20;
+ if (MIPS2C_ERROR(Read from unset register $v0) != 0) {
+ D_8018EDEC = 0xD;
+ sp20 = temp_a1_4;
+ play_sound2(0x4900FF07, temp_a1_4);
+ phi_a1 = temp_a1_4;
+ } else {
+ sp20 = temp_a1_4;
+ play_sound2(0x4900801D, temp_a1_4);
+ D_8018EDEC = 0xB;
+ phi_a1 = temp_a1_4;
+ }
+ }
+ break;
}
if ((phi_a1 + 1) == 0) {
D_8018EDEC = 0xB;
return;
}
- // Duplicate return node #76. Try simplifying control flow for better match
- return;
- }
- play_sound2(0x49008002);
- D_8018EDEC = 0xB;
- return;
- }
- // Duplicate return node #76. Try simplifying control flow for better match
- return;
- }
- phi_a3 = phi_v1;
- if ((phi_v1 & 0x200) != 0) {
- temp_a1_2 = gTimeTrialDataCourseIndex;
- if (temp_a1_2 > 0) {
- gTimeTrialDataCourseIndex = temp_a1_2 - 1;
- sp18 = phi_v1;
- play_sound2(0x49008000, temp_a1_2);
- phi_a3 = sp18;
- }
- }
- if ((phi_a3 & 0x100) != 0) {
- temp_a1_3 = gTimeTrialDataCourseIndex;
- if (temp_a1_3 < 0xF) {
- gTimeTrialDataCourseIndex = temp_a1_3 + 1;
- sp18 = phi_a3;
- play_sound2(0x49008000, temp_a1_3);
- }
- }
- sp18 = phi_a3;
- temp_a1_4 = gTimeTrialDataCourseIndex;
- temp_a2_2 = func_800AAEF4(0xE8);
- temp_t4 = ((temp_a1_4 / 4) * 0x60) + ((temp_a1_4 % 4) * 0x18);
- if (gCourseRecordsMenuSelection == 2) {
- sp28 = temp_a2_2;
- sp18 = phi_a3;
- sp24 = temp_t4 + &D_8018EB90;
- if (func_800B639C(temp_a1_4, temp_a1_4, temp_a2_2, phi_a3) < 0) {
- gCourseRecordsMenuSelection = gCourseRecordsMenuSelection - 1;
- }
- }
- temp_v0_6 = gCourseRecordsMenuSelection;
- phi_v1_2 = &gCourseRecordsMenuSelection;
- if ((temp_v0_6 == 1) && ((temp_t4 + &D_8018EB90)->unk12 == 0)) {
- gCourseRecordsMenuSelection = temp_v0_6 - 1;
- }
- if ((phi_a3 & 0x800) != 0) {
- temp_v0_7 = gCourseRecordsMenuSelection;
- if (temp_v0_7 > 0) {
- gCourseRecordsMenuSelection = temp_v0_7 - 1;
- temp_v0_8 = gCourseRecordsMenuSelection;
- if ((temp_v0_8 == 1) && ((temp_t4 + &D_8018EB90)->unk12 == 0)) {
- gCourseRecordsMenuSelection = temp_v0_8 - 1;
- }
- sp28 = temp_a2_2;
- sp18 = phi_a3;
- sp24 = temp_t4 + &D_8018EB90;
- play_sound2(0x49008000);
- temp_f0_3 = temp_a2_2->unk24;
- phi_v1_2 = &gCourseRecordsMenuSelection;
- if (temp_f0_3 < D_800F2D90) {
- temp_a2_2->unk24 = temp_f0_3 + 4.0;
- }
- temp_a2_2->unk8 = -1;
- }
- }
- phi_a3_2 = phi_a3;
- phi_a2 = temp_a2_2;
- phi_v1_3 = phi_v1_2;
- if ((phi_a3 & 0x400) != 0) {
- temp_v0_9 = *phi_v1_2;
- if (temp_v0_9 < 2) {
- *phi_v1_2 = temp_v0_9 + 1;
- temp_v0_10 = *phi_v1_2;
- if ((temp_v0_10 == 1) && ((temp_t4 + &D_8018EB90)->unk12 == 0)) {
- *phi_v1_2 = temp_v0_10 + 1;
- }
- if ((*phi_v1_2 == 2) && (sp28 = temp_a2_2, sp18 = phi_a3, sp24 = temp_t4 + &D_8018EB90, phi_a3_2 = phi_a3, phi_a2 = temp_a2_2, phi_v1_3 = &gCourseRecordsMenuSelection, (func_800B639C(gTimeTrialDataCourseIndex) < 0))) {
- if ((temp_t4 + &D_8018EB90)->unk12 == 0) {
- gCourseRecordsMenuSelection = 0;
- } else {
- gCourseRecordsMenuSelection = 1;
- }
} else {
- sp28 = temp_a2_2;
- sp18 = phi_a3;
- play_sound2(0x49008000);
- temp_f0_4 = temp_a2_2->unk24;
- phi_a3_2 = phi_a3;
- phi_a2 = temp_a2_2;
- phi_v1_3 = &gCourseRecordsMenuSelection;
- if (temp_f0_4 < D_800F2D98) {
- temp_a2_2->unk24 = temp_f0_4 + 4.0;
- }
- temp_a2_2->unk8 = 1;
+ play_sound2(0x49008002);
+ D_8018EDEC = 0xB;
+ return;
}
}
- }
- if ((phi_a3_2 & 0x4000) != 0) {
- func_8009E208();
- play_sound2(0x49008002);
- return;
- }
- if ((phi_a3_2 & 0x8000) != 0) {
- temp_f0_5 = phi_a2->unk24;
- if (temp_f0_5 < D_800F2DA0) {
- phi_a2->unk24 = temp_f0_5 + 4.0;
- }
- if (*phi_v1_3 == 0) {
- func_8009E208(0x49008001);
- play_sound2(0x49008002);
- return;
+ break;
+ case 13:
+ if ((phi_v1 & 0xD000) != 0) {
+ D_8018EDEC = 0xB;
}
- D_8018EDEC = 0xC;
- D_8018EDF9 = 0;
- play_sound2(0x49008001);
- return;
+ break;
}
- // Duplicate return node #76. Try simplifying control flow for better match
}
}
#else