mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #5795 from JosJuice/gc-region-detection
Improve GameCube region detection
This commit is contained in:
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user