mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 00:27:42 +00:00
Work on CMemoryCardDriver
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define __URDE_CMEMORYCARDDRIVER_HPP__
|
||||
|
||||
#include "CMemoryCardSys.hpp"
|
||||
#include "CGameState.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@@ -23,6 +24,8 @@ public:
|
||||
Twelve = 12,
|
||||
Thirteen = 13,
|
||||
Fourteen = 14,
|
||||
Fifteen = 15,
|
||||
Seventeen = 17,
|
||||
TwentyFive = 26,
|
||||
TwentySix = 26,
|
||||
TwentySeven = 27,
|
||||
@@ -53,14 +56,42 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
struct SMemoryCardSlotInfo
|
||||
struct CARDFileInfo
|
||||
{
|
||||
CMemoryCardSys::EMemoryCardPort x0_cardPort;
|
||||
u32 x4_ = -1;
|
||||
int x4_fileNo = -1;
|
||||
int x8_offset;
|
||||
int xc_length;
|
||||
u16 iBlock;
|
||||
};
|
||||
|
||||
struct SFileInfo
|
||||
{
|
||||
CARDFileInfo x0_fileInfo;
|
||||
std::string x14_name;
|
||||
std::vector<u8> x24_;
|
||||
std::vector<u8> x34_;
|
||||
SMemoryCardSlotInfo(CMemoryCardSys::EMemoryCardPort cardPort, const std::string& name);
|
||||
std::vector<u8> x24_saveFileData;
|
||||
std::vector<u8> x34_saveData;
|
||||
SFileInfo(CMemoryCardSys::EMemoryCardPort cardPort, const std::string& name);
|
||||
CMemoryCardSys::ECardResult Close();
|
||||
CMemoryCardSys::EMemoryCardPort GetFileCardPort() const { return x0_fileInfo.x0_cardPort; }
|
||||
int GetFileNo() const { return x0_fileInfo.x4_fileNo; }
|
||||
CMemoryCardSys::ECardResult TryFileRead();
|
||||
CMemoryCardSys::ECardResult FileRead();
|
||||
CMemoryCardSys::ECardResult GetSaveDataOffset(u32& offOut);
|
||||
};
|
||||
|
||||
struct SSaveHeader
|
||||
{
|
||||
u32 x0_;
|
||||
u32 x4_[3];
|
||||
};
|
||||
|
||||
struct SGameFileSlot
|
||||
{
|
||||
u8 x0_saveBuffer[940] = {};
|
||||
CGameState::GameFileStateInfo x944_fileInfo;
|
||||
SGameFileSlot();
|
||||
void InitializeFromGameState();
|
||||
};
|
||||
|
||||
CMemoryCardSys::EMemoryCardPort x0_cardPort;
|
||||
@@ -71,16 +102,16 @@ private:
|
||||
EError x14_error = EError::Zero;
|
||||
s32 x18_cardFreeBytes = 0;
|
||||
s32 x1c_cardFreeFiles = 0;
|
||||
u32 x20_ = 0;
|
||||
u32 x20_fileTime = 0;
|
||||
u32 x24_ = 0;
|
||||
u64 x28_cardSerial = 0;
|
||||
u8 x30_[174];
|
||||
std::unique_ptr<u8> xe4_[3];
|
||||
std::vector<std::pair<u32, SMemoryCardSlotInfo>> x100_mcSlotInfos;
|
||||
u32 x194_ = -1;
|
||||
u8 x30_systemData[174] = {};
|
||||
std::unique_ptr<SGameFileSlot> xe4_fileSlots[3];
|
||||
std::vector<std::pair<u32, SFileInfo>> x100_mcFileInfos;
|
||||
u32 x194_fileIdx = -1;
|
||||
u32 x198_ = 0;
|
||||
bool x19c_ = false;
|
||||
bool x19d_flag;
|
||||
bool x19d_doMergePersistent;
|
||||
|
||||
public:
|
||||
CMemoryCardDriver(CMemoryCardSys::EMemoryCardPort cardPort, ResId saveBanner,
|
||||
@@ -89,12 +120,51 @@ public:
|
||||
void FinishedLoading2();
|
||||
void NoCardFound();
|
||||
void MountCard();
|
||||
void MountCardFailed(CMemoryCardSys::ECardResult result);
|
||||
void CheckCard();
|
||||
void CheckCardFailed(CMemoryCardSys::ECardResult result);
|
||||
|
||||
CGameState::GameFileStateInfo* GetGameFileStateInfo(int idx);
|
||||
static SSaveHeader LoadSaveHeader(CMemoryInStream& in);
|
||||
static std::unique_ptr<SGameFileSlot> LoadSaveFile(CMemoryInStream& in);
|
||||
void ReadFinished();
|
||||
void MergePersistentOptions();
|
||||
void DeleteFile();
|
||||
void CheckCardCapacity();
|
||||
|
||||
void Case26(CMemoryCardSys::ECardResult result);
|
||||
void Case27(CMemoryCardSys::ECardResult result);
|
||||
void Case28(CMemoryCardSys::ECardResult result);
|
||||
void Case29(CMemoryCardSys::ECardResult result);
|
||||
void Case30(CMemoryCardSys::ECardResult result);
|
||||
void Case31(CMemoryCardSys::ECardResult result);
|
||||
void Case32(CMemoryCardSys::ECardResult result);
|
||||
void Case33(CMemoryCardSys::ECardResult result);
|
||||
void Case34(CMemoryCardSys::ECardResult result);
|
||||
void Case35(CMemoryCardSys::ECardResult result);
|
||||
void Case36(CMemoryCardSys::ECardResult result);
|
||||
void Case37(CMemoryCardSys::ECardResult result);
|
||||
|
||||
void GoTo17();
|
||||
void GoTo28();
|
||||
|
||||
bool GetCardFreeBytes();
|
||||
void HandleCardError(CMemoryCardSys::ECardResult result, EState state);
|
||||
void Update();
|
||||
|
||||
static bool InCardInsertedRange(EState v)
|
||||
{
|
||||
return v >= EState::TwentySix && v <= EState::ThirtySeven;
|
||||
}
|
||||
|
||||
static bool InRange2(EState v)
|
||||
{
|
||||
if (v < EState::TwentyFive)
|
||||
return false;
|
||||
if (v == EState::TwentySeven)
|
||||
return false;
|
||||
if (v == EState::TwentyNine)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user