From 7ca5b720aae2294e0cd823ede8041b3af7a95de0 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 11 Oct 2022 14:50:30 +0300 Subject: [PATCH] Match CMemoryCardDriver::StartFileDeleteBad --- asm/Kyoto/DolphinCMemoryCardSys.s | 4 ++-- asm/MetroidPrime/CMemoryCardDriver.s | 4 ++-- include/Kyoto/CMemoryCardSys.hpp | 1 + src/MetroidPrime/CMemoryCardDriver.cpp | 17 ++++++++++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/asm/Kyoto/DolphinCMemoryCardSys.s b/asm/Kyoto/DolphinCMemoryCardSys.s index 37deac46..f39cd4e6 100644 --- a/asm/Kyoto/DolphinCMemoryCardSys.s +++ b/asm/Kyoto/DolphinCMemoryCardSys.s @@ -858,8 +858,8 @@ Close__19SMemoryCardFileInfoFv: /* 8034DF84 0034AEE4 38 21 00 10 */ addi r1, r1, 0x10 /* 8034DF88 0034AEE8 4E 80 00 20 */ blr -.global FastDeleteFile__14CMemoryCardSysFii -FastDeleteFile__14CMemoryCardSysFii: +.global FastDeleteFile__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPorti +FastDeleteFile__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPorti: /* 8034DF8C 0034AEEC 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8034DF90 0034AEF0 7C 08 02 A6 */ mflr r0 /* 8034DF94 0034AEF4 38 A0 00 00 */ li r5, 0 diff --git a/asm/MetroidPrime/CMemoryCardDriver.s b/asm/MetroidPrime/CMemoryCardDriver.s index 1faa2ff1..0625db8e 100644 --- a/asm/MetroidPrime/CMemoryCardDriver.s +++ b/asm/MetroidPrime/CMemoryCardDriver.s @@ -1793,7 +1793,7 @@ StartFileDeleteAlt__17CMemoryCardDriverFv: /* 8024DA14 0024A974 48 10 10 91 */ bl GetFileNo__19SMemoryCardFileInfoCFv /* 8024DA18 0024A978 7C 64 1B 78 */ mr r4, r3 /* 8024DA1C 0024A97C 80 7F 00 00 */ lwz r3, 0(r31) -/* 8024DA20 0024A980 48 10 05 6D */ bl FastDeleteFile__14CMemoryCardSysFii +/* 8024DA20 0024A980 48 10 05 6D */ bl FastDeleteFile__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPorti /* 8024DA24 0024A984 7C 64 1B 79 */ or. r4, r3, r3 /* 8024DA28 0024A988 41 82 00 0C */ beq lbl_8024DA34 /* 8024DA2C 0024A98C 7F E3 FB 78 */ mr r3, r31 @@ -1829,7 +1829,7 @@ lbl_8024DA7C: /* 8024DA90 0024A9F0 48 10 10 15 */ bl GetFileNo__19SMemoryCardFileInfoCFv /* 8024DA94 0024A9F4 7C 64 1B 78 */ mr r4, r3 /* 8024DA98 0024A9F8 80 7F 00 00 */ lwz r3, 0(r31) -/* 8024DA9C 0024A9FC 48 10 04 F1 */ bl FastDeleteFile__14CMemoryCardSysFii +/* 8024DA9C 0024A9FC 48 10 04 F1 */ bl FastDeleteFile__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPorti /* 8024DAA0 0024AA00 7C 64 1B 79 */ or. r4, r3, r3 /* 8024DAA4 0024AA04 41 82 00 1C */ beq lbl_8024DAC0 /* 8024DAA8 0024AA08 7F E3 FB 78 */ mr r3, r31 diff --git a/include/Kyoto/CMemoryCardSys.hpp b/include/Kyoto/CMemoryCardSys.hpp index f4c5f917..83bc852a 100644 --- a/include/Kyoto/CMemoryCardSys.hpp +++ b/include/Kyoto/CMemoryCardSys.hpp @@ -71,6 +71,7 @@ public: static ECardResult MountCard(EMemoryCardPort port); static ECardResult CheckCard(EMemoryCardPort port); static ECardResult GetStatus(EMemoryCardPort port, int fileNo, CardStat& statOut); + static ECardResult FastDeleteFile(EMemoryCardPort port, int fileNo); static ProbeResults IsMemoryCardInserted(EMemoryCardPort); static ECardResult GetSerialNo(EMemoryCardPort port, long long& serialOut); diff --git a/src/MetroidPrime/CMemoryCardDriver.cpp b/src/MetroidPrime/CMemoryCardDriver.cpp index c74b012f..1a8f7001 100644 --- a/src/MetroidPrime/CMemoryCardDriver.cpp +++ b/src/MetroidPrime/CMemoryCardDriver.cpp @@ -516,7 +516,22 @@ void CMemoryCardDriver::IndexFiles() { } } -void CMemoryCardDriver::StartFileDeleteBad() {} +void CMemoryCardDriver::StartFileDeleteBad() { + x14_error = kE_OK; + x10_state = kS_FileDeleteBad; + + for (int idx = 0; idx < x100_mcFileInfos.capacity(); ++idx) { + rstl::pair< EFileState, SMemoryCardFileInfo >& info = x100_mcFileInfos[idx]; + if (info.first == kFS_BadFile) { + x194_fileIdx = idx; + ECardResult result = CMemoryCardSys::FastDeleteFile(x0_cardPort, info.second.GetFileNo()); + if (result != kCR_READY) { + UpdateFileDeleteBad(result); + } + return; + } + } +} void CMemoryCardDriver::StartFileDeleteAlt() {}