mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
GCMemcardRaw: Amend variable naming
This commit is contained in:
parent
79246d9642
commit
4df8ac7820
@ -22,30 +22,31 @@
|
||||
#define SIZE_TO_Mb (1024 * 8 * 16)
|
||||
#define MC_HDR_SIZE 0xA000
|
||||
|
||||
MemoryCard::MemoryCard(const std::string& filename, int _card_index, u16 sizeMb)
|
||||
: MemoryCardBase(_card_index, sizeMb), m_filename(filename)
|
||||
MemoryCard::MemoryCard(const std::string& filename, int card_index, u16 size_mbits)
|
||||
: MemoryCardBase(card_index, size_mbits), m_filename(filename)
|
||||
{
|
||||
File::IOFile pFile(m_filename, "rb");
|
||||
if (pFile)
|
||||
File::IOFile file(m_filename, "rb");
|
||||
if (file)
|
||||
{
|
||||
// Measure size of the existing memcard file.
|
||||
m_memory_card_size = (u32)pFile.GetSize();
|
||||
m_memory_card_size = (u32)file.GetSize();
|
||||
m_nintendo_card_id = m_memory_card_size / SIZE_TO_Mb;
|
||||
m_memcard_data = std::make_unique<u8[]>(m_memory_card_size);
|
||||
memset(&m_memcard_data[0], 0xFF, m_memory_card_size);
|
||||
|
||||
INFO_LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_filename.c_str());
|
||||
pFile.ReadBytes(&m_memcard_data[0], m_memory_card_size);
|
||||
file.ReadBytes(&m_memcard_data[0], m_memory_card_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new 128Mb memcard
|
||||
m_nintendo_card_id = sizeMb;
|
||||
m_memory_card_size = sizeMb * SIZE_TO_Mb;
|
||||
m_nintendo_card_id = size_mbits;
|
||||
m_memory_card_size = size_mbits * SIZE_TO_Mb;
|
||||
|
||||
m_memcard_data = std::make_unique<u8[]>(m_memory_card_size);
|
||||
// Fills in MC_HDR_SIZE bytes
|
||||
GCMemcard::Format(&m_memcard_data[0], m_filename.find(".JAP.raw") != std::string::npos, sizeMb);
|
||||
GCMemcard::Format(&m_memcard_data[0], m_filename.find(".JAP.raw") != std::string::npos,
|
||||
size_mbits);
|
||||
memset(&m_memcard_data[MC_HDR_SIZE], 0xFF, m_memory_card_size - MC_HDR_SIZE);
|
||||
|
||||
INFO_LOG(EXPANSIONINTERFACE, "No memory card found. A new one was created instead.");
|
||||
@ -95,9 +96,9 @@ void MemoryCard::FlushThread()
|
||||
|
||||
// Opening the file is purposefully done each iteration to ensure the
|
||||
// file doesn't disappear out from under us after the first check.
|
||||
File::IOFile pFile(m_filename, "r+b");
|
||||
File::IOFile file(m_filename, "r+b");
|
||||
|
||||
if (!pFile)
|
||||
if (!file)
|
||||
{
|
||||
std::string dir;
|
||||
SplitPath(m_filename, &dir, nullptr, nullptr);
|
||||
@ -105,11 +106,11 @@ void MemoryCard::FlushThread()
|
||||
{
|
||||
File::CreateFullPath(dir);
|
||||
}
|
||||
pFile.Open(m_filename, "wb");
|
||||
file.Open(m_filename, "wb");
|
||||
}
|
||||
|
||||
// Note - pFile may have changed above, after ctor
|
||||
if (!pFile)
|
||||
// Note - file may have changed above, after ctor
|
||||
if (!file)
|
||||
{
|
||||
PanicAlertT(
|
||||
"Could not write memory card file %s.\n\n"
|
||||
@ -127,7 +128,7 @@ void MemoryCard::FlushThread()
|
||||
std::unique_lock<std::mutex> l(m_flush_mutex);
|
||||
memcpy(&m_flush_buffer[0], &m_memcard_data[0], m_memory_card_size);
|
||||
}
|
||||
pFile.WriteBytes(&m_flush_buffer[0], m_memory_card_size);
|
||||
file.WriteBytes(&m_flush_buffer[0], m_memory_card_size);
|
||||
|
||||
if (!do_exit)
|
||||
{
|
||||
@ -148,29 +149,29 @@ void MemoryCard::MakeDirty()
|
||||
m_dirty.Set();
|
||||
}
|
||||
|
||||
s32 MemoryCard::Read(u32 srcaddress, s32 length, u8* destaddress)
|
||||
s32 MemoryCard::Read(u32 src_address, s32 length, u8* dest_address)
|
||||
{
|
||||
if (!IsAddressInBounds(srcaddress))
|
||||
if (!IsAddressInBounds(src_address))
|
||||
{
|
||||
PanicAlertT("MemoryCard: Read called with invalid source address (0x%x)", srcaddress);
|
||||
PanicAlertT("MemoryCard: Read called with invalid source address (0x%x)", src_address);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(destaddress, &m_memcard_data[srcaddress], length);
|
||||
memcpy(dest_address, &m_memcard_data[src_address], length);
|
||||
return length;
|
||||
}
|
||||
|
||||
s32 MemoryCard::Write(u32 destaddress, s32 length, const u8* srcaddress)
|
||||
s32 MemoryCard::Write(u32 dest_address, s32 length, const u8* src_address)
|
||||
{
|
||||
if (!IsAddressInBounds(destaddress))
|
||||
if (!IsAddressInBounds(dest_address))
|
||||
{
|
||||
PanicAlertT("MemoryCard: Write called with invalid destination address (0x%x)", destaddress);
|
||||
PanicAlertT("MemoryCard: Write called with invalid destination address (0x%x)", dest_address);
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_flush_mutex);
|
||||
memcpy(&m_memcard_data[destaddress], srcaddress, length);
|
||||
memcpy(&m_memcard_data[dest_address], src_address, length);
|
||||
}
|
||||
MakeDirty();
|
||||
return length;
|
||||
|
@ -17,13 +17,13 @@ class PointerWrap;
|
||||
class MemoryCard : public MemoryCardBase
|
||||
{
|
||||
public:
|
||||
MemoryCard(const std::string& filename, int _card_index, u16 sizeMb = MemCard2043Mb);
|
||||
MemoryCard(const std::string& filename, int card_index, u16 size_mbits = MemCard2043Mb);
|
||||
~MemoryCard();
|
||||
void FlushThread();
|
||||
void MakeDirty();
|
||||
|
||||
s32 Read(u32 address, s32 length, u8* destaddress) override;
|
||||
s32 Write(u32 destaddress, s32 length, const u8* srcaddress) override;
|
||||
s32 Read(u32 src_address, s32 length, u8* dest_address) override;
|
||||
s32 Write(u32 dest_address, s32 length, const u8* src_address) override;
|
||||
void ClearBlock(u32 address) override;
|
||||
void ClearAll() override;
|
||||
void DoState(PointerWrap& p) override;
|
||||
|
Loading…
Reference in New Issue
Block a user