Zeldara109

AUT 7-2 d4autoscroll

May 25th, 2020
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. ;copied from defines-aut1.asm
  2. !BossFreeRAM2 = $18B4 ; used as misc persisting RAM in boss battles [cleared on level load]
  3. !BossFreeRAM3 = $18B7 ; used as misc persisting RAM in boss battles [cleared on level load]
  4. !ScrollRAM1 = $1696 ; custom scroll command table index [cleared on level load]
  5. !ScrollRAM2 = $18BB ; custom scroll command timer [cleared on level load]
  6.  
  7. !FrameCount2 = $14
  8. !SpritesLocked = $9D
  9. !GamePaused = $13D4
  10. !GeneratorRAM = $18FE
  11.  
  12. ;;;;;;;
  13.  
  14. level11A: ; 7-2 main
  15.  
  16. !XPartial = !BossFreeRAM2 ;\ reuse some misc RAM that I shouldn't need during autoscrollers
  17. !YPartial = !BossFreeRAM3 ;/
  18.  
  19. ; LDA !ScrollRAM1 : LSR #4 : STA $0F0A ;\ debug: display custom autoscroll table index
  20. ; LDA !ScrollRAM1 : AND #$0F : STA $0F0B ;/
  21. ; LDA #$FC : STA $0F0C ; clear remaining "TIME" tile
  22. ; LDA !ScrollRAM2 : LSR #4 : STA $0F0D ;\ debug: display custom autoscroll timer
  23. ; LDA !ScrollRAM2 : AND #$0F : STA $0F0E ;/
  24.  
  25. LDA !SpritesLocked
  26. ORA !GamePaused
  27. BNE .End ; if either sprites are locked or the game is paused, skip code
  28.  
  29. REP #$20 ; set A to 16-bit
  30. LDA $1A ; if layer 1 X position
  31. CMP #$1400 ; ...is at the end of the level or later
  32. BCS .End ; don't autoscroll
  33.  
  34. CMP.w #$09A4+#$24 ; ...is just after the midway entrance
  35. BNE +
  36. ; midway sync
  37. LDA #$0060 ;\
  38. STA $1C ;| ensure layer 1 Y position is lined up
  39. STA $1464 ;|
  40. SEP #$20 ; set A to 8-bit
  41. STZ !YPartial ;/
  42. LDA #$12 ;\
  43. STA !ScrollRAM1 ;/ initialize autoscroll phase to the midpoint value
  44. STZ !ScrollRAM2 ; and reset autoscroll timer
  45. STZ !GeneratorRAM ; also reset Bullet Bill generator timer
  46. +
  47. SEP #$20 ; set A to 8-bit
  48.  
  49. ; autoscroller phase/timer
  50. LDY !ScrollRAM1 ; autoscroll phase
  51.  
  52. LDA !FrameCount2 ;\
  53. AND #$07 ;/ increment timer only every 8th frame
  54. BNE +
  55. INC !ScrollRAM2 ; timer for autoscroll
  56. LDA !ScrollRAM2
  57. CMP PhaseTimer,y
  58. BNE +
  59. INC !ScrollRAM1 ; if timer is high enough, advance to next phase
  60. STZ !ScrollRAM2 ; and reset timer
  61. +
  62. JSR d4autoscroll ; run autoscrolling code (Y is table index)
  63. .End
  64. SEP #$20 ; set A to 8-bit, to allow branching here with 16-bit A
  65. RTS
  66.  
  67.  
  68. ; 0 1 2 3 4 5 6 7 8 9 A B C D E F
  69. PhaseTimer:
  70. db $08,$08,$60,$50,$60,$30,$20,$40,$18,$20,$70,$20,$08,$40,$10,$1E
  71. db $10,$FF,$30,$70,$24,$5C,$60,$10,$10,$10,$50,$10,$10,$10,$20,$FF
  72.  
  73. ; dtothefourth's autoscrolling code
  74. ;x speeds for each phase, add or remove as needed, this is in full pixels so this will be very fast!
  75. Scroll_XSpeed:
  76. db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  77. db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  78. db $00
  79.  
  80. ;x speeds for each phase, add or remove as needed, this is 1/256 of a pixel so finer control
  81. Scroll_XSpeedPartial:
  82. db $40,$58,$70,$60,$70,$70,$50,$50,$50,$60,$70,$50,$60,$70,$50,$30
  83. db $50,$60,$70,$70,$70,$70,$70,$50,$40,$2C,$1E,$40,$60,$80,$A0,$C0
  84. db $70
  85.  
  86. ;y speeds for each phase, add or remove as needed, this is in full pixels so this will be very fast!
  87. Scroll_YSpeed:
  88. db $00,$00,$FF,$00,$00,$FF,$FF,$00,$00,$FF,$00,$00,$00,$00,$FF,$FF
  89. db $FF,$00,$00,$00,$FF,$00,$00,$00,$00,$FF,$FF,$FF,$FF,$00,$00,$00
  90. db $00
  91.  
  92. ;y speeds for each phase, add or remove as needed, this is 1/256 of a pixel so finer control
  93. Scroll_YSpeedPartial:
  94. db $00,$00,$F0,$20,$00,$E0,$F0,$10,$00,$F0,$10,$30,$10,$00,$E0,$C0
  95. db $E0,$00,$00,$12,$F0,$00,$18,$0C,$00,$E0,$C0,$E0,$F0,$00,$10,$10
  96. db $10
  97.  
  98. d4autoscroll:
  99. ;move screen x, whole pixels
  100. LDA Scroll_XSpeed,Y
  101. STA $1447
  102. REP #$20
  103. BMI +
  104. AND #$00FF
  105. BRA ++
  106. +
  107. ORA #$FF00
  108. ++
  109. CLC
  110. ADC $1462
  111. STA $1462
  112.  
  113. ;move screen y, whole pixels
  114. SEP #$20
  115. LDA Scroll_YSpeed,Y
  116. REP #$20
  117. BMI +
  118. AND #$00FF
  119. BRA ++
  120. +
  121. ORA #$FF00
  122. ++
  123. CLC
  124. ADC $1464
  125. STA $1464
  126.  
  127. SEP #$20
  128.  
  129. ;move screen x, sub pixels
  130. LDA Scroll_XSpeedPartial,Y
  131. STA $1446 ; force the player to move with the screen if they're on the edge
  132. CLC
  133. ADC !XPartial
  134. STA !XPartial
  135. BCC .XDone
  136. REP #$20
  137. INC $1462
  138. SEP #$20
  139. .XDone
  140.  
  141. ;move screen y, sub pixels
  142. LDA Scroll_YSpeedPartial,Y
  143. CLC
  144. ADC !YPartial
  145. STA !YPartial
  146. BCC .YDone
  147. REP #$20
  148. INC $1464
  149. SEP #$20
  150. .YDone
  151. RTS
Advertisement
Add Comment
Please, Sign In to add comment