Advertisement
Guest User

Solid interaction

a guest
Jul 13th, 2019
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. ;This routine will be executed when mario interact with a standar hitbox.
  2. ;It will be excecuted if $0E is 1 after execute Interaction routine
  3. SolidInteraction:
  4. ;LDX !SpriteIndex ;Remove the ";" at the start of the line if it is not a Default interaction
  5. LDA !PlayerYSpeed
  6. STA !ScratchF ;Stores Player Y Speed on Scratch F
  7. STZ !ScratchE ;Scratch E = 0
  8. LDA !PlayerYSpeed ;If Player Y Speed is negative (is going to up) then check interaction with player from above
  9. BMI +++
  10.  
  11. STZ !ScratchD ;
  12. LDA !Scratch3
  13. STA !ScratchC ;$0C = Player Hitbox Height in 16 bits
  14.  
  15. LDA !Scratch9
  16. XBA
  17. LDA !Scratch1 ;A = Player Hitbox X Position
  18. REP #$20
  19. CLC
  20. ADC !ScratchC ;A = Player Hitbox X Position + Player Hitbox Height = Position of the Bottom of the Player Hitbox
  21. SEC
  22. SBC #$0008 ;A = Position of the Bottom of the Player Hitbox - 8
  23. STA !ScratchC ;$0C = A = Position of the Bottom of the Player Hitbox - 8
  24. SEP #$20 ;Basically we will check if the position of the bottom of the player hitbox is touching the top of the sprite hitbox
  25.  
  26. LDA !ScratchB
  27. XBA
  28. LDA !Scratch5 ;A = Position of the sprite hitbox
  29. REP #$20
  30. CMP !ScratchC ;If the Bottom of the player hitbox - 8 > Top of the Sprite Hitbox then Mario is above the sprite
  31. BCS +
  32. BRA ++
  33. +
  34. PHA ;\
  35. LDA !ScratchC ;|
  36. SEC ;|This calculate how much pixels the sprite must move the player
  37. SBC $01,s ;|to put it above the sprite
  38. ADC #$0008 ;|
  39. STA !ScratchC ;|Then set move the sprite
  40. PLA ;|
  41. LDA !PlayerY ;|
  42. SEC ;|
  43. SBC !ScratchC ;|
  44. STA !PlayerY ;/
  45.  
  46. SEP #$20
  47.  
  48. LDA !PlayerBlockedStatus_S00MUDLR
  49. ORA #$04
  50. STA !PlayerBlockedStatus_S00MUDLR ;Set player flag "Is blocked from below"
  51. STZ !PlayerInAirFlag ;Player is not in the Air
  52. LDA #$01
  53. STA $1471|!addr ;Set Player flag to say it that is above other sprite
  54. STA !PlayerRidingPlatform,x ;Set the flag that allows the sprite knows if mario is riding the platform
  55. RTS
  56. ++
  57. SEP #$20
  58. LDA !PlayerBlockedStatus_S00MUDLR ;If player is blocked from below check below
  59. AND #$04
  60. BNE +++
  61. LDA !PlayerYSpeed ;If Player Y Speed = 0, check below
  62. BEQ +++
  63. BRA .sides
  64. +++
  65. SEP #$20
  66. STZ !ScratchD
  67. LDA !Scratch7
  68. STA !ScratchC ;$0C = Sprite Height in 16 bits
  69.  
  70. LDA !ScratchB
  71. XBA
  72. LDA !Scratch5
  73. REP #$20
  74. CLC
  75. ADC !ScratchC ;A = Sprite Hitbox X Position + Sprite Hitbox Height = Position of the Bottom of the Sprite Hitbox
  76. SEC
  77. SBC #$0008
  78. STA !ScratchC ;$0C = Position of the Bottom of the sprite Hitbox - 8
  79. SEP #$20
  80.  
  81. LDA !Scratch9
  82. XBA
  83. LDA !Scratch1 ;A = Position of the top of Player hitbox
  84. REP #$20
  85. CMP !ScratchC
  86. BCC +++ ;If the Bottom of the Sprite hitbox - 8 > Top of the Player Hitbox then Sprite is above the Player
  87.  
  88.  
  89. PHA ;\
  90. LDA !ScratchC ;|
  91. SEC ;|This calculate how much pixels the sprite must move the player
  92. SBC $01,s ;|to put it above the sprite
  93. ADC #$0008 ;|
  94. STA !ScratchC ;|Then set move the sprite
  95. PLA ;|
  96. LDA !PlayerY ;|
  97. CLC ;|
  98. ADC !ScratchC ;|
  99. STA !PlayerY ;/
  100.  
  101. SEP #$20
  102.  
  103. LDA !PlayerBlockedStatus_S00MUDLR
  104. ORA #$08
  105. STA !PlayerBlockedStatus_S00MUDLR ;Player blocked from above
  106. +++
  107. .sides
  108. SEP #$20
  109.  
  110. LDA !PlayerXSpeed
  111. BMI +++ ;If player x speed is right , check left side, other wise check right side
  112.  
  113. STZ !ScratchD
  114. LDA !Scratch2
  115. STA !ScratchC ;Tbh this is analogue to Y axis check
  116.  
  117. LDA !Scratch8
  118. XBA
  119. LDA !Scratch0
  120. REP #$20
  121. CLC
  122. ADC !ScratchC
  123. SEC
  124. SBC #$0008
  125. STA !ScratchC
  126. SEP #$20
  127.  
  128. LDA !ScratchA
  129. XBA
  130. LDA !Scratch4
  131. REP #$20
  132. CMP !ScratchC
  133. BCC ++
  134.  
  135. PHA
  136. LDA !ScratchC
  137. SEC
  138. SBC $01,s
  139. ADC #$0008
  140. STA !ScratchC
  141. PLA
  142. LDA !PlayerX
  143. SEC
  144. SBC !ScratchC
  145. STA !PlayerX
  146. SEP #$20
  147.  
  148. STZ !PlayerXSpeed ;Xspeed = 0
  149.  
  150. LDA !ScratchF
  151. STA !PlayerYSpeed
  152.  
  153. LDA !PlayerBlockedStatus_S00MUDLR
  154. ORA #$01
  155. STA !PlayerBlockedStatus_S00MUDLR ;player Blocked from right
  156. RTS
  157. ++
  158. SEP #$20
  159. LDA !PlayerXSpeed
  160. BEQ +++
  161. RTS
  162. +++
  163. SEP #$20
  164.  
  165. STZ !ScratchD
  166. LDA !Scratch6
  167. STA !ScratchC
  168.  
  169. LDA !ScratchA
  170. XBA
  171. LDA !Scratch4
  172. REP #$20
  173. CLC
  174. ADC !ScratchC
  175. SEC
  176. SBC #$0008
  177. STA !ScratchC
  178. SEP #$20
  179.  
  180. LDA !Scratch8
  181. XBA
  182. LDA !Scratch0
  183. REP #$20
  184. CMP !ScratchC
  185. BCC +++
  186.  
  187. PHA
  188. LDA !ScratchC
  189. SEC
  190. SBC $01,s
  191. ADC #$0008
  192. STA !ScratchC
  193. PLA
  194. LDA !PlayerX
  195. CLC
  196. ADC !ScratchC
  197. STA !PlayerX
  198.  
  199. SEP #$20
  200.  
  201. STZ !PlayerXSpeed
  202.  
  203. LDA !ScratchF
  204. STA !PlayerYSpeed ;
  205.  
  206. LDA !PlayerBlockedStatus_S00MUDLR
  207. ORA #$02
  208. STA !PlayerBlockedStatus_S00MUDLR ;Player blocked from left
  209. RTS
  210. +++
  211. SEP #$20
  212. RTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement