| Data

8421: Left-right movement table

Used by the routine at 8ED4. The entries in this table are used to map the existing value (V) of Willy's direction and movement flags at 85D0 to a new value (V'), depending on the direction Willy is facing and how he is moving or being moved (by 'left' and 'right' keypresses and joystick input, or by a conveyor, or by an urge to visit the toilet). One of the first four entries is used when Willy is not moving.
8421 | DEFB $00 | V=0 (facing right, no movement) + no movement: V'=0 (no change)
8422 | DEFB $01 | V=1 (facing left, no movement) + no movement: V'=1 (no change)
8423 | DEFB $00 | V=2 (facing right, moving) + no movement: V'=0 (facing right, no movement) (i.e. stop)
8424 | DEFB $01 | V=3 (facing left, moving) + no movement: V'=1 (facing left, no movement) (i.e. stop)
One of the next four entries is used when Willy is moving left.
8425 | DEFB $01 | V=0 (facing right, no movement) + move left: V'=1 (facing left, no movement) (i.e. turn around)
8426 | DEFB $03 | V=1 (facing left, no movement) + move left: V'=3 (facing left, moving)
8427 | DEFB $01 | V=2 (facing right, moving) + move left: V'=1 (facing left, no movement) (i.e. turn around)
8428 | DEFB $03 | V=3 (facing left, moving) + move left: V'=3 (no change)
One of the next four entries is used when Willy is moving right.
8429 | DEFB $02 | V=0 (facing right, no movement) + move right: V'=2 (facing right, moving)
842A | DEFB $00 | V=1 (facing left, no movement) + move right: V'=0 (facing right, no movement) (i.e. turn around)
842B | DEFB $02 | V=2 (facing right, moving) + move right: V'=2 (no change)
842C | DEFB $00 | V=3 (facing left, moving) + move right: V'=0 (facing right, no movement) (i.e. turn around)
One of the final four entries is used when Willy is being pulled both left and right; each entry leaves the flags at 85D0 unchanged (so Willy carries on moving in the direction he's already moving, or remains stationary).
842D | DEFB $00 | V=V'=0 (facing right, no movement)
842E | DEFB $01 | V=V'=1 (facing left, no movement)
842F | DEFB $02 | V=V'=2 (facing right, moving)
8430 | DEFB $03 | V=V'=3 (facing left, moving)