Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;This routine will be executed when mario interact with a standar hitbox.
- ;It will be excecuted if $0E is 1 after execute Interaction routine
- SolidInteraction:
- ;LDX !SpriteIndex ;Remove the ";" at the start of the line if it is not a Default interaction
- LDA !PlayerYSpeed
- STA !ScratchF ;Stores Player Y Speed on Scratch F
- STZ !ScratchE ;Scratch E = 0
- LDA !PlayerYSpeed ;If Player Y Speed is negative (is going to up) then check interaction with player from above
- BMI +++
- STZ !ScratchD ;
- LDA !Scratch3
- STA !ScratchC ;$0C = Player Hitbox Height in 16 bits
- LDA !Scratch9
- XBA
- LDA !Scratch1 ;A = Player Hitbox X Position
- REP #$20
- CLC
- ADC !ScratchC ;A = Player Hitbox X Position + Player Hitbox Height = Position of the Bottom of the Player Hitbox
- SEC
- SBC #$0008 ;A = Position of the Bottom of the Player Hitbox - 8
- STA !ScratchC ;$0C = A = Position of the Bottom of the Player Hitbox - 8
- SEP #$20 ;Basically we will check if the position of the bottom of the player hitbox is touching the top of the sprite hitbox
- LDA !ScratchB
- XBA
- LDA !Scratch5 ;A = Position of the sprite hitbox
- REP #$20
- CMP !ScratchC ;If the Bottom of the player hitbox - 8 > Top of the Sprite Hitbox then Mario is above the sprite
- BCS +
- BRA ++
- +
- PHA ;\
- LDA !ScratchC ;|
- SEC ;|This calculate how much pixels the sprite must move the player
- SBC $01,s ;|to put it above the sprite
- ADC #$0008 ;|
- STA !ScratchC ;|Then set move the sprite
- PLA ;|
- LDA !PlayerY ;|
- SEC ;|
- SBC !ScratchC ;|
- STA !PlayerY ;/
- SEP #$20
- LDA !PlayerBlockedStatus_S00MUDLR
- ORA #$04
- STA !PlayerBlockedStatus_S00MUDLR ;Set player flag "Is blocked from below"
- STZ !PlayerInAirFlag ;Player is not in the Air
- LDA #$01
- STA $1471|!addr ;Set Player flag to say it that is above other sprite
- STA !PlayerRidingPlatform,x ;Set the flag that allows the sprite knows if mario is riding the platform
- RTS
- ++
- SEP #$20
- LDA !PlayerBlockedStatus_S00MUDLR ;If player is blocked from below check below
- AND #$04
- BNE +++
- LDA !PlayerYSpeed ;If Player Y Speed = 0, check below
- BEQ +++
- BRA .sides
- +++
- SEP #$20
- STZ !ScratchD
- LDA !Scratch7
- STA !ScratchC ;$0C = Sprite Height in 16 bits
- LDA !ScratchB
- XBA
- LDA !Scratch5
- REP #$20
- CLC
- ADC !ScratchC ;A = Sprite Hitbox X Position + Sprite Hitbox Height = Position of the Bottom of the Sprite Hitbox
- SEC
- SBC #$0008
- STA !ScratchC ;$0C = Position of the Bottom of the sprite Hitbox - 8
- SEP #$20
- LDA !Scratch9
- XBA
- LDA !Scratch1 ;A = Position of the top of Player hitbox
- REP #$20
- CMP !ScratchC
- BCC +++ ;If the Bottom of the Sprite hitbox - 8 > Top of the Player Hitbox then Sprite is above the Player
- PHA ;\
- LDA !ScratchC ;|
- SEC ;|This calculate how much pixels the sprite must move the player
- SBC $01,s ;|to put it above the sprite
- ADC #$0008 ;|
- STA !ScratchC ;|Then set move the sprite
- PLA ;|
- LDA !PlayerY ;|
- CLC ;|
- ADC !ScratchC ;|
- STA !PlayerY ;/
- SEP #$20
- LDA !PlayerBlockedStatus_S00MUDLR
- ORA #$08
- STA !PlayerBlockedStatus_S00MUDLR ;Player blocked from above
- +++
- .sides
- SEP #$20
- LDA !PlayerXSpeed
- BMI +++ ;If player x speed is right , check left side, other wise check right side
- STZ !ScratchD
- LDA !Scratch2
- STA !ScratchC ;Tbh this is analogue to Y axis check
- LDA !Scratch8
- XBA
- LDA !Scratch0
- REP #$20
- CLC
- ADC !ScratchC
- SEC
- SBC #$0008
- STA !ScratchC
- SEP #$20
- LDA !ScratchA
- XBA
- LDA !Scratch4
- REP #$20
- CMP !ScratchC
- BCC ++
- PHA
- LDA !ScratchC
- SEC
- SBC $01,s
- ADC #$0008
- STA !ScratchC
- PLA
- LDA !PlayerX
- SEC
- SBC !ScratchC
- STA !PlayerX
- SEP #$20
- STZ !PlayerXSpeed ;Xspeed = 0
- LDA !ScratchF
- STA !PlayerYSpeed
- LDA !PlayerBlockedStatus_S00MUDLR
- ORA #$01
- STA !PlayerBlockedStatus_S00MUDLR ;player Blocked from right
- RTS
- ++
- SEP #$20
- LDA !PlayerXSpeed
- BEQ +++
- RTS
- +++
- SEP #$20
- STZ !ScratchD
- LDA !Scratch6
- STA !ScratchC
- LDA !ScratchA
- XBA
- LDA !Scratch4
- REP #$20
- CLC
- ADC !ScratchC
- SEC
- SBC #$0008
- STA !ScratchC
- SEP #$20
- LDA !Scratch8
- XBA
- LDA !Scratch0
- REP #$20
- CMP !ScratchC
- BCC +++
- PHA
- LDA !ScratchC
- SEC
- SBC $01,s
- ADC #$0008
- STA !ScratchC
- PLA
- LDA !PlayerX
- CLC
- ADC !ScratchC
- STA !PlayerX
- SEP #$20
- STZ !PlayerXSpeed
- LDA !ScratchF
- STA !PlayerYSpeed ;
- LDA !PlayerBlockedStatus_S00MUDLR
- ORA #$02
- STA !PlayerBlockedStatus_S00MUDLR ;Player blocked from left
- RTS
- +++
- SEP #$20
- RTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement