Im trying to add vertical scrolling to this project. I understand that there is a copy of the back ground in the nametables.
OFFSET_BACKGROUND_VERTICAL:
; Load the current vertical offset value
LDA offset_value
CLC
ADC #$01 ; Increment the offset by 1 (scroll one pixel)
STA offset_value ; Store the updated offset value back
; Check if the offset exceeds 240 lines (after wrapping)
CMP #$F0
BCC skip_wrap ; If it's less than 240, skip wrapping
; Handle wrapping by subtracting 240 and resetting offset
SBC #$F0
STA offset_value
; Switch to the next nametable (if needed)
LDA nametable_base
EOR #$04 ; Toggle between $2000 and $2400 (flip bit 2)
STA nametable_base
skip_wrap:
; Apply the scroll update to the PPU
LDA nametable_base
STA PPU_VRAM_ADDR2 ; Set the high byte of the scroll register
LDA offset_value
STA PPU_VRAM_ADDR2 ; Set the low byte of the scroll register
RTS ; Return to the calling routine
nametable_base:
.byte $20 ; Initialize with $2000 as default
this is my routine so far, test it using the select button. Can someone help me ? im trying to scroll the mirrored background in $2400. My main background is at $2000.
OFFSET_BACKGROUND_VERTICAL:
; Load the current vertical offset value
LDA offset_value
CLC
ADC #$01 ; Increment the offset by 1 (scroll one pixel)
STA offset_value ; Store the updated offset value back
; Check if the offset exceeds 240 lines (after wrapping)
CMP #$F0
BCC skip_wrap ; If it's less than 240, skip wrapping
; Handle wrapping by subtracting 240 and resetting offset
SBC #$F0
STA offset_value
; Switch to the next nametable (if needed)
LDA nametable_base
EOR #$04 ; Toggle between $2000 and $2400 (flip bit 2)
STA nametable_base
skip_wrap:
; Apply the scroll update to the PPU
LDA nametable_base
STA PPU_VRAM_ADDR2 ; Set the high byte of the scroll register
LDA offset_value
STA PPU_VRAM_ADDR2 ; Set the low byte of the scroll register
RTS ; Return to the calling routine
nametable_base:
.byte $20 ; Initialize with $2000 as default
this is my routine so far, test it using the select button. Can someone help me ? im trying to scroll the mirrored background in $2400. My main background is at $2000.
Statistics: Posted by v.depatie — Tue Dec 10, 2024 5:24 pm — Replies 3 — Views 99