Prev: C1DA Up: Map Next: C22D
C1E2: Handle Turning Legs
The handler for the lower half of the robot while it is turning (objects 18 to 1B). The turn takes two passes: the first counts the turn down while the player is moved, and the second sets the sprite that the player ends up with (see TurnedRightSpriteTable and TurnedLeftSpriteTable) and plays a footstep.
Input
C The controls
IX The address of the object
Count the turn down and move.
HandleTurningLegs C1E2 CALL SetPixelAdjustments_Legs Call SetPixelAdjustments_Legs.
C1E5 LD (IX+$06),$17 Set the height of the bottom half to 17.
C1E9 LD (IX+$26),$00 Write 00 to the height of the top half.
C1ED CALL ReadControls Call ReadControls.
C1F0 LD A,(IX+$0D) Fetch the extra flags.
C1F3 AND %00000110 Keep only bits 1 and 2.
C1F5 JR Z,HandleTurningLegs_Finish Jump to HandleTurningLegs_Finish if they are zero.
C1F7 LD A,(IX+$0D) Fetch the extra flags.
C1FA SUB $02 Subtract 02.
C1FC LD (IX+$0D),A Store the extra flags.
C1FF SET 1,(IX+$27) Set bit 1 of the top half flags.
C203 CALL MovePlayer_Gravity Call MovePlayer_Gravity.
C206 JR HandleTurningLegs_Done Jump to HandleTurningLegs_Done.
Finish the turn with the new sprite.
HandleTurningLegs_Finish C208 BIT 0,(IX+$0D) Jump to HandleTurningLegs_Left if bit 0 of the extra flags is clear.
C20C JR Z,HandleTurningLegs_Left
C20E LD HL,$C22D Point HL at TurnedRightSpriteTable.
HandleTurningLegs_Set C211 LD A,(IX+$00) Fetch the sprite number of the player.
C214 CALL SetSpriteFromTable Call SetSpriteFromTable.
C217 CALL PlayFootstepsSound_EveryFrame Call PlayFootstepsSound_EveryFrame.
C21A SET 1,(IX+$27) Set bit 1 of the top half flags.
C21E CALL MovePlayer_WalkControl Call MovePlayer_WalkControl.
HandleTurningLegs_Done C221 RES 1,(IX+$27) Reset bit 1 of the top half flags.
C225 JP HandlePlayerLegs_Draw Jump to HandlePlayerLegs_Draw.
HandleTurningLegs_Left C228 LD HL,$C235 Point HL at TurnedLeftSpriteTable.
C22B JR HandleTurningLegs_Set Jump to HandleTurningLegs_Set.
Prev: C1DA Up: Map Next: C22D