summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/VolumeWiiCrypted.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2016-12-23 18:41:21 +0100
committerJosJuice <josjuice@gmail.com>2017-01-02 20:57:11 +0100
commit66ea9f5cc18ca6beb87ddd7f7a291d96669ad653 (patch)
tree011a81833e2b2b5452b390ba4f58181ab77e8d66 /Source/Core/DiscIO/VolumeWiiCrypted.cpp
parent6aef0630f74e61d6847fc1f1186056df8bd42651 (diff)
DiscIO: Add GetRegion function and Region enum
Instead of needing different switch cases for converting countries to regions in multiple places, we now only need a single country-to-region switch case (in DiscIO/Enums.cpp), and we get a nice Region type.
Diffstat (limited to 'Source/Core/DiscIO/VolumeWiiCrypted.cpp')
-rw-r--r--Source/Core/DiscIO/VolumeWiiCrypted.cpp53
1 files changed, 20 insertions, 33 deletions
diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/VolumeWiiCrypted.cpp
index 09224e04aa..7976e1d758 100644
--- a/Source/Core/DiscIO/VolumeWiiCrypted.cpp
+++ b/Source/Core/DiscIO/VolumeWiiCrypted.cpp
@@ -153,51 +153,38 @@ std::string CVolumeWiiCrypted::GetGameID() const
return DecodeString(ID);
}
-Country CVolumeWiiCrypted::GetCountry() const
+Region CVolumeWiiCrypted::GetRegion() const
{
- if (!m_pReader)
- return Country::COUNTRY_UNKNOWN;
+ u32 region_code;
+ if (!ReadSwapped(0x4E000, &region_code, false))
+ return Region::UNKNOWN_REGION;
+
+ return static_cast<Region>(region_code);
+}
+Country CVolumeWiiCrypted::GetCountry() const
+{
u8 country_byte;
if (!m_pReader->Read(3, 1, &country_byte))
return Country::COUNTRY_UNKNOWN;
- Country country_value = CountrySwitch(country_byte);
+ const Region region = GetRegion();
- u32 region_code;
- if (!ReadSwapped(0x4E000, &region_code, false))
- return country_value;
+ if (RegionSwitchWii(country_byte) == region)
+ return CountrySwitch(country_byte);
- switch (region_code)
+ switch (region)
{
- case 0:
- switch (country_value)
- {
- case Country::COUNTRY_TAIWAN:
- return Country::COUNTRY_TAIWAN;
- default:
- return Country::COUNTRY_JAPAN;
- }
- case 1:
+ case Region::NTSC_J:
+ return Country::COUNTRY_JAPAN;
+ case Region::NTSC_U:
return Country::COUNTRY_USA;
- case 2:
- switch (country_value)
- {
- case Country::COUNTRY_FRANCE:
- case Country::COUNTRY_GERMANY:
- case Country::COUNTRY_ITALY:
- case Country::COUNTRY_NETHERLANDS:
- case Country::COUNTRY_RUSSIA:
- case Country::COUNTRY_SPAIN:
- case Country::COUNTRY_AUSTRALIA:
- return country_value;
- default:
- return Country::COUNTRY_EUROPE;
- }
- case 4:
+ case Region::PAL:
+ return Country::COUNTRY_EUROPE;
+ case Region::NTSC_K:
return Country::COUNTRY_KOREA;
default:
- return country_value;
+ return Country::COUNTRY_UNKNOWN;
}
}