I'm trying to make a spr 0 demo that will scroll bg from 00h to 80h during the frame. It uses mapper one and single screen mirroring. Comment out the first ResetScroll and the bg does scroll to 80h at spr0 hit but doesn't display at 00h. With both ResetScroll calls it stays at 00h.
To be safe the whole bg is opaque with a sprite near the top so I know it's hitting the sprite. Looking at debug confirms. Is there anything missing here?
Edit: code below
To be safe the whole bg is opaque with a sprite near the top so I know it's hitting the sprite. Looking at debug confirms. Is there anything missing here?
Edit: code below
Code:
NMI:
LDA #%00001000
STA $2000
JSR ReadController
JSR HandleKeyPress
LDA PPUSTAT
LDA #20h
STA $2006
LDA #00h
STA $2006
JSR ResetScroll
Spr0Clear:
LDA $2002
AND #%01000000
BNE Spr0Clear
Spr0Hit:
LDA $2002
AND #%01000000
BEQ Spr0Hit
GotSpr0:
LDY 014h
Delay:
DEY
BNE Delay
LDA PPUSTAT
LDA #24h
STA $2006
LDA #00h
STA $2006
LDX #00h
STX PPUSCRL
STX PPUSCRL
LDA #%10001000
STA $2000
RTI
ResetScroll:
LDX PPUSTAT
LDX X_POS
STX PPUSCRL
LDX Y_POS
STX PPUSCRL
RTS
LDA #%00001000
STA $2000
JSR ReadController
JSR HandleKeyPress
LDA PPUSTAT
LDA #20h
STA $2006
LDA #00h
STA $2006
JSR ResetScroll
Spr0Clear:
LDA $2002
AND #%01000000
BNE Spr0Clear
Spr0Hit:
LDA $2002
AND #%01000000
BEQ Spr0Hit
GotSpr0:
LDY 014h
Delay:
DEY
BNE Delay
LDA PPUSTAT
LDA #24h
STA $2006
LDA #00h
STA $2006
LDX #00h
STX PPUSCRL
STX PPUSCRL
LDA #%10001000
STA $2000
RTI
ResetScroll:
LDX PPUSTAT
LDX X_POS
STX PPUSCRL
LDX Y_POS
STX PPUSCRL
RTS