diff options
| author | Matthew Parlane <parlane@gmail.com> | 2017-02-27 16:15:05 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-27 16:15:05 +1300 |
| commit | 48aeb5bf4be58eafd9a9fd36de983aaccfc25365 (patch) | |
| tree | f7fb394acdc67efce888648ecf6d66d71e277964 /Source/Core/DiscIO/VolumeWad.cpp | |
| parent | d1b343ab5aebf9398c5b3d78382678df50728d0c (diff) | |
| parent | 44a3db21e4b7fe20ee2ed6253990f5981b3f12f9 (diff) | |
Merge pull request #4896 from leoetlino/esformats
Use ESFormats for tickets, TMDs and views
Diffstat (limited to 'Source/Core/DiscIO/VolumeWad.cpp')
| -rw-r--r-- | Source/Core/DiscIO/VolumeWad.cpp | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 29f543586d..01080c7b52 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -36,6 +36,16 @@ CVolumeWAD::CVolumeWAD(std::unique_ptr<IBlobReader> reader) : m_reader(std::move Common::AlignUp(m_tick_size, 0x40); m_opening_bnr_offset = m_tmd_offset + Common::AlignUp(m_tmd_size, 0x40) + Common::AlignUp(m_data_size, 0x40); + + if (m_tmd_size > 1024 * 1024 * 4) + { + ERROR_LOG(DISCIO, "TMD is too large: %u bytes", m_tmd_size); + return; + } + + std::vector<u8> tmd_buffer(m_tmd_size); + Read(m_tmd_offset, m_tmd_size, tmd_buffer.data(), false); + m_tmd.SetBytes(std::move(tmd_buffer)); } CVolumeWAD::~CVolumeWAD() @@ -55,40 +65,26 @@ bool CVolumeWAD::Read(u64 offset, u64 length, u8* buffer, bool decrypt) const Region CVolumeWAD::GetRegion() const { - u8 country_code; - if (!Read(m_tmd_offset + 0x0193, 1, &country_code)) + if (!m_tmd.IsValid()) return Region::UNKNOWN_REGION; - - return RegionSwitchWii(country_code); + return m_tmd.GetRegion(); } Country CVolumeWAD::GetCountry() const { - // read the last digit of the titleID in the ticket - u8 country_code; - if (!Read(m_tmd_offset + 0x0193, 1, &country_code)) + if (!m_tmd.IsValid()) return Country::COUNTRY_UNKNOWN; + u8 country_code = static_cast<u8>(m_tmd.GetTitleId() & 0xff); if (country_code == 2) // SYSMENU - { - u16 title_version = 0; - Read(m_tmd_offset + 0x01dc, 2, (u8*)&title_version); - country_code = GetSysMenuRegion(Common::swap16(title_version)); - } + country_code = GetSysMenuRegion(m_tmd.GetTitleVersion()); return CountrySwitch(country_code); } -std::vector<u8> CVolumeWAD::GetTMD() const +IOS::ES::TMDReader CVolumeWAD::GetTMD() const { - if (m_tmd_size > 1024 * 1024 * 4) - { - ERROR_LOG(DISCIO, "TMD is too large: %u bytes", m_tmd_size); - return {}; - } - std::vector<u8> buffer(m_tmd_size); - Read(m_tmd_offset, m_tmd_size, buffer.data(), false); - return buffer; + return m_tmd; } std::string CVolumeWAD::GetGameID() const @@ -125,11 +121,10 @@ bool CVolumeWAD::GetTitleID(u64* buffer) const u16 CVolumeWAD::GetRevision() const { - u16 revision; - if (!m_reader->Read(m_tmd_offset + 0x1dc, 2, (u8*)&revision)) + if (!m_tmd.IsValid()) return 0; - return Common::swap16(revision); + return m_tmd.GetTitleVersion(); } Platform CVolumeWAD::GetVolumeType() const |
