DoLadderStuff:
CPX player1_object
BEQ dontSkipLadderStuff
JMP skipLadderStuff
dontSkipLadderStuff:
;; NATE E - long story short here: smarter check for pressing a direction on a ladder.
;; Checks for pressing a direction, but also makes sure you don't accidently fall off if you don't want to.
GetCurrentActionType player1_object
CMP #$03
BNE +
LDA gamepad
AND #%11000000 ;;pressing L or R
BEQ +
LDA gamepad
AND #%00110000 ;;not pressing U or D
BNE +
LDA Object_physics_byte,x ;;if so, reset ladder AND ground byte
AND #%11111100
STA Object_physics_byte,x
JMP skipLadderStuff
+
LDA Object_physics_byte,x
ORA #%00000010
STA Object_physics_byte,x
;;below is a check for if you're far enoungh unto the ladder.
;;I have no idea what xHold_hi is, but it works better than Object_x_hi,x...
LDA Object_right,x
ADC xHold_hi
AND #%11110000
STA temp
LDA Object_left,x
ADC xHold_hi
AND #%11110000
STA temp1
LDA temp
CMP temp1
BEQ dontSkipLadderSnap
JMP skipLadderStuff
dontSkipLadderSnap:
LDA gamepad
AND #%00010000 ; if up is pressed
BEQ notPressingUpOnLadder
GetCurrentActionType player1_object
CMP #$03 ;; action state of climbing ladder #OBJ_INDEX_LADDER ;; compare to ladder type
BEQ dontChangeToLadderState ;; already is in ladder state
ChangeObjectState #$03, #$04
dontChangeToLadderState:
LDA Object_y_lo,x
SEC
SBC #LADDER_SPEED_LO
STA Object_y_lo,x
LDA Object_y_hi,x
SBC #LADDER_SPEED_HI
STA Object_y_hi,x
STA yHold_hi
CMP #BOUNDS_TOP
BCS hasNotReachedTop
LDA Object_scroll,x
CMP xScroll_hi
BEQ + ;; need to reverse
;; forward auto scroll
LDA #%00000000
JMP ++
+ ;; need to reverse
LDA #%10000000
++
ORA #$02
STA align_screen_flag
LDA #ALIGN_TIMER
STA genericTimer
LDA #$01
STA prevent_scroll_flag
;JSR doTopBounds_player
hasNotReachedTop:
JMP skipLadderStuff
notPressingUpOnLadder:
LDA gamepad
AND #%00100000 ; if down is pressed
BEQ notPressingDownOnLadder
GetCurrentActionType player1_object
CMP #$03 ; #OBJ_INDEX_LADDER ;; compare to ladder type
BEQ dontChangeToLadderState2 ;; already is in ladder state
ChangeObjectState #$03, #$04
dontChangeToLadderState2:
LDA Object_y_lo,x
clc
adc #LADDER_SPEED_LO
STA Object_y_lo,x
LDA Object_y_hi,x
adc #LADDER_SPEED_HI
STA Object_y_hi,x
CMP #BOUNDS_BOTTOM
CLC
ADC Object_bottom,x
BCC skipLadderStuff
LDA Object_scroll,x
CMP xScroll_hi
BEQ + ;; need to reverse
;; forward auto scroll
LDA #%00000000
JMP ++
+ ;; need to reverse
LDA #%10000000
++
ORA #$01
STA align_screen_flag
LDA #ALIGN_TIMER
STA genericTimer
LDA #$01
STA prevent_scroll_flag
notPressingDownOnLadder:
skipLadderStuff:
RTS