16 private byte[]? _nintendoLogo;
19 private readonly List<NdsOverlayDefinition> _arm9Overlays = [];
22 private readonly List<NdsOverlayDefinition> _arm7Overlays = [];
34 public string Title {
get;
set; } =
string.Empty;
97 public IReadOnlyList<NdsOverlayDefinition>
Arm9Overlays => _arm9Overlays;
100 public IReadOnlyList<NdsOverlayDefinition>
Arm7Overlays => _arm7Overlays;
107 ArgumentNullException.ThrowIfNull(overlay);
108 (overlay.Processor ==
NdsProcessor.Arm9 ? _arm9Overlays : _arm7Overlays).Add(overlay);
122 CancellationToken cancellationToken =
default) =>
123 NdsImageBuildImporter.ImportAsync(image, cancellationToken);
131 if (data.Length != 156)
133 throw new ArgumentException(
"The encoded Nintendo DS logo must contain exactly 156 bytes.", nameof(data));
136 _nintendoLogo = data.ToArray();
148 CancellationToken cancellationToken =
default) =>
159 CancellationToken cancellationToken =
default)
161 ArgumentException.ThrowIfNullOrWhiteSpace(path);
164 string output = Path.GetFullPath(path);
165 string? directory = Path.GetDirectoryName(output);
166 if (!
string.IsNullOrEmpty(directory))
168 Directory.CreateDirectory(directory);
171 if (File.Exists(output) && !options.OverwriteDestination)
173 throw new IOException($
"Destination already exists: {output}");
176 string temporary = output +
".ndsforge-" + Guid.NewGuid().ToString(
"N");
180 var stream =
new FileStream(
183 FileAccess.ReadWrite,
186 FileOptions.Asynchronous | FileOptions.SequentialScan);
187 await
using (stream.ConfigureAwait(
false))
189 result = await
WriteAsync(stream, options, cancellationToken).ConfigureAwait(
false);
192 File.Move(temporary, output, options.OverwriteDestination);
197 File.Delete(temporary);
207 CancellationToken cancellationToken =
default)
209 using var stream =
new MemoryStream();
210 await
WriteAsync(stream, options, cancellationToken).ConfigureAwait(
false);
211 return stream.ToArray();
215 internal ReadOnlyMemory<byte> NintendoLogo => _nintendoLogo;
Represents a versioned menu icon, localized titles, and optional DSi animation.
Models structural NitroFS changes before ROM offsets and file identifiers are assigned.
Controls deterministic physical placement without mixing Layout policy into image metadata.
static NdsImageBuildOptions Default
Uses a 16 KiB header area, 512-byte component boundaries, four-byte file boundaries,...
Reports the concrete Layout identities assigned while committing a Build Recipe.
static ValueTask< NdsImageBuilder > FromImageAsync(NdsImage image, CancellationToken cancellationToken=default)
Copies a parsed DS or DSi Image into a detached Build Recipe suitable for structural filesystem chang...
NdsProgramDefinition? Arm9
Supplies the required primary processor payload and its runtime addresses.
uint NormalCardControl
Preserves ROM-control timing and flags used for ordinary cartridge transfers.
string Title
Controls the padded 12-byte printable-ASCII label written at the beginning of the header.
uint Arm7AutoLoad
Preserves the ARM7 SDK autoload-list address used during runtime initialization.
IReadOnlyList< NdsOverlayDefinition > Arm7Overlays
Exposes ARM7 Overlay definitions in the exact order used by the generated table.
string MakerCode
Controls the exact two-character printable-ASCII publisher identifier.
byte AutoStart
Controls the complete boot-policy byte at header offset 0x1F.
ValueTask< NdsImageBuildResult > WriteAsync(Stream destination, NdsImageBuildOptions? options=null, CancellationToken cancellationToken=default)
Writes the complete recipe to a caller-owned random-access stream and optionally verifies it by reope...
NdsImageKind Kind
Selects DS, DSi-enhanced, or DSi-exclusive header and execution semantics for the complete recipe.
ushort SecureTransferTimeout
Preserves the timeout applied to secure-area transfers.
uint Arm9AutoLoad
Preserves the ARM9 SDK autoload-list address used during runtime initialization.
NdsImageBuilder AddOverlay(NdsOverlayDefinition overlay)
Adds an Overlay whose private Allocation receives a File ID after all named NitroFS files.
NdsFileSystemBuilder FileSystem
Provides structural NitroFS operations whose stable snapshot becomes the generated FNT and FAT.
string GameCode
Controls the exact four-character printable-ASCII product code required by the cartridge header.
byte RegionCode
Controls the hardware-dependent region byte without interpreting reserved bits.
byte Version
Controls the publisher-defined software revision byte, independently from format versions.
uint SecureCardControl
Preserves ROM-control timing and flags used during secure cartridge transfers.
async ValueTask< NdsImageBuildResult > WriteAsync(string path, NdsImageBuildOptions? options=null, CancellationToken cancellationToken=default)
Builds beside a host destination and moves the verified temporary image into place only after success...
NdsProgramDefinition? Arm7i
Supplies the required ARM7i payload for a DSi recipe; its single header address serves as load and en...
ulong SecureDisable
Preserves the raw 64-bit secure-area disable token across structural rebuilds.
NdsProgramDefinition? Arm9i
Supplies the required ARM9i payload for a DSi recipe; its single header address serves as load and en...
NdsBanner? Banner
Supplies optional pre-checksummed menu metadata; static and animated supported versions remain lossle...
NdsImageBuilder SetNintendoLogo(ReadOnlySpan< byte > data)
Copies the 156-byte encoded cartridge logo block without embedding or sourcing proprietary assets.
NdsDsiBuildMetadata? DsiMetadata
Supplies DSi service, title, storage, memory-bank, modcrypt, and integrity policy....
NdsProgramDefinition? Arm7
Supplies the required secondary processor payload and its runtime addresses.
IReadOnlyList< NdsOverlayDefinition > Arm9Overlays
Exposes ARM9 Overlay definitions in the exact order used by the generated table.
byte EncryptionSeedSelect
Preserves the raw cartridge encryption seed-selection byte used by secure-area protocols.
NdsImageBuilder()
Establishes deterministic identity defaults and an explicit empty NitroFS root for a new Image.
async ValueTask< byte[]> BuildAsync(NdsImageBuildOptions? options=null, CancellationToken cancellationToken=default)
Materializes a complete deterministic image for tests, small tools, or APIs that require one contiguo...
Provides structured, random-access inspection of a Nintendo DS-family image.
Describes one Overlay record and its private Allocation when constructing a new Image.
Supplies one executable payload and the CPU addresses required to place it in a newly built image.
@ Arm9
The ARM9 program used in Nintendo DS mode.
NdsImageKind
Identifies the hardware family targeted by an image.