Read header of NDS game?

2.1k views Asked by At

I know this is a little out of the ordinary, but I want to try and find out how I can read the metadata of a Nintendo DS game? When on the computer, they have the .nds extension.

I'm trying to work with some homebrew games I have, and I want to make a library. C# is the language I'd prefer to use.

I've tried researching it on the internet, and the closest option I've found is reading the file header. However, considering the game file is supposed to have a title and an image, the closest I've come to it is just getting part of the title up.

I know this can be done, because there are some programs, written in c#, that have done it. So, does anyone know how? I'd muchly appreciate any help.

1

There are 1 answers

1
RCramiro On

All the metadata (including the title/image) is stored in the ROM header, which is the first 512 bytes of the .nds file. You'll have to read in the .nds file as a binary file and examine the values stored at certain offsets.

For example, the 4 bytes starting at offset 0x68h contain a 32-bit value that specifies the offset where the game's title/icon data is stored. The English title is stored in the 256 bytes (encoded in 16-bit Unicode) found at 0x340h from that 0x68 offset.

Similarly, the icon bitmap (32x32 pixels) is stored in the 512 bytes at 0x20h from the 0x68h offset, and the bitmap's palette is stored in the 32 bytes at 0x220h from the 0x86 offset. The icon & its palette are encoded in the standard GBA color scheme/palette (see the Color Format section at http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#Graphics%20Hardware%20Overview).

For more information about the .nds header format, refer to http://nocash.emubase.de/gbatek.htm#dscartridgeheader.

If in doubt, you can refer to ndstool, which is a handy utility for viewing nds header data and extracting files from the DS filesystem. It's open-source and included as part of the devkitPro toolchain, available at http://sourceforge.net/projects/devkitpro/.