While experimenting with the basic Nerdy Nights tutorials, I stumbled into an issue concerning Palettes and simple full color backgrounds ($2001).
I wrote a short minimal example in the attached code, where the task should be straightforward:
1. start the program: set the background to red
2. load some Palettes (they will be ignored)
3. at each frame, set the background to blue
The operation (2) is done in the section "LoadPalettes".
Now, if I comment that part, the code works as expected, otherwise I just get a constant black screen.
I really don't understand the reason for that, especially because I don't see the connection between $2001 and the palettes.
Any help would be very appreciated.
Thanks in advance!
Palettes conflict with simple background.
Moderator: Moderators
Palettes conflict with simple background.
- Attachments
-
- graphics.chr
- (16 KiB) Downloaded 16 times
-
- minimal.asm
- (1010 Bytes) Downloaded 17 times
Re: Palettes conflict with simple background.
The top bits of $2001 don't actually set the background color; instead, they apply something we've called "color emphasis" which merely tints the entire screen with a particular color.
On the NTSC/PAL PPUs this is done by darkening the other color channels (i.e. red emphasis will reduce the green and blue levels, and setting all 3 would dim the screen by about 25%), while on the RGB (arcade) PPUs this is done by forcing the specified channels to maximum intensity (i.e. red emphasis would turn black to red and turn green to yellow, and setting all 3 would turn the entire screen white).
On the NTSC/PAL PPUs this is done by darkening the other color channels (i.e. red emphasis will reduce the green and blue levels, and setting all 3 would dim the screen by about 25%), while on the RGB (arcade) PPUs this is done by forcing the specified channels to maximum intensity (i.e. red emphasis would turn black to red and turn green to yellow, and setting all 3 would turn the entire screen white).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
P.S. If you don't get this note, let me know and I'll write you another.
Re: Palettes conflict with simple background.
Since you don't have any graphics in yet, the only color you're gonna see is color 0, the background color (unless you point the VRAM address at specific palette entries, in which case the PPU will render that instead of the background color - this is a little quirk of the NES). This is the color you write to PPU address $3F00.
Looking at your code, you'd think that'd be color $31, seeing as that's the first color in your palette, but the NES palette has some weird mirroring going on: there's no physical memory for the first color of each sprite palette ($3F10, $3F14, $3F18 and $3F1C), they're actually mirrors of the corresponding colors in the background palettes ($3F00, $3F04, $3F08 and $3F0C). This means that you're overwriting the $31 with the $0F you have in the first sprite palette, and $0F is black.
Since the color emphasis bits in $2001 work by darkening specific color components, like Quietust said, they don't have any noticeable effect on black, which is already completely dark.
Looking at your code, you'd think that'd be color $31, seeing as that's the first color in your palette, but the NES palette has some weird mirroring going on: there's no physical memory for the first color of each sprite palette ($3F10, $3F14, $3F18 and $3F1C), they're actually mirrors of the corresponding colors in the background palettes ($3F00, $3F04, $3F08 and $3F0C). This means that you're overwriting the $31 with the $0F you have in the first sprite palette, and $0F is black.
Since the color emphasis bits in $2001 work by darkening specific color components, like Quietust said, they don't have any noticeable effect on black, which is already completely dark.
Re: Palettes conflict with simple background.
Fantastic. I tried modifying the code by loading another background palette, and it works.
I set a light blue palette, then wrote $%00100000 to $2001 (intensify red) and got a sort of violet background.
My misunderstood came from the NN tutorials, but now that I look better, he actually says "intensify" and not "set".
Therefore, my mistake.
And of course, thank you very much for the kind and complete explanation!
I set a light blue palette, then wrote $%00100000 to $2001 (intensify red) and got a sort of violet background.
My misunderstood came from the NN tutorials, but now that I look better, he actually says "intensify" and not "set".
Therefore, my mistake.
And of course, thank you very much for the kind and complete explanation!