Coin limit: Difference between revisions

m
no edit summary
mNo edit summary
 
Line 6: Line 6:
==The 999 coin limit==
==The 999 coin limit==
The limit is intentionally put in by the programmers to prevent the game to count up coins greater than 999:
The limit is intentionally put in by the programmers to prevent the game to count up coins greater than 999:
if (gMarioState->numCoins > 999) {
 
    gMarioState->numCoins = 999;
<syntaxhighlight lang="c">
}
if (gMarioState->numCoins > 999) {
    gMarioState->numCoins = 999;
}
</syntaxhighlight>
 
When Mario reaches the 999 coin limit, the coins are no longer counted and collecting a coin only makes noise if the value of the global timer is odd.
When Mario reaches the 999 coin limit, the coins are no longer counted and collecting a coin only makes noise if the value of the global timer is odd.
==The 255 coin limit==
==The 255 coin limit==
Line 24: Line 28:
In the Japanese version, there is no coin limit within the courses. When the coin counter reaches a value of 1,000, the game runs a few lines of code wherein there is a typo:
In the Japanese version, there is no coin limit within the courses. When the coin counter reaches a value of 1,000, the game runs a few lines of code wherein there is a typo:


 
<syntaxhighlight lang="c" highlight="2">
if (gMarioState->numCoins > 999) {
if (gMarioState->numCoins > 999) {
    gMarioState->numLives = (s8) 999; //! Wrong variable
    gMarioState->numLives = (s8) 999; //! Wrong variable
}
}
</syntaxhighlight>


This should be the following:
This should be the following:


if (gMarioState->numCoins > 999) {
<syntaxhighlight lang="c" highlight="2">
    gMarioState->numCoins = 999;
if (gMarioState->numCoins > 999) {
}
    gMarioState->numCoins = 999;
}
</syntaxhighlight>


Because the lives counter is a signed short, the value of 999 overflows to -25. This is displayed in the HUD as "M25". (The "M" presumably means "minus".)
Because the lives counter is a signed short, the value of 999 overflows to -25. This is displayed in the HUD as "M25". (The "M" presumably means "minus".)
confirmed_editors
11

edits