Add body for CMemoryCardDriver

This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-10 22:58:03 +03:00
parent e7e54730a3
commit b00d23812a
No known key found for this signature in database
GPG Key ID: E224F951761145F8
2 changed files with 73 additions and 0 deletions

View File

@ -3,8 +3,22 @@
#include "types.h"
// TODO: likely comes from dolphin sdk
enum ECardSlot { kCS_SlotA, kCS_SlotB };
enum ECardResult { k_READY };
struct FileHandle {};
class CMemoryCardSys {
public:
struct CardFileHandle {
ECardSlot slot;
FileHandle handle;
CardFileHandle(ECardSlot slot) : slot(slot) {}
int getFileNo() const;
};
struct CCardFileInfo {};
CMemoryCardSys();
~CMemoryCardSys();

View File

@ -3,6 +3,14 @@
#include "MetroidPrime/Player/CGameState.hpp"
#include "Kyoto/CMemoryCardSys.hpp"
#include "rstl/auto_ptr.hpp"
#include "rstl/pair.hpp"
#include "rstl/single_ptr.hpp"
#include "rstl/vector.hpp"
class CMemoryCardDriver {
public:
enum EState {
@ -59,6 +67,57 @@ public:
kE_FileCorrupted
};
private:
struct SFileInfo {
CMemoryCardSys::CardFileHandle x0_fileInfo;
rstl::string x14_name;
rstl::vector< u8 > x24_saveFileData;
rstl::vector< u8 > x34_saveData;
// SFileInfo(kabufuda::ECardSlot cardPort, std::string_view name);
ECardResult Open();
ECardResult Close();
ECardSlot GetFileCardPort() const { return x0_fileInfo.slot; }
int GetFileNo() const { return x0_fileInfo.getFileNo(); }
ECardResult StartRead();
ECardResult TryFileRead();
ECardResult FileRead();
ECardResult GetSaveDataOffset(u32& offOut) const;
};
struct SGameFileSlot {
u8 x0_saveBuffer[940];
CGameState::GameFileStateInfo x944_fileInfo;
SGameFileSlot();
// explicit SGameFileSlot(CMemoryInStream& in);
void InitializeFromGameState();
void LoadGameState(u32 idx);
// void DoPut(CMemoryStreamOut& w) const { w.Put(x0_saveBuffer.data(), x0_saveBuffer.size()); }
};
enum EFileState { kFS_Unknown, kFS_NoFile, kFS_File, kFS_BadFile };
ECardSlot x0_cardPort;
CAssetId x4_saveBanner;
CAssetId x8_saveIcon0;
CAssetId xc_saveIcon1;
EState x10_state;
EError x14_error;
s32 x18_cardFreeBytes;
s32 x1c_cardFreeFiles;
u32 x20_fileTime;
u64 x28_cardSerial;
u8 x30_systemData[174];
rstl::auto_ptr< SGameFileSlot > xe4_fileSlots[3];
rstl::vector< rstl::pair< EFileState, SFileInfo > > x100_mcFileInfos;
u32 x194_fileIdx;
rstl::single_ptr< CMemoryCardSys::CCardFileInfo > x198_fileInfo;
bool x19c_;
bool x19d_importPersistent;
public:
static bool IsCardBusy(EState);
static bool IsCardWriting(EState);
CMemoryCardDriver();