I feel kind of silly asking about this, but I'm having some problems with a project I've been working on that I can't quite figure out.
In this project, I have a loop which writes 5k data to WRAM which will then be written to the PPU over the course of 4 frames (3 frames for 4k of CHR, and 1 for 1k of NT). I swap name tables and CHR banks every time this happens, so the viewer sees what was previously dumped into the PPU as it works on the next bunch of writes. Obviously this requires the PPU to be disabled outside of Vblank to happen in 4 frames. Specifically, I disable rendering at scanline 192, and re-enable after a chunk of data has been transferred over. For CHR updates, the writes are finished at scanline 32.5 of the next frame, and the name table updates don't require me to enable rendering late in the frame. The scroll is supposed to be static, fixed to the contents of one name table or the other.
I'm having a problem where Nintendulator sometimes fails to detect my sprite #0 hit after I re-enable rendering for each CHR transfer. What I've assumed is that it is because I am not properly resetting my scroll, which would cause the screen to be misaligned with sprite #0, thus causing a hit to not occur. I firstly want to make sure I am setting my scroll correctly. What I don't know is if I am actually in HBlank while I'm setting the important writes. Here is a snippet where I'm re-enabling rendering after doing a transfer, and waiting for a sprite #0 hit afterwards:
So with this piece of code, all I'm trying to do is wait for HBlank, and re-enable rendering so it starts rendering at pixel row #33 of the name table that is currently being viewed. I think this is right, but perhaps I'm doing something wrong? Also, if I'm going off of what Nintendulator says, I'm not sure if Hblank is considered the end of scanline 32, or the start of scanline 33. So maybe I'm setting the scroll in the wrong place...
The scroll may not be the issue, but I think it is. As I've said, Nintendulator only sometimes fails (but it fails pretty much immediately). I did a test on the PowerPak, and it seems to fail when I reset sometimes, so I think whatever the issue is, it's the same on both.
Any help is appreciated; thank you in advance!
In this project, I have a loop which writes 5k data to WRAM which will then be written to the PPU over the course of 4 frames (3 frames for 4k of CHR, and 1 for 1k of NT). I swap name tables and CHR banks every time this happens, so the viewer sees what was previously dumped into the PPU as it works on the next bunch of writes. Obviously this requires the PPU to be disabled outside of Vblank to happen in 4 frames. Specifically, I disable rendering at scanline 192, and re-enable after a chunk of data has been transferred over. For CHR updates, the writes are finished at scanline 32.5 of the next frame, and the name table updates don't require me to enable rendering late in the frame. The scroll is supposed to be static, fixed to the contents of one name table or the other.
I'm having a problem where Nintendulator sometimes fails to detect my sprite #0 hit after I re-enable rendering for each CHR transfer. What I've assumed is that it is because I am not properly resetting my scroll, which would cause the screen to be misaligned with sprite #0, thus causing a hit to not occur. I firstly want to make sure I am setting my scroll correctly. What I don't know is if I am actually in HBlank while I'm setting the important writes. Here is a snippet where I'm re-enabling rendering after doing a transfer, and waiting for a sprite #0 hit afterwards:
Code:
jsr UpdateCHR1 ;TIMED CODE, disable rendering 11,625 cycles. Ends at scanline 32, cycle 25
lda Virtual$2000 ;28
sta $2000 ;32
ldx #9 ;34
-
dex ;*2
bne - ;*5
;5*9 = 45 - 1 = 44 + 34 = 78
nop ;80
lda CurrentNTBeingUpdated ;83
eor #$04 ;85
sta $2006 ;89
lda #33 ;91
sta $2005 ;95
ldx #0 ;97
lda #$80 ;99
ldy #$1E ;101
stx $2005 ;105
sta $2006 ;109
sty $2001 ;112
;other processing
- ;Wait for sprite #0 hit to do next chunk of writes
bit $2002
bvs -
-
bit $2002
bvc -
lda Virtual$2000 ;28
sta $2000 ;32
ldx #9 ;34
-
dex ;*2
bne - ;*5
;5*9 = 45 - 1 = 44 + 34 = 78
nop ;80
lda CurrentNTBeingUpdated ;83
eor #$04 ;85
sta $2006 ;89
lda #33 ;91
sta $2005 ;95
ldx #0 ;97
lda #$80 ;99
ldy #$1E ;101
stx $2005 ;105
sta $2006 ;109
sty $2001 ;112
;other processing
- ;Wait for sprite #0 hit to do next chunk of writes
bit $2002
bvs -
-
bit $2002
bvc -
So with this piece of code, all I'm trying to do is wait for HBlank, and re-enable rendering so it starts rendering at pixel row #33 of the name table that is currently being viewed. I think this is right, but perhaps I'm doing something wrong? Also, if I'm going off of what Nintendulator says, I'm not sure if Hblank is considered the end of scanline 32, or the start of scanline 33. So maybe I'm setting the scroll in the wrong place...
The scroll may not be the issue, but I think it is. As I've said, Nintendulator only sometimes fails (but it fails pretty much immediately). I did a test on the PowerPak, and it seems to fail when I reset sometimes, so I think whatever the issue is, it's the same on both.
Any help is appreciated; thank you in advance!