KMG (File Format)

From Custom Mario Kart
(Redirected from KMG)
Jump to navigation Jump to search
Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.

KMG (Kart MiniGame) is a file format from Mario Kart Wii, exclusively used as minigame.kmg, a sub file of /Race/Common.szs. It contains information for Battle Mode, such as time limits and score increments.

File Format

Overview (offsets)

The following table gives an overview about the locations of the different sections:

Offset Number
of
elements
Type
of
elements
Description
0x000 4 UInt32 File header
0x010 10*11 UInt16 Balloon Battle Time Limit Table.
0x0ec 10*11 UInt16 Unknown.
0x1c8 10 UInt16 Balloon Battle Parameters.
0x1dc 10*11 UInt16 Coin Runners Time Limit Table.
0x2b8 10*11 UInt16 Unknown.
0x394 10*11 UInt16 Start Coin Count Table.
0x470 10*11 UInt16 Maximum Coin Count Table.
0x54c 10*11 UInt16 Unknown.
0x628 10*11 UInt16 Unknown.
0x704 10 UInt16 Coin Runners Parameters.
0x718 End of file

Listing of minigame.kmg

Header

Offset Type Description
0x00 String File magic. Always RKMG in ASCII.
0x04 UInt32 Length of the file in bytes.
0x08 UInt32 Unknown.
0x0C UInt32 Offset to Coin Runners Data, relative to 0x10.
0x10 End of file header, start of Balloon Battle Data.

Balloon Battle Data

This section contains parameters used on Balloon Battle. It consists of three sections: a Time Limit Table, an Unknown Table and a Balloon Battle Parameters sub-section. It is located at 0x10.

Balloon Battle Parameters

After the tables, there is a sub-section that contains different parameters, located at 0x1C8.

Offset Information
0x00 Number of points scored when hitting a player.
0x02 Number of extra points scored when defeating a player (originally unused).
0x04 Number of points scored when losing all balloons.
0x06 Number of points scored when hit by a player (originally unused).
0x08 Number of points scored when hitting a teammate (originally unused).
0x0A Number of points taken when hit by a teammate (originally unused).
0x0C Unknown. The game multiplies this value by 60, indicating it might be seconds.
0x0E Unknown. The game multiplies this value by 60, indicating it might be seconds.
0x10 Unknown. The game multiplies this value by 60, indicating it might be seconds.
0x12 Unknown.

Coin Runners Data

This section contains parameters used on Coin Runners. It consists of seven sections: a Time Limit Table, 3 Unknown Tables, a Start Coin Count Table, a Maximum Coin Count Table and a Coin Runners Parameters sub-section. It is located at 0x1DC.

Start Coin Count Table

This table of 10*11 u16 values (size = 0xdc) contains the number of coins in each battle slot, dependent of the number of players. It is located at offset 0x394.

The table follows the Common Entry Structure.

Maximum Coin Count Table

This table of 10*11 u16 values (size = 0xdc) contains the maximum number of coins in each battle slot, dependent of the number of players. It is located at offset 0x470.

The table follows the Common Entry Structure.

Coin Runners Parameters

After the tables, there is a sub-section that contains different parameters, located at 0x704.

Offset Information
0x00 Unknown.
0x02 Unknown.
0x04 Unknown.
0x06 Unknown.
0x08 Unknown.
0x0A Unknown.
0x0C Unknown.
0x0E Minimum amount of coins lost when falling out of bounds.
0x10 Minimum amount of coins lost when hit by a player.
0x12 Percentage of coins to lose (from 0 to 100).

Other Structures

These structures are used multiple times throughout the file.

Time Limit Table

There are two identical tables that contain time limit information for Balloon Battle and Coin Runners. These tables contain 110 unsigned 16-bit values that each define the time limit for each number of players on each stage in seconds.

The table follows the Common Entry Structure.

All of the default time limit values are 180 (3 minutes).

Unknown Tables

For both Balloon Battle and Coin Runners, there are other 0xDC-byte tables that control unknown parameters. They also follow the Common Entry Structure.

Common Entry Structure

This structure is used multiple times throughout the file. The entries are ordered following the Course IDs for the battle stages minus 0x20.

Format of an entry
Offset Information
0x00 2 player Battle.
0x02 3 player Battle.
0x04 4 player Battle.
0x06 5 player Battle.
0x08 6 player Battle.
0x0A 7 player Battle.
0x0C 8 player Battle.
0x0E 9 player Battle.
0x10 10 player Battle.
0x12 11 player Battle.
0x14 12 player Battle.

Here is an offset table for reference (this example is relative to the start of the Time Limit Table):

Stage 2 Players 3 Players 4 Players 5 Players 6 Players 7 Players 8 Players 9 Players 10 Players 11 Players 12 Players
Delfino Pier 0x00 0x02 0x04 0x06 0x08 0x0A 0x0C 0x0E 0x10 0x12 0x14
Block Plaza 0x16 0x18 0x1A 0x1C 0x1E 0x20 0x22 0x24 0x26 0x28 0x2A
Chain Chomp Wheel 0x2C 0x2E 0x30 0x32 0x34 0x36 0x38 0x3A 0x3C 0x3E 0x40
Funky Stadium 0x42 0x44 0x46 0x48 0x4A 0x4C 0x4E 0x50 0x52 0x54 0x56
Thwomp Desert 0x58 0x5A 0x5C 0x5E 0x60 0x62 0x64 0x66 0x68 0x6A 0x6C
GCN Cookie Land 0x6E 0x70 0x72 0x74 0x76 0x78 0x7A 0x7C 0x7E 0x80 0x82
DS Twilight House 0x84 0x86 0x88 0x8A 0x8C 0x8E 0x90 0x92 0x94 0x96 0x98
SNES Battle Course 4 0x9A 0x9C 0x9E 0xA0 0xA2 0xA4 0xA6 0xA8 0xAA 0xAC 0xAE
GBA Battle Course 3 0xB0 0xB2 0xB4 0xB6 0xB8 0xBA 0xBC 0xBE 0xC0 0xC2 0xC4
N64 Skyscraper 0xC6 0xC8 0xCA 0xCC 0xCE 0xD0 0xD2 0xD4 0xD6 0xD8 0xDA

LE-CODE

LE-CODE Logo (Vertical).png

Track authors can include an own version of minigame.kmg in the SZS file of the track. Create a sub-directory ./Common/ and copy the file into the directory. So it is possible to make arena characteristics independent of a slot. Just create a minigame.kmg and copy all settings of your favorite slot to the other 9 slots.

At the moment, only distributions using LE-CODE recognize this file. See LE-CODE Track FAQ and LE-CODE Distribution FAQ for details.


Tools

The following tools can handle KMG files: