Files
SabreTools.Models/Nitro/CommonHeader.cs

232 lines
5.9 KiB
C#
Raw Permalink Normal View History

2024-04-23 17:15:15 -04:00
using System.Runtime.InteropServices;
2023-09-04 00:12:49 -04:00
namespace SabreTools.Models.Nitro
2023-09-04 00:11:04 -04:00
{
/// <summary>
/// Nintendo DS / DSi cartridge header
/// </summary>
/// <see href="https://dsibrew.org/wiki/DSi_cartridge_header"/>
2024-04-23 17:15:15 -04:00
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
2023-09-04 00:11:04 -04:00
public sealed class CommonHeader
{
/// <summary>
/// Game Title
/// </summary>
2024-04-23 17:15:15 -04:00
/// <remarks>12 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)]
public string? GameTitle;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Gamecode
/// </summary>
2024-04-23 17:15:15 -04:00
public uint GameCode;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Makercode
/// </summary>
2024-04-23 17:15:15 -04:00
/// <remarks>2 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]
public string? MakerCode;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Unitcode
/// </summary>
2024-04-23 17:15:15 -04:00
[MarshalAs(UnmanagedType.U1)]
public Unitcode UnitCode;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Encryption seed select (device code. 0 = normal)
/// </summary>
2024-04-23 17:15:15 -04:00
public byte EncryptionSeedSelect;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Devicecapacity
/// </summary>
2024-04-23 17:15:15 -04:00
public byte DeviceCapacity;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Reserved
/// </summary>
2024-04-23 17:15:15 -04:00
/// <remarks>7 bytes</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
public byte[]? Reserved1;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Game Revision (used by DSi titles)
/// </summary>
2024-04-23 17:15:15 -04:00
public ushort GameRevision;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ROM Version
/// </summary>
2024-04-23 17:15:15 -04:00
public byte RomVersion;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Internal flags, (Bit2: Autostart)
/// </summary>
2024-04-23 17:15:15 -04:00
public byte InternalFlags;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM9 rom offset
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM9RomOffset;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM9 entry address
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM9EntryAddress;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM9 load address
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM9LoadAddress;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM9 size
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM9Size;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM7 rom offset
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM7RomOffset;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM7 entry address
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM7EntryAddress;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM7 load address
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM7LoadAddress;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM7 size
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM7Size;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Name Table (FNT) offset
/// </summary>
2024-04-23 17:15:15 -04:00
public uint FileNameTableOffset;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Name Table (FNT) length
/// </summary>
2024-04-23 17:15:15 -04:00
public uint FileNameTableLength;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Allocation Table (FNT) offset
/// </summary>
2024-04-23 17:15:15 -04:00
public uint FileAllocationTableOffset;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Allocation Table (FNT) length
/// </summary>
2024-04-23 17:15:15 -04:00
public uint FileAllocationTableLength;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Name Table (FNT) offset
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM9OverlayOffset;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Name Table (FNT) length
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM9OverlayLength;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Name Table (FNT) offset
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM7OverlayOffset;
2023-09-04 00:11:04 -04:00
/// <summary>
/// File Name Table (FNT) length
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM7OverlayLength;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Normal card control register settings (0x00416657 for OneTimePROM)
/// </summary>
2024-04-23 17:15:15 -04:00
public uint NormalCardControlRegisterSettings;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Secure card control register settings (0x081808F8 for OneTimePROM)
/// </summary>
2024-04-23 17:15:15 -04:00
public uint SecureCardControlRegisterSettings;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Icon Banner offset (NDSi same as NDS, but with new extra entries)
/// </summary>
2024-04-23 17:15:15 -04:00
public uint IconBannerOffset;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Secure area (2K) CRC
/// </summary>
2024-04-23 17:15:15 -04:00
public ushort SecureAreaCRC;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Secure transfer timeout (0x0D7E for OneTimePROM)
/// </summary>
2024-04-23 17:15:15 -04:00
public ushort SecureTransferTimeout;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM9 autoload
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM9Autoload;
2023-09-04 00:11:04 -04:00
/// <summary>
/// ARM7 autoload
/// </summary>
2024-04-23 17:15:15 -04:00
public uint ARM7Autoload;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Secure disable
/// </summary>
2024-04-23 17:15:15 -04:00
/// <remarks>8 bytes</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[]? SecureDisable;
2023-09-04 00:11:04 -04:00
/// <summary>
/// NTR region ROM size (excluding DSi area)
/// </summary>
2024-04-23 17:15:15 -04:00
public uint NTRRegionRomSize;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Header size
/// </summary>
2024-04-23 17:15:15 -04:00
public uint HeaderSize;
2023-09-04 00:11:04 -04:00
/// <summary>
2024-04-23 17:15:15 -04:00
/// Reserved (0x88, 0x8C, 0x90 = Unknown, used by DSi)
2023-09-04 00:11:04 -04:00
/// </summary>
2024-04-23 17:15:15 -04:00
/// <remarks>56 bytes</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 56)]
public byte[]? Reserved2;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Nintendo Logo
/// </summary>
2024-04-23 17:15:15 -04:00
/// <remarks>156 bytes</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 156)]
public byte[]? NintendoLogo;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Nintendo Logo CRC
/// </summary>
2024-04-23 17:15:15 -04:00
public ushort NintendoLogoCRC;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Header CRC
/// </summary>
2024-04-23 17:15:15 -04:00
public ushort HeaderCRC;
2023-09-04 00:11:04 -04:00
/// <summary>
/// Debugger reserved
/// </summary>
2024-04-23 17:15:15 -04:00
/// <remarks>0x20 bytes</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
public byte[]? DebuggerReserved;
2023-09-04 00:11:04 -04:00
}
}