Skip to content
Permalink
Browse files

Merge pull request #8222 from JosJuice/allow-mismatched-region-settings

Replace "Override Language on NTSC Games" with "Allow Mismatched Region Settings"
  • Loading branch information...
Helios747 committed Aug 21, 2019
2 parents bf9427f + 393709a commit 5f38386575948457a650afec25b2a32c2cab9247
@@ -218,6 +218,7 @@ private void addGeneralSettings(ArrayList<SettingsItem> sl)
Setting overclock = null;
Setting speedLimit = null;
Setting audioStretch = null;
Setting overrideRegionSettings = null;
Setting autoDiscChange = null;
Setting analytics = null;
Setting enableSaveState;
@@ -231,6 +232,7 @@ private void addGeneralSettings(ArrayList<SettingsItem> sl)
overclock = coreSection.getSetting(SettingsFile.KEY_OVERCLOCK_PERCENT);
speedLimit = coreSection.getSetting(SettingsFile.KEY_SPEED_LIMIT);
audioStretch = coreSection.getSetting(SettingsFile.KEY_AUDIO_STRETCH);
overrideRegionSettings = coreSection.getSetting(SettingsFile.KEY_OVERRIDE_REGION_SETTINGS);
autoDiscChange = coreSection.getSetting(SettingsFile.KEY_AUTO_DISC_CHANGE);
analytics = analyticsSection.getSetting(SettingsFile.KEY_ANALYTICS_ENABLED);
enableSaveState = coreSection.getSetting(SettingsFile.KEY_ENABLE_SAVE_STATES);
@@ -271,6 +273,9 @@ else if (defaultCpuCore == 4) // AArch64
R.string.speed_limit, 0, 200, "%", 100, speedLimit));
sl.add(new CheckBoxSetting(SettingsFile.KEY_AUDIO_STRETCH, Settings.SECTION_INI_CORE,
R.string.audio_stretch, R.string.audio_stretch_description, false, audioStretch));
sl.add(new CheckBoxSetting(SettingsFile.KEY_OVERRIDE_REGION_SETTINGS,
Settings.SECTION_INI_CORE, R.string.override_region_settings, 0, false,
overrideRegionSettings));
sl.add(new CheckBoxSetting(SettingsFile.KEY_AUTO_DISC_CHANGE, Settings.SECTION_INI_CORE,
R.string.auto_disc_change, 0, false, autoDiscChange));
sl.add(new CheckBoxSetting(SettingsFile.KEY_ENABLE_SAVE_STATES, Settings.SECTION_INI_CORE,
@@ -306,22 +311,17 @@ private void addInterfaceSettings(ArrayList<SettingsItem> sl)
private void addGameCubeSettings(ArrayList<SettingsItem> sl)
{
Setting systemLanguage = null;
Setting overrideGCLanguage = null;
Setting slotADevice = null;
Setting slotBDevice = null;

SettingSection coreSection = mSettings.getSection(Settings.SECTION_INI_CORE);
systemLanguage = coreSection.getSetting(SettingsFile.KEY_GAME_CUBE_LANGUAGE);
overrideGCLanguage = coreSection.getSetting(SettingsFile.KEY_OVERRIDE_GAME_CUBE_LANGUAGE);
slotADevice = coreSection.getSetting(SettingsFile.KEY_SLOT_A_DEVICE);
slotBDevice = coreSection.getSetting(SettingsFile.KEY_SLOT_B_DEVICE);

sl.add(new SingleChoiceSetting(SettingsFile.KEY_GAME_CUBE_LANGUAGE, Settings.SECTION_INI_CORE,
R.string.gamecube_system_language, 0, R.array.gameCubeSystemLanguageEntries,
R.array.gameCubeSystemLanguageValues, 0, systemLanguage));
sl.add(new CheckBoxSetting(SettingsFile.KEY_OVERRIDE_GAME_CUBE_LANGUAGE,
Settings.SECTION_INI_CORE, R.string.override_gamecube_language, 0, false,
overrideGCLanguage));
sl.add(new SingleChoiceSetting(SettingsFile.KEY_SLOT_A_DEVICE, Settings.SECTION_INI_CORE,
R.string.slot_a_device, 0, R.array.slotDeviceEntries, R.array.slotDeviceValues, 8,
slotADevice));
@@ -48,7 +48,7 @@
public static final String KEY_AUDIO_STRETCH = "AudioStretch";
public static final String KEY_AUTO_DISC_CHANGE = "AutoDiscChange";
public static final String KEY_GAME_CUBE_LANGUAGE = "SelectedLanguage";
public static final String KEY_OVERRIDE_GAME_CUBE_LANGUAGE = "OverrideGCLang";
public static final String KEY_OVERRIDE_REGION_SETTINGS = "OverrideRegionSettings";
public static final String KEY_SLOT_A_DEVICE = "SlotA";
public static final String KEY_SLOT_B_DEVICE = "SlotB";
public static final String KEY_ENABLE_SAVE_STATES = "EnableSaveStates";
@@ -126,7 +126,6 @@
<string name="overclock_warning">WARNING: Changing this from the default (100%) WILL break games and cause glitches. Please do not report bugs that occur with a non-default clock.</string>
<string name="gamecube_submenu">GameCube</string>
<string name="gamecube_system_language">System Language</string>
<string name="override_gamecube_language">Override Language on NTSC games</string>
<string name="slot_a_device">GameCube Slot A Device</string>
<string name="slot_b_device">GameCube Slot B Device</string>
<string name="wii_submenu">Wii</string>
@@ -136,6 +135,7 @@
<string name="wiimote_speaker_description">Enable sound output through the speaker on a real Wiimote (DolphinBar required).</string>
<string name="audio_stretch">Audio Stretching</string>
<string name="audio_stretch_description">Stretches audio to reduce stuttering. Increases latency.</string>
<string name="override_region_settings">Allow Mismatched Region Settings</string>
<string name="auto_disc_change">Change Discs Automatically</string>
<string name="enable_save_states">Enable Savestates</string>
<string name="enable_save_states_description">WARNING: Savestates may not be compatible with future versions of Dolphin and can make it impossible to create normal saves in some cases. Never use savestates as the only way of saving your progress.</string>
@@ -356,7 +356,7 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave;
StartUp.cpu_core = netplay_settings.m_CPUcore;
StartUp.SelectedLanguage = netplay_settings.m_SelectedLanguage;
StartUp.bOverrideGCLanguage = netplay_settings.m_OverrideGCLanguage;
StartUp.bOverrideRegionSettings = netplay_settings.m_OverrideRegionSettings;
StartUp.m_DSPEnableJIT = netplay_settings.m_DSPEnableJIT;
StartUp.m_OCEnable = netplay_settings.m_OCEnable;
StartUp.m_OCFactor = netplay_settings.m_OCFactor;
@@ -387,19 +387,44 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
g_SRAM_netplay_initialized = false;
}

const bool ntsc = DiscIO::IsNTSC(StartUp.m_region);

// Apply overrides
// Some NTSC GameCube games such as Baten Kaitos react strangely to
// language settings that would be invalid on an NTSC system
if (!StartUp.bOverrideGCLanguage && ntsc)
// Override out-of-region languages/countries to prevent games from crashing or behaving oddly
if (!StartUp.bOverrideRegionSettings)
{
StartUp.SelectedLanguage = 0;
const int gc_language =
static_cast<int>(StartUp.GetLanguageAdjustedForRegion(false, StartUp.m_region));
StartUp.SelectedLanguage = gc_language - (gc_language > 0);

if (StartUp.bWii)
{
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;
}
}
}
}

