From 4c20967422b7a9f6fcbd6f86286120626731896c Mon Sep 17 00:00:00 2001 From: Faschz Date: Fri, 17 Dec 2021 12:11:53 -0600 Subject: [PATCH] Decomp func_800762C8 (#200) --- .../controller_pak/func_800762C8.s | 53 ------------------- src/controller_pak.c | 40 ++++++-------- 2 files changed, 15 insertions(+), 78 deletions(-) delete mode 100644 asm/non_matchings/controller_pak/func_800762C8.s diff --git a/asm/non_matchings/controller_pak/func_800762C8.s b/asm/non_matchings/controller_pak/func_800762C8.s deleted file mode 100644 index e953a459..00000000 --- a/asm/non_matchings/controller_pak/func_800762C8.s +++ /dev/null @@ -1,53 +0,0 @@ -glabel func_800762C8 -/* 076EC8 800762C8 27BDFFB0 */ addiu $sp, $sp, -0x50 -/* 076ECC 800762CC AFBF0024 */ sw $ra, 0x24($sp) -/* 076ED0 800762D0 AFB0001C */ sw $s0, 0x1c($sp) -/* 076ED4 800762D4 00808025 */ move $s0, $a0 -/* 076ED8 800762D8 AFB10020 */ sw $s1, 0x20($sp) -/* 076EDC 800762DC 0C01D637 */ jal func_800758DC -/* 076EE0 800762E0 AFA50054 */ sw $a1, 0x54($sp) -/* 076EE4 800762E4 10400006 */ beqz $v0, .L80076300 -/* 076EE8 800762E8 00408825 */ move $s1, $v0 -/* 076EEC 800762EC 0C01D6BB */ jal func_80075AEC -/* 076EF0 800762F0 02002025 */ move $a0, $s0 -/* 076EF4 800762F4 00107780 */ sll $t6, $s0, 0x1e -/* 076EF8 800762F8 1000001E */ b .L80076374 -/* 076EFC 800762FC 01D11025 */ or $v0, $t6, $s1 -.L80076300: -/* 076F00 80076300 0010C080 */ sll $t8, $s0, 2 -/* 076F04 80076304 0310C023 */ subu $t8, $t8, $s0 -/* 076F08 80076308 0018C080 */ sll $t8, $t8, 2 -/* 076F0C 8007630C 0310C021 */ addu $t8, $t8, $s0 -/* 076F10 80076310 3C198012 */ lui $t9, %hi(pfs) # $t9, 0x8012 -/* 076F14 80076314 00108F80 */ sll $s1, $s0, 0x1e -/* 076F18 80076318 27394018 */ addiu $t9, %lo(pfs) # addiu $t9, $t9, 0x4018 -/* 076F1C 8007631C 0018C0C0 */ sll $t8, $t8, 3 -/* 076F20 80076320 362F0009 */ ori $t7, $s1, 9 -/* 076F24 80076324 03192021 */ addu $a0, $t8, $t9 -/* 076F28 80076328 8FA50054 */ lw $a1, 0x54($sp) -/* 076F2C 8007632C 01E08825 */ move $s1, $t7 -/* 076F30 80076330 AFA40028 */ sw $a0, 0x28($sp) -/* 076F34 80076334 0C034160 */ jal osPfsFileState -/* 076F38 80076338 27A60030 */ addiu $a2, $sp, 0x30 -/* 076F3C 8007633C 8FA40028 */ lw $a0, 0x28($sp) -/* 076F40 80076340 14400009 */ bnez $v0, .L80076368 -/* 076F44 80076344 27A7003E */ addiu $a3, $sp, 0x3e -/* 076F48 80076348 97A50038 */ lhu $a1, 0x38($sp) -/* 076F4C 8007634C 8FA60034 */ lw $a2, 0x34($sp) -/* 076F50 80076350 27A8003A */ addiu $t0, $sp, 0x3a -/* 076F54 80076354 0C03421C */ jal osPfsDeleteFile -/* 076F58 80076358 AFA80010 */ sw $t0, 0x10($sp) -/* 076F5C 8007635C 14400002 */ bnez $v0, .L80076368 -/* 076F60 80076360 00000000 */ nop -/* 076F64 80076364 00008825 */ move $s1, $zero -.L80076368: -/* 076F68 80076368 0C01D6BB */ jal func_80075AEC -/* 076F6C 8007636C 02002025 */ move $a0, $s0 -/* 076F70 80076370 02201025 */ move $v0, $s1 -.L80076374: -/* 076F74 80076374 8FBF0024 */ lw $ra, 0x24($sp) -/* 076F78 80076378 8FB0001C */ lw $s0, 0x1c($sp) -/* 076F7C 8007637C 8FB10020 */ lw $s1, 0x20($sp) -/* 076F80 80076380 03E00008 */ jr $ra -/* 076F84 80076384 27BD0050 */ addiu $sp, $sp, 0x50 - diff --git a/src/controller_pak.c b/src/controller_pak.c index bd326e81..6ff6028f 100644 --- a/src/controller_pak.c +++ b/src/controller_pak.c @@ -493,38 +493,28 @@ s32 func_80076194(s32 controllerIndex, s32 *arg1, s32 *arg2) { return phi_v1; } -#ifdef NON_EQUIVALENT -// regalloc & stack issues -// Rename delete_file_from_controller_pak? s32 func_800762C8(s32 controllerIndex, s32 fileNum) { - s16 sp3E; - s16 sp3A; - s32 sp30; - s32 sp34; - u16 sp38; - s32 temp_v0; - OSPfs *temp_a0; + OSPfsState state; + s32 ret; - temp_v0 = func_800758DC(); - if (temp_v0 != 0) { + ret = func_800758DC(controllerIndex); + if (ret != 0) { func_80075AEC(controllerIndex); - return (controllerIndex << 0x1E) | temp_v0; + return (controllerIndex << 0x1E) | ret; } - temp_v0 = controllerIndex << 0x1E; - temp_a0 = &pfs[controllerIndex]; - temp_v0 |= 9; - if (osPfsFileState(temp_a0, fileNum, &sp30) == 0) { - if (osPfsDeleteFile(temp_a0, sp38, sp34, &sp3E, &sp3A) == 0) { - temp_v0 = 0; + + ret = (controllerIndex << 0x1E) | 9; + + if (osPfsFileState(&pfs[controllerIndex], fileNum, &state) == 0) { + if (osPfsDeleteFile(&pfs[controllerIndex], state.company_code, state.game_code, state.game_name, state.ext_name) == 0) { + ret = 0; } } - func_80075AEC(controllerIndex); - return temp_v0; -} -#else -GLOBAL_ASM("asm/non_matchings/controller_pak/func_800762C8.s") -#endif + func_80075AEC(controllerIndex); + + return ret; +} GLOBAL_ASM("asm/non_matchings/controller_pak/func_80076388.s") GLOBAL_ASM("asm/non_matchings/controller_pak/func_800764E8.s")