GCMemcard: Rename MemCardXMb constants to MBIT_SIZE_MEMORY_CARD_X for consistency with other constants.

This commit is contained in:
Admiral H. Curtiss 2019-08-14 23:31:43 +02:00
parent b54a49eaaf
commit 8fc2f0ff2d
4 changed files with 23 additions and 20 deletions

View File

@ -141,7 +141,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gciFolder) : card_index(ind
bool useMC251; bool useMC251;
IniFile gameIni = SConfig::GetInstance().LoadGameIni(); IniFile gameIni = SConfig::GetInstance().LoadGameIni();
gameIni.GetOrCreateSection("Core")->Get("MemoryCard251", &useMC251, false); gameIni.GetOrCreateSection("Core")->Get("MemoryCard251", &useMC251, false);
u16 sizeMb = useMC251 ? MemCard251Mb : MemCard2043Mb; u16 sizeMb = useMC251 ? MBIT_SIZE_MEMORY_CARD_251 : MBIT_SIZE_MEMORY_CARD_2043;
if (gciFolder) if (gciFolder)
{ {
@ -241,7 +241,7 @@ void CEXIMemoryCard::SetupRawMemcard(u16 sizeMb)
SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(SConfig::GetInstance().m_region)); SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(SConfig::GetInstance().m_region));
MemoryCard::CheckPath(filename, region_dir, is_slot_a); MemoryCard::CheckPath(filename, region_dir, is_slot_a);
if (sizeMb == MemCard251Mb) if (sizeMb == MBIT_SIZE_MEMORY_CARD_251)
filename.insert(filename.find_last_of("."), ".251"); filename.insert(filename.find_last_of("."), ".251");
memorycard = std::make_unique<MemoryCard>(filename, card_index, sizeMb); memorycard = std::make_unique<MemoryCard>(filename, card_index, sizeMb);

View File

@ -94,12 +94,12 @@ std::pair<GCMemcardErrorCode, std::optional<GCMemcard>> GCMemcard::Open(std::str
const u64 filesize = file.GetSize(); const u64 filesize = file.GetSize();
const u64 filesize_megabits = BytesToMegabits(filesize).value_or(0); const u64 filesize_megabits = BytesToMegabits(filesize).value_or(0);
const std::array<u16, 6> valid_megabits = {{ const std::array<u16, 6> valid_megabits = {{
MemCard59Mb, MBIT_SIZE_MEMORY_CARD_59,
MemCard123Mb, MBIT_SIZE_MEMORY_CARD_123,
MemCard251Mb, MBIT_SIZE_MEMORY_CARD_251,
Memcard507Mb, MBIT_SIZE_MEMORY_CARD_507,
MemCard1019Mb, MBIT_SIZE_MEMORY_CARD_1019,
MemCard2043Mb, MBIT_SIZE_MEMORY_CARD_2043,
}}; }};
if (!std::any_of(valid_megabits.begin(), valid_megabits.end(), if (!std::any_of(valid_megabits.begin(), valid_megabits.end(),

View File

@ -128,17 +128,17 @@ constexpr u16 BAT_SIZE = 0xFFB;
// possible sizes of memory cards in megabits // possible sizes of memory cards in megabits
// TODO: Do memory card sizes have to be power of two? // TODO: Do memory card sizes have to be power of two?
// TODO: Are these all of them? A 4091 block card should work in theory at least. // TODO: Are these all of them? A 4091 block card should work in theory at least.
constexpr u16 MemCard59Mb = 0x04; constexpr u16 MBIT_SIZE_MEMORY_CARD_59 = 0x04;
constexpr u16 MemCard123Mb = 0x08; constexpr u16 MBIT_SIZE_MEMORY_CARD_123 = 0x08;
constexpr u16 MemCard251Mb = 0x10; constexpr u16 MBIT_SIZE_MEMORY_CARD_251 = 0x10;
constexpr u16 Memcard507Mb = 0x20; // FIXME: case constexpr u16 MBIT_SIZE_MEMORY_CARD_507 = 0x20;
constexpr u16 MemCard1019Mb = 0x40; constexpr u16 MBIT_SIZE_MEMORY_CARD_1019 = 0x40;
constexpr u16 MemCard2043Mb = 0x80; constexpr u16 MBIT_SIZE_MEMORY_CARD_2043 = 0x80;
class MemoryCardBase class MemoryCardBase
{ {
public: public:
explicit MemoryCardBase(int card_index = 0, int size_mbits = MemCard2043Mb) explicit MemoryCardBase(int card_index = 0, int size_mbits = MBIT_SIZE_MEMORY_CARD_2043)
: m_card_index(card_index), m_nintendo_card_id(size_mbits) : m_card_index(card_index), m_nintendo_card_id(size_mbits)
{ {
} }
@ -210,7 +210,8 @@ struct Header
// 0x1e00 bytes at 0x0200: Unused (0xff) // 0x1e00 bytes at 0x0200: Unused (0xff)
std::array<u8, 7680> m_unused_2; std::array<u8, 7680> m_unused_2;
explicit Header(int slot = 0, u16 size_mbits = MemCard2043Mb, bool shift_jis = false); explicit Header(int slot = 0, u16 size_mbits = MBIT_SIZE_MEMORY_CARD_2043,
bool shift_jis = false);
// Calculates the card serial numbers used for encrypting some save files. // Calculates the card serial numbers used for encrypting some save files.
std::pair<u32, u32> CalculateSerial() const; std::pair<u32, u32> CalculateSerial() const;
@ -353,7 +354,7 @@ struct BlockAlloc
// 0x1ff8 bytes at 0x000a: Map of allocated Blocks // 0x1ff8 bytes at 0x000a: Map of allocated Blocks
std::array<Common::BigEndianValue<u16>, BAT_SIZE> m_map; std::array<Common::BigEndianValue<u16>, BAT_SIZE> m_map;
explicit BlockAlloc(u16 size_mbits = MemCard2043Mb); explicit BlockAlloc(u16 size_mbits = MBIT_SIZE_MEMORY_CARD_2043);
u16 GetNextBlock(u16 block) const; u16 GetNextBlock(u16 block) const;
u16 NextFreeBlock(u16 max_block, u16 starting_block = MC_FST_BLOCKS) const; u16 NextFreeBlock(u16 max_block, u16 starting_block = MC_FST_BLOCKS) const;
@ -408,8 +409,9 @@ public:
bool IsValid() const { return m_valid; } bool IsValid() const { return m_valid; }
bool IsShiftJIS() const; bool IsShiftJIS() const;
bool Save(); bool Save();
bool Format(bool shift_jis = false, u16 SizeMb = MemCard2043Mb); bool Format(bool shift_jis = false, u16 SizeMb = MBIT_SIZE_MEMORY_CARD_2043);
static bool Format(u8* card_data, bool shift_jis = false, u16 SizeMb = MemCard2043Mb); static bool Format(u8* card_data, bool shift_jis = false,
u16 SizeMb = MBIT_SIZE_MEMORY_CARD_2043);
static s32 FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, static s32 FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,
std::vector<GCMBlock>& FileBuffer); std::vector<GCMBlock>& FileBuffer);
static s32 PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, static s32 PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,

View File

@ -17,7 +17,8 @@ class PointerWrap;
class MemoryCard : public MemoryCardBase class MemoryCard : public MemoryCardBase
{ {
public: public:
MemoryCard(const std::string& filename, int card_index, u16 size_mbits = MemCard2043Mb); MemoryCard(const std::string& filename, int card_index,
u16 size_mbits = MBIT_SIZE_MEMORY_CARD_2043);
~MemoryCard(); ~MemoryCard();
static void CheckPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA); static void CheckPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA);
void FlushThread(); void FlushThread();