Prev: 60301 Up: Map Next: 60725
60376: Handler: Player
Used by the routine at InitialiseGame.
Walks the player, tests the floor under their feet, unlocks matching doors, and starts a fall if they step off.
Handler_Player 60376 LD IX,62001 Point IX at TablePlayerAttributes.
60380 LD A,16 Set INK: CYAN (5).
60382 RST 16
60383 LD A,5
60385 RST 16
60386 XOR A Clear *PlayerWalkReady for this frame.
60387 LD (62255),A
Skip the floor test while on a lift, on a ladder, or moving vertically.
60390 LD A,(59424) Jump to Handler_Player_OnFloor if *FlagLiftCollision shows a lift overlap.
60393 CP 0
60395 JR NZ,Handler_Player_OnFloor
60397 LD A,(IX+17) Jump to Handler_Player_OnFloor if *PlayerActionState is on a ladder.
60400 CP 3
60402 JR Z,Handler_Player_OnFloor
60404 LD A,(IX+5) Jump to Handler_Player_OnFloor if *PlayerVerticalMovement is moving vertically.
60407 CP 0
60409 JR NZ,Handler_Player_OnFloor
60411 LD A,(IX+3) Jump to Handler_Player_StartFall if *PlayerVerticalPosition is not 3 (not standing on a character row).
60414 CP 3
60416 JP NZ,Handler_Player_StartFall
Only test for a floor on the five walkable row bands.
60419 LD A,(IX+1) Jump to Handler_Player_TestWalkMasks if *PlayerVerticalCoordinate is 26.
60422 CP 26
60424 JR Z,Handler_Player_TestWalkMasks
60426 CP 21 Jump to Handler_Player_TestWalkMasks if *PlayerVerticalCoordinate is 21.
60428 JR Z,Handler_Player_TestWalkMasks
60430 CP 16 Jump to Handler_Player_TestWalkMasks if *PlayerVerticalCoordinate is 16.
60432 JR Z,Handler_Player_TestWalkMasks
60434 CP 11 Jump to Handler_Player_TestWalkMasks if *PlayerVerticalCoordinate is 11.
60436 JR Z,Handler_Player_TestWalkMasks
60438 CP 6 Jump to Handler_Player_StartFall if *PlayerVerticalCoordinate is not 6.
60440 JR NZ,Handler_Player_StartFall
AND the walk masks with the three screen bytes under the player's feet.
Handler_Player_TestWalkMasks 60442 LD C,(IX+0) C=*TablePlayerAttributes.
60445 LD B,(IX+1) B=*PlayerVerticalCoordinate.
60448 DEC B Move up three rows to the feet.
60449 DEC B
60450 DEC B
60451 CALL 3545 Call CL_SET.
60454 LD HL,(23684) HL=*DF_CC.
60457 LD A,(62252) Fetch the left foot mask from *PlayerCollisionMasks.
60460 AND (HL) AND it with the left foot pixels.
60461 JR NZ,Handler_Player_OnFloor Jump to Handler_Player_OnFloor if those pixels are solid.
60463 INC HL Advance to the middle foot column.
60464 LD A,(62253) Fetch the middle foot mask from *PlayerCollisionMask_Middle.
60467 AND (HL) AND it with the middle foot pixels.
60468 JR NZ,Handler_Player_OnFloor Jump to Handler_Player_OnFloor if those pixels are solid.
60470 INC HL Advance to the right foot column.
60471 LD A,(62254) Fetch the right foot mask from *PlayerCollisionMask_Right.
60474 AND (HL) AND it with the right foot pixels.
60475 JR NZ,Handler_Player_OnFloor Jump to Handler_Player_OnFloor if those pixels are solid.
Nothing solid underfoot, so start counting a fall.
Handler_Player_StartFall 60477 DEC (IX+5) Decrease *PlayerVerticalMovement by one.
60480 LD A,(62266) Increment *PlayerStepCounter while there is no floor.
60483 INC A
60484 LD (62266),A
60487 JR Handler_Player_ApplyDeltas Jump to Handler_Player_ApplyDeltas.
Floor (or lift/ ladder) is present.
Handler_Player_OnFloor 60489 LD A,(62271) Fetch *PlayerFallenFlag to see if the player has already fallen.
60492 LD (65532),A Copy it to *SoundFlag_PlayerCollision.
60495 CP 0 Jump to LoseLife if the player has already fallen.
60497 JP NZ,LoseLife
60500 LD A,0 Reset *PlayerStepCounter; the player is on solid ground.
60502 LD (62266),A
Handler_Player_ApplyDeltas 60505 CALL ApplyMovementDeltas Apply the player's movement deltas.
60508 LD A,C Jump to Handler_Player_ClearMovement if the player walked off the right.
60509 CP 34
60511 JP Z,Handler_Player_ClearMovement
60514 CP 3 Jump to Handler_Player_ClearMovement if the player walked off the left.
60516 JP Z,Handler_Player_ClearMovement
60519 LD A,B Jump to Handler_Player_ClearMovement if the player walked off the top.
60520 CP 24
60522 JP Z,Handler_Player_ClearMovement
60525 CP 4 Jump to LoseLife if the player walked off the bottom.
60527 JP Z,LoseLife
60530 LD A,C Jump to Handler_Player_MarkReprint if *TablePlayerAttributes changed.
60531 CP (IX+0)
60534 JR NZ,Handler_Player_MarkReprint
60536 LD A,B Jump to Handler_Player_MarkReprint if *PlayerVerticalCoordinate changed.
60537 CP (IX+1)
60540 JR NZ,Handler_Player_MarkReprint
60542 LD A,(IX+3) Jump to Handler_Player_StorePosition if *PlayerVerticalPosition did not change.
60545 CP D
60546 JR Z,Handler_Player_StorePosition
Handler_Player_MarkReprint 60548 LD A,1 Set *PlayerWalkReady so this walk step will reprint.
60550 LD (62255),A
60553 PUSH DE Stash the new position and offsets on the stack.
60554 PUSH BC
60555 LD A,(IX+17) Jump to Handler_Player_SeekDoorLeft if the player is not facing right.
60558 CP 19
60560 JR NZ,Handler_Player_SeekDoorLeft
60562 DEC C Adjust the test column when facing right.
60563 DEC C
Handler_Player_SeekDoorLeft 60564 CALL FindKeyAtPosition Look for a key or locked door at this position.
60567 POP BC Restore the new position and offsets from the stack.
60568 POP DE
60569 CP 255 Jump to Handler_Player_StorePosition if there is no door here.
60571 JR Z,Handler_Player_StorePosition
60573 CP (IX+16) Jump to Handler_Player_ClearMovement if the player is not holding this door's key.
60576 JR NZ,Handler_Player_ClearMovement
60578 CALL Handler_UnlockDoor Unlock the door.
Handler_Player_StorePosition 60581 LD (IX+0),C Write the new horizontal co-ordinate to *TablePlayerAttributes.
60584 LD (IX+1),B Write the new vertical co-ordinate to *PlayerVerticalCoordinate.
60587 LD (IX+2),E Write the new horizontal offset to *PlayerHorizontalPosition.
60590 LD (IX+3),D Write the new vertical offset to *PlayerVerticalPosition.
60593 PUSH DE Stash the offsets on the stack.
60594 CALL EraseSpriteTrail Erase the player's previous sprite.
60597 POP DE Restore the offsets from the stack.
60598 LD (IX+2),E Write the horizontal offset back to *PlayerHorizontalPosition.
60601 LD (IX+3),D Write the vertical offset back to *PlayerVerticalPosition.
60604 LD A,(62266) Call Action_Falling if *PlayerStepCounter shows the player has been stepping into air.
60607 CP 8
60609 CALL NC,Action_Falling
Reprint the player and refresh the walk masks.
60612 LD HL,35192 Write 35192 to *CHARS.
60615 LD (23606),HL
60618 CALL PrintShiftedSprite Print the player.
60621 LD A,(41227) Copy the left walk mask from WalkMaskSources.
60624 LD (62252),A
60627 LD A,(41259) Copy the middle walk mask from WalkMaskSources_Middle.
60630 LD (62253),A
60633 LD A,(41291) Copy the right walk mask from WalkMaskSources_Right.
60636 LD (62254),A
60639 LD A,(IX+0) Copy the horizontal co-ordinate to the previous-horizontal slot.
60642 LD (IX+13),A
60645 LD A,(IX+1) Copy the vertical co-ordinate to the previous-vertical slot.
60648 LD (IX+14),A
60651 LD A,(IX+3) Copy the vertical offset to the previous-vertical-offset slot.
60654 LD (IX+15),A
60657 LD A,(IX+2) Copy the horizontal offset to the previous-offset slot.
60660 LD (IX+11),A
60663 LD A,(62255) Jump to Handler_Player_ClearMovement if *PlayerWalkReady does not need a door check.
60666 CP 0
60668 JR Z,Handler_Player_ClearMovement
60670 LD C,(IX+0) C=the player's horizontal co-ordinate.
60673 LD B,(IX+1) B=the player's vertical co-ordinate.
60676 LD A,(IX+17) Jump to Handler_Player_HandleDoor if the player is not facing right.
60679 CP 19
60681 JR NZ,Handler_Player_HandleDoor
60683 DEC C Adjust the test column when facing right.
60684 DEC C
Handler_Player_HandleDoor 60685 CALL Handler_KeysAndLockedDoors Handle any key or locked door at the player's feet.
Clear this frame's movement.
Handler_Player_ClearMovement 60688 LD (IX+4),0 Clear horizontal movement.
60692 LD (IX+5),0 Clear vertical movement.
60696 RET Return.
Player is falling; switch to the falling animation.
Action_Falling 60697 LD A,1 Set *PlayerFallenFlag; the player is falling.
60699 LD (62271),A
60702 LD (IX+17),2 Set the action state to blocked / no walk.
60706 LD A,(IX+6) Jump to SetFallingSprite if the sprite is not already a falling frame.
60709 CP 158
60711 JR C,SetFallingSprite
60713 ADD A,6 Advance to the next falling frame.
60715 CP 176 Jump to SetPlayerSprite if the falling animation has not wrapped.
60717 JR NZ,SetPlayerSprite
SetFallingSprite 60719 LD A,158 Set A to 158, the first frame of the "falling" animation.
SetPlayerSprite 60721 LD (IX+6),A Write the frame to the player sprite ID.
60724 RET Return.
Prev: 60301 Up: Map Next: 60725