GCMemcard: Amend variable naming for MemoryCardBase

This commit is contained in:
Lioncash 2017-03-14 22:57:40 -04:00
parent 2b38338a9d
commit 647bec4c17
3 changed files with 30 additions and 28 deletions

View File

@ -70,22 +70,22 @@ enum
class MemoryCardBase
{
public:
explicit MemoryCardBase(int _card_index = 0, int sizeMb = MemCard2043Mb)
: card_index(_card_index), nintendo_card_id(sizeMb)
explicit MemoryCardBase(int card_index = 0, int size_mbits = MemCard2043Mb)
: m_card_index(card_index), m_nintendo_card_id(size_mbits)
{
}
virtual ~MemoryCardBase() {}
virtual s32 Read(u32 address, s32 length, u8* destaddress) = 0;
virtual s32 Write(u32 destaddress, s32 length, const u8* srcaddress) = 0;
virtual s32 Read(u32 src_address, s32 length, u8* dest_address) = 0;
virtual s32 Write(u32 dest_address, s32 length, const u8* src_address) = 0;
virtual void ClearBlock(u32 address) = 0;
virtual void ClearAll() = 0;
virtual void DoState(PointerWrap& p) = 0;
u32 GetCardId() const { return nintendo_card_id; }
bool IsAddressInBounds(u32 address) const { return address <= (memory_card_size - 1); }
u32 GetCardId() const { return m_nintendo_card_id; }
bool IsAddressInBounds(u32 address) const { return address <= (m_memory_card_size - 1); }
protected:
int card_index;
u16 nintendo_card_id;
u32 memory_card_size;
int m_card_index;
u16 m_nintendo_card_id;
u32 m_memory_card_size;
};
struct GCMBlock

View File

@ -185,7 +185,8 @@ void GCMemcardDirectory::FlushThread()
return;
}
Common::SetCurrentThreadName(StringFromFormat("Memcard %d flushing thread", card_index).c_str());
Common::SetCurrentThreadName(
StringFromFormat("Memcard %d flushing thread", m_card_index).c_str());
while (true)
{

View File

@ -29,31 +29,31 @@ MemoryCard::MemoryCard(const std::string& filename, int _card_index, u16 sizeMb)
if (pFile)
{
// Measure size of the existing memcard file.
memory_card_size = (u32)pFile.GetSize();
nintendo_card_id = memory_card_size / SIZE_TO_Mb;
m_memcard_data = std::make_unique<u8[]>(memory_card_size);
memset(&m_memcard_data[0], 0xFF, memory_card_size);
m_memory_card_size = (u32)pFile.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], memory_card_size);
pFile.ReadBytes(&m_memcard_data[0], m_memory_card_size);
}
else
{
// Create a new 128Mb memcard
nintendo_card_id = sizeMb;
memory_card_size = sizeMb * SIZE_TO_Mb;
m_nintendo_card_id = sizeMb;
m_memory_card_size = sizeMb * SIZE_TO_Mb;
m_memcard_data = std::make_unique<u8[]>(memory_card_size);
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);
memset(&m_memcard_data[MC_HDR_SIZE], 0xFF, memory_card_size - MC_HDR_SIZE);
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.");
}
// Class members (including inherited ones) have now been initialized, so
// it's safe to startup the flush thread (which reads them).
m_flush_buffer = std::make_unique<u8[]>(memory_card_size);
m_flush_buffer = std::make_unique<u8[]>(m_memory_card_size);
m_flush_thread = std::thread(&MemoryCard::FlushThread, this);
}
@ -74,7 +74,8 @@ void MemoryCard::FlushThread()
return;
}
Common::SetCurrentThreadName(StringFromFormat("Memcard %d flushing thread", card_index).c_str());
Common::SetCurrentThreadName(
StringFromFormat("Memcard %d flushing thread", m_card_index).c_str());
const auto flush_interval = std::chrono::seconds(15);
@ -124,14 +125,14 @@ void MemoryCard::FlushThread()
{
std::unique_lock<std::mutex> l(m_flush_mutex);
memcpy(&m_flush_buffer[0], &m_memcard_data[0], memory_card_size);
memcpy(&m_flush_buffer[0], &m_memcard_data[0], m_memory_card_size);
}
pFile.WriteBytes(&m_flush_buffer[0], memory_card_size);
pFile.WriteBytes(&m_flush_buffer[0], m_memory_card_size);
if (!do_exit)
{
Core::DisplayMessage(StringFromFormat("Wrote memory card %c contents to %s",
card_index ? 'B' : 'A', m_filename.c_str())
m_card_index ? 'B' : 'A', m_filename.c_str())
.c_str(),
4000);
}
@ -194,14 +195,14 @@ void MemoryCard::ClearAll()
{
{
std::unique_lock<std::mutex> l(m_flush_mutex);
memset(&m_memcard_data[0], 0xFF, memory_card_size);
memset(&m_memcard_data[0], 0xFF, m_memory_card_size);
}
MakeDirty();
}
void MemoryCard::DoState(PointerWrap& p)
{
p.Do(card_index);
p.Do(memory_card_size);
p.DoArray(&m_memcard_data[0], memory_card_size);
p.Do(m_card_index);
p.Do(m_memory_card_size);
p.DoArray(&m_memcard_data[0], m_memory_card_size);
}