Difference between revisions of "Subpixels"

From ALttP Speedrunning Wiki
Jump to: navigation, search
Line 3: Line 3:
 
== How the coordinate and subpixel is updated during movement ==
 
== How the coordinate and subpixel is updated during movement ==
  
* Link has a static velocity when moving around.
+
'''Speed'''
 +
 
 +
* Link has a static speed when moving around.
 
** Walking, normal ground: $18
 
** Walking, normal ground: $18
 
** Dashing, normal ground: $40
 
** Dashing, normal ground: $40
Line 13: Line 15:
 
** Dashing, shallow water: $30
 
** Dashing, shallow water: $30
 
** Diagonal, shallow water: $0D
 
** Diagonal, shallow water: $0D
* When walking leftwards or upwards, the speed is  
+
* When walking leftwards or upwards, the speed is reversed ($18 becomes $E8)
 
* The first significant digit (1 in the case of walking on normal ground) is added to the coordinate directly, no matter what.
 
* The first significant digit (1 in the case of walking on normal ground) is added to the coordinate directly, no matter what.
* The least significant digit (8 in the case of walking on normal ground) is added first to the subpixel coordinate. If this causes the subpixel coordinate to overflow/wrap, we add an additional pixel to the coordinate.
+
* The least significant digit (8 in the case of walking on normal ground) is shifted left four times, and added first to the subpixel . If this causes the subpixel to overflow/wrap, we add an additional pixel to the coordinate.
* The game will reset Link's subpixel accumulator whenever you change direction of movement. A movement after a standstill counts as changing the direction of movement.
+
 
** Note that if you're walking ^, it will reset the subpixel accumulator both when you go to ^> and when you go back to ^ again.
+
'''Subpixel'''
:: This means that pumping into a wall will function as two pumps, both when you press and when you release the extra dpad button.
+
* The game will reset Link's subpixel whenever you change direction of movement. A movement after a standstill counts as changing the direction of movement.
 +
** The game only looks at your dpad to find out of direction has changed. So if you walk upwards alongside a wall, and then press rightwards into the wall, it will treat this as a change of direction, even though Link is still moving upwards.
 +
:: This means that pumping into a wall will function as two pumps, both when you press (from ^ to ^>) and when you release (from ^> to ^).
 
* Starting/executing a dash will not reset the subpixel accumulator. But if you cancel the dash with a movement, it will be reset.
 
* Starting/executing a dash will not reset the subpixel accumulator. But if you cancel the dash with a movement, it will be reset.
 
** If you however start a dash that ends up transitioning to another screen, the subpixel accumulator is not reset unless you start moving in a different direction on the next screen.
 
** If you however start a dash that ends up transitioning to another screen, the subpixel accumulator is not reset unless you start moving in a different direction on the next screen.
  
'''Example: Walking on ground (movement speed is 18), downwards'''
+
'''Example: Walking on ground (movement speed is $18)'''
* frame 1: Subpixel = 0x00 + 0x80 = 0x80. Coordinate = 0 + 1 = 1
+
 
* frame 2: Subpixel = 0x80 + 0x80 = 0x00. Coordinate = 1 + 1 + 1 = 3  (subpixel overflow).
+
* Downwards
* frame 3: Subpixel = 0x00 + 0x80 = 0x80. Coordinate = 3 + 1 = 4
+
** frame 1: Subpixel = 0x00 + 0x80 = 0x80. Coordinate = 0 + 1 + 0 = 1
* frame 4: Subpixel = 0x80 + 0x80 = 0x00. Coordinate = 4 + 1 + 1 = 6  (subpixel overflow).
+
** frame 2: Subpixel = 0x80 + 0x80 = 0x00. Coordinate = 1 + 1 + 1 = 3  (subpixel overflow).
* Etc
+
** frame 3: Subpixel = 0x00 + 0x80 = 0x80. Coordinate = 3 + 1 + 0 = 4
 +
** frame 4: Subpixel = 0x80 + 0x80 = 0x00. Coordinate = 4 + 1 + 1 = 6  (subpixel overflow).
 +
** Etc
  
