Wii VC Round-to-Zero
Wii VC Round-to-Zero refers to an emulation inaccuracy in the Wii Virtual Console (Wii VC). When converting a double precision floating point number (a "double") to a single precision floating point number (a "float"), the N64 typically uses the round-to-nearest rounding mode. This means that if the double is not exactly equal to a float, it will round up or down to the float that is closest in value to the original number. While this behavior is accurately emulated by most emulators and the Wii U VC, the Wii VC instead uses the round-to-zero mode. This mode will always round the double up if it is negative, and round it down if it is positive.
While the programmers did not intentionally use doubles very often, favoring single precision floats instead, they occasionally used them accidentally.
y -= sins(t) * 0.58; t += 0x100;
In the above code sample,
sins(t) are both single precision floats. However, in C, the numeric literal
0.58 is a double since it lacks a trailing
f, as in
0.58f. This causes the expression to evaluate to a double, which is then converted to a float before being stored in
y. Examples such as this one arise in many places in the game's source code, and over time they result in large discrepancies between the N64 and Wii VC versions of the game. For this reason, TASes produced for one of these platforms cannot generally be played back on the other without desync.
The example given above is taken from the code controlling the oscillation of the platforms at the beginning of Bowser in the Fire Sea. Using the N64's rounding mode, the
y variable, which represents the platform's height, will repeatedly return to its original value and continue oscillating with fixed maximum height. Even though each double to single conversion produces a small amount of error, this error balances out over the course of the platform's cycle. On the Wii VC, however, the error always accumulates in the same direction (upward if the platform is below y = 0, and downward if the platform is above y = 0), and so the platform slowly drifts in the vertical direction. This is known as Wii VC platform drift.
From its starting position of y=-3065 til it reaches y=-2048, this platform rises 254 times by 1/4096th of a unit for each 256 frame cycle, 127 times as it goes up, 127 times as it goes down (at the peak and bottom of the oscillation cycle, the platform stays still so no rounding occurs). So doing the math, 127/128*1/4096units*30frames*60seconds*60minutes, we get that the platform drifts by ~13.0806cm/h.
Once it passes y=-2048, the platform halves in rising speed: ~6.5403cm/h. The platform continues to halve in speed as it passes through y=-1024, y=-512, y=-256, and all other 2^n boundaries til it comes to a halt near y=0.
As it passes through a 2^n boundary, its behavior becomes complex. Throughout its up-down oscillation cycle, the platform is sometimes past the 2^n boundary and sometimes not. The overall speed decrease as the platform's average height passes through the 2^n boundary is represented by a arctangent function: the platform suddenly slows down, then decelerates before it accelerates back to its initial acceleration again, before completely stopping at a constant speed.
The platforms at the beginning of the level are below y = 0, and so they gradually rise upward. Over the course of several days, they are high enough they can be used to reach the elevator past the pole, which previously required one A press to get past. It takes eight days for the platform to reach high enough for a dive recover to land in the elevator shaft, but using VSC with a lava boost requires only three days.
After several failed attempts by various players, the A press save in Bowser in the Fire Sea was console verified RTA on 20 Jun 2018 by ethanwhitesm64. Six days later, pannenkoek2012 TASed the red coin star in zero A presses using a modified N64 emulator that replicated the rounding error.
No other console or emulator is known to reproduce this rounding inaccuracy, including the Wii U VC. At the time of its discovery, the bug did not occur on the Dolphin emulator, but has since been corrected.
No other objects are known to have similarly exploitable behavior, though the rounding bug does cause many discrepancies between the original and Wii VC versions of the game, including slightly different surface normals.