Prev: C5D3 Up: Map Next: C66A
C61D: Move Player
Used by the routine at HandlePlayerLegs.
Moves the player by one frame. The speeds along x and y are only set up while the player walks, is jumping or is entering the room, and they are cleared again afterwards. The speed along z has gravity taken off it, which is more if the player is not rising with the jump control held down. If the player lands the jump is over.
Input
C The controls
IX The address of the object
Set the walk speeds unless the player is turning.
MovePlayer C61D BIT 3,(IX+$0C) Jump to MovePlayer_Walk to walk if the player is jumping.
C621 JR NZ,MovePlayer_Walk
C623 LD A,(IX+$0C) Fetch the collision flags.
C626 AND %11110000 Keep only the countdown from entering the room.
C628 JR NZ,MovePlayer_Walk Jump to MovePlayer_Walk to walk if the player has just entered the room.
C62A BIT 2,C Jump to MovePlayer_Gravity if the player is not walking.
C62C JR Z,MovePlayer_Gravity
MovePlayer_Walk C62E PUSH BC Stash the controls on the stack.
C62F CALL SetPlayerSpeed Call SetPlayerSpeed to give the player a speed along x or y.
C632 POP BC Restore the controls from the stack.
Gravity takes one off the speed along z when the player is rising with the jump control held down, and two otherwise.
MovePlayer_Gravity C633 LD A,(IX+$0B) Fetch the speed along the z axis.
C636 AND A Jump to MovePlayer_GravityFalling if the player is falling.
C637 JP M,MovePlayer_GravityFalling
C63A BIT 3,C Jump to MovePlayer_GravityApply if the jump key is held down.
C63C JR NZ,MovePlayer_GravityApply
MovePlayer_GravityFalling C63E DEC A Decrement A.
MovePlayer_GravityApply C63F DEC A Decrement A.
C640 LD (IX+$0B),A Store the speed along the z axis.
C643 LD ($A739),A Set PreviousVerticalSpeed.
C646 ADD A,$02 Add 02.
C648 CALL BlockMovement Call BlockMovement to move the object, as far as it can go.
C64B CALL DoNothing Call DoNothing.
C64E CALL ApplyGravityAndMove_AddSpeeds Call ApplyGravityAndMove_AddSpeeds to add the distances that the player moved to the position of the player.
Clear the jump flag when the player lands from a fall.
C651 BIT 2,(IX+$0C) Jump to MovePlayer_Done if the player is not on the ground.
C655 JR Z,MovePlayer_Done
C657 LD A,($A739) Fetch PreviousVerticalSpeed.
C65A AND A Jump to MovePlayer_Done if the player was not falling.
C65B JP P,MovePlayer_Done
C65E RES 3,(IX+$0C) Clear the flag for jumping, as the player has landed.
Clear the speeds along x and y.
MovePlayer_Done C662 XOR A Write 00 to the speeds along x and y.
C663 LD (IX+$09),A
C666 LD (IX+$0A),A
C669 RET Return.
View the equivalent code in;
Prev: C5D3 Up: Map Next: C66A