'''Example: Walking on ground (movement speed is 2), upwards'''
+
* Upwards
* frame 1: Subpixel = 0x00 - 0x80 = 0x80. Coordinate = 0 + 1 + 1 = 2  (subpixel overflow)
+
** frame 1: Subpixel = 0x00 - 0x80 = 0x80. Coordinate = 0 + 1 + 1 = 2  (subpixel overflow)
* frame 2: Subpixel = 0x80 - 0x80 = 0x00. Coordinate = 2 + 1 = 3
+
** frame 2: Subpixel = 0x80 - 0x80 = 0x00. Coordinate = 2 + 1 + 0 = 3
* Etc
+
** Etc
  
'''Example: Walking on stairs (movement speed is 1), upwards'''
+
'''Example: Walking on stairs (movement speed is $0B)'''  
* frame 1: Subpixel = 0x00 + 0x50 = 0x50. Doesn't wrap, so you get 1.
 
* frame 2: Subpixel = 0x50 + 0x50 = 0xA0. Doesn't wrap, so you get 1.
 
* frame 3: Subpixel = 0xA0 + 0x50 = 0xF0. Doesn't wrap, so you get 1.
 
* frame 4: Subpixel = 0xF0 + 0x50 = 0x40. Wraps, so you get 1 - 1 = 0.
 
  
'''Example: Walking on stairs (movement speed is 1), downwards'''
+
* Downwards
* frame 1: Subpixel = 0x00 - 0x50 = 0xB0. Wraps, so you get 1 - 1 = 0.
+
** frame 1: Subpixel = 0x00 + 0xB0 = 0xB0. Coordinate = 0 + 0 + 0 = 0
* frame 2: Subpixel = 0xB0 - 0x50 = 0x60. Doesn't wrap, so you get 1.
+
** frame 2: Subpixel = 0xB0 + 0xB0 = 0x60. Coordinate = 0 + 0 + 1 = 1  (subpixel overflow)
* frame 3: Subpixel = 0x60 - 0x50 = 0x10. Doesn't wrap, so you get 1.
+
** frame 3: Subpixel = 0x60 + 0xB0 = 0x10. Coordinate = 1 + 0 + 1 = 2  (subpixel overflow)
* frame 4: Subpixel = 0x10 - 0x50 = 0xC0. Wraps, so you get 1 - 1 = 0.
+
** frame 4: Subpixel = 0x10 + 0xB0 = 0xC0. Coordinate = 2 + 0 + 0 = 2
 +
** Etc
  
Basically it works like an "anti subpixel".
+
* Upwards
 +