// Some NTSC Wii games such as Doc Louis's Punch-Out!! and
// 1942 (Virtual Console) crash if the PAL60 option is enabled
if (StartUp.bWii && ntsc)
if (StartUp.bWii && DiscIO::IsNTSC(StartUp.m_region))
Config::SetCurrent(Config::SYSCONF_PAL60, false);

// Ensure any new settings are written to the SYSCONF
@@ -28,7 +28,8 @@ const ConfigInfo<bool> MAIN_SYNC_ON_SKIP_IDLE{{System::Main, "Core", "SyncOnSkip
const ConfigInfo<std::string> MAIN_DEFAULT_ISO{{System::Main, "Core", "DefaultISO"}, ""};
const ConfigInfo<bool> MAIN_ENABLE_CHEATS{{System::Main, "Core", "EnableCheats"}, false};
const ConfigInfo<int> MAIN_GC_LANGUAGE{{System::Main, "Core", "SelectedLanguage"}, 0};
const ConfigInfo<bool> MAIN_OVERRIDE_GC_LANGUAGE{{System::Main, "Core", "OverrideGCLang"}, false};
const ConfigInfo<bool> MAIN_OVERRIDE_REGION_SETTINGS{
{System::Main, "Core", "OverrideRegionSettings"}, false};
const ConfigInfo<bool> MAIN_DPL2_DECODER{{System::Main, "Core", "DPL2Decoder"}, false};
const ConfigInfo<int> MAIN_AUDIO_LATENCY{{System::Main, "Core", "AudioLatency"}, 20};
const ConfigInfo<bool> MAIN_AUDIO_STRETCH{{System::Main, "Core", "AudioStretch"}, false};
@@ -30,7 +30,7 @@ extern const ConfigInfo<bool> MAIN_SYNC_ON_SKIP_IDLE;
extern const ConfigInfo<std::string> MAIN_DEFAULT_ISO;
extern const ConfigInfo<bool> MAIN_ENABLE_CHEATS;
extern const ConfigInfo<int> MAIN_GC_LANGUAGE;
extern const ConfigInfo<bool> MAIN_OVERRIDE_GC_LANGUAGE;
extern const ConfigInfo<bool> MAIN_OVERRIDE_REGION_SETTINGS;
extern const ConfigInfo<bool> MAIN_DPL2_DECODER;
extern const ConfigInfo<int> MAIN_AUDIO_LATENCY;
extern const ConfigInfo<bool> MAIN_AUDIO_STRETCH;
@@ -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 @@ class BaseConfigLayerLoader final : public Config::ConfigLayerLoader
[&](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);
}
@@ -29,7 +29,7 @@ class NetPlayConfigLayerLoader final : public Config::ConfigLayerLoader
layer->Set(Config::MAIN_CPU_THREAD, m_settings.m_CPUthread);
layer->Set(Config::MAIN_CPU_CORE, m_settings.m_CPUcore);
layer->Set(Config::MAIN_GC_LANGUAGE, m_settings.m_SelectedLanguage);
layer->Set(Config::MAIN_OVERRIDE_GC_LANGUAGE, m_settings.m_OverrideGCLanguage);
layer->Set(Config::MAIN_OVERRIDE_REGION_SETTINGS, m_settings.m_OverrideRegionSettings);
layer->Set(Config::MAIN_DSP_HLE, m_settings.m_DSPHLE);
layer->Set(Config::MAIN_OVERCLOCK_ENABLE, m_settings.m_OCEnable);
layer->Set(Config::MAIN_OVERCLOCK, m_settings.m_OCFactor);
@@ -211,7 +211,7 @@ void SConfig::SaveCoreSettings(IniFile& ini)
core->Set("AccurateNaNs", bAccurateNaNs);
core->Set("EnableCheats", bEnableCheats);
core->Set("SelectedLanguage", SelectedLanguage);
core->Set("OverrideGCLang", bOverrideGCLanguage);
core->Set("OverrideRegionSettings", bOverrideRegionSettings);
core->Set("DPL2Decoder", bDPL2Decoder);
core->Set("AudioLatency", iLatency);
core->Set("AudioStretch", m_audio_stretch);
@@ -486,7 +486,7 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("SyncOnSkipIdle", &bSyncGPUOnSkipIdleHack, true);
core->Get("EnableCheats", &bEnableCheats, false);
core->Get("SelectedLanguage", &SelectedLanguage, 0);
core->Get("OverrideGCLang", &bOverrideGCLanguage, false);
core->Get("OverrideRegionSettings", &bOverrideRegionSettings, false);
core->Get("DPL2Decoder", &bDPL2Decoder, false);
core->Get("AudioLatency", &iLatency, 20);
core->Get("AudioStretch", &m_audio_stretch, false);
@@ -650,7 +650,7 @@ void SConfig::LoadJitDebugSettings(IniFile& ini)

void SConfig::ResetRunningGameMetadata()
{
SetRunningGameMetadata("00000000", "", 0, 0, DiscIO::Country::Unknown);
SetRunningGameMetadata("00000000", "", 0, 0, DiscIO::Region::Unknown);
}

void SConfig::SetRunningGameMetadata(const DiscIO::Volume& volume,
@@ -660,13 +660,13 @@ void SConfig::SetRunningGameMetadata(const DiscIO::Volume& volume,
{
SetRunningGameMetadata(volume.GetGameID(), volume.GetGameTDBID(),
volume.GetTitleID().value_or(0), volume.GetRevision().value_or(0),
volume.GetCountry());
volume.GetRegion());
}
else
{
SetRunningGameMetadata(volume.GetGameID(partition), volume.GetGameTDBID(),
volume.GetTitleID(partition).value_or(0),
volume.GetRevision(partition).value_or(0), volume.GetCountry());
volume.GetRevision(partition).value_or(0), volume.GetRegion());
}
}

