Difference between revisions of "LPAR (File Format)"

From Custom Mario Kart
Jump to navigation Jump to search
Line 8: Line 8:
  
 
A [[LE-CODE]] binary file (e.g. ''lecode-PAL.bin'') contains a binary section with magic »LPAR«. It defines how the LE-CODE executor works. Up to [[Wiimms SZS Tools|Wiimms SZS Tools v2.14a]], [[LE-CODE]] parameters had to be set via options when patching. As of v2.15a there is also the possibility to define the parameters by a LPAR file. So a LPAR file is a text version of the binary LPAR section. Options are still accepted and have higher priority than a LPAR file.
 
A [[LE-CODE]] binary file (e.g. ''lecode-PAL.bin'') contains a binary section with magic »LPAR«. It defines how the LE-CODE executor works. Up to [[Wiimms SZS Tools|Wiimms SZS Tools v2.14a]], [[LE-CODE]] parameters had to be set via options when patching. As of v2.15a there is also the possibility to define the parameters by a LPAR file. So a LPAR file is a text version of the binary LPAR section. Options are still accepted and have higher priority than a LPAR file.
 +
 +
This whole article based on [[Wiimms SZS Tool]] v2.15a or later. Some paramters will be available with release of v2.16a, see remarks.
  
 
[[#use|Using a LPAR file]] is recommended, because some parameters can only be set by a LPAR file. A typical command looks like this:
 
[[#use|Using a LPAR file]] is recommended, because some parameters can only be set by a LPAR file. A typical command looks like this:
Line 13: Line 15:
 
Here and in this whole article the filename ''lpar.txt'' is used for the LPAR file, but any other filenames like ''lecode-param.txt'' are possible too. Read »[[#use|Use a LPAR file]]« for more details.
 
Here and in this whole article the filename ''lpar.txt'' is used for the LPAR file, but any other filenames like ''lecode-param.txt'' are possible too. Read »[[#use|Use a LPAR file]]« for more details.
  
A LPAR file is a text file that always begins with the magic »#LE-LPAR« as identification. It is divided into sections. At the moment 2 sections are supported, one for [[#param|General Parameters]] and one for [[#chatmsg|Chat Messages]]. So a LPAR file looks like this:
+
A LPAR file is a text file that always begins with the magic »#LE-LPAR« as identification. It is divided into sections. At the moment 2 sections are supported, one for [[#param|General Parameters]] and one for [[#chatmsg|Chat Messages]]. So a typical LPAR file looks like this:
 
<pre>
 
<pre>
 
#LE-LPAR
 
#LE-LPAR
  
 
[LECODE-PARAMETERS]
 
[LECODE-PARAMETERS]
 +
 +
# LIMIT-MODE will be available with Wiimms SZS Tools v2.16a.
 +
LIMIT-MODE = LE$PRODUCTIVE
  
 
ENGINE          = 10,60,30
 
ENGINE          = 10,60,30
Line 42: Line 47:
 
! style="min-width:5.5em" | Related<br>Option
 
! style="min-width:5.5em" | Related<br>Option
 
! Description
 
! Description
 +
|-
 +
| <tt>LIMIT-MODE</tt> || <tt>const</tt> || —
 +
| This mode defines the allowed values for the other settings:
 +
; LE$PRODUCTIVE : Limit the values to productive values.
 +
; LE$TESTING : Allow test values, but deny experimental values.
 +
; LE$EXPERIMENTAL : Allow all values.
 +
Values set by an option are never limited. See parameter descriptions for limitation details.
 +
 +
This parameter will be available as of [[Wiimms SZS Tools|Wiimms SZS Tools v2.16a]].
 
|-
 
|-
 
| <tt>ENGINE</tt> || <tt>int,int,int</tt> || <tt>--engine</tt>
 
| <tt>ENGINE</tt> || <tt>int,int,int</tt> || <tt>--engine</tt>
Line 50: Line 64:
 
|-
 
|-
 
| <tt>PERF-MONITOR</tt> || <tt>int</tt> || <tt>--perf-mon</tt>
 
| <tt>PERF-MONITOR</tt> || <tt>int</tt> || <tt>--perf-mon</tt>
| Enable (1) or disable (0) the performance monitor for [[Wii]] and [[Wii U]]. The special value 2 enables the it for [[Dolphin]] too, but it doesn't work correctly with Dolphin.
+
| Enable (1) or disable (0) the performance monitor for [[Wii]] and [[Wii U]]. Enabling is only possible if <tt>LIMIT-MODE=LE$TESTING</tt> or <tt>LIMIT-MODE=LE$EXPERIMENTAL</tt>. The special value 2 enables it for Dolphin too, but only if <tt>LIMIT-MODE=LE$EXPERIMENTAL</tt>. It doesn't work correctly with Dolphin.
 
|-
 
|-
 
| <tt>CUSTOM-TT</tt> || <tt>int</tt> || <tt>--custom-tt</tt>
 
| <tt>CUSTOM-TT</tt> || <tt>int</tt> || <tt>--custom-tt</tt>
Line 56: Line 70:
 
|-
 
|-
 
| <tt>XPFLAGS</tt> || <tt>int</tt> || <tt>--xpflags</tt>
 
| <tt>XPFLAGS</tt> || <tt>int</tt> || <tt>--xpflags</tt>
| Enable (1) or disable (0) support for [[extended presence flags]]. Disable it only for tests!
+
| Enable (1) or disable (0) support for [[extended presence flags]]. Disable it only for tests! If <tt>LIMIT-MODE=LE$PRODUCTIVE</tt>, <tt>XPFLAGS</tt> is always enabled.
 
|}
 
|}
  
Line 63: Line 77:
 
[[LE-CODE]] supports a special feature for chat messages in private rooms. If a message is send by the host and at least one guest is present, then some messages change the behavior of the game. Until LE-CODE build 16 the functions were hard coded to the messages (see [[#legacy|below]]). As of [[LE-CODE#b17|LE-CODE build 17]] (in development) and [[Wiimms SZS Tools|Wiimms SZS Tools v2.15]] each function can be assigned to any message, and also to more than 1 message.  
 
[[LE-CODE]] supports a special feature for chat messages in private rooms. If a message is send by the host and at least one guest is present, then some messages change the behavior of the game. Until LE-CODE build 16 the functions were hard coded to the messages (see [[#legacy|below]]). As of [[LE-CODE#b17|LE-CODE build 17]] (in development) and [[Wiimms SZS Tools|Wiimms SZS Tools v2.15]] each function can be assigned to any message, and also to more than 1 message.  
  
Only the definitions at the host side are relevant. The host stores the settings in an internal data structure. The data is send to all guests when starting a Grand Prix. This guarantees that late clients will be informed about the modified settings even if they never received the related chat messages. The settings are reset after finishing or aborting the Grand Prix.
+
Only the definitions at the host side are relevant. The host stores the settings in an internal data structure. The data is send to all guests when starting a Grand Prix. This guarantees that late clients will be informed about the modified settings even if they never received the related chat messages. The settings are reset after finishing or aborting the Grand Prix, or on message mode <tt>CHAT$RESET</tt>.
  
 
{|class="textbox grid alt" style="margin-top:1em"
 
{|class="textbox grid alt" style="margin-top:1em"
Line 70: Line 84:
 
! Category !! Parameter in<br>Wiimms SZS Tools !! Description
 
! Category !! Parameter in<br>Wiimms SZS Tools !! Description
 
|-
 
|-
! rowspan=2 | —
+
| rowspan=2 class=bg-gray1 | —
 
| <tt>CHAT$OFF</tt>
 
| <tt>CHAT$OFF</tt>
 
| Default mode: Message has no special function.
 
| Default mode: Message has no special function.
 
|-
 
|-
 
| <tt>CHAT$RESET</tt>
 
| <tt>CHAT$RESET</tt>
| Reset all special settings. ([[Wiimms SZS Tools|Wiimms SZS Tools ≥ v2.16]])
+
| Reset all special settings. ([[Wiimms SZS Tools|Wiimms SZS Tools ≥ v2.16a]])
 
|-
 
|-
! rowspan=2 | track
+
| rowspan=2 class=bg-green1 | track
 
| <tt>CHAT$TRACK_BY_HOST</tt>
 
| <tt>CHAT$TRACK_BY_HOST</tt>
 
| The host selects a tracks and wins the lottery. The track selection for guests is disabled.
 
| The host selects a tracks and wins the lottery. The track selection for guests is disabled.
Line 84: Line 98:
 
| Cancel <tt>CHAT$TRACK_BY_HOST</tt> and enable standard track lottery.
 
| Cancel <tt>CHAT$TRACK_BY_HOST</tt> and enable standard track lottery.
 
|-
 
|-
! rowspan=3 | vehicle
+
| rowspan=3 class=bg-green2 | vehicle
 
| <tt>CHAT$KARTS_ONLY</tt>
 
| <tt>CHAT$KARTS_ONLY</tt>
 
| Each player must select a kart.
 
| Each player must select a kart.
Line 94: Line 108:
 
| Cancel vehicle requirement.
 
| Cancel vehicle requirement.
 
|-
 
|-
! rowspan=4 | engine
+
| rowspan=4 class=bg-green1 | engine
 
| <tt>CHAT$USE_ENGINE_1</tt>
 
| <tt>CHAT$USE_ENGINE_1</tt>
 
| Force the first engine class. Usually this is 100cc. If mode 200cc is activated, then it is 150cc.
 
| Force the first engine class. Usually this is 100cc. If mode 200cc is activated, then it is 150cc.
Line 107: Line 121:
 
| Cancel engine selection.
 
| Cancel engine selection.
 
|-
 
|-
! n_races
+
| class=bg-green2 | n_races
 
| <tt>chat$n_races(N)</tt>
 
| <tt>chat$n_races(N)</tt>
| Define the number of races in the next Grand Prix. '''N''' is a number between 1 and 512 (inclusive). [[BMG]] messages from 6100 (first race) to 63ff (512th race) are reserved for race introductions at the moment. Later message 610c is planned for races ≥13.
+
| Define the number of races in the next Grand Prix. '''N''' is a number between 1 and 512 (inclusive). [[BMG]] messages from <tt>6100</tt> (first race) to <tt>63ff</tt> (512th race) are reserved for race announcements at the moment. Is is planned to use message <tt>610c</tt> for all races ≥13.
 
|}
 
|}
 
;Notes:
 
;Notes:
 
* Constants are written here with upper case letters and the function-call with lower case letters. Anyway, the text parser accepts constant, variable and function names in any case.
 
* Constants are written here with upper case letters and the function-call with lower case letters. Anyway, the text parser accepts constant, variable and function names in any case.
* Only messages by the host are relevant.
+
* Only messages send by the host are relevant.
 
* Only one option of each category can be active. A later messages cancels the previous message of the same category.
 
* Only one option of each category can be active. A later messages cancels the previous message of the same category.
  
Line 142: Line 156:
 
M80 = chat$n_races(10)
 
M80 = chat$n_races(10)
 
</pre>
 
</pre>
Then use option '''<tt>--lpar lpar.txt</tt>''' when patching the [[LE-CODE]] binary. The option will be available with the next release of [[Wiimms SZS Tools]].
+
Then use option '''<tt>--lpar lpar.txt</tt>''' when patching the [[LE-CODE]] binary.
  
 
The original game uses [[BMG]] messages <tt>582</tt> to <tt>585</tt> (hex) to announce the races. [[LE-CODE]] moved the messages to range <tt>6100</tt> to <tt>6109</tt> to support 10 races. [[MKW-Fun]] defines the following messages:
 
The original game uses [[BMG]] messages <tt>582</tt> to <tt>585</tt> (hex) to announce the races. [[LE-CODE]] moved the messages to range <tt>6100</tt> to <tt>6109</tt> to support 10 races. [[MKW-Fun]] defines the following messages:
Line 175: Line 189:
 
wlect lpar lecode-PAL.bin --lpar old-lpar.txt > lpar.txt
 
wlect lpar lecode-PAL.bin --lpar old-lpar.txt > lpar.txt
 
</pre>
 
</pre>
All examples create a file with name '''lpar.txt'''. After creation you can edit the file. It contains explanations about syntax and meanings. To suppress these explanations, use either option <tt>--no-header</tt> (<tt>-H</tt>) or option <tt>--brief</tt> (<tt>-B</tt>). Both options are fully available as of [[Wiimms SZS Tools|Wiimms SZS Tools v2.16]].
+
All examples create a file with name '''lpar.txt'''. After creation you can edit the file. It contains explanations about syntax and meanings. To suppress these explanations, use either option <tt>--no-header</tt> (<tt>-H</tt>) or option <tt>--brief</tt> (<tt>-B</tt>). Both options are fully available as of [[Wiimms SZS Tools|Wiimms SZS Tools v2.16a]].
  
 
After creation you can edit a LPAR file with any text editor.
 
After creation you can edit a LPAR file with any text editor.

Revision as of 09:20, 8 April 2020

LPAR (LE-CODE Parameters) is a text file format defined by Wiimm. It is used to define parameters for LE-CODE.


Introduction

A LE-CODE binary file (e.g. lecode-PAL.bin) contains a binary section with magic »LPAR«. It defines how the LE-CODE executor works. Up to Wiimms SZS Tools v2.14a, LE-CODE parameters had to be set via options when patching. As of v2.15a there is also the possibility to define the parameters by a LPAR file. So a LPAR file is a text version of the binary LPAR section. Options are still accepted and have higher priority than a LPAR file.

This whole article based on Wiimms SZS Tool v2.15a or later. Some paramters will be available with release of v2.16a, see remarks.

Using a LPAR file is recommended, because some parameters can only be set by a LPAR file. A typical command looks like this:

wlect patch lecode-PAL.bin --lpar lpar.txt  ....

Here and in this whole article the filename lpar.txt is used for the LPAR file, but any other filenames like lecode-param.txt are possible too. Read »Use a LPAR file« for more details.

A LPAR file is a text file that always begins with the magic »#LE-LPAR« as identification. It is divided into sections. At the moment 2 sections are supported, one for General Parameters and one for Chat Messages. So a typical LPAR file looks like this:

#LE-LPAR

[LECODE-PARAMETERS]

# LIMIT-MODE will be available with Wiimms SZS Tools v2.16a.
LIMIT-MODE	= LE$PRODUCTIVE

ENGINE          = 10,60,30
ENABLE-200CC    = 0
PERF-MONITOR    = 0
CUSTOM-TT       = 0
XPFLAGS         = 1


[CHAT-MESSAGE-MODES]
# ....

Section »Create a LPAR file« explains how to create and modify a LPAR file.

Sections

General Parameters [LECODE-PARAMETERS]

This section defines general LE-CODE parameters. The corresponding options have a higher priority. Remove or comment-out a parameter if its value should not be changed. All values will be limited to the allowed ranges.

General Parameters
Parameter
Name
Value Related
Option
Description
LIMIT-MODE const This mode defines the allowed values for the other settings:
LE$PRODUCTIVE
Limit the values to productive values.
LE$TESTING
Allow test values, but deny experimental values.
LE$EXPERIMENTAL
Allow all values.

Values set by an option are never limited. See parameter descriptions for limitation details.

This parameter will be available as of Wiimms SZS Tools v2.16a.

ENGINE int,int,int --engine Define probabilities for engine classes. A list for »100cc,150cc,mirror« is expected. If 200cc is enabled, the values are for »150cc,200cc,mirror«. Any numbers are accepted. They are normalized to get a total of 100 percent. Use »0,1,0« to force 150cc. Use »0,0,0« to reset to Nintendos VR based choice.
ENABLE-200CC int --200cc Enable (1) or disable (0) 200cc support. LE-CODE hasn't implemented this feature yet!
PERF-MONITOR int --perf-mon Enable (1) or disable (0) the performance monitor for Wii and Wii U. Enabling is only possible if LIMIT-MODE=LE$TESTING or LIMIT-MODE=LE$EXPERIMENTAL. The special value 2 enables it for Dolphin too, but only if LIMIT-MODE=LE$EXPERIMENTAL. It doesn't work correctly with Dolphin.
CUSTOM-TT int --custom-tt Enable (1) or disable (0) time trial for custom tracks.
XPFLAGS int --xpflags Enable (1) or disable (0) support for extended presence flags. Disable it only for tests! If LIMIT-MODE=LE$PRODUCTIVE, XPFLAGS is always enabled.

Chat Messages [CHAT-MESSAGE-MODES]

LE-CODE supports a special feature for chat messages in private rooms. If a message is send by the host and at least one guest is present, then some messages change the behavior of the game. Until LE-CODE build 16 the functions were hard coded to the messages (see below). As of LE-CODE build 17 (in development) and Wiimms SZS Tools v2.15 each function can be assigned to any message, and also to more than 1 message.

Only the definitions at the host side are relevant. The host stores the settings in an internal data structure. The data is send to all guests when starting a Grand Prix. This guarantees that late clients will be informed about the modified settings even if they never received the related chat messages. The settings are reset after finishing or aborting the Grand Prix, or on message mode CHAT$RESET.

List of available functions
Category Parameter in
Wiimms SZS Tools
Description
CHAT$OFF Default mode: Message has no special function.
CHAT$RESET Reset all special settings. (Wiimms SZS Tools ≥ v2.16a)
track CHAT$TRACK_BY_HOST The host selects a tracks and wins the lottery. The track selection for guests is disabled.
CHAT$ANY_TRACK Cancel CHAT$TRACK_BY_HOST and enable standard track lottery.
vehicle CHAT$KARTS_ONLY Each player must select a kart.
CHAT$BIKES_ONLY Each player must select a bike.
CHAT$ANY_VEHICLE Cancel vehicle requirement.
engine CHAT$USE_ENGINE_1 Force the first engine class. Usually this is 100cc. If mode 200cc is activated, then it is 150cc.
CHAT$USE_ENGINE_2 Force the second engine class. Usually this is 150cc. If mode 200cc is activated, then it is 200cc.
CHAT$USE_ENGINE_3 Force the third engine class. Usually this is 150cc-mirror. If mode 200cc is activated, then it is 200cc-mirror.
CHAT$RESET_ENGINE Cancel engine selection.
n_races chat$n_races(N) Define the number of races in the next Grand Prix. N is a number between 1 and 512 (inclusive). BMG messages from 6100 (first race) to 63ff (512th race) are reserved for race announcements at the moment. Is is planned to use message 610c for all races ≥13.
Notes
  • Constants are written here with upper case letters and the function-call with lower case letters. Anyway, the text parser accepts constant, variable and function names in any case.
  • Only messages send by the host are relevant.
  • Only one option of each category can be active. A later messages cancels the previous message of the same category.

Legacy settings (old MKW-Fun settings)

Beginning with LE-CODE build 17, no chat messages has a special functionality by default. Each special functionality must be defined explicitly. If you want to use the old behavior defined for MKW-Fun create a file (e.g. with name lpar.txt):

#LE-LPAR
[CHAT-MESSAGE-MODES]
@legacy = 1

This is equivalent to:

#LE-LPAR
[CHAT-MESSAGE-MODES]
M65 = CHAT$ANY_VEHICLE
M69 = CHAT$KARTS_ONLY
M70 = CHAT$BIKES_ONLY
M71 = CHAT$TRACK_BY_HOST
M72 = CHAT$ANY_TRACK
M73 = chat$n_races(1)
M74 = chat$n_races(2)
M75 = chat$n_races(3)
M76 = chat$n_races(4)
M77 = chat$n_races(5)
M78 = chat$n_races(6)
M79 = chat$n_races(8)
M80 = chat$n_races(10)

Then use option --lpar lpar.txt when patching the LE-CODE binary.

The original game uses BMG messages 582 to 585 (hex) to announce the races. LE-CODE moved the messages to range 6100 to 6109 to support 10 races. MKW-Fun defines the following messages:

6100 = \z{802,110002}\z{802,110000} - 1st Race (\z{a02,1000000000} players)
6101 = \z{802,110002}\z{802,110000} - 2nd Race (\z{a02,1000000000} players)
6102 = \z{802,110002}\z{802,110000} - 3rd Race (\z{a02,1000000000} players)
6103 = \z{802,110002}\z{802,110000} - 4th Race (\z{a02,1000000000} players)
6104 = \z{802,110002}\z{802,110000} - 5th Race (\z{a02,1000000000} players)
6105 = \z{802,110002}\z{802,110000} - 6th Race (\z{a02,1000000000} players)
6106 = \z{802,110002}\z{802,110000} - 7th Race (\z{a02,1000000000} players)
6107 = \z{802,110002}\z{802,110000} - 8th Race (\z{a02,1000000000} players)
6108 = \z{802,110002}\z{802,110000} - 9th Race (\z{a02,1000000000} players)
6109 = \z{802,110002}\z{802,110000} - 10th Race (\z{a02,1000000000} players)

Manage LPAR files

Create a LPAR file

A LPAR file can be created from scratch, by reading an old LPAR file or by reading a LE-CODE binary file:

# create LPAR from scratch
wlect create lpar > lpar.txt

# create updated LPAR after reading old LPAR file
wlect create lpar --lpar old-lpar.txt > lpar.txt

# create LPAR by reading a LE-CODE binary file
wlect lpar lecode-PAL.bin > lpar.txt

# create LPAR by LE-CODE binary file and update by old LPAR file
wlect lpar lecode-PAL.bin --lpar old-lpar.txt > lpar.txt

All examples create a file with name lpar.txt. After creation you can edit the file. It contains explanations about syntax and meanings. To suppress these explanations, use either option --no-header (-H) or option --brief (-B). Both options are fully available as of Wiimms SZS Tools v2.16a.

After creation you can edit a LPAR file with any text editor.

Use a LPAR file

A LPAR file is included by option --lpar FILE. Use it with command PATCH when defining the tracks:

wlect patch lecode-PAL.bin  --le-define DEFINITION  --lpar lpar.txt

It is also possible to change the parameters of a LE-CODE binary without definition file:

wlect patch lecode-PAL.bin  --lpar lpar.txt