First round of cleanup for DolphinLib additions

This commit is contained in:
Matt Nadareski
2026-05-12 20:33:53 -04:00
parent 49aa6895b6
commit 2a0e8e2eb0
53 changed files with 3861 additions and 2586 deletions

View File

@@ -17,10 +17,10 @@ namespace SabreTools.Data.Models.GCZ
/// Each value encodes both the offset of the block within the compressed data section
/// and a compression flag in the top bit:
/// <list type="bullet">
/// <item>Top bit CLEAR block is zlib/deflate-compressed at that offset.</item>
/// <item>Top bit SET block is stored uncompressed at that offset.</item>
/// <item>Top bit CLEAR -> block is zlib/deflate-compressed at that offset.</item>
/// <item>Top bit SET -> block is stored uncompressed at that offset.</item>
/// </list>
/// Offset is <c>value &amp; ~UncompressedFlag</c>.
/// Offset is value &amp; ~UncompressedFlag.
/// </summary>
public ulong[] BlockPointers { get; set; } = [];

View File

@@ -30,7 +30,7 @@
public FolderIndex FolderIndex { get; set; }
/// <summary>
/// Date of this file, in the format ((year1980) << 9)+(month << 5)+(day), where
/// Date of this file, in the format ((year-1980) << 9)+(month << 5)+(day), where
/// month={1..12} and day = { 1..31 }. This "date" is typically considered the "last modified" date in local
/// time, but the actual definition is application-defined.
/// </summary>

View File

@@ -11,47 +11,8 @@ namespace SabreTools.Data.Models.NintendoDisc
public const uint WiiMagicWord = 0x5D1C9EA3;
#endregion
#region Disc header layout
// Offsets within the 0x440-byte boot block.
// Layout confirmed against Dolphin source (VolumeDisc.cpp / DiscUtils.h):
// 0x0000x003 Title code (4 chars, e.g. "GAFE")
// 0x0040x005 Maker code (2 chars, e.g. "01") — Dolphin Read(0x4, 2)
// 0x006 Disc number — Dolphin GetDiscNumber() Read(6)
// 0x007 Revision — Dolphin GetRevision() Read(7)
// 0x008 Audio streaming
// 0x009 Streaming buffer size
// 0x00A0x017 Unused (14 bytes)
// 0x018 Wii magic (0x5D1C9EA3)
// 0x01C GC magic (0xC2339F3D)
// 0x0200x07F Game title (0x60 bytes)
// 0x080 Disable hash verification
// 0x081 Disable disc encryption
public const int TitleCodeOffset = 0x000;
public const int TitleCodeLength = 4;
public const int MakerCodeOffset = 0x004;
public const int MakerCodeLength = 2;
/// <summary>Full 6-char game ID = TitleCode[4] + MakerCode[2]</summary>
public const int GameIdOffset = 0x000;
public const int GameIdLength = 6;
public const int DiscNumberOffset = 0x006;
public const int DiscVersionOffset = 0x007;
public const int AudioStreamingOffset = 0x008;
public const int StreamingBufferSizeOffset = 0x009;
public const int WiiMagicOffset = 0x018;
public const int GCMagicOffset = 0x01C;
public const int GameTitleOffset = 0x020;
public const int GameTitleLength = 0x060;
public const int DisableHashVerificationOffset = 0x080;
public const int DisableDiscEncryptionOffset = 0x081;
public const int DolOffsetField = 0x420;
public const int FstOffsetField = 0x424;
public const int FstSizeField = 0x428;
public const int DiscHeaderSize = 0x440;
#endregion
#region BI2 data
public const int Bi2Address = 0x000440;
@@ -97,6 +58,7 @@ namespace SabreTools.Data.Models.NintendoDisc
public const int WiiBlockHeaderSize = 0x0400;
public const int WiiBlockDataSize = 0x7C00;
public const int WiiBlocksPerGroup = 64;
public const int WiiBlockHashSize = 0x0400;
public const int WiiGroupSize = WiiBlocksPerGroup * WiiBlockSize;
public const int WiiGroupDataSize = WiiBlocksPerGroup * WiiBlockDataSize;

