Palette shown when background rendering disabled

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Bisqwit
Posts: 248
Joined: Fri Oct 14, 2011 1:09 am

Palette shown when background rendering disabled

Post by Bisqwit »

http://wiki.nesdev.com/w/index.php/PPU_palettes wrote:If rendering is disabled in PPUMASK ($2001), and the current VRAM address points in $3F00-$3FFF, this color will be shown on screen instead of the backdrop color. A loop that fills the palette will cause each color in turn to be shown on the screen. So to avoid horizontal rainbow bar glitches while loading the palette, wait for a real vertical blank first using an NMI technique.
I find this a bit ambiguous.
So what does it render on the screen, if the address points to $3F11 for instance, does it render color #$11, or does it render color that is in palette at index #$11?
Last edited by Bisqwit on Tue Oct 18, 2011 9:00 am, edited 1 time in total.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Renders what's in the palette I believe. Otherwise you'd only get under 32 possible colors.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Bisqwit
Posts: 248
Joined: Fri Oct 14, 2011 1:09 am

Post by Bisqwit »

Does the special rule also apply to the 8 pixel edge areas if background rendering is disabled on the 8 pixel edges but not otherwise on the screen?
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

I seriously doubt it, as the PPU only enters in it's special "forced blanking" mode when both BG and sprites are disabled, and in this state, left-clipping state does not matter and is overriden.

In any other state (if BG OR sprites OR both are enabled), the PPU does ALL it's fetches even for the disabled planes, and even for the tiles/sprites that falls behind the possibly behind the left-clipped area, it's just that the disabled BG/sprite/left-clipping areas are replaced by transparent pixels at a later stage, and then the transparent color is used.
Useless, lumbering half-wits don't scare us.
beannaich
Posts: 207
Joined: Wed Mar 31, 2010 12:40 pm

Post by beannaich »

Code: Select all

if (hClock < 256 && vClock != -1)
{
    int pixel = (scroll.addr & 0x3F00) == 0x3F00 ? (scroll.addr & 0x1F) : 0;

    colorBuffer[(vClock << 8) | hClock] = colorSwatch[memory.PeekByte(0x3F00 | pixel) & palMask | palEmph];
}
Bisqwit wrote:Does the special rule also apply to the 8 pixel edge areas if background rendering is disabled on the 8 pixel edges but not otherwise on the screen?
Background clipping shouldn't occur when the background is disabled, the same goes for sprites.
Bisqwit
Posts: 248
Joined: Fri Oct 14, 2011 1:09 am

Post by Bisqwit »

beannaich wrote:Background clipping shouldn't occur when the background is disabled, the same goes for sprites.
I did not claim it would, and your post does not address my question.
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Palette shown when background rendering disabled

Post by Zepper »

Bisqwit wrote:So what does it render on the screen, if the address points to $3F11 for instance, does it render color #$11, or does it render color that is in palette at index #$11?
It renders color that is in palette at index #$11. Ditto.
Try Micro Machines.
Bisqwit
Posts: 248
Joined: Fri Oct 14, 2011 1:09 am

Re: Palette shown when background rendering disabled

Post by Bisqwit »

Zepper wrote:
Bisqwit wrote:So what does it render on the screen, if the address points to $3F11 for instance, does it render color #$11, or does it render color that is in palette at index #$11?
It renders color that is in palette at index #$11. Ditto.
Thanks.

Does the palette index get shown on the edges if the user pokes in $3F11 while the PPU is rendering an edge (and background rendering is not globally disabled but is disabled on the 8 pixel edges)?
beannaich
Posts: 207
Joined: Wed Mar 31, 2010 12:40 pm

Post by beannaich »

Bisqwit wrote:
beannaich wrote:Background clipping shouldn't occur when the background is disabled, the same goes for sprites.
I did not claim it would, and your post does not address my question.
If that's not what you meant by the "8 pixels edge in the background" then ignore what I said.

To answer your first question, when background rendering is off, and the PPU address points to a palette index, that color is drawn to the screen. That is what the code I posted shows.

If the address is $3F11, and the dot is 25, scanline 40. Then the color at 25,40 will be whatever color palette[paletteRam[$11]] is.

This behavior can be tested with blargg's full palette test ROMs.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Bisqwit, I think you're confusing us all with "8 pixel edges"... What exactly do you mean by that?

Do you mean the leftmost 8-pixel column we can ask the PPU not to render? That will always show up as color 0. The only time when the PPU renders the color pointed to by the VRAM address is when rendering is completely disabled (sprites and background are turned off).

Note that there are certain entries of the palette that can only be seen this way. The colors at memory locations $3F04, $3F08 and 3F0C will be displayed if you point to them while rendering is off, but when rendering is on they will show whatever color 0 is.
Bisqwit
Posts: 248
Joined: Fri Oct 14, 2011 1:09 am

Post by Bisqwit »

tokumaru wrote:Bisqwit, I think you're confusing us all with "8 pixel edges"... What exactly do you mean by that?
Do you mean the leftmost 8-pixel column we can ask the PPU not to render?
Yes. I don't know how I could have been clearer about it.
That will always show up as color 0. The only time when the PPU renders the color pointed to by the VRAM address is when rendering is completely disabled (sprites and background are turned off).

Note that there are certain entries of the palette that can only be seen this way. The colors at memory locations $3F04, $3F08 and 3F0C will be displayed if you point to them while rendering is off, but when rendering is on they will show whatever color 0 is.
Allright. Thank you. You get brownie points for the very clear and comprehensive answer. :-)

EDIT: One more thing. Is the color shown when rendering is off and memory location points to $3Fxx, subject to de-emphasis and grayscale control bits?
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

EDIT: One more thing. Is the color shown when rendering is off and memory location points to $3Fxx, subject to de-emphasis and grayscale control bits?
I think yes, because this is done by a circuit which is after the normal pixel generation circuit.
Useless, lumbering half-wits don't scare us.
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

Bisqwit wrote:One more thing. Is the color shown when rendering is off and memory location points to $3Fxx, subject to de-emphasis and grayscale control bits?
Good question. Well, fortunately, there's a way to check it out. Try SMB3 - once you beat the castle boss (Boom-Boom), the screen clipping is enabled and the screen flashes in black and white. If you have the cart and a modern TV (LCD, LED etc.), try out.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

I know it's subject to tint bits because blargg's palette demos use this.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Zepper wrote:
Bisqwit wrote:One more thing. Is the color shown when rendering is off and memory location points to $3Fxx, subject to de-emphasis and grayscale control bits?
Good question. Well, fortunately, there's a way to check it out. Try SMB3 - once you beat the castle boss (Boom-Boom), the screen clipping is enabled and the screen flashes in black and white. If you have the cart and a modern TV (LCD, LED etc.), try out.
Or just cast Heal in Dragon Warrior 1, or have the old man restore your MP.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Post Reply