It is currently Sun Aug 19, 2018 8:45 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Jan 19, 2018 8:23 am 
Offline

Joined: Wed Jun 15, 2016 11:49 am
Posts: 69
Hi All,

I recently managed to pass Gekkio's sprite timing test rom in my emulator. This test seemed pretty intimidating at first, but it turned out that a fairly simple algorithm can be used to correctly account for the ppu cycles that are used to evaluate the sprites.

I thought I would share this here to maybe save anyone else working on this a few hours of getting started.

So to lay some groundwork, my emulator runs in single T-cycles (here after simply refered to as cycles), checks if sprite evaluation is needed every cycle, and effectively stalls the ppu whenever such an evaluation needs to happen.

Based on this, there are 4 rules to follow to stall the ppu for the correct number of cycles. They are:

1. Each sprite takes 6 cycles to evaluate.
2. If a sprites position is 0 or 1 (mod 8) then starting up sprite evaluation takes 2 extra cycles
3. If a sprites position is >=4 (mod 8) then starting up sprite evaluation takes 2 less cycles
4. If sprite evaluation ends before all sprites are evaluated, a shut down penalty is incurred as follows : position mod 8 of last sprite evaluated: (0,1,2,3,4,5,6,7) penalty: (3,2,3,2,3,2,2,2)

When I say start up, I mean that the first sprite in that evluation session takes either 8, 6, or 4 cycles to evaluate depending on the position. All other sprites in that same session will take the normal 6 cycles.

So that's all there is to it. Obviously this is only derived heuristically from the test, and more details are needed. It's not a cycle accurate sprite evaluation framework, but it passes the test in a simple enough way that I think we can start to understand what the PPU is doing from here.

Hope it helps someone else who is making their way through these tests.


Top
 Profile  
 
PostPosted: Sun Jan 21, 2018 5:53 pm 
Offline

Joined: Thu Jun 16, 2016 11:53 am
Posts: 11
I had a slightly different solution to this, maybe it will help: https://www.reddit.com/r/EmuDev/comment ... te_timing/


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 1 guest


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