I did this after the sprite 0 split and it worked:
Code: Select all
; Write (NameTable << 2) to PPUADDR
LDA NameTable
ASL
ASL
STA $2006
; Write VerticalScrollingPosition to PPUSCROLL
LDA VerticalScrollingPosition
STA $2005
; Save ((VerticalScrollingPosition & %11111000) << 2)
; to a temporary variable.
AND #%11111000
ASL
ASL
STA MergedScrollingValue
; Write ((HorizontalScrollingPosition >> 3) | ((VerticalScrollingPosition & %11111000) << 2))
; to the temporary variable.
LDA HorizontalScrollingPosition
LSR
LSR
LSR
ORA MergedScrollingValue
STA MergedScrollingValue
; TODO: Wait for hblank.
; Write HorizontalScrollingPosition to PPUSCROLL
LDA HorizontalScrollingPosition
STA $2005
; Write the temporary value to PPUADDR
LDA MergedScrollingValue
STA $2006
One more question:
How do I make sure that these writes are done in hblank?tepples wrote:Writes 3 and 4 must happen in horizontal blanking between X=256 and X=320.