It is currently Thu Sep 20, 2018 6:46 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Sprite evaluation timing
PostPosted: Tue Sep 11, 2018 9:03 am 
Offline

Joined: Mon Aug 20, 2018 1:23 am
Posts: 2
I'm trying to figure out a good way of programming the PPU sprite evaluation state machine, but the nesdev page is a little unclear to me.
Quote:
n even cycles, data is written to secondary OAM (unless secondary OAM is full, in which case it will read the value in secondary OAM instead)
1. Starting at n = 0, read a sprite's Y-coordinate (OAM[n][0], copying it to the next open slot in secondary OAM (unless 8 sprites have been found, in which case the write is ignored).

1a. If Y-coordinate is in range, copy remaining bytes of sprite data (OAM[n][1] thru OAM[n][3]) into secondary OAM.

2. Increment n

2a. If n has overflowed back to zero (all 64 sprites evaluated), go to 4
2b. If less than 8 sprites have been found, go to 1
2c. If exactly 8 sprites have been found, disable writes to secondary OAM because it is full. This causes sprites in back to drop out.


Does 1 and 2 happen on the same cycle ?


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 7:36 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3154
Location: Brazil
I'm still rewriting my sprite evaluation logic, but I have a few notes. Hope it helps.

1. The sprite evaluation starts at PPU cycle 65. On odd cycles, data is read from primary OAM (sprite ram). On even cycles, the buffered data is written to the secondary OAM (32 bytes long).
2. Steps 1 and 2 refer to the normal evaluation. Step 3 is the weird evaluation, and step 4 is when less than 8 sprites are found in the current scanline.
3. 'n' scans through the primary OAM. If 'n'=64, then 'n' warps to 0. Go to step 4. It may be less than 8 sprites in the OAM secondary buffer though. No weird evaluation happens here.
4. If the secondary OAM is full, the weird evaluation starts! If 'n'=64, then 'n' warps to 0. Step 4 now takes place.
zzzz898 wrote:
Does 1 and 2 happen on the same cycle ?

Nope. Data must be read, then written to the secondary OAM. Next, it's checked if the buffer's full (8 sprites found).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group