From ae713dc8940e884ab392b0711b558befd01d8636 Mon Sep 17 00:00:00 2001 From: David Benepe Date: Sun, 9 Aug 2020 18:18:05 -0500 Subject: [PATCH] (7.35%) Decompiled 6 functions in unknown_071730 --- .../unknown_071730/func_80070C9C.s | 33 --- .../unknown_071730/func_80070D10.s | 13 - .../unknown_071730/func_80070E90.s | 32 --- .../unknown_071730/func_800710B0.s | 40 ---- .../unknown_071730/func_80071140.s | 26 -- .../unknown_071730/func_80071440.s | 16 -- src/unknown_071730.c | 226 +++++++++++++++++- 7 files changed, 220 insertions(+), 166 deletions(-) delete mode 100644 asm/non_matchings/unknown_071730/func_80070C9C.s delete mode 100644 asm/non_matchings/unknown_071730/func_80070D10.s delete mode 100644 asm/non_matchings/unknown_071730/func_80070E90.s delete mode 100644 asm/non_matchings/unknown_071730/func_800710B0.s delete mode 100644 asm/non_matchings/unknown_071730/func_80071140.s delete mode 100644 asm/non_matchings/unknown_071730/func_80071440.s diff --git a/asm/non_matchings/unknown_071730/func_80070C9C.s b/asm/non_matchings/unknown_071730/func_80070C9C.s deleted file mode 100644 index 59b0d000..00000000 --- a/asm/non_matchings/unknown_071730/func_80070C9C.s +++ /dev/null @@ -1,33 +0,0 @@ -glabel func_80070C9C -/* 07189C 80070C9C 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0718A0 80070CA0 AFBF0014 */ sw $ra, 0x14($sp) -/* 0718A4 80070CA4 AFA40020 */ sw $a0, 0x20($sp) -/* 0718A8 80070CA8 14800008 */ bnez $a0, .L80070CCC -/* 0718AC 80070CAC AFA50024 */ sw $a1, 0x24($sp) -/* 0718B0 80070CB0 0C02DF44 */ jal func_800B7D10 -/* 0718B4 80070CB4 00000000 */ nop -/* 0718B8 80070CB8 8C440014 */ lw $a0, 0x14($v0) -/* 0718BC 80070CBC 8FA50020 */ lw $a1, 0x20($sp) -/* 0718C0 80070CC0 8FA60024 */ lw $a2, 0x24($sp) -/* 0718C4 80070CC4 0C02DD18 */ jal func_800B7460 -/* 0718C8 80070CC8 00000000 */ nop -.L80070CCC: -/* 0718CC 80070CCC 8FA50020 */ lw $a1, 0x20($sp) -/* 0718D0 80070CD0 8FA60024 */ lw $a2, 0x24($sp) -/* 0718D4 80070CD4 0C01C34F */ jal func_80070D3C -/* 0718D8 80070CD8 00002025 */ move $a0, $zero -/* 0718DC 80070CDC 14400008 */ bnez $v0, .L80070D00 -/* 0718E0 80070CE0 AFA2001C */ sw $v0, 0x1c($sp) -/* 0718E4 80070CE4 0C02DF44 */ jal func_800B7D10 -/* 0718E8 80070CE8 00000000 */ nop -/* 0718EC 80070CEC 8C440014 */ lw $a0, 0x14($v0) -/* 0718F0 80070CF0 8FA50020 */ lw $a1, 0x20($sp) -/* 0718F4 80070CF4 8FA60024 */ lw $a2, 0x24($sp) -/* 0718F8 80070CF8 0C02DD18 */ jal func_800B7460 -/* 0718FC 80070CFC 00000000 */ nop -.L80070D00: -/* 071900 80070D00 8FBF0014 */ lw $ra, 0x14($sp) -/* 071904 80070D04 8FA2001C */ lw $v0, 0x1c($sp) -/* 071908 80070D08 03E00008 */ jr $ra -/* 07190C 80070D0C 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/non_matchings/unknown_071730/func_80070D10.s b/asm/non_matchings/unknown_071730/func_80070D10.s deleted file mode 100644 index 6ed70f11..00000000 --- a/asm/non_matchings/unknown_071730/func_80070D10.s +++ /dev/null @@ -1,13 +0,0 @@ -glabel func_80070D10 -/* 071910 80070D10 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 071914 80070D14 00A03025 */ move $a2, $a1 -/* 071918 80070D18 00802825 */ move $a1, $a0 -/* 07191C 80070D1C AFBF0014 */ sw $ra, 0x14($sp) -/* 071920 80070D20 AFA40018 */ sw $a0, 0x18($sp) -/* 071924 80070D24 0C01C34F */ jal func_80070D3C -/* 071928 80070D28 00002025 */ move $a0, $zero -/* 07192C 80070D2C 8FBF0014 */ lw $ra, 0x14($sp) -/* 071930 80070D30 27BD0018 */ addiu $sp, $sp, 0x18 -/* 071934 80070D34 03E00008 */ jr $ra -/* 071938 80070D38 00000000 */ nop - diff --git a/asm/non_matchings/unknown_071730/func_80070E90.s b/asm/non_matchings/unknown_071730/func_80070E90.s deleted file mode 100644 index 06d48853..00000000 --- a/asm/non_matchings/unknown_071730/func_80070E90.s +++ /dev/null @@ -1,32 +0,0 @@ -glabel func_80070E90 -/* 071A90 80070E90 3C078012 */ lui $a3, %hi(D_801235C0) # $a3, 0x8012 -/* 071A94 80070E94 8CE735C0 */ lw $a3, %lo(D_801235C0)($a3) -/* 071A98 80070E98 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 071A9C 80070E9C 10E00011 */ beqz $a3, .L80070EE4 -/* 071AA0 80070EA0 AFBF0014 */ sw $ra, 0x14($sp) -/* 071AA4 80070EA4 3C0F8012 */ lui $t7, %hi(D_80123580) # $t7, 0x8012 -/* 071AA8 80070EA8 25EF3580 */ addiu $t7, %lo(D_80123580) # addiu $t7, $t7, 0x3580 -/* 071AAC 80070EAC 00077100 */ sll $t6, $a3, 4 -/* 071AB0 80070EB0 01CF1021 */ addu $v0, $t6, $t7 -.L80070EB4: -/* 071AB4 80070EB4 8C580008 */ lw $t8, 8($v0) -/* 071AB8 80070EB8 00000000 */ nop -/* 071ABC 80070EBC 14980006 */ bne $a0, $t8, .L80070ED8 -/* 071AC0 80070EC0 00000000 */ nop -/* 071AC4 80070EC4 00E02025 */ move $a0, $a3 -/* 071AC8 80070EC8 0C01C34F */ jal func_80070D3C -/* 071ACC 80070ECC 00003025 */ move $a2, $zero -/* 071AD0 80070ED0 10000006 */ b .L80070EEC -/* 071AD4 80070ED4 8FBF0014 */ lw $ra, 0x14($sp) -.L80070ED8: -/* 071AD8 80070ED8 24E7FFFF */ addiu $a3, $a3, -1 -/* 071ADC 80070EDC 14E0FFF5 */ bnez $a3, .L80070EB4 -/* 071AE0 80070EE0 2442FFF0 */ addiu $v0, $v0, -0x10 -.L80070EE4: -/* 071AE4 80070EE4 00001025 */ move $v0, $zero -/* 071AE8 80070EE8 8FBF0014 */ lw $ra, 0x14($sp) -.L80070EEC: -/* 071AEC 80070EEC 27BD0018 */ addiu $sp, $sp, 0x18 -/* 071AF0 80070EF0 03E00008 */ jr $ra -/* 071AF4 80070EF4 00000000 */ nop - diff --git a/asm/non_matchings/unknown_071730/func_800710B0.s b/asm/non_matchings/unknown_071730/func_800710B0.s deleted file mode 100644 index 80ee5e6b..00000000 --- a/asm/non_matchings/unknown_071730/func_800710B0.s +++ /dev/null @@ -1,40 +0,0 @@ -glabel func_800710B0 -/* 071CB0 800710B0 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 071CB4 800710B4 AFBF0024 */ sw $ra, 0x24($sp) -/* 071CB8 800710B8 AFB00018 */ sw $s0, 0x18($sp) -/* 071CBC 800710BC 00808025 */ move $s0, $a0 -/* 071CC0 800710C0 AFB20020 */ sw $s2, 0x20($sp) -/* 071CC4 800710C4 0C01BD44 */ jal func_8006F510 -/* 071CC8 800710C8 AFB1001C */ sw $s1, 0x1c($sp) -/* 071CCC 800710CC 3C018012 */ lui $at, %hi(D_80123DCC) # $at, 0x8012 -/* 071CD0 800710D0 AFA2002C */ sw $v0, 0x2c($sp) -/* 071CD4 800710D4 16000011 */ bnez $s0, .L8007111C -/* 071CD8 800710D8 AC303DCC */ sw $s0, %lo(D_80123DCC)($at) -/* 071CDC 800710DC 3C118012 */ lui $s1, %hi(D_80123DC8) # $s1, 0x8012 -/* 071CE0 800710E0 26313DC8 */ addiu $s1, %lo(D_80123DC8) # addiu $s1, $s1, 0x3dc8 -/* 071CE4 800710E4 8E300000 */ lw $s0, ($s1) -/* 071CE8 800710E8 3C128012 */ lui $s2, %hi(D_801235C8) # $s2, 0x8012 -/* 071CEC 800710EC 1A00000B */ blez $s0, .L8007111C -/* 071CF0 800710F0 265235C8 */ addiu $s2, %lo(D_801235C8) # addiu $s2, $s2, 0x35c8 -/* 071CF4 800710F4 2602FFFF */ addiu $v0, $s0, -1 -.L800710F8: -/* 071CF8 800710F8 000270C0 */ sll $t6, $v0, 3 -/* 071CFC 800710FC 024E7821 */ addu $t7, $s2, $t6 -/* 071D00 80071100 8DE40000 */ lw $a0, ($t7) -/* 071D04 80071104 0C01C49E */ jal func_80071278 -/* 071D08 80071108 AE220000 */ sw $v0, ($s1) -/* 071D0C 8007110C 8E300000 */ lw $s0, ($s1) -/* 071D10 80071110 00000000 */ nop -/* 071D14 80071114 1E00FFF8 */ bgtz $s0, .L800710F8 -/* 071D18 80071118 2602FFFF */ addiu $v0, $s0, -1 -.L8007111C: -/* 071D1C 8007111C 8FA4002C */ lw $a0, 0x2c($sp) -/* 071D20 80071120 0C01BD4F */ jal func_8006F53C -/* 071D24 80071124 00000000 */ nop -/* 071D28 80071128 8FBF0024 */ lw $ra, 0x24($sp) -/* 071D2C 8007112C 8FB00018 */ lw $s0, 0x18($sp) -/* 071D30 80071130 8FB1001C */ lw $s1, 0x1c($sp) -/* 071D34 80071134 8FB20020 */ lw $s2, 0x20($sp) -/* 071D38 80071138 03E00008 */ jr $ra -/* 071D3C 8007113C 27BD0030 */ addiu $sp, $sp, 0x30 - diff --git a/asm/non_matchings/unknown_071730/func_80071140.s b/asm/non_matchings/unknown_071730/func_80071140.s deleted file mode 100644 index 95fc90bb..00000000 --- a/asm/non_matchings/unknown_071730/func_80071140.s +++ /dev/null @@ -1,26 +0,0 @@ -glabel func_80071140 -/* 071D40 80071140 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 071D44 80071144 AFBF0014 */ sw $ra, 0x14($sp) -/* 071D48 80071148 0C01BD44 */ jal func_8006F510 -/* 071D4C 8007114C AFA40020 */ sw $a0, 0x20($sp) -/* 071D50 80071150 3C0E8012 */ lui $t6, %hi(D_80123DCC) # $t6, 0x8012 -/* 071D54 80071154 8DCE3DCC */ lw $t6, %lo(D_80123DCC)($t6) -/* 071D58 80071158 8FA40020 */ lw $a0, 0x20($sp) -/* 071D5C 8007115C 15C00005 */ bnez $t6, .L80071174 -/* 071D60 80071160 AFA2001C */ sw $v0, 0x1c($sp) -/* 071D64 80071164 0C01C49E */ jal func_80071278 -/* 071D68 80071168 00000000 */ nop -/* 071D6C 8007116C 10000004 */ b .L80071180 -/* 071D70 80071170 8FA4001C */ lw $a0, 0x1c($sp) -.L80071174: -/* 071D74 80071174 0C01C510 */ jal func_80071440 -/* 071D78 80071178 00000000 */ nop -/* 071D7C 8007117C 8FA4001C */ lw $a0, 0x1c($sp) -.L80071180: -/* 071D80 80071180 0C01BD4F */ jal func_8006F53C -/* 071D84 80071184 00000000 */ nop -/* 071D88 80071188 8FBF0014 */ lw $ra, 0x14($sp) -/* 071D8C 8007118C 27BD0020 */ addiu $sp, $sp, 0x20 -/* 071D90 80071190 03E00008 */ jr $ra -/* 071D94 80071194 00000000 */ nop - diff --git a/asm/non_matchings/unknown_071730/func_80071440.s b/asm/non_matchings/unknown_071730/func_80071440.s deleted file mode 100644 index 1f40f5f0..00000000 --- a/asm/non_matchings/unknown_071730/func_80071440.s +++ /dev/null @@ -1,16 +0,0 @@ -glabel func_80071440 -/* 072040 80071440 3C058012 */ lui $a1, %hi(D_80123DC8) # $a1, 0x8012 -/* 072044 80071444 24A53DC8 */ addiu $a1, %lo(D_80123DC8) # addiu $a1, $a1, 0x3dc8 -/* 072048 80071448 8CA20000 */ lw $v0, ($a1) -/* 07204C 8007144C 3C0F8012 */ lui $t7, %hi(D_801235C8) # $t7, 0x8012 -/* 072050 80071450 25EF35C8 */ addiu $t7, %lo(D_801235C8) # addiu $t7, $t7, 0x35c8 -/* 072054 80071454 000270C0 */ sll $t6, $v0, 3 -/* 072058 80071458 01CF1821 */ addu $v1, $t6, $t7 -/* 07205C 8007145C AC640000 */ sw $a0, ($v1) -/* 072060 80071460 3C188012 */ lui $t8, %hi(D_80123DCC) # $t8, 0x8012 -/* 072064 80071464 8F183DCC */ lw $t8, %lo(D_80123DCC)($t8) -/* 072068 80071468 24590001 */ addiu $t9, $v0, 1 -/* 07206C 8007146C ACB90000 */ sw $t9, ($a1) -/* 072070 80071470 03E00008 */ jr $ra -/* 072074 80071474 A0780004 */ sb $t8, 4($v1) - diff --git a/src/unknown_071730.c b/src/unknown_071730.c index 48268338..4bac24e2 100644 --- a/src/unknown_071730.c +++ b/src/unknown_071730.c @@ -4,19 +4,233 @@ #include "types.h" #include "macros.h" +/* Size: 0x8 bytes */ +typedef struct unk80070BE4_8_0 { + s16 unk0; + s16 unk2; + s32 unk4; +} unk80070BE4_8_0; + +/* Size: 0x14 bytes */ +typedef struct unk80070BE4_8 { + unk80070BE4_8_0 *unk0; + s32 unk4; + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; + u8 pad10[0x4]; +} unk80070BE4_8; + +/* Size: 0x10 bytes */ +typedef struct unk80070BE4 { + s32 unk0; + s32 unk4; + unk80070BE4_8 *unk8; + s32 size; +} unk80070BE4; + +extern unk80070BE4 D_80123580[12]; // unknown number of entries + +#ifndef _ALIGN16 + #define _ALIGN16(val) ((val) & 0xFFFFFFF0) + 0x10 +#endif + +extern s32 D_801235C0; + +/* Size: 0x8 bytes */ +typedef struct unk801235C8 { + u32 unk0; + s8 unk4; + u8 pad5[3]; +} unk801235C8; + +extern unk801235C8 D_801235C8[8]; + +extern s32 D_80123DC8; +extern s32 D_80123DCC; +extern unk80070BE4_8 D_8012D3F0; + +/* Unknown size */ +typedef struct unk800B7D10 { + u8 pad0[0x14]; + s32 unk14; +} unk800B7D10; + +unk800B7D10 *func_800B7D10(void); +void *func_80070D3C(s32, s32, s32); + +unk80070BE4_8 *func_80070BE4(unk80070BE4_8 *arg0, s32 size, s32 arg2); +void func_800710B0(s32); +void* func_80070C9C(s32, s32); +s32 *func_8006F510(void); +void func_8006F53C(s32*); + +void func_80071440(s32 arg0); + +#if 1 GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070B30.s") +#else +void func_80070B30(void) { + D_801235C0 = -1; + // Issue with a0 + func_80070BE4(&D_8012D3F0, 0x80400000 - (s32)(&D_8012D3F0), 1600); + func_800710B0(2); + D_80123DC8 = 0; +} +#endif + +#if 1 GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070B78.s") +#else +// Has stack issues +s32 *func_80070B78(s32 arg0, s32 arg1) { + s32 *temp, *temp2; + s32 temp3; + temp = func_8006F510(); + temp3 = arg0 + (arg1 * sizeof(unk80070BE4_8)); + temp2 = func_80070BE4((unk80070BE4_8 *)func_80070C9C(temp3, -1), temp3, arg1); + func_8006F53C(temp); + return temp2; +} +#endif + +#if 1 GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070BE4.s") -GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070C9C.s") -GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070D10.s") +#else +unk80070BE4_8 *func_80070BE4(unk80070BE4_8 *arg0, s32 size, s32 arg2) { + s32 i; + unk80070BE4 *temp; + unk80070BE4_8 *temp2; + unk80070BE4_8_0 *temp3; + + temp = &D_80123580[++D_801235C0]; + temp->unk0 = arg2; + temp->unk4 = 0; + temp->unk8 = arg0; + temp->size = size; + + for(i = 0; i < temp->unk0; i++) { + arg0[i].unkE = i; + } + + temp2 = temp->unk8; + temp3 = (unk80070BE4_8_0 *)&arg0[arg2]; + if((s32)temp3 & 0xF) { + temp2->unk0 = (unk80070BE4_8_0 *)_ALIGN16((s32)temp3); + } else { + temp2->unk0 = temp3; + } + + temp2->unk4 = size - (arg2 * sizeof(unk80070BE4_8)); + temp2->unk8 = 0; + temp2->unkA = -1; + temp2->unkC = -1; + temp->unk4++; + + return temp->unk8; +} +#endif + +void *func_80070C9C(s32 arg0, s32 arg1) { + void *temp_v0; + if (arg0 == 0) { + func_800B7460(func_800B7D10()->unk14, arg0, arg1); + } + temp_v0 = func_80070D3C(0, arg0, arg1); + if (temp_v0 == (void *)NULL) { + func_800B7460(func_800B7D10()->unk14, arg0, arg1); + } + return temp_v0; +} + +void func_80070D10(s32 arg0, s32 arg1) { + func_80070D3C(0, arg0, arg1); +} + +#if 1 GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070D3C.s") -GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070E90.s") +#else + +void *func_80070D3C(s32 arg0, s32 arg1, s32 arg2) { + unk80070BE4 *temp; + unk80070BE4_8 *temp2; + s32 phi_a0; + s32 phi_a2; + s32 phi_s0; + s32 *sp28; + + temp = &D_80123580[arg0]; + if ((temp->unk4 + 1) == temp->unk0) { + func_8006F53C(sp28); + } else { + if (arg1 & 0xF) { + arg1 = _ALIGN16(arg1); //(arg1 & -0x10) + 0x10; + } + phi_a0 = 0; + phi_a2 = 0x7FFFFFFF; + phi_s0 = -1; + while(phi_a0 != -1) { + temp2 = &temp->unk8[phi_a0]; + if (temp2->unk8 == 0 && temp2->unk4 >= arg1 && temp2->unk4 < phi_a2) { + phi_s0 = phi_a0; + phi_a2 = temp2->unk4; + } + phi_a0 = temp2->unkC; + } + if (phi_s0 != -1) { + func_8007178C(arg0, phi_s0, arg1, 1, 0, arg2); + func_8006F53C(sp28); + return (void *)(&temp->unk8[phi_s0]); + } + func_8006F53C(sp28); + } + return (void *)NULL; +} +#endif + +void *func_80070E90(unk80070BE4_8 *arg0, s32 arg1) { + s32 i; + for(i = D_801235C0; i != 0; i--) { + if (arg0 == D_80123580[i].unk8) { + return func_80070D3C(i, arg1, 0); + } + } + return (void *)NULL; +} + GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80070EF8.s") -GLOBAL_ASM("asm/non_matchings/unknown_071730/func_800710B0.s") -GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80071140.s") + +void func_800710B0(s32 arg0) { + s32 *sp2C = func_8006F510(); + D_80123DCC = arg0; + if (arg0 == 0) { + while (D_80123DC8 > 0) { + func_80071278(D_801235C8[--D_80123DC8].unk0); + } + } + func_8006F53C(sp2C); +} + +void func_80071140(s32 arg0) { + s32 *sp1C = func_8006F510(); + if (D_80123DCC == 0) { + func_80071278(arg0); + } else { + func_80071440(arg0); + } + func_8006F53C(sp1C); +} + GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80071198.s") GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80071278.s") -GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80071440.s") + +void func_80071440(s32 arg0) { + D_801235C8[D_80123DC8].unk0 = arg0; + D_801235C8[D_80123DC8].unk4 = D_80123DCC; + D_80123DC8++; +} + GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80071478.s") GLOBAL_ASM("asm/non_matchings/unknown_071730/func_80071538.s") GLOBAL_ASM("asm/non_matchings/unknown_071730/func_800715EC.s")