Things in PPU that can change outside VBlank

Discuss emulation of the Nintendo Entertainment System and Famicom.
mkwong98
Posts: 319
Joined: Mon May 30, 2011 9:01 pm

Things in PPU that can change outside VBlank

Post by mkwong98 »

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.
User avatar
qbradq
Posts: 972
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq »

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.
mkwong98
Posts: 319
Joined: Mon May 30, 2011 9:01 pm

Post by mkwong98 »

Thank you for the info on reg 2005-7. What about writing to other registers outside VBlank?
User avatar
tokumaru
Posts: 12673
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

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.
mkwong98
Posts: 319
Joined: Mon May 30, 2011 9:01 pm

Post by mkwong98 »

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?
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames »

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.
User avatar
tokumaru
Posts: 12673
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

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. =)
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.
tepples
Posts: 23011
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)

Post by tepples »

During horizontal blanking, the PPU fetches the patterns for the next scanline's sprites and the next scanline's first two background tiles.