mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 09:47:43 +00:00
Work on CMemoryCardDriver
This commit is contained in:
@@ -7,6 +7,11 @@
|
||||
#include "CSaveWorld.hpp"
|
||||
#include <vector>
|
||||
|
||||
// longest file name string excluding terminating zero
|
||||
#define CARD_FILENAME_MAX 32
|
||||
|
||||
#define CARD_ICON_MAX 8
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CDummyWorld;
|
||||
@@ -53,10 +58,11 @@ class CMemoryCardSys
|
||||
TLockedToken<CGameHintInfo> x0_hints;
|
||||
std::vector<std::pair<ResId, CSaveWorldMemory>> xc_memoryWorlds; /* MLVL as key */
|
||||
std::experimental::optional<std::vector<CSaveWorldIntermediate>> x1c_worldInter; /* used to be auto_ptr of vector */
|
||||
std::unordered_map<ResId, CSaveWorld::EScanCategory> x20_scanStates;
|
||||
std::vector<std::pair<ResId, CSaveWorld::EScanCategory>> x20_scanStates;
|
||||
public:
|
||||
const std::vector<CGameHintInfo::CGameHint>& GetHints() const { return x0_hints->GetHints(); }
|
||||
const std::vector<std::pair<ResId, CSaveWorldMemory>>& GetMemoryWorlds() const { return xc_memoryWorlds; }
|
||||
const std::vector<std::pair<ResId, CSaveWorld::EScanCategory>>& GetScanStates() const { return x20_scanStates; }
|
||||
CMemoryCardSys();
|
||||
bool InitializePump();
|
||||
|
||||
@@ -68,6 +74,7 @@ public:
|
||||
|
||||
enum class ECardResult
|
||||
{
|
||||
CARD_RESULT_CRC_MISMATCH = -1003,
|
||||
CARD_RESULT_FATAL_ERROR = -128,
|
||||
CARD_RESULT_ENCODING = -13,
|
||||
CARD_RESULT_BROKEN = -6,
|
||||
@@ -85,11 +92,59 @@ public:
|
||||
u32 x8_sectorSize; // in bytes
|
||||
};
|
||||
|
||||
struct CARDStat
|
||||
{
|
||||
// read-only (Set by CARDGetStatus)
|
||||
char x0_fileName[CARD_FILENAME_MAX];
|
||||
u32 x20_length;
|
||||
u32 x24_time; // seconds since 01/01/2000 midnight
|
||||
u8 x28_gameName[4];
|
||||
u8 x2c_company[2];
|
||||
|
||||
// read/write (Set by CARDGetStatus/CARDSetStatus)
|
||||
u8 x2e_bannerFormat;
|
||||
u8 x2f___padding;
|
||||
u32 x30_iconAddr; // offset to the banner, bannerTlut, icon, iconTlut data set.
|
||||
u16 x34_iconFormat;
|
||||
u16 x36_iconSpeed;
|
||||
u32 x38_commentAddr; // offset to the pair of 32 byte character strings.
|
||||
|
||||
// read-only (Set by CARDGetStatus)
|
||||
u32 x3c_offsetBanner;
|
||||
u32 x40_offsetBannerTlut;
|
||||
u32 x44_offsetIcon[CARD_ICON_MAX];
|
||||
u32 x64_offsetIconTlut;
|
||||
u32 x68_offsetData;
|
||||
|
||||
u32 GetTime() const { return x24_time; }
|
||||
u32 GetBannerFormat() const { return x2e_bannerFormat & 0x3; }
|
||||
void SetBannerFormat(u32 fmt) { x2e_bannerFormat = (x2e_bannerFormat & ~0x3) | fmt; }
|
||||
u32 GetIconFormat(int idx) const { return (x34_iconFormat >> (idx * 2)) & 0x3; }
|
||||
void SetIconFormat(u32 fmt, int idx)
|
||||
{
|
||||
x34_iconFormat &= ~(0x3 << (idx * 2));
|
||||
x34_iconFormat |= fmt << (idx * 2);
|
||||
}
|
||||
void SetIconSpeed(u32 sp, int idx)
|
||||
{
|
||||
x36_iconSpeed &= ~(0x3 << (idx * 2));
|
||||
x36_iconSpeed |= sp << (idx * 2);
|
||||
}
|
||||
u32 GetIconAddr() const { return x30_iconAddr; }
|
||||
void SetIconAddr(u32 addr) { x30_iconAddr = addr; }
|
||||
u32 GetCommentAddr() const { return x38_commentAddr; }
|
||||
void SetCommentAddr(u32 addr) { x38_commentAddr = addr; }
|
||||
};
|
||||
|
||||
static CardProbeResults CardProbe(EMemoryCardPort port);
|
||||
static ECardResult MountCard(EMemoryCardPort port);
|
||||
static ECardResult CheckCard(EMemoryCardPort port);
|
||||
static ECardResult GetNumFreeBytes(EMemoryCardPort port, s32& freeBytes, s32& freeFiles);
|
||||
static ECardResult GetSerialNo(EMemoryCardPort port, u64& serialOut);
|
||||
static ECardResult GetResultCode(EMemoryCardPort port);
|
||||
static ECardResult GetStatus(EMemoryCardPort port, int fileNo, CARDStat& statOut);
|
||||
static ECardResult DeleteFile(EMemoryCardPort port, const char* name);
|
||||
static ECardResult FastDeleteFile(EMemoryCardPort port, int fileNo);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user