Advertisement
Guest User

asm code

a guest
Sep 12th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. ;=================================================
  2. ; Layer 2 Smash Sideways
  3. ; By Erik557
  4. ;=================================================
  5. ; This is an horizontal version of the Layer 2
  6. ; smasher you see in, for example, Wendy's castle.
  7. ; It's very customizable.
  8. ;=================================================
  9.  
  10.  
  11. ; Defines and tables
  12.  
  13. !FreeRAM = $18CB ; 2 bytes. must be between $0100 and $1fff
  14.  
  15. !SmashPos = $E0 ; where will the smasher stop before rising again.
  16.  
  17. timeBefFalling: ; time until the smasher falls.
  18. db $40 ; smaller the value, smaller the delay
  19.  
  20. timeBefOffset: ; time before the smasher lowers by one tile.
  21. db $80 ; smaller the value, smaller the delay
  22.  
  23. smashSpeed: ; speed of the smasher when it falls.
  24. db $02 ; the smaller the value, the slower it smashes
  25.  
  26. timeBefRising: ; time before the smasher goes back.
  27. db $50 ; smaller the value, smaller the delay
  28.  
  29. riseSpeed: ; speed of the smasher when it rises.
  30. db $01 ; the smaller the value, the slower it smashes
  31.  
  32. screenStart:
  33. minScreenPos: ; screens with activity and no activity.
  34. dw $0500, $0F00
  35.  
  36. maxScreenPos:
  37. dw $0100, $0600
  38. screenEnd:
  39.  
  40. !FreeRAM := !FreeRAM|!addr
  41.  
  42. init:
  43. LDA $71 ;\
  44. CMP #$0A ; | don't run on castle intros
  45. BEQ .return ;/
  46. STZ $1466|!addr ; initial layer 2 pos
  47. STZ $1411|!addr ; no horizontal scroll
  48. LDY #$00 ;\
  49. LDA timeBefFalling,y ; | init timer
  50. STA !FreeRAM ;/
  51. STZ !FreeRAM+1
  52. .return
  53. RTL
  54.  
  55. main:
  56. LDA $71 ;\
  57. CMP #$0A ; | don't run on castle intros
  58. BEQ .return ;/
  59. LDA $9D ;\
  60. ORA $13D4|!addr ; | don't run on game locked or pause
  61. BNE .return ;/
  62. REP #$20 ; 16-bit A
  63. LDY.b #screenEnd-screenStart/2-2 ; number of screens to check
  64. .posLoop
  65. LDA $1468|!addr ;\
  66. CMP minScreenPos,y ; |
  67. BCS .checkNextScreen ; | check if mario is in the specified positions
  68. CMP maxScreenPos,y ; |
  69. BCC .checkNextScreen ;/
  70. SEP #$20 ; 8-bit A
  71. LDA.w !FreeRAM ;\ check if time for move is now
  72. BEQ smash ;/
  73. DEC.w !FreeRAM ; if not, decrement timer and return
  74. RTL
  75.  
  76. .checkNextScreen
  77. DEY ;\
  78. DEY ; | check next set of screens
  79. BPL .posLoop ;/
  80. SEP #$20 ; 8-bit A
  81. STZ $1466|!addr ; reset layer 2 pos
  82. .return
  83. RTL
  84.  
  85. smash:
  86. TYA ;\
  87. LSR ; | correctly index the next tables
  88. TAY ;/
  89. LDA !FreeRAM+1 ;\ check if fall or rise
  90. BEQ .offset ;/
  91. CMP #$01
  92. BEQ .fall
  93. .rise
  94. LDA $1466|!addr ;\
  95. SEC ; | increase layer 2 pos
  96. SBC riseSpeed,y ;/
  97. BNE + ; return if not time to offset
  98. STZ !FreeRAM+1 ; decrease state
  99. LDA timeBefOffset,y ;\ set time before the smasher offsets
  100. STA !FreeRAM ;/
  101. LDA #$00 ;\ set layer 2 position
  102. + STA $1466|!addr ;/
  103. ..return
  104. RTL
  105. .fall
  106. LDA $1466|!addr ;\
  107. CLC ; | decrease layer 2 pos
  108. ADC smashSpeed,y ;/
  109. CMP #!SmashPos ;\ return if not time to return (...)
  110. BNE + ;/
  111. INC !FreeRAM+1 ; increase state
  112. LDA #$20 ;\ shake layer 1
  113. STA $1887|!addr ;/
  114. LDA #$09 ;\ play SFX
  115. STA $1DFC|!addr ;/
  116. LDA timeBefRising,y ;\ set time before the smasher rises
  117. STA !FreeRAM ;/
  118. LDA #!SmashPos ;\ set layer 2 position
  119. + STA $1466|!addr ;/
  120. ..return
  121. RTL
  122.  
  123. .offset
  124. LDA $1466|!addr ;\
  125. INC ; | decrease layer 2 pos
  126. STA $1466|!addr ;/
  127. CMP #$10 ;\ return if not time to fall
  128. BNE ..return ;/
  129. INC !FreeRAM+1 ; increase state
  130. LDA timeBefFalling,y ;\ set time before the smasher falls
  131. STA !FreeRAM ;/
  132. ..return
  133. RTL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement