Passing Gekkio's intr_2_mode0_timing_sprites test ROM

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
Alyosha_TAS
Posts: 102
Joined: Wed Jun 15, 2016 11:49 am

Passing Gekkio's intr_2_mode0_timing_sprites test ROM

Post by Alyosha_TAS » Fri Jan 19, 2018 8:23 am

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.

binji
Posts: 11
Joined: Thu Jun 16, 2016 11:53 am

Re: Passing Gekkio's intr_2_mode0_timing_sprites test ROM

Post by binji » Sun Jan 21, 2018 5:53 pm

I had a slightly different solution to this, maybe it will help: https://www.reddit.com/r/EmuDev/comment ... te_timing/

Post Reply