Just how cranky is the PPU OAM?
Page 3 of 3

Author:  Quietust [ Sat Mar 23, 2013 4:33 pm ]
Post subject:  Re: Just how cranky is the PPU OAM?

While looking through my available test programs, I found one that was surprisingly similar to what's being tested here, so I made a few additions to make this.

Start - Perform the test
Left/Right - Decrement/increment "addr1"
Up/Down - Decrement/increment "addr2"
B - Toggle "skipwr2"
A - Toggle "skiprender"
Select - Toggle "skipframe"

Top row: 3 numbers, left to right.
First number: value of "addr1". Displayed in gray if "skipframe" is enabled.
Second number: zero. Displayed in gray if "skiprender" is enabled.
Third number: value of "addr2". Displayed in gray if "skipwr2" is enabled.

Upon pressing Start, the following sequence is executed (starting during VBLANK):
1. Enable rendering for the coming frame.
2. Write "addr1" to $2003 and perform a Sprite DMA.
3. If "skipwr2" is not enabled, write "addr2" to $2003.
4. If "skipframe" is set, skip to step 7.
5. If "skiprender" is set, write $00 to $2001 (to disable rendering).
6. Wait until the next NMI.
7. If "skiprender" or "skipframe" is set, write $00 to $2003 (the PPU will do this for us otherwise).
8. Read values from OAM and print them to the screen.

Test results are printed in sets of 8 sprites per 3 lines, with each sprite's bytes grouped into 8 consecutive digits. Result values which differ from the previous test are shown in gray, while values which have not changed are shown in white.

From running an earlier version of the test on my CopyNES, I've observed the following:
1. When $2003 contains a nonzero value before rendering starts, the OAM bytes in that page get copied to page 0 once rendering starts. If OAM is read back immediately instead of letting rendering start, this doesn't happen.
2. Depending on CPU/PPU clock alignment, the very act of writing to $2003 can cause bytes to get copied from one page to another (in one case, I was seeing $20-$27 getting copied to the page specified by $2003).
3. Depending on CPU/PPU clock alignment, some values of "addr2" may cause other indeterminate (but consistent) values to be modified (e.g. OAM[$06] would sometimes have bit 6 cleared).

I haven't yet tested what happens when "skiprender" is enabled (I just added it now, and my CopyNES is off right now).

Page 3 of 3 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group