Return a more meaningful type from GetSysMenuRegion

This commit is contained in:
JosJuice 2017-03-17 21:16:59 +01:00
parent 04c49aa395
commit 9d54e4a9de
5 changed files with 35 additions and 29 deletions

View File

@ -118,7 +118,7 @@ u64 TMDReader::GetIOSId() const
DiscIO::Region TMDReader::GetRegion() const DiscIO::Region TMDReader::GetRegion() const
{ {
if (GetTitleId() == 0x0000000100000002) if (GetTitleId() == 0x0000000100000002)
return DiscIO::RegionSwitchWii(DiscIO::GetSysMenuRegion(GetTitleVersion())); return DiscIO::GetSysMenuRegion(GetTitleVersion());
return DiscIO::RegionSwitchWii(static_cast<u8>(GetTitleId() & 0xff)); return DiscIO::RegionSwitchWii(static_cast<u8>(GetTitleId() & 0xff));
} }

View File

@ -18,6 +18,23 @@ bool IsNTSC(Region region)
// Increment CACHE_REVISION (ISOFile.cpp & GameFile.cpp) if the code below is modified // Increment CACHE_REVISION (ISOFile.cpp & GameFile.cpp) if the code below is modified
Country TypicalCountryForRegion(Region region)
{
switch (region)
{
case Region::NTSC_J:
return Country::COUNTRY_JAPAN;
case Region::NTSC_U:
return Country::COUNTRY_USA;
case Region::PAL:
return Country::COUNTRY_EUROPE;
case Region::NTSC_K:
return Country::COUNTRY_KOREA;
default:
return Country::COUNTRY_UNKNOWN;
}
}
Region RegionSwitchGC(u8 country_code) Region RegionSwitchGC(u8 country_code)
{ {
Region region = RegionSwitchWii(country_code); Region region = RegionSwitchWii(country_code);
@ -124,23 +141,23 @@ Country CountrySwitch(u8 country_code)
} }
} }
u8 GetSysMenuRegion(u16 title_version) Region GetSysMenuRegion(u16 title_version)
{ {
if (title_version == 33) if (title_version == 33)
return 'A'; // 1.0 uses 33 as the version number in all regions return Region::UNKNOWN_REGION; // 1.0 uses 33 as the version number in all regions
switch (title_version & 0xf) switch (title_version & 0xf)
{ {
case 0: case 0:
return 'J'; return Region::NTSC_J;
case 1: case 1:
return 'E'; return Region::NTSC_U;
case 2: case 2:
return 'P'; return Region::PAL;
case 6: case 6:
return 'K'; return Region::NTSC_K;
default: default:
return 'A'; return Region::UNKNOWN_REGION;
} }
} }
@ -153,16 +170,16 @@ std::string GetSysMenuVersionString(u16 title_version)
switch (GetSysMenuRegion(title_version)) switch (GetSysMenuRegion(title_version))
{ {
case 'J': case Region::NTSC_J:
region_letter = "J"; region_letter = "J";
break; break;
case 'E': case Region::NTSC_U:
region_letter = "U"; region_letter = "U";
break; break;
case 'P': case Region::PAL:
region_letter = "E"; region_letter = "E";
break; break;
case 'K': case Region::NTSC_K:
region_letter = "K"; region_letter = "K";
break; break;
} }

View File

@ -69,10 +69,11 @@ enum class Language
}; };
bool IsNTSC(Region region); bool IsNTSC(Region region);
Country TypicalCountryForRegion(Region region);
Region RegionSwitchGC(u8 country_code); Region RegionSwitchGC(u8 country_code);
Region RegionSwitchWii(u8 country_code); Region RegionSwitchWii(u8 country_code);
Country CountrySwitch(u8 country_code); Country CountrySwitch(u8 country_code);
u8 GetSysMenuRegion(u16 title_version); Region GetSysMenuRegion(u16 title_version);
std::string GetSysMenuVersionString(u16 title_version); std::string GetSysMenuVersionString(u16 title_version);
std::string GetCompanyFromID(const std::string& company_id); std::string GetCompanyFromID(const std::string& company_id);
} }

View File

@ -77,7 +77,7 @@ Country CVolumeWAD::GetCountry() const
u8 country_code = static_cast<u8>(m_tmd.GetTitleId() & 0xff); u8 country_code = static_cast<u8>(m_tmd.GetTitleId() & 0xff);
if (country_code == 2) // SYSMENU if (country_code == 2) // SYSMENU
country_code = GetSysMenuRegion(m_tmd.GetTitleVersion()); return TypicalCountryForRegion(GetSysMenuRegion(m_tmd.GetTitleVersion()));
return CountrySwitch(country_code); return CountrySwitch(country_code);
} }

View File

@ -174,22 +174,10 @@ Country CVolumeWiiCrypted::GetCountry() const
const Region region = GetRegion(); const Region region = GetRegion();
if (RegionSwitchWii(country_byte) == region) if (RegionSwitchWii(country_byte) != region)
return CountrySwitch(country_byte); return TypicalCountryForRegion(region);
switch (region) return CountrySwitch(country_byte);
{
case Region::NTSC_J:
return Country::COUNTRY_JAPAN;
case Region::NTSC_U:
return Country::COUNTRY_USA;
case Region::PAL:
return Country::COUNTRY_EUROPE;
case Region::NTSC_K:
return Country::COUNTRY_KOREA;
default:
return Country::COUNTRY_UNKNOWN;
}
} }
std::string CVolumeWiiCrypted::GetMakerID() const std::string CVolumeWiiCrypted::GetMakerID() const