From d0c322f6e6cf5b574d4f54eb38df82c52c288671 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 18 Jul 2017 15:53:04 +0200 Subject: [PATCH] DirectoryBlob: Don't silently set GC region to NTSC-J if bi2.bin is missing We were already handling the Wii region in region.bin in this way. --- Source/Core/DiscIO/DirectoryBlob.cpp | 18 ++++++++++++++---- Source/Core/DiscIO/DirectoryBlob.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index ab53bd3af7..a91472fb63 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -56,6 +56,9 @@ enum class PartitionType : u32 // There are more types used by Super Smash Bros. Brawl, but they don't have special names }; +// 0xFF is an arbitrarily picked value. Note that we can't use 0x00, because that means NTSC-J +constexpr u32 INVALID_REGION = 0xFF; + constexpr u8 ENTRY_SIZE = 0x0c; constexpr u8 FILE_ENTRY = 0; constexpr u8 DIRECTORY_ENTRY = 1; @@ -422,9 +425,6 @@ void DirectoryBlobReader::SetWiiRegionData(const std::string& game_partition_roo { m_wii_region_data.resize(0x10, 0x00); m_wii_region_data.resize(0x20, 0x80); - - // 0xFF is an arbitrarily picked value. Note that we can't use 0x00, because that means NTSC-J - constexpr u32 INVALID_REGION = 0xFF; Write32(INVALID_REGION, 0, &m_wii_region_data); const std::string region_bin_path = game_partition_root + "disc/region.bin"; @@ -590,7 +590,17 @@ void DirectoryBlobPartition::SetBI2() { constexpr u64 BI2_ADDRESS = 0x440; constexpr u64 BI2_SIZE = 0x2000; - AddFileToContents(&m_contents, m_root_directory + "sys/bi2.bin", BI2_ADDRESS, BI2_SIZE); + m_bi2.resize(BI2_SIZE); + + if (!m_is_wii) + Write32(INVALID_REGION, 0x18, &m_bi2); + + const std::string bi2_path = m_root_directory + "sys/bi2.bin"; + const size_t bytes_read = ReadFileToVector(bi2_path, &m_bi2); + if (!m_is_wii && bytes_read < 0x1C) + ERROR_LOG(DISCIO, "Couldn't read region from %s", bi2_path.c_str()); + + m_contents.emplace(BI2_ADDRESS, BI2_SIZE, m_bi2.data()); } u64 DirectoryBlobPartition::SetApploader() diff --git a/Source/Core/DiscIO/DirectoryBlob.h b/Source/Core/DiscIO/DirectoryBlob.h index 97bff45e83..5547f19110 100644 --- a/Source/Core/DiscIO/DirectoryBlob.h +++ b/Source/Core/DiscIO/DirectoryBlob.h @@ -95,6 +95,7 @@ private: std::set m_contents; std::vector m_disk_header; + std::vector m_bi2; std::vector m_apploader; std::vector m_fst_data;