@@ -682,15 +682,13 @@ void SConfig::SetRunningGameMetadata(const IOS::ES::TMDReader& tmd, DiscIO::Plat
!DVDInterface::UpdateRunningGameMetadata(tmd_title_id))
{
// If not launching a disc game, just read everything from the TMD.
const DiscIO::Country country = DiscIO::CountryCodeToCountry(
static_cast<u8>(tmd_title_id), platform, tmd.GetRegion(), tmd.GetTitleVersion());
SetRunningGameMetadata(tmd.GetGameID(), tmd.GetGameTDBID(), tmd_title_id, tmd.GetTitleVersion(),
country);
tmd.GetRegion());
}
}

void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id,
u64 title_id, u16 revision, DiscIO::Country country)
u64 title_id, u16 revision, DiscIO::Region region)
{
const bool was_changed = m_game_id != game_id || m_gametdb_id != gametdb_id ||
m_title_id != title_id || m_revision != revision;
@@ -723,9 +721,7 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
}

const Core::TitleDatabase title_database;
const DiscIO::Language language = !bWii && country == DiscIO::Country::Japan ?
DiscIO::Language::Japanese :
GetCurrentLanguage(bWii);
const DiscIO::Language language = GetLanguageAdjustedForRegion(bWii, region);
m_title_description = title_database.Describe(m_gametdb_id, language);
NOTICE_LOG(CORE, "Active title: %s", m_title_description.c_str());
Host_TitleChanged();
@@ -782,7 +778,7 @@ void SConfig::LoadDefaults()
bFastDiscSpeed = false;
bEnableMemcardSdWriting = true;
SelectedLanguage = 0;
bOverrideGCLanguage = false;
bOverrideRegionSettings = false;
bWii = false;
bDPL2Decoder = false;
iLatency = 20;
@@ -995,6 +991,40 @@ DiscIO::Language SConfig::GetCurrentLanguage(bool wii) const
return language;
}

