100 Coin Star
100 Coin Stars or 100c Stars are stars that appear after collecting 100 coins in all of the main courses. They differ from all other stars in the main courses in that they appear directly above Mario instead of a fixed location. They appear in no other courses, even if one manages to collect 100 coins. 100 Coin Stars are unique in that when Mario collects one, he is not ejected from the current course. Instead, a textbox appears, and Mario is allowed to continue exploring the course.
Coin Count vs. Coin Display
The game uses two different variables to track Mario's coins: the coin count and the coin display. The former is updated the instant Mario collects a coin, while the latter is used to display the coin count on-screen.
The coin count is set to 0 when the game starts and when entering a level. When exiting a level, the coin count is not reset, and examining the game's memory reveals that it continues to be updated when coins are collected. A 100 Coin Star appears when this variable equals 100, so long as Mario is in a main course.
The coin display will increment by 1 until it catches up with the coin count. In particular, the coin display only increments when it is less than the coin count and the global timer is odd. Using this method, the programmers intended the coin display to update once every two frames. However, by manipulating the global timer through pause buffering, one can prevent the coin display from updating altogether.
Both the coin count and the coin display are stored as 16-bit signed shorts, so their values can range between -32768 and 32767 inclusive. In all versions of the game after the original Japanese N64 version, the coin count is capped at 999 on every frame. However, in the Japanese version, a bug is present in the game's code that sets the life counter to 999 when the coin counter exceeds 999:
// On every frame... if (lives > 100) lives = 100; if (coins > 999) lives = 999; //! this should use "coins" instead of "lives"
The effects of this bug are twofold: the coin count can exceed 999, and the lives count is erroneously set to 999.
Because the coin count can exceed 999, using infinite coin glitches, it can reach 32767. Due to signed integer overflow, if one more coin is collected, the coin counter would become -32768. Collecting coins will continue to increase this value. Note that the coin display would remain 32767, for it only updates when it is less than the coin count. If one collects 32868 more coins, or 65636 coins in total, the coin counter will equal 100, spawning another 100 Coin Star. Although this star will appear yellow, collecting it will not increase the game's star count from 120 to 121 or more. This is because each star is represented in memory by 1 bit, and when a star is collected, the game uses the bitwise OR operator to store this information.
Since Mario's life count is stored as an 8-bit signed byte, when it is set to 999, the upper byte is discarded and the number that is stored is -25. Since the above code runs every frame, Mario's life count is constantly set to -25. This means collecting |1-Ups will not change this value. Since Mario's coin count is not reset when he exits a level, losing a life will also not change the life count until another main course is entered. However, once Mario's coin count becomes negative, the life counter can be modified again.
Because 100 coin stars can spawn anywhere you can collect a coin, they are useful for various challenges.
A Button Challenge
When Mario is in freefall, if he is close enough to an edge, he will perform a ledge-grab. In doing so, his height will be updated to the height of the ledge above him, awarding him a small height bonus. Since Mario cannot ledge-grab after dive recovering, dive recovering near a ledge in the A Button Challenge forfeits this height bonus. In certain scenarios, one can use the Star Dance Clip (SDC) to gain this height bonus without pressing A. When Mario collects a star, his action is set to one that allows him to perform a ledge-grab, regardless of his previous action. If he is close enough to a ledge, he is placed on top of it before doing his star dance animation. Since 100 Coin Stars do not eject Mario from the course, players can use this height bonus to collect stars without pressing A. The Star Dance Clip can be used in combination with Vertical Speed Conservation, which puts Mario into a free-fall state, by ground-pounding to gain height before collecting a 100 Coin Star.
In the A Button Challenge, the SDC is used:
- as an alternative strat to collect To the Top of the Fortress 0x on the Japanese version
- to get to the mainland on the tiny island of Tiny-Huge Island 0x, saving 5 A presses
- to get to the cogs 0x in Tick-Tock Clock
- to go to Hazy-Maze Cave 0x
among other A press saves.