Difference between revisions of "KMP (File Format)/Mario Kart 7"

From Custom Mario Kart
Jump to navigation Jump to search
(Replaced content with "This page has been moved to the mario kart 7 wiki -> http://mk7.tock.eu/index.php?title=KMP_(File_Format)")
Line 1: Line 1:
KMP files are used in [[Mario Kart Wii]] aswell as in [[Mario Kart 7]]. This article describes the KMP file format used in [[Mario Kart 7]].
+
This page has been moved to the mario kart 7 wiki -> http://mk7.tock.eu/index.php?title=KMP_(File_Format)
 
 
KMP files contain information about how the course is played, such as start positions, check points and the CPU routes. The file is written in [[Little endian|little endian]].
 
 
 
== File Header ==
 
This is the general layout for a KMP header:
 
 
 
{| class="wikitable"
 
|+ File header of a KMP file
 
|-
 
! Offset !! width="6%" | Type !! Description
 
|-
 
| 0x00 || String || File magic.
 
|-
 
| 0x04 || UInt32 || Length of the file in bytes.
 
|-
 
| 0x08 || UInt16 || '''N''' = Number of sections in the file.
 
|-
 
| 0x0A || UInt16 || Header length.
 
|-
 
| 0x0C || UInt32 || Unknown meaning, perhaps something like a revision number. The value of MK7 KMP files is 0x1C0C (le) = 3100.
 
|-
 
| 0x10 || UInt32['''N'''] || '''N''' section offsets. The type of each section can be detected by analysing the first 4 bytes of the section; it's always the section name. The offset is relative to the end of this header.
 
|-
 
| colspan=2 {{unknown|'''N''' * 0x04 + 0x10}} || {{unknown|End of this file header}}
 
|}
 
 
 
=== Typical File Header ===
 
This is specific file header for [[Mario Kart 7]] tracks. It is a structure with 0x58 (=88) bytes.
 
 
 
{| class="wikitable"
 
|+ File header of a MK7 KMP file
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || String || File magic. Always ''DMDC'' in ASCII.
 
|-
 
| 0x04 || UInt32 || Length of the file in bytes.
 
|-
 
| 0x08 || UInt16 || Number of sections in the file (0x12).
 
|-
 
| 0x0A || UInt16 || Header length.
 
|-
 
| 0x0C || UInt32 || Probably a revision number. The value of MK7 KMP files is 0xC1C = 3100.
 
|-
 
| 0x10 || UInt32 || [[#TPTK|TPTK]] section offset.
 
|-
 
| 0x14 || UInt32 || [[#TPNE|TPNE]] section offset.
 
|-
 
| 0x18 || UInt32 || [[#HPNE|HPNE]] section offset.
 
|-
 
| 0x1C || UInt32 || [[#TPTI|TPTI]] section offset.
 
|-
 
| 0x20 || UInt32 || [[#HPTI|HPTI]] section offset.
 
|-
 
| 0x24 || UInt32 || [[#TPKC|TPKC]] section offset.
 
|-
 
| 0x28 || UInt32 || [[#HPKC|HPKC]] section offset.
 
|-
 
| 0x2C || UInt32 || [[#JBOG|JBOG]] section offset.
 
|-
 
| 0x30 || UInt32 || [[#ITOP|ITOP]] section offset.
 
|-
 
| 0x34 || UInt32 || [[#AERA|AERA]] section offset.
 
|-
 
| 0x38 || UInt32 || [[#EMAC|EMAC]] section offset.
 
|-
 
| 0x3C || UInt32 || [[#TPGJ|TPGJ]] section offset.
 
|-
 
| 0x40 || UInt32 || [[#TPNC|TPNC]] section offset.
 
|-
 
| 0x44 || UInt32 || [[#TPSM|TPSM]] section offset.
 
|-
 
| 0x48 || UInt32 || [[#IGTS|IGTS]] section offset.
 
|-
 
| 0x4C || UInt32 || [[#SROC|SROC]] section offset.
 
|-
 
| 0x50 || UInt32 || [[#TPLG|TPLG]] section offset.
 
|-
 
| 0x54 || UInt32 || [[#HPLG|HPLG]] section offset.
 
|-
 
| unknown|0x58 || colspan=2 {{unknown|End of this file header}}
 
|}
 
 
 
All offsets are relative to the end of the header.
 
 
 
== Sections ==
 
Every section starts with this section header. The section header is a 0x08 byte structure as follows:
 
 
 
{| class="wikitable"
 
|+ Section header for all KMP sections
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || String || The section name in ASCII. Compared with [[Mario Kart Wii]], the section names are written in reversed order.
 
|-
 
| 0x04 || UInt16 || Number of entries.
 
|-
 
| 0x06 || UInt16 || Additional value. The POTI section stores the total number of points of all routes. The CAME section stores 0xFFFF. All other values 0x0000 (padding).
 
|-
 
| 0x08
 
| colspan=2 {{unknown|End of header & start of first entry}}
 
|}
 
 
 
=== TPTK ===
 
The TPTK ''(kart point)'' section describes kart points; the starting positions of racers.
 
Each entry is a 0x1A byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Float[3] || A '''3D position vector''' of the start position.
 
|-
 
| 0x0C || Float[3] || A '''3D rotation vector''' of the start position.
 
|-
 
| 0x18 || UInt16 || Player index.
 
|-
 
| 0x1A || UInt16 || Padding?
 
|}
 
 
 
This section is only used in battle tracks. The start point is written as an object in the [[#JBOG|JBOG]] section in the regular tracks.
 
 
 
=== TPNE ===
 
The TPNE ''(enemy point)'' section describes enemy points; the routes of CPU racers. The CPU racers attempt to follow the path described by each group of points (as determined by HPNE). Each entry is a 0x18 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Float[3] || A 3D position vector of the enemy position.
 
|-
 
| 0x0C || Float || This value controls, how much the enemies leave the direct point-to-point line to the left and right side.
 
|-
 
| 0x10 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x14 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== HPNE ===
 
The HPNE ''(enemy path)'' section describes enemy points grouping; how the routes of CPU racers link together.
 
Each entry is a 0x48 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || UInt16 || Point start. The index of the first [[#TPNE|TPNE]] entry in this group.
 
|-
 
| 0x02 || UInt16 || Point length. The number of [[#TPNE|TPNE]] entries in this group.
 
|-
 
| 0x04 || UInt16[16] || Previous group. The indicies of up to 16 the previous [[#TPNE|TPNE]] groups entries may have followed. Unneeded slots are set to value 0xFFFF.
 
|-
 
| 0x24 || UInt16[16] || Next group. The indicies of up to 16 next [[#TPNE|TPNE]] group entries to follow. Unneeded slots are set to value 0xFFFF.
 
|-
 
| 0x44 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== TPTI ===
 
The TPTI ''(item point)'' section describes item points; the routes of items such as red shells. The items attempt to follow the path described by each group of points (as determined by HPTI). Each entry is a 0x14 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Float[3] || A 3D position vector of the item position.
 
|-
 
| 0x0C || Float || Bullet Bill can be controlled a little bit by left and right. And this value defines the range.
 
|-
 
| 0x10 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
|}
 
 
 
=== HPTI ===
 
The HPTI ''(item path)'' section describes item point grouping; how the routes of items link together.
 
Each entry is a 0x1C byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || UInt16 || Point start. The index of the first [[#TPTI|TPTI]] entry in this group.
 
|-
 
| 0x02 || UInt16 || Point length. The number of [[#TPTI|TPTI]] entries in this group.
 
|-
 
| 0x04 || UInt16[6] || Previous group. The indicies of up to 6 the previous [[#TPTI|TPTI]] groups entries may have followed. Unneeded slots are set to value 0xFFFF.
 
|-
 
| 0x10 || UInt16[6] || Next group. The indicies of up to 6 next [[#TPTI|TPTI]] group entries to follow. Unneeded slots are set to value 0xFFFF.
 
|}
 
 
 
=== TPKC ===
 
The TPKC ''(checkpoint)'' section describes check points; the routes players must follow to count laps. The racers must follow the path described by each group of points (as determined by [[#HPKC|HPKC]]). Each entry is a 0x18 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Float[2] || A 2D position vector (X and Z coordinate) of the '''left point''' of the check point line.
 
|-
 
| 0x08 || Float[2] || A 2D position vector (X and Z coordinate) of the '''right point''' of the check point line.
 
|-
 
| 0x10 || Byte || Respawn ID.
 
|-
 
| 0x11 || Byte || Checkpoint type.
 
|-
 
| 0x12 || Byte || '''Previous check point''' in this group's sequence; 0xFF for the first point of the group.
 
|-
 
| 0x13 || Byte || '''Next check point''' in this group's sequence; 0xFF for the last point of the group.
 
|-
 
| 0x14 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x15 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x16 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x17 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
|}
 
 
 
=== HPKC ===
 
The HPKC ''(checkpoint path)'' section describes check point grouping; how the routes of check points link together. Each entry is a 0x10 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Byte || Point start. The index of the first [[#TPKC|TPKC]] entry in this group.
 
|-
 
| 0x01 || Byte || Point length. The number of [[#TPKC|TPKC]] entries in this group.
 
|-
 
| 0x02 || Byte[6] || Previous group. The indicies of up to 6 the previous [[#TPKC|TPKC]] groups entries may have followed. Unneeded slots are set to value 0xFF.
 
|-
 
| 0x08 || Byte[6] || Next group. The indicies of up to 6 next [[#TPKC|TPKC]] group entries to follow. Unneeded slots are set to value 0xFF.
 
|-
 
| 0x0E || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== JBOG ===
 
The JBOG ''(game object)'' section describes objects; things on the course such as item boxes and coins. Each entry is a 0x40 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || UInt16 || '''Object ID''' to identify the Object.
 
|-
 
| 0x02 || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x04 || Float[3] || A '''3D position vector''' of the object.
 
|-
 
| 0x10 || Float[3] || A '''3D rotation vector''' of the object.
 
|-
 
| 0x1C || Float[3] || A '''3D scale vector''' of the object's scale.
 
|-
 
| 0x28 || UInt16 || '''Route''' used by the object. This is index link into the [[#ITOP|ITOP]] section. The value 0xFFFF means ''"no route"''.
 
|-
 
| 0x2A || UInt16[8] || Up to 8 object specific '''settings'''.
 
|-
 
| 0x3A || UInt16 || Object '''presence flags'''.
 
|-
 
| 0x3C || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x3E || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== ITOP ===
 
The ITOP section describes routes; these are routes for many things including cameras and objects.
 
 
 
Each entry is a 0x04 byte structure as follows, which is followed by 0x10 byte structures:
 
 
 
{| class="wikitable"
 
|+ Route Header
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || UInt16 || '''Number of points''' in the route.
 
|-
 
| 0x02 || Byte || Route setting 1.
 
|-
 
| 0x03 || Byte || Route setting 2.
 
|}
 
 
 
Each point in each entry is as follows:
 
 
 
{| class="wikitable"
 
|+ Route Points
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Float[3] || A '''3D position vector''' of the route position.
 
|-
 
| 0x0C || UInt16 || Route point setting 1.
 
|-
 
| 0x0E || UInt16 || Route point setting 2.
 
|}
 
 
 
=== AERA ===
 
The AERA section describes areas; used to determine which camera to use for example. Each entry is a 0x30 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Byte || Area '''mode'''. 0 = box, 1 = cylinder.
 
|-
 
| 0x01 || Byte || Area '''type'''.
 
|-
 
| 0x02 || Byte || '''Index of [[#EMAC|EMAC]]'''.
 
|-
 
| 0x03 || Byte || '''Priority value'''. A higher number means a higher priority to choose which area activates if multiple areas intersected.
 
|-
 
| 0x04 || Float[3] || A '''3D position vector''' of the area.
 
|-
 
| 0x10 || Float[3] || A '''3D rotation vector''' of the area's rotation.
 
|-
 
| 0x1C || Float[3] || A '''3D scale vector''' of the area's scale.
 
|-
 
| 0x28 || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x2A || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x2C || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x2E || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== EMAC ===
 
The EMAC section describes cameras; used to determine cameras for starting routes, time trial pans, etc. Each entry is a 0x48 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Byte || Camera '''type'''.
 
|-
 
| 0x01 || Byte || Next camera entry index. Value 0xFF means: no next camera.
 
|-
 
| 0x02 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x03 || Byte || '''Route''' used by the camera. This is index link into the [[#ITOP|ITPO]] section. The value 0xFF means ''"no route"''.
 
|-
 
| 0x04 || UInt16 || Route speed.
 
|-
 
| 0x06 || UInt16 || FOV speed.
 
|-
 
| 0x08 || UInt16 || Viewpoint speed.
 
|-
 
| 0x0A || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x0B || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x0C || Float[3] || A '''3D position''' vector of the camera.
 
|-
 
| 0x18 || Float[3] || A '''3D rotation''' vector of the camera.
 
|-
 
| 0x24 || Float || The angle of the FOV (start).
 
|-
 
| 0x28 || Float || The angle of the FOV (end).
 
|-
 
| 0x2C || Float[3] || Start vector of the '''view point'''.
 
|-
 
| 0x38 || Float[3] || Destination vector of the '''view point'''.
 
|-
 
| 0x44 || Float || The '''time''' how long this Camera is active.
 
|}
 
 
 
=== TPGJ ===
 
The TPGJ section describes Jugem points; the respawn points. Each entry is a 0x1C byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Float[3] || A '''3D position vector''' of the respawn position.
 
|-
 
| 0x0C || Float[3] || A '''3D rotation vector''' of the respawn position.
 
|-
 
| 0x18 || UInt16 || The ID of this respawn position.
 
|-
 
| 0x1A || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== TPNC ===
 
It seems that this section is usused.
 
 
 
=== TPSM ===
 
It seems that this section is usused.
 
 
 
=== IGTS ===
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x01 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x02 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x03 || Byte || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x04 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x08 || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x0A || UInt16 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== SROC ===
 
It seems that this section is usused.
 
 
 
=== TPLG ===
 
Each entry is a 0x18 byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offset !! Type !! Description
 
|-
 
| 0x00 || Float[3] || A '''3D position vector''' of the point.
 
|-
 
| 0x0C || Float || Point scale.
 
|-
 
| 0x10 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x14 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
=== HPLG ===
 
Each entry is a 0x0C byte structure as follows:
 
 
 
{| class="wikitable"
 
|-
 
! Offse !! Type !! Description
 
|-
 
| 0x00 || Byte || Point start. The index of the first [[#TPLG|TPLG]] entry in this group.
 
|-
 
| 0x01 || Byte || Point length. The number of [[#TPLG|TPLG]] entries in this group.
 
|-
 
| 0x02 || Byte[6] || Previous groups. The indicies of up to 6 the previous [[#TPLG|TPLG]] groups entries may have followed. Unneeded slots are set to value 0xFF.
 
|-
 
| 0x08 || Byte[6] || Next groups. The indicies of up to 6 next [[#TPLG|TPLG]] group entries to follow. Unneeded slots are set to value 0xFF.
 
|-
 
| 0x0C || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|-
 
| 0x10 || UInt32 || {{Unknown-left|'''Unknown'''.}}
 
|}
 
 
 
== Notes ==
 
* The rotation vector is written as radians in float.
 
* Many sections are similar to the [[KMP (File Format)|Mario Kart Wii KMP]].
 
 
 
== Tools ==
 
The following tools can handle Mario Kart 7 KMP files:<br>
 
* [https://static.wiidatabase.de/Every-File-Explorer.zip Every File Explorer], by [[Gericom]] (not editable)<br>
 
* [https://github.com/mariohackandglitch/KMPExpander/releases/tag/v4 KMP Expander], by [[Ermelber]]
 
 
 
[[Category:File Format/Other]]
 

Revision as of 15:05, 22 September 2019

This page has been moved to the mario kart 7 wiki -> http://mk7.tock.eu/index.php?title=KMP_(File_Format)