From 08d0b98988af1ff0991d660911b4a400980676d5 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 5 Oct 2018 17:48:59 +0200 Subject: [PATCH 1/7] DiscIO: Merge RegionSwitchGC and RegionSwitchWii --- Source/Core/Core/IOS/ES/Formats.cpp | 2 +- Source/Core/DiscIO/Enums.cpp | 10 ++-------- Source/Core/DiscIO/Enums.h | 4 +--- Source/Core/DiscIO/VolumeGC.cpp | 2 +- Source/Core/DiscIO/VolumeWii.cpp | 4 ++-- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index b2990f0d4000..44e648603fef 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -298,7 +298,7 @@ DiscIO::Region TMDReader::GetRegion() const if (GetTitleId() == Titles::SYSTEM_MENU) return DiscIO::GetSysMenuRegion(GetTitleVersion()); - return DiscIO::RegionSwitchWii(static_cast(GetTitleId() & 0xff)); + return DiscIO::RegionSwitch(static_cast(GetTitleId() & 0xff), DiscIO::Platform::WiiWAD); } std::string TMDReader::GetGameID() const diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index 66dcdd19d6ab..5318ab6b787a 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -145,13 +145,7 @@ 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 RegionSwitch(u8 country_code, Platform platform) { switch (country_code) { @@ -182,7 +176,7 @@ Region RegionSwitchWii(u8 country_code) case 'K': case 'Q': case 'T': - return Region::NTSC_K; + return platform == Platform::GameCubeDisc ? Region::NTSC_J : Region::NTSC_K; default: return Region::Unknown; diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index 524336651d73..e7f892797100 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -77,9 +77,7 @@ 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); +Region RegionSwitch(u8 country_code, Platform platform); Country CountrySwitch(u8 country_code); Region GetSysMenuRegion(u16 title_version); diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp index f844d329c864..71506e839359 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -95,7 +95,7 @@ Country VolumeGC::GetCountry(const Partition& partition) const if (region == Region::NTSC_J && (country == 'E' || country == 'K' || country == 'W')) return Country::Korea; - if (RegionSwitchGC(country) != region) + if (RegionSwitch(country, Platform::GameCubeDisc) != region) return TypicalCountryForRegion(region); return CountrySwitch(country); diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index 73e5b290b7ef..3cb5cf42c04c 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -290,10 +290,10 @@ 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(3, partition).value_or(0); + const u8 country_byte = ReadSwapped(3, partition).value_or(0); const Region region = GetRegion(); - if (RegionSwitchWii(country_byte) != region) + if (RegionSwitch(country_byte, Platform::WiiDisc) != region) return TypicalCountryForRegion(region); return CountrySwitch(country_byte); From 57d05293fd11748a7a533ad81a1b61e85e4daca6 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 5 Oct 2018 20:14:23 +0200 Subject: [PATCH 2/7] DiscIO: Move the Korean GC mess out of VolumeGC --- Source/Core/Core/TitleDatabase.cpp | 6 ++++-- Source/Core/DiscIO/Enums.cpp | 12 ++++++++---- Source/Core/DiscIO/Enums.h | 4 ++-- Source/Core/DiscIO/VolumeGC.cpp | 12 ++---------- Source/Core/DiscIO/VolumeWad.cpp | 2 +- Source/Core/DiscIO/VolumeWii.cpp | 4 ++-- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Source/Core/Core/TitleDatabase.cpp b/Source/Core/Core/TitleDatabase.cpp index 32871eba309d..cd7449b13965 100644 --- a/Source/Core/Core/TitleDatabase.cpp +++ b/Source/Core/Core/TitleDatabase.cpp @@ -97,12 +97,14 @@ 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; + return IsGCTitle(game_id) && DiscIO::CountrySwitch(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; + return IsGCTitle(game_id) && DiscIO::CountrySwitch(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 5318ab6b787a..5d3129fd7dc2 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -145,7 +145,7 @@ Country TypicalCountryForRegion(Region region) } } -Region RegionSwitch(u8 country_code, Platform platform) +Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) { switch (country_code) { @@ -153,8 +153,10 @@ Region RegionSwitch(u8 country_code, Platform platform) case 'W': return Region::NTSC_J; - case 'B': case 'E': + return expected_region == Region::NTSC_J ? Region::NTSC_J : Region::NTSC_U; + + case 'B': case 'N': case 'Z': return Region::NTSC_U; @@ -183,7 +185,7 @@ Region RegionSwitch(u8 country_code, Platform platform) } } -Country CountrySwitch(u8 country_code) +Country CountrySwitch(u8 country_code, Platform platform, Region region) { switch (country_code) { @@ -222,6 +224,8 @@ Country CountrySwitch(u8 country_code) // NTSC case 'E': + return region == Region::NTSC_J ? Country::Korea : Country::USA; + 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) @@ -236,7 +240,7 @@ Country CountrySwitch(u8 country_code) return Country::Korea; case 'W': - return Country::Taiwan; + return platform == Platform::GameCubeDisc ? Country::Korea : Country::Taiwan; default: if (country_code > 'A') // Silently ignore IOS wads diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index e7f892797100..6acbee9960f6 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -77,8 +77,8 @@ bool IsNTSC(Region region); Country TypicalCountryForRegion(Region region); // Avoid using this function if you can. Country codes aren't always reliable region indicators. -Region RegionSwitch(u8 country_code, Platform platform); -Country CountrySwitch(u8 country_code); +Region RegionSwitch(u8 country_code, Platform platform, Region expected_region = Region::Unknown); +Country CountrySwitch(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 71506e839359..c984d60f9dd3 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(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 (RegionSwitch(country, Platform::GameCubeDisc) != region) + if (RegionSwitch(country, Platform::GameCubeDisc, region) != region) return TypicalCountryForRegion(region); - return CountrySwitch(country); + return CountrySwitch(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 7a1df3e0d579..ef102df9c1fd 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 CountrySwitch(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 3cb5cf42c04c..c64dc3ec0535 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -293,10 +293,10 @@ Country VolumeWii::GetCountry(const Partition& partition) const const u8 country_byte = ReadSwapped(3, partition).value_or(0); const Region region = GetRegion(); - if (RegionSwitch(country_byte, Platform::WiiDisc) != region) + if (RegionSwitch(country_byte, Platform::WiiDisc, region) != region) return TypicalCountryForRegion(region); - return CountrySwitch(country_byte); + return CountrySwitch(country_byte, Platform::WiiDisc, region); } std::string VolumeWii::GetMakerID(const Partition& partition) const From 504024ab46a17e6fa6295b2d0fc022e216bd8a1a Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 8 Oct 2018 13:36:06 +0200 Subject: [PATCH 3/7] DiscIO: Add the missing 'V' country code --- Source/Core/DiscIO/Enums.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index 5d3129fd7dc2..efb4801a4d64 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -171,6 +171,7 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) case 'R': case 'S': case 'U': + case 'V': case 'X': case 'Y': return Region::PAL; @@ -201,6 +202,7 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) case 'Y': // German, French case 'L': // Japanese import to PAL regions case 'M': // Japanese import to PAL regions + case 'V': case 'P': return Country::Europe; From cab5e52d15e6336d226347c9fe8d920893adec83 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 8 Oct 2018 13:46:55 +0200 Subject: [PATCH 4/7] DiscIO: Fix the 'W', 'X', 'Y' and 'Z' country codes These country codes have the unfortunate property that they are used by Wii disc games in two different regions. We already correct for this in VolumeGC::GetCountry and VolumeWii::GetCountry, so this commit shouldn't really have any effect on how the game list behaves, but it will be useful if we in the future would want to call CountrySwitch directly without having extra code in the caller for handling region weirdness. --- Source/Core/DiscIO/Enums.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index efb4801a4d64..4df97d37283f 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -150,17 +150,23 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) switch (country_code) { case 'J': - case 'W': return Region::NTSC_J; + case 'W': + return expected_region == Region::PAL ? Region::PAL : Region::NTSC_J; + case 'E': return expected_region == Region::NTSC_J ? Region::NTSC_J : Region::NTSC_U; case 'B': case 'N': - case 'Z': return Region::NTSC_U; + case 'X': + case 'Y': + case 'Z': + return expected_region == Region::NTSC_U ? Region::NTSC_U : Region::PAL; + case 'D': case 'F': case 'H': @@ -172,8 +178,6 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) case 'S': case 'U': case 'V': - case 'X': - case 'Y': return Region::PAL; case 'K': @@ -194,12 +198,22 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) case 'A': return Country::World; + // Mixed regions + case 'X': + case 'Y': + case 'Z': + return region == Region::NTSC_U ? Country::USA : Country::Europe; + + case 'W': + if (region == Region::PAL) + return Country::Europe; + else + return platform == Platform::GameCubeDisc ? Country::Korea : Country::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 'V': @@ -229,7 +243,6 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) return region == Region::NTSC_J ? Country::Korea : Country::USA; 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) return Country::USA; @@ -241,9 +254,6 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) case 'T': // Korea with English language return Country::Korea; - case 'W': - return platform == Platform::GameCubeDisc ? Country::Korea : Country::Taiwan; - default: if (country_code > 'A') // Silently ignore IOS wads WARN_LOG(DISCIO, "Unknown Country Code! %c", country_code); From 7607dc3573923b284f719aef54863b7e163c3052 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 8 Oct 2018 13:48:36 +0200 Subject: [PATCH 5/7] DiscIO: Fix CountrySwitch's 'M' comment (and clarify other VC comments) --- Source/Core/DiscIO/Enums.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index 4df97d37283f..500bfc3f3c0f 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -214,8 +214,8 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) case 'D': return Country::Germany; - case 'L': // Japanese import to PAL regions - case 'M': // Japanese import to PAL regions + case 'L': // NTSC-J games released on PAL VC + case 'M': // NTSC-U games released on PAL VC case 'V': case 'P': return Country::Europe; @@ -242,16 +242,16 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) case 'E': return region == Region::NTSC_J ? Country::Korea : Country::USA; - case 'N': // Japanese import to USA and other NTSC regions - case 'B': // Ufouria: The Saga (Virtual Console) + 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 + case 'Q': // NTSC-J games released on NTSC-K VC + case 'T': // NTSC-U games released on NTSC-K VC return Country::Korea; default: From 7fd1784b9af49ecfbe98f6f0b589e1f462ca8520 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 8 Oct 2018 13:48:36 +0200 Subject: [PATCH 6/7] DiscIO: Add more RegionSwitch/CountrySwitch comments --- Source/Core/DiscIO/Enums.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index 500bfc3f3c0f..167b5eb14589 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -153,10 +153,16 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) return Region::NTSC_J; case 'W': - return expected_region == Region::PAL ? Region::PAL : Region::NTSC_J; + 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': - return expected_region == Region::NTSC_J ? Region::NTSC_J : Region::NTSC_U; + 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': @@ -165,6 +171,7 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) 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': @@ -183,6 +190,7 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) case 'K': case 'Q': case 'T': + // 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: @@ -202,13 +210,16 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) 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; + 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 platform == Platform::GameCubeDisc ? Country::Korea : Country::Taiwan; + return Country::Taiwan; // Wii games in traditional Chinese released in Taiwan // PAL case 'D': @@ -216,8 +227,8 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) case 'L': // NTSC-J games released on PAL VC case 'M': // NTSC-U games released on PAL VC - case 'V': - case 'P': + case 'V': // Used by some Nordic Wii releases + case 'P': // The most common country code for PAL return Country::Europe; case 'U': @@ -240,7 +251,10 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) // NTSC case 'E': - return region == Region::NTSC_J ? Country::Korea : Country::USA; + 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 @@ -249,10 +263,9 @@ Country CountrySwitch(u8 country_code, Platform platform, Region region) case 'J': return Country::Japan; - case 'K': + 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 - return Country::Korea; default: if (country_code > 'A') // Silently ignore IOS wads From f834ef1dfede5b1f010314810845c97715eabae7 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 8 Oct 2018 13:51:21 +0200 Subject: [PATCH 7/7] DiscIO: Rename RegionSwitch/CountrySwitch Callers don't need to know that these functions are implemented with a switch statement. --- Source/Core/Core/IOS/ES/Formats.cpp | 3 ++- Source/Core/Core/TitleDatabase.cpp | 14 ++++++++++---- Source/Core/DiscIO/Enums.cpp | 4 ++-- Source/Core/DiscIO/Enums.h | 5 +++-- Source/Core/DiscIO/VolumeGC.cpp | 4 ++-- Source/Core/DiscIO/VolumeWad.cpp | 2 +- Source/Core/DiscIO/VolumeWii.cpp | 4 ++-- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 44e648603fef..9086e8270c2e 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::RegionSwitch(static_cast(GetTitleId() & 0xff), DiscIO::Platform::WiiWAD); + return DiscIO::CountryCodeToRegion(static_cast(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 cd7449b13965..7000fe723d50 100644 --- a/Source/Core/Core/TitleDatabase.cpp +++ b/Source/Core/Core/TitleDatabase.cpp @@ -97,14 +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::Platform::GameCubeDisc) == - 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::Platform::GameCubeDisc) != - 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 167b5eb14589..723525ec4858 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -145,7 +145,7 @@ Country TypicalCountryForRegion(Region region) } } -Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) +Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region) { switch (country_code) { @@ -198,7 +198,7 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region) } } -Country CountrySwitch(u8 country_code, Platform platform, Region region) +Country CountryCodeToCountry(u8 country_code, Platform platform, Region region) { switch (country_code) { diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index 6acbee9960f6..fc6f0543db11 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -77,8 +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 RegionSwitch(u8 country_code, Platform platform, Region expected_region = Region::Unknown); -Country CountrySwitch(u8 country_code, Platform platform, Region region = Region::Unknown); +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 c984d60f9dd3..1275fcfb786d 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -87,10 +87,10 @@ Country VolumeGC::GetCountry(const Partition& partition) const const u8 country = ReadSwapped(3, partition).value_or(0); const Region region = GetRegion(); - if (RegionSwitch(country, Platform::GameCubeDisc, region) != region) + if (CountryCodeToRegion(country, Platform::GameCubeDisc, region) != region) return TypicalCountryForRegion(region); - return CountrySwitch(country, Platform::GameCubeDisc, region); + 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 ef102df9c1fd..c274181695b8 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, Platform::WiiWAD); + 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 c64dc3ec0535..29d822fca977 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -293,10 +293,10 @@ Country VolumeWii::GetCountry(const Partition& partition) const const u8 country_byte = ReadSwapped(3, partition).value_or(0); const Region region = GetRegion(); - if (RegionSwitch(country_byte, Platform::WiiDisc, region) != region) + if (CountryCodeToRegion(country_byte, Platform::WiiDisc, region) != region) return TypicalCountryForRegion(region); - return CountrySwitch(country_byte, Platform::WiiDisc, region); + return CountryCodeToCountry(country_byte, Platform::WiiDisc, region); } std::string VolumeWii::GetMakerID(const Partition& partition) const