Well, I had sprite 0 added to a little program I am working on, and for some reason, it just doesn't work. I am either on nametable 0 ot 1 in the program, and it switches back and forth, and when the needed info on both is done, will switch to nametable #0. With this code, it is always on nametable 0 and is just perplexing me.
I just need it to wait for it, and then write the MSB of the main nametable to 0. It just doesn't work though. I've tried BIT $2002 then BVC to loop it first, but that didn't work. I moved my sprite up and make sure it was on the background white pixel, but that's a no-go either. So I made the sprite the same as what it went over and moved it there and it still doesn't work at all. Would me doing the write in the middle of the scanline be affecting it? I also tried writing scroll too but that didn't do anything either. It's always 0 with this little program so that's not the problem either. So I'm kinda at a loss of what is causing this. If I do just a JSR/RTS from it, it works perfectly and the nametable switches as needed, but with it, it just breaks and stays on the nametable 0. I just can't figure this out. I'd post more code, but I am confident the problem is just this routine. The program even reflects the change when grabbing the characters, this just doesn't work.
Thanks!
EDIT:
Got it to work, my problem is that I assumed at NMI being flagged it cleared, but I guess not, as this new code works for anybody else having this problem: [Somewhat aken from Nerdy Nights]
Well, for anyone else who has a problem, hope this helps, sorry for posting a topic. Of course, 30 minutes of trying and I figure it out after I post a topic, ugh. So is it cleared at the start of rendering? Is that what happens?
Code:
Sprite0HitTest:
LDA $2002
AND #$40
BEQ Sprite0HitTest
LDA PPUCTRL
AND #$FE
STA $2000
RTS
LDA $2002
AND #$40
BEQ Sprite0HitTest
LDA PPUCTRL
AND #$FE
STA $2000
RTS
I just need it to wait for it, and then write the MSB of the main nametable to 0. It just doesn't work though. I've tried BIT $2002 then BVC to loop it first, but that didn't work. I moved my sprite up and make sure it was on the background white pixel, but that's a no-go either. So I made the sprite the same as what it went over and moved it there and it still doesn't work at all. Would me doing the write in the middle of the scanline be affecting it? I also tried writing scroll too but that didn't do anything either. It's always 0 with this little program so that's not the problem either. So I'm kinda at a loss of what is causing this. If I do just a JSR/RTS from it, it works perfectly and the nametable switches as needed, but with it, it just breaks and stays on the nametable 0. I just can't figure this out. I'd post more code, but I am confident the problem is just this routine. The program even reflects the change when grabbing the characters, this just doesn't work.
Thanks!
EDIT:
Got it to work, my problem is that I assumed at NMI being flagged it cleared, but I guess not, as this new code works for anybody else having this problem: [Somewhat aken from Nerdy Nights]
Code:
Sprite0HitTest:
BIT $2002
BVS Sprite0HitTest ;Wait for it to be cleared for some reason. That reason is because if we run this inside of vblank, it is not instantly tripped, causing the splitting scroll to never happen.
Sprite0HitLoop:
BIT $2002
BVC Sprite0HitLoop ;Wait for it to hit again.
LDA PPUCTRL
AND #$FE
STA $2000
RTS
BIT $2002
BVS Sprite0HitTest ;Wait for it to be cleared for some reason. That reason is because if we run this inside of vblank, it is not instantly tripped, causing the splitting scroll to never happen.
Sprite0HitLoop:
BIT $2002
BVC Sprite0HitLoop ;Wait for it to hit again.
LDA PPUCTRL
AND #$FE
STA $2000
RTS
Well, for anyone else who has a problem, hope this helps, sorry for posting a topic. Of course, 30 minutes of trying and I figure it out after I post a topic, ugh. So is it cleared at the start of rendering? Is that what happens?