Introduction
A .nds file is a copy of the ROM in a game card for Nintendo’s DS, for playing in an emulator or on a flash card.
The DS has two processors, an ARM946E-S (the “ARM9”, architecture ARMv5TE) and an ARM7TDMI (the “ARM7”, ARMv4T), and a ROM image
holds a program for each, a file system of the game’s data, and a small banner for the menu. As with the Game Boy Advance there is
no wrapper around it: the file is the card’s contents, and the 512-byte header at the start says where everything is.
Structure
The header gives, for each processor, the place of its program in the file, the address in
RAM it is copied to, the address it starts at and its size. It also places the NitroFS (the file name table and the file allocation
table, see NitroFS), the two overlay tables, the banner,
and ends with the Nintendo logo, the logo checksum and the header checksum. The ARM9 program is meant to start at 0x4000 or later (a hand-made
ROM may put it earlier), and the range 0x4000–0x7FFF is the secure area, whose first 8 bytes read “encryObj” when it is
stored decrypted and are some encrypted value otherwise.
The programs address the console through its memory map.
0x000game title, game code, maker code, unit code, region, version32 bytes0x020ARM9 and ARM7: ROM offset, entry, RAM address, size32 bytes0x040file name table, file allocation table, overlay tables, card settings, banner offset44 bytes0x06Csecure area checksum and delay, auto-load hooks, total size, header size20 bytes0x0C0Nintendo logo, then the logo checksum and the header checksum160 bytes0x160debug ROM, reserved160 bytes0x200programs, tables, banner and files, wherever the header saysvaries
Not described
The header, the banner, the NitroFS and the memory map are written. What remains:
- Viewer: the explorer opens
.ndsfiles: every header field decoded, the logo, header, secure-area and banner checksums checked, the NitroFS directories and files listed (each file opens as bytes), the banner’s icon drawn and its titles read, the overlay tables, and the ARM9 and ARM7 programs disassembled at their RAM addresses (ARMv5TE and ARMv4T) with the memory map and I/O register names. Whether bytes are ARM or Thumb is not in the file, so each processor has a choice for it in the options bar; that choice can never be made by the viewer. The secure area is described by facts only (does it start with “encryObj”): nothing is decrypted. It does not read the DSi extended header (the DSi flag is reported), does not know the layout of the autoload tables and overlay code, does not follow code from the entry points (all bytes are decoded as instructions), and has not been run in a browser by its author. - Reference: the DSi header at
0x200, the card commands and the key tables, NitroSDK file formats inside the file system (NCLR, NCGR, NSBMD and the rest), sound and 3D registers beyond the names listed.
Links
Software
- melonDS – accurate Nintendo DS emulator (Windows, macOS, Linux)
- DeSmuME – Nintendo DS emulator with a debugger (Windows, macOS, Linux)
- RetroArch – front end that plays them with a DS core (Windows, macOS, Linux, mobile)
- BlocksDS – toolchain homebrew games are built with, whose tools write the header and checksums (Windows, macOS, Linux)
Reference
- GBATEK – Martin Korth’s hardware reference; the sections “DS Cartridge Header”, “DS Cartridge Icon/Title”, “DS Cartridge NitroROM and NitroARC File Systems”, “DS Memory Maps” and “DS I/O Maps” are what these pages follow