mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-22 06:45:11 +00:00
First round of cleanup for DolphinLib additions
This commit is contained in:
@@ -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):
|
||||
// 0x000–0x003 Title code (4 chars, e.g. "GAFE")
|
||||
// 0x004–0x005 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
|
||||
// 0x00A–0x017 Unused (14 bytes)
|
||||
// 0x018 Wii magic (0x5D1C9EA3)
|
||||
// 0x01C GC magic (0xC2339F3D)
|
||||
// 0x020–0x07F 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;
|
||||
|
||||
|
||||
64
SabreTools.Data.Models/NintendoDisc/DOLHeader.cs
Normal file
64
SabreTools.Data.Models/NintendoDisc/DOLHeader.cs
Normal 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];
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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 0x004–0x005; 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; <<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; } = [];
|
||||
}
|
||||
}
|
||||
|
||||
26
SabreTools.Data.Models/NintendoDisc/FileSystemTable.cs
Normal file
26
SabreTools.Data.Models/NintendoDisc/FileSystemTable.cs
Normal 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; } = [];
|
||||
}
|
||||
}
|
||||
26
SabreTools.Data.Models/NintendoDisc/FileSystemTableEntry.cs
Normal file
26
SabreTools.Data.Models/NintendoDisc/FileSystemTableEntry.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
23
SabreTools.Data.Models/NintendoDisc/WiiPartitionGroup.cs
Normal file
23
SabreTools.Data.Models/NintendoDisc/WiiPartitionGroup.cs
Normal 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; } = [];
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,15 @@ namespace SabreTools.Data.Models.NintendoDisc
|
||||
{
|
||||
/// <summary>
|
||||
/// A single entry in the Wii disc partition table.
|
||||
/// The table lives at 0x40000–0x4FFFF 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 >> 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>
|
||||
|
||||
Reference in New Issue
Block a user