diff options
| author | Leo Lam <leolino.lam@gmail.com> | 2017-07-20 14:13:11 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-20 14:13:11 +0800 |
| commit | c207a1072da9ccfda727bbc740cc1a73c763aae1 (patch) | |
| tree | 83baf257749db2cda3c5e97a82f4ba9b642b3b82 /Source/Core/DiscIO | |
| parent | 39e17ccc41d79b778bae4c1be9cf661842165c66 (diff) | |
| parent | c83cac7cca874de782109fdeee2990aab8606879 (diff) | |
Merge pull request #5795 from JosJuice/gc-region-detection
Improve GameCube region detection
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/Enums.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Enums.h | 9 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Volume.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeGC.cpp | 25 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeWad.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeWii.cpp | 5 |
6 files changed, 35 insertions, 8 deletions
diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index 94af6c75a9..6add18d801 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -48,7 +48,7 @@ Country TypicalCountryForRegion(Region region) Region RegionSwitchGC(u8 country_code) { Region region = RegionSwitchWii(country_code); - return region == Region::NTSC_K ? Region::UNKNOWN_REGION : region; + return region == Region::NTSC_K ? Region::NTSC_J : region; } Region RegionSwitchWii(u8 country_code) diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index cce235c38e..fda94c43be 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -40,10 +40,10 @@ enum class Country NUMBER_OF_COUNTRIES }; -// Regions 0 - 2 and 4 match Nintendo's Wii region numbering. +// Regions 0 - 2 and 4 match Nintendo's GameCube/Wii region numbering. enum class Region { - NTSC_J = 0, // Japan and Taiwan + NTSC_J = 0, // Japan and Taiwan (and South Korea for GameCube only) NTSC_U = 1, // Mainly North America PAL = 2, // Mainly Europe and Oceania UNKNOWN_REGION = 3, // 3 seems to be unused? Anyway, we need an UNKNOWN_REGION. Let's put it here @@ -71,11 +71,16 @@ enum class Language bool IsDisc(Platform volume_type); bool IsWii(Platform volume_type); 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 GetSysMenuRegion(u16 title_version); std::string GetSysMenuVersionString(u16 title_version); + std::string GetCompanyFromID(const std::string& company_id); } diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index e0978048ab..209a0d09a9 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -83,6 +83,7 @@ public: virtual Platform GetVolumeType() const = 0; virtual bool SupportsIntegrityCheck() const { return false; } virtual bool CheckIntegrity(const Partition& partition) const { return false; } + // May be inaccurate for WADs virtual Region GetRegion() const = 0; Country GetCountry() const { return GetCountry(GetGamePartition()); } virtual Country GetCountry(const Partition& partition) const = 0; diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp index 1a89917812..46ac57278c 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -60,14 +60,31 @@ std::string VolumeGC::GetGameID(const Partition& partition) const Region VolumeGC::GetRegion() const { - const std::optional<u8> country_code = ReadSwapped<u8>(3, PARTITION_NONE); - return country_code ? RegionSwitchGC(*country_code) : Region::UNKNOWN_REGION; + const std::optional<u32> region_code = ReadSwapped<u32>(0x458, PARTITION_NONE); + if (!region_code) + return Region::UNKNOWN_REGION; + const Region region = static_cast<Region>(*region_code); + return region <= Region::PAL ? region : Region::UNKNOWN_REGION; } Country VolumeGC::GetCountry(const Partition& partition) const { - const std::optional<u8> country_code = ReadSwapped<u8>(3, partition); - return country_code ? CountrySwitch(*country_code) : Country::COUNTRY_UNKNOWN; + // The 0 that we use as a default value is mapped to COUNTRY_UNKNOWN and UNKNOWN_REGION + 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::COUNTRY_KOREA; + + if (RegionSwitchGC(country) != region) + return TypicalCountryForRegion(region); + + return CountrySwitch(country); } std::string VolumeGC::GetMakerID(const Partition& partition) const diff --git a/Source/Core/DiscIO/VolumeWad.h b/Source/Core/DiscIO/VolumeWad.h index d8b45d3585..d1964bcfa1 100644 --- a/Source/Core/DiscIO/VolumeWad.h +++ b/Source/Core/DiscIO/VolumeWad.h @@ -50,6 +50,7 @@ public: return ""; } Platform GetVolumeType() const override; + // Provides a best guess for the region. Might be inaccurate or UNKNOWN_REGION. Region GetRegion() const override; Country GetCountry(const Partition& partition = PARTITION_NONE) const override; diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index cf570e39ea..7225a1e57f 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -233,7 +233,10 @@ std::string VolumeWii::GetGameID(const Partition& partition) const Region VolumeWii::GetRegion() const { const std::optional<u32> region_code = m_pReader->ReadSwapped<u32>(0x4E000); - return region_code ? static_cast<Region>(*region_code) : Region::UNKNOWN_REGION; + if (!region_code) + return Region::UNKNOWN_REGION; + const Region region = static_cast<Region>(*region_code); + return region <= Region::NTSC_K ? region : Region::UNKNOWN_REGION; } Country VolumeWii::GetCountry(const Partition& partition) const |
