Prev: 49725 Up: Map Next: 49814
49758: Handle Walking
Used by the routine at HandlePlayerLegs.
Animates the legs of the player, with a footstep sound, while the player is walking, entering the room or jumping. The frame of the animation is in the lowest two bits of the sprite number. When the player stops walking the legs carry on until they reach frame 1, where the feet are together. The routine does nothing while the player is turning (objects 24 to 27).
Input
C The controls
IX The address of the object
Return while turning.
HandleWalking 49758 LD A,(IX+0) Fetch the sprite number of the player.
49761 SUB 24 Subtract 24.
49763 CP 4 Return if the player is turning.
49765 RET C
Step while entering, jumping or walking.
49766 LD A,(IX+12) Fetch the collision flags.
49769 AND %11110000 Keep only bits 4-7.
49771 JR NZ,HandleWalking_Step Jump to HandleWalking_Step if the player is entering the room.
49773 BIT 3,(IX+12) Jump to HandleWalking_Step if the player is jumping.
49777 JR NZ,HandleWalking_Step
49779 BIT 2,C Jump to HandleWalking_Stop if bit 2 of C is clear.
49781 JR Z,HandleWalking_Stop
HandleWalking_Step 49783 PUSH BC Stash BC on the stack.
49784 CALL PlayFootstepsSound Call PlayFootstepsSound.
49787 POP BC Restore BC from the stack.
Go on to the next frame, which is 0 to 3.
HandleWalking_Animate 49788 LD A,(IX+0) Fetch the sprite number of the player.
49791 LD E,A Copy it to E.
49792 INC A Increment A.
49793 AND %00000011 Keep only bits 0 and 1.
49795 LD D,A Copy the frame to D.
49796 LD A,E Copy E to A.
49797 AND %11111100 Keep only bits 2-7.
49799 OR D Merge the new frame.
49800 LD (IX+0),A Set the sprite number of the player.
49803 RET Return.
HandleWalking_Stop 49804 LD A,(IX+0) Fetch the sprite number of the player.
49807 AND %00000011 Keep only bits 0 and 1.
49809 CP 1 Return if it is 1.
49811 RET Z
49812 JR HandleWalking_Animate Jump to HandleWalking_Animate.
View the equivalent code in;
Prev: 49725 Up: Map Next: 49814