NdsForge.NET 1.0.1
Read, validate, edit, compare, and build Nintendo DS and DSi images from .NET
Loading...
Searching...
No Matches
NdsOverlay.cs
1namespace NdsForge;
2
4public sealed class NdsOverlay
5{
10 internal NdsOverlay(NdsProcessor processor, ReadOnlySpan<byte> data, NdsFileSystem fileSystem)
11 {
12 Processor = processor;
13 Id = NdsBinary.ReadUInt32(data, 0x00);
14 LoadAddress = NdsBinary.ReadUInt32(data, 0x04);
15 RamSize = NdsBinary.ReadUInt32(data, 0x08);
16 BssSize = NdsBinary.ReadUInt32(data, 0x0C);
17 StaticInitializerStart = NdsBinary.ReadUInt32(data, 0x10);
18 StaticInitializerEnd = NdsBinary.ReadUInt32(data, 0x14);
19 FileId = NdsBinary.ReadUInt32(data, 0x18);
20 uint flagsAndSize = NdsBinary.ReadUInt32(data, 0x1C);
21 CompressedSize = flagsAndSize & 0x00FF_FFFF;
22 Flags = (byte)(flagsAndSize >> 24);
23
24 if (FileId < fileSystem.Allocations.Count)
25 {
26 Data = fileSystem.Allocations[checked((int)FileId)].Data;
27 fileSystem.TryGetFile(checked((int)FileId), out NdsFile? namedFile);
28 File = namedFile;
29 }
30 }
31
33 public NdsProcessor Processor { get; }
34
36 public uint Id { get; }
37
39 public uint LoadAddress { get; }
40
42 public uint RamSize { get; }
43
45 public uint BssSize { get; }
46
48 public uint StaticInitializerStart { get; }
49
51 public uint StaticInitializerEnd { get; }
52
54 public uint FileId { get; }
55
57 public uint CompressedSize { get; }
58
60 public byte Flags { get; }
61
63 public NdsRegion? Data { get; }
64
66 public NdsFile? File { get; }
67}
Provides tree, path, and file-ID access to an image's NitroFS.
bool TryGetFile(string path, [NotNullWhen(true)] out NdsFile? file)
Attempts to find a named file by canonical or root-relative path.
IReadOnlyList< NdsFileAllocation > Allocations
Gets every FAT allocation, including unnamed overlay payloads.
Connects a byte-preserving FNT path and stable FAT identifier to lazily read cartridge bytes.
Definition NdsFile.cs:5
uint BssSize
Reserves additional zero-filled runtime memory that is absent from the cartridge payload.
Definition NdsOverlay.cs:45
uint StaticInitializerStart
Marks the inclusive start of the runtime constructor pointer list for this overlay.
Definition NdsOverlay.cs:48
uint FileId
Gets the referenced FAT file ID, which is independent of Id.
Definition NdsOverlay.cs:54
uint LoadAddress
Specifies the ARM memory address at which the overlay loader places initialized payload bytes.
Definition NdsOverlay.cs:39
uint CompressedSize
Decodes the low 24 bits of the packed control word; zero commonly indicates an uncompressed payload.
Definition NdsOverlay.cs:57
NdsProcessor Processor
Distinguishes the independent ARM9 and ARM7 overlay namespaces and load environments.
Definition NdsOverlay.cs:33
byte Flags
Preserves the packed control word's high byte, including compression and authentication-related bits.
Definition NdsOverlay.cs:60
NdsRegion? Data
Gets the resolved payload region, or null for an invalid file ID.
Definition NdsOverlay.cs:63
uint Id
Identifies runtime overlay metadata and is not required to equal the payload's FileId.
Definition NdsOverlay.cs:36
uint RamSize
Declares initialized runtime bytes after decompression, so it may exceed the stored payload length.
Definition NdsOverlay.cs:42
NdsFile? File
Links to a navigable FNT entry only when the FAT payload is also named; valid overlays may remain unn...
Definition NdsOverlay.cs:66
uint StaticInitializerEnd
Marks the exclusive end of the constructor pointer list and should not precede its start.
Definition NdsOverlay.cs:51
Identifies a bounded range of bytes in an image.
Definition NdsRegion.cs:11
NdsProcessor
Identifies a processor and execution mode.