Prev: C969 Up: Map Next: C9FB
C9A1: Move Player
Used by the routine at HandlePlayerLegs.
Moves the player by one frame. The speeds in X and Y are only set up while the player walks or is jumping, and they are cleared again afterwards. The speed in Z has gravity taken off it, which is more if the player is falling or has let go of the jump control.
Input
C The controls
IX Address of the object
MovePlayer C9A1 LD A,($5BC4) Fetch the flag that is set while an object is put into the cauldron from ObjectInCauldronFlag.
C9A4 AND A
C9A5 JR Z,MovePlayer_Speed Jump to MovePlayer_Speed if it is not set.
C9A7 LD (IX+$0B),$02 Set the speed in Z to 02.
MovePlayer_Speed C9AB BIT 3,(IX+$0C) Jump to MovePlayer_Forward if the player is jumping.
C9AF JR NZ,MovePlayer_Forward
C9B1 LD A,(IX+$0C) Fetch the flags.
C9B4 AND %11110000 Keep the counter of the player entering the room.
C9B6 JR NZ,MovePlayer_Forward Jump to MovePlayer_Forward if it is.
C9B8 BIT 2,C Jump to MovePlayer_Gravity if it is not pressed.
C9BA JR Z,MovePlayer_Gravity
MovePlayer_Forward C9BC PUSH BC Stash the controls on the stack.
C9BD CALL SetPlayerSpeed Set the speeds in X and Y from the direction of the player.
C9C0 POP BC Restore the controls from the stack.
Gravity takes one off the speed in Z when the player is rising with the jump control held down, and two otherwise.
MovePlayer_Gravity C9C1 LD A,(IX+$0B) Fetch the speed in Z and test it.
C9C4 AND A
C9C5 JP M,MovePlayer_Fall Jump to MovePlayer_Fall if it is negative.
C9C8 BIT 3,C Jump to MovePlayer_Store if it is pressed.
C9CA JR NZ,MovePlayer_Store
MovePlayer_Fall C9CC DEC A Take one off the speed in Z.
MovePlayer_Store C9CD DEC A Take one off the speed in Z.
C9CE LD (IX+$0B),A Store the new speed in Z.
C9D1 LD ($5BC1),A Store it as the last speed in Z of the player too at PlayerFallSpeed.
C9D4 ADD A,$02 Add two to it.
C9D6 CALL M,PlaySoundFromHeight Play the sound of falling if the player is falling fast enough.
C9D9 CALL BlockMovement Stop the player moving through other objects and the walls of the room.
C9DC CALL HandleRoomExit Change room if the player has gone through an arch.
C9DF CALL MoveObject Add the speeds to the position of the player.
C9E2 BIT 2,(IX+$0C) Jump to MovePlayer_Stop if the player is not blocked in Z.
C9E6 JR Z,MovePlayer_Stop
C9E8 LD A,($5BC1) Fetch the last speed in Z and test it from PlayerFallSpeed.
C9EB AND A
C9EC JP P,MovePlayer_Stop Jump to MovePlayer_Stop if the player was rising.
C9EF RES 3,(IX+$0C) Flag the player as no longer jumping, as it has landed.
This entry point is used by the routines at HandleSpecialObject, HandleBlock and HandleTable.
MovePlayer_Stop C9F3 XOR A Set the speeds in X and Y to zero.
C9F4 LD (IX+$09),A
C9F7 LD (IX+$0A),A
C9FA RET Return.
View the equivalent code in;
Prev: C969 Up: Map Next: C9FB