From c3def3e91ffeb7116ff78fc51971acca8da25797 Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Mon, 3 Jan 2022 02:07:24 -0500 Subject: [PATCH] Match a variety of functions, identify a struct type and some related variables, regenerated some mips_to_c code (#129) * Meaningful commit message Signed-off-by: Taggerung * Identify another struct and array Regenerated a lot of mips_to_c code based on these identifications Signed-off-by: Taggerung --- asm/bss_8001C4D0.s | 4 +- .../code_80091750/add_8018D9E0_entry.s | 6 +- .../code_80091750/func_80099110.s | 6 - .../code_80091750/func_80099184.s | 24 +- .../code_80091750/func_800996BC.s | 8 +- .../code_80091750/func_8009A374.s | 4 +- .../code_80091750/func_8009A478.s | 4 +- .../code_80091750/func_8009B8C4.s | 4 +- .../code_80091750/func_800AADD4.s | 18 - .../code_80091750/func_800AAE18.s | 23 - .../code_80091750/func_800AAF94.s | 15 - include/common_structs.h | 11 + include/variables.h | 5 + src/code_80091750.c | 438 ++++++++---------- src/code_800AF9B0.c | 3 +- 15 files changed, 231 insertions(+), 342 deletions(-) delete mode 100644 asm/non_matchings/code_80091750/func_80099110.s delete mode 100644 asm/non_matchings/code_80091750/func_800AADD4.s delete mode 100644 asm/non_matchings/code_80091750/func_800AAE18.s delete mode 100644 asm/non_matchings/code_80091750/func_800AAF94.s diff --git a/asm/bss_8001C4D0.s b/asm/bss_8001C4D0.s index f3b1a1cbc..f07243855 100644 --- a/asm/bss_8001C4D0.s +++ b/asm/bss_8001C4D0.s @@ -1785,7 +1785,7 @@ glabel D_8018E060 glabel D_8018E0E8 .skip 40 -glabel D_8018E110 +glabel gD_8018E118TotalSize .skip 8 glabel D_8018E118 @@ -1797,7 +1797,7 @@ glabel D_8018E11C glabel D_8018E124 .skip 1588 -glabel D_8018E758 +glabel gNumD_8018E118Entries .skip 4 glabel D_8018E75C diff --git a/asm/non_matchings/code_80091750/add_8018D9E0_entry.s b/asm/non_matchings/code_80091750/add_8018D9E0_entry.s index 570bbf12f..7f370c5b9 100644 --- a/asm/non_matchings/code_80091750/add_8018D9E0_entry.s +++ b/asm/non_matchings/code_80091750/add_8018D9E0_entry.s @@ -437,9 +437,9 @@ glabel L8009ECAC /* 09F8D0 8009ECD0 8FBF001C */ lw $ra, 0x1c($sp) glabel L8009ECD4 /* 09F8D4 8009ECD4 0C01BB91 */ jal func_8006EE44 -/* 09F8D8 8009ECD8 00000000 */ nop -/* 09F8DC 8009ECDC 3C028019 */ lui $v0, %hi(D_8018E110) # $v0, 0x8019 -/* 09F8E0 8009ECE0 2442E110 */ addiu $v0, %lo(D_8018E110) # addiu $v0, $v0, -0x1ef0 +/* 09F8D8 8009ECD8 00000000 */ nop +/* 09F8DC 8009ECDC 3C028019 */ lui $v0, %hi(gD_8018E118TotalSize) # $v0, 0x8019 +/* 09F8E0 8009ECE0 2442E110 */ addiu $v0, %lo(gD_8018E118TotalSize) # addiu $v0, $v0, -0x1ef0 /* 09F8E4 8009ECE4 8C590000 */ lw $t9, ($v0) /* 09F8E8 8009ECE8 3C010001 */ lui $at, 1 /* 09F8EC 8009ECEC 3C040200 */ lui $a0, %hi(D_020045E8) # $a0, 0x200 diff --git a/asm/non_matchings/code_80091750/func_80099110.s b/asm/non_matchings/code_80091750/func_80099110.s deleted file mode 100644 index e12716955..000000000 --- a/asm/non_matchings/code_80091750/func_80099110.s +++ /dev/null @@ -1,6 +0,0 @@ -glabel func_80099110 -/* 099D10 80099110 3C018019 */ lui $at, %hi(D_8018E110) # $at, 0x8019 -/* 099D14 80099114 AC20E110 */ sw $zero, %lo(D_8018E110)($at) -/* 099D18 80099118 3C018019 */ lui $at, %hi(D_8018E758) -/* 099D1C 8009911C 03E00008 */ jr $ra -/* 099D20 80099120 AC20E758 */ sw $zero, %lo(D_8018E758)($at) diff --git a/asm/non_matchings/code_80091750/func_80099184.s b/asm/non_matchings/code_80091750/func_80099184.s index c546f9a73..eeda20ab5 100644 --- a/asm/non_matchings/code_80091750/func_80099184.s +++ b/asm/non_matchings/code_80091750/func_80099184.s @@ -15,12 +15,12 @@ glabel func_80099184 /* 099DB8 800991B8 11C0006C */ beqz $t6, .L8009936C /* 099DBC 800991BC 3C158019 */ lui $s5, %hi(D_8018D9B0) # $s5, 0x8019 /* 099DC0 800991C0 3C148019 */ lui $s4, %hi(D_8018D9B4) # $s4, 0x8019 -/* 099DC4 800991C4 3C138019 */ lui $s3, %hi(D_8018E758) # $s3, 0x8019 -/* 099DC8 800991C8 3C128019 */ lui $s2, %hi(D_8018E110) # $s2, 0x8019 +/* 099DC4 800991C4 3C138019 */ lui $s3, %hi(gNumD_8018E118Entries) # $s3, 0x8019 +/* 099DC8 800991C8 3C128019 */ lui $s2, %hi(gD_8018E118TotalSize) # $s2, 0x8019 /* 099DCC 800991CC 3C108019 */ lui $s0, %hi(D_8018E118) # $s0, 0x8019 /* 099DD0 800991D0 2610E118 */ addiu $s0, %lo(D_8018E118) # addiu $s0, $s0, -0x1ee8 -/* 099DD4 800991D4 2652E110 */ addiu $s2, %lo(D_8018E110) # addiu $s2, $s2, -0x1ef0 -/* 099DD8 800991D8 2673E758 */ addiu $s3, %lo(D_8018E758) # addiu $s3, $s3, -0x18a8 +/* 099DD4 800991D4 2652E110 */ addiu $s2, %lo(gD_8018E118TotalSize) # addiu $s2, $s2, -0x1ef0 +/* 099DD8 800991D8 2673E758 */ addiu $s3, %lo(gNumD_8018E118Entries) # addiu $s3, $s3, -0x18a8 /* 099DDC 800991DC 2694D9B4 */ addiu $s4, %lo(D_8018D9B4) # addiu $s4, $s4, -0x264c /* 099DE0 800991E0 26B5D9B0 */ addiu $s5, %lo(D_8018D9B0) # addiu $s5, $s5, -0x2650 /* 099DE4 800991E4 8E630000 */ lw $v1, ($s3) @@ -160,12 +160,12 @@ glabel func_80099184 /* 099FC4 800993C4 00409025 */ move $s2, $v0 /* 099FC8 800993C8 11C0004E */ beqz $t6, .L80099504 /* 099FCC 800993CC 26D6D9B0 */ addiu $s6, %lo(D_8018D9B0) # addiu $s6, $s6, -0x2650 -/* 099FD0 800993D0 3C148019 */ lui $s4, %hi(D_8018E758) # $s4, 0x8019 -/* 099FD4 800993D4 3C138019 */ lui $s3, %hi(D_8018E110) # $s3, 0x8019 +/* 099FD0 800993D0 3C148019 */ lui $s4, %hi(gNumD_8018E118Entries) # $s4, 0x8019 +/* 099FD4 800993D4 3C138019 */ lui $s3, %hi(gD_8018E118TotalSize) # $s3, 0x8019 /* 099FD8 800993D8 3C118019 */ lui $s1, %hi(D_8018E118) # $s1, 0x8019 /* 099FDC 800993DC 2631E118 */ addiu $s1, %lo(D_8018E118) # addiu $s1, $s1, -0x1ee8 -/* 099FE0 800993E0 2673E110 */ addiu $s3, %lo(D_8018E110) # addiu $s3, $s3, -0x1ef0 -/* 099FE4 800993E4 2694E758 */ addiu $s4, %lo(D_8018E758) # addiu $s4, $s4, -0x18a8 +/* 099FE0 800993E0 2673E110 */ addiu $s3, %lo(gD_8018E118TotalSize) # addiu $s3, $s3, -0x1ef0 +/* 099FE4 800993E4 2694E758 */ addiu $s4, %lo(gNumD_8018E118Entries) # addiu $s4, $s4, -0x18a8 /* 099FE8 800993E8 24150005 */ li $s5, 5 /* 099FEC 800993EC 8E830000 */ lw $v1, ($s4) .L800993F0: @@ -272,12 +272,12 @@ glabel func_80099184 /* 09A15C 8009955C 11C00046 */ beqz $t6, .L80099678 /* 09A160 80099560 26B5D9B0 */ addiu $s5, %lo(D_8018D9B0) # addiu $s5, $s5, -0x2650 /* 09A164 80099564 3C148019 */ lui $s4, %hi(D_8018D9B4) # $s4, 0x8019 -/* 09A168 80099568 3C138019 */ lui $s3, %hi(D_8018E758) # $s3, 0x8019 -/* 09A16C 8009956C 3C128019 */ lui $s2, %hi(D_8018E110) # $s2, 0x8019 +/* 09A168 80099568 3C138019 */ lui $s3, %hi(gNumD_8018E118Entries) # $s3, 0x8019 +/* 09A16C 8009956C 3C128019 */ lui $s2, %hi(gD_8018E118TotalSize) # $s2, 0x8019 /* 09A170 80099570 3C108019 */ lui $s0, %hi(D_8018E118) # $s0, 0x8019 /* 09A174 80099574 2610E118 */ addiu $s0, %lo(D_8018E118) # addiu $s0, $s0, -0x1ee8 -/* 09A178 80099578 2652E110 */ addiu $s2, %lo(D_8018E110) # addiu $s2, $s2, -0x1ef0 -/* 09A17C 8009957C 2673E758 */ addiu $s3, %lo(D_8018E758) # addiu $s3, $s3, -0x18a8 +/* 09A178 80099578 2652E110 */ addiu $s2, %lo(gD_8018E118TotalSize) # addiu $s2, $s2, -0x1ef0 +/* 09A17C 8009957C 2673E758 */ addiu $s3, %lo(gNumD_8018E118Entries) # addiu $s3, $s3, -0x18a8 /* 09A180 80099580 2694D9B4 */ addiu $s4, %lo(D_8018D9B4) # addiu $s4, $s4, -0x264c /* 09A184 80099584 8E630000 */ lw $v1, ($s3) .L80099588: diff --git a/asm/non_matchings/code_80091750/func_800996BC.s b/asm/non_matchings/code_80091750/func_800996BC.s index d613101b6..fcdab3aa9 100644 --- a/asm/non_matchings/code_80091750/func_800996BC.s +++ b/asm/non_matchings/code_80091750/func_800996BC.s @@ -18,12 +18,12 @@ glabel func_800996BC /* 09A2FC 800996FC 11C0008A */ beqz $t6, .L80099928 /* 09A300 80099700 2417FFFF */ li $s7, -1 /* 09A304 80099704 3C158019 */ lui $s5, %hi(D_8018D9B4) # $s5, 0x8019 -/* 09A308 80099708 3C148019 */ lui $s4, %hi(D_8018E758) # $s4, 0x8019 -/* 09A30C 8009970C 3C138019 */ lui $s3, %hi(D_8018E110) # $s3, 0x8019 +/* 09A308 80099708 3C148019 */ lui $s4, %hi(gNumD_8018E118Entries) # $s4, 0x8019 +/* 09A30C 8009970C 3C138019 */ lui $s3, %hi(gD_8018E118TotalSize) # $s3, 0x8019 /* 09A310 80099710 3C118019 */ lui $s1, %hi(D_8018E118) # $s1, 0x8019 /* 09A314 80099714 2631E118 */ addiu $s1, %lo(D_8018E118) # addiu $s1, $s1, -0x1ee8 -/* 09A318 80099718 2673E110 */ addiu $s3, %lo(D_8018E110) # addiu $s3, $s3, -0x1ef0 -/* 09A31C 8009971C 2694E758 */ addiu $s4, %lo(D_8018E758) # addiu $s4, $s4, -0x18a8 +/* 09A318 80099718 2673E110 */ addiu $s3, %lo(gD_8018E118TotalSize) # addiu $s3, $s3, -0x1ef0 +/* 09A31C 8009971C 2694E758 */ addiu $s4, %lo(gNumD_8018E118Entries) # addiu $s4, $s4, -0x18a8 /* 09A320 80099720 26B5D9B4 */ addiu $s5, %lo(D_8018D9B4) # addiu $s5, $s5, -0x264c /* 09A324 80099724 24160001 */ li $s6, 1 /* 09A328 80099728 8E830000 */ lw $v1, ($s4) diff --git a/asm/non_matchings/code_80091750/func_8009A374.s b/asm/non_matchings/code_80091750/func_8009A374.s index 7108e21e5..dbc1ddc55 100644 --- a/asm/non_matchings/code_80091750/func_8009A374.s +++ b/asm/non_matchings/code_80091750/func_8009A374.s @@ -34,8 +34,8 @@ glabel func_8009A374 /* 09AFE4 8009A3E4 AC790004 */ sw $t9, 4($v1) /* 09AFE8 8009A3E8 AC600008 */ sw $zero, 8($v1) /* 09AFEC 8009A3EC AC68000C */ sw $t0, 0xc($v1) -/* 09AFF0 8009A3F0 3C098019 */ lui $t1, %hi(D_8018E758) # $t1, 0x8019 -/* 09AFF4 8009A3F4 8D29E758 */ lw $t1, %lo(D_8018E758)($t1) +/* 09AFF0 8009A3F0 3C098019 */ lui $t1, %hi(gNumD_8018E118Entries) # $t1, 0x8019 +/* 09AFF4 8009A3F4 8D29E758 */ lw $t1, %lo(gNumD_8018E118Entries)($t1) /* 09AFF8 8009A3F8 AC690010 */ sw $t1, 0x10($v1) /* 09AFFC 8009A3FC 8C4A0000 */ lw $t2, ($v0) /* 09B000 8009A400 5140000A */ beql $t2, $zero, .L8009A42C diff --git a/asm/non_matchings/code_80091750/func_8009A478.s b/asm/non_matchings/code_80091750/func_8009A478.s index dd36e05be..83160b958 100644 --- a/asm/non_matchings/code_80091750/func_8009A478.s +++ b/asm/non_matchings/code_80091750/func_8009A478.s @@ -35,8 +35,8 @@ glabel func_8009A478 /* 09B0EC 8009A4EC AC790004 */ sw $t9, 4($v1) /* 09B0F0 8009A4F0 AC600008 */ sw $zero, 8($v1) /* 09B0F4 8009A4F4 AC68000C */ sw $t0, 0xc($v1) -/* 09B0F8 8009A4F8 3C098019 */ lui $t1, %hi(D_8018E758) # $t1, 0x8019 -/* 09B0FC 8009A4FC 8D29E758 */ lw $t1, %lo(D_8018E758)($t1) +/* 09B0F8 8009A4F8 3C098019 */ lui $t1, %hi(gNumD_8018E118Entries) # $t1, 0x8019 +/* 09B0FC 8009A4FC 8D29E758 */ lw $t1, %lo(gNumD_8018E118Entries)($t1) /* 09B100 8009A500 00003025 */ move $a2, $zero /* 09B104 8009A504 AC690010 */ sw $t1, 0x10($v1) /* 09B108 8009A508 8C4A0000 */ lw $t2, ($v0) diff --git a/asm/non_matchings/code_80091750/func_8009B8C4.s b/asm/non_matchings/code_80091750/func_8009B8C4.s index 567db7c4e..66b245765 100644 --- a/asm/non_matchings/code_80091750/func_8009B8C4.s +++ b/asm/non_matchings/code_80091750/func_8009B8C4.s @@ -1,6 +1,6 @@ glabel func_8009B8C4 -/* 09C4C4 8009B8C4 3C058019 */ lui $a1, %hi(D_8018E758) # $a1, 0x8019 -/* 09C4C8 8009B8C8 8CA5E758 */ lw $a1, %lo(D_8018E758)($a1) +/* 09C4C4 8009B8C4 3C058019 */ lui $a1, %hi(gNumD_8018E118Entries) # $a1, 0x8019 +/* 09C4C8 8009B8C8 8CA5E758 */ lw $a1, %lo(gNumD_8018E118Entries)($a1) /* 09C4CC 8009B8CC 27BDFFF0 */ addiu $sp, $sp, -0x10 /* 09C4D0 8009B8D0 00001025 */ move $v0, $zero /* 09C4D4 8009B8D4 18A0000E */ blez $a1, .L8009B910 diff --git a/asm/non_matchings/code_80091750/func_800AADD4.s b/asm/non_matchings/code_80091750/func_800AADD4.s deleted file mode 100644 index 84d0cb736..000000000 --- a/asm/non_matchings/code_80091750/func_800AADD4.s +++ /dev/null @@ -1,18 +0,0 @@ -glabel func_800AADD4 -/* 0AB9D4 800AADD4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0AB9D8 800AADD8 AFBF0014 */ sw $ra, 0x14($sp) -/* 0AB9DC 800AADDC 8C820000 */ lw $v0, ($a0) -/* 0AB9E0 800AADE0 3C038019 */ lui $v1, %hi(gCharacterGridSelections) # 0x8019 -/* 0AB9E4 800AADE4 240F000E */ li $t7, 14 -/* 0AB9E8 800AADE8 2442FFCC */ addiu $v0, $v0, -0x34 -/* 0AB9EC 800AADEC 00621821 */ addu $v1, $v1, $v0 -/* 0AB9F0 800AADF0 8063EDE4 */ lb $v1, %lo(gCharacterGridSelections)($v1) # -0x121c($v1) -/* 0AB9F4 800AADF4 00027040 */ sll $t6, $v0, 1 -/* 0AB9F8 800AADF8 01EEC023 */ subu $t8, $t7, $t6 -/* 0AB9FC 800AADFC A0980014 */ sb $t8, 0x14($a0) -/* 0ABA00 800AAE00 0C02ABE5 */ jal func_800AAF94 -/* 0ABA04 800AAE04 2465FFFF */ addiu $a1, $v1, -1 -/* 0ABA08 800AAE08 8FBF0014 */ lw $ra, 0x14($sp) -/* 0ABA0C 800AAE0C 27BD0018 */ addiu $sp, $sp, 0x18 -/* 0ABA10 800AAE10 03E00008 */ jr $ra -/* 0ABA14 800AAE14 00000000 */ nop diff --git a/asm/non_matchings/code_80091750/func_800AAE18.s b/asm/non_matchings/code_80091750/func_800AAE18.s deleted file mode 100644 index dd76c4d30..000000000 --- a/asm/non_matchings/code_80091750/func_800AAE18.s +++ /dev/null @@ -1,23 +0,0 @@ -glabel func_800AAE18 -/* 0ABA18 800AAE18 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0ABA1C 800AAE1C AFBF0014 */ sw $ra, 0x14($sp) -/* 0ABA20 800AAE20 00802825 */ move $a1, $a0 -/* 0ABA24 800AAE24 8C840000 */ lw $a0, ($a0) -/* 0ABA28 800AAE28 AFA50018 */ sw $a1, 0x18($sp) -/* 0ABA2C 800AAE2C 0C02ABF3 */ jal func_800AAFCC -/* 0ABA30 800AAE30 2484FFD5 */ addiu $a0, $a0, -0x2b -/* 0ABA34 800AAE34 04400006 */ bltz $v0, .L800AAE50 -/* 0ABA38 800AAE38 8FA50018 */ lw $a1, 0x18($sp) -/* 0ABA3C 800AAE3C 00027040 */ sll $t6, $v0, 1 -/* 0ABA40 800AAE40 240F000E */ li $t7, 14 -/* 0ABA44 800AAE44 01EEC023 */ subu $t8, $t7, $t6 -/* 0ABA48 800AAE48 10000003 */ b .L800AAE58 -/* 0ABA4C 800AAE4C A0B80014 */ sb $t8, 0x14($a1) -.L800AAE50: -/* 0ABA50 800AAE50 24190006 */ li $t9, 6 -/* 0ABA54 800AAE54 A0B90014 */ sb $t9, 0x14($a1) -.L800AAE58: -/* 0ABA58 800AAE58 8FBF0014 */ lw $ra, 0x14($sp) -/* 0ABA5C 800AAE5C 27BD0018 */ addiu $sp, $sp, 0x18 -/* 0ABA60 800AAE60 03E00008 */ jr $ra -/* 0ABA64 800AAE64 00000000 */ nop diff --git a/asm/non_matchings/code_80091750/func_800AAF94.s b/asm/non_matchings/code_80091750/func_800AAF94.s deleted file mode 100644 index 93067e0f0..000000000 --- a/asm/non_matchings/code_80091750/func_800AAF94.s +++ /dev/null @@ -1,15 +0,0 @@ -glabel func_800AAF94 -/* 0ABB94 800AAF94 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0ABB98 800AAF98 AFBF0014 */ sw $ra, 0x14($sp) -/* 0ABB9C 800AAF9C AFA40018 */ sw $a0, 0x18($sp) -/* 0ABBA0 800AAFA0 0C02ABAD */ jal func_800AAEB4 -/* 0ABBA4 800AAFA4 00A02025 */ move $a0, $a1 -/* 0ABBA8 800AAFA8 8FA30018 */ lw $v1, 0x18($sp) -/* 0ABBAC 800AAFAC 8C4E000C */ lw $t6, 0xc($v0) -/* 0ABBB0 800AAFB0 AC6E000C */ sw $t6, 0xc($v1) -/* 0ABBB4 800AAFB4 8C4F0010 */ lw $t7, 0x10($v0) -/* 0ABBB8 800AAFB8 AC6F0010 */ sw $t7, 0x10($v1) -/* 0ABBBC 800AAFBC 8FBF0014 */ lw $ra, 0x14($sp) -/* 0ABBC0 800AAFC0 27BD0018 */ addiu $sp, $sp, 0x18 -/* 0ABBC4 800AAFC4 03E00008 */ jr $ra -/* 0ABBC8 800AAFC8 00000000 */ nop diff --git a/include/common_structs.h b/include/common_structs.h index 2c1234035..a37e98743 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -481,4 +481,15 @@ typedef struct { /* 0x06 */ u16 alpha; } RGBA16; // size = 0x08 +typedef struct { + /* 0x00 */ segment_address_t textureData; + /** + * Its hard to tell what exactly what this is meant to be, + * but it appears to be used as some sort of offset/index from the address stored in D_8018D9B0. + * This value is (roughly) the sum of (width * height) of the + * textures in all the previous entries in D_8018E118 + */ + /* 0x04 */ s32 offset; +} struct_8018E118_entry; // size = 0x08 + #endif diff --git a/include/variables.h b/include/variables.h index 097674627..44638b190 100644 --- a/include/variables.h +++ b/include/variables.h @@ -7,16 +7,19 @@ extern s32 gCCSelection; extern s8 gCharacterIdByGPOverallRank[8]; // D_8018D9D0 +extern s8 gCharacterGridSelections[4]; // D_8018EDE4 extern s32 gControllerPakNumPagesFree; // D_8018EB80 extern s8 gControllerPakSelectedTableRow; // D_800E86C0 extern f32 gCourseCompletionPercentByPlayerId[8]; // D_801644D0 extern f32 gCourseCompletionPercentByRank[8]; // D_80162FD8 +extern s16 gCupCourseOrder[NUM_CUPS][NUM_COURSES_PER_CUP]; // D_800F2BB4 extern s8 gCupCourseSelection; // D_8018EE0B extern char *gCupNames[]; // D_800E7500 extern s8 gCupSelection; // D_8018EE09 // Maps course IDs (as defined in the COURSES enum) to the cup they belong to extern u8 gCupSelectionByCourseId[NUM_COURSES]; // D_800E7664 extern s16 gCurrentCourseId; +extern s32 gD_8018E118TotalSize; // D_8018E110 extern char *gDebugSoundModeNames[NUM_SOUND_MODES]; // D_800E7700 extern s32 gGlobalTimer; // D_800DC54C extern s8 gGPPointsByCharacterId[8]; // D_8018D9C8 @@ -29,6 +32,7 @@ extern s8 gControllerPakMenuSelection; // D_8018EDF0 extern s32 gModeSelection; // Indicates the ID of the next title screen demo that will be played extern u8 gNextDemoId; // D_800E86BC +extern s32 gNumD_8018E118Entries; // D_8018E758 // Maps course IDs (as defined in the COURSES enum) to an index in a given cup's track order extern u8 gPerCupIndexByCourseId[NUM_COURSES]; // D_800EFD50 extern s32 gPlayerCountSelection1; @@ -43,6 +47,7 @@ extern s8 gTimeTrialDataCourseIndex; // D_8018EDF7 extern struct_8018D9E0_entry D_8018D9E0[32]; // D_8018D9E0 extern struct_8018DEE0_entry D_8018DEE0[16]; // D_8018DEE0 +extern struct_8018E118_entry D_8018E118[200]; // D_8018E118 extern struct_D_802874D8 D_802874D8; extern s16 D_801650D0[4][8]; extern s16 D_80165110[4][8]; diff --git a/src/code_80091750.c b/src/code_80091750.c index a03305884..1816479db 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -4280,18 +4280,10 @@ void dma_copy_base_7fa3c0(s32 arg0, u32 arg1, void *arg2) { GLOBAL_ASM("asm/non_matchings/code_80091750/dma_copy_base_7fa3c0.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern s32 D_8018E110; -extern s32 D_8018E758; - void func_80099110(void) { - D_8018E110 = 0; - D_8018E758 = 0; + gD_8018E118TotalSize = 0; + gNumD_8018E118Entries = 0; } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_80099110.s") -#endif void *segmented_to_virtual(segment_address_t arg0) { return gSegmentTable[arg0 >> 0x18] + (arg0 & 0xFFFFFF) + 0x80000000; @@ -4302,50 +4294,45 @@ void *segmented_to_virtual_dupe(segment_address_t arg0) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? dma_copy_base_729a30(s32, s32, u8 *); // extern -void *segmented_to_virtual(segment_address_t); // extern -extern s32 D_8018D9B0; -extern u8 *D_8018D9B4; -extern s32 D_8018E110; -extern ? D_8018E118; -extern s32 D_8018E758; +//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe +? dma_copy_base_729a30(u32, s32, s32); /* extern */ +? mio0decode(s32, s32); /* extern */ -void func_80099184(void) { - s32 temp_a0; +void func_80099184(u32 arg0) { + Mk64_Texture *temp_v0; s32 temp_t3; s32 temp_t6; s32 temp_v0_2; s32 temp_v1; u16 temp_v0_3; - void *temp_v0; + u32 temp_a0; s32 phi_v0; - void *phi_s1; + Mk64_Texture *phi_s1; s32 phi_a1; s32 phi_a1_2; s32 phi_a1_3; - temp_v0 = segmented_to_virtual(); + temp_v0 = segmented_to_virtual(arg0); phi_s1 = temp_v0; - if (temp_v0->unk4 != 0) { + if (temp_v0->segmentAddress != 0) { do { - temp_v1 = D_8018E758; + temp_v1 = gNumD_8018E118Entries; phi_v0 = 0; phi_a1 = 0; if (temp_v1 > 0) { loop_4: temp_v0_2 = phi_v0 + 1; phi_v0 = temp_v0_2; - if (*(&D_8018E118 + (phi_v0 * 8)) == phi_s1->unk4) { + if (D_8018E118[phi_v0].textureData == phi_s1->segmentAddress) { phi_a1 = 1; } else if (temp_v0_2 < temp_v1) { goto loop_4; } } if (phi_a1 == 0) { - temp_a0 = phi_s1->unk4; - if (phi_s1->unk0 == 3) { - temp_v0_3 = phi_s1->unk10; + temp_a0 = phi_s1->segmentAddress; + if (phi_s1->type == 3) { + temp_v0_3 = phi_s1->size; phi_a1_2 = 0x1000; if (temp_v0_3 != 0) { phi_a1_2 = temp_v0_3 & 0xFFFF; @@ -4355,17 +4342,17 @@ loop_4: phi_a1_3 = (((phi_a1_2 / 8) * 8) + 8) & 0xFFFF; } dma_copy_base_729a30(temp_a0, phi_a1_3, D_8018D9B4); - mio0decode(D_8018D9B4, (D_8018E110 * 2) + D_8018D9B0); + mio0decode(D_8018D9B4, (gD_8018E118TotalSize * 2) + D_8018D9B0); } else { - dma_copy_base_729a30(temp_a0, phi_s1->unkA * phi_s1->unk8 * 2, (D_8018E110 * 2) + D_8018D9B0); + dma_copy_base_729a30(temp_a0, phi_s1->height * phi_s1->width * 2, (gD_8018E118TotalSize * 2) + D_8018D9B0); } - *(&D_8018E118 + (D_8018E758 * 8)) = phi_s1->unk4; - (&D_8018E118 + (D_8018E758 * 8))->unk4 = D_8018E110; - D_8018E758 = D_8018E758 + 1; - temp_t3 = D_8018E110 + (phi_s1->unkA * phi_s1->unk8); + D_8018E118[gNumD_8018E118Entries].textureData = phi_s1->segmentAddress; + D_8018E118[gNumD_8018E118Entries].offset = gD_8018E118TotalSize; + gNumD_8018E118Entries += 1; + temp_t3 = gD_8018E118TotalSize + (phi_s1->height * phi_s1->width); temp_t6 = temp_t3; - D_8018E110 = temp_t3; - D_8018E110 = ((temp_t6 / 8) * 8) + 8; + gD_8018E118TotalSize = temp_t3; + gD_8018E118TotalSize = ((temp_t6 / 8) * 8) + 8; } phi_s1 += 0x14; } while (phi_s1->unk18 != 0); @@ -4387,51 +4374,48 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009969C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? dma_copy_base_729a30(s32, s32, u8 *); // extern -? dma_copy_base_7fa3c0(s32, s32, u8 *); // extern -void *segmented_to_virtual(segment_address_t); // extern -? tkmk00decode(u8 *, s32, s32, ?); // extern +//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe +? dma_copy_base_729a30(u32, s32, s32); /* extern */ +? dma_copy_base_7fa3c0(u32, s32, s32); /* extern */ +? mio0decode(s32, s32); /* extern */ +? tkmk00decode(s32, s32, s32, ?); /* extern */ extern s32 D_8018D9B0; -extern u8 *D_8018D9B4; +extern s32 D_8018D9B4; extern s32 D_8018D9B8; -extern s32 D_8018E110; -extern ? D_8018E118; -extern s32 D_8018E758; -void func_800996BC(s32 arg1) { +void func_800996BC(u32 arg0, s32 arg1) { + Mk64_Texture *temp_v0; s32 temp_t0; s32 temp_t1; s32 temp_v0_2; s32 temp_v1; u16 temp_v0_3; - void *temp_v0; s32 phi_v0; - void *phi_s0; + Mk64_Texture *phi_s0; s32 phi_a1; s32 phi_a1_2; s32 phi_a1_3; ? phi_v0_2; - temp_v0 = segmented_to_virtual(arg0); + temp_v0 = segmented_to_virtual(); phi_s0 = temp_v0; - if (temp_v0->unk4 != 0) { + if (temp_v0->segmentAddress != 0) { do { - temp_v1 = D_8018E758; + temp_v1 = gNumD_8018E118Entries; phi_v0 = 0; phi_a1 = 0; if (temp_v1 > 0) { loop_4: temp_v0_2 = phi_v0 + 1; phi_v0 = temp_v0_2; - if (*(&D_8018E118 + (phi_v0 * 8)) == phi_s0->unk4) { + if (D_8018E118[phi_v0].textureData == phi_s0->segmentAddress) { phi_a1 = 1; } else if (temp_v0_2 < temp_v1) { goto loop_4; } } if ((phi_a1 == 0) || (arg1 > 0)) { - temp_v0_3 = phi_s0->unk10; + temp_v0_3 = phi_s0->size; phi_a1_2 = 0x1000; if (temp_v0_3 != 0) { phi_a1_2 = temp_v0_3 & 0xFFFF; @@ -4440,55 +4424,37 @@ loop_4: if ((phi_a1_2 % 8) != 0) { phi_a1_3 = (((phi_a1_2 / 8) * 8) + 8) & 0xFFFF; } - if (arg1 != -1) { - if (arg1 != 0) { - if (arg1 != 1) { - if (arg1 != 2) { - - } else { - goto block_19; - } - } else { - goto block_18; - } - } else { -block_19: - dma_copy_base_7fa3c0(phi_s0->unk4, phi_a1_3, D_8018D9B4); - } - } else { -block_18: - dma_copy_base_729a30(phi_s0->unk4, phi_a1_3, D_8018D9B4); + switch (arg1) { /* irregular */ + case -1: + case 1: + dma_copy_base_729a30(phi_s0->segmentAddress, phi_a1_3, D_8018D9B4); + break; + case 0: + case 2: + dma_copy_base_7fa3c0(phi_s0->segmentAddress, phi_a1_3, D_8018D9B4); + break; } - if (arg1 != -1) { - if (arg1 != 0) { - if (arg1 != 1) { - if (arg1 != 2) { - - } else { - goto block_26; - } - } else { - goto block_25; - } - } else { -block_26: - phi_v0_2 = 1; - if (phi_s0->unk0 == 1) { - phi_v0_2 = 0xBE; - } - tkmk00decode(D_8018D9B4, D_8018D9B8, (D_8018E110 * 2) + D_8018D9B0, phi_v0_2); + switch (arg1) { /* switch 1; irregular */ + case -1: /* switch 1 */ + case 1: /* switch 1 */ + mio0decode(D_8018D9B4, (gD_8018E118TotalSize * 2) + D_8018D9B0); + break; + case 0: /* switch 1 */ + case 2: /* switch 1 */ + phi_v0_2 = 1; + if (phi_s0->type == 1) { + phi_v0_2 = 0xBE; } - } else { -block_25: - mio0decode(D_8018D9B4, (D_8018E110 * 2) + D_8018D9B0); + tkmk00decode(D_8018D9B4, D_8018D9B8, (gD_8018E118TotalSize * 2) + D_8018D9B0, phi_v0_2); + break; } - *(&D_8018E118 + (D_8018E758 * 8)) = phi_s0->unk4; - (&D_8018E118 + (D_8018E758 * 8))->unk4 = D_8018E110; - D_8018E758 = D_8018E758 + 1; - temp_t0 = D_8018E110 + (phi_s0->unkA * phi_s0->unk8); + D_8018E118[gNumD_8018E118Entries].textureData = phi_s0->segmentAddress; + D_8018E118[gNumD_8018E118Entries].offset = gD_8018E118TotalSize; + gNumD_8018E118Entries += 1; + temp_t0 = gD_8018E118TotalSize + (phi_s0->height * phi_s0->width); temp_t1 = temp_t0; - D_8018E110 = temp_t0; - D_8018E110 = ((temp_t1 / 8) * 8) + 8; + gD_8018E118TotalSize = temp_t0; + gD_8018E118TotalSize = ((temp_t1 / 8) * 8) + 8; } phi_s0 += 0x14; } while (phi_s0->unk18 != 0); @@ -4591,17 +4557,21 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_80099A94.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern OSMesgQueue gDmaMesgQueue; +//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe +? mio0decode(s32, s32); /* extern */ +? osInvalDCache(s32, s32); /* extern */ +? osPiStartDma(? *, ?, ?, void *, s32, s32, ? *); /* extern */ +? osRecvMesg(? *, ? *, ?); /* extern */ +extern s32 D_800DC50C; extern s32 D_8018D9B0; -extern void *D_8018D9B4; +extern s32 D_8018D9B4; extern void *D_8018E060; -extern ? D_8018E118; extern ? _textures_0aSegmentRomStart; +extern ? gDmaMesgQueue; void func_80099AEC(void) { ? sp6C; - void *sp68; + ? sp68; s32 sp60; ? *sp58; s32 temp_t7; @@ -4613,13 +4583,13 @@ void func_80099AEC(void) { void *temp_v0; void *temp_v0_2; s32 phi_s0; - u32 phi_s0_2; + s32 phi_s0_2; void **phi_s1; s32 phi_s0_3; - u32 phi_s0_4; + s32 phi_s0_4; s8 phi_s5; s32 phi_s0_5; - u32 phi_s0_6; + s32 phi_s0_6; s8 phi_s5_2; s8 phi_s5_3; @@ -4637,7 +4607,7 @@ void func_80099AEC(void) { phi_s0_3 = 0x1400; phi_s0_5 = 0x1400; if (temp_v1 != 0) { - phi_s0 = temp_v1; + phi_s0 = (s32) temp_v1; } phi_s0_2 = phi_s0; if ((phi_s0 % 8) != 0) { @@ -4651,12 +4621,12 @@ loop_9: temp_v0 = phi_s1->unk8; phi_s5 = phi_s5_3; if (temp_v0 == 0) { - phi_s5 = phi_s5_3 + 1; + phi_s5 = (s8) (phi_s5_3 + 1); } else { temp_v1_2 = temp_v0->unk10; temp_t7 = sp60 * 4; if (temp_v1_2 != 0) { - phi_s0_3 = temp_v1_2; + phi_s0_3 = (s32) temp_v1_2; } phi_s0_4 = phi_s0_3; if ((phi_s0_3 % 8) != 0) { @@ -4665,19 +4635,19 @@ loop_9: osInvalDCache(temp_t7 + D_8018D9B4, phi_s0_4); osPiStartDma(&sp6C, 0, 0, sp58 + (temp_v0->unk4 & 0xFFFFFF), temp_t7 + D_8018D9B4, phi_s0_4, &gDmaMesgQueue); } - mio0decode(D_8018D9B4, (((phi_s1->unk4 * 8) + &D_8018E118)->unk4 * 2) + D_8018D9B0); - phi_s1->unk0 = 0; + mio0decode(D_8018D9B4, (D_8018E118[phi_s1->unk4].offset * 2) + D_8018D9B0); + phi_s1->unk0 = NULL; temp_s1 = phi_s1 + 8; phi_s5_2 = phi_s5; if (phi_s5 == 0) { osRecvMesg(&gDmaMesgQueue, &sp68, 1); temp_v0_2 = temp_s1->unk8; if (temp_v0_2 == 0) { - phi_s5_2 = phi_s5 + 1; + phi_s5_2 = (s8) (phi_s5 + 1); } else { temp_v1_3 = temp_v0_2->unk10; if (temp_v1_3 != 0) { - phi_s0_5 = temp_v1_3; + phi_s0_5 = (s32) temp_v1_3; } phi_s0_6 = phi_s0_5; if ((phi_s0_5 % 8) != 0) { @@ -4686,7 +4656,7 @@ loop_9: osInvalDCache(D_8018D9B4, phi_s0_6); osPiStartDma(&sp6C, 0, 0, sp58 + (temp_v0_2->unk4 & 0xFFFFFF), D_8018D9B4, phi_s0_6, &gDmaMesgQueue); } - mio0decode((sp60 * 4) + D_8018D9B4, (((temp_s1->unk4 * 8) + &D_8018E118)->unk4 * 2) + D_8018D9B0); + mio0decode((sp60 * 4) + D_8018D9B4, (D_8018E118[temp_s1->unk4].offset * 2) + D_8018D9B0); temp_s1->unk0 = 0; phi_s1 = temp_s1 + 8; phi_s5_3 = phi_s5_2; @@ -4868,34 +4838,30 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009A344.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8009969C(s32, s32, s32 *); // extern -void *segmented_to_virtual_dupe(segment_address_t); // extern -extern ? D_8018DEE0; -extern s32 D_8018E758; +//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe +? func_8009969C(u32, s32, Mk64_Animation_Part *); /* extern */ -s32 func_8009A374(s32 *arg0) { +s32 func_8009A374(Mk64_Animation_Part *arg0) { s32 sp24; - void *sp1C; - ? *temp_v1; - s32 *temp_a2; - s32 *temp_v0; - s32 temp_a0; + struct_8018DEE0_entry *sp1C; + Mk64_Animation_Part *temp_a2; + Mk64_Animation_Part *temp_v0; s32 temp_a1; - s32 temp_t8; - void *temp_v1_2; + struct_8018DEE0_entry *temp_v1; + struct_8018DEE0_entry *temp_v1_2; + u32 temp_a0; s32 phi_a1; - ? *phi_v1; + struct_8018DEE0_entry *phi_v1; s32 phi_a1_2; - s32 *phi_a2; + Mk64_Animation_Part *phi_a2; temp_v0 = segmented_to_virtual_dupe(arg0); temp_a2 = temp_v0; phi_a1 = 0; phi_a1_2 = 0; phi_a2 = temp_a2; - if (D_8018DEE0.unkC != 0) { - phi_v1 = &D_8018DEE0; + if (D_8018DEE0->visible != 0) { + phi_v1 = D_8018DEE0; loop_2: temp_a1 = phi_a1 + 1; temp_v1 = phi_v1 + 0x18; @@ -4906,37 +4872,36 @@ loop_2: loop_3: goto loop_3; } - if (temp_v1->unkC == 0) { + if (temp_v1->visible == 0) { goto block_5; } goto loop_2; } block_5: - temp_t8 = phi_a1_2 * 0x18; - temp_v1_2 = &D_8018DEE0 + temp_t8; - temp_v1_2->unk0 = temp_v0; - temp_v1_2->unk4 = -1; - temp_v1_2->unk8 = 0; - temp_v1_2->unkC = 0x80000000; - temp_v1_2->unk10 = D_8018E758; - if (*temp_v0 != 0) { + temp_v1_2 = &D_8018DEE0[phi_a1_2]; + temp_v1_2->texutreSequence = temp_v0; + temp_v1_2->sequenceIndex = -1; + temp_v1_2->frameCountDown = 0; + temp_v1_2->visible = 0x80000000; + temp_v1_2->D_8018E118_index = gNumD_8018E118Entries; + if (temp_v0->texture != 0) { arg0 = temp_a2; sp24 = phi_a1_2; sp1C = temp_v1_2; - func_8009969C(*temp_a2, phi_a1_2, temp_a2); + func_8009969C(temp_a2->texture, phi_a1_2, temp_a2); phi_a2 = arg0; } temp_a0 = phi_a2->unk8; if (temp_a0 != 0) { - sp1C = &D_8018DEE0 + temp_t8; + sp1C = &D_8018DEE0[phi_a1_2]; sp24 = phi_a1_2; func_8009969C(temp_a0, phi_a1_2, phi_a2); } else { sp24 = phi_a1_2; - sp1C = &D_8018DEE0 + temp_t8; - func_8009969C(phi_a2->unk0, phi_a1_2, phi_a2); + sp1C = &D_8018DEE0[phi_a1_2]; + func_8009969C(phi_a2->texture, phi_a1_2, phi_a2); } - (&D_8018DEE0 + temp_t8)->unk14 = 0; + D_8018DEE0[phi_a1_2].unk14 = 0; return sp24; } #else @@ -4944,32 +4909,28 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009A374.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_80099958(s32, s32, ?, s32); // extern -void *segmented_to_virtual_dupe(segment_address_t); // extern -extern ? D_8018DEE0; -extern s32 D_8018E758; +//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe +? func_80099958(u32, s32, ?, s32); /* extern */ -s32 func_8009A478(s32 arg1) { +s32 func_8009A478(Mk64_Animation_Part *arg0, s32 arg1) { s32 sp2C; - void *sp24; - ? *temp_v1; - s32 *temp_s0; - s32 *temp_v0; - s32 temp_a0; + struct_8018DEE0_entry *sp24; + Mk64_Animation_Part *temp_s0; + Mk64_Animation_Part *temp_v0; s32 temp_a3; - s32 temp_t8; - void *temp_v1_2; + struct_8018DEE0_entry *temp_v1; + struct_8018DEE0_entry *temp_v1_2; + u32 temp_a0; s32 phi_a3; - ? *phi_v1; + struct_8018DEE0_entry *phi_v1; s32 phi_a3_2; temp_v0 = segmented_to_virtual_dupe(arg0); temp_s0 = temp_v0; phi_a3 = 0; phi_a3_2 = 0; - if (D_8018DEE0.unkC != 0) { - phi_v1 = &D_8018DEE0; + if (D_8018DEE0->visible != 0) { + phi_v1 = D_8018DEE0; loop_2: temp_a3 = phi_a3 + 1; temp_v1 = phi_v1 + 0x18; @@ -4980,35 +4941,34 @@ loop_2: loop_3: goto loop_3; } - if (temp_v1->unkC == 0) { + if (temp_v1->visible == 0) { goto block_5; } goto loop_2; } block_5: - temp_t8 = phi_a3_2 * 0x18; - temp_v1_2 = &D_8018DEE0 + temp_t8; - temp_v1_2->unk0 = temp_v0; - temp_v1_2->unk4 = -1; - temp_v1_2->unk8 = 0; - temp_v1_2->unkC = 0x80000000; - temp_v1_2->unk10 = D_8018E758; - if (temp_v0->unk0 != 0) { + temp_v1_2 = &D_8018DEE0[phi_a3_2]; + temp_v1_2->texutreSequence = temp_v0; + temp_v1_2->sequenceIndex = -1; + temp_v1_2->frameCountDown = 0; + temp_v1_2->visible = 0x80000000; + temp_v1_2->D_8018E118_index = gNumD_8018E118Entries; + if (temp_v0->texture != 0) { sp2C = phi_a3_2; sp24 = temp_v1_2; - func_80099958(temp_s0->unk0, arg1, 0, phi_a3_2); + func_80099958(temp_s0->texture, arg1, 0, phi_a3_2); } temp_a0 = temp_s0->unk8; if (temp_a0 != 0) { - sp24 = &D_8018DEE0 + temp_t8; + sp24 = &D_8018DEE0[phi_a3_2]; sp2C = phi_a3_2; func_80099958(temp_a0, arg1, 1, phi_a3_2); } else { sp2C = phi_a3_2; - sp24 = &D_8018DEE0 + temp_t8; - func_80099958(temp_s0->unk0, arg1, 1, phi_a3_2); + sp24 = &D_8018DEE0[phi_a3_2]; + func_80099958(temp_s0->texture, arg1, 1, phi_a3_2); } - (&D_8018DEE0 + temp_t8)->unk14 = 0; + D_8018DEE0[phi_a3_2].unk14 = 0; return sp2C; } #else @@ -5197,20 +5157,20 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009A944.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -f64 func_800917B0(f64, f64); // extern +//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe +f64 func_800917B0(f64, f64); /* extern */ extern s32 D_8018D9B0; -extern ? D_8018E118; -void func_8009B0A4(s32 arg0, s32 arg1) { - ? sp48; - ? *temp_s1; +void func_8009B0A4(s32 D_8018E118_index, s32 arg1) { + f32 sp48; + f32 *temp_s1; f64 temp_f10; f64 temp_f6; s16 *temp_a3_2; s32 temp_s0_2; s32 temp_t5; s32 temp_v1; + struct_8018E118_entry *temp_v0; u16 *temp_a3; u16 temp_v0_2; u16 temp_v0_3; @@ -5219,18 +5179,17 @@ void func_8009B0A4(s32 arg0, s32 arg1) { u32 temp_v1_2; u32 temp_v1_3; u32 temp_v1_4; - void *temp_v0; s32 phi_s0; f64 phi_f10; f64 phi_f6; - ? *phi_s1; + f32 *phi_s1; u32 phi_v1; u16 *phi_a3; u32 phi_v1_2; u32 phi_v1_3; s32 phi_s0_2; - temp_f6 = arg1; + temp_f6 = (f64) arg1; phi_s0 = 0; phi_f6 = temp_f6; phi_s0_2 = 0; @@ -5239,30 +5198,30 @@ void func_8009B0A4(s32 arg0, s32 arg1) { } phi_s1 = &sp48; do { - temp_f10 = phi_s0; + temp_f10 = (f64) phi_s0; phi_f10 = temp_f10; if (phi_s0 < 0) { phi_f10 = temp_f10 + 4294967296.0; } temp_s0 = phi_s0 + 1; temp_s1 = phi_s1 + 4; - temp_s1->unk-4 = func_800917B0(phi_f10 * 0.03125, (phi_f6 * 1.5 * 0.00390625) + 0.25); - phi_s0 = temp_s0; + temp_s1->unk-4 = (f32) func_800917B0(phi_f10 * 0.03125, (phi_f6 * 1.5 * 0.00390625) + 0.25); + phi_s0 = (s32) temp_s0; phi_s1 = temp_s1; - } while (temp_s0 < 0x20); - temp_v0 = (arg0 * 8) + &D_8018E118; - temp_v1 = temp_v0->unk4; + } while (temp_s0 < 0x20U); + temp_v0 = &D_8018E118[D_8018E118_index]; + temp_v1 = temp_v0->offset; temp_t5 = temp_v0->unkC - temp_v1; temp_a3 = (temp_v1 * 2) + D_8018D9B0; phi_a3 = temp_a3; if (temp_t5 != 0) { if ((temp_t5 & 1) != 0) { temp_v0_2 = *temp_a3; - temp_v1_2 = *(&sp48 + ((((((temp_v0_2 & 0xF800) >> 0xB) * 0x55) + (((temp_v0_2 & 0x7C0) >> 6) * 0x4B) + (((temp_v0_2 & 0x3E) >> 1) * 0x5F)) >> 8) * 4)) * 32.0f; + temp_v1_2 = (u32) ((&sp48)[(u32) ((((s32) (temp_v0_2 & 0xF800) >> 0xB) * 0x55) + (((s32) (temp_v0_2 & 0x7C0) >> 6) * 0x4B) + (((s32) (temp_v0_2 & 0x3E) >> 1) * 0x5F)) >> 8] * 32.0f); phi_v1 = temp_v1_2; phi_s0_2 = 1; - if (temp_v1_2 >= 0x20) { - phi_v1 = 0x1F; + if (temp_v1_2 >= 0x20U) { + phi_v1 = 0x1FU; } *temp_a3 = (phi_v1 * 0x842) + (temp_v0_2 & 1); phi_a3 = temp_a3 + 2; @@ -5274,19 +5233,19 @@ block_11: do { temp_v0_3 = phi_a3->unk0; temp_s0_2 = phi_s0_2 + 2; - temp_v1_3 = *(&sp48 + ((((((temp_v0_3 & 0xF800) >> 0xB) * 0x55) + (((temp_v0_3 & 0x7C0) >> 6) * 0x4B) + (((temp_v0_3 & 0x3E) >> 1) * 0x5F)) >> 8) * 4)) * 32.0f; + temp_v1_3 = (u32) ((&sp48)[(u32) ((((s32) (temp_v0_3 & 0xF800) >> 0xB) * 0x55) + (((s32) (temp_v0_3 & 0x7C0) >> 6) * 0x4B) + (((s32) (temp_v0_3 & 0x3E) >> 1) * 0x5F)) >> 8] * 32.0f); phi_v1_2 = temp_v1_3; phi_s0_2 = temp_s0_2; - if (temp_v1_3 >= 0x20) { - phi_v1_2 = 0x1F; + if (temp_v1_3 >= 0x20U) { + phi_v1_2 = 0x1FU; } temp_v0_4 = phi_a3->unk2; phi_a3->unk0 = (phi_v1_2 * 0x842) + (temp_v0_3 & 1); temp_a3_2 = phi_a3 + 2; - temp_v1_4 = *(&sp48 + ((((((temp_v0_4 & 0xF800) >> 0xB) * 0x55) + (((temp_v0_4 & 0x7C0) >> 6) * 0x4B) + (((temp_v0_4 & 0x3E) >> 1) * 0x5F)) >> 8) * 4)) * 32.0f; + temp_v1_4 = (u32) ((&sp48)[(u32) ((((s32) (temp_v0_4 & 0xF800) >> 0xB) * 0x55) + (((s32) (temp_v0_4 & 0x7C0) >> 6) * 0x4B) + (((s32) (temp_v0_4 & 0x3E) >> 1) * 0x5F)) >> 8] * 32.0f); phi_v1_3 = temp_v1_4; - if (temp_v1_4 >= 0x20) { - phi_v1_3 = 0x1F; + if (temp_v1_4 >= 0x20U) { + phi_v1_3 = 0x1FU; } *temp_a3_2 = (phi_v1_3 * 0x842) + (temp_v0_4 & 1); phi_a3 = temp_a3_2 + 2; @@ -5375,29 +5334,27 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009B538.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 +//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe extern s32 D_8018D9B0; -extern ? D_8018E118; -extern s32 D_8018E758; -s32 func_8009B8C4(s32 arg0) { +s32 func_8009B8C4(u32 arg0) { s32 sp4; s32 temp_a1; s32 temp_v1; - ? *phi_a2; + struct_8018E118_entry *phi_a2; s32 phi_v1; s32 phi_v0; - temp_a1 = D_8018E758; + temp_a1 = gNumD_8018E118Entries; phi_v1 = 0; phi_v0 = 0; if (temp_a1 > 0) { - phi_a2 = &D_8018E118; + phi_a2 = D_8018E118; loop_2: temp_v1 = phi_v1 + 1; phi_v1 = temp_v1; - if (arg0 == phi_a2->unk0) { - sp4 = phi_a2->unk4; + if (arg0 == phi_a2->textureData) { + sp4 = phi_a2->offset; phi_v0 = 1; } else { phi_a2 += 8; @@ -7763,7 +7720,7 @@ extern s32 gPlayerWinningIndex; extern u16 D_80162DD4; extern ? D_801640F4; extern s32 D_8018CA78; -extern s32 D_8018E110; +extern s32 gD_8018E118TotalSize; extern s32 *D_8018E75C; extern s8 D_8018ED90; extern s32 D_8018ED94; @@ -8226,7 +8183,7 @@ loop_3: return; case 0x2: func_8006EE44(priority); - D_8018E110 += 0x10000; + gD_8018E118TotalSize += 0x10000; func_80099184(&D_020045E8); return; case 0x3: @@ -9694,7 +9651,6 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A1780.s") #endif extern Gfx D_02004A0C[]; -extern s16 gCupCourseOrder[4][4]; void func_800A1924(struct_8018D9E0_entry *arg0) { func_8009A76C(arg0->D_8018DEE0_index, 0x17, 0x84, -1); @@ -15158,44 +15114,29 @@ block_13: GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AAC18.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_800AAF94(s32); // extern -extern ? gCharacterGridSelections; +void func_800AAF94(struct_8018D9E0_entry*, s32); -void func_800AADD4(void *arg0) { - s32 temp_v0; +void func_800AADD4(struct_8018D9E0_entry *arg0) { + s32 playerId; + s8 characterSelectionIndex; - temp_v0 = arg0->unk0 - 0x34; - arg0->unk14 = 0xE - (temp_v0 * 2); - func_800AAF94(*(&gCharacterGridSelections + temp_v0) - 1); + playerId = arg0->type - 0x34; + characterSelectionIndex = gCharacterGridSelections[playerId]; + arg0->priority = 0xE - (playerId * 2); + func_800AAF94(arg0, characterSelectionIndex - 1); } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AADD4.s") -#endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_800AAFCC(s32, void *); // extern - -void func_800AAE18(void *arg0) { - s32 temp_a0; +void func_800AAE18(struct_8018D9E0_entry *arg0) { s32 temp_v0; - void *temp_a1; - temp_a1 = arg0; - temp_a0 = arg0->unk0; - arg0 = temp_a1; - temp_v0 = func_800AAFCC(temp_a0 - 0x2B, temp_a1); + temp_v0 = func_800AAFCC(arg0->type - 0x2B); if (temp_v0 >= 0) { - arg0->unk14 = 0xE - (temp_v0 * 2); - return; + arg0->priority = 0xE - (temp_v0 * 2); + } + else { + arg0->priority = 6; } - arg0->unk14 = 6; } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AAE18.s") -#endif #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 @@ -15300,20 +15241,15 @@ loop_1: GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AAF30.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -void *func_800AAEB4(?); // extern +extern struct_8018D9E0_entry *func_800AAEB4(s32); -void func_800AAF94(void *arg0, ? arg1) { - void *temp_v0; +void func_800AAF94(struct_8018D9E0_entry *arg0, s32 arg1) { + struct_8018D9E0_entry *temp_v0; temp_v0 = func_800AAEB4(arg1); - arg0->unkC = temp_v0->unkC; - arg0->unk10 = temp_v0->unk10; + arg0->column = temp_v0->column; + arg0->row = temp_v0->row; } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AAF94.s") -#endif #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index 6772f0252..2b6bf5759 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -51,7 +51,6 @@ extern s8 D_8018ED16; extern s8 D_8018ED17; extern u32 D_8018EDB8; extern u32 D_8018EDBC; -extern s8 gCharacterGridSelections; // D_8018EDE4 extern s8 D_8018EDE5; extern s8 D_8018EDE6; extern s8 D_8018EDE7; @@ -2334,7 +2333,7 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B29D8.s") #endif s32 func_800B34E8(s32 arg0) { - if (arg0 == gCharacterGridSelections) { + if (arg0 == gCharacterGridSelections[0]) { return 0; } if (arg0 == D_8018EDE5) {