Subpixels, Exits, and Elevators
This elevator positioning issue has bothered me for
10 years, and so I finally gave it a full examination.
Subpixels are divided into 16 portions of 16 (16*16=256). Link spawns at Zelda at X-position 112.000. One step right at speed 1 would be 112.016. One step left would be 111.240. Link's maximum speed is 24, meaning he advances 24 chunks of 16 subpixels in one frame, or 1.5 pixels. Moving right from 112.000 at top speed (24) takes him to 113.128 on the next frame and 115.000 on the frame after that.
Room exits occur when Link crosses a particular pixel line. For example, Link reaches the left exit at Zelda after crossing from 251.000 to 250.240. Link can stand at 251.000 forever, but once he reaches 250.240 or further left, the screen will go to black 2 frames later.
This
abacus chart shows Link's final X-position when exiting left from Zelda after various losses of subpixels from suboptimal speed. The main point is that there's a 24-subpixel block that maintains the same exit frame. Examples:
-At max speed, Link crosses over the exit line (250.240) going from 251.064 to 249.192. So the position on the first frame after crossing is 248.064, and then the second frame (33951) is always the black screen.
-If Link slows down and loses 1 subpixel chunk, then he crosses over the exit line going from 251.080 to 249.208. Link is still well beyond the 250.240 threshold, and so no frame is lost. The black screen still comes up on frame 33951.
-Going from 252.112 to 250.240 is still enough to exit on frame 33951. But when Link slows down too much and loses too many subpixels, he will go from 252.128 to 251.000. That is not enough to cross the exit line, and so Link will need another frame to cross from 251.000 to 249.128. Then Link's final position will be 248.000, and the black screen will come up on frame 33952.
Testing elevators, however, yielded an unexpected result. I tested every relevant subpixel position. Instead of a 24-subpixel cycle, there's an uneven 8-cycle.
Inzult and I are getting the same frame result on the elevators. Inzult is within the 'valley.' The chart shows that getting to X-position 119.192 would lead to an exit on frame 36662. Whereas getting to X-position 120.176 would lead to an exit 1 frame later on frame 36663, even though it's 15 subpixel chunks closer to the exit! How is that possible?
The answer is that the exit shifts a pixel to the right.
119.064 to 119.176: exit cross is 238.000.
119.192 to 120.048 (The Valley): exit cross is 238.000.
120.064 to 120.176: exit cross is 239.000.
120.192 to 121.048: exit cross is 238.000.
Without the exit cross oddity, I'm fairly sure that it's like a normal 24-subpixel block. Inzult is on the earlier part of it, and I'm at the end of it, but the result is the same because we both cross the 238.000 exit line on the same frame.
I've confirmed that starting just one more subpixel step over (from position 121.064) would be enough to reach 238.000 1 frame earlier. But right now it's theoretical. 121.048 is the best position I've been able to get on the elevator so far, but I'll keep trying.