summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMat M <mathew1800@gmail.com>2018-10-12 10:25:45 -0400
committerGitHub <noreply@github.com>2018-10-12 10:25:45 -0400
commitb3cd6158fcdf62b2e2add10b4b23b5b20f857be5 (patch)
treeb8898e1010281542c1c31241f3de1d839f6cf5b7 /Source
parent6e40955a8a40e87ebf3476d0b3323b3b4284579f (diff)
parentf834ef1dfede5b1f010314810845c97715eabae7 (diff)
Merge pull request #7471 from JosJuice/country-region-switch
DiscIO: Improve RegionSwitch/CountrySwitch
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/IOS/ES/Formats.cpp3
-rw-r--r--Source/Core/Core/TitleDatabase.cpp12
-rw-r--r--Source/Core/DiscIO/Enums.cpp81
-rw-r--r--Source/Core/DiscIO/Enums.h7
-rw-r--r--Source/Core/DiscIO/VolumeGC.cpp12
-rw-r--r--Source/Core/DiscIO/VolumeWad.cpp2
-rw-r--r--Source/Core/DiscIO/VolumeWii.cpp6
7 files changed, 73 insertions, 50 deletions
diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp
index b2990f0d40..9086e8270c 100644
--- a/Source/Core/Core/IOS/ES/Formats.cpp
+++ b/Source/Core/Core/IOS/ES/Formats.cpp
@@ -298,7 +298,8 @@ DiscIO::Region TMDReader::GetRegion() const
if (GetTitleId() == Titles::SYSTEM_MENU)
return DiscIO::GetSysMenuRegion(GetTitleVersion());
- return DiscIO::RegionSwitchWii(static_cast<u8>(GetTitleId() & 0xff));
+ return DiscIO::CountryCodeToRegion(static_cast<u8>(GetTitleId() & 0xff),
+ DiscIO::Platform::WiiWAD);
}
std::string TMDReader::GetGameID() const
diff --git a/Source/Core/Core/TitleDatabase.cpp b/Source/Core/Core/TitleDatabase.cpp
index 32871eba30..7000fe723d 100644
--- a/Source/Core/Core/TitleDatabase.cpp
+++ b/Source/Core/Core/TitleDatabase.cpp
@@ -97,12 +97,20 @@ static bool IsWiiTitle(const std::string& game_id)
static bool IsJapaneseGCTitle(const std::string& game_id)
{
- return IsGCTitle(game_id) && DiscIO::CountrySwitch(game_id[3]) == DiscIO::Country::Japan;
+ if (!IsGCTitle(game_id))
+ return false;
+
+ return DiscIO::CountryCodeToCountry(game_id[3], DiscIO::Platform::GameCubeDisc) ==
+ DiscIO::Country::Japan;
}
static bool IsNonJapaneseGCTitle(const std::string& game_id)
{
- return IsGCTitle(game_id) && DiscIO::CountrySwitch(game_id[3]) != DiscIO::Country::Japan;
+ if (!IsGCTitle(game_id))
+ return false;
+
+ return DiscIO::CountryCodeToCountry(game_id[3], DiscIO::Platform::GameCubeDisc) !=
+ DiscIO::Country::Japan;
}
// Note that this function will not overwrite entries that already are in the maps
diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp
index 66dcdd19d6..723525ec48 100644
--- a/Source/Core/DiscIO/Enums.cpp
+++ b/Source/Core/DiscIO/Enums.cpp
@@ -145,26 +145,35 @@ Country TypicalCountryForRegion(Region region)
}
}
-Region RegionSwitchGC(u8 country_code)
-{
- Region region = RegionSwitchWii(country_code);
- return region == Region::NTSC_K ? Region::NTSC_J : region;
-}
-
-Region RegionSwitchWii(u8 country_code)
+Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region)
{
switch (country_code)
{
case 'J':
- case 'W':
return Region::NTSC_J;
- case 'B':
+ case 'W':
+ if (expected_region == Region::PAL)
+ return Region::PAL; // Only the Nordic version of Ratatouille (Wii)
+ else
+ return Region::NTSC_J; // Korean GC games in English or Taiwanese Wii games
+
case 'E':
+ if (expected_region == Region::NTSC_J)
+ return Region::NTSC_J; // Korean GC games in English
+ else
+ return Region::NTSC_U; // The most common country code for NTSC-U
+
+ case 'B':
case 'N':
- case 'Z':
return Region::NTSC_U;
+ case 'X':
+ case 'Y':
+ case 'Z':
+ // Additional language versions, store-exclusive versions, other special versions
+ return expected_region == Region::NTSC_U ? Region::NTSC_U : Region::PAL;
+
case 'D':
case 'F':
case 'H':
@@ -175,21 +184,21 @@ Region RegionSwitchWii(u8 country_code)
case 'R':
case 'S':
case 'U':
- case 'X':
- case 'Y':
+ case 'V':
return Region::PAL;
case 'K':
case 'Q':
case 'T':
- return Region::NTSC_K;
+ // All of these country codes are Korean, but the NTSC-K region doesn't exist on GC
+ return platform == Platform::GameCubeDisc ? Region::NTSC_J : Region::NTSC_K;
default:
return Region::Unknown;
}
}
-Country CountrySwitch(u8 country_code)
+Country CountryCodeToCountry(u8 country_code, Platform platform, Region region)
{
switch (country_code)
{
@@ -197,15 +206,29 @@ Country CountrySwitch(u8 country_code)
case 'A':
return Country::World;
+ // Mixed regions
+ case 'X':
+ case 'Y':
+ case 'Z':
+ // Additional language versions, store-exclusive versions, other special versions
+ return region == Region::NTSC_U ? Country::USA : Country::Europe;
+
+ case 'W':
+ if (region == Region::PAL)
+ return Country::Europe; // Only the Nordic version of Ratatouille (Wii)
+ else if (platform == Platform::GameCubeDisc)
+ return Country::Korea; // GC games in English released in Korea
+ else
+ return Country::Taiwan; // Wii games in traditional Chinese released in Taiwan
+
// PAL
case 'D':
return Country::Germany;
- case 'X': // Used by a couple PAL games
- case 'Y': // German, French
- case 'L': // Japanese import to PAL regions
- case 'M': // Japanese import to PAL regions
- case 'P':
+ case 'L': // NTSC-J games released on PAL VC
+ case 'M': // NTSC-U games released on PAL VC
+ case 'V': // Used by some Nordic Wii releases
+ case 'P': // The most common country code for PAL
return Country::Europe;
case 'U':
@@ -228,21 +251,21 @@ Country CountrySwitch(u8 country_code)
// NTSC
case 'E':
- case 'N': // Japanese import to USA and other NTSC regions
- case 'Z': // Prince of Persia - The Forgotten Sands (Wii)
- case 'B': // Ufouria: The Saga (Virtual Console)
+ if (region == Region::NTSC_J)
+ return Country::Korea; // GC games in English released in Korea
+ else
+ return Country::USA; // The most common country code for NTSC-U
+
+ case 'B': // PAL games released on NTSC-U VC
+ case 'N': // NTSC-J games released on NTSC-U VC
return Country::USA;
case 'J':
return Country::Japan;
- case 'K':
- case 'Q': // Korea with Japanese language
- case 'T': // Korea with English language
- return Country::Korea;
-
- case 'W':
- return Country::Taiwan;
+ case 'K': // Games in Korean released in Korea
+ case 'Q': // NTSC-J games released on NTSC-K VC
+ case 'T': // NTSC-U games released on NTSC-K VC
default:
if (country_code > 'A') // Silently ignore IOS wads
diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h
index 524336651d..fc6f0543db 100644
--- a/Source/Core/DiscIO/Enums.h
+++ b/Source/Core/DiscIO/Enums.h
@@ -77,10 +77,9 @@ bool IsNTSC(Region region);
Country TypicalCountryForRegion(Region region);
// Avoid using this function if you can. Country codes aren't always reliable region indicators.
-Region RegionSwitchGC(u8 country_code);
-// Avoid using this function if you can. Country codes aren't always reliable region indicators.
-Region RegionSwitchWii(u8 country_code);
-Country CountrySwitch(u8 country_code);
+Region CountryCodeToRegion(u8 country_code, Platform platform,
+ Region expected_region = Region::Unknown);
+Country CountryCodeToCountry(u8 country_code, Platform platform, Region region = Region::Unknown);
Region GetSysMenuRegion(u16 title_version);
std::string GetSysMenuVersionString(u16 title_version);
diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp
index f844d329c8..1275fcfb78 100644
--- a/Source/Core/DiscIO/VolumeGC.cpp
+++ b/Source/Core/DiscIO/VolumeGC.cpp
@@ -87,18 +87,10 @@ Country VolumeGC::GetCountry(const Partition& partition) const
const u8 country = ReadSwapped<u8>(3, partition).value_or(0);
const Region region = GetRegion();
- // Korean GC releases use NTSC-J.
- // E is normally used for America, but it's also used for English-language Korean GC releases.
- // K is used by games that are in the Korean language.
- // W means Taiwan for Wii games, but on the GC, it's used for English-language Korean releases.
- // (There doesn't seem to be any pattern to which of E and W is used for Korean GC releases.)
- if (region == Region::NTSC_J && (country == 'E' || country == 'K' || country == 'W'))
- return Country::Korea;
-
- if (RegionSwitchGC(country) != region)
+ if (CountryCodeToRegion(country, Platform::GameCubeDisc, region) != region)
return TypicalCountryForRegion(region);
- return CountrySwitch(country);
+ return CountryCodeToCountry(country, Platform::GameCubeDisc, region);
}
std::string VolumeGC::GetMakerID(const Partition& partition) const
diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp
index 7a1df3e0d5..c274181695 100644
--- a/Source/Core/DiscIO/VolumeWad.cpp
+++ b/Source/Core/DiscIO/VolumeWad.cpp
@@ -88,7 +88,7 @@ Country VolumeWAD::GetCountry(const Partition& partition) const
if (country_code == 2) // SYSMENU
return TypicalCountryForRegion(GetSysMenuRegion(m_tmd.GetTitleVersion()));
- return CountrySwitch(country_code);
+ return CountryCodeToCountry(country_code, Platform::WiiWAD);
}
const IOS::ES::TMDReader& VolumeWAD::GetTMD(const Partition& partition) const
diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp
index 73e5b290b7..29d822fca9 100644
--- a/Source/Core/DiscIO/VolumeWii.cpp
+++ b/Source/Core/DiscIO/VolumeWii.cpp
@@ -290,13 +290,13 @@ Region VolumeWii::GetRegion() const
Country VolumeWii::GetCountry(const Partition& partition) const
{
// The 0 that we use as a default value is mapped to Country::Unknown and Region::Unknown
- u8 country_byte = ReadSwapped<u8>(3, partition).value_or(0);
+ const u8 country_byte = ReadSwapped<u8>(3, partition).value_or(0);
const Region region = GetRegion();
- if (RegionSwitchWii(country_byte) != region)
+ if (CountryCodeToRegion(country_byte, Platform::WiiDisc, region) != region)
return TypicalCountryForRegion(region);
- return CountrySwitch(country_byte);
+ return CountryCodeToCountry(country_byte, Platform::WiiDisc, region);
}
std::string VolumeWii::GetMakerID(const Partition& partition) const