Turning rendering on/off midframe effects on picture

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
provably
Posts: 10
Joined: Tue Dec 15, 2015 3:50 am

Turning rendering on/off midframe effects on picture

Post by provably » Tue Dec 15, 2015 12:52 pm

Hello.

Does anyone have precise information on how turning rendering on/off midframe affects the output picture?

(I don't have any hardware to test anything. Please don't direct me to the Visual 2C02; it is enigmatic.)

User avatar
rainwarrior
Posts: 7822
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Turning rendering on/off midframe effects on picture

Post by rainwarrior » Tue Dec 15, 2015 1:23 pm

When you disable rendering, the screen will output the palette 0 (i.e. background) colour.

If the PPU address is changed to the $3F00 region while rendering is off, it will instead output whatever colour appears in the palette at the current address.

Finally, turning rendering off at some points during an active scanline can corrupt sprite evaluation on the next frame, I think? (I don't know the precise details, never tried it personally.)

Rendering is only "off" if both nametable and sprites are off, otherwise all the internal updates and fetching still happens, just one of them is masked. When both of them are off, rendering truly stops. (So turning off just sprites mid-scanline is completely fine. It's only turning the whole thing off that can corrupt sprite evaluation, AFAIK.)

provably
Posts: 10
Joined: Tue Dec 15, 2015 3:50 am

Re: Turning rendering on/off midframe effects on picture

Post by provably » Tue Dec 15, 2015 1:46 pm

Thank you for the reply.

I need information about what exactly is output after rendering turned off and on again.

User avatar
Dwedit
Posts: 4328
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Turning rendering on/off midframe effects on picture

Post by Dwedit » Tue Dec 15, 2015 2:55 pm

You turn off rendering, and you get the background color. If you have the PPU Address pointing into palette memory, you get that color instead.
You turn rendering on between dots 256 and 320, and the next scanline displays correctly, but without sprites for that scanline. (possibly stray secondary OAM garbage instead of proper sprites?)
You turn rendering on in the middle of a displayed scanline, and you get up to 16 stale background pixels, then proper pixels from that scanline but incorrectly scrolled horizontally, then the following scanlines are scrolled properly. The sprites for that line might be either nothing, or stray values from the secondary OAM. The sprites won't be correct until two scanlines after you turned rendering on. Since turning off rendering can possibly corrupt the OAM address, it might possibly even use the wrong OAM address and have corrupt sprites for the whole frame.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
dougeff
Posts: 2709
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Turning rendering on/off midframe effects on picture

Post by dougeff » Tue Dec 15, 2015 3:48 pm

What about turning Sprites on and/or off midframe?

(With rendering remaining on)

Would you get a section of screen where sprites disappear into (like an upward doorway).
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
tokumaru
Posts: 11745
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Turning rendering on/off midframe effects on picture

Post by tokumaru » Tue Dec 15, 2015 4:00 pm

Disabling one or the other (sprites or background) simply hides that layer's pixels, without affecting data fetching or sprite evaluation in any way, so it's perfectly safe to do at any time.

If you disable sprites only, all sprites will disappear until you turn them back on. Using this for doorways would be overkill though, since masking with transparent high priority sprites is generally simpler than timing raster effects, specially if you don't have an scanline counter at your disposal.

Disabling sprites is a good way to keep sprites from overlapping status bars, though.

provably
Posts: 10
Joined: Tue Dec 15, 2015 3:50 am

Re: Turning rendering on/off midframe effects on picture

Post by provably » Tue Dec 15, 2015 4:12 pm

Dwedit, thank you.
up to 16 stale background pixels
This depends on the fine X, right?

So, with rendering off, the PPU just "skips everything" (i. e. the shifts, tile loads are not performed)? Then, does the offset of the fetch pattern change when rendering is back on (do the four fetches begin occuring on m+8n cycles instead of 1+8n from then on)? Or is the fetch pattern unchanged?

Post Reply