From d3190ec4f11bc2ceac7cf94648f1692fff9f71ed Mon Sep 17 00:00:00 2001 From: Stevoisiak Date: Mon, 23 Feb 2015 19:48:25 -0500 Subject: VolumeWad: Private variables for offset values --- Source/Core/DiscIO/VolumeWad.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 0e1f0c79b3..0a74312d1a 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -19,8 +19,8 @@ namespace DiscIO { CVolumeWAD::CVolumeWAD(IBlobReader* _pReader) - : m_pReader(_pReader), m_opening_bnr_offset(0), m_hdr_size(0) - , m_cert_size(0), m_tick_size(0), m_tmd_size(0), m_data_size(0) + : m_pReader(_pReader), m_offset(0), m_tmd_offset(0), m_opening_bnr_offset(0), + m_hdr_size(0), m_cert_size(0), m_tick_size(0), m_tmd_size(0), m_data_size(0) { Read(0x00, 4, (u8*)&m_hdr_size); Read(0x08, 4, (u8*)&m_cert_size); @@ -28,14 +28,16 @@ CVolumeWAD::CVolumeWAD(IBlobReader* _pReader) Read(0x14, 4, (u8*)&m_tmd_size); Read(0x18, 4, (u8*)&m_data_size); - u32 TmdOffset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size) + ALIGN_40(m_tick_size); - m_opening_bnr_offset = TmdOffset + ALIGN_40(m_tmd_size) + ALIGN_40(m_data_size); + m_offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size); + m_tmd_offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size) + ALIGN_40(m_tick_size); + m_opening_bnr_offset = m_tmd_offset + ALIGN_40(m_tmd_size) + ALIGN_40(m_data_size); + // read the last digit of the titleID in the ticket - Read(TmdOffset + 0x0193, 1, &m_Country); + Read(m_tmd_offset + 0x0193, 1, &m_Country); if (m_Country == 2) // SYSMENU { u16 titlever = 0; - Read(TmdOffset + 0x01dc, 2, (u8*)&titlever); + Read(m_tmd_offset + 0x01dc, 2, (u8*)&titlever); m_Country = GetSysMenuRegion(Common::swap16(titlever)); } } @@ -66,10 +68,9 @@ IVolume::ECountry CVolumeWAD::GetCountry() const std::string CVolumeWAD::GetUniqueID() const { std::string temp = GetMakerID(); - u32 Offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size); char GameCode[8]; - if (!Read(Offset + 0x01E0, 4, (u8*)GameCode)) + if (!Read(m_offset + 0x01E0, 4, (u8*)GameCode)) return "0"; GameCode[4] = temp.at(0); @@ -81,11 +82,9 @@ std::string CVolumeWAD::GetUniqueID() const std::string CVolumeWAD::GetMakerID() const { - u32 Offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size) + ALIGN_40(m_tick_size); - char temp[3] = {1}; // Some weird channels use 0x0000 in place of the MakerID, so we need a check there - if (!Read(0x198 + Offset, 2, (u8*)temp) || temp[0] == 0 || temp[1] == 0) + if (!Read(0x198 + m_tmd_offset, 2, (u8*)temp) || temp[0] == 0 || temp[1] == 0) return "00"; temp[2] = 0; @@ -95,9 +94,7 @@ std::string CVolumeWAD::GetMakerID() const bool CVolumeWAD::GetTitleID(u8* _pBuffer) const { - u32 Offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size); - - if (!Read(Offset + 0x01DC, 8, _pBuffer)) + if (!Read(m_offset + 0x01DC, 8, _pBuffer)) return false; return true; @@ -105,10 +102,8 @@ bool CVolumeWAD::GetTitleID(u8* _pBuffer) const int CVolumeWAD::GetRevision() const { - u32 TmdOffset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size) + ALIGN_40(m_tick_size); - u16 revision; - if (!m_pReader->Read(TmdOffset + 0x1dc, 2, (u8*)&revision)) + if (!m_pReader->Read(m_tmd_offset + 0x1dc, 2, (u8*)&revision)) return 0; return Common::swap16(revision); -- cgit v1.2.3 From df2f6d137e5e1b9e7ffe8a51f9952ab555a45898 Mon Sep 17 00:00:00 2001 From: Stevoisiak Date: Mon, 23 Feb 2015 19:50:19 -0500 Subject: VolumeWad: Move country identification to GetCountry() Brings the code more in line with the rest of the game volume code --- Source/Core/DiscIO/VolumeWad.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 0a74312d1a..2cbfbc92fd 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -31,15 +31,6 @@ CVolumeWAD::CVolumeWAD(IBlobReader* _pReader) m_offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size); m_tmd_offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size) + ALIGN_40(m_tick_size); m_opening_bnr_offset = m_tmd_offset + ALIGN_40(m_tmd_size) + ALIGN_40(m_data_size); - - // read the last digit of the titleID in the ticket - Read(m_tmd_offset + 0x0193, 1, &m_Country); - if (m_Country == 2) // SYSMENU - { - u16 titlever = 0; - Read(m_tmd_offset + 0x01dc, 2, (u8*)&titlever); - m_Country = GetSysMenuRegion(Common::swap16(titlever)); - } } CVolumeWAD::~CVolumeWAD() @@ -62,7 +53,18 @@ IVolume::ECountry CVolumeWAD::GetCountry() const if (!m_pReader) return COUNTRY_UNKNOWN; - return CountrySwitch(m_Country); + // read the last digit of the titleID in the ticket + u8 CountryCode; + Read(m_tmd_offset + 0x0193, 1, &CountryCode); + + if (CountryCode == 2) // SYSMENU + { + u16 titlever = 0; + Read(m_tmd_offset + 0x01dc, 2, (u8*)&titlever); + CountryCode = GetSysMenuRegion(Common::swap16(titlever)); + } + + return CountrySwitch(CountryCode); } std::string CVolumeWAD::GetUniqueID() const -- cgit v1.2.3 From 06cb85991e7abbbaf50479eb902ee5c43c7415a9 Mon Sep 17 00:00:00 2001 From: Stevoisiak Date: Mon, 23 Feb 2015 20:43:29 -0500 Subject: De-capitalized CountryCode --- Source/Core/DiscIO/VolumeWad.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 2cbfbc92fd..07c8255980 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -54,17 +54,17 @@ IVolume::ECountry CVolumeWAD::GetCountry() const return COUNTRY_UNKNOWN; // read the last digit of the titleID in the ticket - u8 CountryCode; - Read(m_tmd_offset + 0x0193, 1, &CountryCode); + u8 country_code; + Read(m_tmd_offset + 0x0193, 1, &country_code); - if (CountryCode == 2) // SYSMENU + if (country_code == 2) // SYSMENU { u16 titlever = 0; Read(m_tmd_offset + 0x01dc, 2, (u8*)&titlever); - CountryCode = GetSysMenuRegion(Common::swap16(titlever)); + country_code = GetSysMenuRegion(Common::swap16(titlever)); } - return CountrySwitch(CountryCode); + return CountrySwitch(country_code); } std::string CVolumeWAD::GetUniqueID() const -- cgit v1.2.3 From eff924e9e2c541efa40b1afcf0828a30896c9d08 Mon Sep 17 00:00:00 2001 From: Stevoisiak Date: Sat, 28 Feb 2015 17:24:02 -0500 Subject: General Formatting --- Source/Core/DiscIO/VolumeWad.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 07c8255980..ad19645d21 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -22,6 +22,7 @@ CVolumeWAD::CVolumeWAD(IBlobReader* _pReader) : m_pReader(_pReader), m_offset(0), m_tmd_offset(0), m_opening_bnr_offset(0), m_hdr_size(0), m_cert_size(0), m_tick_size(0), m_tmd_size(0), m_data_size(0) { + // Source: http://wiibrew.org/wiki/WAD_files Read(0x00, 4, (u8*)&m_hdr_size); Read(0x08, 4, (u8*)&m_cert_size); Read(0x10, 4, (u8*)&m_tick_size); -- cgit v1.2.3 From 5346e791bcba13f1e018d59514c57c610b2d0f0b Mon Sep 17 00:00:00 2001 From: Stevoisiak Date: Sat, 28 Feb 2015 21:42:16 -0500 Subject: VolumeWad: change titlever to title_version --- Source/Core/DiscIO/VolumeWad.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index ad19645d21..1dc746ea4d 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -60,9 +60,9 @@ IVolume::ECountry CVolumeWAD::GetCountry() const if (country_code == 2) // SYSMENU { - u16 titlever = 0; - Read(m_tmd_offset + 0x01dc, 2, (u8*)&titlever); - country_code = GetSysMenuRegion(Common::swap16(titlever)); + u16 title_version = 0; + Read(m_tmd_offset + 0x01dc, 2, (u8*)&title_version); + country_code = GetSysMenuRegion(Common::swap16(title_version)); } return CountrySwitch(country_code); -- cgit v1.2.3