Famicom PPU sprite evaluation is an elusive concept that I am currently trying to implement, but I am struggling to understand the wiki article "PPU sprite evaluation", and my attempt at implementing it results in most NES games having every sprite flicker (I don't mean when a game tries to display more than 8 sprites; enemies and blocks in Super Mario Bros. will flicker even when there is only 1 of each). More specifically, it is not clear to me exactly at which times the PPU switches between the 4 modes during cycles 64-256. I already understand that the PPU reads from primary OAM during odd cycles and writes to secondary OAM during even cycles, and that cycles 1-64 are for filling the secondary OAM with 0xFF.
- In step 2.1 (start at n = 0, sprite n's Y coördinate at OAM[n]), there is an instruction for when the Y coördinate is in range of the current scanline, which is to copy the tile ID, attributes, and X, but what if one is not found? Go to step 2, or stay on step 1?
- In step 2.2 (Increment n), 2a states to go to step 4 if n has overflowed to 0, 2b states to go to step 1 if less than 8 sprites are found, but in 2c, which disables writes to secondary OAM when 8 sprites are found, no step number is specified. Does it go to step 2.3 when that happens?
I would like to use Visual 2C02 to analyze the behavior myself, but Visual 2C02 is on a limited uplink, and it would be nice if it was available to download so that I don't have to stress the server.
The current source code is available
EDIT 1: changed terminology to clarify that I am talking about sub-steps 2.1-2.4 in step 2.
EDIT 2: Now that I did post the source code, a sentence above had to be changed to indicate where it can be found.