Difference between revisions of "Wiimms SZS Tools/KMP"

From Custom Mario Kart
Jump to navigation Jump to search
Line 25: Line 25:
 
== Editing ==
 
== Editing ==
  
After decoding you have an text file, typical named '''course.txt'''. You can edit it with a text editor of you choice and can user all powerful commands of the editor. It is also possible to use script, batch files or other tools to modify it.
+
After decoding you have a text file, typical named '''course.txt'''. You can edit it with a text editor of you choice and can user all powerful commands of the editor. It is also possible to use scripts, batch files or other tools to modify it.
  
 
=== Syntax ===
 
=== Syntax ===
Line 43: Line 43:
 
=== Sections ===
 
=== Sections ===
  
The whole file is divided in sections. Each section starts with &raquo;<nowiki>[NAME]</nowiki>&laquo; and ends at the beginning of the next section. If the same section exists two or more times, only the last section is relevant. External tools may use this feature to add a new calculated sections at the end of the file.
+
The whole file is divided into sections. Each section starts with &raquo;<nowiki>[NAME]</nowiki>&laquo; and ends at the beginning of the next section. If the same section exists two or more times, only the last section is relevant. External tools may use this feature to add a new calculated sections at the end of the file.
  
 
The '''<nowiki>[SETUP]</nowiki>''' section is special. The most important parameter is '''&raquo;REVISION = number&laquo;'''. This numeric value is used to decide, how the following sections are read and handled. This may be important if the tools change the syntax and/or semantics. If an external tool add some sections at the end, they should first declare a <nowiki>[SETUP]</nowiki> section to specify the revision followed by the data section.
 
The '''<nowiki>[SETUP]</nowiki>''' section is special. The most important parameter is '''&raquo;REVISION = number&laquo;'''. This numeric value is used to decide, how the following sections are read and handled. This may be important if the tools change the syntax and/or semantics. If an external tool add some sections at the end, they should first declare a <nowiki>[SETUP]</nowiki> section to specify the revision followed by the data section.

Revision as of 21:06, 9 August 2011

This page is related to Wiimms SZS Tools and to the file format KMP. It shows how to use the tools to change the KMP parameters.


Extracting and decoding a KMP file

KMP files are stored as sub files in SZS files of tracks. They contain information about how the course is played, such as start positions and check points. →KMP (File Format)

Extracting track files

If you have a SZS file you can extract it's content with:

wszst extract MY.szs

If adding option --decode, all supported file types are decoded. BMG and KMP are decoded into text files an Images into PNG files:

wszst extract MY.szs --decode

You can add the option --dest=dir if you want to override the default destination.

Decoding a KMP file

If you have already an extracted KMP file, you decode it with:

wkmpt decode course.kmp

Editing

After decoding you have a text file, typical named course.txt. You can edit it with a text editor of you choice and can user all powerful commands of the editor. It is also possible to use scripts, batch files or other tools to modify it.

Syntax

General syntax rules:

  • The tools generate always windows compatible text files with CR+LF as line termination. Unix system has no problems with it. If scanning a text file, windows and Unix format is allowed.
  • The first 8 characters of a KMP text file must be »#KMP-TXT«.
  • Spaces and tabs (=blanks) at beginning or end of line are ignored. Blanks (single or multiple) are used to separate columns.
  • Empty lines (= lines containing only blanks) and lines beginning with a '#' are ignored.
  • Lines beginning with a '[' signal the beginning of a new section.
  • Lines beginning with a '@' are special parameter lines.
  • Lines beginning with a '$' are grouping markers.
  • Lines beginning with a letter or digit are normal lines and contains lists of parameters. The may be splitted into multiple lines.
    • Lines beginning with a '>' are continuation of normal lines.
  • Names and keywords are sequences of letters (case ignored), digits and '_', '.' and '$'.

Sections

The whole file is divided into sections. Each section starts with »[NAME]« and ends at the beginning of the next section. If the same section exists two or more times, only the last section is relevant. External tools may use this feature to add a new calculated sections at the end of the file.

The [SETUP] section is special. The most important parameter is »REVISION = number«. This numeric value is used to decide, how the following sections are read and handled. This may be important if the tools change the syntax and/or semantics. If an external tool add some sections at the end, they should first declare a [SETUP] section to specify the revision followed by the data section.

Example:

[SETUP]
# Use syntax and semantics of tools revision 1234
REVISION = 1234

[CKPT]
# Calculated check points
...

Encoding and packing

Encoding a KMP file

Encoding is as simple as decoding:

 wkmpt encode course.txt

Packing a SZS file

If you have extracted a complete SZS file, you can pack it again with:

wszst create MY.d

MY.d is the previous created directory containing all sub files. The tools knows (because of reading the file wszst-setup.txt) all about the extraction process. It compares the time stamps of the war and decoded files and encode files, if they are younger or if the raw file is missed. For KMP this means: If you habe edited and stored it, it will be encoded automatically, if not, the original raw files is used. An explicit encoding is not necessary.

Links