Replace MemoryCard251 setting with generic MemoryCardSize
This allows for a broader range of game-specific memory card sizes to be configured.
This commit is contained in:
parent
52a388af9a
commit
33a6701e56
|
@ -4,7 +4,7 @@
|
|||
# Values set here will override the main Dolphin settings.
|
||||
# This game does not work properly with large memorycards, use a 251 block card
|
||||
# see https://www.nintendo.com/consumer/memorycard1019.jsp
|
||||
MemoryCard251 = True
|
||||
MemoryCardSize = 2
|
||||
|
||||
[OnLoad]
|
||||
# Add memory patches to be loaded once on boot here.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Values set here will override the main Dolphin settings.
|
||||
# This game does not work properly with large memorycards, use a 251 block card
|
||||
# see https://www.nintendo.com/consumer/memorycard1019.jsp
|
||||
MemoryCard251 = True
|
||||
MemoryCardSize = 2
|
||||
|
||||
[OnLoad]
|
||||
# Add memory patches to be loaded once on boot here.
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
[Core]
|
||||
# Values set here will override the main Dolphin settings.
|
||||
MemoryCard251 = True
|
||||
MemoryCardSize = 2
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[Core]
|
||||
# Values set here will override the main Dolphin settings.
|
||||
MemoryCard251 = True
|
||||
MemoryCardSize = 2
|
||||
|
||||
[OnLoad]
|
||||
# Add memory patches to be loaded once on boot here.
|
||||
|
@ -14,4 +14,4 @@ MemoryCard251 = True
|
|||
# Add action replay cheats here.
|
||||
|
||||
[Video_Hacks]
|
||||
ImmediateXFBEnable = False
|
||||
ImmediateXFBEnable = False
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Values set here will override the main Dolphin settings.
|
||||
# This game does not work properly with large memorycards, use a 251 block card
|
||||
# see https://www.nintendo.com/consumer/memorycard1019.jsp
|
||||
MemoryCard251 = True
|
||||
MemoryCardSize = 2
|
||||
CPUThread = False
|
||||
|
||||
[OnLoad]
|
||||
|
|
|
@ -75,11 +75,12 @@ void Init()
|
|||
CEXIMemoryCard::Init();
|
||||
|
||||
{
|
||||
bool use_memcard_251;
|
||||
u16 size_mbits = Memcard::MBIT_SIZE_MEMORY_CARD_2043;
|
||||
int size_override;
|
||||
IniFile gameIni = SConfig::GetInstance().LoadGameIni();
|
||||
gameIni.GetOrCreateSection("Core")->Get("MemoryCard251", &use_memcard_251, false);
|
||||
const u16 size_mbits =
|
||||
use_memcard_251 ? Memcard::MBIT_SIZE_MEMORY_CARD_251 : Memcard::MBIT_SIZE_MEMORY_CARD_2043;
|
||||
gameIni.GetOrCreateSection("Core")->Get("MemoryCardSize", &size_override, -1);
|
||||
if (size_override >= 0 && size_override <= 4)
|
||||
size_mbits = Memcard::MBIT_SIZE_MEMORY_CARD_59 << size_override;
|
||||
const bool shift_jis =
|
||||
SConfig::ToGameCubeRegion(SConfig::GetInstance().m_region) == DiscIO::Region::NTSC_J;
|
||||
const CardFlashId& flash_id = g_SRAM.settings_ex.flash_id[Memcard::SLOT_A];
|
||||
|
|
|
@ -236,8 +236,11 @@ void CEXIMemoryCard::SetupRawMemcard(u16 size_mb)
|
|||
SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(SConfig::GetInstance().m_region));
|
||||
MemoryCard::CheckPath(filename, region_dir, is_slot_a);
|
||||
|
||||
if (size_mb == Memcard::MBIT_SIZE_MEMORY_CARD_251)
|
||||
filename.insert(filename.find_last_of('.'), ".251");
|
||||
if (size_mb < Memcard::MBIT_SIZE_MEMORY_CARD_2043)
|
||||
{
|
||||
filename.insert(filename.find_last_of('.'),
|
||||
fmt::format(".{}", Memcard::MbitToFreeBlocks(size_mb)));
|
||||
}
|
||||
|
||||
m_memory_card = std::make_unique<MemoryCard>(filename, m_card_index, size_mb);
|
||||
}
|
||||
|
|
|
@ -673,7 +673,7 @@ std::optional<DEntry> GCMemcard::GetDEntry(u8 index) const
|
|||
BlockAlloc::BlockAlloc(u16 size_mbits)
|
||||
{
|
||||
memset(this, 0, BLOCK_SIZE);
|
||||
m_free_blocks = (size_mbits * MBIT_TO_BLOCKS) - MC_FST_BLOCKS;
|
||||
m_free_blocks = MbitToFreeBlocks(size_mbits);
|
||||
m_last_allocated_block = 4;
|
||||
FixChecksums();
|
||||
}
|
||||
|
|
|
@ -141,6 +141,11 @@ constexpr u8 MEMORY_CARD_ICON_FORMAT_CI8_UNIQUE_PALETTE = 3;
|
|||
// each palette entry is 16 bits in RGB5A3 format
|
||||
constexpr u32 MEMORY_CARD_CI8_PALETTE_ENTRIES = 256;
|
||||
|
||||
constexpr u32 MbitToFreeBlocks(u16 size_mb)
|
||||
{
|
||||
return size_mb * MBIT_TO_BLOCKS - MC_FST_BLOCKS;
|
||||
}
|
||||
|
||||
struct GCMBlock
|
||||
{
|
||||
GCMBlock();
|
||||
|
|
|
@ -203,8 +203,7 @@ GCMemcardDirectory::GCMemcardDirectory(const std::string& directory, int slot,
|
|||
}
|
||||
|
||||
// leave about 10% of free space on the card if possible
|
||||
const int total_blocks =
|
||||
m_hdr.m_data.m_size_mb * Memcard::MBIT_TO_BLOCKS - Memcard::MC_FST_BLOCKS;
|
||||
const int total_blocks = Memcard::MbitToFreeBlocks(m_hdr.m_data.m_size_mb);
|
||||
const int reserved_blocks = total_blocks / 10;
|
||||
|
||||
// load files for other games
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "Core/ConfigManager.h"
|
||||
#include "Core/GeckoCode.h"
|
||||
#include "Core/HW/EXI/EXI_DeviceIPL.h"
|
||||
#include "Core/HW/GCMemcard/GCMemcard.h"
|
||||
#include "Core/HW/SI/SI.h"
|
||||
#include "Core/HW/SI/SI_Device.h"
|
||||
#include "Core/HW/SI/SI_DeviceGCController.h"
|
||||
|
@ -856,8 +857,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
|||
|
||||
bool is_slot_a;
|
||||
std::string region;
|
||||
bool mc251;
|
||||
packet >> is_slot_a >> region >> mc251;
|
||||
int size_override;
|
||||
packet >> is_slot_a >> region >> size_override;
|
||||
|
||||
// This check is mainly intended to filter out characters which have special meanings in paths
|
||||
if (region != JAP_DIR && region != USA_DIR && region != EUR_DIR)
|
||||
|
@ -866,8 +867,15 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string size_suffix;
|
||||
if (size_override >= 0 && size_override <= 4)
|
||||
{
|
||||
size_suffix = fmt::format(
|
||||
".{}", Memcard::MbitToFreeBlocks(Memcard::MBIT_SIZE_MEMORY_CARD_59 << size_override));
|
||||
}
|
||||
|
||||
const std::string path = File::GetUserPath(D_GCUSER_IDX) + GC_MEMCARD_NETPLAY +
|
||||
(is_slot_a ? "A." : "B.") + region + (mc251 ? ".251" : "") + ".raw";
|
||||
(is_slot_a ? "A." : "B.") + region + size_suffix + ".raw";
|
||||
if (File::Exists(path) && !File::Delete(path))
|
||||
{
|
||||
PanicAlertFmtT("Failed to delete NetPlay memory card. Verify your write permissions.");
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "Core/ConfigManager.h"
|
||||
#include "Core/GeckoCode.h"
|
||||
#include "Core/GeckoCodeConfig.h"
|
||||
#include "Core/HW/GCMemcard/GCMemcard.h"
|
||||
#include "Core/HW/GCMemcard/GCMemcardDirectory.h"
|
||||
#include "Core/HW/GCMemcard/GCMemcardRaw.h"
|
||||
#include "Core/HW/Sram.h"
|
||||
|
@ -1572,17 +1573,21 @@ bool NetPlayServer::SyncSaveData()
|
|||
|
||||
MemoryCard::CheckPath(path, region, is_slot_a);
|
||||
|
||||
bool mc251;
|
||||
int size_override;
|
||||
IniFile gameIni = SConfig::LoadGameIni(game->GetGameID(), game->GetRevision());
|
||||
gameIni.GetOrCreateSection("Core")->Get("MemoryCard251", &mc251, false);
|
||||
gameIni.GetOrCreateSection("Core")->Get("MemoryCardSize", &size_override, -1);
|
||||
|
||||
if (mc251)
|
||||
path.insert(path.find_last_of('.'), ".251");
|
||||
if (size_override >= 0 && size_override <= 4)
|
||||
{
|
||||
path.insert(path.find_last_of('.'),
|
||||
fmt::format(".{}", Memcard::MbitToFreeBlocks(Memcard::MBIT_SIZE_MEMORY_CARD_59
|
||||
<< size_override)));
|
||||
}
|
||||
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_RAW);
|
||||
pac << is_slot_a << region << mc251;
|
||||
pac << is_slot_a << region << size_override;
|
||||
|
||||
if (File::Exists(path))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue