Advertisement
Romano338

8-directional cannon blocks pack UberASM

Sep 23rd, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. ;do not insert this as blocks. This is uberasm code.
  2. ;put this in gamemode_code.asm in "gamemode_14:" or level_code.asm.
  3. ;you can edit the speeds, just go to the bottom.
  4.  
  5. ;Tip: you can copy this instantly by pressing CTRL+A to select all,
  6. ;then CTRL+C to copy.
  7.  
  8. !freeram_dir = $0DA1
  9. !freeram_interact = $0DC3
  10.  
  11. Cannon:
  12. LDA !freeram_interact ;\Use !freeram_interact
  13. BEQ .goto_dir ;|as a timer of when the
  14. LDA $9D ;|cannons become re-interactable
  15. ORA $13D4 ;|(so mario cannot be trapped
  16. BNE .goto_dir ;|inside cannon).
  17. LDA !freeram_interact ;|
  18. DEC A ;|
  19. STA !freeram_interact ;/
  20. .goto_dir:
  21. LDA $71 ;\If player dies, then reset the flag
  22. CMP #$09 ;|(because if mario re-enters the level,
  23. BNE .dontreset ;|he's still being shooted, except freeram
  24. STZ !freeram_dir ;|that resets on level load).
  25. JMP .cannon_done ;/and you are done
  26.  
  27. .dontreset:
  28. LDA !freeram_dir ;\Let mario be free when 0.
  29. BNE .cannon_notdone ;|
  30. JMP .cannon_done ;/
  31. .cannon_notdone:
  32. LDA #$01 ;\Allow screen to scroll up.
  33. STA $1404 ;/
  34. STZ $73 ;\No spinjump or crouching (to prevent
  35. STZ $140D ;/player being able to "move").
  36. LDA $77 ;\If player blocked..
  37. BNE .stop_player ;/Then stop player.
  38. LDY !freeram_dir ;\set x and y speed
  39. LDA cannon_x_speed,y ;|
  40. STA $7B ;|
  41. LDA cannon_Y_speed,y ;|
  42. STA $7D ;/
  43. BRA .set_facing_dir
  44. .stop_player:
  45. STZ !freeram_dir ;\Revert player
  46. STZ $7D ;|
  47. STZ $7B ;/
  48. BRA .cannon_done
  49. .set_facing_dir:
  50. LDA !freeram_dir ;\if mario is going straight
  51. CMP #$01 ;|up or down, and/or inside
  52. BEQ .noface ;|cannon, then don't face
  53. CMP #$05 ;|
  54. BEQ .noface ;|
  55. CMP #$09 ;|
  56. BEQ .noface ;/
  57. LDY !freeram_dir ;\face correctly
  58. LDA mario_face_dir,y ;|
  59. STA $76 ;/
  60. .noface:
  61. LDA !freeram_dir
  62. ASL ;>Because JMP addresses are 2 bytes.
  63. TAX ;>Transfer to index
  64. JMP.w (.Facing,x)
  65. .Facing:
  66. dw .cannon_done ;>#$00
  67. dw .up_jmp_pose ;>#$01
  68. dw .long_jmp_pose ;>#$02
  69. dw .long_jmp_pose ;>#$03
  70. dw .sit_pose ;>#$04
  71. dw .sit_pose ;>#$05
  72. dw .sit_pose ;>#$06
  73. dw .long_jmp_pose ;>#$07
  74. dw .long_jmp_pose ;>#$08
  75. dw .waiting ;>#$09
  76.  
  77. .waiting
  78. ;this is when the player is waiting in cannon. (happens if not #$01
  79. ;#$08).
  80. LDA #$FF ;\become invisible, not compatable w/
  81. STA $78 ;/yoshi.
  82. LDA #$4C ;\disable controls version1:
  83. BRA .cannon_done
  84. .up_jmp_pose:
  85. STZ $13ED
  86. LDA #$0B
  87. STA $72
  88. BRA .disable_ctrls2
  89. .sit_pose:
  90. LDA #$1C
  91. STA $13ED
  92. LDA #$24
  93. STA $72
  94. BRA .disable_ctrls2
  95. .long_jmp_pose:
  96. LDA #$0C
  97. STA $72
  98. STZ $13ED
  99. .disable_ctrls2:
  100. LDA #$CF ;\disable controls version2:
  101. .cannon_done:
  102. TRB $15 ;|only allows L/R, select and start.
  103. TRB $16 ;|
  104. TRB $17 ;|
  105. TRB $18 ;/
  106. RTS ;>if you have codes below here, remove this RTS
  107. ;and move the table that was below here to the very
  108. ;bottom of uberasm's file code (so that other codes
  109. ;are located between the table and this code above).
  110.  
  111. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  112. ;This should be located on the very bottom of the page if you have
  113. ;other codes past the RTS.
  114. ;This table should be located after (below) the pointer to it (which is:
  115. ;"cannon_x_speed" for example, or the game will crash).
  116. ;this is the speed table for each cannon direction, the order of the
  117. ;numbers follow:
  118. ;1st number = not used
  119. ;2nd number = up
  120. ;3rd number = up-right
  121. ;4th number = right
  122. ;5th number = down-right
  123. ;6th number = down
  124. ;7th number = down-left
  125. ;8th number = left
  126. ;9th number = up-left
  127. ;10th number = waiting in cannon (x and y speed are both zero)
  128. ;
  129. ; -- U UR R DR D DL L LU W
  130. cannon_x_speed: db $00,$00,$2D,$40,$2D,$00,$D3,$C0,$D3,$00
  131. cannon_Y_speed: db $00,$C0,$D3,$00,$2D,$40,$2D,$00,$D3,$00
  132. ;
  133. ;To find the magnitude of the diagional speed, here is the
  134. ;formula: S*sin(45)
  135. ;Where S is the unsigned speed (invert to negative by using
  136. ;#$100 - #$ss), example
  137.  
  138. ;#$40 = 64 in decimal, so...
  139.  
  140. ;64*sin(45)
  141.  
  142. ;you'll get a value close to 45 in decimal (which is #$2D in hex),
  143. ;use that on BOTH X and Y speeds.
  144. ;Make sure your windows calculator is not in programmer mode or it
  145. ;will always round down.
  146. ;to have edited and still have "equal" positive (right and down)
  147. ;and negative (left and up) speeds, use this forumla (in hex):
  148. ;
  149. ;N=100-P
  150. ;
  151. ;N = negative value (#$80-#$FF)
  152. ;P = positive value (#$01-#$7F)
  153.  
  154. mario_face_dir: ;don't change this!!
  155. db $00,$00,$01,$01,$01,$00,$00,$00,$00,$00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement