thebiob

Pipe Cannon Uberasm

Apr 20th, 2017
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. !Freeram_PipeCannonState = $60
  2. ;^[1 byte], the state mario would be when in pipe.
  3.  
  4. !Freeram_PipeCannonTmr = $61
  5. ;^[1 byte], the timer when mario switches action.
  6.  
  7. main:
  8. LDA $71 ;\If dying, don't continue cannon mode.
  9. CMP #$09 ;|(fixes time limit bug)
  10. BNE .NotDying ;|
  11. JML .Return ;/
  12. .NotDying
  13. LDA !Freeram_PipeCannonTmr ;\Decrement timer
  14. DEC A ;/
  15. BMI .NoDecrement ;>If negative, don't decrement
  16. STA !Freeram_PipeCannonTmr ;>Store to decrement (#$00 is the smallest value)
  17. .NoDecrement
  18.  
  19. LDA !Freeram_PipeCannonState ;>Load state into A
  20. BEQ .NoState ;>Allow mario to have control if #$00
  21. PHA ;>This is faster
  22. LDA #$0B ;\Throughout the launch, mario cannot
  23. STA $71 ;/move.
  24. PLA ;>Restore it
  25. .NoState
  26. ASL ;>Left shift bits (*2, because each address has 2 bytes).
  27. TAX ;>Index it with X
  28. JMP.w (.States,x)
  29.  
  30. .States
  31. dw .Return ;>#$00
  32. dw ..Entering ;>#$01
  33. dw ..Waiting ;>#$02
  34. dw ..PriorShoot ;>#$03
  35. dw ..Shoot ;>#$04
  36. dw .SelfReset ;>#$05
  37. ;;;;;;;;;;;;;;;;;;;;;;;;
  38. ..Entering
  39. LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
  40. BEQ ...NextState ;/
  41. LDA #$01 ;>Set...
  42. STA $9D ;>...Freeze time
  43. STA $13F9 ;>...Behind layers
  44. LDA #$0F ;\Set pose
  45. STA $13E0 ;/
  46. LDA #$10 ;\Set speed
  47. STA $7D ;/
  48. STZ $7B ;>Blocks don't perfectly halt x speed.
  49. BRA .Return
  50.  
  51. ...NextState
  52. LDA #$02 ;\Switch state to waiting
  53. STA !Freeram_PipeCannonState ;/
  54. LDA.b #60 ;\Set timer of the waiting
  55. STA !Freeram_PipeCannonTmr ;/
  56. LDA #$01 ;>Set...
  57. STA $13F9 ;>...Behind layers (without this, mario goes in front for 1 frame
  58. BRA .Return
  59.  
  60. ..Waiting
  61. LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
  62. BEQ ...NextState ;/
  63. LDA #$01 ;>Set...
  64. STA $9D ;>...Freeze time
  65. STA $13F9 ;>...Behind layers
  66. STZ $7D ;>Stop Y speed
  67. BRA .Return
  68.  
  69. ...NextState
  70. LDA #$03 ;\Set state to prior shoot
  71. STA !Freeram_PipeCannonState ;/
  72. LDA #$09 ;\SFX
  73. STA $1DFC ;/
  74. LDA.b #04 ;\Set timer for the go in front of layers (for prior shoot)
  75. STA !Freeram_PipeCannonTmr ;/(he must go in front as soon mario gets completly out of pipe)
  76. STZ $9D ;>Unfreeze game
  77. LDA #$01 ;>Set...
  78. STA $13F9 ;>...Behind layers (without this, mario goes in front for 1 frame).
  79. BRA .Return
  80.  
  81. ..PriorShoot
  82. LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
  83. BEQ ...NextState ;/
  84. LDA #$01 ;\Behind layer as you exit.
  85. STA $13F9 ;/
  86. STZ $73 ;>Prevent crouching if mairo crouch slide into cannon.
  87. LDA #$01 ;\Behind layers (without this, mario goes in front for 1 frame).
  88. STA $13F9 ;/
  89. BRA .SharedCode
  90.  
  91. ...NextState
  92. LDA #$04 ;\Set state to post shoot
  93. STA !Freeram_PipeCannonState ;/
  94. LDA #$00 ;\Clear timer since this last state no longer uses the timer.
  95. STA !Freeram_PipeCannonTmr ;/
  96. LDA #$01 ;\Behind layers (without this, mario goes in front for 1 frame).
  97. STA $13F9 ;/
  98. BRA .Return
  99.  
  100. ..Shoot
  101. STZ $13F9 ;>Go in front of layers
  102. .SharedCode
  103. LDA #$80 ;\Shoot player upwards
  104. STA $7D ;/
  105. LDA #$0B ;\Up jump pose
  106. STA $13E0 ;|
  107. STA $72 ;/
  108. LDA #$01 ;\Screen scrolls up.
  109. STA $1404 ;/
  110. LDA $77 ;\If mario hits a ceiling...
  111. AND.b #%00001000 ;|
  112. BEQ ..NotBlocked ;/
  113. LDA #$00 ;\Then cancel out cannon mode
  114. STA !Freeram_PipeCannonState ;/
  115. STA $71 ;>Allow movement.
  116. ..NotBlocked
  117. BRA .Return
  118. .SelfReset
  119. STZ !Freeram_PipeCannonState ;\This needed to be cleared for 1 frame or there will be
  120. STZ $71 ;/glitches.
  121. .Return
  122. RTL
Advertisement
Add Comment
Please, Sign In to add comment