View File

@@ -0,0 +1,64 @@
namespace SabreTools.Data.Models.NintendoDisc
{
/// <see href="https://wiki.tockdom.com/wiki/DOL_(File_Format)"/>
public class DOLHeader
{
/// <summary>
/// Section offsets indicate where each section's data begins relative
/// to the start of this header. 0 for unused sections.
/// </summary>
/// <remarks>
/// Big-endian
/// Indexes 0-6 are text sections.
/// Indexes 7-17 are data sections.
/// </remarks>
public uint[] SectionOffsetTable { get; set; } = new uint[18];
/// <summary>
/// Section address indicates where each section should be copied to by
/// the loader as a virtual memory address. 0 for unused sections.
/// </summary>
/// <remarks>
/// Big-endian
/// Indexes 0-6 are text sections.
/// Indexes 7-17 are data sections.
/// </remarks>
public uint[] SectionAddressTable { get; set; } = new uint[18];
/// <summary>
/// Section lengths indicate the size in bytes of each section.
/// 0 for unused sections.
/// </summary>
/// <remarks>
/// Big-endian
/// Indexes 0-6 are text sections.
/// Indexes 7-17 are data sections.
/// </remarks>
public uint[] SectionLengthsTable { get; set; } = new uint[18];
/// <summary>
/// bss address indicates the start of the zero initialised (bss) range.
/// </summary>
/// <remarks>Big-endian</remarks>
public uint BSSAddress { get; set; }
/// <summary>
/// bss length indicates the size in bytes of the zero initialised (bss) range.
/// </summary>
/// <remarks>Big-endian</remarks>
public uint BSSLength { get; set; }
/// <summary>
/// Entry point indicates the virtual memory address of a function to run after
/// the DOL has been loaded in order to start the program.
/// This function should not return.
/// </summary>
/// <remarks>Big-endian</remarks>
public uint EntryPoint { get; set; }
/// <summary>
/// Padding
/// </summary>
public byte[] Padding { get; set; } = new byte[0x1C];
}
}

View File

@@ -10,11 +10,6 @@ namespace SabreTools.Data.Models.NintendoDisc
/// </summary>
public DiscHeader Header { get; set; } = new();
/// <summary>
/// Detected platform (GameCube or Wii)
/// </summary>
public Platform Platform { get; set; }
/// <summary>
/// Wii partition table entries (Wii discs only)
/// </summary>

View File

@@ -12,12 +12,6 @@ namespace SabreTools.Data.Models.NintendoDisc
/// <remarks>6 bytes at offset 0x000</remarks>
public string GameId { get; set; } = string.Empty;
/// <summary>
/// 2-character ASCII maker / publisher code (e.g. "01")
/// </summary>
/// <remarks>Derived from GameId bytes at offset 0x0040x005; not a separate on-disc field</remarks>
public string MakerCode { get; set; } = string.Empty;
/// <summary>
/// Zero-based disc number for multi-disc games
/// </summary>
@@ -38,6 +32,11 @@ namespace SabreTools.Data.Models.NintendoDisc
/// </summary>
public byte StreamingBufferSize { get; set; }
/// <summary>
/// Unused 0x0E bytes (offsets 0x00A-0x017)
/// </summary>
public byte[] Padding00A { get; set; } = [];
/// <summary>
/// Wii magic word at offset 0x018 (0x5D1C9EA3 for Wii discs, 0 for GameCube)
/// </summary>
@@ -63,6 +62,11 @@ namespace SabreTools.Data.Models.NintendoDisc
/// </summary>
public byte DisableDiscEncryption { get; set; }
/// <summary>
/// Unused padding until DOL/FST offset fields at 0x420
/// </summary>
public byte[] Padding082 { get; set; } = [];
/// <summary>
/// Offset of the main DOL executable (no shift for GameCube; &lt;&lt;2 for Wii)
/// </summary>
@@ -77,5 +81,10 @@ namespace SabreTools.Data.Models.NintendoDisc
/// Maximum size of the File System Table in bytes
/// </summary>
public uint FstSize { get; set; }
/// <summary>
/// Remaining bytes to complete the 0x440 header
/// </summary>
public byte[] Padding42C { get; set; } = [];
}
}

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Data.Models.NintendoDisc
{
public class FileSystemTable
{
/// <summary>
/// 8 bytes of unknown data
/// </summary>
/// <remarks>
/// Maps to <see cref="FileSystemTableEntry.NameOffset"/> and
/// <see cref="FileSystemTableEntry.FileOffset"/> but is unused?
/// </remarks>
public byte[] Unknown { get; set; } = new byte[8];
/// <summary>
/// Number of entries in the table
/// </summary>
/// <remarks>Big-endian</remarks>
public uint EntryCount { get; set; }
/// <summary>
/// File system table entries
/// </summary>
/// <remarks>Length given by <see cref="EntryCount"/></remarks>
public FileSystemTableEntry[] Entries { get; set; } = [];
}
}

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Data.Models.NintendoDisc
{
/// <summary>
/// File entry with start and end byte offsets on disc
/// </summary>
public class FileSystemTableEntry
{
/// <summary>
/// Offset to the entry name
/// </summary>
/// <remarks>Big-endian, has high byte set to 0xFF if a directory entry</remarks>
public uint NameOffset { get; set; }
/// <summary>
/// Offset to the start of the file
/// </summary>
/// <remarks>Big-endian</remarks>
public uint FileOffset { get; set; }
/// <summary>
/// File size
/// </summary>
/// <remarks>Big-endian</remarks>
public uint FileSize { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
namespace SabreTools.Data.Models.NintendoDisc
{
public class WiiPartitionGroup
{
/// <summary>
/// Number of entries in the group
/// </summary>
/// <remarks>Big-endian</remarks>
public uint Count { get; set; }
/// <summary>
/// Offset to the start of the table
/// </summary>
/// <remarks>Big-endian, requires left bit shift of 2 to get the real value</remarks>
public uint Offset { get; set; }
/// <summary>
/// Entries for the group, stored at <see cref="Offset"/>
/// </summary>
/// <remarks>Number of entries determined by <see cref="Count"/></remarks>
public WiiPartitionTableEntry[] Entries { get; set; } = [];
}
}

View File

@@ -2,15 +2,15 @@ namespace SabreTools.Data.Models.NintendoDisc
{
/// <summary>
/// A single entry in the Wii disc partition table.
/// The table lives at 0x400000x4FFFF on the disc.
/// The table lives at 0x40000-0x4FFFF on the disc.
/// </summary>
/// <see href="https://wiibrew.org/wiki/Wii_disc#Partition_table"/>
public sealed class WiiPartitionTableEntry
{
/// <summary>
/// Absolute byte offset of the partition on the disc.
/// Stored on-disc as <c>offset &gt;&gt; 2</c> (big-endian u32).
/// Absolute byte offset of the partition on the disc
/// </summary>
/// <remarks>Big-endian, requires left bit shift of 2 to get the real value</remarks>
public long Offset { get; set; }
/// <summary>

View File

@@ -6,7 +6,7 @@ namespace SabreTools.Data.Models.OLE
/// VT_STORAGE (0x0043), VT_STREAMED_OBJECT (0x0044), VT_STORED_OBJECT (0x0044), and
/// VT_VERSIONED_STREAM (0x0049). It MUST be represented as a CodePageString, and its value MUST
/// be derived from the property identifier of the property represented according to the following
/// Augmented BackusNaur Form (ABNF) [RFC4234] syntax.
/// Augmented Backus-Naur Form (ABNF) [RFC4234] syntax.
///
/// Indirectproperty = "prop" propertyIdentifier
///

View File

@@ -6,16 +6,28 @@ namespace SabreTools.Data.Models.WIA
/// </summary>
public sealed class PartitionDataEntry
{
/// <summary>Zero-based index of the first sector covered by this range</summary>
/// <summary>
/// Zero-based index of the first sector covered by this range
/// </summary>
/// <remarks>Big-endian</remarks>
public uint FirstSector { get; set; }
/// <summary>Number of sectors covered by this range</summary>
/// <summary>
/// Number of sectors covered by this range
/// </summary>
/// <remarks>Big-endian</remarks>
public uint NumberOfSectors { get; set; }
/// <summary>Index into the group-entry array of the first group for this range</summary>
/// <summary>
/// Index into the group-entry array of the first group for this range
/// </summary>
/// <remarks>Big-endian</remarks>
public uint GroupIndex { get; set; }
/// <summary>Number of groups covering this range</summary>
/// <summary>
/// Number of groups covering this range
/// </summary>
/// <remarks>Big-endian</remarks>
public uint NumberOfGroups { get; set; }
}
}

View File

@@ -12,10 +12,14 @@ namespace SabreTools.Data.Models.WIA
/// <remarks>16 bytes</remarks>
public byte[] PartitionKey { get; set; } = new byte[16];
/// <summary>First sector range for this partition (typically encrypted data)</summary>
/// <summary>
/// First sector range for this partition (typically encrypted data)
/// </summary>
public PartitionDataEntry DataEntry0 { get; set; } = new();
/// <summary>Second sector range for this partition (typically decrypted/raw data)</summary>
/// <summary>
/// Second sector range for this partition (typically decrypted/raw data)
/// </summary>
public PartitionDataEntry DataEntry1 { get; set; } = new();
}
}

View File

@@ -6,16 +6,28 @@ namespace SabreTools.Data.Models.WIA
/// </summary>
public sealed class RawDataEntry
{
/// <summary>Byte offset of this region within the equivalent ISO image</summary>
/// <summary>
/// Byte offset of this region within the equivalent ISO image
/// </summary>
/// <remarks>Big-endian</remarks>
public ulong DataOffset { get; set; }
/// <summary>Size of this region in bytes</summary>
/// <summary>
/// Size of this region in bytes
/// </summary>
/// <remarks>Big-endian</remarks>
public ulong DataSize { get; set; }
/// <summary>Index into the group-entry array of the first group for this region</summary>
/// <summary>
/// Index into the group-entry array of the first group for this region
/// </summary>
/// <remarks>Big-endian</remarks>
public uint GroupIndex { get; set; }
/// <summary>Number of groups covering this region</summary>
/// <summary>
/// Number of groups covering this region
/// </summary>
/// <remarks>Big-endian</remarks>
public uint NumberOfGroups { get; set; }
}
}

View File

@@ -8,19 +8,22 @@ namespace SabreTools.Data.Models.WIA
{
/// <summary>
/// Actual byte offset of this group's data within the RVZ file.
/// (On disk this value is stored as <c>offset &gt;&gt; 2</c>.)
/// (On disk this value is stored as offset &gt;&gt; 2.)
/// </summary>
public ulong DataOffset { get; set; }
/// <remarks>Big-endian</remarks>
public uint DataOffset { get; set; }
/// <summary>
/// Total size of this group's data (compressed + any RVZ-pack section) in bytes
/// </summary>
/// <remarks>Big-endian</remarks>
public uint DataSize { get; set; }
/// <summary>
/// Size of the RVZ-packed (junk-stripped) portion within this group's data.
/// 0 means no RVZ packing was applied.
/// </summary>
/// <remarks>Big-endian</remarks>
public uint RvzPackedSize { get; set; }
}
}

