From 7ed13f92a39d3d23d88c923331284557d3be2624 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 11 Oct 2022 15:26:29 +0300 Subject: [PATCH] Add CMemoryCardDriver::StartFileCreateTransactional --- src/MetroidPrime/CMemoryCardDriver.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/MetroidPrime/CMemoryCardDriver.cpp b/src/MetroidPrime/CMemoryCardDriver.cpp index 5f701558..fb69c11d 100644 --- a/src/MetroidPrime/CMemoryCardDriver.cpp +++ b/src/MetroidPrime/CMemoryCardDriver.cpp @@ -588,7 +588,30 @@ void CMemoryCardDriver::StartFileWrite() { UpdateFileWrite(result); } -void CMemoryCardDriver::StartFileCreateTransactional() {} +void CMemoryCardDriver::StartFileCreateTransactional() { + x14_error = kE_OK; + x10_state = kS_FileCreateTransactional; + ClearFileInfo(); + if (x18_cardFreeBytes < 8192 || x1c_cardFreeFiles < 1) { + x10_state = kS_FileCreateTransactionalFailed; + x14_error = kE_CardFull; + return; + } + + int altFileIdx; + if (x194_fileIdx == 0) { + altFileIdx = 1; + } else { + altFileIdx = 0; + } + + x194_fileIdx = altFileIdx; + x198_fileInfo = new CCardFileInfo(x0_cardPort, rstl::string_l(skSaveFileNames[x194_fileIdx])); + InitializeFileInfo(); + ECardResult result = x198_fileInfo->CreateFile(); + if (result != kCR_READY) + UpdateFileCreateTransactional(result); +} void CMemoryCardDriver::StartFileWriteTransactional() {}