File Formats
TODO:
- More filetypes
- Double-check course data block names
- Perhaps info on control bytes and slope controllers?
This page lists file formats used by New Super Mario Bros., what they're used for, and their structures.
Do recall that the NDS uses little endian, so values are read starting from the least significant byte.
Tilesets
These files contain information about tilesets.
Tile Object Definition Files
AKA unt files. These define a tileset's tile objects and can be found in the BG_unt/ folder. These are distinct from the unt_hd files.
These consist of an object block, which contain object row blocks, which can contain either a slope controller — a byte greater than or equal to 0x80, or a tile — defined like so:
| Length | Description |
|---|---|
| 0x1 | Control byte |
| 0x2 | Map16 tile; can be from any of the loaded tilesets — 0x0000-0x00FF = jyotyu, 0x0100-0x03FF = main tileset, 0x0400-0x05FF = subnohara |
The end of an object row block is denoted with 0xFE, while the end of an object block is denoted with 0xFF.
Unt_hd Files
Contain supplementary information about a tileset's tile objects. Can be found in the BG_unt/ folder and will be suffixed with "_hd". Each block is defined suchly:
| Length | Description |
|---|---|
| 0x2 | Offset of tile object (in unt file) |
| 0x1 | Width |
| 0x1 | Height |
There is a block for each object defined in the tilesets unt file.
Courses
These files contain information about course areas and can be found in the course/ folder.
Course Data Files
Course data files contain all the information about a course area bar tile object layout. Files are named X##_#.bin, where X is a letter corresponding to the world, ## is a number corresponding to the course, and # is the area.
Blocks are counted starting from 1, a la NSMBe. Header:
| Length | Description |
|---|---|
| 0x4 | Block 1 (general settings) offset |
| 0x4 | Block 1 (general settings) length |
| 0x4 | Block 2 offset |
| 0x4 | Block 2 length |
| 0x4 | Block 3 (bottom backgrounds) offset |
| 0x4 | Block 3 (bottom backgrounds) length |
| 0x4 | Block 4 (tilesets) offset |
| 0x4 | Block 4 (tilesets) length |
| 0x4 | Block 5 (top backgrounds) offset |
| 0x4 | Block 5 (top backgrounds) length |
| 0x4 | Block 6 (entrances) offset |
| 0x4 | Block 6 (entrances) length |
| 0x4 | Block 7 (stage objects) offset |
| 0x4 | Block 7 (stage objects) length |
| 0x4 | Block 8 (views) offset |
| 0x4 | Block 8 (views) length |
| 0x4 | Block 9 (zones) offset |
| 0x4 | Block 9 (zones) length |
| 0x4 | Block 10 (progress paths) offset |
| 0x4 | Block 10 (progress paths) length |
| 0x4 | Block 11 (paths) offset |
| 0x4 | Block 11 (paths) length |
| 0x4 | Block 12 (progress path nodes) offset |
| 0x4 | Block 12 (progress path nodes) length |
| 0x4 | Block 13 (path nodes) offset |
| 0x4 | Block 13 (path nodes) length |
| 0x4 | Block 14 (object banks) offset |
| 0x4 | Block 14 (object banks) length |
Course BgDat Files
These files contain information about the placement of tile objects in a course area. Their filenames follow the same convention as the course data files but are suffixed with "_bgdat" Each tile object is defined as such:
| Length | Description |
|---|---|
| 0x1 | Tile object number |
| 0x1 | Leftmost nybble determines which tileset the object comes from — 0x0 for jyotyu, 0x1 for the main tileset, 0x2 for subnohara |
| 0x2 | X position of tile object (top left, relative to top left of stage) |
| 0x2 | Y position of tile object (top left, relative to top left of stage) |
| 0x2 | Width of tile object |
| 0x2 | Height of tile object |
Each file is terminated with 0xFFFF.
NSMBe
File formats created for use with NSMBe.
NMP
A NSMBe Exported Patch; also specified in NSMBe's source. The header consists of a byte specifying a string length (in practice, always 0x15) followed by a string (which must read "NSMBe4 Exported Patch" or, allowed in versions 5.3 and above, "NSMBe5 Exported Patch"). It's suceeded by a list of files to replace, with each file defined suchly:
0x01; any other value denotes the end of the file list.
0x1
File name length.
File name length
File name; used to identify the files to replace. If the file is not found when applying the patch, it is skipped.
0x2
File ID. When a patch is applied, if a file in the ROM has the name of a file specified in the patch but a different file ID, a warning is shown.
0x4
File data length.
File data length
File data.
The end of the file list is denoted with a null byte.