Advertisement
Guest User

pls no bully

a guest
Nov 28th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.45 KB | None | 0 0
  1. level1C:
  2. .InitCode: ;\ This section is to be used in the INIT code of
  3.  
  4. levelASM
  5. REP #$20 ; |
  6. LDA #$0D02 ; | Use Mode 02 on register 210D
  7. STA $4330 ; | 4330 = Mode, 4331 = Register
  8. LDA #$9E00 ; | Address of HDMA table
  9. STA $4332 ; | 4332 = Low-Byte of table, 4333 = High-Byte of table
  10. SEP #$20 ; |
  11. LDA.b #$7F ; | Address of HDMA table, get bank byte
  12. STA $4334 ; | 4334 = Bank-Byte of table
  13. LDA #$08 ; |
  14. TSB $0D9F ; | Enable HDMA channel 3
  15. RTS ;/ End HDMA setup
  16. ;The Table takes up 226 bytes of the free RAM
  17. ;It ranges from $7F9E00 - $7F9EE1 (both addresses included)
  18.  
  19. .MainCode: ;\ This section is to be used in the MAIN code of
  20.  
  21. levelASM
  22. LDY #$00 ; | Y will be the loop counter.
  23. LDY #$00 ; | X the index for writing the table to the RAM
  24. LDA $13 ; | Speed of waves
  25. LSR #2 ; | Slowing down A
  26. STA $00 ;/ Save for later use.
  27.  
  28. PHB : PHK : PLB ;\ Preservev bank
  29. .Loop: ; | Jump back if not finished writing table
  30. LDA #$03 ; | Set scanline height
  31. STA $7F9E00,x ; | for each wave
  32. TYA ; | Transfer Y to A, to calculate next index
  33. ADC $00 ; | Add frame counter
  34. AND #$0F ; |
  35. PHY ; | Preserve loop counter
  36. TAY ;/ Get the index in Y
  37.  
  38. LDA.w .WaveTable,y ;\ Load in wave value
  39. LSR ; | Half only
  40. CLC ; | Clear Carry for addition
  41. ADC $1462 ; | Add value to layer X position (low byte)
  42. STA $7F9E01,x ; | store to HDMA table (low byte)
  43. LDA $1463 ; | Get high byte of X position
  44. ADC #$00 ; | Add value to layer X position (low byte)
  45. STA $7F9E02,x ;/ store to HDMA table (high byte)
  46.  
  47. PLY ;\ Pull original loop counter
  48. CPY #$4A ; | Compare if we have written enough HDMA entries.
  49. BPL .End ; | If bigger, end HDMA
  50. INX ; | Increase X, so that in the next loop, it writes the
  51.  
  52. new table data...
  53. INX ; | ... at the end of the old one instead of
  54.  
  55. overwritting it.
  56. INX ; |
  57. INY ; | Increase loop counter
  58. BRA .Loop ;/ Repeat loop
  59.  
  60. .End: ;\ Jump here when at the end of HDMA
  61. PLB ; | Pull back data bank.
  62. LDA #$00 ; | End HDMA by writting 00...
  63. STA $7F9E03,x ; | ...at the end of the table.
  64. RTS ;/
  65.  
  66. .WaveTable: ;\
  67. db $00 ; |
  68. db $01 ; |
  69. db $02 ; |
  70. db $03 ; |
  71. db $04 ; |
  72. db $05 ; |
  73. db $06 ; |
  74. db $07 ; |
  75. db $07 ; |
  76. db $06 ; |
  77. db $05 ; |
  78. db $04 ; |
  79. db $03 ; |
  80. db $02 ; |
  81. db $01 ; |
  82. db $00 ;/
  83.  
  84. .InitCodee: ;\ This section is to be used in the INIT code of
  85.  
  86. levelASM
  87. REP #$20 ; |
  88. LDA #$1002 ; | Use Mode 02 on register 2110
  89. STA $4340 ; | 4340 = Mode, 4341 = Register
  90. LDA #$9E04 ; | Address of HDMA table
  91. STA $4342 ; | 4342 = Low-Byte of table, 4343 = High-Byte of table
  92. SEP #$20 ; |
  93. LDA.b #$7F ; | Address of HDMA table, get bank byte
  94. STA $4344 ; | 4344 = Bank-Byte of table
  95. LDA #$10 ; |
  96. TSB $0D9F ; | Enable HDMA channel 4
  97. RTS ;/ End HDMA setup
  98. ;The Table takes up 226 bytes of the free RAM
  99. ;It ranges from $7F9E00 - $7F9EE1 (both addresses included)
  100.  
  101. .MainCodee: ;\ This section is to be used in the MAIN code of
  102.  
  103. levelASM
  104. LDY #$00 ; | Y will be the loop counter.
  105. LDY #$00 ; | X the index for writing the table to the RAM
  106. LDA $13 ; | Speed of waves
  107. LSR #2 ; | Slowing down A
  108. STA $00 ;/ Save for later use.
  109.  
  110. PHB : PHK : PLB ;\ Preservev bank
  111. .Loopee: ; | Jump back if not finished writing table
  112. LDA #$03 ; | Set scanline height
  113. STA $7F9E04,x ; | for each wave
  114. TYA ; | Transfer Y to A, to calculate next index
  115. ADC $00 ; | Add frame counter
  116. AND #$0F ; |
  117. PHY ; | Preserve loop counter
  118. TAY ;/ Get the index in Y
  119.  
  120. LDA.w .WaveTable,y ;\ Load in wave value
  121. LSR ; | Half only
  122. CLC ; | Clear Carry for addition
  123. ADC $1468 ; | Add value to layer Y position (low byte)
  124. STA $7F9E05,x ; | store to HDMA table (low byte)
  125. LDA $1469 ; | Get high byte of X position
  126. ADC #$00 ; | Add value to layer X position (low byte)
  127. STA $7F9E06,x ;/ store to HDMA table (high byte)
  128.  
  129. PLY ;\ Pull original loop counter
  130. CPY #$4A ; | Compare if we have written enough HDMA entries.
  131. BPL .End ; | If bigger, end HDMA
  132. INX ; | Increase X, so that in the next loop, it writes the
  133.  
  134. new table data...
  135. INX ; | ... at the end of the old one instead of
  136.  
  137. overwritting it.
  138. INX ; |
  139. INY ; | Increase loop counter
  140. BRA .Loop ;/ Repeat loop
  141.  
  142. .Endee: ;\ Jump here when at the end of HDMA
  143. PLB ; | Pull back data bank.
  144. LDA #$00 ; | End HDMA by writting 00...
  145. STA $7F9E07,x ; | ...at the end of the table.
  146. RTS ;/
  147.  
  148. .WaveTablee: ;\
  149. db $00 ; |
  150. db $02 ; |
  151. db $04 ; |
  152. db $06 ; |
  153. db $08 ; |
  154. db $0A ; |
  155. db $0C ; |
  156. db $0E ; |
  157. db $0E ; |
  158. db $0C ; |
  159. db $0A ; |
  160. db $08 ; |
  161. db $06 ; |
  162. db $04 ; |
  163. db $02 ; |
  164. db $00 ;/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement