From 03a49bb75e570361b28763d891c3645a0519b789 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 11 Oct 2022 10:02:35 -0700 Subject: [PATCH] Match CMemoryCardDriver::GetCardFreeBytes --- asm/Kyoto/DolphinCMemoryCardSys.s | 4 ++-- asm/MetroidPrime/CMemoryCardDriver.s | 2 +- include/Kyoto/CMemoryCardSys.hpp | 1 + src/MetroidPrime/CMemoryCardDriver.cpp | 9 ++++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/asm/Kyoto/DolphinCMemoryCardSys.s b/asm/Kyoto/DolphinCMemoryCardSys.s index 2acf1d22..4435b232 100644 --- a/asm/Kyoto/DolphinCMemoryCardSys.s +++ b/asm/Kyoto/DolphinCMemoryCardSys.s @@ -1106,8 +1106,8 @@ __ct__19SMemoryCardFileInfoFiRCQ24rstl6string: /* 8034E2F0 0034B250 38 21 00 10 */ addi r1, r1, 0x10 /* 8034E2F4 0034B254 4E 80 00 20 */ blr -.global GetNumFreeBytes__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPortRUi -GetNumFreeBytes__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPortRUi: +.global GetNumFreeBytes__14CMemoryCardSysF15EMemoryCardPortRUiRUi +GetNumFreeBytes__14CMemoryCardSysF15EMemoryCardPortRUiRUi: /* 8034E2F8 0034B258 94 21 FF E0 */ stwu r1, -0x20(r1) /* 8034E2FC 0034B25C 7C 08 02 A6 */ mflr r0 /* 8034E300 0034B260 90 01 00 24 */ stw r0, 0x24(r1) diff --git a/asm/MetroidPrime/CMemoryCardDriver.s b/asm/MetroidPrime/CMemoryCardDriver.s index d6f269f4..de24e12d 100644 --- a/asm/MetroidPrime/CMemoryCardDriver.s +++ b/asm/MetroidPrime/CMemoryCardDriver.s @@ -80,7 +80,7 @@ GetCardFreeBytes__17CMemoryCardDriverFv: /* 8024C2A4 00249204 38 9F 00 18 */ addi r4, r31, 0x18 /* 8024C2A8 00249208 80 63 00 00 */ lwz r3, 0(r3) /* 8024C2AC 0024920C 38 BF 00 1C */ addi r5, r31, 0x1c -/* 8024C2B0 00249210 48 10 20 49 */ bl GetNumFreeBytes__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPortRUi +/* 8024C2B0 00249210 48 10 20 49 */ bl GetNumFreeBytes__14CMemoryCardSysF15EMemoryCardPortRUiRUi /* 8024C2B4 00249214 2C 03 00 00 */ cmpwi r3, 0 /* 8024C2B8 00249218 41 82 00 14 */ beq lbl_8024C2CC /* 8024C2BC 0024921C 7F E3 FB 78 */ mr r3, r31 diff --git a/include/Kyoto/CMemoryCardSys.hpp b/include/Kyoto/CMemoryCardSys.hpp index 36db87ca..11ee75ab 100644 --- a/include/Kyoto/CMemoryCardSys.hpp +++ b/include/Kyoto/CMemoryCardSys.hpp @@ -96,6 +96,7 @@ public: static ECardResult GetSerialNo(EMemoryCardPort port, long long& serialOut); static void UnmountCard(EMemoryCardPort); static ECardResult Rename(EMemoryCardPort, const rstl::string&, const rstl::string&); + static ECardResult GetNumFreeBytes(EMemoryCardPort port, uint& freeBytes, uint& freeFiles); void Initialize(); diff --git a/src/MetroidPrime/CMemoryCardDriver.cpp b/src/MetroidPrime/CMemoryCardDriver.cpp index 3e9a6593..7155eafc 100644 --- a/src/MetroidPrime/CMemoryCardDriver.cpp +++ b/src/MetroidPrime/CMemoryCardDriver.cpp @@ -789,4 +789,11 @@ const CGameState::GameFileStateInfo* CMemoryCardDriver::GetGameFileStateInfo(int return nullptr; }; -bool CMemoryCardDriver::GetCardFreeBytes() { return false; } +bool CMemoryCardDriver::GetCardFreeBytes() { + if (CMemoryCardSys::GetNumFreeBytes(x0_cardPort, x18_cardFreeBytes, x1c_cardFreeFiles) != kCR_READY) { + NoCardFound(); + return false; + } + + return true; + }