Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;copied from defines-aut1.asm
- !BossFreeRAM2 = $18B4 ; used as misc persisting RAM in boss battles [cleared on level load]
- !BossFreeRAM3 = $18B7 ; used as misc persisting RAM in boss battles [cleared on level load]
- !ScrollRAM1 = $1696 ; custom scroll command table index [cleared on level load]
- !ScrollRAM2 = $18BB ; custom scroll command timer [cleared on level load]
- !FrameCount2 = $14
- !SpritesLocked = $9D
- !GamePaused = $13D4
- !GeneratorRAM = $18FE
- ;;;;;;;
- level11A: ; 7-2 main
- !XPartial = !BossFreeRAM2 ;\ reuse some misc RAM that I shouldn't need during autoscrollers
- !YPartial = !BossFreeRAM3 ;/
- ; LDA !ScrollRAM1 : LSR #4 : STA $0F0A ;\ debug: display custom autoscroll table index
- ; LDA !ScrollRAM1 : AND #$0F : STA $0F0B ;/
- ; LDA #$FC : STA $0F0C ; clear remaining "TIME" tile
- ; LDA !ScrollRAM2 : LSR #4 : STA $0F0D ;\ debug: display custom autoscroll timer
- ; LDA !ScrollRAM2 : AND #$0F : STA $0F0E ;/
- LDA !SpritesLocked
- ORA !GamePaused
- BNE .End ; if either sprites are locked or the game is paused, skip code
- REP #$20 ; set A to 16-bit
- LDA $1A ; if layer 1 X position
- CMP #$1400 ; ...is at the end of the level or later
- BCS .End ; don't autoscroll
- CMP.w #$09A4+#$24 ; ...is just after the midway entrance
- BNE +
- ; midway sync
- LDA #$0060 ;\
- STA $1C ;| ensure layer 1 Y position is lined up
- STA $1464 ;|
- SEP #$20 ; set A to 8-bit
- STZ !YPartial ;/
- LDA #$12 ;\
- STA !ScrollRAM1 ;/ initialize autoscroll phase to the midpoint value
- STZ !ScrollRAM2 ; and reset autoscroll timer
- STZ !GeneratorRAM ; also reset Bullet Bill generator timer
- +
- SEP #$20 ; set A to 8-bit
- ; autoscroller phase/timer
- LDY !ScrollRAM1 ; autoscroll phase
- LDA !FrameCount2 ;\
- AND #$07 ;/ increment timer only every 8th frame
- BNE +
- INC !ScrollRAM2 ; timer for autoscroll
- LDA !ScrollRAM2
- CMP PhaseTimer,y
- BNE +
- INC !ScrollRAM1 ; if timer is high enough, advance to next phase
- STZ !ScrollRAM2 ; and reset timer
- +
- JSR d4autoscroll ; run autoscrolling code (Y is table index)
- .End
- SEP #$20 ; set A to 8-bit, to allow branching here with 16-bit A
- RTS
- ; 0 1 2 3 4 5 6 7 8 9 A B C D E F
- PhaseTimer:
- db $08,$08,$60,$50,$60,$30,$20,$40,$18,$20,$70,$20,$08,$40,$10,$1E
- db $10,$FF,$30,$70,$24,$5C,$60,$10,$10,$10,$50,$10,$10,$10,$20,$FF
- ; dtothefourth's autoscrolling code
- ;x speeds for each phase, add or remove as needed, this is in full pixels so this will be very fast!
- Scroll_XSpeed:
- db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- db $00
- ;x speeds for each phase, add or remove as needed, this is 1/256 of a pixel so finer control
- Scroll_XSpeedPartial:
- db $40,$58,$70,$60,$70,$70,$50,$50,$50,$60,$70,$50,$60,$70,$50,$30
- db $50,$60,$70,$70,$70,$70,$70,$50,$40,$2C,$1E,$40,$60,$80,$A0,$C0
- db $70
- ;y speeds for each phase, add or remove as needed, this is in full pixels so this will be very fast!
- Scroll_YSpeed:
- db $00,$00,$FF,$00,$00,$FF,$FF,$00,$00,$FF,$00,$00,$00,$00,$FF,$FF
- db $FF,$00,$00,$00,$FF,$00,$00,$00,$00,$FF,$FF,$FF,$FF,$00,$00,$00
- db $00
- ;y speeds for each phase, add or remove as needed, this is 1/256 of a pixel so finer control
- Scroll_YSpeedPartial:
- db $00,$00,$F0,$20,$00,$E0,$F0,$10,$00,$F0,$10,$30,$10,$00,$E0,$C0
- db $E0,$00,$00,$12,$F0,$00,$18,$0C,$00,$E0,$C0,$E0,$F0,$00,$10,$10
- db $10
- d4autoscroll:
- ;move screen x, whole pixels
- LDA Scroll_XSpeed,Y
- STA $1447
- REP #$20
- BMI +
- AND #$00FF
- BRA ++
- +
- ORA #$FF00
- ++
- CLC
- ADC $1462
- STA $1462
- ;move screen y, whole pixels
- SEP #$20
- LDA Scroll_YSpeed,Y
- REP #$20
- BMI +
- AND #$00FF
- BRA ++
- +
- ORA #$FF00
- ++
- CLC
- ADC $1464
- STA $1464
- SEP #$20
- ;move screen x, sub pixels
- LDA Scroll_XSpeedPartial,Y
- STA $1446 ; force the player to move with the screen if they're on the edge
- CLC
- ADC !XPartial
- STA !XPartial
- BCC .XDone
- REP #$20
- INC $1462
- SEP #$20
- .XDone
- ;move screen y, sub pixels
- LDA Scroll_YSpeedPartial,Y
- CLC
- ADC !YPartial
- STA !YPartial
- BCC .YDone
- REP #$20
- INC $1464
- SEP #$20
- .YDone
- RTS
Advertisement
Add Comment
Please, Sign In to add comment