diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index e46ca238d0..f3f1f3bf71 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -145,7 +145,8 @@ Country TypicalCountryForRegion(Region region) } } -Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region) +Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region, + std::optional revision) { switch (country_code) { @@ -159,11 +160,24 @@ Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_r 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 + if (platform != Platform::GameCubeDisc) return Region::NTSC_U; // The most common country code for NTSC-U + if (revision) + { + if (*revision >= 0x30) + return Region::NTSC_J; // Korean GC games in English + else + return Region::NTSC_U; // The most common country code for NTSC-U + } + else + { + 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': return Region::NTSC_U; @@ -198,7 +212,8 @@ Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_r } } -Country CountryCodeToCountry(u8 country_code, Platform platform, Region region) +Country CountryCodeToCountry(u8 country_code, Platform platform, Region region, + std::optional revision) { switch (country_code) { @@ -214,10 +229,10 @@ Country CountryCodeToCountry(u8 country_code, Platform platform, Region region) 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) + if (platform == Platform::GameCubeDisc) return Country::Korea; // GC games in English released in Korea + else if (region == Region::PAL) + return Country::Europe; // Only the Nordic version of Ratatouille (Wii) else return Country::Taiwan; // Wii games in traditional Chinese released in Taiwan @@ -251,11 +266,24 @@ Country CountryCodeToCountry(u8 country_code, Platform platform, Region region) // NTSC case 'E': - if (region == Region::NTSC_J) - return Country::Korea; // GC games in English released in Korea - else + if (platform != Platform::GameCubeDisc) return Country::USA; // The most common country code for NTSC-U + if (revision) + { + if (*revision >= 0x30) + return Country::Korea; // GC games in English released in Korea + else + return Country::USA; // The most common country code for NTSC-U + } + else + { + 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; diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index e44de11ee7..020f608bfb 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include "Common/CommonTypes.h" @@ -78,8 +79,10 @@ bool IsNTSC(Region region); Country TypicalCountryForRegion(Region region); // Avoid using this function if you can. Country codes aren't always reliable region indicators. Region CountryCodeToRegion(u8 country_code, Platform platform, - Region expected_region = Region::Unknown); -Country CountryCodeToCountry(u8 country_code, Platform platform, Region region = Region::Unknown); + Region expected_region = Region::Unknown, + std::optional revision = {}); +Country CountryCodeToCountry(u8 country_code, Platform platform, Region region = Region::Unknown, + std::optional revision = {}); 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 67cf71072e..6d9a48cd0e 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -97,11 +97,12 @@ Country VolumeGC::GetCountry(const Partition& partition) const // The 0 that we use as a default value is mapped to Country::Unknown and Region::Unknown const u8 country = ReadSwapped(3, partition).value_or(0); const Region region = GetRegion(); + const std::optional revision = GetRevision(); - if (CountryCodeToRegion(country, Platform::GameCubeDisc, region) != region) + if (CountryCodeToRegion(country, Platform::GameCubeDisc, region, revision) != region) return TypicalCountryForRegion(region); - return CountryCodeToCountry(country, Platform::GameCubeDisc, region); + return CountryCodeToCountry(country, Platform::GameCubeDisc, region, revision); } std::string VolumeGC::GetMakerID(const Partition& partition) const diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 94191c05c7..19f907e6f7 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -96,10 +96,11 @@ Country VolumeWAD::GetCountry(const Partition& partition) const return TypicalCountryForRegion(GetSysMenuRegion(m_tmd.GetTitleVersion())); const Region region = GetRegion(); - if (CountryCodeToRegion(country_byte, Platform::WiiWAD, region) != region) + const std::optional revision = GetRevision(); + if (CountryCodeToRegion(country_byte, Platform::WiiWAD, region, revision) != region) return TypicalCountryForRegion(region); - return CountryCodeToCountry(country_byte, Platform::WiiWAD, region); + return CountryCodeToCountry(country_byte, Platform::WiiWAD, region, revision); } const IOS::ES::TicketReader& VolumeWAD::GetTicket(const Partition& partition) const diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index f5b0a253cc..f589c69921 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -316,11 +316,12 @@ Country VolumeWii::GetCountry(const Partition& partition) const // The 0 that we use as a default value is mapped to Country::Unknown and Region::Unknown const u8 country_byte = ReadSwapped(3, partition).value_or(0); const Region region = GetRegion(); + const std::optional revision = GetRevision(); - if (CountryCodeToRegion(country_byte, Platform::WiiDisc, region) != region) + if (CountryCodeToRegion(country_byte, Platform::WiiDisc, region, revision) != region) return TypicalCountryForRegion(region); - return CountryCodeToCountry(country_byte, Platform::WiiDisc, region); + return CountryCodeToCountry(country_byte, Platform::WiiDisc, region, revision); } std::string VolumeWii::GetMakerID(const Partition& partition) const diff --git a/Source/Core/DiscIO/VolumeWii.h b/Source/Core/DiscIO/VolumeWii.h index e6b7e4117d..01df4f053f 100644 --- a/Source/Core/DiscIO/VolumeWii.h +++ b/Source/Core/DiscIO/VolumeWii.h @@ -45,22 +45,22 @@ public: static u64 EncryptedPartitionOffsetToRawOffset(u64 offset, const Partition& partition, u64 partition_data_offset); u64 PartitionOffsetToRawOffset(u64 offset, const Partition& partition) const override; - std::string GetGameID(const Partition& partition) const override; - std::string GetGameTDBID(const Partition& partition) const override; - std::string GetMakerID(const Partition& partition) const override; - std::optional GetRevision(const Partition& partition) const override; - std::string GetInternalName(const Partition& partition) const override; + std::string GetGameID(const Partition& partition = PARTITION_NONE) const override; + std::string GetGameTDBID(const Partition& partition = PARTITION_NONE) const override; + std::string GetMakerID(const Partition& partition = PARTITION_NONE) const override; + std::optional GetRevision(const Partition& partition = PARTITION_NONE) const override; + std::string GetInternalName(const Partition& partition = PARTITION_NONE) const override; std::map GetLongNames() const override; std::vector GetBanner(u32* width, u32* height) const override; std::string GetApploaderDate(const Partition& partition) const override; - std::optional GetDiscNumber(const Partition& partition) const override; + std::optional GetDiscNumber(const Partition& partition = PARTITION_NONE) const override; Platform GetVolumeType() const override; bool SupportsIntegrityCheck() const override { return true; } bool CheckIntegrity(const Partition& partition) const override; Region GetRegion() const override; - Country GetCountry(const Partition& partition) const override; + Country GetCountry(const Partition& partition = PARTITION_NONE) const override; BlobType GetBlobType() const override; u64 GetSize() const override; bool IsSizeAccurate() const override;