Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boot: Do a better job of preserving certain parts of settings.txt #8673

Merged
merged 2 commits into from
Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion Source/Core/Core/Boot/Boot_BS2Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DiscIO::Region, const RegionSetting> region_settings = {
leoetlino marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -254,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);
Expand All @@ -267,11 +292,32 @@ 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)
{
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")};
}
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();
}
}
Expand All @@ -290,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");
Expand Down