DirectoryBlob: fix data alignment for GC/Triforce and skip Triforce DIMM memory range

The 0x8000 alignment in DirectoryBlob is needed for Wii disc group encryption,
but for GC/Triforce it inflates file offsets unnecessarily. Use 0x20 alignment
for Triforce (matching original disc layout) while keeping 0x8000 for GC due
to DTK audio streaming requirements.

On Triforce games with many files, the inflated offsets can land in the
AMMediaboard DIMM memory range (0x1F000000-0x1F800000). Reads from that
region return SRAM data instead of disc data, causing the game to hang.

Skip the DIMM range when assigning per-file data offsets if any portion of
the file would overlap [0x1F000000, 0x1F800000).
This commit is contained in:
naari3
2026-04-25 19:48:00 +09:00
parent 6871428a81
commit e013d95053
2 changed files with 13 additions and 3 deletions
+12 -3
View File
@@ -895,7 +895,8 @@ DirectoryBlobPartition::DirectoryBlobPartition(
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>&
fst_callback,
DirectoryBlobReader* blob)
: m_wrapped_partition(partition)
: m_wrapped_partition(partition),
m_is_triforce(volume && volume->GetVolumeType() == Platform::Triforce)
{
std::vector<FSTBuilderNode> sys_nodes;
@@ -1230,6 +1231,14 @@ void DirectoryBlobPartition::WriteDirectory(std::vector<u8>* fst_data,
}
else
{
// Skip Triforce DIMM so the file doesn't overlap with it. Any portion of
// a file placed in 0x1F000000-0x1F800000 would be shadowed by SRAM on the
// AMMediaboard and read back as DIMM contents instead of disc data.
if (m_is_triforce && *data_offset < 0x1F800000 && *data_offset + entry.m_size > 0x1F000000)
{
*data_offset = 0x1F800000ull;
}
// put entry in FST
WriteEntryData(fst_data, fst_offset, FILE_ENTRY, *name_offset, *data_offset, entry.m_size,
m_address_shift);
@@ -1243,8 +1252,8 @@ void DirectoryBlobPartition::WriteDirectory(std::vector<u8>* fst_data,
std::move(content.m_source));
}
// 32 KiB aligned - many games are fine with less alignment, but not all
*data_offset = Common::AlignUp(*data_offset + entry.m_size, 0x8000ull);
const u64 data_alignment = m_is_triforce ? 0x20ull : 0x8000ull;
*data_offset = Common::AlignUp(*data_offset + entry.m_size, data_alignment);
}
}
}
+1
View File
@@ -231,6 +231,7 @@ private:
std::string m_root_directory;
bool m_is_wii = false;
bool m_is_triforce = false;
// GameCube has no shift, Wii has 2 bit shift
u32 m_address_shift = 0;