DiscIO::Language SConfig::GetLanguageAdjustedForRegion(bool wii, DiscIO::Region region) const
{
const DiscIO::Language language = GetCurrentLanguage(wii);

if (!wii && region == DiscIO::Region::NTSC_K)
region = DiscIO::Region::NTSC_J; // NTSC-K only exists on Wii, so use a fallback

if (!wii && region == DiscIO::Region::NTSC_J && language == DiscIO::Language::English)
return DiscIO::Language::Japanese; // English and Japanese both use the value 0 in GC SRAM

if (!bOverrideRegionSettings)
{
if (region == DiscIO::Region::NTSC_J)
return DiscIO::Language::Japanese;

if (region == DiscIO::Region::NTSC_U && language != DiscIO::Language::English &&
(!wii || (language != DiscIO::Language::French && language != DiscIO::Language::Spanish)))
{
return DiscIO::Language::English;
}

if (region == DiscIO::Region::PAL &&
(language < DiscIO::Language::English || language > DiscIO::Language::Dutch))
{
return DiscIO::Language::English;
}

if (region == DiscIO::Region::NTSC_K)
return DiscIO::Language::Korean;
}

return language;
}

IniFile SConfig::LoadDefaultGameIni() const
{
return LoadDefaultGameIni(GetGameID(), m_revision);

0 comments on commit 5f38386

Please sign in to comment.
You can’t perform that action at this time.