Prev: 60815 Up: Map Next: 60936
60826: Handler: Ladders Descending
Used by the routines at PlayerControls_Kempston and PlayerControls.
Input
IX On entry will be set to TablePlayerAttributes
Handler_LaddersDescending 60826 LD A,(IX+17) Jump to Handler_LaddersDescending_AlreadyOnLadder if *PlayerActionState is already on a ladder.
60829 CP 3
60831 JR Z,Handler_LaddersDescending_AlreadyOnLadder
60833 LD C,(IX+0) C=*TablePlayerAttributes.
60836 LD B,(IX+1) B=*PlayerVerticalCoordinate.
60839 LD HL,(23512) HL=*ReferenceLadders.
Handler_LaddersDescending_Loop 60842 LD A,(HL) Return if this ladder entry is the terminator (255).
60843 CP 255
60845 RET Z
60846 INC HL Advance to the ladder vertical.
60847 CP C Jump to Action_LadderDescend if this ladder is in the player's column.
60848 JR Z,Action_LadderDescend
60850 INC HL Advance to the next ladder entry.
60851 JR Handler_LaddersDescending_Loop Jump to Handler_LaddersDescending_Loop.
Action_LadderDescend 60853 LD A,(HL) A=the ladder vertical.
60854 DEC A Move two rows up for the bottom bound.
60855 DEC A
60856 LD (IX+19),A Write the lower ladder bound to *PlayerLadderBoundLower.
60859 ADD A,5 Add 5 for the top bound.
60861 LD (IX+18),A Write the upper ladder bound to *PlayerLadderBoundUpper.
60864 INC HL Advance to the next ladder entry.
60865 SUB B Compare that span with the player's vertical.
60866 CP 4 Jump to Handler_LaddersDescending_Loop if the player is not on this ladder.
60868 JR NC,Handler_LaddersDescending_Loop
60870 LD A,(IX+17) Jump to AnimateDescending if *PlayerActionState is already on a ladder.
60873 CP 3
60875 JR Z,AnimateDescending
Write the frame before the climb-down sprite we actually want (128) to *PlayerSpriteID. The next step adds 6 so the first drawn frame is correct.
60877 LD (IX+6),122 Write 122 to *PlayerSpriteID.
60881 LD (IX+17),3 Set *PlayerActionState to on a ladder.
AnimateDescending 60885 LD A,(IX+6) Advance *PlayerSpriteID by one climb-down frame.
60888 ADD A,6
60890 LD (IX+6),A
60893 CP 152 Jump to SkipResetDescendingFrame if the climb-down frames have not wrapped (frame 152 begins the next animation).
60895 JR NZ,SkipResetDescendingFrame
Reset the climbing-down player sprite to the first frame.
60897 LD (IX+6),128 Write 128 to *PlayerSpriteID.
SkipResetDescendingFrame 60901 DEC (IX+5) Set *PlayerVerticalMovement to move down.
60904 LD (IX+2),3 Centre *PlayerHorizontalPosition on the ladder.
60908 RET Return.
Already climbing down; stop at the bottom bound.
Handler_LaddersDescending_AlreadyOnLadder 60909 LD A,(IX+1) Jump to AnimateDescending if *PlayerVerticalCoordinate has not reached *PlayerLadderBoundLower.
60912 CP (IX+19)
60915 JR NZ,AnimateDescending
60917 RET Return.
This entry point is used by the routine at Handler_LaddersAscending.
Already climbing up; stop at the top bound.
Handler_LaddersAscending_AlreadyOnLadder 60918 LD A,(IX+18) Jump to AnimateAscending if *PlayerVerticalCoordinate has not reached *PlayerLadderBoundUpper.
60921 LD B,A
60922 LD A,(IX+1)
60925 CP B
60926 JR NZ,AnimateAscending
60928 LD A,(IX+3) Jump to AnimateAscending if *PlayerVerticalPosition is not 3.
60931 CP 3
60933 JR NZ,AnimateAscending
60935 RET Return.
Prev: 60815 Up: Map Next: 60936