Add almost matched CMemoryCardDriver::UpdateFileRead

This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-11 02:22:28 +03:00
parent 9fe421822a
commit 711a67cc54
No known key found for this signature in database
GPG Key ID: E224F951761145F8
4 changed files with 69 additions and 36 deletions

View File

@ -838,8 +838,8 @@ Close__13CCardFileInfoFv:
/* 8034DF40 0034AEA0 38 21 00 10 */ addi r1, r1, 0x10 /* 8034DF40 0034AEA0 38 21 00 10 */ addi r1, r1, 0x10
/* 8034DF44 0034AEA4 4E 80 00 20 */ blr /* 8034DF44 0034AEA4 4E 80 00 20 */ blr
.global Close__19SMemoryCardFileInfo .global Close__19SMemoryCardFileInfoFv
Close__19SMemoryCardFileInfo: Close__19SMemoryCardFileInfoFv:
/* 8034DF48 0034AEA8 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8034DF48 0034AEA8 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8034DF4C 0034AEAC 7C 08 02 A6 */ mflr r0 /* 8034DF4C 0034AEAC 7C 08 02 A6 */ mflr r0
/* 8034DF50 0034AEB0 90 01 00 14 */ stw r0, 0x14(r1) /* 8034DF50 0034AEB0 90 01 00 14 */ stw r0, 0x14(r1)

View File

@ -1904,7 +1904,7 @@ lbl_8024DB90:
/* 8024DB98 0024AAF8 48 00 01 60 */ b lbl_8024DCF8 /* 8024DB98 0024AAF8 48 00 01 60 */ b lbl_8024DCF8
lbl_8024DB9C: lbl_8024DB9C:
/* 8024DB9C 0024AAFC 38 7E 00 04 */ addi r3, r30, 4 /* 8024DB9C 0024AAFC 38 7E 00 04 */ addi r3, r30, 4
/* 8024DBA0 0024AB00 48 10 03 A9 */ bl Close__19SMemoryCardFileInfo /* 8024DBA0 0024AB00 48 10 03 A9 */ bl Close__19SMemoryCardFileInfoFv
/* 8024DBA4 0024AB04 2C 03 FF FD */ cmpwi r3, -3 /* 8024DBA4 0024AB04 2C 03 FF FD */ cmpwi r3, -3
/* 8024DBA8 0024AB08 40 82 00 1C */ bne lbl_8024DBC4 /* 8024DBA8 0024AB08 40 82 00 1C */ bne lbl_8024DBC4
/* 8024DBAC 0024AB0C 7F E3 FB 78 */ mr r3, r31 /* 8024DBAC 0024AB0C 7F E3 FB 78 */ mr r3, r31
@ -2535,7 +2535,7 @@ UpdateFileRead__17CMemoryCardDriverF11ECardResult:
/* 8024E3D4 0024B334 1C 60 00 48 */ mulli r3, r0, 0x48 /* 8024E3D4 0024B334 1C 60 00 48 */ mulli r3, r0, 0x48
/* 8024E3D8 0024B338 38 63 00 04 */ addi r3, r3, 4 /* 8024E3D8 0024B338 38 63 00 04 */ addi r3, r3, 4
/* 8024E3DC 0024B33C 7C 7D 1A 14 */ add r3, r29, r3 /* 8024E3DC 0024B33C 7C 7D 1A 14 */ add r3, r29, r3
/* 8024E3E0 0024B340 48 0F FB 69 */ bl Close__19SMemoryCardFileInfo /* 8024E3E0 0024B340 48 0F FB 69 */ bl Close__19SMemoryCardFileInfoFv
/* 8024E3E4 0024B344 2C 03 00 00 */ cmpwi r3, 0 /* 8024E3E4 0024B344 2C 03 00 00 */ cmpwi r3, 0
/* 8024E3E8 0024B348 41 82 00 10 */ beq lbl_8024E3F8 /* 8024E3E8 0024B348 41 82 00 10 */ beq lbl_8024E3F8
/* 8024E3EC 0024B34C 7F E3 FB 78 */ mr r3, r31 /* 8024E3EC 0024B34C 7F E3 FB 78 */ mr r3, r31

View File

@ -117,7 +117,7 @@ private:
rstl::reserved_vector< u8, 174 > x30_systemData; rstl::reserved_vector< u8, 174 > x30_systemData;
rstl::reserved_vector< rstl::auto_ptr< SGameFileSlot >, 3 > xe4_fileSlots; rstl::reserved_vector< rstl::auto_ptr< SGameFileSlot >, 3 > xe4_fileSlots;
rstl::reserved_vector< rstl::pair< EFileState, SMemoryCardFileInfo >, 2 > x100_mcFileInfos; rstl::reserved_vector< rstl::pair< EFileState, SMemoryCardFileInfo >, 2 > x100_mcFileInfos;
u32 x194_fileIdx; int x194_fileIdx;
rstl::single_ptr< CMemoryCardSys::CCardFileInfo > x198_fileInfo; rstl::single_ptr< CMemoryCardSys::CCardFileInfo > x198_fileInfo;
bool x19c_; bool x19c_;
bool x19d_importPersistent; bool x19d_importPersistent;
@ -154,6 +154,8 @@ public:
void NoCardFound(); void NoCardFound();
void IndexFiles(); void IndexFiles();
void StartFileDeleteBad(); void StartFileDeleteBad();
void StartFileDeleteAlt();
void StartFileRead();
void StartFileCreate(); void StartFileCreate();
void StartFileWrite(); void StartFileWrite();
void StartFileCreateTransactional(); void StartFileCreateTransactional();

View File

@ -6,8 +6,8 @@ bool CMemoryCardDriver::IsCardBusy(EState) { return false; }
bool CMemoryCardDriver::IsCardWriting(EState) { return false; } bool CMemoryCardDriver::IsCardWriting(EState) { return false; }
CMemoryCardDriver::CMemoryCardDriver(CMemoryCardSys::EMemoryCardPort cardPort, CAssetId saveBanner, CAssetId saveIcon0, CAssetId saveIcon1, CMemoryCardDriver::CMemoryCardDriver(CMemoryCardSys::EMemoryCardPort cardPort, CAssetId saveBanner,
bool importPersistent) CAssetId saveIcon0, CAssetId saveIcon1, bool importPersistent)
: x0_cardPort(cardPort) : x0_cardPort(cardPort)
, x4_saveBanner(saveBanner) , x4_saveBanner(saveBanner)
, x8_saveIcon0(saveIcon0) , x8_saveIcon0(saveIcon0)
@ -25,21 +25,14 @@ CMemoryCardDriver::CMemoryCardDriver(CMemoryCardSys::EMemoryCardPort cardPort, C
, x194_fileIdx(-1) , x194_fileIdx(-1)
, x198_fileInfo(nullptr) , x198_fileInfo(nullptr)
, x19c_(false) , x19c_(false)
, x19d_importPersistent(importPersistent) , x19d_importPersistent(importPersistent) {
{
x100_mcFileInfos.push_back(rstl::pair< EFileState, SMemoryCardFileInfo >( x100_mcFileInfos.push_back(rstl::pair< EFileState, SMemoryCardFileInfo >(
kFS_Unknown, kFS_Unknown, SMemoryCardFileInfo(x0_cardPort, rstl::string_l("MetroidPrime A"))));
SMemoryCardFileInfo(x0_cardPort, rstl::string_l("MetroidPrime A"))
));
x100_mcFileInfos.push_back(rstl::pair< EFileState, SMemoryCardFileInfo >( x100_mcFileInfos.push_back(rstl::pair< EFileState, SMemoryCardFileInfo >(
kFS_Unknown, kFS_Unknown, SMemoryCardFileInfo(x0_cardPort, rstl::string_l("MetroidPrime B"))));
SMemoryCardFileInfo(x0_cardPort, rstl::string_l("MetroidPrime B"))
));
} }
void CMemoryCardDriver::ClearFileInfo() { void CMemoryCardDriver::ClearFileInfo() { x198_fileInfo = nullptr; }
x198_fileInfo = nullptr;
}
CMemoryCardDriver::~CMemoryCardDriver() {} CMemoryCardDriver::~CMemoryCardDriver() {}
@ -161,7 +154,41 @@ void CMemoryCardDriver::UpdateCardCheck(ECardResult result) {
} }
} }
void CMemoryCardDriver::UpdateFileRead(ECardResult) {} void CMemoryCardDriver::UpdateFileRead(ECardResult result) {
if (result == kCR_READY) {
ECardResult readRes = x100_mcFileInfos[x194_fileIdx].second.TryFileRead();
if (x100_mcFileInfos[x194_fileIdx].second.Close() != kCR_READY) {
NoCardFound();
return;
}
int altFileIdx = !bool(x194_fileIdx);
if (readRes == kCR_READY) {
x10_state = kS_Ready;
ReadFinished();
EFileState fileSt = x100_mcFileInfos[altFileIdx].first;
if (fileSt != kFS_NoFile) {
StartFileDeleteAlt();
} else {
CheckCardCapacity();
}
return;
}
if (readRes == kCR_CRC_MISMATCH) {
x100_mcFileInfos[x194_fileIdx].first = kFS_BadFile;
if (x100_mcFileInfos[altFileIdx].first == kFS_File) {
x10_state = kS_CardCheckDone;
IndexFiles();
} else {
x10_state = kS_FileBad;
x14_error = kE_FileCorrupted;
}
}
} else {
HandleCardError(result, kS_FileBad);
}
}
void CMemoryCardDriver::UpdateFileDeleteAlt(ECardResult) {} void CMemoryCardDriver::UpdateFileDeleteAlt(ECardResult) {}
@ -203,6 +230,10 @@ void CMemoryCardDriver::IndexFiles() {}
void CMemoryCardDriver::StartFileDeleteBad() {} void CMemoryCardDriver::StartFileDeleteBad() {}
void CMemoryCardDriver::StartFileDeleteAlt() {}
void CMemoryCardDriver::StartFileRead() {}
void CMemoryCardDriver::StartFileCreate() {} void CMemoryCardDriver::StartFileCreate() {}
void CMemoryCardDriver::StartFileWrite() {} void CMemoryCardDriver::StartFileWrite() {}