For a long time, this strategy for this section has been unchanged:
-Perform a glitchy ledge grab to get up the spiral staircase
-SBLJ on the stairs
-Wall hug across from the 50 star door staircase (by WDW painting) and reflect speed with C^
-Use 50 Star Door rejection text to store speed
-Convert stored speed by using the Z+C^->Punch method, known here as "Clock Punch" because it aims for a corner of the clock, so that Mario doesn't punch a wall and lose his speed.
The method is fast, but not quite ideal, because punching takes 16 frames, and the 50 Star Door text is longer than some other text sources in the map. A couple years ago, snark tried to get a Z+C^->Jumpkick method
working, but couldn't get one that was faster than Clock Punch. Tyler Kehne and SilentSlayers also discussed and tested using the sign near the 50 Star stairs to convert speed, but that proved fruitless. So it didn't seem likely that this section would see any improvement. However, when sonicpacker was redoing the section, he had trouble replicating the most optimal Clock Punch that had been used in previous runs. Tyler also tried to replicate it with no success. Frustrated, Tyler decided to fully understand what made the Clock Punch work, in order to know what would make it unsuccessful. As it turns out, the mechanism is quite interesting.
The first important thing to understand is what conditions will cause Mario to punch a wall. When Mario punches a wall, he recoils backwards and loses his forwards speed, so it is necessary to avoid this. Surprisingly, the wall punch check isn't explicitly based on Mario's angle relative to the wall. Instead, the game performs a wall collision test on the point 50 units directly in front of Mario. If this point is within 5 units of a wall, then Mario's punch connects with it. The diagram below visualizes this. You can see that Mario's angle is implicitly involved, but the limit for how closely Mario must face the wall depends on the distance.
So, by considering the geometry, you can see that in order for a wall punch to occur, cos(Δθ) ≥ (d - 5) / 50, where Δθ is the difference between Mario's facing angle and the angle normal (i.e. perpindicular) towards the wall, and d is Mario's distance from the wall. A few things to note from this:
-You can calculate a critical distance D if you know Δθ, i.e. D = 5 + 50 * cos(Δθ). If Mario is within D then a wall punch will occur.
-If Mario is more than 55 units away from the wall, the punch won't connect no matter what Δθ is.
-If Mario is right up against the wall, i.e. d = 50, the critical angle Δθ = 4704 (2-byte angle, eq. to .451 rad or 25.8°)
-It's possible to punch the wall even when Mario is behind it, if you space it correctly. Mario won't clip through it and will recoil back as normal.
The second thing to be aware of is when the wall punch test occurs relative to the other important Mario physics calculations. It happens as follows:
1. Initial Collision Test
- Includes wall collision test, at Mario's position, that will push him 50 units away from any nearby walls.
2. Wall Punch Test
3. Quarterframe Movement
- Mario's main movement calculations happen here. His speed is divided into 4 and applied in 4 "quarterframes".
- Each qframe includes a wall collision test, but not at Mario's position. It tests the position Mario is targeting, which is essentially Speed / 4 units in front of Mario.
- If the target position is in a wall that is being tested for collision, the wall will push the target position outward to the edge of the wall (50 units away). Subsequent collision tests with other walls on that qframe will use the new target position, not the original one. So the priority of which walls are tested first can matter.
A successful Clock Punch looks like this:
Only 2 qframes are shown in Step 2 for simplicity. Note that Wall B has priority over Wall A. Mario's target position during qframe movement is deep into Wall A, and since Wall B is tested first, it doesn't register a collision. Wall A then pushes the target position outward. If Wall A had priority, then Wall B would be able to push the target position away as well, which would prevent Mario from being able to move so far to the right of Wall A, and would make the clock punch impossible without a much larger Δθ.
Once the mechanism was understood, it was possible to calculate the actual limitations of the clock punch. In order for Wall B to push Mario past the critical distance for the Wall A wall punch, Mario has to move far enough to the right in Step 2. Well, how far is far enough? Let's look at the math:
To calculate how Wall B collision affects Mario's position in step 3, do the following:
Distance from wall: d = n ⋅ p + negdot
If d < 50, p += (50 - d) * n
-n is the unit normal vector of the wall. It points perpendicularly away from the wall and has a length of 1.
-p is Mario's position
-"⋅" indicates a dot product
-"negdot" is a property of the collision triangle (walls, floors, ceilings) data structure. It is equal to the negative of the dot product of n and any point on the wall. It represents the distance of the wall from the origin.
Wall A happens to align with the Z axis, which makes the calculation a bit easier, since we only have to consider Mario's how Mario's Z position is affected by Step 3.
Wall A stats:
- X = 7130
- 50 units in front: X = 7080
Wall B stats:
- n (X,Z) = (0.8996062875, -0.4367020726)
- negdot = 3113.685791
Putting it all together:
pNew = p + (50 - d) * n = p + (50 - n ⋅ p - negdot) * n
zNew = z + (50 - n_x * x - n_z * z - negdot) * n_z
zNew = 7080 + (50 - 0.8996062875 * x - -0.4367020726 * 7080 - 3113.685791) * -0.4367020726
zNew = 7067.7 + 0.39286 * x
Remember, to avoid the wall punch, Mario must be farther than the critical distance away from Wall A.
7130 - zNew ≥ 5 + 50 * cos(Δθ)
So we can now calculate the x position Mario needs to reach in Step 2, based on Mario's facing angle:
7130 - (7067.7 + 0.39286 * xMin) ≥ 5 + 50 * cos(Δθ)
xMin ≤ 145.853 - 127.272 * cos(Δθ)
But we're not done yet. In order to calculate Mario's minimum speed, we need to know how Step 3 affects Mario's x position when Mario reaches xMin. The difference of those coordinates determines what Mario's minimum X speed, and therefore his H speed, must be on subsequent frames.
xNew ≥ xMin + (50 - n_x * xMin - n_z * z - negdot) * n_x
xNew ≥ xMin + (50 - 0.8996062875 * xMin - -0.4367020726 * 7080 - 3113.685791) * 0.8996062875
xNew ≥ 25.3373 + 0.190709 * xMin
xSpdMin = xNew - xMin = 25.3373 + 0.190709 * xMin - xMin = 25.3373 - 0.809291 * xMin
xSpdMin = 25.3373 - 0.809291 * (145.853 - 127.272 * cos(Δθ
xSpdMin = 103 * (cos(Δθ) - 0.9)
hSpdMin = xSpdMin / sin(Δθ) (Note that -θ and Δθ are actually the same here, because Wall A is aligned with the Z axis, so Δθ = abs(θ - 0.
hSpdMin = 103 * (cos(Δθ) - 0.9) / sin(Δθ)
Bingo! We have the minimum H Speed. And the max H Speed is easy. It's just the minimum speed that will cause Mario to clip through wall A. To do that, he has to move 100 units in the Z direction on one qframe, or 400 per frame. So,
hSpdMax = 400 / cos(Δθ) (Since Δθ is small, this is barely going to be more than 400.)
Now, let's find out how low θ can go. A lower θ means you don't have to strain as much after the clock punch, so you can commit more input to gaining speed.
| θ|| Minimum Hor. Speed|| Maximum Hor. Speed|| Possible?|
| -320 (previous best)|| 334.2003515|| 400.1883216|| YES|
| -304|| 351.9466194|| 400.1699538|| YES|
| -288|| 371.6562061|| 400.1525291|| YES|
| -272 (used in the run)|| 393.67558|| 400.1360476|| YES|
| -256|| 418.4378266|| 400.1205088|| NO|
The viability of -272 isn't obvious. At first glance it seems definitely possible, because the minimum speed is less than the negative speed. However, the clock punch occurs over about a dozen frames, and Mario loses 1 unit of speed each frame. Since he has to be at no more than 400.1360476 upon reaching the clock, his speed goes below 393.67558 well before the punch finishes. Luckily, Mario's punch can only connect with the wall for part of the animation, and when that "active" part of the animation runs out, Mario still has about 395 speed, assuming he reaches the clock at about 400 speed. So -272 is possible, but just barely, and it needs basically optimal speed to work. -256 is obviously impossible, and -288 is the best possible angle with the speed used in the previous strat (390.1311646 at clock corner).
There's one more important detail for getting Clock Punch to work. Even if the speed and angle are valid, it can still fail. Step 2 assumes that Mario gets 4 qframes worth of sideways movement along the wall. However, depending on Mario's positioning at the 50 Star Door, he may arrive at the clock corner and begin Step 2 with qframes to spare. In that case, he won't get the full 4qf of movement along the wall, and won't reach the target X position, causing a wall punch on the next frame. It's hard to predict whether this will happen beforehand, which is why it seems a little random. If it fails with valid speed and angle, you can mess with Mario's angle on the last frame to get a different position at the Star Door.
Getting close to 400 speed for the -272 angle was problematic. The previous route got to the 50 Star Door with -438.8380432 speed, but you lose too much speed when converting to forward speed with Z+C^->Punch to get to the clock corner with 400. In order to that reliably, you want about -458 speed at the star door. But the properties of decelerating in SM64 made this a challenge.
You can only decelerate rapidly a couple ways. Jumps and "pressed" jumpkicks cut 20% of Mario's H speed, and dust frames with input cut 2% of speed. "Held" jumpkicks don't cut Mario's speed. Dust frames without input don't cut Mario's speed either. Landing from a jump or either kind of jumpkick give Mario 3 dust frames, and for each one you have the option of making it "input" or "no input". So you can't just quickly decelerate to an arbitrary speed; you have to work with what the game lets you do. It's also worth noting that in order to cancel the C^ wallhug by the WDW painting, you have to do a pressed AB kick, so at least a 20% speed cut (with 3 option dust frames when you land on the stairs) is mandatory.
The previous route BLJ'd to about -710 speed, which is the best you can do without another BLJ. Based on this starting speed, it's actually impossible to decelerate to anything close to -458 without losing frames. The route takes 1 extra jump (20% speed cut) and arrives at the star door with -438 speed. If you don't take the extra jump, the next highest deceleration would be a held jumpkick and 6 dust frames (6 2% cuts = 11.4% speed cut), but that leaves Mario with way too much speed (about -485). So you need a different initial speed.
after a lot of testing with different BLJ speeds, Tyler realized that, counterintuitively, BLJ'ing to a significantly less speed didn't have much of an effect on Mario's ascent to the 50 Star Door. You would think that it would take longer, but a couple factors limit how fast Mario can perform the ascent. The time it takes to wall hug by the WDW painting is mostly limited by the time it takes Mario to turn around to an appropriate angle, which speed doesn't affect. Mario's movement up the stairs is also capped at about 410 h units/frame because the wall hitboxes on the steps push him away. So Mario can have less speed and still arrive at the Star Door at the same frame.
Taking advantage of this, Tyler tried a starting speed of about -670, and did a held jumpkick with 5 total input dust frames (9.6% extra speed cut). This led to a 50 Star Door speed of -457.9104309, and a clock corner speed of 399.3190613 (improvable by <1 unit). Not only is this 9 units better than before, but it lets the optimal -272 angle be accomplished!
After Tyler finshed that, it was up to sonicpacker to finish the job, which he did nicely. With the improved angle, he was able to complete the ascent to BitS with much less straining to counteract horizontal drift, which allowed for an even more improved speed. That little bit of extra speed adds up, and lets Mario reach the BitS warp 1 frame earlier. That's right, all of that work led to one magnificent frame being saved, which the vast majority of people didn't notice. But it was worth it, and now the clock punch is unimprovable.