NKM (File Format)
NKM is a file format that describes objects, routes, cameras and other information about a course in Mario Kart DS.
File Format
File Header
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | File magic. Always NKMD in ASCII. |
0x04 | UInt16 | Version number. Final tracks are always 3.7 (0x25 = 37). Beta tracks are 3.0 (0x1E = 30), 3.2 (0x20 = 32) or 3.4 (0x22 = 34). The files written with MKDS Course Modifier 4.0 beta 10 are 4.0 (0x28 = 40), because of the additional information section. |
0x06 | UInt16 | Size of header in bytes. |
0x08 | UInt32[] | Section offsets. |
The section offsets may point to the sections in any order, however, in original files they are always stored in the same order as presented in this documentation.
Section Header
Every sections except the STAG section starts with the following section header. The section header is a 0x08 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | Section magic. |
0x04 | UInt32 | Number of entries in the section. |
OBJI
The OBJI Section describes object used in tracks. Each entry is a 0x3C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32[3] | 3D rotation vector. |
0x18 | Fx32[3] | 3D scale vector. |
0x24 | UInt16 | Object ID. |
0x26 | UInt16 | Route ID. 0xFFFF if none. |
0x28 | UInt16[8] | 4 object-specific settings. |
0x38 | UInt32 | Show in Time Trails. 1 if shown, 0 if not. |
PATH
The PATH section describes paths used for objects and cameras. Each entry is a 0x04 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Byte | Route ID. |
0x01 | Byte | 1 if the route loops, 0 otherwise. |
0x02 | UInt16 | Number of points. The points are stored in the POIT section. |
POIT
The POIT section describes points that is used by the PATH section. Each entry is a 0x14 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Byte | Point index in the route. |
0x0D | Byte | Unknown. |
0x0E | Int16 | Point duration. Not always used. |
0x10 | UInt32 | Unknown. |
STAG
The STAG section describes global information about the track. This is the only section that doesn't start with the section header. The section is a 0x2C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | Section magic. Always STAG in ASCII. |
0x04 | UInt16 | Track ID. |
0x06 | UInt16 | Amount of laps. |
0x08 | Byte | Unknown. |
0x09 | Byte | 1 = fog enabled, 0 = disabled. |
0x0A | Byte | Fog table generation mode. |
0x0B | Byte | Fog slope. |
0x0C | UInt32 | Unknown. |
0x10 | UInt32 | Unknown. |
0x14 | Fx32 | Fog distance. |
0x18 | GXRgb | Fog color. |
0x1A | UInt16 | Fog alpha (0-15). |
0x1C | GXRgb | KCL color 1, the default color. |
0x1E | GXRgb | KCL color 2. |
0x20 | GXRgb | KCL color 3. |
0x22 | GXRgb | KCL color 4. |
0x24 | Fx32 | Frustum far. |
0x28 | UInt32 | Unknown. |
KTPS
The KTPS section describes start positions of racers. Each entry is a 0x1C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32[3] | 3D rotation vector. |
0x18 | UInt16 | Padding (0xFFFF). |
0x1A | UInt16 | Start position index. Only used in battle stages and mission mode. For regular courses it is 0xFFFF. |
KTPJ
The KTPJ section describes respawn positions. Each entry is a 0x20 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32[3] | 3D rotation vector. |
0x18 | UInt16 | Enemy position ID (EPOI). |
0x1A | UInt16 | Item position ID (IPOI). |
0x1C | UInt32 | Respawn ID. |
In tracks with version 0x1E, the Respawn ID does not exist. Tracks with version 0x1E, 0x20 and 0x22 (beta tracks) has a different rotation vector. The Y-rotation can be calculated by using:
Atan2(Rotation.X, Rotation.Z)
KTP2
The KTP2 section describes points you need to pass to let the lap count. Each entry is a 0x1C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32[3] | 3D rotation vector. |
0x18 | UInt16 | Padding (0xFFFF). |
0x1A | UInt16 | Index. Always 0xFFFF. |
KTPC
The KTPC section describes cannons (or pipe) destination points. Pipes do only work in battle mode by default. Each entry is a 0x1C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32[3] | 3D rotation vector. |
0x18 | UInt16 | Unknown. |
0x1A | UInt16 | Cannon index. Used for the 'Cannon Activator' collision type. |
KTPM
The KTPM sections describes points that you need to pass to let a mission succeed. Each entry is a 0x1C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32[3] | 3D rotation vector. |
0x18 | UInt16 | Padding (0xFFFF). |
0x1A | UInt16 | Index (last start position index + 1 is the first one). |
CPOI
The CPOI section describes check points. Each entry is a 0x24 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 2D position vector. |
0x08 | Fx32[3] | 2D position vector 2. |
0x10 | Fx32 | Sinus. |
0x14 | Fx32 | Cosinus. |
0x18 | Fx32 | Distance |
0x1C | Int16 | Section data 1. Has to do with different sections and such, but it is still very unknown. |
0x1E | Int16 | Section data 2. Has to do with different sections and such, but it is still very unknown. |
0x20 | UInt16 | Key ID. 0x0000 = lap counter, 0x0001 – 0xFFFE = key, 0xFFFF = no key. |
0x22 | Byte | Respawn ID. |
0x23 | Byte | Unknown. |
CPAT
The CPAT section describes CPOI grouping. Each entry is a 0x0C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | UInt16 | Point start. |
0x02 | UInt16 | Point length. |
0x04 | Byte[3] | Next group. The indicies of up to 3 the previous CPOI groups entries may have followed. Unneeded slots are set to value 0xFF. |
0x07 | Byte[3] | Previous group. The indicies of up to 3 next CPOI group entries to follow. Unneeded slots are set to value 0xFF. |
0x0A | Int16 | Section order. |
\t
IPOI
The IPOI section describes item points; the routes of items such as red shells. Each entry is a 0x14 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32 | Point scale. |
0x10 | UInt32 | Unknown. |
IPAT
The IPAT section describes IPOI grouping. Each entry is a 0x0C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | UInt16 | Point start. |
0x02 | UInt16 | Point length. |
0x04 | Byte[3] | Next group. The indicies of up to 3 the previous IPOI groups entries may have followed. Unneeded slots are set to value 0xFF. |
0x07 | Byte[3] | Previous group. The indicies of up to 3 next IPOI group entries to follow. Unneeded slots are set to value 0xFF. |
0x0A | Int16 | Section order. |
EPOI
The EPOI section describes enemy points; the routes that the CPUs take. Each entry is a 0x18 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32 | Point scale. |
0x10 | Int16 | Drifting. |
0x12 | UInt16 | Unknown. |
0x14 | UInt32 | Unknown. |
EPAT
The EPAT section describes EPOI grouping. Each entry is a 0x0C byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | UInt16 | Point start. |
0x02 | UInt16 | Point length. |
0x04 | Byte[3] | Next group. The indicies of up to 3 the previous EPOI groups entries may have followed. Unneeded slots are set to value 0xFF. |
0x07 | Byte[3] | Previous group. The indicies of up to 3 next EPOI group entries to follow. Unneeded slots are set to value 0xFF. |
0x0A | Int16 | Section order . |
MEPO
The MEPO section describes enemy points used in minigames. Each entry is a 0x18 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | Fx32[3] | 3D position vector. |
0x0C | Fx32 | Point scale. |
0x10 | Int32 | Drifting. |
0x14 | UInt32 | Unknown. |
MEPA
The MEPA section describes MEPO grouping used in minigames. Each entry is a 0x14 byte structure as follows:
Offset | Type | Description |
---|---|---|
0x00 | UInt16 | Point start. |
0x02 | UInt16 | Point length. |
0x04 | Byte[8] | Next group. The indicies of up to 8 the previous MEPO groups entries may have followed. Unneeded slots are set to value 0xFF. |
0x0C | Byte[8] | Previous group. The indicies of up to 8 next MEPO group entries to follow. Unneeded slots are set to value 0xFF. |
AREA
The AREA section describes areas, mosty used for determine which camera to use. Each entry is a 0x48 byte structure as follows:
Offset | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | Fx32[3] | 3D position vector. | ||||||||||||
0x0C | Fx32[3] | 3D length vector. | ||||||||||||
0x18 | Fx32[3] | X-vector?. | ||||||||||||
0x24 | Fx32[3] | Y-vector?. | ||||||||||||
0x30 | Fx32[3] | Z-vector?. | ||||||||||||
0x3C | Int16 | Unknown. | ||||||||||||
0x3E | Int16 | Unknown. | ||||||||||||
0x40 | Int16 | Unknown. | ||||||||||||
0x42 | Byte | Unknown. | ||||||||||||
0x43 | Byte | Camera ID. | ||||||||||||
0x44 | Byte | Area type.
| ||||||||||||
0x45 | Byte | Unknown. | ||||||||||||
0x46 | UInt16 | Unknown. |
CAME
The CAME section describes cameras used in tracks. Each entry is a 0x4C byte structure as follows:
Offset | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | Fx32[3] | 3D position vector 1. | ||||||||||||||||||||
0x0C | Fx32[3] | 3D rotation vector. | ||||||||||||||||||||
0x18 | Fx32[3] | 3D position vector 2. | ||||||||||||||||||||
0x24 | Fx32[3] | 3D position vector 3. | ||||||||||||||||||||
0x30 | Int16 | FOV begin. | ||||||||||||||||||||
0x32 | Fx16 | FOV begin sine. | ||||||||||||||||||||
0x34 | Fx16 | FOV begin cosine. | ||||||||||||||||||||
0x36 | Int16 | FOV end. | ||||||||||||||||||||
0x38 | Fx16 | FOV end sine. | ||||||||||||||||||||
0x3A | Fx16 | FOV end cosine. | ||||||||||||||||||||
0x3C | UInt16 | Camera zoom. | ||||||||||||||||||||
0x3E | UInt16 | Camera type.
| ||||||||||||||||||||
0x40 | UInt16 | Linked route (0xFFFF if none). | ||||||||||||||||||||
0x42 | UInt16 | Route speed. | ||||||||||||||||||||
0x44 | UInt16 | Point speed. | ||||||||||||||||||||
0x46 | UInt16 | Camera duration in 1/60 second units. | ||||||||||||||||||||
0x48 | UInt16 | Next camera (0xFFFF if this is the last one). | ||||||||||||||||||||
0x4A | Byte | Intro pan first camera indicator (0x00 = none, 0x01 = top screen, 0x02 = bottom screen). | ||||||||||||||||||||
0x4B | Byte | Unknown |
NKMI
Since MKDS Course Modifier 4.0 beta 10, some additional information may be stored in the NKM file. The NKMI section describes some information about the track itself, like the name and the version etc.
Offset | Size | Type | Description |
---|---|---|---|
0x00 | 0x04 | Char[4] | Section magic. NKMI in ASCII. |
0x04 | 0x04 | UInt32 | Section length. |
0x08 | a | StringNT | Track name. |
0x08 + a | b | StringNT | Author. |
0x08 + a + b | c | StringNT | Version. |
0x08 + a + b + c | d | StringNT | Latest edit date. Format: dd/MM/yyyy HH:mm:ss. |
Tools
The following tools can handle NKM files:
- Every File Explorer, by Gericom
- Mario Kart Toolbox, by Gericom
- MKDS Course Modifier, by Gericom