From 5205b09751cca102840eab64efd0212c206095d7 Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Sun, 13 Feb 2022 02:17:34 -0500 Subject: [PATCH] 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 --- .../code_80091750/func_800925CC.s | 2 +- .../code_80091750/func_8009CA6C.s | 12 +- .../code_80091750/func_8009CE64.s | 8 +- .../code_80091750/func_800A0EB8.s | 2 +- .../code_80091750/func_800A1500.s | 2 +- .../code_80091750/func_800A4550.s | 2 +- .../code_80091750/func_800A474C.s | 2 +- .../code_80091750/func_800A54EC.s | 2 +- .../code_80091750/func_800A8CA4.s | 2 +- .../code_80091750/func_800AB314.s | 2 +- .../code_80091750/func_800ACC50.s | 2 +- .../code_80091750/func_800ACF40.s | 2 +- .../code_800AF9B0/func_800B053C.s | 2 +- .../code_800AF9B0/func_800B15AC.s | 4 +- src/code_80091750.c | 77 +- src/code_80091750.h | 4 +- src/code_800AF9B0.c | 793 +++++++++--------- 17 files changed, 450 insertions(+), 470 deletions(-) diff --git a/asm/non_matchings/code_80091750/func_800925CC.s b/asm/non_matchings/code_80091750/func_800925CC.s index 8667cd415..d871932e7 100644 --- a/asm/non_matchings/code_80091750/func_800925CC.s +++ b/asm/non_matchings/code_80091750/func_800925CC.s @@ -1,7 +1,7 @@ glabel func_800925CC /* 0931CC 800925CC 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 0931D0 800925D0 AFBF0014 */ sw $ra, 0x14($sp) -/* 0931D4 800925D4 0C02ABBD */ jal func_800AAEF4 +/* 0931D4 800925D4 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0931D8 800925D8 240400AF */ li $a0, 175 /* 0931DC 800925DC 8C4E0004 */ lw $t6, 4($v0) /* 0931E0 800925E0 24010002 */ li $at, 2 diff --git a/asm/non_matchings/code_80091750/func_8009CA6C.s b/asm/non_matchings/code_80091750/func_8009CA6C.s index a038d8f1a..c9bb66800 100644 --- a/asm/non_matchings/code_80091750/func_8009CA6C.s +++ b/asm/non_matchings/code_80091750/func_8009CA6C.s @@ -5,32 +5,32 @@ glabel func_8009CA6C /* 09D678 8009CA78 1081001F */ beq $a0, $at, .L8009CAF8 /* 09D67C 8009CA7C 00803025 */ move $a2, $a0 /* 09D680 8009CA80 240400AA */ li $a0, 170 -/* 09D684 8009CA84 0C02ABCC */ jal func_800AAF30 +/* 09D684 8009CA84 0C02ABCC */ jal find_8018D9E0_entry /* 09D688 8009CA88 AFA60018 */ sw $a2, 0x18($sp) /* 09D68C 8009CA8C 14400051 */ bnez $v0, .L8009CBD4 /* 09D690 8009CA90 8FA60018 */ lw $a2, 0x18($sp) /* 09D694 8009CA94 240400AB */ li $a0, 171 -/* 09D698 8009CA98 0C02ABCC */ jal func_800AAF30 +/* 09D698 8009CA98 0C02ABCC */ jal find_8018D9E0_entry /* 09D69C 8009CA9C AFA60018 */ sw $a2, 0x18($sp) /* 09D6A0 8009CAA0 1440004C */ bnez $v0, .L8009CBD4 /* 09D6A4 8009CAA4 8FA60018 */ lw $a2, 0x18($sp) /* 09D6A8 8009CAA8 240400B9 */ li $a0, 185 -/* 09D6AC 8009CAAC 0C02ABCC */ jal func_800AAF30 +/* 09D6AC 8009CAAC 0C02ABCC */ jal find_8018D9E0_entry /* 09D6B0 8009CAB0 AFA60018 */ sw $a2, 0x18($sp) /* 09D6B4 8009CAB4 14400047 */ bnez $v0, .L8009CBD4 /* 09D6B8 8009CAB8 8FA60018 */ lw $a2, 0x18($sp) /* 09D6BC 8009CABC 240400BA */ li $a0, 186 -/* 09D6C0 8009CAC0 0C02ABCC */ jal func_800AAF30 +/* 09D6C0 8009CAC0 0C02ABCC */ jal find_8018D9E0_entry /* 09D6C4 8009CAC4 AFA60018 */ sw $a2, 0x18($sp) /* 09D6C8 8009CAC8 14400042 */ bnez $v0, .L8009CBD4 /* 09D6CC 8009CACC 8FA60018 */ lw $a2, 0x18($sp) /* 09D6D0 8009CAD0 240400AC */ li $a0, 172 -/* 09D6D4 8009CAD4 0C02ABCC */ jal func_800AAF30 +/* 09D6D4 8009CAD4 0C02ABCC */ jal find_8018D9E0_entry /* 09D6D8 8009CAD8 AFA60018 */ sw $a2, 0x18($sp) /* 09D6DC 8009CADC 1440003D */ bnez $v0, .L8009CBD4 /* 09D6E0 8009CAE0 8FA60018 */ lw $a2, 0x18($sp) /* 09D6E4 8009CAE4 240400B0 */ li $a0, 176 -/* 09D6E8 8009CAE8 0C02ABCC */ jal func_800AAF30 +/* 09D6E8 8009CAE8 0C02ABCC */ jal find_8018D9E0_entry /* 09D6EC 8009CAEC AFA60018 */ sw $a2, 0x18($sp) /* 09D6F0 8009CAF0 14400038 */ bnez $v0, .L8009CBD4 /* 09D6F4 8009CAF4 8FA60018 */ lw $a2, 0x18($sp) diff --git a/asm/non_matchings/code_80091750/func_8009CE64.s b/asm/non_matchings/code_80091750/func_8009CE64.s index 5b61fbe40..195676f43 100644 --- a/asm/non_matchings/code_80091750/func_8009CE64.s +++ b/asm/non_matchings/code_80091750/func_8009CE64.s @@ -64,7 +64,7 @@ glabel func_8009CE64 /* 09DB4C 8009CF4C A0480000 */ sb $t0, ($v0) .L8009CF50: /* 09DB50 8009CF50 AFA20018 */ sw $v0, 0x18($sp) -/* 09DB54 8009CF54 0C02ABCC */ jal func_800AAF30 +/* 09DB54 8009CF54 0C02ABCC */ jal find_8018D9E0_entry /* 09DB58 8009CF58 AFA50028 */ sw $a1, 0x28($sp) /* 09DB5C 8009CF5C 1040001D */ beqz $v0, .L8009CFD4 /* 09DB60 8009CF60 8FA50028 */ lw $a1, 0x28($sp) @@ -102,7 +102,7 @@ glabel func_8009CE64 /* 09DBD0 8009CFD0 8FBF0014 */ lw $ra, 0x14($sp) .L8009CFD4: /* 09DBD4 8009CFD4 240400AC */ li $a0, 172 -/* 09DBD8 8009CFD8 0C02ABCC */ jal func_800AAF30 +/* 09DBD8 8009CFD8 0C02ABCC */ jal find_8018D9E0_entry /* 09DBDC 8009CFDC AFA50028 */ sw $a1, 0x28($sp) /* 09DBE0 8009CFE0 10400013 */ beqz $v0, .L8009D030 /* 09DBE4 8009CFE4 8FA50028 */ lw $a1, 0x28($sp) @@ -128,7 +128,7 @@ glabel func_8009CE64 /* 09DC2C 8009D02C 8FBF0014 */ lw $ra, 0x14($sp) .L8009D030: /* 09DC30 8009D030 240400C7 */ li $a0, 199 -/* 09DC34 8009D034 0C02ABCC */ jal func_800AAF30 +/* 09DC34 8009D034 0C02ABCC */ jal find_8018D9E0_entry /* 09DC38 8009D038 AFA50028 */ sw $a1, 0x28($sp) /* 09DC3C 8009D03C 10400021 */ beqz $v0, .L8009D0C4 /* 09DC40 8009D040 8FA50028 */ lw $a1, 0x28($sp) @@ -172,7 +172,7 @@ glabel L8009D0AC /* 09DCBC 8009D0BC 3C01800E */ lui $at, %hi(D_800DC5FC) # $at, 0x800e /* 09DCC0 8009D0C0 A420C5FC */ sh $zero, %lo(D_800DC5FC)($at) .L8009D0C4: -/* 09DCC4 8009D0C4 0C02ABCC */ jal func_800AAF30 +/* 09DCC4 8009D0C4 0C02ABCC */ jal find_8018D9E0_entry /* 09DCC8 8009D0C8 240400BD */ li $a0, 189 /* 09DCCC 8009D0CC 10400030 */ beqz $v0, .L8009D190 /* 09DCD0 8009D0D0 8FAF0018 */ lw $t7, 0x18($sp) diff --git a/asm/non_matchings/code_80091750/func_800A0EB8.s b/asm/non_matchings/code_80091750/func_800A0EB8.s index 243cbdd6b..8b7d9228e 100644 --- a/asm/non_matchings/code_80091750/func_800A0EB8.s +++ b/asm/non_matchings/code_80091750/func_800A0EB8.s @@ -3,7 +3,7 @@ glabel func_800A0EB8 /* 0A1ABC 800A0EBC AFBF0014 */ sw $ra, 0x14($sp) /* 0A1AC0 800A0EC0 AFA40018 */ sw $a0, 0x18($sp) /* 0A1AC4 800A0EC4 AFA5001C */ sw $a1, 0x1c($sp) -/* 0A1AC8 800A0EC8 0C02ABBD */ jal func_800AAEF4 +/* 0A1AC8 800A0EC8 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0A1ACC 800A0ECC 240400DA */ li $a0, 218 /* 0A1AD0 800A0ED0 8FA4001C */ lw $a0, 0x1c($sp) /* 0A1AD4 800A0ED4 00405825 */ move $t3, $v0 diff --git a/asm/non_matchings/code_80091750/func_800A1500.s b/asm/non_matchings/code_80091750/func_800A1500.s index 9b4a1bfb7..d2924445b 100644 --- a/asm/non_matchings/code_80091750/func_800A1500.s +++ b/asm/non_matchings/code_80091750/func_800A1500.s @@ -3,7 +3,7 @@ glabel func_800A1500 /* 0A2104 800A1504 AFBF0014 */ sw $ra, 0x14($sp) /* 0A2108 800A1508 AFA40028 */ sw $a0, 0x28($sp) /* 0A210C 800A150C 24040064 */ li $a0, 100 -/* 0A2110 800A1510 0C02ABBD */ jal func_800AAEF4 +/* 0A2110 800A1510 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0A2114 800A1514 AFA0001C */ sw $zero, 0x1c($sp) /* 0A2118 800A1518 8C430004 */ lw $v1, 4($v0) /* 0A211C 800A151C 8FA5001C */ lw $a1, 0x1c($sp) diff --git a/asm/non_matchings/code_80091750/func_800A4550.s b/asm/non_matchings/code_80091750/func_800A4550.s index 5e2acf576..15653e599 100644 --- a/asm/non_matchings/code_80091750/func_800A4550.s +++ b/asm/non_matchings/code_80091750/func_800A4550.s @@ -39,7 +39,7 @@ glabel func_800A4550 /* 0A51DC 800A45DC E7B40014 */ swc1 $f20, 0x14($sp) /* 0A51E0 800A45E0 0C024DAE */ jal func_800936B8 /* 0A51E4 800A45E4 24840021 */ addiu $a0, $a0, 0x21 -/* 0A51E8 800A45E8 0C02ABBD */ jal func_800AAEF4 +/* 0A51E8 800A45E8 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0A51EC 800A45EC 240400BB */ li $a0, 187 /* 0A51F0 800A45F0 8FA30048 */ lw $v1, 0x48($sp) /* 0A51F4 800A45F4 28610003 */ slti $at, $v1, 3 diff --git a/asm/non_matchings/code_80091750/func_800A474C.s b/asm/non_matchings/code_80091750/func_800A474C.s index 3e56384c6..d9d28aa2a 100644 --- a/asm/non_matchings/code_80091750/func_800A474C.s +++ b/asm/non_matchings/code_80091750/func_800A474C.s @@ -69,7 +69,7 @@ glabel func_800A474C /* 0A5438 800A4838 8FAB0030 */ lw $t3, 0x30($sp) /* 0A543C 800A483C 55600024 */ bnel $t3, $zero, .L800A48D0 /* 0A5440 800A4840 24020003 */ li $v0, 3 -/* 0A5444 800A4844 0C02ABBD */ jal func_800AAEF4 +/* 0A5444 800A4844 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0A5448 800A4848 240400BB */ li $a0, 187 /* 0A544C 800A484C 8FAC0050 */ lw $t4, 0x50($sp) /* 0A5450 800A4850 29810005 */ slti $at, $t4, 5 diff --git a/asm/non_matchings/code_80091750/func_800A54EC.s b/asm/non_matchings/code_80091750/func_800A54EC.s index 1c9eb74b7..9cdd13faf 100644 --- a/asm/non_matchings/code_80091750/func_800A54EC.s +++ b/asm/non_matchings/code_80091750/func_800A54EC.s @@ -8,7 +8,7 @@ glabel func_800A54EC /* 0A6104 800A5504 3C0A800E */ lui $t2, %hi(gModeSelection) # $t2, 0x800e /* 0A6108 800A5508 8D4AC53C */ lw $t2, %lo(gModeSelection)($t2) /* 0A610C 800A550C 240400C7 */ li $a0, 199 -/* 0A6110 800A5510 0C02ABCC */ jal func_800AAF30 +/* 0A6110 800A5510 0C02ABCC */ jal find_8018D9E0_entry /* 0A6114 800A5514 AFAA0040 */ sw $t2, 0x40($sp) /* 0A6118 800A5518 3C088015 */ lui $t0, %hi(gDisplayListHead) # $t0, 0x8015 /* 0A611C 800A551C 25080298 */ addiu $t0, %lo(gDisplayListHead) # addiu $t0, $t0, 0x298 diff --git a/asm/non_matchings/code_80091750/func_800A8CA4.s b/asm/non_matchings/code_80091750/func_800A8CA4.s index cabcb4fd3..c9d481480 100644 --- a/asm/non_matchings/code_80091750/func_800A8CA4.s +++ b/asm/non_matchings/code_80091750/func_800A8CA4.s @@ -9,7 +9,7 @@ glabel func_800A8CA4 /* 0A98C0 800A8CC0 AFB3003C */ sw $s3, 0x3c($sp) /* 0A98C4 800A8CC4 AFB20038 */ sw $s2, 0x38($sp) /* 0A98C8 800A8CC8 AFB10034 */ sw $s1, 0x34($sp) -/* 0A98CC 800A8CCC 0C02ABBD */ jal func_800AAEF4 +/* 0A98CC 800A8CCC 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0A98D0 800A8CD0 24040064 */ li $a0, 100 /* 0A98D4 800A8CD4 3C118015 */ lui $s1, %hi(gDisplayListHead) # $s1, 0x8015 /* 0A98D8 800A8CD8 26310298 */ addiu $s1, %lo(gDisplayListHead) # addiu $s1, $s1, 0x298 diff --git a/asm/non_matchings/code_80091750/func_800AB314.s b/asm/non_matchings/code_80091750/func_800AB314.s index 7b2eeead1..3dfafc786 100644 --- a/asm/non_matchings/code_80091750/func_800AB314.s +++ b/asm/non_matchings/code_80091750/func_800AB314.s @@ -8,7 +8,7 @@ glabel func_800AB314 /* 0ABF28 800AB328 24A4005F */ addiu $a0, $a1, 0x5f /* 0ABF2C 800AB32C AFA3001C */ sw $v1, 0x1c($sp) /* 0ABF30 800AB330 AFA5003C */ sw $a1, 0x3c($sp) -/* 0ABF34 800AB334 0C02ABBD */ jal func_800AAEF4 +/* 0ABF34 800AB334 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0ABF38 800AB338 AFA60040 */ sw $a2, 0x40($sp) /* 0ABF3C 800AB33C 8FA5003C */ lw $a1, 0x3c($sp) /* 0ABF40 800AB340 8FA3001C */ lw $v1, 0x1c($sp) diff --git a/asm/non_matchings/code_80091750/func_800ACC50.s b/asm/non_matchings/code_80091750/func_800ACC50.s index c84acd6e6..3272e7e65 100644 --- a/asm/non_matchings/code_80091750/func_800ACC50.s +++ b/asm/non_matchings/code_80091750/func_800ACC50.s @@ -44,7 +44,7 @@ glabel L800ACC84 /* 0AD8F0 800ACCF0 8FBF001C */ lw $ra, 0x1c($sp) glabel L800ACCF4 /* 0AD8F4 800ACCF4 240400B1 */ li $a0, 177 -/* 0AD8F8 800ACCF8 0C02ABBD */ jal func_800AAEF4 +/* 0AD8F8 800ACCF8 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0AD8FC 800ACCFC AFA50020 */ sw $a1, 0x20($sp) /* 0AD900 800ACD00 8C4E0004 */ lw $t6, 4($v0) /* 0AD904 800ACD04 8FA50020 */ lw $a1, 0x20($sp) diff --git a/asm/non_matchings/code_80091750/func_800ACF40.s b/asm/non_matchings/code_80091750/func_800ACF40.s index ffbe28f41..d7a67a02b 100644 --- a/asm/non_matchings/code_80091750/func_800ACF40.s +++ b/asm/non_matchings/code_80091750/func_800ACF40.s @@ -91,7 +91,7 @@ glabel L800AD01C /* 0ADC8C 800AD08C 14200040 */ bnez $at, .L800AD190 /* 0ADC90 800AD090 AE0F0020 */ sw $t7, 0x20($s0) /* 0ADC94 800AD094 AFA50034 */ sw $a1, 0x34($sp) -/* 0ADC98 800AD098 0C02ABBD */ jal func_800AAEF4 +/* 0ADC98 800AD098 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0ADC9C 800AD09C AFA60038 */ sw $a2, 0x38($sp) /* 0ADCA0 800AD0A0 8C590004 */ lw $t9, 4($v0) /* 0ADCA4 800AD0A4 8FA50034 */ lw $a1, 0x34($sp) diff --git a/asm/non_matchings/code_800AF9B0/func_800B053C.s b/asm/non_matchings/code_800AF9B0/func_800B053C.s index 48b5493c0..90676fc9f 100644 --- a/asm/non_matchings/code_800AF9B0/func_800B053C.s +++ b/asm/non_matchings/code_800AF9B0/func_800B053C.s @@ -22,7 +22,7 @@ glabel func_800B053C /* 0B1188 800B0588 14400385 */ bnez $v0, .L800B13A0 /* 0B118C 800B058C 97A6003E */ lhu $a2, 0x3e($sp) /* 0B1190 800B0590 240400F0 */ li $a0, 240 -/* 0B1194 800B0594 0C02ABBD */ jal func_800AAEF4 +/* 0B1194 800B0594 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0B1198 800B0598 A7A6003E */ sh $a2, 0x3e($sp) /* 0B119C 800B059C 3C098019 */ lui $t1, %hi(D_8018EDEC) # $t1, 0x8019 /* 0B11A0 800B05A0 2529EDEC */ addiu $t1, %lo(D_8018EDEC) # addiu $t1, $t1, -0x1214 diff --git a/asm/non_matchings/code_800AF9B0/func_800B15AC.s b/asm/non_matchings/code_800AF9B0/func_800B15AC.s index ab3cfa5f3..00c620d16 100644 --- a/asm/non_matchings/code_800AF9B0/func_800B15AC.s +++ b/asm/non_matchings/code_800AF9B0/func_800B15AC.s @@ -65,7 +65,7 @@ glabel func_800B15AC /* 0B229C 800B169C 8FA70018 */ lw $a3, 0x18($sp) .L800B16A0: /* 0B22A0 800B16A0 240400E8 */ li $a0, 232 -/* 0B22A4 800B16A4 0C02ABBD */ jal func_800AAEF4 +/* 0B22A4 800B16A4 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0B22A8 800B16A8 AFA70018 */ sw $a3, 0x18($sp) /* 0B22AC 800B16AC 3C058019 */ lui $a1, %hi(gTimeTrialDataCourseIndex) # $a1, 0x8019 /* 0B22B0 800B16B0 80A5EDF7 */ lb $a1, %lo(gTimeTrialDataCourseIndex)($a1) @@ -290,7 +290,7 @@ glabel func_800B15AC /* 0B25D8 800B19D8 8FBF0014 */ lw $ra, 0x14($sp) .L800B19DC: /* 0B25DC 800B19DC 00603825 */ move $a3, $v1 -/* 0B25E0 800B19E0 0C02ABBD */ jal func_800AAEF4 +/* 0B25E0 800B19E0 0C02ABBD */ jal find_8018D9E0_entry_dupe /* 0B25E4 800B19E4 AFA30018 */ sw $v1, 0x18($sp) /* 0B25E8 800B19E8 8FA70018 */ lw $a3, 0x18($sp) /* 0B25EC 800B19EC 3C038019 */ lui $v1, %hi(D_8018EDF9) # $v1, 0x8019 diff --git a/src/code_80091750.c b/src/code_80091750.c index cdd4b89f2..c1b330a07 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -632,11 +632,11 @@ void func_800925A0(void) { #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern void *func_800AAEF4(s32); // extern -// removed a temp from this func temp = func_800AAEF4. +extern void *find_8018D9E0_entry_dupe(s32); // extern +// removed a temp from this func temp = find_8018D9E0_entry_dupe. void func_800925CC(void) { - if (func_800AAEF4(0xAF)->unk4 == 2) { - func_800AAEF4(0xAF)->unk4 = 3; + if (find_8018D9E0_entry_dupe(0xAF)->unk4 == 2) { + find_8018D9E0_entry_dupe(0xAF)->unk4 = 3; } } #else @@ -657,8 +657,8 @@ void func_8009265C(void) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -? add_8018D9E0_entry(?, ?, ?, ?); /* extern */ +//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda +extern u16 D_800DC5E4; void func_80092688(void) { u16 temp_t6; @@ -1159,7 +1159,7 @@ void func_80093754(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f } void print_text2(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f32 y_scale, s32 arg6) { - s32 temp_v0_3; + MkTexture *glyphTexture; s32 characterWidth; s32 glyphIndex; @@ -1168,9 +1168,9 @@ void print_text2(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f32 do { glyphIndex = char_to_glyph_index(text); if (glyphIndex >= 0) { - temp_v0_3 = segmented_to_virtual(gGlyphTextureLUT[glyphIndex]); - func_80099184(temp_v0_3); - gDisplayListHead = func_8009BEF0(gDisplayListHead, temp_v0_3, column - (gGlyphDisplayWidth[glyphIndex] / 2), row, arg6, x_scale, y_scale); + glyphTexture = segmented_to_virtual(gGlyphTextureLUT[glyphIndex]); + func_80099184(glyphTexture); + gDisplayListHead = func_8009BEF0(gDisplayListHead, glyphTexture, column - (gGlyphDisplayWidth[glyphIndex] / 2), row, arg6, x_scale, y_scale); if ((glyphIndex >= 0xD5) && (glyphIndex < 0xE0)) { characterWidth = 0x20; } else { @@ -1902,17 +1902,15 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_80095574.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_80098C18(s32, s32, s32, s32, s32, s32); // extern +//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda extern s32 D_8018E7A8; -extern s32 gDisplayListHead; -void func_800958D4(s32 arg0, s32 arg4, s32 arg5) { +void func_800958D4(s32 arg0, s32 ulx, s32 uly, s32 lrx, s32 lry, s32 arg5) { s32 temp_lo; s32 phi_v0; s32 phi_v0_2; - temp_lo = ((D_8018E7A8 % arg5) << 9) / arg5; + temp_lo = (s32) (((s32) D_8018E7A8 % arg5) << 9) / arg5; phi_v0 = temp_lo; if (temp_lo >= 0x101) { phi_v0 = 0x200 - temp_lo; @@ -1921,7 +1919,7 @@ void func_800958D4(s32 arg0, s32 arg4, s32 arg5) { if (phi_v0 >= 0x100) { phi_v0_2 = 0xFF; } - gDisplayListHead = func_80098C18(gDisplayListHead, arg4, phi_v0_2, phi_v0_2, phi_v0_2, 0xFF); + gDisplayListHead = func_80098C18(gDisplayListHead, ulx, uly, lrx, lry, phi_v0_2, phi_v0_2, phi_v0_2, 0xFF); } #else GLOBAL_ASM("asm/non_matchings/code_80091750/func_800958D4.s") @@ -5925,7 +5923,7 @@ void func_8009CA6C(s32 arg0) { u8 temp_t0; ? phi_a1; - if ((arg0 == 4) || ((arg0 = arg0, (func_800AAF30(0xAA) == 0)) && (arg0 = arg0, (func_800AAF30(0xAB) == 0)) && (arg0 = arg0, (func_800AAF30(0xB9) == 0)) && (arg0 = arg0, (func_800AAF30(0xBA) == 0)) && (arg0 = arg0, (func_800AAF30(0xAC) == 0)) && (arg0 = arg0, (func_800AAF30(0xB0) == 0)))) { + if ((arg0 == 4) || ((arg0 = arg0, (find_8018D9E0_entry(0xAA) == 0)) && (arg0 = arg0, (find_8018D9E0_entry(0xAB) == 0)) && (arg0 = arg0, (find_8018D9E0_entry(0xB9) == 0)) && (arg0 = arg0, (find_8018D9E0_entry(0xBA) == 0)) && (arg0 = arg0, (find_8018D9E0_entry(0xAC) == 0)) && (arg0 = arg0, (find_8018D9E0_entry(0xB0) == 0)))) { temp_v1 = gDisplayListHead; gDisplayListHead = temp_v1 + 8; temp_v1->words.w0 = 0x06000000; @@ -6091,7 +6089,7 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009CE1C.s") //generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 ? func_8000F124(s8, s32); /* extern */ ? func_8009CE1C(s32 *, s32, s32); /* extern */ -void *func_800AAF30(?, s32, s32); /* extern */ +void *find_8018D9E0_entry(?, s32, s32); /* extern */ ? func_80290338(); /* extern */ ? func_80290360(); /* extern */ ? func_80290388(); /* extern */ @@ -6170,7 +6168,7 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { } sp18 = temp_v0_2; sp28 = 0; - temp_v0_3 = func_800AAF30(0xB0, 0, 2); + temp_v0_3 = find_8018D9E0_entry(0xB0, 0, 2); if (temp_v0_3 != 0) { temp_v1_2 = temp_v0_3->unk4; if (temp_v1_2 != 0xA) { @@ -6192,7 +6190,7 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { return; } sp28 = 0; - temp_v0_4 = func_800AAF30(0xAC, 0); + temp_v0_4 = find_8018D9E0_entry(0xAC, 0); if (temp_v0_4 != 0) { temp_v1_3 = temp_v0_4->unk4; if (temp_v1_3 != 0xB) { @@ -6207,7 +6205,7 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { return; } sp28 = 0; - temp_v0_5 = func_800AAF30(0xC7, 0); + temp_v0_5 = find_8018D9E0_entry(0xC7, 0); if (temp_v0_5 != 0) { temp_t6 = temp_v0_5->unk4; switch (temp_t6) { /* switch 1 */ @@ -6243,7 +6241,7 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { D_800DC5FC = 0; } } - temp_v0_6 = func_800AAF30(0xBD, phi_a1_3); + temp_v0_6 = find_8018D9E0_entry(0xBD, phi_a1_3); if (temp_v0_6 != 0) { temp_t6_2 = temp_v0_6->unk4; switch (temp_t6_2) { /* switch 2 */ @@ -8902,7 +8900,7 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A09E0.s") 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); + temp_t1 = find_8018D9E0_entry_dupe(0xDA); if ((gControllerPakMenuSelection != CONTROLLER_PAK_MENU_SELECT_RECORD) && (gControllerPakMenuSelection != CONTROLLER_PAK_MENU_END)) { gDPSetPrimColor(gDisplayListHead++, 0, 0, 0xFF, temp_t1->unk20, 0x00, 0xFF); @@ -9027,7 +9025,7 @@ void func_800A0EB8(s32 arg0, s32 arg1) { struct_8018D9E0_entry *temp_t3; s32 phi_t1; - temp_t3 = func_800AAEF4(0xDA); + temp_t3 = find_8018D9E0_entry_dupe(0xDA); if (arg1 == 0) { if (gControllerPakMenuSelection == CONTROLLER_PAK_MENU_END) { phi_t1 = 1; @@ -9227,7 +9225,7 @@ void func_800A1500(struct_8018D9E0_entry *arg0) { s32 phi_a1; sp1C = 0; - temp_v0 = func_800AAEF4(0x64); + temp_v0 = find_8018D9E0_entry_dupe(0x64); temp_v1 = temp_v0->unk4; phi_a1 = sp1C; switch (temp_v1) { /* irregular */ @@ -10783,7 +10781,7 @@ void func_800A4550(s32 recordType, s32 column, s32 row) { phi_v0 = recordType * 4; } func_800936B8(column + 0x21, row, *(&D_800E7734 + phi_v0), 0, 0.7f, 0.7f); - temp_v0_2 = func_800AAEF4(0xBB); + temp_v0_2 = find_8018D9E0_entry_dupe(0xBB); if (recordType < 3) { if ((temp_v0_2->unk20 & (1 << recordType)) != 0) { phi_a0 = (s32) gGlobalTimer % 3; @@ -10866,7 +10864,7 @@ void func_800A474C(s32 recordType, s32 column, s32 row) { } func_800939C8(column + 0x14, row, D_800E7744[recordType], 2, 0.65f, 0.65f); if (sp30 == 0) { - temp_v0 = func_800AAEF4(0xBB); + temp_v0 = find_8018D9E0_entry_dupe(0xBB); if (recordType < 5) { if (recordType == temp_v0->unk1C) { sp40 = (s32) gGlobalTimer % 3; @@ -11245,7 +11243,7 @@ void func_800A54EC(void) { temp_t2 = gModeSelection; sp40 = temp_t2; temp_v1 = gDisplayListHead; - sp48 = func_800AAF30(0xC7); + sp48 = find_8018D9E0_entry(0xC7); gDisplayListHead = temp_v1 + 8; temp_v1->words.w1 = (s32) D_802B8880 & 0x1FFFFFFF; temp_v1->words.w0 = 0x03800010; @@ -13213,7 +13211,7 @@ void func_800A8CA4(struct_8018D9E0_entry *arg0) { struct_8018D9E0_entry *temp_v0; s32 phi_s0; - temp_v0 = func_800AAEF4(0x64); + temp_v0 = find_8018D9E0_entry_dupe(0x64); temp_v1 = gDisplayListHead; temp_s2 = arg0->column; temp_s3 = arg0->row; @@ -14743,7 +14741,18 @@ loop_3: GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AAEB4.s") #endif -struct_8018D9E0_entry *func_800AAEF4(s32 arg0) { +/** + * @bug + * `arg0` is the desired "type" of the 8018D9E0 entry to + * search for. If no entry with that "type" is found, this + * function will enter a `while(1)` loop, hard-locking the + * game. + * + * In practice this never appears to happen, but that is + * probably as much a matter of luck as it is good + * reasoning on the original author(s) part. +**/ +struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32 arg0) { struct_8018D9E0_entry *entry = D_8018D9E0; for (; !(entry > (&D_8018D9E0[D_8018D9E0_SIZE])); entry++) { if (entry->type == arg0) { @@ -14757,7 +14766,7 @@ escape: return entry; } -struct_8018D9E0_entry *func_800AAF30(s32 arg0) { +struct_8018D9E0_entry *find_8018D9E0_entry(s32 arg0) { struct_8018D9E0_entry *entry = D_8018D9E0; for (; !(entry > (&D_8018D9E0[D_8018D9E0_SIZE])); entry++) { if (entry->type == arg0) { @@ -14994,7 +15003,7 @@ void func_800AB314(struct_8018D9E0_entry *arg0) { arg0 = arg0; temp_a1 = phi_a1 + 1; temp_v1 = phi_v1 + 4; - temp_v1->unk-4 = func_800AAEF4(phi_a1 + 0x5F); + temp_v1->unk-4 = find_8018D9E0_entry_dupe(phi_a1 + 0x5F); phi_v1 = temp_v1; phi_a1 = temp_a1; } while (temp_a1 < 4); @@ -16048,7 +16057,7 @@ void func_800ACC50(struct_8018D9E0_entry *arg0) { return; case 1: arg0 = temp_a1; - if (func_800AAEF4(0xB1)->unk4 >= 2) { + if (find_8018D9E0_entry_dupe(0xB1)->unk4 >= 2) { arg0->unk4 = 2; return; } @@ -16230,7 +16239,7 @@ block_11: if (temp_t7_2 >= 0x1F) { sp34 = (s32) temp_a1; sp38 = temp_a2; - if (func_800AAEF4(0xB0)->unk4 >= 2) { + if (find_8018D9E0_entry_dupe(0xB0)->unk4 >= 2) { sp38 = temp_a2; func_8009A640(arg0->D_8018DEE0_index, 0, temp_a2, segmented_to_virtual_dupe(D_800E8380[temp_a1])); arg0->unk4 = 3; diff --git a/src/code_80091750.h b/src/code_80091750.h index 4095e40fa..5ba53a91e 100644 --- a/src/code_80091750.h +++ b/src/code_80091750.h @@ -156,8 +156,8 @@ void func_800A954C(struct_8018D9E0_entry*); void func_800AADD4(struct_8018D9E0_entry*); void func_800AAE18(struct_8018D9E0_entry*); struct_8018D9E0_entry *func_800AAEB4(s32); -struct_8018D9E0_entry *func_800AAEF4(s32); -struct_8018D9E0_entry *func_800AAF30(s32); +struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32); +struct_8018D9E0_entry *find_8018D9E0_entry(s32); s32 func_800AAF70(s32); void func_800AAF94(struct_8018D9E0_entry*, s32); void func_800AB260(struct_8018D9E0_entry*); 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); - 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; - 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); - return; - } - /* Duplicate return node #166. Try simplifying control flow for better match */ - return; - } + 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; - } - 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); + 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 SOUND_HEADPHONES: - play_sound2(0x49008025); + case 1: /* switch 2 */ + func_800B6708(); break; - case SOUND_MONO: - play_sound2(0x49008029); + case 2: /* switch 2 */ + D_8018EDEC = 0x34; + play_sound2(0x4900FF07); break; - default: + 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); + return; + } + 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; } + 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); } - // Duplicate return node #76. Try simplifying control flow for better match + } + 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; } - sp18 = phi_v1; - temp_a2 = func_800AAEF4(0xE9, 0xB); + 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); + } + if (*phi_v1_3 == 0) { + func_8009E208(0x49008001); + play_sound2(0x49008002); + return; + } + D_8018EDEC = 0xC; + D_8018EDF9 = 0; + play_sound2(0x49008001); + return; + } + 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 + } else { + play_sound2(0x49008002); + D_8018EDEC = 0xB; return; } - play_sound2(0x49008002); + } + break; + case 13: + if ((phi_v1 & 0xD000) != 0) { D_8018EDEC = 0xB; - return; } - // Duplicate return node #76. Try simplifying control flow for better match - return; + break; } - 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; - } - } - } - 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; - } - D_8018EDEC = 0xC; - D_8018EDF9 = 0; - play_sound2(0x49008001); - return; - } - // Duplicate return node #76. Try simplifying control flow for better match } } #else