Selecting Window Layer Color?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Selecting Window Layer Color?
by on (#163803)
Well, I always thought that using the two windows would look good over (or under, I'll say that in a minute) a 2bpp BG to make it more colorful, but I went to looking at the window layer registers, but I haven't found one for specifying color, aside from this, but I don't understand what it means: (It's register $2132.)

SuperFamicom.org wrote:
bgrccccc
b/g/r = Which color plane(s) to set the intensity for.
ccccc = Color intensity.

Based on this, it appears that only straight red, blue, or green is possible, but unless I'm crazy, that isn't the case. Anyway, I wanted to actually put a colored window in the back of the screen behind the 2bpp layer to have more than one unique background color and potentially have 5 colors per tile. (This technique would work well for things like clouds where the edges have the biggest difference in color and the center is mostly solid.) You can say what you want, but the 2bpp layer annoys me the most about the SNES. (I haven't really done anything too CPU heavy yet though, so I don't know.) I still think a good trick would be to change the y scrolling value and the tilemap location register for BG 3 to effectively shrink the palette space and whatever else by whatever amount. Hell. if you're really crazy about it, you could do it to where every 8x1 pixel area is different, and in that case, you could have even more colors in an 8x8 area than what would be possible with 4bpp.
Re: Selecting Window Layer Color?
by on (#163804)
Other pages on that wiki, as well as nocash's explanation are more useful than just what's said there about the $2132 register:
sfcwiki:Transparency
fullsnes:SNES PPU Color Math
sfcwiki:Grog's Guide to Sub-Screen Addition - Subtraction and Mask Windows on the SNES
Re: Selecting Window Layer Color?
by on (#163805)
Espozo wrote:
register $2132

That's not window colour specifically; that's the subscreen backdrop. It's used in colour math, which you can mask using the windows. I'm pretty sure this could give you 8 colours per tile if BG3 is at the back, since you've got three colours per tile plus the main screen backdrop all being mathed, or not, with the subscreen backdrop.

The subscreen backdrop colour is 15-bit RGB, but it's set per-component - red, green, and blue are set separately. The "rgb" bits tell the PPU which component(s) your 5-bit value is intended for. You can set two or three of them at once by setting more than one of the "rgb" bits to 1 in your $2132 write, but that's only useful if you want a colour in which at least two RGB components have the same value. Gray, for example, can be set in one shot. Pure red, green, or blue can also be set in one shot, but only if the other two components are already zeroed (because if you don't send them a value, they won't change). An arbitrary RGB colour requires three writes in the general case.

For combining windowing with colour math, you'll want to look at $2125, $212B, and $2130 (assuming I didn't miss anything), in addition to the other registers that deal with either the windows or the colour math settings.