DirectoryBlob: Split out setting partition table to new function

This commit is contained in:
JosJuice 2017-06-10 10:41:49 +02:00
parent c4879aa48d
commit b28ec0b7ee
2 changed files with 13 additions and 8 deletions

View File

@ -54,12 +54,7 @@ constexpr u64 BI2_SIZE = 0x2000;
constexpr u64 APPLOADER_ADDRESS = 0x2440;
constexpr u64 WII_REGION_DATA_ADDRESS = 0x4E000;
constexpr u64 WII_REGION_DATA_SIZE = 0x20;
constexpr u64 GAME_PARTITION_ADDRESS = 0x50000;
constexpr u64 PARTITION_TABLE_ADDRESS = 0x40000;
const std::array<u32, 10> PARTITION_TABLE = {
{Common::swap32(1), Common::swap32((PARTITION_TABLE_ADDRESS + 0x20) >> 2), 0, 0, 0, 0, 0, 0,
Common::swap32(GAME_PARTITION_ADDRESS >> 2), 0}};
DiscContent::DiscContent(u64 offset, u64 size, const std::string& path)
: m_offset(offset), m_size(size), m_content_source(path)
@ -181,9 +176,7 @@ DirectoryBlobReader::DirectoryBlobReader(const std::string& root_directory)
if (m_is_wii)
{
m_nonpartition_contents.emplace(PARTITION_TABLE_ADDRESS, PARTITION_TABLE.size() * sizeof(u32),
reinterpret_cast<const u8*>(PARTITION_TABLE.data()));
SetPartitionTable();
SetWiiRegionData();
SetTMDAndTicket();
}
@ -295,6 +288,17 @@ void DirectoryBlobReader::SetDiscHeaderAndDiscType()
}
}
void DirectoryBlobReader::SetPartitionTable()
{
constexpr u64 PARTITION_TABLE_ADDRESS = 0x40000;
static const std::array<u32, 10> PARTITION_TABLE = {
{Common::swap32(1), Common::swap32((PARTITION_TABLE_ADDRESS + 0x20) >> 2), 0, 0, 0, 0, 0, 0,
Common::swap32(GAME_PARTITION_ADDRESS >> 2), 0}};
m_nonpartition_contents.emplace(PARTITION_TABLE_ADDRESS, PARTITION_TABLE.size() * sizeof(u32),
reinterpret_cast<const u8*>(PARTITION_TABLE.data()));
}
void DirectoryBlobReader::SetWiiRegionData()
{
m_wii_region_data.resize(0x10, 0x00);

View File

@ -77,6 +77,7 @@ private:
bool ReadInternal(u64 offset, u64 length, u8* buffer, const std::set<DiscContent>& contents);
void SetDiscHeaderAndDiscType();
void SetPartitionTable();
void SetWiiRegionData();
void SetTMDAndTicket();
bool SetApploader(const std::string& apploader);