View File

@@ -8,13 +8,14 @@ namespace SabreTools.Data.Models.WIA
{
/// <summary>
/// Actual byte offset of this group's data within the WIA file.
/// (On disk this value is stored as <c>offset &gt;&gt; 2</c>.)
/// </summary>
public ulong DataOffset { get; set; }
/// <remarks>Big-endian, requires left bit shift of 2 to get the real value</remarks>
public uint DataOffset { get; set; }
/// <summary>
/// Compressed size of this group's data in bytes (0 means group contains only zeroes)
/// </summary>
/// <remarks>Big-endian</remarks>
public uint DataSize { get; set; }
}
}

View File

@@ -15,16 +15,19 @@ namespace SabreTools.Data.Models.WIA
/// <summary>
/// Format version (e.g. 0x01000000)
/// </summary>
/// <remarks>Big-endian</remarks>
public uint Version { get; set; }
/// <summary>
/// Minimum version required to read this file
/// </summary>
/// <remarks>Big-endian</remarks>
public uint VersionCompatible { get; set; }
/// <summary>
/// Size of WiaHeader2 in bytes
/// </summary>
/// <remarks>Big-endian</remarks>
public uint Header2Size { get; set; }
/// <summary>
@@ -36,11 +39,13 @@ namespace SabreTools.Data.Models.WIA
/// <summary>
/// Total size of the equivalent uncompressed ISO image in bytes
/// </summary>
/// <remarks>Big-endian</remarks>
public ulong IsoFileSize { get; set; }
/// <summary>
/// Total size of this WIA / RVZ file in bytes
/// </summary>
/// <remarks>Big-endian</remarks>
public ulong WiaFileSize { get; set; }
/// <summary>

