Things in PPU that can change outside VBlank

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Things in PPU that can change outside VBlank
by on (#80278)
From what I've read, scrolling can be modified anytime, pattern table and name table(including attribute table?) can be modified during VBlank or when PPU is disabled. What about other memory addresses and registers? Thanks.

by on (#80285)
You are over-simplifying things. Now I am no PPU expert so I won't go into specifics. You'll have to research that on your own.

The PPU has at least one address register that I know of that it uses while rendering the background. This address register is a combination of the name table selection bits and the scrolling bits.

The reason that writing to the PPU address space during rendering screws things up is that read / write access through $2006 / $2007 uses (parts of) the address register mentioned above.

It's really a threading issue at the hardware level. Kinda cool :D

Anyway, you should probably start out reading the PPU Reference on the Wiki, followed by The Skinny on NES Scrolling by loopy.

by on (#80299)
Thank you for the info on reg 2005-7. What about writing to other registers outside VBlank?

by on (#80300)
Basically, you can do anything except memory accesses. Here's a list of registers that can be changed during rendering time:

$2000: YES;
$2001: YES;
$2003: NO;
$2004: NO;
$2005: YES;
$2006: YES, only for scrolling;
$2007: NO;

Whatever can be controlled by these registers can be changed during rendering. The only exception I can think of is the vertical scroll, that won't take effect until the next frame unless you use combined $2005/$2006 writes (a trick discovered by loopy a few years ago).

Anything that needs memory accesses (i.e. $2006 & $2007), like pattern tables, name tables, attribute tables and palettes can't be changed while rendering. Accesses to OAM (sprites) also screw things up.

by on (#80301)
Thanks! So does it mean I can do anything outside VBlank as long as I disable the PPU? And what about HBlank? Does it count as rendering?

by on (#80302)
Every HBlank I think updates the scrolling and sprites for the next scanline. And then $2006 during rendering does different stuff than in VBlank, so you may want to read up on that too.

by on (#80305)
mkwong98 wrote:
So does it mean I can do anything outside VBlank as long as I disable the PPU?

Yes, but you'll get no picture until it's enabled again. =)

Quote:
And what about HBlank? Does it count as rendering?

I believe part of the HBlank is spent on tasks related to rendering, such as fetching the sprite patterns for the next scanline and such. There may be a small window for memory accesses, but it's so little time you can't really do anything useful with it.

by on (#80308)
During horizontal blanking, the PPU fetches the patterns for the next scanline's sprites and the next scanline's first two background tiles.