1. During cycles 65-256, it occurs the sprite evaluation for the next scanline, and on cycles 257-320 the tile data fetching for the next scanline. At the beginning of the following scanline, the PPU starts clearing the secondary OAM buffer. Here - when is the first sprite pixel drawn on the screen?
What I do is... On the next scanline, copy the entire secondary OAM buffer and start drawing sprites when the current PPU cycle matches a certain sprite X-position, but is this correct?
2. When the sprite zero hit flag (PPU status $40) is cleared?
As I understand it: The X position of each of the frontmost 8 sprites on each line is copied from secondary OAM to a down counter when the sprite read out of secondary OAM during horizontal blanking. After that, the pattern shifter starts outputting pixels once the down counter expires.
All 3 status bits are cleared at the start of scanline -1, the pre-render scanline (NTSC/PAL-M: 261; PAL/Dendy: 311).
tepples wrote:
As I understand it: The X position of each of the frontmost 8 sprites on each line is copied from secondary OAM to a down counter when the sprite read out of secondary OAM during horizontal blanking. After that, the pattern shifter starts outputting pixels once the down counter expires.
Writes to the secondary OAM finish at cycle 320. "During horizontal blanking" of the
same scanline OR the
next scanline?
Based on the OAM access pattern during horizontal blank, I imagine that the copy of the X coordinate from secondary OAM to the down counter associated with the sprite shifter happens during the horizontal blank between the scanline when a sprite is evaluated and determined to be in range and the following scanline when it is displayed. For example, if an 8x1-pixel portion of sprite is evaluated on scanline 64 and displayed on scanline 65, the X copy happens in the horizontal blank between scanline 64 and scanline 65. The horizontal position of these reads is 263, 271, 279, 287, 295, 303, 311, and 319.
Could someone back this up with data from Visual 2C02?
tepples wrote:
Based on the OAM access pattern during horizontal blank, I imagine that the copy of the X coordinate from secondary OAM to the down counter associated with the sprite shifter happens during the horizontal blank between the scanline when a sprite is evaluated and determined to be in range and the following scanline when it is displayed. For example, if an 8x1-pixel portion of sprite is evaluated on scanline 64 and displayed on scanline 65, the happens in the horizontal blank between scanline 64 and scanline 65. The horizontal position of these reads is 263, 271, 279, 287, 295, 303, 311, and 319.
Could someone back this up with data from Visual 2C02?
bump
Zepper, I don't mean to be rude, but sometimes it looks like you're demanding answers from people when nobody really has them. Visual 2C02 is a public tool, so if these details about the workings of the NES are so important to you, maybe you should spend some time figuring it out so you can test these things yourself instead of asking others to do it for you.
For what it's worth, I investigated this a bit and confirmed that it is during the 5th "sprite fetch" cycle (i.e. 261/269/277/285/293/301/309/317) that the sprite's X coordinate is copied into the relevant sprite slot's countdown timer; the 4th cycle is when the attributes (palette+priority) are copied (and the X/Y flip are latched for the pattern fetches that happen during cycles 5-8).
I do agree, though, that Visual 2C02 is there so everyone can look at it and figure out how things work. The "teach a man to fish" adage is especially relevant here.