diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp index 7c4f453c27..db171bf378 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp @@ -141,7 +141,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gciFolder) : card_index(ind bool useMC251; IniFile gameIni = SConfig::GetInstance().LoadGameIni(); 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) { @@ -241,7 +241,7 @@ void CEXIMemoryCard::SetupRawMemcard(u16 sizeMb) SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(SConfig::GetInstance().m_region)); 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"); memorycard = std::make_unique(filename, card_index, sizeMb); diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index 434a8d892f..f610243238 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -94,12 +94,12 @@ std::pair> GCMemcard::Open(std::str const u64 filesize = file.GetSize(); const u64 filesize_megabits = BytesToMegabits(filesize).value_or(0); const std::array valid_megabits = {{ - MemCard59Mb, - MemCard123Mb, - MemCard251Mb, - Memcard507Mb, - MemCard1019Mb, - MemCard2043Mb, + MBIT_SIZE_MEMORY_CARD_59, + MBIT_SIZE_MEMORY_CARD_123, + MBIT_SIZE_MEMORY_CARD_251, + MBIT_SIZE_MEMORY_CARD_507, + MBIT_SIZE_MEMORY_CARD_1019, + MBIT_SIZE_MEMORY_CARD_2043, }}; if (!std::any_of(valid_megabits.begin(), valid_megabits.end(), diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.h b/Source/Core/Core/HW/GCMemcard/GCMemcard.h index 4f575dfe79..8855a493de 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.h +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.h @@ -128,17 +128,17 @@ constexpr u16 BAT_SIZE = 0xFFB; // possible sizes of memory cards in megabits // 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. -constexpr u16 MemCard59Mb = 0x04; -constexpr u16 MemCard123Mb = 0x08; -constexpr u16 MemCard251Mb = 0x10; -constexpr u16 Memcard507Mb = 0x20; // FIXME: case -constexpr u16 MemCard1019Mb = 0x40; -constexpr u16 MemCard2043Mb = 0x80; +constexpr u16 MBIT_SIZE_MEMORY_CARD_59 = 0x04; +constexpr u16 MBIT_SIZE_MEMORY_CARD_123 = 0x08; +constexpr u16 MBIT_SIZE_MEMORY_CARD_251 = 0x10; +constexpr u16 MBIT_SIZE_MEMORY_CARD_507 = 0x20; +constexpr u16 MBIT_SIZE_MEMORY_CARD_1019 = 0x40; +constexpr u16 MBIT_SIZE_MEMORY_CARD_2043 = 0x80; class MemoryCardBase { 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) { } @@ -210,7 +210,8 @@ struct Header // 0x1e00 bytes at 0x0200: Unused (0xff) std::array 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. std::pair CalculateSerial() const; @@ -353,7 +354,7 @@ struct BlockAlloc // 0x1ff8 bytes at 0x000a: Map of allocated Blocks std::array, 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 NextFreeBlock(u16 max_block, u16 starting_block = MC_FST_BLOCKS) const; @@ -408,8 +409,9 @@ public: bool IsValid() const { return m_valid; } bool IsShiftJIS() const; bool Save(); - bool Format(bool shift_jis = false, u16 SizeMb = MemCard2043Mb); - static bool Format(u8* card_data, 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 = MBIT_SIZE_MEMORY_CARD_2043); static s32 FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, std::vector& FileBuffer); static s32 PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h index 0659e33d3a..727d625aa4 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h @@ -17,7 +17,8 @@ class PointerWrap; class MemoryCard : public MemoryCardBase { 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(); static void CheckPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA); void FlushThread();