From 36c92294dfcb2605b29bcc12e69526e904887818 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 16 Mar 2020 15:19:08 +0100 Subject: [PATCH 1/2] Boot: Preserve CODE value in setting.txt if it already matches the region This is a part of fixing https://bugs.dolphin-emu.org/issues/11930. --- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index a85a939e79..8f8f630e80 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -242,6 +242,30 @@ bool CBoot::EmulatedBS2_GC(const DiscIO::VolumeDisc& volume) return RunApploader(/*is_wii*/ false, volume); } +static DiscIO::Region CodeRegion(char c) +{ + switch (c) + { + case 'J': // Japan + case 'T': // Taiwan + return DiscIO::Region::NTSC_J; + case 'B': // Brazil + case 'M': // Middle East + case 'R': // Argentina + case 'S': // ??? + case 'U': // USA + case 'W': // ??? + return DiscIO::Region::NTSC_U; + case 'A': // Australia + case 'E': // Europe + return DiscIO::Region::PAL; + case 'K': // Korea + return DiscIO::Region::NTSC_K; + default: + return DiscIO::Region::Unknown; + } +} + bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type) { static const std::map region_settings = { @@ -267,11 +291,25 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type) { gen.SetBytes(std::move(data)); serno = gen.GetValue("SERNO"); + + bool region_matches = false; if (SConfig::GetInstance().bOverrideRegionSettings) + { + region_matches = true; + } + else + { + const std::string code = gen.GetValue("CODE"); + if (code.size() >= 2 && CodeRegion(code[1]) == SConfig::GetInstance().m_region) + region_matches = true; + } + + if (region_matches) { region_setting = RegionSetting{gen.GetValue("AREA"), gen.GetValue("VIDEO"), gen.GetValue("GAME"), gen.GetValue("CODE")}; } + gen.Reset(); } } From 3614e9fcc292e8a6860549233c74c5fbd0fdf9de Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 16 Mar 2020 15:36:58 +0100 Subject: [PATCH 2/2] Boot: Preserve MODEL value in setting.txt It doesn't necessarily start with RVL-001. --- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 8f8f630e80..5065128707 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -278,6 +278,7 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type) Common::SettingsHandler gen; std::string serno; + std::string model = "RVL-001(" + region_setting.area + ")"; CreateSystemMenuTitleDirs(); const std::string settings_file_path(Common::GetTitleDataPath(Titles::SYSTEM_MENU) + "/" WII_SETTING); @@ -291,6 +292,7 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type) { gen.SetBytes(std::move(data)); serno = gen.GetValue("SERNO"); + model = gen.GetValue("MODEL"); bool region_matches = false; if (SConfig::GetInstance().bOverrideRegionSettings) @@ -309,6 +311,12 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type) region_setting = RegionSetting{gen.GetValue("AREA"), gen.GetValue("VIDEO"), gen.GetValue("GAME"), gen.GetValue("CODE")}; } + else + { + const size_t parenthesis_pos = model.find('('); + if (parenthesis_pos != std::string::npos) + model = model.substr(0, parenthesis_pos) + '(' + region_setting.area + ')'; + } gen.Reset(); } @@ -328,7 +336,6 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type) INFO_LOG(BOOT, "Using serial number: %s", serno.c_str()); } - std::string model = "RVL-001(" + region_setting.area + ")"; gen.AddSetting("AREA", region_setting.area); gen.AddSetting("MODEL", model); gen.AddSetting("DVD", "0");