Advertisement
Guest User

Spiky Interaction

a guest
Jul 20th, 2019
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. SpikyInteraction:
  2. LDA $1490|!addr ;if player is using the star
  3. BEQ + ;kill the sprite
  4. %Star()
  5. RTS
  6. +
  7. LDA $187A|!addr ;If player is riding yoshi then skip spinjump check
  8. BNE +
  9.  
  10. LDA $140D|!addr ;if player is doing spin jump then check if can do spin jump over the sprite; otherwise damage the player
  11. BEQ +++
  12. +
  13. LDA !PlayerYSpeed ;\
  14. SEC ;|Get relative speed between player and the sprite, if it is negative then damage the player
  15. SBC !SpriteYSpeed,x ;/
  16. BMI +++ ;other wise check the position of the player
  17.  
  18. STZ !ScratchD
  19. LDA !Scratch3
  20. STA !ScratchC ;Loads height of the player hitbox on Scratch C
  21.  
  22. LDA !Scratch9
  23. XBA
  24. LDA !Scratch1 ;Loads player hitbox Y position
  25. REP #$20
  26. CLC
  27. ADC !ScratchC ;A =Player hitbox Y position + hitbox height = Bottom of the hitbox
  28. SEC
  29. SBC #$0008
  30. STA !ScratchC ;!Scratch C = Bottom of player hitbox - 8 (to detects a range)
  31. SEP #$20
  32.  
  33. LDA !ScratchB ;A = top of Sprite hitbox
  34. XBA
  35. LDA !Scratch5
  36. REP #$20
  37. CMP !ScratchC ;compare Top of the sprite hitbox with the Bottom of player hitbox - 8 (to detects a range)
  38. BCC +++ ;If the top of the sprite hitbox is on a position Higher than bottom of player hitbox then do spin jump
  39.  
  40.  
  41. PHA ;\
  42. LDA !ScratchC ;|
  43. SEC ;|
  44. SBC $01,s ;|
  45. ADC #$0008 ;|Moves the player to the top of the sprite hitbox
  46. STA !ScratchC ;|
  47. PLA ;|
  48. ;|
  49. LDA !PlayerY ;|
  50. SEC ;|
  51. SBC !ScratchC ;|
  52. STA !PlayerY ;|
  53. ;|
  54. SEP #$20 ;/
  55.  
  56. JSL $01AB99|!rom ;Display White Star
  57. JSL $01AA33|!rom ;Do the player boost its Y Speed
  58.  
  59. LDA #$02
  60. STA $1DF9|!addr ;Play Spin Jump Sound
  61.  
  62. ;#######################################################################
  63. ;Here you can add code that happend when the player spin jump the sprite
  64. ;#######################################################################
  65.  
  66. RTS ;Return
  67. +++
  68. SEP #$20
  69.  
  70. ;###########################################################################
  71. ;Here you can add code that happend when the player is damaged by the sprite
  72. ;##########################################################################
  73.  
  74. PHX
  75.  
  76. LDA $187A|!addr ;if the player is not riding yoshi then damage the player
  77. BEQ + ;otherwise dismount yoshi
  78. JSR FindYoshi
  79. BCC +
  80. JSR DismountYoshi
  81. PLX
  82. RTS
  83. +
  84. JSL $00F5B7|!rom
  85. PLX
  86. RTS
  87.  
  88. FindYoshi:
  89. LDX $18DF|!addr
  90. BEQ .crawlForYoshi
  91. DEX
  92. BRA .found
  93. .crawlForYoshi:
  94. LDX.w $1692|!addr
  95. ; Start Slot according to sprite data
  96. LDA.l $02A773|!rom,x
  97. SEC
  98. SBC #$FE ; spaces 2 reserved slots, have to interact with them too
  99. TAX
  100. .loop:
  101. LDA !SpriteNumber,x
  102. CMP #$35
  103. BNE .continueLoop
  104.  
  105. LDA !SpriteStatus,x
  106. BNE .found
  107. .continueLoop
  108. DEX
  109. BPL .loop
  110. .returnClear:
  111. CLC
  112. RTS
  113. .found
  114. SEC
  115. RTS
  116.  
  117. DismountYoshi:
  118. LDA #$10
  119. STA !SpriteDecTimer6,x
  120. LDA #$03 ; \ Play sound effect
  121. STA $1DFA|!addr ; /
  122. LDA #$13 ; \ Play sound effect
  123. STA $1DFC|!addr ; /
  124. LDA #$02
  125. STA !SpriteMiscTable3,x
  126. STZ $187A|!addr
  127. LDA #$C0
  128. STA !PlayerYSpeed
  129. STZ !PlayerXSpeed
  130. %SubHorzPos()
  131. LDA XSpeedDismountTable,y
  132. STA !SpriteXSpeed,X
  133. STZ !SpriteMiscTable10,x
  134. STZ !SpriteMiscTable6,X
  135. STZ $18AE|!addr
  136. STZ $0DC1|!addr
  137. LDA #$30 ; \ Mario invincible timer = #$30
  138. STA $1497|!addr ; /
  139. JSR CODE_01EDCC
  140. RTS ; Return
  141.  
  142. XSpeedDismountTable:
  143. db $E8,$18
  144.  
  145. CODE_01EDCC:
  146. LDY.B #$00
  147. LDA !SpriteYLow,X
  148. SEC
  149. SBC YoshiOffset,Y
  150. STA !PlayerY
  151. STA $D3
  152. LDA !SpriteYHigh,X
  153. SBC #$00
  154. STA !PlayerY+$01
  155. STA $D4
  156. RTS ; Return
  157.  
  158. YoshiOffset:
  159. db $04,$10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement