Also override the SYSCONF country setting
Fixes https://bugs.dolphin-emu.org/issues/10066
This commit is contained in:
parent
561a4cfcce
commit
393709a45a
|
@ -387,7 +387,7 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
|
|||
g_SRAM_netplay_initialized = false;
|
||||
}
|
||||
|
||||
// Override out-of-region languages to prevent games from crashing or behaving oddly
|
||||
// Override out-of-region languages/countries to prevent games from crashing or behaving oddly
|
||||
if (!StartUp.bOverrideRegionSettings)
|
||||
{
|
||||
const int gc_language =
|
||||
|
@ -399,6 +399,26 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
|
|||
const u32 wii_language =
|
||||
static_cast<u32>(StartUp.GetLanguageAdjustedForRegion(true, StartUp.m_region));
|
||||
Config::SetCurrent(Config::SYSCONF_LANGUAGE, wii_language);
|
||||
|
||||
const u8 country_code = static_cast<u8>(Config::Get(Config::SYSCONF_COUNTRY));
|
||||
if (StartUp.m_region != DiscIO::SysConfCountryToRegion(country_code))
|
||||
{
|
||||
switch (StartUp.m_region)
|
||||
{
|
||||
case DiscIO::Region::NTSC_J:
|
||||
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x01); // Japan
|
||||
break;
|
||||
case DiscIO::Region::NTSC_U:
|
||||
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x31); // United States
|
||||
break;
|
||||
case DiscIO::Region::PAL:
|
||||
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x6c); // Switzerland
|
||||
break;
|
||||
case DiscIO::Region::NTSC_K:
|
||||
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x88); // South Korea
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Config
|
|||
|
||||
const ConfigInfo<bool> SYSCONF_SCREENSAVER{{System::SYSCONF, "IPL", "SSV"}, false};
|
||||
const ConfigInfo<u32> SYSCONF_LANGUAGE{{System::SYSCONF, "IPL", "LNG"}, 0x01};
|
||||
const ConfigInfo<u32> SYSCONF_COUNTRY{{System::SYSCONF, "IPL", "SADR"}, 0x6c};
|
||||
const ConfigInfo<bool> SYSCONF_WIDESCREEN{{System::SYSCONF, "IPL", "AR"}, true};
|
||||
const ConfigInfo<bool> SYSCONF_PROGRESSIVE_SCAN{{System::SYSCONF, "IPL", "PGS"}, true};
|
||||
const ConfigInfo<bool> SYSCONF_PAL60{{System::SYSCONF, "IPL", "E60"}, 0x01};
|
||||
|
@ -21,9 +22,10 @@ const ConfigInfo<u32> SYSCONF_SENSOR_BAR_SENSITIVITY{{System::SYSCONF, "BT", "SE
|
|||
const ConfigInfo<u32> SYSCONF_SPEAKER_VOLUME{{System::SYSCONF, "BT", "SPKV"}, 0x58};
|
||||
const ConfigInfo<bool> SYSCONF_WIIMOTE_MOTOR{{System::SYSCONF, "BT", "MOT"}, true};
|
||||
|
||||
const std::array<SYSCONFSetting, 9> SYSCONF_SETTINGS{
|
||||
const std::array<SYSCONFSetting, 10> SYSCONF_SETTINGS{
|
||||
{{SYSCONF_SCREENSAVER, SysConf::Entry::Type::Byte},
|
||||
{SYSCONF_LANGUAGE, SysConf::Entry::Type::Byte},
|
||||
{SYSCONF_COUNTRY, SysConf::Entry::Type::BigArray},
|
||||
{SYSCONF_WIDESCREEN, SysConf::Entry::Type::Byte},
|
||||
{SYSCONF_PROGRESSIVE_SCAN, SysConf::Entry::Type::Byte},
|
||||
{SYSCONF_PAL60, SysConf::Entry::Type::Byte},
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Config
|
|||
|
||||
extern const ConfigInfo<bool> SYSCONF_SCREENSAVER;
|
||||
extern const ConfigInfo<u32> SYSCONF_LANGUAGE;
|
||||
extern const ConfigInfo<u32> SYSCONF_COUNTRY;
|
||||
extern const ConfigInfo<bool> SYSCONF_WIDESCREEN;
|
||||
extern const ConfigInfo<bool> SYSCONF_PROGRESSIVE_SCAN;
|
||||
extern const ConfigInfo<bool> SYSCONF_PAL60;
|
||||
|
@ -35,6 +36,6 @@ struct SYSCONFSetting
|
|||
SysConf::Entry::Type type;
|
||||
};
|
||||
|
||||
extern const std::array<SYSCONFSetting, 9> SYSCONF_SETTINGS;
|
||||
extern const std::array<SYSCONFSetting, 10> SYSCONF_SETTINGS;
|
||||
|
||||
} // namespace Config
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "Core/ConfigLoaders/BaseConfigLoader.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
@ -43,9 +44,22 @@ void SaveToSYSCONF(Config::LayerType layer)
|
|||
const std::string key = info.location.section + "." + info.location.key;
|
||||
|
||||
if (setting.type == SysConf::Entry::Type::Long)
|
||||
{
|
||||
sysconf.SetData<u32>(key, setting.type, Config::Get(layer, info));
|
||||
}
|
||||
else if (setting.type == SysConf::Entry::Type::Byte)
|
||||
{
|
||||
sysconf.SetData<u8>(key, setting.type, static_cast<u8>(Config::Get(layer, info)));
|
||||
}
|
||||
else if (setting.type == SysConf::Entry::Type::BigArray)
|
||||
{
|
||||
// Somewhat hacky support for IPL.SADR. The setting only stores the
|
||||
// first 4 bytes even thought the SYSCONF entry is much bigger.
|
||||
SysConf::Entry* entry = sysconf.GetOrAddEntry(key, setting.type);
|
||||
if (entry->bytes.size() < 0x1007 + 1)
|
||||
entry->bytes.resize(0x1007 + 1);
|
||||
*reinterpret_cast<u32*>(entry->bytes.data()) = Config::Get(layer, info);
|
||||
}
|
||||
},
|
||||
setting.config_info);
|
||||
}
|
||||
|
@ -167,9 +181,26 @@ private:
|
|||
[&](auto& info) {
|
||||
const std::string key = info.location.section + "." + info.location.key;
|
||||
if (setting.type == SysConf::Entry::Type::Long)
|
||||
{
|
||||
layer->Set(info.location, sysconf.GetData<u32>(key, info.default_value));
|
||||
}
|
||||
else if (setting.type == SysConf::Entry::Type::Byte)
|
||||
{
|
||||
layer->Set(info.location, sysconf.GetData<u8>(key, info.default_value));
|
||||
}
|
||||
else if (setting.type == SysConf::Entry::Type::BigArray)
|
||||
{
|
||||
// Somewhat hacky support for IPL.SADR. The setting only stores the
|
||||
// first 4 bytes even thought the SYSCONF entry is much bigger.
|
||||
u32 value = info.default_value;
|
||||
SysConf::Entry* entry = sysconf.GetEntry(key);
|
||||
if (entry)
|
||||
{
|
||||
std::memcpy(&value, entry->bytes.data(),
|
||||
std::min(entry->bytes.size(), sizeof(u32)));
|
||||
}
|
||||
layer->Set(info.location, value);
|
||||
}
|
||||
},
|
||||
setting.config_info);
|
||||
}
|
||||
|
|
|
@ -145,6 +145,29 @@ Country TypicalCountryForRegion(Region region)
|
|||
}
|
||||
}
|
||||
|
||||
Region SysConfCountryToRegion(u8 country_code)
|
||||
{
|
||||
if (country_code == 0)
|
||||
return Region::Unknown;
|
||||
|
||||
if (country_code < 0x08) // Japan
|
||||
return Region::NTSC_J;
|
||||
|
||||
if (country_code < 0x40) // Americas
|
||||
return Region::NTSC_U;
|
||||
|
||||
if (country_code < 0x80) // Europe, Oceania, parts of Africa
|
||||
return Region::PAL;
|
||||
|
||||
if (country_code < 0xa8) // Southeast Asia
|
||||
return country_code == 0x88 ? Region::NTSC_K : Region::NTSC_J;
|
||||
|
||||
if (country_code < 0xc0) // Middle East
|
||||
return Region::NTSC_U;
|
||||
|
||||
return Region::Unknown;
|
||||
}
|
||||
|
||||
Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region,
|
||||
std::optional<u16> revision)
|
||||
{
|
||||
|
|
|
@ -77,6 +77,7 @@ bool IsWii(Platform volume_type);
|
|||
bool IsNTSC(Region region);
|
||||
|
||||
Country TypicalCountryForRegion(Region region);
|
||||
Region SysConfCountryToRegion(u8 country_code);
|
||||
// Avoid using this function if you can. Country codes aren't always reliable region indicators.
|
||||
Region CountryCodeToRegion(u8 country_code, Platform platform,
|
||||
Region expected_region = Region::Unknown,
|
||||
|
|
Loading…
Reference in New Issue