Prev: 60826 Up: Map Next: 61019
60936: Handler: Ladders Ascending
Used by the routines at PlayerControls_Kempston and PlayerControls.
Input
IX On entry will be set to TablePlayerAttributes
Handler_LaddersAscending 60936 LD A,(IX+17) Jump to Handler_LaddersAscending_AlreadyOnLadder if *PlayerActionState is already on a ladder.
60939 CP 3
60941 JR Z,Handler_LaddersAscending_AlreadyOnLadder
60943 LD C,(IX+0) C=*TablePlayerAttributes.
60946 LD B,(IX+1) B=*PlayerVerticalCoordinate.
60949 LD HL,(23512) HL=*ReferenceLadders.
Handler_LaddersAscending_Loop 60952 LD A,(HL) Return if this ladder entry is the terminator (255).
60953 CP 255
60955 RET Z
60956 INC HL Advance to the ladder vertical.
60957 CP C Jump to Action_LadderAscend if this ladder is in the player's column.
60958 JR Z,Action_LadderAscend
60960 INC HL Advance to the next ladder entry.
60961 JR Handler_LaddersAscending_Loop Jump to Handler_LaddersAscending_Loop.
Action_LadderAscend 60963 LD A,(HL) A=the ladder vertical.
60964 INC HL Advance past this ladder's vertical.
60965 DEC A Move two rows up for the bottom bound.
60966 DEC A
60967 CP B Jump to Handler_LaddersAscending_Loop if the player is not at the foot of this ladder.
60968 JR NZ,Handler_LaddersAscending_Loop
60970 LD (IX+19),A Write the lower ladder bound to *PlayerLadderBoundLower.
60973 ADD A,5 Add 5 for the top bound.
60975 LD (IX+18),A Write the upper ladder bound to *PlayerLadderBoundUpper.
60978 INC HL Advance to the next ladder entry.
60979 LD A,(IX+17) Jump to AnimateAscending if *PlayerActionState is already on a ladder.
60982 CP 3
60984 JR Z,AnimateAscending
Write the frame after the climb-up sprite we actually want (146) to *PlayerSpriteID. The next step subtracts 6 so the first drawn frame is correct.
60986 LD (IX+6),152 Write 152 to *PlayerSpriteID.
60990 LD (IX+17),3 Set *PlayerActionState to on a ladder.
This entry point is used by the routine at Handler_LaddersDescending.
AnimateAscending 60994 LD A,(IX+6) Step *PlayerSpriteID back by one climb-up frame.
60997 SUB 6
60999 LD (IX+6),A
61002 CP 122 Jump to SkipResetAscendingFrame if the climb-up frames have not wrapped (frame 122 begins the next animation).
61004 JR NZ,SkipResetAscendingFrame
Reset the climbing-up player sprite to the first frame.
61006 LD (IX+6),146 Write 146 to *PlayerSpriteID.
SkipResetAscendingFrame 61010 LD (IX+5),1 Set *PlayerVerticalMovement to move up.
61014 LD (IX+2),3 Centre *PlayerHorizontalPosition on the ladder.
61018 RET Return.
Prev: 60826 Up: Map Next: 61019