mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'master' of https://github.com/AxioDL/urde
This commit is contained in:
commit
3d7a2fb140
|
@ -97,9 +97,10 @@ add_definitions(-DZE_ATHENA_TYPES=1)
|
||||||
set(ZEUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/specter/zeus/include)
|
set(ZEUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/specter/zeus/include)
|
||||||
include_directories(${ATHENA_INCLUDE_DIR} ${LOGVISOR_INCLUDE_DIR} ${HECL_INCLUDE_DIR}
|
include_directories(${ATHENA_INCLUDE_DIR} ${LOGVISOR_INCLUDE_DIR} ${HECL_INCLUDE_DIR}
|
||||||
${NOD_INCLUDE_DIR} ${ZEUS_INCLUDE_DIR} ${BOO_INCLUDE_DIR} ${AMUSE_INCLUDE_DIR}
|
${NOD_INCLUDE_DIR} ${ZEUS_INCLUDE_DIR} ${BOO_INCLUDE_DIR} ${AMUSE_INCLUDE_DIR}
|
||||||
${SPECTER_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${KABUFUDA_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
${SPECTER_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
add_subdirectory(DataSpec)
|
add_subdirectory(DataSpec)
|
||||||
add_subdirectory(kabufuda)
|
add_subdirectory(kabufuda)
|
||||||
|
include_directories(${KABUFUDA_INCLUDE_DIR})
|
||||||
add_subdirectory(Editor)
|
add_subdirectory(Editor)
|
||||||
|
|
||||||
set(CLIENT_SOURCES
|
set(CLIENT_SOURCES
|
||||||
|
|
Binary file not shown.
|
@ -9,6 +9,11 @@
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using ECardResult = kabufuda::ECardResult;
|
||||||
|
|
||||||
|
kabufuda::SystemString g_CardImagePaths[2] = {};
|
||||||
|
kabufuda::Card g_CardStates[2] = {};
|
||||||
|
|
||||||
CSaveWorldIntermediate::CSaveWorldIntermediate(ResId mlvl, ResId savw)
|
CSaveWorldIntermediate::CSaveWorldIntermediate(ResId mlvl, ResId savw)
|
||||||
: x0_mlvlId(mlvl), x8_savwId(savw)
|
: x0_mlvlId(mlvl), x8_savwId(savw)
|
||||||
{
|
{
|
||||||
|
@ -140,10 +145,11 @@ void CMemoryCardSys::CCardFileInfo::LockBannerToken(ResId bannerTxtr, CSimplePoo
|
||||||
x40_bannerTok.emplace(sp.GetObj({FOURCC('TXTR'), bannerTxtr}, m_texParam));
|
x40_bannerTok.emplace(sp.GetObj({FOURCC('TXTR'), bannerTxtr}, m_texParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::CCardFileInfo::Icon::Icon(ResId id, u32 speed, CSimplePool& sp, const CVParamTransfer& cv)
|
CMemoryCardSys::CCardFileInfo::Icon::Icon(ResId id, kabufuda::EAnimationSpeed speed,
|
||||||
|
CSimplePool& sp, const CVParamTransfer& cv)
|
||||||
: x0_id(id), x4_speed(speed), x8_tex(sp.GetObj({FOURCC('TXTR'), id}, cv)) {}
|
: x0_id(id), x4_speed(speed), x8_tex(sp.GetObj({FOURCC('TXTR'), id}, cv)) {}
|
||||||
|
|
||||||
void CMemoryCardSys::CCardFileInfo::LockIconToken(ResId iconTxtr, u32 speed, CSimplePool& sp)
|
void CMemoryCardSys::CCardFileInfo::LockIconToken(ResId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp)
|
||||||
{
|
{
|
||||||
x50_iconToks.emplace_back(iconTxtr, speed, sp, m_texParam);
|
x50_iconToks.emplace_back(iconTxtr, speed, sp, m_texParam);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +245,7 @@ void CMemoryCardSys::CCardFileInfo::WriteIconData(CMemoryOutStream& out) const
|
||||||
out.writeBytes(palette.get(), 512);
|
out.writeBytes(palette.get(), 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::PumpCardTransfer()
|
ECardResult CMemoryCardSys::CCardFileInfo::PumpCardTransfer()
|
||||||
{
|
{
|
||||||
if (x0_status == EStatus::Standby)
|
if (x0_status == EStatus::Standby)
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
|
@ -251,7 +257,7 @@ CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::PumpCardTransfer()
|
||||||
if (result != ECardResult::READY)
|
if (result != ECardResult::READY)
|
||||||
return result;
|
return result;
|
||||||
x0_status = EStatus::Done;
|
x0_status = EStatus::Done;
|
||||||
CARDStat stat = {};
|
kabufuda::CardStat stat = {};
|
||||||
result = GetStatus(stat);
|
result = GetStatus(stat);
|
||||||
if (result != ECardResult::READY)
|
if (result != ECardResult::READY)
|
||||||
return result;
|
return result;
|
||||||
|
@ -269,7 +275,7 @@ CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::PumpCardTransfer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::GetStatus(CARDStat& stat) const
|
ECardResult CMemoryCardSys::CCardFileInfo::GetStatus(kabufuda::CardStat& stat) const
|
||||||
{
|
{
|
||||||
ECardResult result = CMemoryCardSys::GetStatus(GetCardPort(), GetFileNo(), stat);
|
ECardResult result = CMemoryCardSys::GetStatus(GetCardPort(), GetFileNo(), stat);
|
||||||
if (result != ECardResult::READY)
|
if (result != ECardResult::READY)
|
||||||
|
@ -278,112 +284,193 @@ CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::GetStatus(CARDStat& s
|
||||||
stat.SetCommentAddr(4);
|
stat.SetCommentAddr(4);
|
||||||
stat.SetIconAddr(68);
|
stat.SetIconAddr(68);
|
||||||
|
|
||||||
u32 bannerFmt;
|
kabufuda::EImageFormat bannerFmt;
|
||||||
if (x3c_bannerTex != -1)
|
if (x3c_bannerTex != -1)
|
||||||
{
|
{
|
||||||
if ((*x40_bannerTok)->GetMemoryCardTexelFormat() == ETexelFormat::RGB5A3)
|
if ((*x40_bannerTok)->GetMemoryCardTexelFormat() == ETexelFormat::RGB5A3)
|
||||||
bannerFmt = 2;
|
bannerFmt = kabufuda::EImageFormat::RGB5A3;
|
||||||
else
|
else
|
||||||
bannerFmt = 1;
|
bannerFmt = kabufuda::EImageFormat::C8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bannerFmt = 0;
|
bannerFmt = kabufuda::EImageFormat::None;
|
||||||
stat.SetBannerFormat(bannerFmt);
|
stat.SetBannerFormat(bannerFmt);
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (const Icon& icon : x50_iconToks)
|
for (const Icon& icon : x50_iconToks)
|
||||||
{
|
{
|
||||||
stat.SetIconFormat(icon.x8_tex->GetMemoryCardTexelFormat() == ETexelFormat::RGB5A3 ? 2 : 1, idx);
|
stat.SetIconFormat(icon.x8_tex->GetMemoryCardTexelFormat() == ETexelFormat::RGB5A3 ?
|
||||||
|
kabufuda::EImageFormat::RGB5A3 : kabufuda::EImageFormat::C8, idx);
|
||||||
stat.SetIconSpeed(icon.x4_speed, idx);
|
stat.SetIconSpeed(icon.x4_speed, idx);
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
if (idx < 8)
|
if (idx < 8)
|
||||||
{
|
{
|
||||||
stat.SetIconFormat(0, idx);
|
stat.SetIconFormat(kabufuda::EImageFormat::None, idx);
|
||||||
stat.SetIconSpeed(0, idx);
|
stat.SetIconSpeed(kabufuda::EAnimationSpeed::End, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::CreateFile()
|
ECardResult CMemoryCardSys::CCardFileInfo::CreateFile()
|
||||||
{
|
{
|
||||||
return ECardResult::READY;
|
return CMemoryCardSys::CreateFile(m_handle.slot, x18_fileName.c_str(),
|
||||||
|
CalculateTotalDataSize(), m_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::Write()
|
ECardResult CMemoryCardSys::CCardFileInfo::WriteFile()
|
||||||
{
|
{
|
||||||
BuildCardBuffer();
|
BuildCardBuffer();
|
||||||
//DCStoreRange(info.x104_cardBuffer.data(), info.x104_cardBuffer.size());
|
//DCStoreRange(x104_cardBuffer.data(), x104_cardBuffer.size());
|
||||||
//CARDWriteAsync(&info.x4_info, info.x104_cardBuffer.data(), info.x104_cardBuffer.size(), 0, 0);
|
return CMemoryCardSys::WriteFile(m_handle, x104_cardBuffer.data(), x104_cardBuffer.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::CCardFileInfo::CloseFile()
|
||||||
|
{
|
||||||
|
return CMemoryCardSys::CloseFile(m_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
kabufuda::ProbeResults CMemoryCardSys::CardProbe(kabufuda::ECardSlot port)
|
||||||
|
{
|
||||||
|
return kabufuda::Card::probeCardFile(g_CardImagePaths[int(port)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::MountCard(kabufuda::ECardSlot port)
|
||||||
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
card = kabufuda::Card(g_CardImagePaths[int(port)], "GM8E", "01");
|
||||||
|
ECardResult result = card.getError();
|
||||||
|
if (result == ECardResult::READY)
|
||||||
|
return ECardResult::READY;
|
||||||
|
card = kabufuda::Card();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::CheckCard(kabufuda::ECardSlot port)
|
||||||
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
return card.getError();
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::CreateFile(kabufuda::ECardSlot port, const char* name, u32 size, CardFileHandle& info)
|
||||||
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
info.slot = port;
|
||||||
|
return card.createFile(name, size, info.handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::OpenFile(kabufuda::ECardSlot port, const char* name, CardFileHandle& info)
|
||||||
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
info.slot = port;
|
||||||
|
info.handle = card.openFile(name);
|
||||||
|
return info.handle ? ECardResult::READY : ECardResult::NOFILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::FastOpenFile(kabufuda::ECardSlot port, int fileNo, CardFileHandle& info)
|
||||||
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
info.slot = port;
|
||||||
|
info.handle = card.openFile(fileNo);
|
||||||
|
return info.handle ? ECardResult::READY : ECardResult::NOFILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::CloseFile(CardFileHandle& info)
|
||||||
|
{
|
||||||
|
info.handle.reset();
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::CCardFileInfo::Close()
|
ECardResult CMemoryCardSys::ReadFile(const CardFileHandle& info, void* buf, s32 length, s32 offset)
|
||||||
{
|
{
|
||||||
EMemoryCardPort port = GetCardPort();
|
kabufuda::Card& card = g_CardStates[int(info.slot)];
|
||||||
//CARDClose(port);
|
if (CardResult err = card.getError())
|
||||||
x4_info.chan = port;
|
return err;
|
||||||
|
card.seek(info, offset, kabufuda::SeekOrigin::Begin);
|
||||||
|
card.read(info, buf, length);
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::CardProbeResults CMemoryCardSys::CardProbe(EMemoryCardPort port)
|
ECardResult CMemoryCardSys::WriteFile(const CardFileHandle& info, const void* buf, s32 length, s32 offset)
|
||||||
{
|
{
|
||||||
return {};
|
kabufuda::Card& card = g_CardStates[int(info.slot)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
card.seek(info, offset, kabufuda::SeekOrigin::Begin);
|
||||||
|
card.write(info, buf, length);
|
||||||
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::MountCard(EMemoryCardPort port)
|
ECardResult CMemoryCardSys::GetNumFreeBytes(kabufuda::ECardSlot port, s32& freeBytes, s32& freeFiles)
|
||||||
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
card.getFreeBlocks(freeBytes, freeFiles);
|
||||||
|
return ECardResult::READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::GetSerialNo(kabufuda::ECardSlot port, u64& serialOut)
|
||||||
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
card.getSerial(serialOut);
|
||||||
|
return ECardResult::READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
ECardResult CMemoryCardSys::GetResultCode(kabufuda::ECardSlot port)
|
||||||
{
|
{
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::CheckCard(EMemoryCardPort port)
|
ECardResult CMemoryCardSys::GetStatus(kabufuda::ECardSlot port, int fileNo, CardStat& statOut)
|
||||||
{
|
{
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::GetNumFreeBytes(EMemoryCardPort port, s32& freeBytes, s32& freeFiles)
|
ECardResult CMemoryCardSys::SetStatus(kabufuda::ECardSlot port, int fileNo, const CardStat& stat)
|
||||||
{
|
{
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::GetSerialNo(EMemoryCardPort port, u64& serialOut)
|
ECardResult CMemoryCardSys::DeleteFile(kabufuda::ECardSlot port, const char* name)
|
||||||
{
|
{
|
||||||
return ECardResult::READY;
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
return card.deleteFile(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::GetResultCode(EMemoryCardPort port)
|
ECardResult CMemoryCardSys::FastDeleteFile(kabufuda::ECardSlot port, int fileNo)
|
||||||
{
|
{
|
||||||
return ECardResult::READY;
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
return card.deleteFile(fileNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::GetStatus(EMemoryCardPort port, int fileNo, CARDStat& statOut)
|
ECardResult CMemoryCardSys::Rename(kabufuda::ECardSlot port, const char* oldName, const char* newName)
|
||||||
{
|
{
|
||||||
return ECardResult::READY;
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
return card.renameFile(oldName, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::SetStatus(EMemoryCardPort port, int fileNo, const CARDStat& stat)
|
ECardResult CMemoryCardSys::FormatCard(kabufuda::ECardSlot port)
|
||||||
{
|
|
||||||
return ECardResult::READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::DeleteFile(EMemoryCardPort port, const char* name)
|
|
||||||
{
|
|
||||||
return ECardResult::READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::FastDeleteFile(EMemoryCardPort port, int fileNo)
|
|
||||||
{
|
|
||||||
return ECardResult::READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::Rename(EMemoryCardPort port, const char* oldName, const char* newName)
|
|
||||||
{
|
|
||||||
return ECardResult::READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardSys::FormatCard(EMemoryCardPort port)
|
|
||||||
{
|
{
|
||||||
|
kabufuda::Card& card = g_CardStates[int(port)];
|
||||||
|
if (CardResult err = card.getError())
|
||||||
|
return err;
|
||||||
|
card.format(port);
|
||||||
return ECardResult::READY;
|
return ECardResult::READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,9 @@
|
||||||
#include "CGameHintInfo.hpp"
|
#include "CGameHintInfo.hpp"
|
||||||
#include "CSaveWorld.hpp"
|
#include "CSaveWorld.hpp"
|
||||||
#include "GuiSys/CStringTable.hpp"
|
#include "GuiSys/CStringTable.hpp"
|
||||||
|
#include "kabufuda/Card.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#undef NOFILE
|
|
||||||
|
|
||||||
// longest file name string excluding terminating zero
|
|
||||||
#define CARD_FILENAME_MAX 32
|
|
||||||
|
|
||||||
#define CARD_ICON_MAX 8
|
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
class CDummyWorld;
|
class CDummyWorld;
|
||||||
|
@ -64,105 +58,40 @@ class CMemoryCardSys
|
||||||
std::experimental::optional<std::vector<CSaveWorldIntermediate>> x1c_worldInter; /* used to be auto_ptr of vector */
|
std::experimental::optional<std::vector<CSaveWorldIntermediate>> x1c_worldInter; /* used to be auto_ptr of vector */
|
||||||
std::vector<std::pair<ResId, CSaveWorld::EScanCategory>> x20_scanStates;
|
std::vector<std::pair<ResId, CSaveWorld::EScanCategory>> x20_scanStates;
|
||||||
public:
|
public:
|
||||||
|
using ECardResult = kabufuda::ECardResult;
|
||||||
|
struct CardResult
|
||||||
|
{
|
||||||
|
ECardResult result;
|
||||||
|
CardResult(ECardResult res) : result(res) {}
|
||||||
|
operator ECardResult() const { return result; }
|
||||||
|
operator bool() const { return result != ECardResult::READY; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CardFileHandle
|
||||||
|
{
|
||||||
|
kabufuda::ECardSlot slot;
|
||||||
|
std::unique_ptr<kabufuda::IFileHandle> handle;
|
||||||
|
CardFileHandle(kabufuda::ECardSlot slot) : slot(slot) {}
|
||||||
|
kabufuda::IFileHandle* operator->() const { return handle.get(); }
|
||||||
|
operator std::unique_ptr<kabufuda::IFileHandle>&() { return handle; }
|
||||||
|
operator const std::unique_ptr<kabufuda::IFileHandle>&() const { return handle; }
|
||||||
|
};
|
||||||
|
|
||||||
|
using CardStat = kabufuda::CardStat;
|
||||||
const std::vector<CGameHintInfo::CGameHint>& GetHints() const { return x0_hints->GetHints(); }
|
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, CSaveWorldMemory>>& GetMemoryWorlds() const { return xc_memoryWorlds; }
|
||||||
const std::vector<std::pair<ResId, CSaveWorld::EScanCategory>>& GetScanStates() const { return x20_scanStates; }
|
const std::vector<std::pair<ResId, CSaveWorld::EScanCategory>>& GetScanStates() const { return x20_scanStates; }
|
||||||
CMemoryCardSys();
|
CMemoryCardSys();
|
||||||
bool InitializePump();
|
bool InitializePump();
|
||||||
|
|
||||||
enum class EMemoryCardPort
|
|
||||||
{
|
|
||||||
SlotA,
|
|
||||||
SlotB
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class ECardResult
|
|
||||||
{
|
|
||||||
CRC_MISMATCH = -1003,
|
|
||||||
FATAL_ERROR = -128,
|
|
||||||
ENCODING = -13,
|
|
||||||
BROKEN = -6,
|
|
||||||
IOERROR = -5,
|
|
||||||
NOFILE = -4,
|
|
||||||
NOCARD = -3,
|
|
||||||
WRONGDEVICE = -2,
|
|
||||||
BUSY = -1,
|
|
||||||
READY = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CardProbeResults
|
|
||||||
{
|
|
||||||
ECardResult x0_error;
|
|
||||||
u32 x4_cardSize; // in megabits
|
|
||||||
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 GetFileLength() const { return x20_length; }
|
|
||||||
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; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CARDFileInfo
|
|
||||||
{
|
|
||||||
EMemoryCardPort chan;
|
|
||||||
s32 fileNo = -1;
|
|
||||||
|
|
||||||
s32 offset;
|
|
||||||
s32 length;
|
|
||||||
u16 iBlock;
|
|
||||||
u16 __padding;
|
|
||||||
|
|
||||||
CARDFileInfo(EMemoryCardPort port) : chan(port) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CCardFileInfo
|
struct CCardFileInfo
|
||||||
{
|
{
|
||||||
struct Icon
|
struct Icon
|
||||||
{
|
{
|
||||||
ResId x0_id;
|
ResId x0_id;
|
||||||
u32 x4_speed;
|
kabufuda::EAnimationSpeed x4_speed;
|
||||||
TLockedToken<CTexture> x8_tex;
|
TLockedToken<CTexture> x8_tex;
|
||||||
Icon(ResId id, u32 speed, CSimplePool& sp, const CVParamTransfer& cv);
|
Icon(ResId id, kabufuda::EAnimationSpeed speed, CSimplePool& sp, const CVParamTransfer& cv);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EStatus
|
enum class EStatus
|
||||||
|
@ -173,7 +102,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
EStatus x0_status = EStatus::Standby;
|
EStatus x0_status = EStatus::Standby;
|
||||||
CARDFileInfo x4_info;
|
//CARDFileInfo x4_info;
|
||||||
|
CardFileHandle m_handle;
|
||||||
std::string x18_fileName;
|
std::string x18_fileName;
|
||||||
std::string x28_comment;
|
std::string x28_comment;
|
||||||
ResId x3c_bannerTex = -1;
|
ResId x3c_bannerTex = -1;
|
||||||
|
@ -184,14 +114,14 @@ public:
|
||||||
|
|
||||||
CVParamTransfer m_texParam = {new TObjOwnerParam<u32>(SBIG('OTEX'))};
|
CVParamTransfer m_texParam = {new TObjOwnerParam<u32>(SBIG('OTEX'))};
|
||||||
|
|
||||||
CCardFileInfo(EMemoryCardPort port, const std::string& name)
|
CCardFileInfo(kabufuda::ECardSlot port, const std::string& name)
|
||||||
: x4_info(port), x18_fileName(name) {}
|
: m_handle(port), x18_fileName(name) {}
|
||||||
|
|
||||||
void LockBannerToken(ResId bannerTxtr, CSimplePool& sp);
|
void LockBannerToken(ResId bannerTxtr, CSimplePool& sp);
|
||||||
void LockIconToken(ResId iconTxtr, u32 speed, CSimplePool& sp);
|
void LockIconToken(ResId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp);
|
||||||
|
|
||||||
EMemoryCardPort GetCardPort() const { return x4_info.chan; }
|
kabufuda::ECardSlot GetCardPort() const { return m_handle.slot; }
|
||||||
int GetFileNo() const { return x4_info.fileNo; }
|
int GetFileNo() const { return m_handle->getFileNo(); }
|
||||||
u32 CalculateBannerDataSize() const;
|
u32 CalculateBannerDataSize() const;
|
||||||
u32 CalculateTotalDataSize() const;
|
u32 CalculateTotalDataSize() const;
|
||||||
void BuildCardBuffer();
|
void BuildCardBuffer();
|
||||||
|
@ -199,10 +129,10 @@ public:
|
||||||
void WriteIconData(CMemoryOutStream& out) const;
|
void WriteIconData(CMemoryOutStream& out) const;
|
||||||
void SetComment(const std::string& c) { x28_comment = c; }
|
void SetComment(const std::string& c) { x28_comment = c; }
|
||||||
ECardResult PumpCardTransfer();
|
ECardResult PumpCardTransfer();
|
||||||
ECardResult GetStatus(CARDStat& stat) const;
|
ECardResult GetStatus(CardStat& stat) const;
|
||||||
ECardResult CreateFile();
|
ECardResult CreateFile();
|
||||||
ECardResult Write();
|
ECardResult WriteFile();
|
||||||
ECardResult Close();
|
ECardResult CloseFile();
|
||||||
|
|
||||||
CMemoryOutStream BeginMemoryOut(u32 sz)
|
CMemoryOutStream BeginMemoryOut(u32 sz)
|
||||||
{
|
{
|
||||||
|
@ -211,18 +141,24 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static CardProbeResults CardProbe(EMemoryCardPort port);
|
static kabufuda::ProbeResults CardProbe(kabufuda::ECardSlot port);
|
||||||
static ECardResult MountCard(EMemoryCardPort port);
|
static ECardResult MountCard(kabufuda::ECardSlot port);
|
||||||
static ECardResult CheckCard(EMemoryCardPort port);
|
static ECardResult CheckCard(kabufuda::ECardSlot port);
|
||||||
static ECardResult GetNumFreeBytes(EMemoryCardPort port, s32& freeBytes, s32& freeFiles);
|
static ECardResult CreateFile(kabufuda::ECardSlot port, const char* name, u32 size, CardFileHandle& info);
|
||||||
static ECardResult GetSerialNo(EMemoryCardPort port, u64& serialOut);
|
static ECardResult OpenFile(kabufuda::ECardSlot port, const char* name, CardFileHandle& info);
|
||||||
static ECardResult GetResultCode(EMemoryCardPort port);
|
static ECardResult FastOpenFile(kabufuda::ECardSlot port, int fileNo, CardFileHandle& info);
|
||||||
static ECardResult GetStatus(EMemoryCardPort port, int fileNo, CARDStat& statOut);
|
static ECardResult CloseFile(CardFileHandle& info);
|
||||||
static ECardResult SetStatus(EMemoryCardPort port, int fileNo, const CARDStat& stat);
|
static ECardResult ReadFile(const CardFileHandle& info, void* buf, s32 length, s32 offset);
|
||||||
static ECardResult DeleteFile(EMemoryCardPort port, const char* name);
|
static ECardResult WriteFile(const CardFileHandle& info, const void* buf, s32 length, s32 offset);
|
||||||
static ECardResult FastDeleteFile(EMemoryCardPort port, int fileNo);
|
static ECardResult GetNumFreeBytes(kabufuda::ECardSlot port, s32& freeBytes, s32& freeFiles);
|
||||||
static ECardResult Rename(EMemoryCardPort port, const char* oldName, const char* newName);
|
static ECardResult GetSerialNo(kabufuda::ECardSlot port, u64& serialOut);
|
||||||
static ECardResult FormatCard(EMemoryCardPort port);
|
static ECardResult GetResultCode(kabufuda::ECardSlot port);
|
||||||
|
static ECardResult GetStatus(kabufuda::ECardSlot port, int fileNo, CardStat& statOut);
|
||||||
|
static ECardResult SetStatus(kabufuda::ECardSlot port, int fileNo, const CardStat& stat);
|
||||||
|
static ECardResult DeleteFile(kabufuda::ECardSlot port, const char* name);
|
||||||
|
static ECardResult FastDeleteFile(kabufuda::ECardSlot port, int fileNo);
|
||||||
|
static ECardResult Rename(kabufuda::ECardSlot port, const char* oldName, const char* newName);
|
||||||
|
static ECardResult FormatCard(kabufuda::ECardSlot port);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,27 +13,22 @@ static const char* SaveFileNames[] =
|
||||||
"MetroidPrime B"
|
"MetroidPrime B"
|
||||||
};
|
};
|
||||||
|
|
||||||
using ECardResult = CMemoryCardSys::ECardResult;
|
using ECardResult = kabufuda::ECardResult;
|
||||||
using EMemoryCardPort = CMemoryCardSys::EMemoryCardPort;
|
using ECardSlot = kabufuda::ECardSlot;
|
||||||
|
|
||||||
ECardResult CMemoryCardDriver::SFileInfo::Open()
|
ECardResult CMemoryCardDriver::SFileInfo::Open()
|
||||||
{
|
{
|
||||||
//CARDOpen(GetFileCardPort(), x14_name.data(), &x0_fileInfo);
|
return CMemoryCardSys::OpenFile(GetFileCardPort(), x14_name.c_str(), x0_fileInfo);
|
||||||
return ECardResult::READY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ECardResult CMemoryCardDriver::SFileInfo::Close()
|
ECardResult CMemoryCardDriver::SFileInfo::Close()
|
||||||
{
|
{
|
||||||
auto backup = GetFileCardPort();
|
return CMemoryCardSys::CloseFile(x0_fileInfo);
|
||||||
ECardResult result = ECardResult::READY;
|
|
||||||
//result = CARDClose(backup);
|
|
||||||
x0_fileInfo.x0_cardPort = backup;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardSys::ECardResult CMemoryCardDriver::SFileInfo::StartRead()
|
ECardResult CMemoryCardDriver::SFileInfo::StartRead()
|
||||||
{
|
{
|
||||||
CMemoryCardSys::CARDStat stat = {};
|
CMemoryCardSys::CardStat stat = {};
|
||||||
ECardResult result = CMemoryCardSys::GetStatus(GetFileCardPort(), GetFileNo(), stat);
|
ECardResult result = CMemoryCardSys::GetStatus(GetFileCardPort(), GetFileNo(), stat);
|
||||||
if (result != ECardResult::READY)
|
if (result != ECardResult::READY)
|
||||||
return result;
|
return result;
|
||||||
|
@ -41,8 +36,7 @@ CMemoryCardSys::ECardResult CMemoryCardDriver::SFileInfo::StartRead()
|
||||||
u32 length = stat.GetFileLength();
|
u32 length = stat.GetFileLength();
|
||||||
x34_saveData.clear();
|
x34_saveData.clear();
|
||||||
x24_saveFileData.resize(length);
|
x24_saveFileData.resize(length);
|
||||||
//return CARDReadAsync(&x0_fileInfo, x24_saveFileData.data(), length, 0, 0);
|
return CMemoryCardSys::ReadFile(x0_fileInfo, x24_saveFileData.data(), length, 0);
|
||||||
return ECardResult::READY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ECardResult CMemoryCardDriver::SFileInfo::TryFileRead()
|
ECardResult CMemoryCardDriver::SFileInfo::TryFileRead()
|
||||||
|
@ -83,7 +77,7 @@ ECardResult CMemoryCardDriver::SFileInfo::FileRead()
|
||||||
|
|
||||||
ECardResult CMemoryCardDriver::SFileInfo::GetSaveDataOffset(u32& offOut)
|
ECardResult CMemoryCardDriver::SFileInfo::GetSaveDataOffset(u32& offOut)
|
||||||
{
|
{
|
||||||
CMemoryCardSys::CARDStat stat = {};
|
CMemoryCardSys::CardStat stat = {};
|
||||||
ECardResult result = CMemoryCardSys::GetStatus(GetFileCardPort(), GetFileNo(), stat);
|
ECardResult result = CMemoryCardSys::GetStatus(GetFileCardPort(), GetFileNo(), stat);
|
||||||
if (result != ECardResult::READY)
|
if (result != ECardResult::READY)
|
||||||
{
|
{
|
||||||
|
@ -95,10 +89,10 @@ ECardResult CMemoryCardDriver::SFileInfo::GetSaveDataOffset(u32& offOut)
|
||||||
offOut += 64;
|
offOut += 64;
|
||||||
switch (stat.GetBannerFormat())
|
switch (stat.GetBannerFormat())
|
||||||
{
|
{
|
||||||
case 1:
|
case kabufuda::EImageFormat::C8:
|
||||||
offOut += 3584;
|
offOut += 3584;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case kabufuda::EImageFormat::RGB5A3:
|
||||||
offOut += 6144;
|
offOut += 6144;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -106,9 +100,11 @@ ECardResult CMemoryCardDriver::SFileInfo::GetSaveDataOffset(u32& offOut)
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
bool paletteIcon = false;
|
bool paletteIcon = false;
|
||||||
while (u32 fmt = stat.GetIconFormat(idx))
|
for (kabufuda::EImageFormat fmt = stat.GetIconFormat(idx);
|
||||||
|
fmt != kabufuda::EImageFormat::None;
|
||||||
|
fmt = stat.GetIconFormat(idx))
|
||||||
{
|
{
|
||||||
if (fmt == 1)
|
if (fmt == kabufuda::EImageFormat::C8)
|
||||||
{
|
{
|
||||||
paletteIcon = true;
|
paletteIcon = true;
|
||||||
offOut += 1024;
|
offOut += 1024;
|
||||||
|
@ -142,14 +138,10 @@ void CMemoryCardDriver::SGameFileSlot::InitializeFromGameState()
|
||||||
x944_fileInfo = CGameState::LoadGameFileState(x0_saveBuffer);
|
x944_fileInfo = CGameState::LoadGameFileState(x0_saveBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemoryCardDriver::SFileInfo::SFileInfo(EMemoryCardPort port,
|
CMemoryCardDriver::SFileInfo::SFileInfo(kabufuda::ECardSlot port, const std::string& name)
|
||||||
const std::string& name)
|
: x0_fileInfo(port), x14_name(name) {}
|
||||||
: x14_name(name)
|
|
||||||
{
|
|
||||||
x0_fileInfo.x0_cardPort = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMemoryCardDriver::CMemoryCardDriver(EMemoryCardPort cardPort, ResId saveBanner,
|
CMemoryCardDriver::CMemoryCardDriver(kabufuda::ECardSlot cardPort, ResId saveBanner,
|
||||||
ResId saveIcon0, ResId saveIcon1, bool importPersistent)
|
ResId saveIcon0, ResId saveIcon1, bool importPersistent)
|
||||||
: x0_cardPort(cardPort), x4_saveBanner(saveBanner),
|
: x0_cardPort(cardPort), x4_saveBanner(saveBanner),
|
||||||
x8_saveIcon0(saveIcon0), xc_saveIcon1(saveIcon1), x19d_doImportPersistent(importPersistent)
|
x8_saveIcon0(saveIcon0), xc_saveIcon1(saveIcon1), x19d_doImportPersistent(importPersistent)
|
||||||
|
@ -189,10 +181,9 @@ std::unique_ptr<CMemoryCardDriver::SGameFileSlot> CMemoryCardDriver::LoadSaveFil
|
||||||
|
|
||||||
void CMemoryCardDriver::ReadFinished()
|
void CMemoryCardDriver::ReadFinished()
|
||||||
{
|
{
|
||||||
CMemoryCardSys::CARDStat stat = {};
|
CMemoryCardSys::CardStat stat = {};
|
||||||
SFileInfo& fileInfo = x100_mcFileInfos[x194_fileIdx].second;
|
SFileInfo& fileInfo = x100_mcFileInfos[x194_fileIdx].second;
|
||||||
if (CMemoryCardSys::GetStatus(x0_cardPort, fileInfo.GetFileNo(), stat) !=
|
if (CMemoryCardSys::GetStatus(x0_cardPort, fileInfo.GetFileNo(), stat) != ECardResult::READY)
|
||||||
ECardResult::READY)
|
|
||||||
{
|
{
|
||||||
NoCardFound();
|
NoCardFound();
|
||||||
return;
|
return;
|
||||||
|
@ -247,9 +238,9 @@ void CMemoryCardDriver::IndexFiles()
|
||||||
}
|
}
|
||||||
else if (result == ECardResult::READY)
|
else if (result == ECardResult::READY)
|
||||||
{
|
{
|
||||||
CMemoryCardSys::CARDStat stat = {};
|
CMemoryCardSys::CardStat stat = {};
|
||||||
if (CMemoryCardSys::GetStatus(x0_cardPort, info.second.GetFileNo(), stat) ==
|
if (CMemoryCardSys::GetStatus(x0_cardPort, info.second.GetFileNo(), stat) ==
|
||||||
ECardResult::READY)
|
ECardResult::READY)
|
||||||
{
|
{
|
||||||
u32 comment = stat.GetCommentAddr();
|
u32 comment = stat.GetCommentAddr();
|
||||||
if (comment == -1)
|
if (comment == -1)
|
||||||
|
@ -280,7 +271,7 @@ void CMemoryCardDriver::IndexFiles()
|
||||||
{
|
{
|
||||||
if (x100_mcFileInfos[1].first == EFileState::File)
|
if (x100_mcFileInfos[1].first == EFileState::File)
|
||||||
{
|
{
|
||||||
CMemoryCardSys::CARDStat stat = {};
|
CMemoryCardSys::CardStat stat = {};
|
||||||
if (CMemoryCardSys::GetStatus(x0_cardPort, x100_mcFileInfos[0].second.GetFileNo(), stat) ==
|
if (CMemoryCardSys::GetStatus(x0_cardPort, x100_mcFileInfos[0].second.GetFileNo(), stat) ==
|
||||||
ECardResult::READY)
|
ECardResult::READY)
|
||||||
{
|
{
|
||||||
|
@ -421,7 +412,7 @@ void CMemoryCardDriver::StartFileWrite()
|
||||||
{
|
{
|
||||||
x14_error = EError::OK;
|
x14_error = EError::OK;
|
||||||
x10_state = EState::FileWrite;
|
x10_state = EState::FileWrite;
|
||||||
ECardResult result = x198_fileInfo->Write();
|
ECardResult result = x198_fileInfo->WriteFile();
|
||||||
if (result != ECardResult::READY)
|
if (result != ECardResult::READY)
|
||||||
UpdateFileWrite(result);
|
UpdateFileWrite(result);
|
||||||
}
|
}
|
||||||
|
@ -450,7 +441,7 @@ void CMemoryCardDriver::StartFileWriteTransactional()
|
||||||
{
|
{
|
||||||
x14_error = EError::OK;
|
x14_error = EError::OK;
|
||||||
x10_state = EState::FileWriteTransactional;
|
x10_state = EState::FileWriteTransactional;
|
||||||
ECardResult result = x198_fileInfo->Write();
|
ECardResult result = x198_fileInfo->WriteFile();
|
||||||
if (result != ECardResult::READY)
|
if (result != ECardResult::READY)
|
||||||
UpdateFileWriteTransactional(result);
|
UpdateFileWriteTransactional(result);
|
||||||
}
|
}
|
||||||
|
@ -658,7 +649,7 @@ void CMemoryCardDriver::UpdateFileWrite(ECardResult result)
|
||||||
if (xferResult == ECardResult::READY)
|
if (xferResult == ECardResult::READY)
|
||||||
{
|
{
|
||||||
x10_state = EState::Ready;
|
x10_state = EState::Ready;
|
||||||
if (x198_fileInfo->Close() == ECardResult::READY)
|
if (x198_fileInfo->CloseFile() == ECardResult::READY)
|
||||||
return;
|
return;
|
||||||
NoCardFound();
|
NoCardFound();
|
||||||
return;
|
return;
|
||||||
|
@ -696,7 +687,7 @@ void CMemoryCardDriver::UpdateFileWriteTransactional(ECardResult result)
|
||||||
if (xferResult == ECardResult::READY)
|
if (xferResult == ECardResult::READY)
|
||||||
{
|
{
|
||||||
x10_state = EState::FileWriteTransactionalDone;
|
x10_state = EState::FileWriteTransactionalDone;
|
||||||
if (x198_fileInfo->Close() != ECardResult::READY)
|
if (x198_fileInfo->CloseFile() != ECardResult::READY)
|
||||||
{
|
{
|
||||||
NoCardFound();
|
NoCardFound();
|
||||||
return;
|
return;
|
||||||
|
@ -768,7 +759,7 @@ void CMemoryCardDriver::InitializeFileInfo()
|
||||||
x198_fileInfo->SetComment(comment);
|
x198_fileInfo->SetComment(comment);
|
||||||
|
|
||||||
x198_fileInfo->LockBannerToken(x4_saveBanner, *g_SimplePool);
|
x198_fileInfo->LockBannerToken(x4_saveBanner, *g_SimplePool);
|
||||||
x198_fileInfo->LockIconToken(x8_saveIcon0, 2, *g_SimplePool);
|
x198_fileInfo->LockIconToken(x8_saveIcon0, kabufuda::EAnimationSpeed::Middle, *g_SimplePool);
|
||||||
|
|
||||||
CMemoryOutStream w = x198_fileInfo->BeginMemoryOut(3004);
|
CMemoryOutStream w = x198_fileInfo->BeginMemoryOut(3004);
|
||||||
|
|
||||||
|
@ -825,7 +816,7 @@ void CMemoryCardDriver::HandleCardError(ECardResult result, EState state)
|
||||||
|
|
||||||
void CMemoryCardDriver::Update()
|
void CMemoryCardDriver::Update()
|
||||||
{
|
{
|
||||||
CMemoryCardSys::CardProbeResults result = CMemoryCardSys::CardProbe(x0_cardPort);
|
kabufuda::ProbeResults result = CMemoryCardSys::CardProbe(x0_cardPort);
|
||||||
|
|
||||||
if (result.x0_error == ECardResult::NOCARD)
|
if (result.x0_error == ECardResult::NOCARD)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,30 +70,22 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CARDFileInfo
|
|
||||||
{
|
|
||||||
CMemoryCardSys::EMemoryCardPort x0_cardPort;
|
|
||||||
int x4_fileNo = -1;
|
|
||||||
int x8_offset;
|
|
||||||
int xc_length;
|
|
||||||
u16 iBlock;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SFileInfo
|
struct SFileInfo
|
||||||
{
|
{
|
||||||
CARDFileInfo x0_fileInfo;
|
CMemoryCardSys::CardFileHandle x0_fileInfo;
|
||||||
std::string x14_name;
|
std::string x14_name;
|
||||||
std::vector<u8> x24_saveFileData;
|
std::vector<u8> x24_saveFileData;
|
||||||
std::vector<u8> x34_saveData;
|
std::vector<u8> x34_saveData;
|
||||||
SFileInfo(CMemoryCardSys::EMemoryCardPort cardPort, const std::string& name);
|
SFileInfo(kabufuda::ECardSlot cardPort, const std::string& name);
|
||||||
CMemoryCardSys::ECardResult Open();
|
kabufuda::ECardResult Open();
|
||||||
CMemoryCardSys::ECardResult Close();
|
kabufuda::ECardResult Close();
|
||||||
CMemoryCardSys::EMemoryCardPort GetFileCardPort() const { return x0_fileInfo.x0_cardPort; }
|
kabufuda::ECardSlot GetFileCardPort() const { return x0_fileInfo.slot; }
|
||||||
int GetFileNo() const { return x0_fileInfo.x4_fileNo; }
|
int GetFileNo() const { return x0_fileInfo->getFileNo(); }
|
||||||
CMemoryCardSys::ECardResult StartRead();
|
kabufuda::ECardResult StartRead();
|
||||||
CMemoryCardSys::ECardResult TryFileRead();
|
kabufuda::ECardResult TryFileRead();
|
||||||
CMemoryCardSys::ECardResult FileRead();
|
kabufuda::ECardResult FileRead();
|
||||||
CMemoryCardSys::ECardResult GetSaveDataOffset(u32& offOut);
|
kabufuda::ECardResult GetSaveDataOffset(u32& offOut);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSaveHeader
|
struct SSaveHeader
|
||||||
|
@ -129,7 +121,7 @@ private:
|
||||||
BadFile
|
BadFile
|
||||||
};
|
};
|
||||||
|
|
||||||
CMemoryCardSys::EMemoryCardPort x0_cardPort;
|
kabufuda::ECardSlot x0_cardPort;
|
||||||
ResId x4_saveBanner;
|
ResId x4_saveBanner;
|
||||||
ResId x8_saveIcon0;
|
ResId x8_saveIcon0;
|
||||||
ResId xc_saveIcon1;
|
ResId xc_saveIcon1;
|
||||||
|
@ -148,7 +140,7 @@ private:
|
||||||
bool x19d_doImportPersistent;
|
bool x19d_doImportPersistent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMemoryCardDriver(CMemoryCardSys::EMemoryCardPort cardPort, ResId saveBanner,
|
CMemoryCardDriver(kabufuda::ECardSlot cardPort, ResId saveBanner,
|
||||||
ResId saveIcon0, ResId saveIcon1, bool importPersistent);
|
ResId saveIcon0, ResId saveIcon1, bool importPersistent);
|
||||||
|
|
||||||
void NoCardFound();
|
void NoCardFound();
|
||||||
|
@ -176,24 +168,24 @@ public:
|
||||||
void StartCardFormat(); // 37
|
void StartCardFormat(); // 37
|
||||||
|
|
||||||
void UpdateCardProbe(); // 25
|
void UpdateCardProbe(); // 25
|
||||||
void UpdateMountCard(CMemoryCardSys::ECardResult result); // 26
|
void UpdateMountCard(kabufuda::ECardResult result); // 26
|
||||||
void UpdateCardCheck(CMemoryCardSys::ECardResult result); // 27
|
void UpdateCardCheck(kabufuda::ECardResult result); // 27
|
||||||
void UpdateFileDeleteBad(CMemoryCardSys::ECardResult result); // 28
|
void UpdateFileDeleteBad(kabufuda::ECardResult result); // 28
|
||||||
void UpdateFileRead(CMemoryCardSys::ECardResult result); // 29
|
void UpdateFileRead(kabufuda::ECardResult result); // 29
|
||||||
void UpdateFileDeleteAlt(CMemoryCardSys::ECardResult result); // 30
|
void UpdateFileDeleteAlt(kabufuda::ECardResult result); // 30
|
||||||
void UpdateFileCreate(CMemoryCardSys::ECardResult result); // 31
|
void UpdateFileCreate(kabufuda::ECardResult result); // 31
|
||||||
void UpdateFileWrite(CMemoryCardSys::ECardResult result); // 32
|
void UpdateFileWrite(kabufuda::ECardResult result); // 32
|
||||||
void UpdateFileCreateTransactional(CMemoryCardSys::ECardResult result); // 33
|
void UpdateFileCreateTransactional(kabufuda::ECardResult result); // 33
|
||||||
void UpdateFileWriteTransactional(CMemoryCardSys::ECardResult result); // 34
|
void UpdateFileWriteTransactional(kabufuda::ECardResult result); // 34
|
||||||
void UpdateFileDeleteAltTransactional(CMemoryCardSys::ECardResult result); // 35
|
void UpdateFileDeleteAltTransactional(kabufuda::ECardResult result); // 35
|
||||||
void UpdateFileRenameBtoA(CMemoryCardSys::ECardResult result); // 36
|
void UpdateFileRenameBtoA(kabufuda::ECardResult result); // 36
|
||||||
void UpdateCardFormat(CMemoryCardSys::ECardResult result); // 37
|
void UpdateCardFormat(kabufuda::ECardResult result); // 37
|
||||||
|
|
||||||
void ClearFileInfo() { x198_fileInfo.reset(); }
|
void ClearFileInfo() { x198_fileInfo.reset(); }
|
||||||
void InitializeFileInfo();
|
void InitializeFileInfo();
|
||||||
void WriteBackupBuf();
|
void WriteBackupBuf();
|
||||||
bool GetCardFreeBytes();
|
bool GetCardFreeBytes();
|
||||||
void HandleCardError(CMemoryCardSys::ECardResult result, EState state);
|
void HandleCardError(kabufuda::ECardResult result, EState state);
|
||||||
void Update();
|
void Update();
|
||||||
void ClearError() { x14_error = EError::OK; }
|
void ClearError() { x14_error = EError::OK; }
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ CIOWin::EMessageReturn CSaveUI::Update(float dt)
|
||||||
|
|
||||||
if (x6c_cardDriver->x10_state == EState::NoCard)
|
if (x6c_cardDriver->x10_state == EState::NoCard)
|
||||||
{
|
{
|
||||||
auto res = CMemoryCardSys::CardProbe(CMemoryCardSys::EMemoryCardPort::SlotA);
|
auto res = CMemoryCardSys::CardProbe(kabufuda::ECardSlot::SlotA);
|
||||||
if (res.x0_error == CMemoryCardSys::ECardResult::READY ||
|
if (res.x0_error == CMemoryCardSys::ECardResult::READY ||
|
||||||
res.x0_error == CMemoryCardSys::ECardResult::WRONGDEVICE)
|
res.x0_error == CMemoryCardSys::ECardResult::WRONGDEVICE)
|
||||||
ResetCardDriver();
|
ResetCardDriver();
|
||||||
|
@ -257,7 +257,7 @@ CSaveUI::CSaveUI(u32 instIdx, u64 serial)
|
||||||
|
|
||||||
std::unique_ptr<CMemoryCardDriver> CSaveUI::ConstructCardDriver(bool importState)
|
std::unique_ptr<CMemoryCardDriver> CSaveUI::ConstructCardDriver(bool importState)
|
||||||
{
|
{
|
||||||
return std::make_unique<CMemoryCardDriver>(CMemoryCardSys::EMemoryCardPort::SlotA,
|
return std::make_unique<CMemoryCardDriver>(kabufuda::ECardSlot::SlotA,
|
||||||
g_ResFactory->GetResourceIdByName("TXTR_SaveBanner")->id,
|
g_ResFactory->GetResourceIdByName("TXTR_SaveBanner")->id,
|
||||||
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon0")->id,
|
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon0")->id,
|
||||||
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon1")->id, importState);
|
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon1")->id, importState);
|
||||||
|
|
2
kabufuda
2
kabufuda
|
@ -1 +1 @@
|
||||||
Subproject commit 31029767c8238d0cd9f301153a7196150a45c25d
|
Subproject commit 223ea9a56ebc8ad7e03a2b920dbdc9d621cda551
|
Loading…
Reference in New Issue