Difference between revisions of "Presence flag"

From Custom Mario Kart
Jump to navigation Jump to search
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{KMP}}
 
{{KMP}}
The '''presence flags''' is a 16 bit parameter of [[KMP#GOBJ|KMP/GOBJ]] and defines for which number of players an object exists (is visible and active).
 
  
 +
== Overview ==
 +
'''Presence flags''' are 16-bit parameters of the [[KMP#GOBJ|GOBJ]] section in [[KMP]] files and define when objects load for a certain amount of players.
  
__TOC__
+
== Wrong First Analysis ==
 
+
The first analysis of these flags were derived from [[Filesystem/Race/Course/koopa_course.szs/course.0|/Race/Course/koopa_course.szs/course.0]]:
== First and wrong interpretation ==
 
 
 
The first interpretation of the flags were derived from [[Filesystem/Race/Course/koopa_course.szs/course.0|/Race/Course/koopa_course.szs/course.0]]:
 
 
<pre>
 
<pre>
 
<ObjDefine>
 
<ObjDefine>
Line 19: Line 17:
 
</ObjDefine>
 
</ObjDefine>
 
</pre>
 
</pre>
Because a usual presence flag has the value of 0x3f, the first (and wrong) interpretation was:
 
  
{| class="textbox grid"
+
As the usual presence flag has a value of 0x3f, the first analysis was wrong:
! Bit<br/>Number !! Hex<br/>Value !! First and wrong interpretation
+
{| class="textbox grid sortable center"
|-
+
|+ First Analysis
| align=center | 0 || align=center | 0x01 || Offline single player and time trials.
+
! Bit number
 +
! Hex value
 +
! Enables during/with
 
|-
 
|-
| align=center | 1 || align=center | 0x02 || Offline 2 players.
+
| 0
 +
| 0x01
 +
| Offline single player<br>Time Trials
 +
|- class=alt
 +
| 1
 +
| 0x02
 +
| Offline two players
 
|-
 
|-
| align=center | 2 || align=center | 0x04 || Offline 3 or 4 players.
+
| 2
 +
| 0x04
 +
| Offline three or four players
 +
|- class=alt
 +
| 3
 +
| 0x08
 +
| Online single player
 
|-
 
|-
| align=center | 3 || align=center | 0x08 || Online single player.
+
| 4
|-
+
| 0x10
| align=center | 4 || align=center | 0x10 || Online 2 players.
+
| Online two players
|-
+
|- class=alt
| align=center | 5 || align=center | 0x20 || Online 3 or 4 players.
+
| 5
 +
| 0x20
 +
| Online three or four players
 
|}
 
|}
  
== Correct interpretation ==
+
== Correct Second Analysis ==
 +
In 2016, [[Wiimm]] tested all 16 possible bits of the flags and discovered only the three least significant bits are used and others get ignored:
  
In 2016, [[Wiimm]] tested all 16 possible bits of the flags and found a new interpretation: '''Only the 3 least significant bits are used''', all other are ignored:
+
{| class="textbox grid sortable center"
 
+
|+ Second Analysis
{| class="textbox grid"
+
! Bit number
! Bit<br/>Number !! Hex<br/>Value !! Correct interpretation
+
! Hex value
|-
+
! Enables during/with
| align=center | 0 || align=center | 0x01 || Single player (offline and online) and time trials.
 
|-
 
| align=center | 1 || align=center | 0x02 || 2 players, offline and online.
 
|-
 
| align=center | 2 || align=center | 0x04 || 3 or 4 players, offline.
 
 
|-
 
|-
| align=center | 3 || align=center | 0x08 || ''no meaning (ignored)''
+
| 0
 +
| 0x01
 +
| Offline or online single player<br>Time Trials
 +
|- class=alt
 +
| 1
 +
| 0x02
 +
| Offline or online two players
 
|-
 
|-
| align=center | 4 || align=center | 0x10 || ''no meaning (ignored)''
+
| 2
 +
| 0x04
 +
| Offline three or four players
 +
|- class=alt
 +
| 3
 +
| 0x08
 +
| &mdash;
 
|-
 
|-
| align=center | 5 || align=center | 0x20 || ''no meaning (ignored)''
+
| 4
 +
| 0x10
 +
| &mdash;
 +
|- class=alt
 +
| 5
 +
| 0x20
 +
| &mdash;
 
|}
 
|}
  
It is important to hide [[object]]s for ''2 players mode'' only, if they are decorative. Otherwise online players at split-screen will use another track than single players!<br/>
+
It is important to note that [[object]]s should be disabled for two or more players if they are only decorative. When this is not the case, online players using split-screen will get an advantage because objects that affect gameplay have been disabled. To avoid this, simply set bit 0 and 1 to equal values.
'''In other words: For objects with impact on the gameplay, bit 0 and bit 1 must be equal!'''
 
 
 
=== Typical values ===
 
  
The following table shows typical values. The second column (''Same as'') reduces the value to the 3 least significant bits:
+
=== Functions of Values ===
 +
The following table shows the effect certain values have. The second column (''Same as'') reduces the value to the three least significant bits:
  
{| class="textbox grid"
+
{| class="textbox grid sortable center"
! Value !! Same as !! Description !! Usage
+
|+ Functions of Values
 +
! Value
 +
! Same as
 +
! Function
 +
! Usage
 
|-
 
|-
| align=center | 0x00 || align=center | 0
+
| 0x00
| Object is always disabled. It's like ''not defined''.
+
| 0
| This value is used by custom track authors to disable objects temporary.
+
| Object is always disabled.
 +
| Can be used to disable objects temporarily.
 +
|- class=alt
 +
| 0x09
 +
| rowspan=2| 1
 +
| rowspan=2| Object is only enabled for online or offline single player. Do not use this value for objects with gameplay impact.
 +
| rowspan=2| Can be used to reduce the [[Slow Motion Bug]] when using Multiplayer split-screen. This value is only used for decorative objects, like {{obj-ref|0x13e|WLscreenGC}} and {{obj-ref|0x2c2|dkmonitor}}.
 +
|- class=alt
 +
| 0x39
 
|-
 
|-
| align=center | 0x09 || align=center rowspan=2 | 1
+
| 0x3f
| rowspan=2 | Object is only enabled for single player mode (offline and online), but not for 2 or more players.
+
| 7
'''Don't use it for objects with impact on the gameplay!'''
 
| This value is used by Nintendo to reduce [[Slow Motion Bug|slow motion bug]] at multiplayer split screen. This value is only used for decorative objects like {{obj-ref|WLscreenGC}}, but never for objects with impact on the gameplay.
 
|-
 
| align=center | 0x39
 
| This value is used by many custom track authors to reduce [[Slow Motion Bug|slow motion bug]].
 
|-
 
| align=center | 0x3f || align=center | 7
 
 
| Object is always enabled.
 
| Object is always enabled.
| Standard value.
+
| The standard value.
 
|}
 
|}
  
== Alternative file *_d.szs ==
+
== Alternative Multiplayer Files ==
 +
Each track file with the name '''*.szs''' has an alternative file with the name '''*_d.szs''', which is loaded for two, three and four players, but only offline. Theoretically, it can be a totally different track. The idea is to allow fewer and simpler animations to reduce the [[Slow Motion Bug]], but it does not help for online racing.
  
For each track file with the name '''NAME.szs''' exists an alternative file with the name '''NAME_d.szs'''. This _d file is loaded for 2, 3 and 4 players, but only offline. Theorically it can be a total different track. The idea is to allow easier and less animations to reduce the [[Slow Motion Bug|slow motion bug]], but it doesn't help for online racing.
+
== Extended Presence Flags ==
 +
As of [[LE-CODE]] build 15 (2020-02-14), full implementation of [[extended presence flags]] has been completed.
  
 +
[[Category:Custom Track Tutorial]]
 +
[[Category:Object]]
 
[[Category:Technical Information]]
 
[[Category:Technical Information]]
[[Category:Custom Track Tutorial]]
 
[[category:Object]]
 

Latest revision as of 15:09, 21 November 2021

Overview

Presence flags are 16-bit parameters of the GOBJ section in KMP files and define when objects load for a certain amount of players.

Wrong First Analysis

The first analysis of these flags were derived from /Race/Course/koopa_course.szs/course.0:

<ObjDefine>
    ...
    format    sepa1_SW  user_data  1  Bool  1
    format    sepa2_SW  user_data  1  Bool  1
    format    sepa4_SW  user_data  1  Bool  1
    format    sepaW1_SW  user_data  1  Bool  1
    format    sepaW2_SW  user_data  1  Bool  1
    format    sepaW4_SW  user_data  1  Bool  1
</ObjDefine>

As the usual presence flag has a value of 0x3f, the first analysis was wrong:

First Analysis
Bit number Hex value Enables during/with
0 0x01 Offline single player
Time Trials
1 0x02 Offline two players
2 0x04 Offline three or four players
3 0x08 Online single player
4 0x10 Online two players
5 0x20 Online three or four players

Correct Second Analysis

In 2016, Wiimm tested all 16 possible bits of the flags and discovered only the three least significant bits are used and others get ignored:

Second Analysis
Bit number Hex value Enables during/with
0 0x01 Offline or online single player
Time Trials
1 0x02 Offline or online two players
2 0x04 Offline three or four players
3 0x08
4 0x10
5 0x20

It is important to note that objects should be disabled for two or more players if they are only decorative. When this is not the case, online players using split-screen will get an advantage because objects that affect gameplay have been disabled. To avoid this, simply set bit 0 and 1 to equal values.

Functions of Values

The following table shows the effect certain values have. The second column (Same as) reduces the value to the three least significant bits:

Functions of Values
Value Same as Function Usage
0x00 0 Object is always disabled. Can be used to disable objects temporarily.
0x09 1 Object is only enabled for online or offline single player. Do not use this value for objects with gameplay impact. Can be used to reduce the Slow Motion Bug when using Multiplayer split-screen. This value is only used for decorative objects, like WLscreenGC and dkmonitor.
0x39
0x3f 7 Object is always enabled. The standard value.

Alternative Multiplayer Files

Each track file with the name *.szs has an alternative file with the name *_d.szs, which is loaded for two, three and four players, but only offline. Theoretically, it can be a totally different track. The idea is to allow fewer and simpler animations to reduce the Slow Motion Bug, but it does not help for online racing.

Extended Presence Flags

As of LE-CODE build 15 (2020-02-14), full implementation of extended presence flags has been completed.