NdsForge.NET 1.0.1
Read, validate, edit, compare, and build Nintendo DS and DSi images from .NET
Loading...
Searching...
No Matches
NdsOverlayDefinition.cs
1namespace NdsForge;
2
8public sealed class NdsOverlayDefinition
9{
22 NdsProcessor processor,
23 uint id,
24 ReadOnlySpan<byte> contents,
25 uint loadAddress,
26 uint ramSize,
27 uint bssSize = 0,
28 uint staticInitializerStart = 0,
29 uint staticInitializerEnd = 0,
30 uint compressedSize = 0,
31 byte flags = 0)
32 : this(
33 processor,
34 id,
35 contents.ToArray(),
36 linkedFilePath: null,
37 linkedFile: null,
38 loadAddress,
39 ramSize,
40 bssSize,
41 staticInitializerStart,
42 staticInitializerEnd,
43 compressedSize,
44 flags)
45 {
46 }
47
61 NdsProcessor processor,
62 uint id,
63 string filePath,
64 uint loadAddress,
65 uint ramSize,
66 uint bssSize = 0,
67 uint staticInitializerStart = 0,
68 uint staticInitializerEnd = 0,
69 uint compressedSize = 0,
70 byte flags = 0) => new(
71 processor,
72 id,
73 contents: null,
74 NdsFileSystemBuilder.NormalizePath(filePath, allowRoot: false),
75 linkedFile: null,
76 loadAddress,
77 ramSize,
78 bssSize,
79 staticInitializerStart,
80 staticInitializerEnd,
81 compressedSize,
82 flags);
83
97 NdsProcessor processor,
98 uint id,
99 NdsBuildFile file,
100 uint loadAddress,
101 uint ramSize,
102 uint bssSize = 0,
103 uint staticInitializerStart = 0,
104 uint staticInitializerEnd = 0,
105 uint compressedSize = 0,
106 byte flags = 0) => new(
107 processor,
108 id,
109 contents: null,
110 linkedFilePath: null,
111 file ?? throw new ArgumentNullException(nameof(file)),
112 loadAddress,
113 ramSize,
114 bssSize,
115 staticInitializerStart,
116 staticInitializerEnd,
117 compressedSize,
118 flags);
119
133 private NdsOverlayDefinition(
134 NdsProcessor processor,
135 uint id,
136 byte[]? contents,
137 string? linkedFilePath,
138 NdsBuildFile? linkedFile,
139 uint loadAddress,
140 uint ramSize,
141 uint bssSize,
142 uint staticInitializerStart,
143 uint staticInitializerEnd,
144 uint compressedSize,
145 byte flags)
146 {
147 if (processor is not NdsProcessor.Arm9 and not NdsProcessor.Arm7)
148 {
149 throw new ArgumentOutOfRangeException(nameof(processor), "DS overlay tables belong to ARM9 or ARM7.");
150 }
151
152 if (staticInitializerEnd < staticInitializerStart || compressedSize > 0x00FF_FFFF)
153 {
154 throw new ArgumentException("Overlay initializer bounds or compressed size are invalid.");
155 }
156
157 Processor = processor;
158 Id = id;
159 Contents = contents ?? [];
160 LinkedFilePath = linkedFilePath;
161 LinkedFile = linkedFile;
162 LoadAddress = loadAddress;
163 RamSize = ramSize;
164 BssSize = bssSize;
165 StaticInitializerStart = staticInitializerStart;
166 StaticInitializerEnd = staticInitializerEnd;
167 CompressedSize = compressedSize;
168 Flags = flags;
169 }
170
172 public NdsProcessor Processor { get; }
173
175 public uint Id { get; }
176
178 public ReadOnlyMemory<byte> Contents { get; }
179
181 public string? LinkedFilePath { get; }
182
184 internal NdsBuildFile? LinkedFile { get; }
185
187 internal string? EffectiveLinkedFilePath => LinkedFile?.Path ?? LinkedFilePath;
188
190 internal bool HasPrivateAllocation => EffectiveLinkedFilePath is null;
191
193 public uint LoadAddress { get; }
194
196 public uint RamSize { get; }
197
199 public uint BssSize { get; }
200
202 public uint StaticInitializerStart { get; }
203
205 public uint StaticInitializerEnd { get; }
206
208 public uint CompressedSize { get; }
209
211 public byte Flags { get; }
212}
Holds one NitroFS payload while an image is being assembled, independently of any source ROM.
string Path
Identifies the file in NitroFS using a leading slash and one-byte path segments; Latin-1 code points ...
Models structural NitroFS changes before ROM offsets and file identifiers are assigned.
uint RamSize
Declares initialized runtime bytes after optional decompression.
uint StaticInitializerEnd
Marks the exclusive end of the runtime constructor pointer list.
static NdsOverlayDefinition LinkToFile(NdsProcessor processor, uint id, string filePath, uint loadAddress, uint ramSize, uint bssSize=0, uint staticInitializerStart=0, uint staticInitializerEnd=0, uint compressedSize=0, byte flags=0)
Links an Overlay record to a named NitroFS payload so both identities share one FAT Allocation.
NdsOverlayDefinition(NdsProcessor processor, uint id, ReadOnlySpan< byte > contents, uint loadAddress, uint ramSize, uint bssSize=0, uint staticInitializerStart=0, uint staticInitializerEnd=0, uint compressedSize=0, byte flags=0)
Copies an Overlay payload and captures every field required by its fixed 32-byte table record.
string? LinkedFilePath
Identifies a shared named NitroFS payload, or remains null for a private Allocation.
uint BssSize
Declares zero-filled runtime bytes that do not occupy cartridge storage.
static NdsOverlayDefinition LinkToFile(NdsProcessor processor, uint id, NdsBuildFile file, uint loadAddress, uint ramSize, uint bssSize=0, uint staticInitializerStart=0, uint staticInitializerEnd=0, uint compressedSize=0, byte flags=0)
Links to a builder-owned file object so directory or file moves automatically retain the Overlay rela...
byte Flags
Occupies the high byte of the packed table control word without reinterpretation.
uint Id
Identifies the Overlay to runtime code without determining its FAT File ID.
ReadOnlyMemory< byte > Contents
Contains definition-owned stored bytes for a private Allocation, or empty memory for a named-file lin...
uint StaticInitializerStart
Marks the inclusive start of the runtime constructor pointer list.
uint CompressedSize
Occupies the low 24 bits of the packed table control word.
NdsProcessor Processor
Selects the independent ARM9 or ARM7 Overlay table and execution environment.
uint LoadAddress
Specifies the first runtime address receiving initialized Overlay bytes.
NdsProcessor
Identifies a processor and execution mode.