NdsForge.NET 1.0.1
Read, validate, edit, compare, and build Nintendo DS and DSi images from .NET
Loading...
Searching...
No Matches
NdsImageBuildOptions.cs
1namespace NdsForge;
2
4public sealed record NdsImageBuildOptions
5{
7 public static NdsImageBuildOptions Default { get; } = new();
8
10 public NdsImageBuildProfile Profile { get; init; }
11
13 public int HeaderSize { get; init; } = 0x4000;
14
16 public int SectionAlignment { get; init; } = 0x200;
17
19 public int FileAlignment { get; init; } = 4;
20
22 public byte PaddingByte { get; init; } = 0xFF;
23
25 public bool VerifyOutput { get; init; } = true;
26
28 public bool OverwriteDestination { get; init; }
29
32 internal void Validate()
33 {
34 if (HeaderSize < 0x4000 || !IsPowerOfTwo(SectionAlignment) || !IsPowerOfTwo(FileAlignment))
35 {
36 throw new ArgumentException(
37 "The header must be at least 0x4000 bytes and all alignments must be positive powers of two.");
38 }
39 }
40
44 private static bool IsPowerOfTwo(int value) => value > 0 && (value & (value - 1)) == 0;
45}
Controls deterministic physical placement without mixing Layout policy into image metadata.
int FileAlignment
Aligns individual FAT payload starts; four bytes avoids unnecessary growth while retaining word align...
byte PaddingByte
Fills every Layout gap after the reserved header area, making otherwise unspecified bytes reproducibl...
NdsImageBuildProfile Profile
Selects NdsForge defaults or a precisely versioned external-tool Layout contract.
static NdsImageBuildOptions Default
Uses a 16 KiB header area, 512-byte component boundaries, four-byte file boundaries,...
int HeaderSize
Reserves bytes before the first Program; DS homebrew conventionally uses 0x4000.
int SectionAlignment
Aligns Programs, filesystem tables, and Banner starts; it must be a positive power of two.
bool OverwriteDestination
Allows a successful path build to atomically replace an existing regular destination file.
bool VerifyOutput
Reopens the completed stream and validates its structure, checksums, and NitroFS payload mapping.
NdsImageBuildProfile
Selects a documented Layout personality without contaminating the logical Build Recipe.