diff --git a/README.md b/README.md index 25d9c7cc..32f35391 100755 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ You are not required to install a binutils package, but it does speed up the ini **a.** Use the `-jN` argument to use `N` number of threads to speed up building. For example, if you have a system with 4 cores / 4 threads, you should do `make -j4`. ## Modding - -If you are modifying the code in the repo, then you should add `NON_MATCHING=1` to the make command. - +If you are modifying the code in the repo, then you should add `NON_MATCHING=1` to the make command. Example: `make NON_MATCHING=1 -j4` + +The `NON_MATCHING` define will include the functions that don't exactly match one-to-one, but should be no different functionality-wise. If you do notice any bugs that occur in a `NON_MATCHING` build that are not in the vanilla game, then please file an issue describing the bug. It would be helpful if you can track down which function is causing the bug, but that is not required. ## Style Guide @@ -113,14 +113,14 @@ s32 is_drumstick_unlocked(void) { } ``` -As of July 30th 2021, this is our current score: +As of August 6th 2021, this is our current score: ``` ======================================================= ADVENTURE ONE (ASM -> C Decompilation) - ------------------- 12.14% Complete ------------------- - # Decompiled functions: 830 - # GLOBAL_ASM remaining: 938 - # NON_MATCHING functions: 58 + ------------------- 13.16% Complete ------------------- + # Decompiled functions: 852 + # GLOBAL_ASM remaining: 918 + # NON_MATCHING functions: 76 --------------------- Game Status --------------------- Balloons: 8/47, Keys: 1/4, Trophies: 0/5 T.T. Amulets: 0/4, Wizpig Amulets: 0/4 @@ -130,7 +130,7 @@ As of July 30th 2021, this is our current score: ADVENTURE TWO (Cleanup & Documentation) ------------------- 0.75% Complete ------------------- # Documented functions: 61 - # Undocumented remaining: 1707 + # Undocumented remaining: 1709 --------------------- Game Status --------------------- Balloons: 0/47, Keys: 0/4, Trophies: 0/5 T.T. Amulets: 0/4, Wizpig Amulets: 0/4 @@ -147,7 +147,7 @@ As of July 30th 2021, this is our current score: What should be focused on. -* Decompiling the asm files into matching c files. +* Decompiling the non-matching asm files into matching C functions. * Documenting variables & functions ### Minor diff --git a/asm/non_matchings/menu/MenuBootInit.s b/asm/non_matchings/menu/MenuBootInit.s deleted file mode 100644 index 294caf4b..00000000 --- a/asm/non_matchings/menu/MenuBootInit.s +++ /dev/null @@ -1,74 +0,0 @@ -glabel menu_boot_init -/* 0890F4 800884F4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0890F8 800884F8 AFBF0014 */ sw $ra, 0x14($sp) -/* 0890FC 800884FC 3C04800E */ lui $a0, %hi(D_800DF77C) # $a0, 0x800e -/* 089100 80088500 0C030076 */ jal func_800C01D8 -/* 089104 80088504 2484F77C */ addiu $a0, %lo(D_800DF77C) # addiu $a0, $a0, -0x884 -/* 089108 80088508 00002025 */ move $a0, $zero -/* 08910C 8008850C 00002825 */ move $a1, $zero -/* 089110 80088510 0C01DECD */ jal func_80077B34 -/* 089114 80088514 00003025 */ move $a2, $zero -/* 089118 80088518 3C04800E */ lui $a0, %hi(D_800DF7C4) # $a0, 0x800e -/* 08911C 8008851C 0C02719D */ jal func_8009C674 -/* 089120 80088520 2484F7C4 */ addiu $a0, %lo(D_800DF7C4) # addiu $a0, $a0, -0x83c -/* 089124 80088524 3C0E800E */ lui $t6, %hi(D_800DF7C4) # $t6, 0x800e -/* 089128 80088528 85CEF7C4 */ lh $t6, %lo(D_800DF7C4)($t6) -/* 08912C 8008852C 3C048012 */ lui $a0, %hi(D_80126550) # $a0, 0x8012 -/* 089130 80088530 24846550 */ addiu $a0, %lo(D_80126550) # addiu $a0, $a0, 0x6550 -/* 089134 80088534 3C08800E */ lui $t0, %hi(D_800DF7C4+2) # $t0, 0x800e -/* 089138 80088538 000E7880 */ sll $t7, $t6, 2 -/* 08913C 8008853C 8508F7C6 */ lh $t0, %lo(D_800DF7C4+2)($t0) -/* 089140 80088540 008FC021 */ addu $t8, $a0, $t7 -/* 089144 80088544 8F190000 */ lw $t9, ($t8) -/* 089148 80088548 3C01800E */ lui $at, %hi(D_800DF7DC) # $at, 0x800e -/* 08914C 8008854C 3C0C800E */ lui $t4, %hi(D_800DF7C4+4) # $t4, 0x800e -/* 089150 80088550 00084880 */ sll $t1, $t0, 2 -/* 089154 80088554 858CF7C8 */ lh $t4, %lo(D_800DF7C4+4)($t4) -/* 089158 80088558 00895021 */ addu $t2, $a0, $t1 -/* 08915C 8008855C AC39F7DC */ sw $t9, %lo(D_800DF7DC)($at) -/* 089160 80088560 8D4B0000 */ lw $t3, ($t2) -/* 089164 80088564 3C01800E */ lui $at, %hi(D_800DF7DC+16) # $at, 0x800e -/* 089168 80088568 000C6880 */ sll $t5, $t4, 2 -/* 08916C 8008856C 008D7021 */ addu $t6, $a0, $t5 -/* 089170 80088570 AC2BF7E4 */ sw $t3, %lo(D_800DF7DC+8)($at) -/* 089174 80088574 8DCF0000 */ lw $t7, ($t6) - # The extra lui is here. -/* 089178 80088578 3C03800E */ lui $v1, %hi(D_800DF7DC+24) # $v1, 0x800e -/* 08917C 8008857C 3C02800E */ lui $v0, %hi(D_800DF7C4+6) # $v0, 0x800e -/* 089180 80088580 3C05800E */ lui $a1, %hi(D_800DF7C4+22) # $a1, 0x800e -/* 089184 80088584 24A5F7DA */ addiu $a1, %lo(D_800DF7C4+22) # addiu $a1, $a1, -0x826 -/* 089188 80088588 2442F7CA */ addiu $v0, %lo(D_800DF7C4+6) # addiu $v0, $v0, -0x836 -/* 08918C 8008858C 2463F7F4 */ addiu $v1, %lo(D_800DF7DC+24) # addiu $v1, $v1, -0x80c -/* 089190 80088590 AC2FF7EC */ sw $t7, %lo(D_800DF7DC+16)($at) -.L80088594: -/* 089194 80088594 84580000 */ lh $t8, ($v0) -/* 089198 80088598 844A0002 */ lh $t2, 2($v0) -/* 08919C 8008859C 0018C880 */ sll $t9, $t8, 2 -/* 0891A0 800885A0 00994021 */ addu $t0, $a0, $t9 -/* 0891A4 800885A4 8D090000 */ lw $t1, ($t0) -/* 0891A8 800885A8 84480006 */ lh $t0, 6($v0) -/* 0891AC 800885AC 844E0004 */ lh $t6, 4($v0) -/* 0891B0 800885B0 000A5880 */ sll $t3, $t2, 2 -/* 0891B4 800885B4 AC690000 */ sw $t1, ($v1) -/* 0891B8 800885B8 008B6021 */ addu $t4, $a0, $t3 -/* 0891BC 800885BC 00084880 */ sll $t1, $t0, 2 -/* 0891C0 800885C0 000E7880 */ sll $t7, $t6, 2 -/* 0891C4 800885C4 8D8D0000 */ lw $t5, ($t4) -/* 0891C8 800885C8 008FC021 */ addu $t8, $a0, $t7 -/* 0891CC 800885CC 00895021 */ addu $t2, $a0, $t1 -/* 0891D0 800885D0 8D4B0000 */ lw $t3, ($t2) -/* 0891D4 800885D4 8F190000 */ lw $t9, ($t8) -/* 0891D8 800885D8 24420008 */ addiu $v0, $v0, 8 -/* 0891DC 800885DC 24630020 */ addiu $v1, $v1, 0x20 -/* 0891E0 800885E0 AC6DFFE8 */ sw $t5, -0x18($v1) -/* 0891E4 800885E4 AC6BFFF8 */ sw $t3, -8($v1) -/* 0891E8 800885E8 1445FFEA */ bne $v0, $a1, .L80088594 -/* 0891EC 800885EC AC79FFF0 */ sw $t9, -0x10($v1) -/* 0891F0 800885F0 3C018012 */ lui $at, %hi(D_80126C20) # $at, 0x8012 -/* 0891F4 800885F4 8FBF0014 */ lw $ra, 0x14($sp) -/* 0891F8 800885F8 AC206C20 */ sw $zero, %lo(D_80126C20)($at) -/* 0891FC 800885FC 3C018012 */ lui $at, %hi(D_80126C18) # $at, 0x8012 -/* 089200 80088600 AC206C18 */ sw $zero, %lo(D_80126C18)($at) -/* 089204 80088604 03E00008 */ jr $ra -/* 089208 80088608 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/non_matchings/menu/func_8008AD44.s b/asm/non_matchings/menu/calculate_and_display_rom_checksum.s similarity index 99% rename from asm/non_matchings/menu/func_8008AD44.s rename to asm/non_matchings/menu/calculate_and_display_rom_checksum.s index a7a872a5..ba5899af 100644 --- a/asm/non_matchings/menu/func_8008AD44.s +++ b/asm/non_matchings/menu/calculate_and_display_rom_checksum.s @@ -1,4 +1,4 @@ -glabel func_8008AD44 +glabel calculate_and_display_rom_checksum /* 08B944 8008AD44 27BDFFD0 */ addiu $sp, $sp, -0x30 /* 08B948 8008AD48 3C0E800E */ lui $t6, %hi(D_800E1E18) # $t6, 0x800e /* 08B94C 8008AD4C 8DCE1E18 */ lw $t6, %lo(D_800E1E18)($t6) diff --git a/asm/non_matchings/menu/func_8009B1E4.s b/asm/non_matchings/menu/func_8009B1E4.s deleted file mode 100644 index 91a8db13..00000000 --- a/asm/non_matchings/menu/func_8009B1E4.s +++ /dev/null @@ -1,86 +0,0 @@ -glabel func_8009B1E4 -/* 09BDE4 8009B1E4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 09BDE8 8009B1E8 8FAE0028 */ lw $t6, 0x28($sp) -/* 09BDEC 8009B1EC AFBF0014 */ sw $ra, 0x14($sp) -/* 09BDF0 8009B1F0 29C10100 */ slti $at, $t6, 0x100 -/* 09BDF4 8009B1F4 AFA40018 */ sw $a0, 0x18($sp) -/* 09BDF8 8009B1F8 AFA5001C */ sw $a1, 0x1c($sp) -/* 09BDFC 8009B1FC AFA60020 */ sw $a2, 0x20($sp) -/* 09BE00 8009B200 14200003 */ bnez $at, .L8009B210 -/* 09BE04 8009B204 AFA70024 */ sw $a3, 0x24($sp) -/* 09BE08 8009B208 240A00FF */ li $t2, 255 -/* 09BE0C 8009B20C AFAA0028 */ sw $t2, 0x28($sp) -.L8009B210: -/* 09BE10 8009B210 8FAA0028 */ lw $t2, 0x28($sp) -/* 09BE14 8009B214 3C048012 */ lui $a0, %hi(D_801263A0) # $a0, 0x8012 -/* 09BE18 8009B218 05410002 */ bgez $t2, .L8009B224 -/* 09BE1C 8009B21C 248463A0 */ addiu $a0, %lo(D_801263A0) # addiu $a0, $a0, 0x63a0 -/* 09BE20 8009B220 00005025 */ move $t2, $zero -.L8009B224: -/* 09BE24 8009B224 8C820000 */ lw $v0, ($a0) -/* 09BE28 8009B228 3C19800E */ lui $t9, %hi(D_800E1780) # $t9, 0x800e -/* 09BE2C 8009B22C 244F0008 */ addiu $t7, $v0, 8 -/* 09BE30 8009B230 AC8F0000 */ sw $t7, ($a0) -/* 09BE34 8009B234 27391780 */ addiu $t9, %lo(D_800E1780) # addiu $t9, $t9, 0x1780 -/* 09BE38 8009B238 3C180600 */ lui $t8, 0x600 -/* 09BE3C 8009B23C AC580000 */ sw $t8, ($v0) -/* 09BE40 8009B240 AC590004 */ sw $t9, 4($v0) -/* 09BE44 8009B244 8C820000 */ lw $v0, ($a0) -/* 09BE48 8009B248 3C0BFA00 */ lui $t3, 0xfa00 -/* 09BE4C 8009B24C 244C0008 */ addiu $t4, $v0, 8 -/* 09BE50 8009B250 AC8C0000 */ sw $t4, ($a0) -/* 09BE54 8009B254 314D00FF */ andi $t5, $t2, 0xff -/* 09BE58 8009B258 AC4D0004 */ sw $t5, 4($v0) -/* 09BE5C 8009B25C AC4B0000 */ sw $t3, ($v0) -/* 09BE60 8009B260 8C820000 */ lw $v0, ($a0) -/* 09BE64 8009B264 3C18FFFD */ lui $t8, (0xFFFDF6FB >> 16) # lui $t8, 0xfffd -/* 09BE68 8009B268 244E0008 */ addiu $t6, $v0, 8 -/* 09BE6C 8009B26C AC8E0000 */ sw $t6, ($a0) -/* 09BE70 8009B270 3C0FFCFF */ lui $t7, (0xFCFFFFFF >> 16) # lui $t7, 0xfcff -/* 09BE74 8009B274 35EFFFFF */ ori $t7, (0xFCFFFFFF & 0xFFFF) # ori $t7, $t7, 0xffff -/* 09BE78 8009B278 3718F6FB */ ori $t8, (0xFFFDF6FB & 0xFFFF) # ori $t8, $t8, 0xf6fb -/* 09BE7C 8009B27C AC580004 */ sw $t8, 4($v0) -/* 09BE80 8009B280 AC4F0000 */ sw $t7, ($v0) -/* 09BE84 8009B284 8FAC0018 */ lw $t4, 0x18($sp) -/* 09BE88 8009B288 8FAD0020 */ lw $t5, 0x20($sp) -/* 09BE8C 8009B28C 8C820000 */ lw $v0, ($a0) -/* 09BE90 8009B290 018D7021 */ addu $t6, $t4, $t5 -/* 09BE94 8009B294 8FAD0024 */ lw $t5, 0x24($sp) -/* 09BE98 8009B298 8FAC001C */ lw $t4, 0x1c($sp) -/* 09BE9C 8009B29C 31CF03FF */ andi $t7, $t6, 0x3ff -/* 09BEA0 8009B2A0 000FC380 */ sll $t8, $t7, 0xe -/* 09BEA4 8009B2A4 24590008 */ addiu $t9, $v0, 8 -/* 09BEA8 8009B2A8 AC990000 */ sw $t9, ($a0) -/* 09BEAC 8009B2AC 3C01F600 */ lui $at, 0xf600 -/* 09BEB0 8009B2B0 018D7021 */ addu $t6, $t4, $t5 -/* 09BEB4 8009B2B4 31CF03FF */ andi $t7, $t6, 0x3ff -/* 09BEB8 8009B2B8 0301C825 */ or $t9, $t8, $at -/* 09BEBC 8009B2BC 000FC080 */ sll $t8, $t7, 2 -/* 09BEC0 8009B2C0 03386025 */ or $t4, $t9, $t8 -/* 09BEC4 8009B2C4 AC4C0000 */ sw $t4, ($v0) -/* 09BEC8 8009B2C8 8FB9001C */ lw $t9, 0x1c($sp) -/* 09BECC 8009B2CC 8FAD0018 */ lw $t5, 0x18($sp) -/* 09BED0 8009B2D0 333803FF */ andi $t8, $t9, 0x3ff -/* 09BED4 8009B2D4 31AE03FF */ andi $t6, $t5, 0x3ff -/* 09BED8 8009B2D8 000E7B80 */ sll $t7, $t6, 0xe -/* 09BEDC 8009B2DC 00186080 */ sll $t4, $t8, 2 -/* 09BEE0 8009B2E0 01EC6825 */ or $t5, $t7, $t4 -/* 09BEE4 8009B2E4 AC4D0004 */ sw $t5, 4($v0) -/* 09BEE8 8009B2E8 8C820000 */ lw $v0, ($a0) -/* 09BEEC 8009B2EC 3C19E700 */ lui $t9, 0xe700 -/* 09BEF0 8009B2F0 244E0008 */ addiu $t6, $v0, 8 -/* 09BEF4 8009B2F4 AC8E0000 */ sw $t6, ($a0) -/* 09BEF8 8009B2F8 AC400004 */ sw $zero, 4($v0) -/* 09BEFC 8009B2FC AC590000 */ sw $t9, ($v0) -/* 09BF00 8009B300 8C820000 */ lw $v0, ($a0) -/* 09BF04 8009B304 240FFFFF */ li $t7, -1 -/* 09BF08 8009B308 24580008 */ addiu $t8, $v0, 8 -/* 09BF0C 8009B30C AC980000 */ sw $t8, ($a0) -/* 09BF10 8009B310 AC4F0004 */ sw $t7, 4($v0) -/* 09BF14 8009B314 0C01ECF4 */ jal func_8007B3D0 -/* 09BF18 8009B318 AC4B0000 */ sw $t3, ($v0) -/* 09BF1C 8009B31C 8FBF0014 */ lw $ra, 0x14($sp) -/* 09BF20 8009B320 27BD0018 */ addiu $sp, $sp, 0x18 -/* 09BF24 8009B324 03E00008 */ jr $ra -/* 09BF28 8009B328 00000000 */ nop - diff --git a/asm/non_matchings/menu/menu_audio_options_loop.s b/asm/non_matchings/menu/menu_audio_options_loop.s index fc60e7fe..72ee4808 100644 --- a/asm/non_matchings/menu/menu_audio_options_loop.s +++ b/asm/non_matchings/menu/menu_audio_options_loop.s @@ -218,7 +218,7 @@ glabel menu_audio_options_loop /* 085B84 80084F84 24020100 */ li $v0, 256 /* 085B88 80084F88 AC620000 */ sw $v0, ($v1) .L80084F8C: -/* 085B8C 80084F8C 0C000C58 */ jal sfxSetVolumeSlider +/* 085B8C 80084F8C 0C000C58 */ jal set_sfx_volume_slider /* 085B90 80084F90 00402025 */ move $a0, $v0 /* 085B94 80084F94 1000005A */ b .L80085100 /* 085B98 80084F98 00000000 */ nop @@ -242,9 +242,9 @@ glabel menu_audio_options_loop /* 085BD8 80084FD8 24020100 */ li $v0, 256 /* 085BDC 80084FDC AC620000 */ sw $v0, ($v1) .L80084FE0: -/* 085BE0 80084FE0 0C00068F */ jal musicSetVolSlider +/* 085BE0 80084FE0 0C00068F */ jal set_music_volume_slider /* 085BE4 80084FE4 00402025 */ move $a0, $v0 -/* 085BE8 80084FE8 0C000572 */ jal musicIsPlaying +/* 085BE8 80084FE8 0C000572 */ jal music_is_playing /* 085BEC 80084FEC 00000000 */ nop /* 085BF0 80084FF0 14400043 */ bnez $v0, .L80085100 /* 085BF4 80084FF4 3C0D8012 */ lui $t5, %hi(D_801263D8) # $t5, 0x8012 diff --git a/asm/non_matchings/menu/menu_magic_codes_loop.s b/asm/non_matchings/menu/menu_magic_codes_loop.s index 72ec7a8e..eac09303 100644 --- a/asm/non_matchings/menu/menu_magic_codes_loop.s +++ b/asm/non_matchings/menu/menu_magic_codes_loop.s @@ -48,7 +48,7 @@ glabel menu_magic_codes_loop /* 08A980 80089D80 28410014 */ slti $at, $v0, 0x14 /* 08A984 80089D84 10200006 */ beqz $at, .L80089DA0 /* 08A988 80089D88 00000000 */ nop -/* 08A98C 80089D8C 0C0225A9 */ jal func_800896A4 +/* 08A98C 80089D8C 0C0225A9 */ jal render_magic_codes_ui /* 08A990 80089D90 AFA70044 */ sw $a3, 0x44($sp) /* 08A994 80089D94 3C0B8012 */ lui $t3, %hi(D_801263D8) # $t3, 0x8012 /* 08A998 80089D98 8FA70044 */ lw $a3, 0x44($sp) diff --git a/asm/non_matchings/menu/menu_track_select_loop.s b/asm/non_matchings/menu/menu_track_select_loop.s index cd17591f..318b57ee 100644 --- a/asm/non_matchings/menu/menu_track_select_loop.s +++ b/asm/non_matchings/menu/menu_track_select_loop.s @@ -69,7 +69,7 @@ glabel menu_track_select_loop /* 08FF30 8008F330 0C0243B6 */ jal func_80090ED8 /* 08FF34 8008F334 00000000 */ nop /* 08FF38 8008F338 8FA40020 */ lw $a0, 0x20($sp) -/* 08FF3C 8008F33C 0C0243CC */ jal func_80090F30 +/* 08FF3C 8008F33C 0C0243CC */ jal render_track_select_setup_ui /* 08FF40 8008F340 00000000 */ nop /* 08FF44 8008F344 8FA40020 */ lw $a0, 0x20($sp) /* 08FF48 8008F348 0C024862 */ jal func_80092188 diff --git a/asm/non_matchings/menu/func_800896A4.s b/asm/non_matchings/menu/render_magic_codes_ui.s similarity index 99% rename from asm/non_matchings/menu/func_800896A4.s rename to asm/non_matchings/menu/render_magic_codes_ui.s index 85e94cef..99170f97 100644 --- a/asm/non_matchings/menu/func_800896A4.s +++ b/asm/non_matchings/menu/render_magic_codes_ui.s @@ -1,4 +1,4 @@ -glabel func_800896A4 +glabel render_magic_codes_ui /* 08A2A4 800896A4 27BDFF80 */ addiu $sp, $sp, -0x80 /* 08A2A8 800896A8 AFBF0044 */ sw $ra, 0x44($sp) /* 08A2AC 800896AC AFA40080 */ sw $a0, 0x80($sp) @@ -410,7 +410,7 @@ glabel func_800896A4 /* 08A894 80089C94 000268C0 */ sll $t5, $v0, 3 /* 08A898 80089C98 05A10004 */ bgez $t5, .L80089CAC /* 08A89C 80089C9C 8FBF0044 */ lw $ra, 0x44($sp) -/* 08A8A0 80089CA0 0C022B51 */ jal func_8008AD44 +/* 08A8A0 80089CA0 0C022B51 */ jal calculate_and_display_rom_checksum /* 08A8A4 80089CA4 00000000 */ nop /* 08A8A8 80089CA8 8FBF0044 */ lw $ra, 0x44($sp) .L80089CAC: diff --git a/asm/non_matchings/menu/func_80090F30.s b/asm/non_matchings/menu/render_track_select_setup_ui.s similarity index 99% rename from asm/non_matchings/menu/func_80090F30.s rename to asm/non_matchings/menu/render_track_select_setup_ui.s index 1efa1b8a..ad77263b 100644 --- a/asm/non_matchings/menu/func_80090F30.s +++ b/asm/non_matchings/menu/render_track_select_setup_ui.s @@ -3,7 +3,7 @@ glabel D_800E84F0 .float 1.2 .text -glabel func_80090F30 +glabel render_track_select_setup_ui /* 091B30 80090F30 27BDFF68 */ addiu $sp, $sp, -0x98 /* 091B34 80090F34 AFBF0054 */ sw $ra, 0x54($sp) /* 091B38 80090F38 AFBE0050 */ sw $fp, 0x50($sp) diff --git a/asm/non_matchings/unknown_09F8F0/func_800A277C.s b/asm/non_matchings/unknown_09F8F0/func_800A277C.s index f48d6b0a..94521038 100644 --- a/asm/non_matchings/unknown_09F8F0/func_800A277C.s +++ b/asm/non_matchings/unknown_09F8F0/func_800A277C.s @@ -125,7 +125,7 @@ glabel func_800A277C /* 0A34EC 800A28EC 8FA900A8 */ lw $t1, 0xa8($sp) /* 0A34F0 800A28F0 14400006 */ bnez $v0, .L800A290C /* 0A34F4 800A28F4 240E0010 */ li $t6, 16 -/* 0A34F8 800A28F8 0C000572 */ jal musicIsPlaying +/* 0A34F8 800A28F8 0C000572 */ jal music_is_playing /* 0A34FC 800A28FC AFA900A8 */ sw $t1, 0xa8($sp) /* 0A3500 800A2900 8FA900A8 */ lw $t1, 0xa8($sp) /* 0A3504 800A2904 14400003 */ bnez $v0, .L800A2914 diff --git a/src/audio.c b/src/audio.c index e8a1e811..51d38e10 100644 --- a/src/audio.c +++ b/src/audio.c @@ -561,7 +561,7 @@ s16 musicGetTempo(void) { return D_80115D30; } -u8 musicIsPlaying(void) { +u8 music_is_playing(void) { return (alCSPGetState(gMusicPlayer) == AL_PLAYING); } @@ -687,7 +687,7 @@ void set_relative_volume_for_music(u8 vol){ alCSPSetVol(gMusicPlayer, (s16)((s32)(D_800DC66C*normalized_vol)>>8)); } -void musicSetVolSlider(u32 slider_val){ +void set_music_volume_slider(u32 slider_val){ f32 normalized_vol; slider_val = (slider_val < 0x101)?slider_val:256; diff --git a/src/menu.c b/src/menu.c index 2d195cc4..d7ec758b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -147,10 +147,7 @@ s32 D_801267E8; s8* D_801267EC; s32 D_801267F0[5]; s32 D_80126804; -s32 D_80126808; -s32 D_8012680C; -s32 D_80126810; -s32 D_80126814; +s32 D_80126808[4]; s32 D_80126818; s32 D_8012681C; s32 D_80126820; @@ -188,7 +185,7 @@ s32 D_80126928; s32 D_8012692C; s32 D_80126930[36]; s8 gPlayerSelectVehicle[4]; // Unknown number of entries. -s32 D_801269C4; +u8 D_801269C4[4]; s32 D_801269C8; s32 D_801269CC; s32 gAudioOutputStrings[3]; @@ -200,7 +197,7 @@ s32 D_801269EC; s32 D_801269F0; s32 D_801269F4; s32 D_801269F8; -s32 D_801269FC; +s32 *D_801269FC; s32 D_80126A00; s32 D_80126A04; s32 D_80126A08; @@ -253,7 +250,7 @@ s32 D_80126BF0[8]; s32 D_80126C10; s32 D_80126C14; s32 D_80126C18; -s32 D_80126C1C; +char **D_80126C1C; s32 D_80126C20; s32 D_80126C24; s32 D_80126C28; @@ -551,7 +548,7 @@ s32 gShowControllerPakMenu = FALSE; s32 gActiveMagicCodes = 0; s32 gUnlockedMagicCodes = 0; -s32 gMagicCodeMenuStrings[5] = { 0, 0, 0, 0, 0 }; +char *gMagicCodeMenuStrings[5] = { 0, 0, 0, 0, 0 }; u8 D_800DFDB4[10][2] = { { 0x0F, 0x64 }, @@ -779,14 +776,14 @@ s16 D_800E06D4[8] = { 0x0000, 0x004A, 0xFFAB, 0x0000 }; -u16 D_800E06E4[14] = { +s16 D_800E06E4[14] = { 0x50, 0x8C, 0xA0, 0x40, 0x04, 0x04, 0x50, 0x14, 0x3A, 0x28, 0x50, 0x28, 0x66, 0x28 }; -u16 D_800E0700[8] = { +s16 D_800E0700[8] = { 0x50, 0x98, 0xA0, 0x28, 0x04, 0x04, 0x50, 0x0E }; @@ -913,15 +910,14 @@ s16 D_800E09A0[8] = { 0x0000, 0xFF60, 0x0000, 0xFF80 }; -// Not sure about typing with these. -s32 D_800E09B0[5] = { 0, 0, 0, 0, 0 }; -s32 D_800E09C4[5] = { 0, 0, 0, 0, 0 }; -s32 D_800E09D8[5] = { 0, 0, 0, 0, 0 }; -s32 D_800E09EC[3] = { 0, 0, 0 }; -s32 D_800E09F8[3] = { 0, 0, 0 }; -s32 D_800E0A04[3] = { 0, 0, 0 }; -s32 D_800E0A10 = 0; -s32 D_800E0A14[4] = { 0, 0, 0, 0 }; +char *D_800E09B0[5] = { 0, 0, 0, 0, 0 }; +char *D_800E09C4[5] = { 0, 0, 0, 0, 0 }; +char *D_800E09D8[5] = { 0, 0, 0, 0, 0 }; +char *D_800E09EC[3] = { 0, 0, 0 }; +char *D_800E09F8[3] = { 0, 0, 0 }; +char *D_800E0A04[3] = { 0, 0, 0 }; +s16 D_800E0A10 = 0; +char *D_800E0A14[4] = { 0, 0, 0, 0 }; s16 D_800E0A24[14] = { 0x0005, 0x003B, 0x0032, 0x0033, @@ -1554,10 +1550,38 @@ void load_level_for_menu(s32, s32, s32); void func_8008CACC(void); void reset_character_id_slots(void); void func_80000FDC(s32, s32, f32); +void decompress_filename_string(u32 compressedFilename, char *output, s32 length); +void calculate_and_display_rom_checksum(void); +void func_800851FC(void); +void set_music_volume_slider(s32); +s32 music_is_playing(void); + +void reset_controller_sticks(void); +void menu_logos_screen_init(void); +void menu_title_screen_init(void); +void menu_options_init(void); +void menu_audio_options_init(void); +void menu_save_options_init(void); +void menu_magic_codes_init(void); +void menu_magic_codes_list_init(void); +void menu_character_select_init(void); +void menu_game_select_init(void); +void menu_file_select_init(void); +void menu_track_select_init(void); +void menu_5_init(void); +void menu_11_init(void); +void menu_trophy_race_round_init(void); +void menu_trophy_race_rankings_init(void); +void menu_23_init(void); +void menu_ghost_data_init(void); +void menu_credits_init(void); +void menu_boot_init(void); +void menu_caution_init(void); +void func_80001844(void); #ifdef NON_MATCHING -// Should be functionally equivalent? +// Should be functionally equivalent void load_menu_text(s32 language) { s32 start, langIndex, i, j; @@ -1741,41 +1765,22 @@ void func_800813C0(void) { D_800DF458 = 1; } -#ifdef NON_MATCHING -void reset_controller_sticks(void); -void menu_logos_screen_init(void); -void menu_title_screen_init(void); -void menu_options_init(void); -void menu_audio_options_init(void); -void menu_save_options_init(void); -void menu_magic_codes_init(void); -void menu_magic_codes_list_init(void); -void menu_character_select_init(void); -void menu_game_select_init(void); -void menu_file_select_init(void); -void menu_track_select_init(void); -void menu_5_init(void); -void menu_11_init(void); -void menu_trophy_race_round_init(void); -void menu_trophy_race_rankings_init(void); -void menu_23_init(void); -void menu_ghost_data_init(void); -void menu_credits_init(void); -void menu_boot_init(void); -void menu_caution_init(void); - -// Almost close to matching. void menu_init(u32 menuId) { + s32 i; + gCurrentMenuId = menuId; reset_controller_sticks(); gIgnorePlayerInput = 1; D_801263BC = 0; D_801263C8 = 0; D_80126828 = 0; - D_80126808 = 0; - D_8012680C = 0; // This creates an extra lui - D_80126810 = 0; - D_80126814 = 0; // This creates an extra lui + + // Does not match with a for loop + i = 0; + while(i < 4) { + D_80126808[i++] = 0; + } + func_80001844(); switch(gCurrentMenuId) { case MENU_LOGOS: @@ -1841,9 +1846,6 @@ void menu_init(u32 menuId) { } D_80126470 = 0xD000; } -#else -GLOBAL_ASM("asm/non_matchings/menu/menu_init.s") -#endif /** * Runs every frame. Calls the loop function of the current menu id @@ -2207,13 +2209,12 @@ void func_800841B8(s32 arg0) { } } -#if 1 -GLOBAL_ASM("asm/non_matchings/menu/menu_options_loop.s") -#else +#ifdef NON_MATCHING void func_80084734(void); void set_language(s32 language); +// Should be functionally equivalent s32 menu_options_loop(s32 arg0) { s32 buttonsPressed; s32 analogX; @@ -2246,7 +2247,7 @@ s32 menu_options_loop(s32 arg0) { } } - if ((buttonsPressed & 0x4000) || ((buttonsPressed & 0x9000) && D_800DF460 == 5)) { + if ((buttonsPressed & B_BUTTON) || ((buttonsPressed & (A_BUTTON | START_BUTTON)) && D_800DF460 == 5)) { // Leave the option menu func_80000C98(-0x80, D_800DF460, analogX); gMenuDelay = -1; @@ -2267,7 +2268,7 @@ s32 menu_options_loop(s32 arg0) { func_80001D04(0xEB, 0); } else if (D_800DF460 == 1 && analogX != 0) { // Enable/Disable subtitles. - if (D_80126448+4 & 0x2000000) { + if (D_80126448 & 0x2000000) { func_80001D04(0xEB, 0); func_8009EABC(0, 0x2000000); func_800C2AF4(0); @@ -2325,6 +2326,8 @@ s32 menu_options_loop(s32 arg0) { gIgnorePlayerInput = 0; return 0; } +#else +GLOBAL_ASM("asm/non_matchings/menu/menu_options_loop.s") #endif @@ -2338,7 +2341,7 @@ void menu_audio_options_init(void) { gOptionsMenuItemIndex = 0; D_801263BC = 0; gMenuDelay = 0; - D_801269FC = 0; + D_801269FC = NULL; D_801263D8 = -1; func_8009C674(D_800DFA2C); func_8009C8A4(&D_800DFA2C[6]); @@ -2362,22 +2365,16 @@ void menu_audio_options_init(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80084854.s") -#if 1 -GLOBAL_ASM("asm/non_matchings/menu/menu_audio_options_loop.s") -#else - -extern s32 D_800DFABC; -extern s32 D_800DFAC8; - -void func_800851FC(void); +#ifdef NON_MATCHING +// Almost matching, should be functionally equivalent s32 menu_audio_options_loop(s32 arg0) { - s32 sp40; + s32 buttonInputs; s32 sp30; s32 phi_a2; - s32 phi_a3; - s32 phi_t0; - s32 phi_s0; + s32 contY; + s32 contX; + s32 i; sp30 = 0; D_801263BC = (s32) ((D_801263BC + arg0) & 0x3F); @@ -2392,18 +2389,17 @@ s32 menu_audio_options_loop(s32 arg0) { func_80084854(); } if (gIgnorePlayerInput == 0 && gMenuDelay == 0) { - sp40 = 0; + buttonInputs = 0; + contX = 0; + contY = 0; phi_a2 = 0; - phi_a3 = 0; - phi_t0 = 0; - phi_s0 = 0; - while(phi_s0 != 4) { - sp40 |= get_buttons_pressed_from_player(phi_s0); - phi_a2 += func_8006A59C(phi_s0); - phi_a3 += gControllersYAxisDirection[phi_s0]; - phi_t0 += gControllersXAxisDirection[phi_s0]; - phi_s0++; + // Check all 4 controllers for inputs + for(i = 0; i < 4; i++) { + buttonInputs |= get_buttons_pressed_from_player(i); + phi_a2 += func_8006A59C(i); + contY += gControllersYAxisDirection[i]; + contX += gControllersXAxisDirection[i]; } if (phi_a2 < 0) { @@ -2418,21 +2414,21 @@ s32 menu_audio_options_loop(s32 arg0) { } } - if (((sp40 & 0x9000) && (D_801263E0 == gOptionsMenuItemIndex + 1)) || (sp40 & 0x4000)) { + if (((buttonInputs & (A_BUTTON | START_BUTTON)) && (D_801263E0 == gOptionsMenuItemIndex + 1)) || (buttonInputs & B_BUTTON)) { gMenuDelay = -1; func_800C01D8(&D_800DF774); if (D_801263D8 >= 0) { func_80000C98(-0x80); } sp30 = 3; - } else if (phi_a3 < 0 && gOptionsMenuItemIndex < D_801263E0 - 1) { + } else if (contY < 0 && gOptionsMenuItemIndex < D_801263E0 - 1) { gOptionsMenuItemIndex++; sp30 = 1; - } else if (phi_a3 > 0 && gOptionsMenuItemIndex > 0) { + } else if (contY > 0 && gOptionsMenuItemIndex > 0) { gOptionsMenuItemIndex--; sp30 = 1; - } else if (gOptionsMenuItemIndex == 0 && phi_t0 != 0) { - if (phi_t0 < 0) { + } else if (gOptionsMenuItemIndex == 0 && contX != 0) { + if (contX < 0) { D_800DFAC8--; } else { D_800DFAC8++; @@ -2445,16 +2441,16 @@ s32 menu_audio_options_loop(s32 arg0) { } set_stereo_pan_mode(D_800DFAC8); sp30 = 1; - } else if ((phi_a2 >> 2) != 0) { - if(gOptionsMenuItemIndex == 2) { + } else if (((phi_a2 >> 2) != 0) && ((gOptionsMenuItemIndex == 1) || (gOptionsMenuItemIndex == 2))) { + if(gOptionsMenuItemIndex == 1) { gSfxVolumeSliderValue += (phi_a2 >> 2); if (gSfxVolumeSliderValue < 0) { gSfxVolumeSliderValue = 0; } else if (gSfxVolumeSliderValue >= 0x101) { gSfxVolumeSliderValue = 0x100; } - sfxSetVolumeSlider(gSfxVolumeSliderValue); - } else if(gOptionsMenuItemIndex == 1) { + set_sfx_volume_slider(gSfxVolumeSliderValue); + } else if(gOptionsMenuItemIndex == 2) { gMusicVolumeSliderValue += (phi_a2 >> 2); if (gMusicVolumeSliderValue < 0) { gMusicVolumeSliderValue = 0; @@ -2463,8 +2459,8 @@ s32 menu_audio_options_loop(s32 arg0) { gMusicVolumeSliderValue = 0x100; } } - func_80001A3C(gMusicVolumeSliderValue); - if (!musicIsPlaying()) { + set_music_volume_slider(gMusicVolumeSliderValue); + if (!music_is_playing()) { if (D_801263D8 >= 0) { func_80000B28(); play_music((u8)D_800DFABC); @@ -2476,15 +2472,15 @@ s32 menu_audio_options_loop(s32 arg0) { } } } - } else if (D_801263E0 >= 5 && gOptionsMenuItemIndex == 1) { - if (phi_t0 < 0 && D_800DFABC > 0) { + } else if (D_801263E0 >= 5 && gOptionsMenuItemIndex == 3) { + if (contX < 0 && D_800DFABC > 0) { D_800DFABC--; sp30 = 1; - } else if (phi_t0 > 0 && D_800DFABC < (ALSeqFile_80115CF8_GetSeqCount() - 1)) { + } else if (contX > 0 && D_800DFABC < (ALSeqFile_80115CF8_GetSeqCount() - 1)) { D_800DFABC++; sp30 = 1; } - if (sp40 & 0x9000) { + if (buttonInputs & (A_BUTTON | START_BUTTON)) { func_80000B28(); func_80000BE0(0x18); play_music((u8)D_800DFABC); @@ -2492,18 +2488,18 @@ s32 menu_audio_options_loop(s32 arg0) { } } - if (gOptionsMenuItemIndex == 1 && D_801269FC == 0) { + if (gOptionsMenuItemIndex == 1 && D_801269FC == NULL) { func_80001D04(0x19B, &D_801269FC); - } else if (D_801269FC != 0) { - func_8000488C(D_801269FC); + } else if (D_801269FC != NULL) { + func_8000488C(&D_801269FC); } if (sp30 == 3) { - func_80001D04(0x241, 0); + func_80001D04(0x241, NULL); } else if (sp30 == 2) { - func_80001D04(0xEF, 0); + func_80001D04(0xEF, NULL); } else if (sp30 == 1) { - func_80001D04(0xEB, 0); + func_80001D04(0xEB, NULL); } } if (gMenuDelay < -0x1E) { @@ -2514,11 +2510,12 @@ s32 menu_audio_options_loop(s32 arg0) { gIgnorePlayerInput = 0; return 0; } - +#else +GLOBAL_ASM("asm/non_matchings/menu/menu_audio_options_loop.s") #endif void func_800851FC(void) { - if (D_801269FC != 0) { + if (D_801269FC != NULL) { func_8000488C(D_801269FC); } if (D_801263D8 >= 0) { @@ -2893,7 +2890,131 @@ void menu_magic_codes_init(void) { func_800C4170(2); } -GLOBAL_ASM("asm/non_matchings/menu/func_800896A4.s") +#ifdef NON_MATCHING + +// Close to matching, but should be functionally equivalent. +void render_magic_codes_ui(s32 arg0) { + s32 xPos, yPos; + s32 yIncr; + s32 i, j; + s32 temp, alpha, green; + char c; + + set_text_background_color(0, 0, 0, 0); + func_800C5B58(&D_801263A0, 0, 0, 7); + set_text_font(2); + set_text_color(0, 0, 0, 0xFF, 0x80); + draw_text(&D_801263A0, 0xA1, 0x23, gMenuText[17], 0xC); // gMenuText[17] = "MAGIC CODES" + set_text_color(0xFF, 0xFF, 0xFF, NULL, 0xFF); + draw_text(&D_801263A0, 0xA0, 0x20, gMenuText[17], 0xC); // gMenuText[17] = "MAGIC CODES" + set_text_font(0); + set_text_color(0xFF, 0xFF, 0xFF, NULL, 0xFF); + + c = 'A'; + yPos = 60; + // Draw the input table + for(i = 0; i < 4; i++) { + for(j = 0; j < 7; j++) { + xPos = 64 + (j * 32); + if (gOptionsMenuItemIndex == 5 && j == gCheatInputCurrentColumn && i == gCheatInputCurrentRow) { + temp = D_801263BC * 8; + if (temp >= 0x100) { + temp = 0x1FF - temp; + } + set_text_color(0x80, 0xFF, 0xC0, (temp >> 1) + 0x80, 0xFF); + } + if (c < '[') { + draw_text(&D_801263A0, xPos, yPos, &c, 0xC); // Draw the character + } else if (j == 5) { + draw_text(&D_801263A0, xPos, yPos, &D_800E8210, 0xC); // D_800E8210 = "DEL" + } else { + draw_text(&D_801263A0, xPos, yPos, &D_800E8214, 0xC); // D_800E8214 = "OK" + } + if ((5 == gOptionsMenuItemIndex) && (j == gCheatInputCurrentColumn) && (i == gCheatInputCurrentRow)) { + set_text_color(0xFF, 0xFF, 0xFF, 0, 0xFF); + } + c++; + c &= 0xFF; + } + yPos += 0x16; + } + + temp = D_801263BC * 8; + if (temp >= 0x100) { + temp = 0x1FF - temp; + } + + set_text_font(0); + yPos = 0xA4; + yIncr = 16; + if (osTvType == TV_TYPE_PAL) { + yIncr = 24; + } + + for(i = 0; gMagicCodeMenuStrings[i] != NULL; i++) { + alpha = 0; + if (i == gOptionsMenuItemIndex && D_801263E0 == 0) { + alpha = temp; + } + set_text_color(0xFF, 0xFF, 0xFF, alpha, 0xFF); + draw_text(&D_801263A0, -0x8000, yPos, gMagicCodeMenuStrings[i], 0xC); + yPos += yIncr; + } + set_text_font(0); + set_text_color(0xFF, 0xFF, 0x80, 0x80, 0xFF); + set_text_background_color(0, 0, 0x80, 0x80); + if (gOptionsMenuItemIndex == 4) { + if (D_80126C4C == -1) { + draw_text(&D_801263A0, -0x8000, 0x90, gMenuText[18], 0xC); // gMenuText[18] = "Sorry, the code was incorrect" + } else { + // Draw cheat code name. + draw_text(&D_801263A0, -0x8000, 0x90, (char*)(*gCheatsAssetData) + (*gCheatsAssetData + 1)[D_80126C4C + 1], 0xC); + } + } else if (5 == gOptionsMenuItemIndex) { + draw_text(&D_801263A0, -0x8000, 0x90, D_80126C58, 0xC); + } else if (gOptionsMenuItemIndex == 6) { + draw_text(&D_801263A0, -0x8000, 0x90, gMenuText[19], 0xC); // gMenuText[19] = "All cheats have been deleted" + } + if (D_801263E0 != 0) { + yPos = 0x78; + if (osTvType == TV_TYPE_PAL) { + yPos = 0x86; + } + func_800C5494(6); + func_800C4F7C(6, 0); + func_800C4EDC(6, 0x4C, yPos - 0x1C, 0xF4, yPos + 0x1C); + func_800C4FBC(6, 0, 0, 0, 0xA0); + yPos = 4; + for(i = 0; i < 3; i++) { + alpha = 0; + green = 0xFF; + if (i == 0) { + alpha = 64; + green = 0; + } else if (i == D_801263E0) { + alpha = temp; + } + func_800C5000(6, 0xFF, green, 0xFF, alpha, 0xFF); + + // gMenuText[148] = "CLEAR ALL CODES?", [149] = "OK", [150] = "CANCEL" + func_800C5168(6, -0x8000, yPos, gMenuText[148 + i], 1, 4); + + if (i != 0) { + yPos += 0x10; + } else { + yPos += 0x14; + } + } + func_800C5B58(&D_801263A0, 0, 0, 6); + } + if ((get_filtered_cheats() << 3) < 0) { + calculate_and_display_rom_checksum(); + } +} +#else +GLOBAL_ASM("asm/non_matchings/menu/render_magic_codes_ui.s") +#endif + GLOBAL_ASM("asm/non_matchings/menu/menu_magic_codes_loop.s") void func_8008A4C8(void) { @@ -3056,7 +3177,47 @@ void func_8008AD1C(void) { func_800C422C(2); } -GLOBAL_ASM("asm/non_matchings/menu/func_8008AD44.s") +#ifdef NON_MATCHING + +extern u8 *__ROM_END; + +void calculate_and_display_rom_checksum(void) { + s32 romOffset, numBytes, numBytesLeft; + s32 i; + u8 *tempBuffer; + if (!D_800E1E18) { + numBytesLeft = &__ROM_END; + numBytesLeft -= 0x1000; + romOffset = 0x1000; + tempBuffer = allocate_from_main_pool_safe(0x5000, COLOR_TAG_BLACK); + + while (numBytesLeft > 0) { + numBytes = numBytesLeft; + if (numBytesLeft >= 0x5001) { + numBytes = 0x5000; + } + dmacopy(romOffset, tempBuffer, numBytes); + numBytesLeft -= numBytes; + + for(i = 0; i < numBytes; i++) { + D_800E1E14 += tempBuffer[i]; + } + + romOffset += numBytes; + } + + free_from_memory_pool(tempBuffer); + D_800E1E18 = TRUE; + } + + set_render_printf_background_color(0, 0, 0, 0x80); + set_render_printf_position(0x20, 0x88); + render_printf(D_800E8218, D_800E1E14, &__ROM_END); // D_800E8218 = "ROM checksum %08X,%d\n" + +} +#else +GLOBAL_ASM("asm/non_matchings/menu/calculate_and_display_rom_checksum.s") +#endif void func_8008AEB4(s32 arg0, s32 *arg1) { switch(arg0) { @@ -3321,7 +3482,7 @@ void draw_menu_element(s32, MenuElement*, f32); s32 menu_caution_loop(s32 arg0) { if (gMenuDelay != 0) { gMenuDelay += arg0; - } else if (gIgnorePlayerInput <= 0 && get_buttons_pressed_from_player(0) & 0xD000) { + } else if (gIgnorePlayerInput <= 0 && (get_buttons_pressed_from_player(0) & (A_BUTTON | B_BUTTON | START_BUTTON))) { func_80001D04(0xEF, NULL); gMenuDelay = 1; func_800C01D8(&D_800DF774); @@ -3345,10 +3506,6 @@ void func_8008C4E8(void) { #ifdef NON_MATCHING -typedef struct unk80126460 { - MenuElement elem[2]; -} unk80126460; - void menu_game_select_init(void) { s32 i; @@ -3392,20 +3549,12 @@ void menu_game_select_init(void) { GLOBAL_ASM("asm/non_matchings/menu/menu_game_select_init.s") #endif -#if 1 -GLOBAL_ASM("asm/non_matchings/menu/func_8008C698.s") -#else -typedef struct unk80126460 { - MenuElement textShadow; - MenuElement text; -} unk80126460; - -extern unk80126460 *D_80126460[4]; - +#ifdef NON_MATCHING void func_8008C698(s32 arg0) { s32 fade; s32 i; s32 filterAlpha; + u8 temp; if (gMenuDelay >= -21 && gMenuDelay < 22) { fade = D_801263BC * 8; @@ -3420,7 +3569,9 @@ void func_8008C698(s32 arg0) { if (i == D_800DF460) { filterAlpha = fade; } - ((unk80126460*)(*D_80126460 + i + 1))->text.filterAlpha = filterAlpha; + // This doesn't match. + temp = i; // How do I make this a `mov`? + (&((unk80126460*)D_80126460)[temp] + 1)->elem[1].filterAlpha = filterAlpha; } if (osTvType == 0) { @@ -3431,10 +3582,12 @@ void func_8008C698(s32 arg0) { D_800DF7A0 = 0; } - draw_menu_element(1, (MenuElement*)*D_80126460, 1.0f); + draw_menu_element(1, (MenuElement*)D_80126460, 1.0f); func_80080BC8(&D_801263A0); } } +#else +GLOBAL_ASM("asm/non_matchings/menu/func_8008C698.s") #endif #ifdef NON_MATCHING @@ -3494,7 +3647,7 @@ s32 menu_game_select_loop(s32 arg0) { menu_init(MENU_CHARACTER_SELECT); return 0; } else { - func_8008C698(arg0, &D_801263D8); + func_8008C698(arg0); if ((gMenuDelay == 0) && (D_801263D8 == 0)) { playerInputs = get_buttons_pressed_from_player(0); playerYDir = gControllersYAxisDirection[0]; @@ -3637,9 +3790,9 @@ void render_file_select_menu(s32 arg0) { func_8008CC28(s2, D_800E03FC[2] + D_800E03CC[i].unk0, D_800E03FC[3] + D_800E03CC[i].unk2, 0, 0, 0, 0x80); func_80068508(1); D_800DF75C->unk18 = D_801264A0[i].unk2 / s5; - func_8008CC28(NULL, (D_800E03FC[6] + D_800E03CC[i].unk0) - 6, D_800E03FC[7] + D_800E03CC[i].unk2, 0, 0, 0, 0x80); + func_8008CC28(0, (D_800E03FC[6] + D_800E03CC[i].unk0) - 6, D_800E03FC[7] + D_800E03CC[i].unk2, 0, 0, 0, 0x80); D_800DF75C->unk18 = D_801264A0[i].unk2 % s5; - func_8008CC28(NULL, D_800E03FC[6] + D_800E03CC[i].unk0 + 6, D_800E03FC[7] + D_800E03CC[i].unk2, 0, 0, 0, 0x80); + func_8008CC28(0, D_800E03FC[6] + D_800E03CC[i].unk0 + 6, D_800E03FC[7] + D_800E03CC[i].unk2, 0, 0, 0, 0x80); func_80068508(0); D_800DF4A8 = 0x40; D_800DF4AC = 0x40; @@ -3858,7 +4011,7 @@ void func_8008FF1C(s32 arg0); void func_800904E8(s32 arg0); void func_80090918(s32 arg0); void func_80090ED8(s32 arg0); -void func_80090F30(s32 arg0); +void render_track_select_setup_ui(s32 arg0); void func_80092188(s32 arg0); void func_8008E4EC(void); s32 get_thread30_level_id_to_load(void); @@ -3890,7 +4043,7 @@ s32 menu_track_select_loop(s32 arg0) { break; case 1: func_80090ED8(arg0); - func_80090F30(arg0); + render_track_select_setup_ui(arg0); func_80092188(arg0); break; } @@ -3985,7 +4138,304 @@ void func_80090ED8(s32 arg0) { } } -GLOBAL_ASM("asm/non_matchings/menu/func_80090F30.s") +#ifdef NON_MATCHING + +// Somewhat close to matching, but should be functionally equivalent. +void render_track_select_setup_ui(s32 arg0) { + s32 sp84; + s32 sp80; + s32 sp7C; + char *sp78; + s32 sp74; + Settings *settings; // sp70 + s32 temp; + s32 i, j; + s32 s3; + s32 s4; + s32 s7; + + sp80 = 0; + sp78 = NULL; + sp74 = FALSE; + settings = get_settings(); + if (osTvType == TV_TYPE_PAL) { + sp80 = 12; + } + if ((gNumberOfActivePlayers == 2) && (D_801269C8 < 4) && (D_801263E0 >= 2)) { + sp74 = TRUE; + } + func_80066894(0, 1); + func_8009BD5C(); + func_80067F2C(&D_801263A0, &D_801263A8); + if (gMenuDelay < 0) { + if (D_801269F4 == 4) { + sp84 = 6; + } else if (D_801269F4 == 5) { + sp84 = 5; + } else { + sp84 = 4; + } + D_800DF75C[sp84].unkC = 0.0f; + D_800DF75C[sp84].unk10 = 0.0f; + if (osTvType == TV_TYPE_PAL) { + D_800DF454 = 1.2f; + } + func_8009CA60(sp84); + D_800DF454 = 1.0f; + } + if ((gMenuDelay >= -0x16) && (gMenuDelay < 0x1F)) { + if (gMenuDelay < 0) { + D_800DF764 = (gMenuDelay * 0x10) + 0xFF; + } else { + D_800DF764 = 0xFF; + } + if (D_800DF764 < 0) { + D_800DF764 = 0; + } + sp7C = func_8006B0F8(gTrackIdForPreview); + set_text_font(2); + set_text_color(0xC0, 0xC0, 0xFF, 0, D_800DF764); + set_text_background_color(0, 0, 0, 0); + draw_text(&D_801263A0, -0x8000, 0x2B, func_8006BDDC(gTrackIdForPreview), 0xC); // Draw track name? + sp84 = D_801263BC * 8; + if (sp84 >= 0x100) { + sp84 = 0x1FF - sp84; + } + func_800C4FBC(7, 0xFF, sp84, 0, D_800DF764); + if ((D_801263E0 == -1) || ((D_801263E0 == 2) && (D_801269C8 == 4) && is_adventure_two_unlocked())) { + s4 = func_800C4DA0(gMenuText[146], 0, 0); // gMenuText[146] = "ADVENTURE" + temp = func_800C4DA0(gMenuText[147], 0, 0); // gMenuText[147] = "ADVENTURE TWO" + if (s4 < temp) { + s4 = temp; + } + if (s4 < D_800E0700[2]) { + s4 = D_800E0700[2]; + } else { + s4 += 0xC; + } + func_80080580(&D_801263A0, -(s4 >> 1), 0x78 - D_800E0700[1], s4, D_800E0700[3], + D_800E0700[4], D_800E0700[5], D_800DF764 + 0xB0E0C000, D_8012665C); + func_80080E6C(); + set_text_font(0); + s7 = D_800E0700[7] + D_800E0700[1] + sp80; + s7++; + for(i = 0; i < 2; i++) { + for(j = 0; j < 4; j += 2) { + if (j == 0) { + set_text_color(0, 0, 0, 0xFF, D_800DF764 >> 1); + } else { + s32 alpha = i; + if (i == D_800E0418) { + alpha = sp84; + } + set_text_color(0xFF, 0xFF, 0xFF, alpha, D_800DF764); + } + // gMenuText[146] = "ADVENTURE", gMenuText[147] = "ADVENTURE TWO" + draw_text(&D_801263A0, 0xA1 - j, s7 - j, gMenuText[146 + i], 0xC); + } + s7 += 16; + } + } + if (D_801269C8 < 4) { + set_text_font(0); + set_text_color(0xFF, 0x40, 0x40, 0x60, D_800DF764); + draw_text(&D_801263A0, 0x38, 0x48 + sp80, gMenuText[9], 8); // gMenuText[9] = "BEST TIME" + draw_text(&D_801263A0, 0x38, 0x5C + sp80, gMenuText[10], 8); // gMenuText[10] = "BEST LAP" + set_text_color(0xFF, 0x80, 0xFF, 0x60, D_800DF764); + decompress_filename_string(settings->courseInitialsPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], &sp78, 3); + draw_text(&D_801263A0, 0xFA, 0x48 + sp80, &sp78, 0xC); + decompress_filename_string(settings->flapInitialsPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], &sp78, 3); + draw_text(&D_801263A0, 0xFA, 0x5C + sp80, &sp78, 0xC); + func_80081800(settings->courseTimesPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], 0x16, 0x35, 0x80, 0xFF, 0xFF, 0); + func_80081800(settings->flapTimesPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], 0x16, 0x21, 0xFF, 0xC0, 0xFF, 0); + if (D_801263E0 != -1) { + if (gNumberOfActivePlayers == 1) { + // Glow effect + func_800C4EDC(7, 0x86, sp80 + 0x70, 0xBA, sp80 + 0x89); + func_800C5B58(&D_801263A0, 0, 0, 7); + if (D_801263E0 <= 0) { + render_textured_rectangle(&D_801263A0, &D_800E05B4, 0x88, sp80 + 0x72, 0xFF, 0xFF, 0xFF, D_800DF764); + } else { + render_textured_rectangle(&D_801263A0, &D_800E05C4, 0x88, sp80 + 0x72, 0xFF, 0xFF, 0xFF, D_800DF764); + for(i = 0; i < 2; i++) { + s32 yTemp = 0x97 + sp80 + (i * 0x18); + if (i == D_800E0414) { + render_textured_rectangle(&D_801263A0, D_800E0648[(i * 3) + 1], 0x68, yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); + } else { + render_textured_rectangle(&D_801263A0, D_800E0648[(i * 3) + 2], 0x68, yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); + } + } + } + } else { + if (!sp74) { + s3 = (gNumberOfActivePlayers - 1) * gNumberOfActivePlayers; + for(i = 0; i < gNumberOfActivePlayers; i++) { + + if (((gNumberOfActivePlayers == 1) && (i == D_801263E0)) || ((gNumberOfActivePlayers >= 2) && (D_801269C4[i] == 0))) { + s32 temp_v0_9 = D_800E0688[s3 + (i*2)]; + s32 temp_v1 = D_800E0688[s3 + (i*2) + 1] + sp80; + // Glow effect around Player image + func_800C4EDC(7, temp_v0_9 - 2, temp_v1 - 2, temp_v0_9 + 0x32, temp_v1 + 0x17); + func_800C5B58(&D_801263A0, 0, 0, 7); + } + + // "Player" text image + render_textured_rectangle(&D_801263A0, D_800E0660[i], D_800E0688[s3 + (i*2)], D_800E0688[s3 + (i*2) + 1] + sp80, 0xFF, 0xFF, 0xFF, D_800DF764); + } + } + } + + if ((gNumberOfActivePlayers >= 2) || D_801263E0 == 0) { + // Draws "Car", "Hover", "Plane" text choice images. + if (sp74 == 0) { + s32 yTemp = 0x8B + sp80; + s3 = ((gNumberOfActivePlayers - 1) * gNumberOfActivePlayers) / 2; + for(i = 0; i < 3; i++) { + if ((1 << i) & sp7C) { + if (gNumberOfActivePlayers > 0) { + for (j = 0; j < gNumberOfActivePlayers; j++) { + if (i == gPlayerSelectVehicle[j]) { + // Highlighted + render_textured_rectangle(&D_801263A0, D_800E0624[(i*3) + 1], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); + } else if (settings->courseFlagsPtr[gTrackIdForPreview] & 2) { + // Not highlighted + render_textured_rectangle(&D_801263A0, D_800E0624[(i*3) + 2], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); + } else { + // Not available (Ghosted out) + render_textured_rectangle(&D_801263A0, D_800E0624[(i*3) + 2], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764 / 2); + } + } + } + yTemp += 0x18; + } + } + } + } + sp80 += 0x8B; + s7 = sp80; + if (gPlayerSelectVehicle[0] == 2) { + s7 = sp80 + 2; + } + if (gNumberOfActivePlayers == 1) { + if (D_801263E0 == 0) { + // Draw vehicle image for one player + render_textured_rectangle(&D_801263A0, D_800E0624[gPlayerSelectVehicle[0] * 3], 0x95, s7, 0xFF, 0xFF, 0xFF, D_800DF764); + } else { + // Draw T.T. image for one player + render_textured_rectangle(&D_801263A0, D_800E0648[D_800E0414 * 3], 0x95, sp80, 0xFF, 0xFF, 0xFF, D_800DF764); + } + } + if ((gNumberOfActivePlayers == 2) && (!sp74)) { + s7 = sp80; + // Draw vehicle image for first player + render_textured_rectangle(&D_801263A0, D_800E0624[gPlayerSelectVehicle[0] * 3], 0x4F, s7, 0xFF, 0xFF, 0xFF, D_800DF764); + if (gPlayerSelectVehicle[1] == 2) { + s7 = sp80 + 2; + } + // Draw vehicle image for second player + render_textured_rectangle(&D_801263A0, D_800E0624[gPlayerSelectVehicle[1] * 3], 0xB0, s7, 0xFF, 0xFF, 0xFF, D_800DF764); + } + + func_8007B3D0(&D_801263A0); + + if (gNumberOfActivePlayers < 3) { + // Draw border around vehicle images + if (!sp74) { + D_800DF75C[7].unk10 = -52.0f; + if (gNumberOfActivePlayers == 1) { + D_800DF75C[7].unkC = 21.0f; + func_8009CA60(7); + } else { + D_800DF75C[7].unkC = -48.0f; + func_8009CA60(7); + D_800DF75C[7].unkC = 48.0f; + func_8009CA60(7); + } + } + } + + if (sp74) { + s32 temp_v0_12 = func_800C4DA0(gMenuText[136], 0, 0); // gMenuText[136] = "NUMBER OF RACERS" + if ((D_800E06E4[2] - 0xC) < temp_v0_12) { + s4 = temp_v0_12 + 0xC; + } else { + s4 = D_800E06E4[2]; + } + func_80080580(&D_801263A0, -(s4 >> 1), 0x78 - D_800E06E4[1], s4, D_800E06E4[3], + D_800E06E4[4], D_800E06E4[5], 0xB0E0C0FF, D_8012665C); + func_80080E6C(); + set_text_font(0); + set_text_color(0, 0, 0, 0xFF, 0x80); + draw_text(&D_801263A0, D_800E06E4[6] + D_800E06E4[0] + 1, D_800E06E4[7] + D_800E06E4[1] + 1, gMenuText[136], 0xC); + set_text_color(0xFF, 0xFF, 0xFF, 0, 0xFF); + draw_text(&D_801263A0, D_800E06E4[6] + D_800E06E4[0] - 1, D_800E06E4[7] + D_800E06E4[1] - 1, gMenuText[136], 0xC); + // gMenuText[136] = "NUMBER OF RACERS" + func_80068508(1); + func_8007BF1C(0); + for(i = 0; i < 3; i++) { + s32 index = i * 2; + if (i == gMultiplayerSelectedNumberOfRacers) { + if (D_801263E0 < 3) { + D_800DF4A8 = 0xFF - sp84; + D_800DF4AC = 0xFF - sp84; + } else { + D_800DF4A8 = 0; + D_800DF4AC = 0; + } + } + // X position + D_800DF75C[0].unkC = (D_800E06E4[index + 8] + D_800E06E4[0]) - 0xA0; + // Y position + D_800DF75C[0].unk10 = (-D_800E06E4[index + 9] - D_800E06E4[1]) + 0x78; + // Number value to draw. + D_800DF75C[0].unk18 = index + 2; + func_8009CA60(0); + D_800DF4A8 = 0xFF; + D_800DF4AC = 0xFF; + } + func_8007BF1C(1); + func_80068508(0); + } + } + } + if (D_801269C8 < 4) { + func_8007BF1C(0); + i = 11; + if (gIsInAdventureTwo) { + i = 12; + } + D_800DF75C[i].unk10 = 42.0f; + if ((settings->courseFlagsPtr[gTrackIdForPreview] & 2) || is_adventure_two_unlocked()) { + D_800DF75C[i].unkC = -128.0f; + func_8009CA60(i); + } + if ((settings->courseFlagsPtr[gTrackIdForPreview] & 4) || is_adventure_two_unlocked()) { + D_800DF75C[i].unkC = 120.0f; + func_8009CA60(i); + } + func_8007BF1C(1); + } + if ((gNumberOfActivePlayers == 1) && (D_801263E0 >= 0) && (func_80092BE0(gTrackIdForPreview) >= 0)) { + // Render small T.T. icon. + render_textured_rectangle(&D_801263A0, &D_800E0614, 0xCC, 0x7A, 0xFF, 0xFF, 0xFF, D_800DF764); + func_8007B3D0(&D_801263A0); + } + if (D_801269C8 != 5) { + if (((D_801263E0 == 2) && !sp74) || ((D_801263E0 == 3) && sp74) || (D_801263E0 == 4)) { + set_text_font(2); + set_text_color(0xFF, 0xFF, 0xFF, 0, D_800DF764); + if (D_801269C8 >= 4) { + sp80 += 0x18; + } + draw_text(&D_801263A0, 0xA0, 0xAC, D_800E823C, 0xC); // D_800E823C = "OK?" + } + } + D_800DF764 = 0xFF; + } +} +#else +GLOBAL_ASM("asm/non_matchings/menu/render_track_select_setup_ui.s") +#endif GLOBAL_ASM("asm/non_matchings/menu/func_80092188.s") @@ -4259,7 +4709,41 @@ void func_80094C14(s32 arg0) { } GLOBAL_ASM("asm/non_matchings/menu/func_80094D28.s") + +#ifdef NON_MATCHING +void func_80095624(s32 arg0) { + switch (arg0 & 0xFF) { + case 1: + case 5: + // Two addiu instructions need to swap positions here! + D_80126C1C = D_800E09D8; + break; + case 4: + case 6: + // Two addiu instructions need to swap positions here! + D_80126C1C = D_800E09C4; + break; + case 7: + D_80126C1C = D_800E0A04; + break; + case 8: + D_80126C1C = D_800E0A14; + break; + case 9: + D_80126C1C = D_800E09EC; + break; + default: + D_80126C1C = D_800E09B0; + break; + } + + for(D_80126C24 = 0; D_80126C1C[D_80126C24] != 0; D_80126C24++) { + } +} +#else GLOBAL_ASM("asm/non_matchings/menu/func_80095624.s") +#endif + GLOBAL_ASM("asm/non_matchings/menu/func_80095728.s") void func_800981E8(void); @@ -4535,9 +5019,7 @@ void func_80098754(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80098774.s") GLOBAL_ASM("asm/non_matchings/menu/menu_trophy_race_rankings_init.s") -#if 1 -GLOBAL_ASM("asm/non_matchings/menu/func_80098EBC.s") -#else +#ifdef NON_MATCHING void func_80098EBC(s32 arg0) { s32 test; s32 fade; @@ -4558,15 +5040,17 @@ void func_80098EBC(s32 arg0) { fade = (test >> 1) + 0x80; } - D_800E1048+64[i][0].filterRed = fade; - D_800E1048+64[i][0].filterGreen = fade; - D_800E1048+64[i][0].filterBlue = fade; + D_800E1048[i][0].filterRed = fade; + D_800E1048[i][0].filterGreen = fade; + D_800E1048[i][0].filterBlue = fade; } if (D_801263E0 == 2 || D_801263E0 == 3) { draw_menu_element(1, &D_800E1048, 1.0f); } } +#else +GLOBAL_ASM("asm/non_matchings/menu/func_80098EBC.s") #endif GLOBAL_ASM("asm/non_matchings/menu/menu_trophy_race_rankings_loop.s") @@ -4701,7 +5185,24 @@ void menu_credits_init(void) { func_8006F564(1); } -GLOBAL_ASM("asm/non_matchings/menu/func_8009B1E4.s") +void func_8009B1E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + if (arg4 >= 0x100) { + arg4 = 0xFF; + } + if (arg4 < 0) { + arg4 = 0; + } + + gSPDisplayList(D_801263A0++, D_800E1780) + gDPSetPrimColor(D_801263A0++, 0, 0, 0, 0, 0, arg4) + gDPSetCombineMode(D_801263A0++, G_CC_PRIMITIVE, G_CC_PRIMITIVE) + gDPFillRectangle(D_801263A0++, arg0, arg1, arg0 + arg2, arg1 + arg3) + gDPPipeSync(D_801263A0++) + gDPSetPrimColor(D_801263A0++, 0, 0, 255, 255, 255, 255) + + func_8007B3D0(&D_801263A0); +} + GLOBAL_ASM("asm/non_matchings/menu/menu_credits_loop.s") void func_8009BCF0(void) { diff --git a/src/menu.h b/src/menu.h index 29894923..3cb002cc 100644 --- a/src/menu.h +++ b/src/menu.h @@ -271,7 +271,7 @@ extern s32 gShowControllerPakMenu; extern s32 gActiveMagicCodes; extern s32 gUnlockedMagicCodes; -extern s32 gMagicCodeMenuStrings[5]; +extern char *gMagicCodeMenuStrings[5]; extern u8 D_800DFDB4[10][2]; @@ -376,9 +376,9 @@ extern s16 D_800E06C4[8]; extern s16 D_800E06D4[8]; -extern u16 D_800E06E4[14]; +extern s16 D_800E06E4[14]; -extern u16 D_800E0700[8]; +extern s16 D_800E0700[8]; extern s16 D_800E0710[16]; @@ -410,16 +410,6 @@ extern s16 D_800E0990[8]; extern s16 D_800E09A0[8]; -// Not sure about typing with these. -extern s32 D_800E09B0[5]; -extern s32 D_800E09C4[5]; -extern s32 D_800E09D8[5]; -extern s32 D_800E09EC[3]; -extern s32 D_800E09F8[3]; -extern s32 D_800E0A04[3]; -extern s32 D_800E0A10; -extern s32 D_800E0A14[4]; - extern s16 D_800E0A24[14]; extern s16 D_800E0A40[8]; @@ -589,4 +579,8 @@ extern s16 D_800E1E2C[10]; extern s16 D_800E1E40[10]; +typedef struct unk80126460 { + MenuElement elem[2]; +} unk80126460; + #endif diff --git a/src/unknown_003260.c b/src/unknown_003260.c index dd932640..19a0951a 100644 --- a/src/unknown_003260.c +++ b/src/unknown_003260.c @@ -158,7 +158,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_003260/func_80002E38.s") GLOBAL_ASM("asm/non_matchings/unknown_003260/func_80003008.s") GLOBAL_ASM("asm/non_matchings/unknown_003260/func_80003040.s") -void sfxSetVolumeSlider(u32 arg0) { +void set_sfx_volume_slider(u32 arg0) { if (arg0 > 256) { arg0 = 256; }