diff --git a/asm/Kyoto/DolphinCMemoryCardSys.s b/asm/Kyoto/DolphinCMemoryCardSys.s index e585ac7a..ed952241 100644 --- a/asm/Kyoto/DolphinCMemoryCardSys.s +++ b/asm/Kyoto/DolphinCMemoryCardSys.s @@ -333,8 +333,8 @@ lbl_8034D85C: /* 8034D884 0034A7E4 38 21 00 80 */ addi r1, r1, 0x80 /* 8034D888 0034A7E8 4E 80 00 20 */ blr -.global GetSerialNo__14CMemoryCardSysFiRx -GetSerialNo__14CMemoryCardSysFiRx: +.global GetSerialNo__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPortRx +GetSerialNo__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPortRx: /* 8034D88C 0034A7EC 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8034D890 0034A7F0 7C 08 02 A6 */ mflr r0 /* 8034D894 0034A7F4 90 01 00 14 */ stw r0, 0x14(r1) diff --git a/asm/MetroidPrime/CMemoryCardDriver.s b/asm/MetroidPrime/CMemoryCardDriver.s index ee22813f..134a7edd 100644 --- a/asm/MetroidPrime/CMemoryCardDriver.s +++ b/asm/MetroidPrime/CMemoryCardDriver.s @@ -2612,7 +2612,7 @@ UpdateCardCheck__17CMemoryCardDriverF11ECardResult: /* 8024E4E4 0024B444 41 82 00 48 */ beq lbl_8024E52C /* 8024E4E8 0024B448 80 7F 00 00 */ lwz r3, 0(r31) /* 8024E4EC 0024B44C 38 9F 00 28 */ addi r4, r31, 0x28 -/* 8024E4F0 0024B450 48 0F F3 9D */ bl GetSerialNo__14CMemoryCardSysFiRx +/* 8024E4F0 0024B450 48 0F F3 9D */ bl GetSerialNo__14CMemoryCardSysFQ214CMemoryCardSys15EMemoryCardPortRx /* 8024E4F4 0024B454 2C 03 00 00 */ cmpwi r3, 0 /* 8024E4F8 0024B458 41 82 00 34 */ beq lbl_8024E52C /* 8024E4FC 0024B45C 7F E3 FB 78 */ mr r3, r31 diff --git a/include/Kyoto/CMemoryCardSys.hpp b/include/Kyoto/CMemoryCardSys.hpp index cdc915f5..dd9554b6 100644 --- a/include/Kyoto/CMemoryCardSys.hpp +++ b/include/Kyoto/CMemoryCardSys.hpp @@ -53,6 +53,7 @@ public: static ECardResult GetResultCode(int); static ProbeResults IsMemoryCardInserted(EMemoryCardPort); + static ECardResult GetSerialNo(EMemoryCardPort port, long long& serialOut); void Initialize(); diff --git a/include/MetroidPrime/CMemoryCardDriver.hpp b/include/MetroidPrime/CMemoryCardDriver.hpp index 19e3ef8f..3ba58f55 100644 --- a/include/MetroidPrime/CMemoryCardDriver.hpp +++ b/include/MetroidPrime/CMemoryCardDriver.hpp @@ -113,7 +113,7 @@ private: int x18_cardFreeBytes; int x1c_cardFreeFiles; uint x20_fileTime; - u64 x28_cardSerial; + long long x28_cardSerial; rstl::reserved_vector< u8, 174 > x30_systemData; rstl::reserved_vector< rstl::auto_ptr< SGameFileSlot >, 3 > xe4_fileSlots; rstl::reserved_vector< rstl::pair< EFileState, SMemoryCardFileInfo >, 2 > x100_mcFileInfos; diff --git a/src/MetroidPrime/CMemoryCardDriver.cpp b/src/MetroidPrime/CMemoryCardDriver.cpp index ce3f089a..a8d2d168 100644 --- a/src/MetroidPrime/CMemoryCardDriver.cpp +++ b/src/MetroidPrime/CMemoryCardDriver.cpp @@ -143,7 +143,23 @@ void CMemoryCardDriver::UpdateMountCard(ECardResult result) { } } -void CMemoryCardDriver::UpdateCardCheck(ECardResult) {} +void CMemoryCardDriver::UpdateCardCheck(ECardResult result) { + if (result == kCR_READY) { + x10_state = kS_CardCheckDone; + if (!GetCardFreeBytes()) + return; + if (CMemoryCardSys::GetSerialNo(x0_cardPort, x28_cardSerial) == kCR_READY) + return; + NoCardFound(); + + } else if (result == kCR_BROKEN) { + x10_state = kS_CardCheckFailed; + x14_error = kE_CardBroken; + + } else { + HandleCardError(result, kS_CardCheckFailed); + } +} void CMemoryCardDriver::UpdateFileRead(ECardResult) {}