NdsRom

class NdsRom

Parses, mutates, and repacks a Nintendo DS ROM image.

NDS ROM binary layout (little-endian): 0x000 – 0x1FF header (512 bytes) arm9RomOffset ARM9 binary arm7RomOffset ARM7 binary fntOffset File Name Table fatOffset File Allocation Table (8 bytes per file: start u32, end u32) arm9OvlOffset ARM9 overlay table (32 bytes per entry) arm7OvlOffset ARM7 overlay table (32 bytes per entry) iconOffset Icon/title banner (file data at offsets recorded in FAT)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

ARM7 binary (sound/wireless co-processor code, loaded at the address given in the ROM header).

Link copied to clipboard

Raw file data for each ARM7 overlay, in overlay-table order. Index 0 corresponds to the first entry in the ARM7 overlay table.

Link copied to clipboard

Raw bytes of the ARM7 overlay table (32 bytes × N entries). Use arm7Overlays to access individual overlay data by index.

Link copied to clipboard

ARM9 binary (the main game code, loaded at the address given in the ROM header).

Link copied to clipboard

Raw file data for each ARM9 overlay, in overlay-table order. Index 0 corresponds to the first entry in the ARM9 overlay table.

Link copied to clipboard

Raw bytes of the ARM9 overlay table (32 bytes × N entries). Use arm9Overlays to access individual overlay data by index.

Link copied to clipboard

Icon/title banner block, or an empty array if the ROM carries no banner.

Link copied to clipboard

All files in the ROM filesystem, keyed by virtual path (e.g. "a/0/3/2").

Link copied to clipboard

Four-character game code read from header bytes 0x0C–0x0F (e.g. "IPKE").

Link copied to clipboard

Game title read from header bytes 0x00–0x0B, with trailing NUL characters stripped.

Link copied to clipboard

Raw 512-byte ROM header; offset fields are recalculated during pack.

Functions

Link copied to clipboard

Serialises the (possibly modified) ROM back to a byte array.

Link copied to clipboard

Returns a new NdsRom with the ARM7 binary replaced by data. The original instance is unchanged.

Link copied to clipboard
fun withArm7Overlay(index: Int, data: ByteArray): NdsRom

Returns a new NdsRom with the ARM7 overlay at index replaced by data. The original instance is unchanged.

Link copied to clipboard

Returns a new NdsRom with the ARM9 binary replaced by data. The original instance is unchanged.

Link copied to clipboard
fun withArm9Overlay(index: Int, data: ByteArray): NdsRom

Returns a new NdsRom with the ARM9 overlay at index replaced by data. The original instance is unchanged.

Link copied to clipboard
fun withFile(path: String, data: ByteArray): NdsRom

Returns a new NdsRom with the filesystem file at path replaced by data. If path does not exist in the original ROM this call has no effect on the packed output. The original instance is unchanged.

Link copied to clipboard

Returns a new NdsRom with multiple filesystem files replaced at once. Keys in updates that do not exist in the original ROM are silently ignored. The original instance is unchanged.