LDA gamepad
AND #%00010000 ; is up pressed ?
BEQ dontMessWithGravity
; LDA Object_physics_byte,x
; AND #%00000001 ; Are we in the air ?
; BNE dontMessWithGravity
LDA Object_v_speed_hi,x
BMI dontMessWithGravity
LDA Object_movement,x
AND #%00001111
CMP #%00000110
BEQ checkLeftCollisionOnly
LDA collisionPoint1,x
BEQ dontMessWithGravity
JMP doGrab
checkLeftCollisionOnly:
LDA collisionPoint0,x
CMP #$07 ; tiletype of wall grab tile
BEQ dontMessWithGravity
doGrab:
ChangeObjectState #$07, #$08
dontMessWithGravity:
CPX player1_object
BNE dontMessWithGravity
LDA gamepad
AND #%00010000 ; is up pressed ?
BEQ dontMessWithGravity
LDA Object_v_speed_hi,x ; are we falling downwards ?
BMI dontMessWithGravity
CLC
ADC Object_y_hi,x ; are we in map bounds ?
CMP #$10
BCC dontMessWithGravity
CMP #$D6
BCS dontMessWithGravity
LDX player1_object ; fetch facing direction of player
LDA Object_movement,x
AND #%00001111
CMP #%00000110
BEQ doLeftCollisionCheck
LDA collisionPoint1 ; compare top right collision point
CMP #$03 ; compare against "wallgrab tile"
BNE dontMessWithGravity
JMP doGrab
doLeftCollisionCheck:
LDA collisionPoint0 ; compare top left collision point
CMP #$03 ; compare against "wallgrab tile"
BNE dontMessWithGravity
doGrab: ; enable grabbing the wall
ChangeObjectState #$07, #$03
dontMessWithGravity:
GetCurrentActionType player1_object
CMP #$07
BEQ doWallClimbJumpThing
RTS
doWallClimbJumpThing:
ChangeObjectState #$02, #$03
LDA #$00
SEC
SBC #JUMP_SPEED_LO
STA Object_v_speed_lo,x
LDA #$00
SEC
SBC #JUMP_SPEED_HI
STA Object_v_speed_hi,x
RTS
LDX player1_object
GetCurrentActionType player1_object
STA temp
CMP #$07
BNE +
LDA gamepad
AND #%00111111
STA gamepad
RTS
+
; a jumps
LDX player1_object
;;; let's check for if we are standing on a jumpthrough platform,
;;; for which "down and jump" will jump downwards through
;;; comment this out if you do not want that functionality
LDA screenFlags
AND #%00100000 ;; does it use gravity?
BEQ dontJump
GetCurrentActionType player1_object
CMP #$07
BEQ doWallClimbJumpThing
RTS
doWallClimbJumpThing:
ChangeObjectState #$02, #$03
LDA #$00
SEC
SBC #JUMP_SPEED_LO
STA Object_v_speed_lo,x
LDA #$00
SEC
SBC #JUMP_SPEED_HI
STA Object_v_speed_hi,x
RTS
LDA Object_physics_byte,x
AND #%00001000
BEQ notStandingOnJumpThroughPlatform
LDA gamepad
AND #%00100000
BEQ notStandingOnJumpThroughPlatform
LDA Object_y_hi,x
CLC
ADC #$09
STA Object_y_hi,x
JMP dontJump
notStandingOnJumpThroughPlatform:
LDA Object_physics_byte,x
AND #%00000001
BNE canJump
LDA Object_physics_byte,x
AND #%00000100
BEQ dontJump
canJump:
;;; TURN OFF "STANDING ON JUMPTHROUGH PLATFORM" if it is on
LDA Object_physics_byte,x
AND #%11110111
STA Object_physics_byte,x
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LDA #$00
SEC
SBC #JUMP_SPEED_LO
STA Object_v_speed_lo,x
LDA #$00
SEC
SBC #JUMP_SPEED_HI
STA Object_v_speed_hi,x
GetCurrentActionType player1_object
CMP #$03 ;; attack
BEQ +
ChangeObjectState #$02, #$04
+
PlaySound #SND_JUMP
dontJump:
RTS
ExtraInputControl:
;;; occasionally, there is input code that may be very specific, and it may be
;;; difficult to implement via the visual interface and accompanying scripts.
;;; this is a code that runs after all input checks, and allows for custom ASM.
LDA gameState
CMP #GS_MainGame
BEQ doMainGameUpdates
JMP skipMainGameExtraInputControl
doMainGameUpdates:
LDX player1_object
GetCurrentActionType player1_object
STA temp
LDA Object_physics_byte,x
AND #%00000010
BEQ isNotClimbing
LDA temp
CMP #$04
BNE isNotClimbing
LDA gamepad
AND #%11000000
BEQ noDirWhileClimbing
ChangeObjectState #$02, #$04
noDirWhileClimbing:
;;; is climbing.
;;; which means don't check to change to idle.
JMP skipMainGameExtraInputControl
isNotClimbing:
LDA temp
CMP #$03 ;; is it shooting (shooting is same anim in air and on ground)
BNE isNotAttackingAction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
JMP skipMainGameExtraInputControl
isNotAttackingAction:
LDA gamepad
AND #%11000000 ;;; left and right
BEQ dontskipMainGameExtraInputControl
JMP skipMainGameExtraInputControl
dontskipMainGameExtraInputControl:
;;; if left and right are not pressed
LDA screenFlags
AND #%00100000 ;; does it use gravity?
;; if it does not, it would not have jumping or ducking, so
;; skip state updates for jumping and ducking.
BEQ notDucking ;; just will change to idle.
LDA Object_physics_byte,x
AND #%00000001 ;; if is in air
BNE notInAir
GetCurrentActionType player1_object
CMP #$02 ;; is it already state 2?
BEQ skipMainGameExtraInputControl
ChangeObjectState #$02, #$04
JMP skipMainGameExtraInputControl
notInAir:
LDA Object_h_speed_lo,x
ORA Object_h_speed_hi,x
BNE skipMainGameExtraInputControl
;;;; controller is not pressed
;;;; horizontal speed is zero.
;; check to see if in air, shooting, etc.
LDA gamepad
AND #%00100000 ; if down is pressed
BEQ notDucking
ChangeObjectState #$5, #$04
JMP skipMainGameExtraInputControl
skipMainGameExtraInputControl:
RTS
notDucking:
LDA gamepad
AND #%11110000
BNE skipMainGameExtraInputControl2
GetCurrentActionType player1_object ; check curren state
BEQ skipMainGameExtraInputControl2 ; if already 0, don't change it again.
ChangeObjectState #$00, #$04
skipMainGameExtraInputControl2:
LDX player1_object
GetCurrentActionType player1_object
STA temp
CMP #$07
BNE +
LDA gamepad
AND #%00111111
STA gamepad
RTS
+
RTS
; a jumps
LDX player1_object
;;; let's check for if we are standing on a jumpthrough platform,
;;; for which "down and jump" will jump downwards through
;;; comment this out if you do not want that functionality
GetCurrentActionType player1_object
CMP #$04 ; set this to your climb action state
BEQ doWallClimbJumpThing
LDA screenFlags
AND #%00100000 ;; does it use gravity?
BNE dontDoWallClimbJumpThing
JMP dontJump
doWallClimbJumpThing:
ChangeObjectState #$02, #$03
LDA #$00
SEC
SBC #JUMP_SPEED_LO
STA Object_v_speed_lo,x
LDA #$00
SEC
SBC #JUMP_SPEED_HI
STA Object_v_speed_hi,x
RTS
dontDoWallClimbJumpThing:
LDA Object_physics_byte,x
AND #%00001000
BEQ notStandingOnJumpThroughPlatform
LDA gamepad
AND #%00100000
BEQ notStandingOnJumpThroughPlatform
LDA Object_y_hi,x
CLC
ADC #$09
STA Object_y_hi,x
JMP dontJump
notStandingOnJumpThroughPlatform:
LDA Object_physics_byte,x
AND #%00000001
BNE canJump
LDA Object_physics_byte,x
AND #%00000100
BEQ dontJump
canJump:
;;; TURN OFF "STANDING ON JUMPTHROUGH PLATFORM" if it is on
LDA Object_physics_byte,x
AND #%11110111
STA Object_physics_byte,x
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LDA #$00
SEC
SBC #JUMP_SPEED_LO
STA Object_v_speed_lo,x
LDA #$00
SEC
SBC #JUMP_SPEED_HI
STA Object_v_speed_hi,x
GetCurrentActionType player1_object
CMP #$03 ;; attack
BEQ +
ChangeObjectState #$02, #$04
+
PlaySound #SND_JUMP
dontJump:
RTS
ExtraInputControl:
;;; occasionally, there is input code that may be very specific, and it may be
;;; difficult to implement via the visual interface and accompanying scripts.
;;; this is a code that runs after all input checks, and allows for custom ASM.
LDA gameState
CMP #GS_MainGame
BEQ doMainGameUpdates
JMP skipMainGameExtraInputControl
doMainGameUpdates:
LDX player1_object
GetCurrentActionType player1_object
STA temp
CMP #$04 ; set this to your climb action state
BNE +
LDA gamepad
AND #%00111111
STA gamepad
RTS
+
LDX player1_object
GetCurrentActionType player1_object
STA temp
; LDA Object_physics_byte,x
; AND #%00000010
; BEQ isNotClimbing
; LDA temp
; CMP #$04
; BNE isNotClimbing
; LDA gamepad
; AND #%11000000
; BEQ noDirWhileClimbing
; ChangeObjectState #$02, #$04
;noDirWhileClimbing:
;;; is climbing.
;;; which means don't check to change to idle.
; JMP skipMainGameExtraInputControl
isNotClimbing:
LDA temp
CMP #$03 ;; is it shooting (shooting is same anim in air and on ground)
BNE isNotAttackingAction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
JMP skipMainGameExtraInputControl
isNotAttackingAction:
LDA gamepad
AND #%11000000 ;;; left and right
BEQ dontskipMainGameExtraInputControl
JMP skipMainGameExtraInputControl
dontskipMainGameExtraInputControl:
;;; if left and right are not pressed
LDA screenFlags
AND #%00100000 ;; does it use gravity?
;; if it does not, it would not have jumping or ducking, so
;; skip state updates for jumping and ducking.
BEQ notDucking ;; just will change to idle.
LDA Object_physics_byte,x
AND #%00000001 ;; if is in air
BNE notInAir
GetCurrentActionType player1_object
CMP #$02 ;; is it already state 2?
BEQ skipMainGameExtraInputControl
ChangeObjectState #$02, #$04
JMP skipMainGameExtraInputControl
notInAir:
LDA Object_h_speed_lo,x
ORA Object_h_speed_hi,x
BNE skipMainGameExtraInputControl
;;;; controller is not pressed
;;;; horizontal speed is zero.
;; check to see if in air, shooting, etc.
LDA gamepad
AND #%00100000 ; if down is pressed
BEQ notDucking
ChangeObjectState #$5, #$04
JMP skipMainGameExtraInputControl
skipMainGameExtraInputControl:
RTS
notDucking:
LDA gamepad
AND #%11110000
BNE skipMainGameExtraInputControl2
GetCurrentActionType player1_object ; check curren state
BEQ skipMainGameExtraInputControl2 ; if already 0, don't change it again.
ChangeObjectState #$00, #$04
skipMainGameExtraInputControl2:
RTS