From a3ee61e1a97899a0d29f15cdebf6a6589aa444dd Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 10 Jun 2017 17:31:03 +0200 Subject: [PATCH] DirectoryBlob: Let DirectoryBlob force GC/Wii for partition --- Source/Core/DiscIO/DirectoryBlob.cpp | 24 ++++++++++++++++-------- Source/Core/DiscIO/DirectoryBlob.h | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index 74e9682860..e8db47d29a 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -156,7 +156,7 @@ std::unique_ptr DirectoryBlobReader::Create(const std::stri } DirectoryBlobReader::DirectoryBlobReader(const std::string& root_directory) - : m_root_directory(root_directory), m_game_partition(root_directory) + : m_root_directory(root_directory), m_game_partition(root_directory, {}) { m_is_wii = m_game_partition.IsWii(); @@ -311,15 +311,16 @@ void DirectoryBlobReader::SetTMDAndTicket() reinterpret_cast(&m_tmd_header)); } -DirectoryBlobPartition::DirectoryBlobPartition(const std::string& root_directory) +DirectoryBlobPartition::DirectoryBlobPartition(const std::string& root_directory, + std::optional is_wii) : m_root_directory(root_directory) { - SetDiscHeaderAndDiscType(); + SetDiscHeaderAndDiscType(is_wii); SetBI2(); BuildFST(SetDOL(SetApploader())); } -void DirectoryBlobPartition::SetDiscHeaderAndDiscType() +void DirectoryBlobPartition::SetDiscHeaderAndDiscType(std::optional is_wii) { constexpr u64 DISKHEADER_ADDRESS = 0; constexpr u64 DISKHEADER_SIZE = 0x440; @@ -331,10 +332,17 @@ void DirectoryBlobPartition::SetDiscHeaderAndDiscType() m_contents.emplace(DISKHEADER_ADDRESS, DISKHEADER_SIZE, m_disk_header.data()); - m_is_wii = Common::swap32(&m_disk_header[0x18]) == 0x5d1c9ea3; - const bool is_gc = Common::swap32(&m_disk_header[0x1c]) == 0xc2339f3d; - if (m_is_wii == is_gc) - ERROR_LOG(DISCIO, "Couldn't detect disc type based on %s", boot_bin_path.c_str()); + if (is_wii.has_value()) + { + m_is_wii = *is_wii; + } + else + { + m_is_wii = Common::swap32(&m_disk_header[0x18]) == 0x5d1c9ea3; + const bool is_gc = Common::swap32(&m_disk_header[0x1c]) == 0xc2339f3d; + if (m_is_wii == is_gc) + ERROR_LOG(DISCIO, "Couldn't detect disc type based on %s", boot_bin_path.c_str()); + } m_address_shift = m_is_wii ? 2 : 0; } diff --git a/Source/Core/DiscIO/DirectoryBlob.h b/Source/Core/DiscIO/DirectoryBlob.h index 3bcde03dd5..647ac11380 100644 --- a/Source/Core/DiscIO/DirectoryBlob.h +++ b/Source/Core/DiscIO/DirectoryBlob.h @@ -55,7 +55,7 @@ private: class DirectoryBlobPartition { public: - explicit DirectoryBlobPartition(const std::string& root_directory); + DirectoryBlobPartition(const std::string& root_directory, std::optional is_wii); // We do not allow copying, because it might mess up the pointers inside DiscContents DirectoryBlobPartition(const DirectoryBlobPartition&) = delete; @@ -67,7 +67,7 @@ public: const std::vector& GetHeader() const { return m_disk_header; } const std::set& GetContents() const { return m_contents; } private: - void SetDiscHeaderAndDiscType(); + void SetDiscHeaderAndDiscType(std::optional is_wii); void SetBI2(); // Returns DOL address