** frame 1: Subpixel = 0x00 - 0xB0 = 0x50. Coordinate = 0 + 0 + 1 = 1  (subpixel overflow
 +
** frame 2: Subpixel = 0x50 - 0xB0 = 0xA0. Coordinate = 1 + 0 + 1 = 2  (subpixel overflow)
 +
** frame 3: Subpixel = 0xA0 - 0xB0 = 0xF0. Coordinate = 1 + 0 + 1 = 3  (subpixel overflow)
 +
** frame 4: Subpixel = 0xF0 - 0xB0 = 0x40. Coordinate = 3 + 0 + 0 = 3
 +
** Etc
  
 
== How it affects slope dashes ==
 
== How it affects slope dashes ==

Revision as of 15:08, 12 January 2018

This game uses subpixels for its movement. This is how Link gets the movement speed of 2-1-2-1 on normal ground etc.

How the coordinate and subpixel is updated during movement

Speed

  • Link has a static speed when moving around.
    • Walking, normal ground: $18
    • Dashing, normal ground: $40
    • Diagonal, normal ground: $10
    • Walking, stairs: $0B
    • Dashing, stairs: $0A
    • Diagonal, stairs: $0B
    • Walking, shallow water: $14
    • Dashing, shallow water: $30
    • Diagonal, shallow water: $0D
  • When walking leftwards or upwards, the speed is reversed ($18 becomes $E8)
  • The first significant digit (1 in the case of walking on normal ground) is added to the coordinate directly, no matter what.
  • The least significant digit (8 in the case of walking on normal ground) is shifted left four times, and added first to the subpixel . If this causes the subpixel to overflow/wrap, we add an additional pixel to the coordinate.

Subpixel

  • The game will reset Link's subpixel whenever you change direction of movement. A movement after a standstill counts as changing the direction of movement.
    • The game only looks at your dpad to find out of direction has changed. So if you walk upwards alongside a wall, and then press rightwards into the wall, it will treat this as a change of direction, even though Link is still moving upwards.
This means that pumping into a wall will function as two pumps, both when you press (from ^ to ^>) and when you release (from ^> to ^).
  • Starting/executing a dash will not reset the subpixel accumulator. But if you cancel the dash with a movement, it will be reset.
    • If you however start a dash that ends up transitioning to another screen, the subpixel accumulator is not reset unless you start moving in a different direction on the next screen.

Example: Walking on ground (movement speed is $18)

  • Downwards
    • frame 1: Subpixel = 0x00 + 0x80 = 0x80. Coordinate = 0 + 1 + 0 = 1
    • frame 2: Subpixel = 0x80 + 0x80 = 0x00. Coordinate = 1 + 1 + 1 = 3 (subpixel overflow).
    • frame 3: Subpixel = 0x00 + 0x80 = 0x80. Coordinate = 3 + 1 + 0 = 4
    • frame 4: Subpixel = 0x80 + 0x80 = 0x00. Coordinate = 4 + 1 + 1 = 6 (subpixel overflow).
    • Etc
  • Upwards
    • frame 1: Subpixel = 0x00 - 0x80 = 0x80. Coordinate = 0 + 1 + 1 = 2 (subpixel overflow)
    • frame 2: Subpixel = 0x80 - 0x80 = 0x00. Coordinate = 2 + 1 + 0 = 3
    • Etc

Example: Walking on stairs (movement speed is $0B)

  • Downwards
    • frame 1: Subpixel = 0x00 + 0xB0 = 0xB0. Coordinate = 0 + 0 + 0 = 0
    • frame 2: Subpixel = 0xB0 + 0xB0 = 0x60. Coordinate = 0 + 0 + 1 = 1 (subpixel overflow)
    • frame 3: Subpixel = 0x60 + 0xB0 = 0x10. Coordinate = 1 + 0 + 1 = 2 (subpixel overflow)
    • frame 4: Subpixel = 0x10 + 0xB0 = 0xC0. Coordinate = 2 + 0 + 0 = 2
    • Etc
  • Upwards
    • frame 1: Subpixel = 0x00 - 0xB0 = 0x50. Coordinate = 0 + 0 + 1 = 1 (subpixel overflow
    • frame 2: Subpixel = 0x50 - 0xB0 = 0xA0. Coordinate = 1 + 0 + 1 = 2 (subpixel overflow)
    • frame 3: Subpixel = 0xA0 - 0xB0 = 0xF0. Coordinate = 1 + 0 + 1 = 3 (subpixel overflow)
    • frame 4: Subpixel = 0xF0 - 0xB0 = 0x40. Coordinate = 3 + 0 + 0 = 3
    • Etc

How it affects slope dashes

Dashing on a slope is a fairly volatile thing when you frame advance through it. Link will move anything from 0 to 3 pixels in both the horizontal or vertical direction, seemingly at random. We're not sure the exact rules, but it looks like different parts of the slope will give different pixel boosts.

Another factor is subpixels. Depending on what subpixel you have, you might or might not get an extra pixel boost at any point during the slope dash. This means that even if you start your dash from the exact same coordinate, the slopedash can go fast or slow depending on the subpixel value.

One way to make sure you get the same subpixel is to hit diagonal before starting the dash.

Bomb Clips

Since a criteria for performing a Bomb Clip is that you are positioned exactly below the explosion, your subpixel value will matter just as much as your coordinate, since different paths through the slope might or might not include the coordinate where Link is directly below.

Some setups works the same for both subpixel=0x00 and subpixel=0x80, in which case it doesn't matter.

If a setup requires a specific subpixel, you would need to go from a standstill to a movement for an exact amount of frames, before starting the dash (for example hit > + A on the same frame).