mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 05:36:12 +00:00
Nitro model cleanup
This commit is contained in:
@@ -8,12 +8,12 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// <summary>
|
||||
/// DS/DSi cart header
|
||||
/// </summary>
|
||||
public CommonHeader? CommonHeader { get; set; }
|
||||
public CommonHeader CommonHeader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// DSi extended cart header
|
||||
/// </summary>
|
||||
public ExtendedDSiHeader? ExtendedDSiHeader { get; set; }
|
||||
public ExtendedDSiHeader ExtendedDSiHeader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Secure area, may be encrypted or decrypted
|
||||
@@ -24,11 +24,11 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// <summary>
|
||||
/// Name table (folder allocation table, name list)
|
||||
/// </summary>
|
||||
public NameTable? NameTable { get; set; }
|
||||
public NameTable NameTable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// File allocation table
|
||||
/// </summary>
|
||||
public FileAllocationTableEntry[]? FileAllocationTable { get; set; }
|
||||
public FileAllocationTableEntry[] FileAllocationTable { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// </summary>
|
||||
/// <remarks>12 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)]
|
||||
public string? GameTitle;
|
||||
public string GameTitle;
|
||||
|
||||
/// <summary>
|
||||
/// Gamecode
|
||||
@@ -26,7 +26,7 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// </summary>
|
||||
/// <remarks>2 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]
|
||||
public string? MakerCode;
|
||||
public string MakerCode;
|
||||
|
||||
/// <summary>
|
||||
/// Unitcode
|
||||
|
||||
@@ -365,4 +365,4 @@ namespace SabreTools.Data.Models.Nitro
|
||||
0x96,0xE7,0xC4,0x18,0x5F,0xAD,0xF5,0x19,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ namespace SabreTools.Data.Models.Nitro
|
||||
|
||||
DSi = 0x03,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,21 +14,21 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// </summary>
|
||||
/// <remarks>5 entries</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
||||
public uint[]? GlobalMBK15Settings;
|
||||
public uint[] GlobalMBK15Settings = new uint[5];
|
||||
|
||||
/// <summary>
|
||||
/// Local MBK6..MBK8 Settings for ARM9
|
||||
/// </summary>
|
||||
/// <remarks>3 entries</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public uint[]? LocalMBK68SettingsARM9;
|
||||
public uint[] LocalMBK68SettingsARM9 = new uint[3];
|
||||
|
||||
/// <summary>
|
||||
/// Local MBK6..MBK8 Settings for ARM7
|
||||
/// </summary>
|
||||
/// <remarks>3 entries</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public uint[]? LocalMBK68SettingsARM7;
|
||||
public uint[] LocalMBK68SettingsARM7 = new uint[3];
|
||||
|
||||
/// <summary>
|
||||
/// Global MBK9 Setting
|
||||
|
||||
@@ -20,4 +20,4 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// </summary>
|
||||
public uint EndOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,4 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// </summary>
|
||||
public byte Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// <summary>
|
||||
/// The variable length name (UTF-8)
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Only there if it is a folder. Refers to the the index of it
|
||||
@@ -26,4 +26,4 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// </summary>
|
||||
public ushort Index { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// The name table stores the names of the files and the structure
|
||||
/// of the file system. From the information stored, the index of the
|
||||
/// file's entry in the File Allocation Table can be found.
|
||||
///
|
||||
///
|
||||
/// It is split into two parts:
|
||||
/// - Folder Allocation Table
|
||||
/// - Name List
|
||||
@@ -15,11 +15,11 @@ namespace SabreTools.Data.Models.Nitro
|
||||
/// <summary>
|
||||
/// Folder allocation table
|
||||
/// </summary>
|
||||
public FolderAllocationTableEntry[]? FolderAllocationTable { get; set; }
|
||||
public FolderAllocationTableEntry[] FolderAllocationTable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name list
|
||||
/// </summary>
|
||||
public NameListEntry[]? NameList { get; set; }
|
||||
public NameListEntry[] NameList { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,10 +56,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <param name="tableData">Blowfish table data as a byte array</param>
|
||||
private void EncryptARM9(byte[] tableData)
|
||||
{
|
||||
// If the secure area is invalid, nothing can be done
|
||||
if (SecureArea == null)
|
||||
return;
|
||||
|
||||
// Point to the beginning of the secure area
|
||||
int readOffset = 0;
|
||||
|
||||
@@ -178,10 +174,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <param name="tableData">Blowfish table data as a byte array</param>
|
||||
private void DecryptARM9(byte[] tableData)
|
||||
{
|
||||
// If the secure area is invalid, nothing can be done
|
||||
if (SecureArea == null)
|
||||
return;
|
||||
|
||||
// Point to the beginning of the secure area
|
||||
int readOffset = 0;
|
||||
int writeOffset = 0;
|
||||
@@ -259,13 +251,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <returns>True if the file has known values for a decrypted file, null if it's empty, false otherwise</returns>
|
||||
public bool? CheckIfDecrypted(out string? message)
|
||||
{
|
||||
// Return empty if the secure area is undefined
|
||||
if (SecureArea == null)
|
||||
{
|
||||
message = "Secure area is undefined. Cannot be encrypted or decrypted.";
|
||||
return null;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
uint firstValue = SecureArea.ReadUInt32LittleEndian(ref offset);
|
||||
uint secondValue = SecureArea.ReadUInt32LittleEndian(ref offset);
|
||||
|
||||
@@ -25,17 +25,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
Print(builder, Model.FileAllocationTable);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, CommonHeader? header)
|
||||
private static void Print(StringBuilder builder, CommonHeader header)
|
||||
{
|
||||
builder.AppendLine(" Common Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No common header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.GameTitle, " Game title");
|
||||
builder.AppendLine(header.GameCode, " Game code");
|
||||
builder.AppendLine(header.MakerCode, " Maker code");
|
||||
@@ -79,17 +72,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ExtendedDSiHeader? header)
|
||||
private static void Print(StringBuilder builder, ExtendedDSiHeader header)
|
||||
{
|
||||
builder.AppendLine(" Extended DSi Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No extended DSi header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.GlobalMBK15Settings, " Global MBK1..MBK5 settings");
|
||||
builder.AppendLine(header.LocalMBK68SettingsARM9, " Local MBK6..MBK8 settings for ARM9");
|
||||
builder.AppendLine(header.LocalMBK68SettingsARM7, " Local MBK6..MBK8 settings for ARM7");
|
||||
@@ -141,7 +127,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, byte[]? secureArea)
|
||||
private static void Print(StringBuilder builder, byte[] secureArea)
|
||||
{
|
||||
builder.AppendLine(" Secure Area Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -149,27 +135,21 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, NameTable? table)
|
||||
private static void Print(StringBuilder builder, NameTable table)
|
||||
{
|
||||
builder.AppendLine(" Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null)
|
||||
{
|
||||
builder.AppendLine(" No name table");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
|
||||
Print(builder, table.FolderAllocationTable);
|
||||
Print(builder, table.NameList);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, FolderAllocationTableEntry[]? entries)
|
||||
private static void Print(StringBuilder builder, FolderAllocationTableEntry[] entries)
|
||||
{
|
||||
builder.AppendLine(" Folder Allocation Table:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
if (entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No folder allocation table entries");
|
||||
builder.AppendLine();
|
||||
@@ -198,11 +178,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, NameListEntry[]? entries)
|
||||
private static void Print(StringBuilder builder, NameListEntry[] entries)
|
||||
{
|
||||
builder.AppendLine(" Name List:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
if (entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No name list entries");
|
||||
builder.AppendLine();
|
||||
@@ -223,11 +203,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, FileAllocationTableEntry[]? entries)
|
||||
private static void Print(StringBuilder builder, FileAllocationTableEntry[] entries)
|
||||
{
|
||||
builder.AppendLine(" File Allocation Table:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
if (entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No file allocation table entries");
|
||||
builder.AppendLine();
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Extension Methods
|
||||
|
||||
/// <inheritdoc cref="Cart.CommonHeader"/>
|
||||
public CommonHeader? CommonHeader => Model.CommonHeader;
|
||||
public CommonHeader CommonHeader => Model.CommonHeader;
|
||||
|
||||
/// <inheritdoc cref="CommonHeader.GameCode"/>
|
||||
public uint GameCode => Model.CommonHeader?.GameCode ?? 0;
|
||||
public uint GameCode => Model.CommonHeader.GameCode;
|
||||
|
||||
/// <inheritdoc cref="Cart.SecureArea"/>
|
||||
public byte[] SecureArea => Model.SecureArea;
|
||||
|
||||
Reference in New Issue
Block a user