diff options
| author | Lioncash <mathew1800@gmail.com> | 2015-09-22 13:25:54 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2015-09-22 13:50:35 -0400 |
| commit | 4b9b82e00016cbb8aa3c8a45bd32aea460f28c07 (patch) | |
| tree | 76f25689c3087da3ba0c663e307b40ada1bc551d /Source/Core/DiscIO | |
| parent | 5d774df1e8e0622a68f53c741db07922baadeae3 (diff) | |
DiscIO: Do swapping in GetTitleID implementations
Gets rid of external swaps at every usage.
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/Volume.h | 2 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeCommon.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeWad.cpp | 5 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeWad.h | 2 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeWiiCrypted.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeWiiCrypted.h | 2 |
6 files changed, 15 insertions, 11 deletions
diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index 6f80efc55d..a2314e825d 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -76,7 +76,7 @@ public: return Common::swap32(temp); } - virtual bool GetTitleID(u8*) const { return false; } + virtual bool GetTitleID(u64*) const { return false; } virtual std::unique_ptr<u8[]> GetTMD(u32 *_sz) const { *_sz = 0; diff --git a/Source/Core/DiscIO/VolumeCommon.cpp b/Source/Core/DiscIO/VolumeCommon.cpp index f5ceac8b0f..345ead0193 100644 --- a/Source/Core/DiscIO/VolumeCommon.cpp +++ b/Source/Core/DiscIO/VolumeCommon.cpp @@ -29,12 +29,11 @@ std::vector<u32> IVolume::GetBanner(int* width, int* height) const *width = 0; *height = 0; - u64 TitleID = 0; - GetTitleID((u8*)&TitleID); - TitleID = Common::swap64(TitleID); + u64 title_id = 0; + GetTitleID(&title_id); std::string file_name = StringFromFormat("%s/title/%08x/%08x/data/banner.bin", - File::GetUserPath(D_WIIROOT_IDX).c_str(), (u32)(TitleID >> 32), (u32)TitleID); + File::GetUserPath(D_WIIROOT_IDX).c_str(), (u32)(title_id >> 32), (u32)title_id); if (!File::Exists(file_name)) return std::vector<u32>(); diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index f37e165b56..a268b3add9 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -93,11 +93,12 @@ std::string CVolumeWAD::GetMakerID() const return DecodeString(temp); } -bool CVolumeWAD::GetTitleID(u8* _pBuffer) const +bool CVolumeWAD::GetTitleID(u64* buffer) const { - if (!Read(m_offset + 0x01DC, 8, _pBuffer)) + if (!Read(m_offset + 0x01DC, sizeof(u64), reinterpret_cast<u8*>(buffer))) return false; + *buffer = Common::swap64(*buffer); return true; } diff --git a/Source/Core/DiscIO/VolumeWad.h b/Source/Core/DiscIO/VolumeWad.h index 8405b612e9..580a751a8d 100644 --- a/Source/Core/DiscIO/VolumeWad.h +++ b/Source/Core/DiscIO/VolumeWad.h @@ -27,7 +27,7 @@ public: CVolumeWAD(std::unique_ptr<IBlobReader> reader); ~CVolumeWAD(); bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt = false) const override; - bool GetTitleID(u8* _pBuffer) const override; + bool GetTitleID(u64* buffer) const override; std::string GetUniqueID() const override; std::string GetMakerID() const override; u16 GetRevision() const override; diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/VolumeWiiCrypted.cpp index 96fe209d0d..aa7f36da64 100644 --- a/Source/Core/DiscIO/VolumeWiiCrypted.cpp +++ b/Source/Core/DiscIO/VolumeWiiCrypted.cpp @@ -107,11 +107,15 @@ bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, bool de return true; } -bool CVolumeWiiCrypted::GetTitleID(u8* _pBuffer) const +bool CVolumeWiiCrypted::GetTitleID(u64* buffer) const { // Tik is at m_VolumeOffset size 0x2A4 // TitleID offset in tik is 0x1DC - return Read(m_VolumeOffset + 0x1DC, 8, _pBuffer, false); + if (!Read(m_VolumeOffset + 0x1DC, sizeof(u64), reinterpret_cast<u8*>(buffer), false)) + return false; + + *buffer = Common::swap64(*buffer); + return true; } std::unique_ptr<u8[]> CVolumeWiiCrypted::GetTMD(u32 *size) const diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.h b/Source/Core/DiscIO/VolumeWiiCrypted.h index 87055f16e1..66b48a2e44 100644 --- a/Source/Core/DiscIO/VolumeWiiCrypted.h +++ b/Source/Core/DiscIO/VolumeWiiCrypted.h @@ -26,7 +26,7 @@ public: CVolumeWiiCrypted(std::unique_ptr<IBlobReader> reader, u64 _VolumeOffset, const unsigned char* _pVolumeKey); ~CVolumeWiiCrypted(); bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const override; - bool GetTitleID(u8* _pBuffer) const override; + bool GetTitleID(u64* buffer) const override; std::unique_ptr<u8[]> GetTMD(u32 *_sz) const override; std::string GetUniqueID() const override; std::string GetMakerID() const override; |
