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.
This commit is contained in:
JosJuice 2017-07-18 15:53:04 +02:00
parent 3fd0d39a85
commit d0c322f6e6
2 changed files with 15 additions and 4 deletions

View File

@ -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 // 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 ENTRY_SIZE = 0x0c;
constexpr u8 FILE_ENTRY = 0; constexpr u8 FILE_ENTRY = 0;
constexpr u8 DIRECTORY_ENTRY = 1; 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(0x10, 0x00);
m_wii_region_data.resize(0x20, 0x80); 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); Write32(INVALID_REGION, 0, &m_wii_region_data);
const std::string region_bin_path = game_partition_root + "disc/region.bin"; 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_ADDRESS = 0x440;
constexpr u64 BI2_SIZE = 0x2000; 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() u64 DirectoryBlobPartition::SetApploader()

View File

@ -95,6 +95,7 @@ private:
std::set<DiscContent> m_contents; std::set<DiscContent> m_contents;
std::vector<u8> m_disk_header; std::vector<u8> m_disk_header;
std::vector<u8> m_bi2;
std::vector<u8> m_apploader; std::vector<u8> m_apploader;
std::vector<u8> m_fst_data; std::vector<u8> m_fst_data;