Prev: B047 Up: Map Next: B078
B053: Update Player Direction
Used by the routine at GamePlay_Start.
Sets the direction the player faces to match the way the player has moved. Bits 2-3 of the sprite ID hold the direction: 00 is left, 04 is right, 08 is up and 0C is down. The vertical movement is tested first, so if the player has moved both horizontally and vertically then the horizontal direction is used. The walking animation is also advanced (see AnimateWalk).
Input
D New Y position
E New X position
IX Actor record of the player
UpdatePlayerDirection B053 CALL AnimateWalk Animate the walking player.
B056 LD A,D Fetch the new Y position.
B057 CP (IX+$04) Jump to UpdatePlayerDirection_Horizontal if the player has not moved up or down.
B05A JR Z,UpdatePlayerDirection_Horizontal
B05C LD A,(IX+$00) Fetch the sprite ID of the player.
B05F JR C,FaceUp Jump to FaceUp if the player has moved up.
B061 OR %00001100 Set bits 2-3, so the player faces down.
This entry point is used by the routine at FaceUp.
UpdatePlayerDirection_Store B063 LD (IX+$00),A Set the new sprite ID of the player.
UpdatePlayerDirection_Horizontal B066 LD A,E Fetch the new X position.
B067 CP (IX+$03) Return if the player has not moved left or right.
B06A RET Z
B06B LD A,(IX+$00) Fetch the sprite ID of the player.
B06E JR C,FaceLeft Jump to FaceLeft if the player has moved left.
B070 AND %11110011 Keep only bits 0-1, 4-7.
B072 OR %00000100 Set bit 2, so the player faces right.
This entry point is used by the routine at FaceLeft.
UpdatePlayerDirection_Write B074 LD (IX+$00),A Set the new sprite ID of the player.
B077 RET Return.
Prev: B047 Up: Map Next: B078