View File

@@ -10,22 +10,26 @@ namespace SabreTools.Data.Models.WIA
/// <summary>
/// Disc type: 1 = GameCube, 2 = Wii
/// </summary>
/// <remarks>Big-endian</remarks>
public WiaDiscType DiscType { get; set; }
/// <summary>
/// Compression algorithm applied to group data
/// </summary>
/// <remarks>Big-endian</remarks>
public WiaRvzCompressionType CompressionType { get; set; }
/// <summary>
/// Informational compression level used when writing (19)
/// Informational compression level used when writing (1-9)
/// </summary>
/// <remarks>Big-endian</remarks>
public int CompressionLevel { get; set; }
/// <summary>
/// Group / chunk size in bytes.
/// WIA requires exactly 2 MiB; RVZ accepts powers of 2 between 32 KiB and 2 MiB.
/// </summary>
/// <remarks>Big-endian</remarks>
public uint ChunkSize { get; set; }
/// <summary>
@@ -37,16 +41,19 @@ namespace SabreTools.Data.Models.WIA
/// <summary>
/// Number of PartitionEntry structures that follow the raw-data entries
/// </summary>
/// <remarks>Big-endian</remarks>
public uint NumberOfPartitionEntries { get; set; }
/// <summary>
/// Size of each PartitionEntry in bytes
/// </summary>
/// <remarks>Big-endian</remarks>
public uint PartitionEntrySize { get; set; }
/// <summary>
/// File offset of the PartitionEntry array
/// </summary>
/// <remarks>Big-endian</remarks>
public ulong PartitionEntriesOffset { get; set; }
/// <summary>
@@ -58,31 +65,37 @@ namespace SabreTools.Data.Models.WIA
/// <summary>
/// Number of RawDataEntry structures
/// </summary>
/// <remarks>Big-endian</remarks>
public uint NumberOfRawDataEntries { get; set; }
/// <summary>
/// File offset of the RawDataEntry array
/// </summary>
/// <remarks>Big-endian</remarks>
public ulong RawDataEntriesOffset { get; set; }
/// <summary>
/// Total size in bytes of all RawDataEntry structures
/// </summary>
/// <remarks>Big-endian</remarks>
public uint RawDataEntriesSize { get; set; }
/// <summary>
/// Number of group entries (WiaGroupEntry or RvzGroupEntry)
/// </summary>
/// <remarks>Big-endian</remarks>
public uint NumberOfGroupEntries { get; set; }
/// <summary>
/// File offset of the group-entry array
/// </summary>
/// <remarks>Big-endian</remarks>
public ulong GroupEntriesOffset { get; set; }
/// <summary>
/// Total size in bytes of all group entries
/// </summary>
/// <remarks>Big-endian</remarks>
public uint GroupEntriesSize { get; set; }
/// <summary>