Prev: C43F Up: Map Next: C4A3
C440: Handle Player Legs
The handler of the legs of the player, which are the object types 20 to 27. The legs are the first of the two objects of the player, and they do everything: the body, which follows them, is run by HandlePlayerTop.
The type of the legs says which way the player is facing, and which step of the walk is being taken. If something dangerous has touched the player the legs explode. Otherwise the controls are read and used to turn, walk, jump, pick up and drop objects, and fire.
Input
IX Record of the legs
HandlePlayerLegs C440 CALL SetSpriteOffset_Minus12_Minus6 Call SetSpriteOffset_Minus12_Minus6 to set where the sprite is drawn.
C443 BIT 6,(IX+$0D) Jump to HandlePlayerLegs_Controls if the player has not been touched by anything dangerous.
C447 JR Z,HandlePlayerLegs_Controls
C449 SET 6,(IX+$2D) Make the body explode too.
C44D JP StartExplosion Jump to StartExplosion to make the legs explode.
Read the controls, and clear the speeds along x and y.
HandlePlayerLegs_Controls C450 CALL ReadControls Call ReadControls to read the controls.
C453 XOR A Set the speeds along x and y to zero.
C454 LD (IX+$09),A
C457 LD (IX+$0A),A
Act on the controls.
C45A CALL HandleTurning Call HandleTurning to turn the player.
C45D CALL StepLegs Call StepLegs to step the legs.
C460 CALL HandleJump Call HandleJump to start a jump.
C463 CALL HandlePickupAndDrop Call HandlePickupAndDrop to pick up or drop an object.
C466 CALL TestPlayerInRoom Call TestPlayerInRoom to find out if the player is clear of the walls.
C469 JR NC,HandlePlayerLegs_Outside Jump to HandlePlayerLegs_Outside if the player is not.
Move the player, which is done with the body flagged as being moved so that the legs do not collide with it.
HandlePlayerLegs_Move C46B SET 1,(IX+$27) Flag the body as being moved.
C46F LD A,(IX+$03) Jump to HandlePlayerLegs_MoveLegs unless the legs are higher than F0.
C472 CP $F0
C474 JR C,HandlePlayerLegs_MoveLegs
C476 LD (IX+$03),$F0 Put the legs at a height of F0, which is the highest that they can be.
HandlePlayerLegs_MoveLegs C47A CALL MovePlayer Call MovePlayer to move the legs.
C47D CALL FireProjectile Call FireProjectile to fire a projectile, if the fire key is pressed.
C480 RES 1,(IX+$27) Clear the flag on the body.
C484 RES 0,(IX+$07) Clear the flag that makes the legs ignore the walls.
Count down the time since the player entered the room, which is in the top four bits of the collision flags.
C488 LD A,(IX+$0C) Fetch the collision flags.
C48B SUB $10 Take 10 off them, and jump to HandlePlayerLegs_Done if there was nothing to take off.
C48D JR C,HandlePlayerLegs_Done
C48F LD (IX+$0C),A Set them.
HandlePlayerLegs_Done C492 JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags to mark the legs to be drawn.
The player is not clear of the walls, as it is in a doorway. Stop it from rising, though it can still fall.
HandlePlayerLegs_Outside C495 LD A,(IX+$0B) Fetch the speed along z.
C498 AND A Jump to HandlePlayerLegs_Move if the player is falling.
C499 JP M,HandlePlayerLegs_Move
C49C XOR A Set the speed along z to zero.
C49D LD (IX+$0B),A
C4A0 JR HandlePlayerLegs_Move Jump to HandlePlayerLegs_Move.
C4A2 RET Return, which nothing does.
View the equivalent code in;
Prev: C43F Up: Map Next: C4A3