sprite evaluation questions

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

sprite evaluation questions

Post by Zepper »

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?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: sprite evaluation questions

Post by tepples »

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).
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: sprite evaluation questions

Post by Zepper »

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?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: sprite evaluation questions

Post by tepples »

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?
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: sprite evaluation questions

Post by Zepper »

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
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: sprite evaluation questions

Post by tokumaru »

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.
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: sprite evaluation questions

Post by Quietust »

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.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: sprite evaluation questions

Post by Zepper »

Thanks Q.
Post Reply