Config: Move ToGameCubeRegion(), GetDirectoryForRegion(), and GetBootROMPath() to new config system namespace.
This commit is contained in:
parent
664663e8de
commit
2081e2f2a1
|
@ -311,8 +311,8 @@ std::unique_ptr<BootParameters> BootParameters::GenerateFromFile(std::vector<std
|
|||
|
||||
BootParameters::IPL::IPL(DiscIO::Region region_) : region(region_)
|
||||
{
|
||||
const std::string directory = SConfig::GetInstance().GetDirectoryForRegion(region);
|
||||
path = SConfig::GetInstance().GetBootROMPath(directory);
|
||||
const std::string directory = Config::GetDirectoryForRegion(region);
|
||||
path = Config::GetBootROMPath(directory);
|
||||
}
|
||||
|
||||
BootParameters::IPL::IPL(DiscIO::Region region_, Disc&& disc_) : IPL(region_)
|
||||
|
@ -434,7 +434,7 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename)
|
|||
if (known_ipl && pal_ipl != (boot_region == DiscIO::Region::PAL))
|
||||
{
|
||||
PanicAlertFmtT("{0} IPL found in {1} directory. The disc might not be recognized",
|
||||
pal_ipl ? "PAL" : "NTSC", SConfig::GetDirectoryForRegion(boot_region));
|
||||
pal_ipl ? "PAL" : "NTSC", Config::GetDirectoryForRegion(boot_region));
|
||||
}
|
||||
|
||||
// Run the descrambler over the encrypted section containing BS1/BS2
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "Common/CommonPaths.h"
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Common/EnumMap.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
@ -523,4 +524,51 @@ void SetUSBDeviceWhitelist(const std::set<std::pair<u16, u16>>& devices)
|
|||
{
|
||||
Config::SetBase(Config::MAIN_USB_PASSTHROUGH_DEVICES, SaveUSBWhitelistToString(devices));
|
||||
}
|
||||
|
||||
// The reason we need this function is because some memory card code
|
||||
// expects to get a non-NTSC-K region even if we're emulating an NTSC-K Wii.
|
||||
DiscIO::Region ToGameCubeRegion(DiscIO::Region region)
|
||||
{
|
||||
if (region != DiscIO::Region::NTSC_K)
|
||||
return region;
|
||||
|
||||
// GameCube has no NTSC-K region. No choice of replacement value is completely
|
||||
// non-arbitrary, but let's go with NTSC-J since Korean GameCubes are NTSC-J.
|
||||
return DiscIO::Region::NTSC_J;
|
||||
}
|
||||
|
||||
const char* GetDirectoryForRegion(DiscIO::Region region)
|
||||
{
|
||||
if (region == DiscIO::Region::Unknown)
|
||||
region = ToGameCubeRegion(Config::Get(Config::MAIN_FALLBACK_REGION));
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case DiscIO::Region::NTSC_J:
|
||||
return JAP_DIR;
|
||||
|
||||
case DiscIO::Region::NTSC_U:
|
||||
return USA_DIR;
|
||||
|
||||
case DiscIO::Region::PAL:
|
||||
return EUR_DIR;
|
||||
|
||||
case DiscIO::Region::NTSC_K:
|
||||
ASSERT_MSG(BOOT, false, "NTSC-K is not a valid GameCube region");
|
||||
return JAP_DIR; // See ToGameCubeRegion
|
||||
|
||||
default:
|
||||
ASSERT_MSG(BOOT, false, "Default case should not be reached");
|
||||
return EUR_DIR;
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetBootROMPath(const std::string& region_directory)
|
||||
{
|
||||
const std::string path =
|
||||
File::GetUserPath(D_GCUSER_IDX) + DIR_SEP + region_directory + DIR_SEP GC_IPL;
|
||||
if (!File::Exists(path))
|
||||
return File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + region_directory + DIR_SEP GC_IPL;
|
||||
return path;
|
||||
}
|
||||
} // namespace Config
|
||||
|
|
|
@ -331,4 +331,11 @@ extern const Info<std::string> MAIN_USB_PASSTHROUGH_DEVICES;
|
|||
std::set<std::pair<u16, u16>> GetUSBDeviceWhitelist();
|
||||
void SetUSBDeviceWhitelist(const std::set<std::pair<u16, u16>>& devices);
|
||||
|
||||
// GameCube path utility functions
|
||||
|
||||
// Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions
|
||||
DiscIO::Region ToGameCubeRegion(DiscIO::Region region);
|
||||
// The region argument must be valid for GameCube (i.e. must not be NTSC-K)
|
||||
const char* GetDirectoryForRegion(DiscIO::Region region);
|
||||
std::string GetBootROMPath(const std::string& region_directory);
|
||||
} // namespace Config
|
||||
|
|
|
@ -220,53 +220,6 @@ std::string SConfig::MakeGameID(std::string_view file_name)
|
|||
return "ID-" + std::string(file_name.substr(0, lastdot));
|
||||
}
|
||||
|
||||
// The reason we need this function is because some memory card code
|
||||
// expects to get a non-NTSC-K region even if we're emulating an NTSC-K Wii.
|
||||
DiscIO::Region SConfig::ToGameCubeRegion(DiscIO::Region region)
|
||||
{
|
||||
if (region != DiscIO::Region::NTSC_K)
|
||||
return region;
|
||||
|
||||
// GameCube has no NTSC-K region. No choice of replacement value is completely
|
||||
// non-arbitrary, but let's go with NTSC-J since Korean GameCubes are NTSC-J.
|
||||
return DiscIO::Region::NTSC_J;
|
||||
}
|
||||
|
||||
const char* SConfig::GetDirectoryForRegion(DiscIO::Region region)
|
||||
{
|
||||
if (region == DiscIO::Region::Unknown)
|
||||
region = ToGameCubeRegion(GetFallbackRegion());
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case DiscIO::Region::NTSC_J:
|
||||
return JAP_DIR;
|
||||
|
||||
case DiscIO::Region::NTSC_U:
|
||||
return USA_DIR;
|
||||
|
||||
case DiscIO::Region::PAL:
|
||||
return EUR_DIR;
|
||||
|
||||
case DiscIO::Region::NTSC_K:
|
||||
ASSERT_MSG(BOOT, false, "NTSC-K is not a valid GameCube region");
|
||||
return JAP_DIR; // See ToGameCubeRegion
|
||||
|
||||
default:
|
||||
ASSERT_MSG(BOOT, false, "Default case should not be reached");
|
||||
return EUR_DIR;
|
||||
}
|
||||
}
|
||||
|
||||
std::string SConfig::GetBootROMPath(const std::string& region_directory) const
|
||||
{
|
||||
const std::string path =
|
||||
File::GetUserPath(D_GCUSER_IDX) + DIR_SEP + region_directory + DIR_SEP GC_IPL;
|
||||
if (!File::Exists(path))
|
||||
return File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + region_directory + DIR_SEP GC_IPL;
|
||||
return path;
|
||||
}
|
||||
|
||||
struct SetGameMetadata
|
||||
{
|
||||
SetGameMetadata(SConfig* config_, DiscIO::Region* region_) : config(config_), region(region_) {}
|
||||
|
@ -375,21 +328,16 @@ bool SConfig::SetPathsAndGameMetadata(const BootParameters& boot)
|
|||
return false;
|
||||
|
||||
if (m_region == DiscIO::Region::Unknown)
|
||||
m_region = GetFallbackRegion();
|
||||
m_region = Config::Get(Config::MAIN_FALLBACK_REGION);
|
||||
|
||||
// Set up paths
|
||||
const std::string region_dir = GetDirectoryForRegion(ToGameCubeRegion(m_region));
|
||||
const std::string region_dir = Config::GetDirectoryForRegion(Config::ToGameCubeRegion(m_region));
|
||||
m_strSRAM = File::GetUserPath(F_GCSRAM_IDX);
|
||||
m_strBootROM = GetBootROMPath(region_dir);
|
||||
m_strBootROM = Config::GetBootROMPath(region_dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DiscIO::Region SConfig::GetFallbackRegion()
|
||||
{
|
||||
return Config::Get(Config::MAIN_FALLBACK_REGION);
|
||||
}
|
||||
|
||||
DiscIO::Language SConfig::GetCurrentLanguage(bool wii) const
|
||||
{
|
||||
DiscIO::Language language;
|
||||
|
|
|
@ -72,13 +72,7 @@ struct SConfig
|
|||
|
||||
void LoadDefaults();
|
||||
static std::string MakeGameID(std::string_view file_name);
|
||||
// Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions
|
||||
static DiscIO::Region ToGameCubeRegion(DiscIO::Region region);
|
||||
// The region argument must be valid for GameCube (i.e. must not be NTSC-K)
|
||||
static const char* GetDirectoryForRegion(DiscIO::Region region);
|
||||
std::string GetBootROMPath(const std::string& region_directory) const;
|
||||
bool SetPathsAndGameMetadata(const BootParameters& boot);
|
||||
static DiscIO::Region GetFallbackRegion();
|
||||
DiscIO::Language GetCurrentLanguage(bool wii) const;
|
||||
DiscIO::Language GetLanguageAdjustedForRegion(bool wii, DiscIO::Region region) const;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ void Init()
|
|||
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;
|
||||
Config::ToGameCubeRegion(SConfig::GetInstance().m_region) == DiscIO::Region::NTSC_J;
|
||||
const CardFlashId& flash_id = g_SRAM.settings_ex.flash_id[Memcard::SLOT_A];
|
||||
const u32 rtc_bias = g_SRAM.settings.rtc_bias;
|
||||
const u32 sram_language = static_cast<u32>(g_SRAM.settings.language);
|
||||
|
|
|
@ -162,8 +162,8 @@ CEXIMemoryCard::GetGCIFolderPath(Slot card_slot, AllowMovieFolder allow_movie_fo
|
|||
if (use_movie_folder)
|
||||
path += "Movie" DIR_SEP;
|
||||
|
||||
const DiscIO::Region region = SConfig::ToGameCubeRegion(SConfig::GetInstance().m_region);
|
||||
path = path + SConfig::GetDirectoryForRegion(region) + DIR_SEP +
|
||||
const DiscIO::Region region = Config::ToGameCubeRegion(SConfig::GetInstance().m_region);
|
||||
path = path + Config::GetDirectoryForRegion(region) + DIR_SEP +
|
||||
fmt::format("Card {}", s_card_short_names[card_slot]);
|
||||
return {std::move(path), !use_movie_folder};
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ void CEXIMemoryCard::SetupRawMemcard(u16 size_mb)
|
|||
}
|
||||
|
||||
const std::string region_dir =
|
||||
SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(SConfig::GetInstance().m_region));
|
||||
Config::GetDirectoryForRegion(Config::ToGameCubeRegion(SConfig::GetInstance().m_region));
|
||||
MemoryCard::CheckPath(filename, region_dir, m_card_slot);
|
||||
|
||||
if (size_mb < Memcard::MBIT_SIZE_MEMORY_CARD_2043)
|
||||
|
|
|
@ -1470,8 +1470,8 @@ bool NetPlayServer::StartGame()
|
|||
|
||||
const sf::Uint64 initial_rtc = GetInitialNetPlayRTC();
|
||||
|
||||
const std::string region = SConfig::GetDirectoryForRegion(
|
||||
SConfig::ToGameCubeRegion(m_dialog->FindGameFile(m_selected_game_identifier)->GetRegion()));
|
||||
const std::string region = Config::GetDirectoryForRegion(
|
||||
Config::ToGameCubeRegion(m_dialog->FindGameFile(m_selected_game_identifier)->GetRegion()));
|
||||
|
||||
// sync GC SRAM with clients
|
||||
if (!g_SRAM_netplay_initialized)
|
||||
|
@ -1666,7 +1666,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
return true;
|
||||
|
||||
const std::string region =
|
||||
SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(game->GetRegion()));
|
||||
Config::GetDirectoryForRegion(Config::ToGameCubeRegion(game->GetRegion()));
|
||||
|
||||
for (ExpansionInterface::Slot slot : ExpansionInterface::MEMCARD_SLOTS)
|
||||
{
|
||||
|
|
|
@ -713,7 +713,7 @@ void GameList::OpenGCSaveFolder()
|
|||
case ExpansionInterface::EXIDeviceType::MemoryCardFolder:
|
||||
{
|
||||
std::string path = StringFromFormat("%s/%s/%s", File::GetUserPath(D_GCUSER_IDX).c_str(),
|
||||
SConfig::GetDirectoryForRegion(game->GetRegion()),
|
||||
Config::GetDirectoryForRegion(game->GetRegion()),
|
||||
slot == Slot::A ? "Card A" : "Card B");
|
||||
|
||||
std::string override_path = Config::Get(Config::GetInfoForGCIPathOverride(slot));
|
||||
|
|
|
@ -1001,12 +1001,9 @@ void MenuBar::UpdateToolsMenu(bool emulation_started)
|
|||
{
|
||||
m_boot_sysmenu->setEnabled(!emulation_started);
|
||||
m_perform_online_update_menu->setEnabled(!emulation_started);
|
||||
m_ntscj_ipl->setEnabled(!emulation_started &&
|
||||
File::Exists(SConfig::GetInstance().GetBootROMPath(JAP_DIR)));
|
||||
m_ntscu_ipl->setEnabled(!emulation_started &&
|
||||
File::Exists(SConfig::GetInstance().GetBootROMPath(USA_DIR)));
|
||||
m_pal_ipl->setEnabled(!emulation_started &&
|
||||
File::Exists(SConfig::GetInstance().GetBootROMPath(EUR_DIR)));
|
||||
m_ntscj_ipl->setEnabled(!emulation_started && File::Exists(Config::GetBootROMPath(JAP_DIR)));
|
||||
m_ntscu_ipl->setEnabled(!emulation_started && File::Exists(Config::GetBootROMPath(USA_DIR)));
|
||||
m_pal_ipl->setEnabled(!emulation_started && File::Exists(Config::GetBootROMPath(EUR_DIR)));
|
||||
m_import_backup->setEnabled(!emulation_started);
|
||||
m_check_nand->setEnabled(!emulation_started);
|
||||
|
||||
|
|
Loading…
Reference in New Issue