RKC (File Format)

From Custom Mario Kart
Revision as of 19:34, 12 June 2019 by Yosh (talk | contribs) (mode 07 and 0E works perfectly as intended :))
Jump to navigation Jump to search

RKC Files (Revolution Kart Competition) are files downloaded by Mario Kart Wii using the WC24 download engine. The RKC file contains data and a U8 file with a new KMP for the competition. The RKC file is part of the DISTMAP.BIN file, which is stored inside the wc24dl.vff file in the savegame.

The maximum file size for a RKC file in the unmodified game is 20480 bytes. It might be possible to change the maximum size by finding the call to malloc() which allocates the space for the RKC data in the game's memory.

File Format

The RKC files contain multiple headers, they are all explained here.

RKCT

The RKCT header, or the main header, is 0x10 bytes long:

Offset Type Description
0x00 String File magic. Always RKCT in ASCII.
0x04 UInt32 Length of the data in bytes.
0x08 UInt32 Length of all file headers (offset to the beginning of the U8 file).
0x0C UInt32 Unknown, always 0x640. Maybe a version number?

RKCO

The RKCO Header contains all information for the competition. Stuff like Course ID, CommonObj that gets loaded and other information. The header is 0x3C bytes long:

Offset Type Description
0x00 String Section magic. Always RKCO in ASCII.
0x04 UInt16 Game mode.
0x06 Byte Course ID.
0x07 Byte Engine class. 0: 50cc, 1: 100cc, 2: 150cc, 3: battle.
0x08 Byte Amount of laps (laps, so triggered with checkpoints, not scores).
0x09 Byte Padding.
0x0A UInt16 Vehicle restriction. 0: karts only, 1: bikes only, 2: no restriction.
0x0C UInt16 Camera angle. 3: normal camera, 7: camera from above.
0x0E UInt16 Minimap object. Defines an object to be shown on the minimap.
0x10 UInt16 Always empty, but read by the game.
0x12 UInt16 Always empty, but read by the game.
0x14 UInt16 Cannon flag. If a track has no cannon, this is set to 0. If a track has a cannon and its
setting is 0xFFFF, it is set to 0, too. Otherwise, it is set to the value of the cannon setting.
0x16 UInt16 Amount of CPU players.
0x18 Byte[22] Driver and vehicle settings for CPU players. First byte driver, second byte vehicle.
0xFF for random driver / vehicle or unused slots.
0x2E Byte Controller. 0x00 for free choice, 0x01 for Wii-Wheel only.
0x2F Byte Padding.
0x30 UInt16 Common object files to load. Bit field for the different files.
0x32 UInt16 Score (amount of gates, amount of coins, etc).
0x34 Byte Intro settings. Between 0x00 and 0x03:
  • 0x00: no intro video
  • 0x01: intro with Battle music
  • 0x02: intro with VS Race music
  • 0x03: Intro with Boss music
0x35 Byte Padding.
0x36 UInt16 Unknown, either 18000 (0x4650) for tracks with laps, 36000 (0x8CA0) for tracks with a score, or 54000 (0xD2F0), exclusively used for the Giant Pokey competition.
0x38 UInt16 Padding.
0x3A UInt16 This seems to be a checksum of the header.

Game Modes

Here are the known game modes:

Value Description
0x00 Time Trial. No position tracker. 3 Mushrooms, multiple KTPT, MSPT.
0x01 VS Race. Position tracker, single KTPT (player last), CPUs, continuing racing after finish.
0x03 Many different objects.
0x04 Spiky Topmen, big Pokey.
0x05 Coins (single coin, leafpile coin).
0x06 Star gates.
0x07 Hit CPUs with blue shell, red shell, green shell, Fake item box, banana, or bob-omb to win (unused), No Position tracker, single KTPT (player first) or multiple, CPUs, MSPT (number of CPUs).
0x0B Battle. No Position tracker, single KTPT (player first) or multiple, CPUs, MSPT (number of CPUs).
0x0C Battle. Position tracker, single KTPT (player first) or multiple, CPUs, MSPT (number of CPUs).
0x0E Perform drifts to win, CPUs drifts count too (unused). No position tracker, single KTPT (player first) or multiple, CPUs, MSPT (number of CPUs).

Note that when there is no position tracker, the game always act like you're 12th.

In game mode 0x03, many different objects will give you a point when you destroy, hit or activate them. The objects are:

and probably some more.

There are a few more game modes (the ones which do not appear in the list of game modes above), but their meaning and usage is unknown.

RKCS

This is the part of a RKC file that contains the actual data. It only contains a YAZ0 compressed U8 file with a KMP file and some object files which are neither in the course, the competition bases or in one of the CommonObj files.

This U8 file must contain the folders AIParam and ItemSlotTable, but both of them may be empty if you do not want to modify the AI settings or the items.

Replacing and ripping RKC files

NOTE: The data blocks which were previously known as "RSF Files" (this name was invented by khacker35000vr to name unknown data groups) are not part of the actual competition. If you extract the VFF file and not just open it in a hex editor, you can see that there is no data after the RKC file. The "trash data" (RSF) in the VFF file after the RKC data is just random data from the previous competition, because Nintendo just copies the new RKC file to the specific offset and does not clear the rest of the file. So, when a new competition is smaller than the old one, those trash bytes stay in the file, even though they are not needed.

Replacing

  • Search the RKC file in the VFF File.
  • Copy and paste (overwrite old data) the data of your custom RKC file at the good offset.
  • If the new RKC file is larger than the older one this may not work. At the moment there is no tool to create larger VFF files.

Ripping

  • Use Riivolution along with the savegame XML when a competition is in progress, or copy your savegame to SD with tools like Savegame Manager GX.
  • Extract the wc24dl.vff with "vffdump.py".
  • Open the file "DISTMAP.BIN" in a hex editor and search for "RKCT".
  • Check the size and copy that amount of bytes to a new file (RKC).

Misc.

  • Custom tournaments are able to be made, and can be added to Leseratte's competition system for Wiimmfi.
  • All downloaded contents (competition and other players' ghost data) for Mario Kart Wii are saved in wc24dl.vff.

Tools

The following tools can handle RKC files:

A kaitai format description file can be found on this GitHub repository.