From df01c5f965aff9698f6d4b46514baeef908e54be Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 11 Oct 2022 15:30:49 +0300 Subject: [PATCH] Match CMemoryCardDriver::StartCardFormat Former-commit-id: 408d89630c0a3d26b1be0f80850b914510d899f9 --- asm/Kyoto/DolphinCMemoryCardSys.s | 4 ++-- asm/MetroidPrime/CMemoryCardDriver.s | 2 +- include/Kyoto/CMemoryCardSys.hpp | 1 + src/MetroidPrime/CMemoryCardDriver.cpp | 8 +++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/asm/Kyoto/DolphinCMemoryCardSys.s b/asm/Kyoto/DolphinCMemoryCardSys.s index a2c7790f..3baec4f8 100644 --- a/asm/Kyoto/DolphinCMemoryCardSys.s +++ b/asm/Kyoto/DolphinCMemoryCardSys.s @@ -1129,8 +1129,8 @@ GetNumFreeBytes__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPortRUi: /* 8034E340 0034B2A0 38 21 00 20 */ addi r1, r1, 0x20 /* 8034E344 0034B2A4 4E 80 00 20 */ blr -.global FormatCard__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPort -FormatCard__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPort: +.global FormatCard__14CMemoryCardSysF15EMemoryCardPort +FormatCard__14CMemoryCardSysF15EMemoryCardPort: /* 8034E348 0034B2A8 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8034E34C 0034B2AC 7C 08 02 A6 */ mflr r0 /* 8034E350 0034B2B0 38 80 00 00 */ li r4, 0 diff --git a/asm/MetroidPrime/CMemoryCardDriver.s b/asm/MetroidPrime/CMemoryCardDriver.s index 6191ed6c..b5dff25b 100644 --- a/asm/MetroidPrime/CMemoryCardDriver.s +++ b/asm/MetroidPrime/CMemoryCardDriver.s @@ -1345,7 +1345,7 @@ StartCardFormat__17CMemoryCardDriverFv: /* 8024D3FC 0024A35C 38 00 00 25 */ li r0, 0x25 /* 8024D400 0024A360 90 03 00 10 */ stw r0, 0x10(r3) /* 8024D404 0024A364 80 63 00 00 */ lwz r3, 0(r3) -/* 8024D408 0024A368 48 10 0F 41 */ bl FormatCard__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPort +/* 8024D408 0024A368 48 10 0F 41 */ bl FormatCard__14CMemoryCardSysF15EMemoryCardPort /* 8024D40C 0024A36C 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D410 0024A370 41 82 00 0C */ beq lbl_8024D41C /* 8024D414 0024A374 7F E3 FB 78 */ mr r3, r31 diff --git a/include/Kyoto/CMemoryCardSys.hpp b/include/Kyoto/CMemoryCardSys.hpp index b0c6ede5..78f8d0cc 100644 --- a/include/Kyoto/CMemoryCardSys.hpp +++ b/include/Kyoto/CMemoryCardSys.hpp @@ -75,6 +75,7 @@ public: static ECardResult GetStatus(EMemoryCardPort port, int fileNo, CardStat& statOut); static ECardResult DeleteFile(EMemoryCardPort port, const rstl::string& name); static ECardResult FastDeleteFile(EMemoryCardPort port, int fileNo); + static ECardResult FormatCard(EMemoryCardPort port); 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 c1d7dff7..3c0b2925 100644 --- a/src/MetroidPrime/CMemoryCardDriver.cpp +++ b/src/MetroidPrime/CMemoryCardDriver.cpp @@ -630,7 +630,13 @@ void CMemoryCardDriver::StartFileDeleteAltTransactional() { UpdateFileAltDeleteTransactional(result); } -void CMemoryCardDriver::StartCardFormat() {} +void CMemoryCardDriver::StartCardFormat() { + x14_error = kE_OK; + x10_state = kS_CardFormat; + ECardResult result = CMemoryCardSys::FormatCard(x0_cardPort); + if (result != kCR_READY) + UpdateCardFormat(result); +} void CMemoryCardDriver::InitializeFileInfo() {}