Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !Freeram_PipeCannonState = $60
- ;^[1 byte], the state mario would be when in pipe.
- !Freeram_PipeCannonTmr = $61
- ;^[1 byte], the timer when mario switches action.
- main:
- LDA $71 ;\If dying, don't continue cannon mode.
- CMP #$09 ;|(fixes time limit bug)
- BNE .NotDying ;|
- JML .Return ;/
- .NotDying
- LDA !Freeram_PipeCannonTmr ;\Decrement timer
- DEC A ;/
- BMI .NoDecrement ;>If negative, don't decrement
- STA !Freeram_PipeCannonTmr ;>Store to decrement (#$00 is the smallest value)
- .NoDecrement
- LDA !Freeram_PipeCannonState ;>Load state into A
- BEQ .NoState ;>Allow mario to have control if #$00
- PHA ;>This is faster
- LDA #$0B ;\Throughout the launch, mario cannot
- STA $71 ;/move.
- PLA ;>Restore it
- .NoState
- ASL ;>Left shift bits (*2, because each address has 2 bytes).
- TAX ;>Index it with X
- JMP.w (.States,x)
- .States
- dw .Return ;>#$00
- dw ..Entering ;>#$01
- dw ..Waiting ;>#$02
- dw ..PriorShoot ;>#$03
- dw ..Shoot ;>#$04
- dw .SelfReset ;>#$05
- ;;;;;;;;;;;;;;;;;;;;;;;;
- ..Entering
- LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
- BEQ ...NextState ;/
- LDA #$01 ;>Set...
- STA $9D ;>...Freeze time
- STA $13F9 ;>...Behind layers
- LDA #$0F ;\Set pose
- STA $13E0 ;/
- LDA #$10 ;\Set speed
- STA $7D ;/
- STZ $7B ;>Blocks don't perfectly halt x speed.
- BRA .Return
- ...NextState
- LDA #$02 ;\Switch state to waiting
- STA !Freeram_PipeCannonState ;/
- LDA.b #60 ;\Set timer of the waiting
- STA !Freeram_PipeCannonTmr ;/
- LDA #$01 ;>Set...
- STA $13F9 ;>...Behind layers (without this, mario goes in front for 1 frame
- BRA .Return
- ..Waiting
- LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
- BEQ ...NextState ;/
- LDA #$01 ;>Set...
- STA $9D ;>...Freeze time
- STA $13F9 ;>...Behind layers
- STZ $7D ;>Stop Y speed
- BRA .Return
- ...NextState
- LDA #$03 ;\Set state to prior shoot
- STA !Freeram_PipeCannonState ;/
- LDA #$09 ;\SFX
- STA $1DFC ;/
- LDA.b #04 ;\Set timer for the go in front of layers (for prior shoot)
- STA !Freeram_PipeCannonTmr ;/(he must go in front as soon mario gets completly out of pipe)
- STZ $9D ;>Unfreeze game
- LDA #$01 ;>Set...
- STA $13F9 ;>...Behind layers (without this, mario goes in front for 1 frame).
- BRA .Return
- ..PriorShoot
- LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
- BEQ ...NextState ;/
- LDA #$01 ;\Behind layer as you exit.
- STA $13F9 ;/
- STZ $73 ;>Prevent crouching if mairo crouch slide into cannon.
- LDA #$01 ;\Behind layers (without this, mario goes in front for 1 frame).
- STA $13F9 ;/
- BRA .SharedCode
- ...NextState
- LDA #$04 ;\Set state to post shoot
- STA !Freeram_PipeCannonState ;/
- LDA #$00 ;\Clear timer since this last state no longer uses the timer.
- STA !Freeram_PipeCannonTmr ;/
- LDA #$01 ;\Behind layers (without this, mario goes in front for 1 frame).
- STA $13F9 ;/
- BRA .Return
- ..Shoot
- STZ $13F9 ;>Go in front of layers
- .SharedCode
- LDA #$80 ;\Shoot player upwards
- STA $7D ;/
- LDA #$0B ;\Up jump pose
- STA $13E0 ;|
- STA $72 ;/
- LDA #$01 ;\Screen scrolls up.
- STA $1404 ;/
- LDA $77 ;\If mario hits a ceiling...
- AND.b #%00001000 ;|
- BEQ ..NotBlocked ;/
- LDA #$00 ;\Then cancel out cannon mode
- STA !Freeram_PipeCannonState ;/
- STA $71 ;>Allow movement.
- ..NotBlocked
- BRA .Return
- .SelfReset
- STZ !Freeram_PipeCannonState ;\This needed to be cleared for 1 frame or there will be
- STZ $71 ;/glitches.
- .Return
- RTL
Advertisement
Add Comment
Please, Sign In to add comment