Windows

Windows are used to hide layers from regions of the screen. On a per-scanline basis, they can be used to cut out areas of:
 * Background layers (BG1, BG2, BG3, BG4)
 * The Sprite layer (OBJ)
 * The main screen
 * The sub screen (color math)

Registers
See: PPU registers: Windows

Window
The SNES has two window devices which can be used to selectively cut holes out of parts of the picture.

Each window has a left and right pixel position (WH0/WH1/WH2/WH3) where the window should hide the affected layers. The window effect (1 output) is at left <= X <= right. If left > right then the window effect is nowhere (all 0 output). HDMA can be used to create shapes by adjusting the left/right position for each scanline.

Each window can be separately enabled for the various layers, and also inverted (W12SEL/W34SEL). If the window is inverted, the left/right position instead defines where the window should not hide the affected layers (if left > right, the window effect is everywhere, all 1 output). If the window is disabled then invert has no effect (all 0 output).

Additionally if two windows are enabled for the same layer, boolean logic can be applied between them (WBGLOG/WOBJSEL). An individual window is 0 when showing the layer, and 1 when hiding it. This logic will combine the effect of both windows in the chosen way.

The windows can be selectively applied to the main screen and sub screen layers (TMW/TSW).

Finally, the color window can be used to black areas of the main screen, or create a transparent region on the sub screen to mask color math (CGWSEL).

Window Mask Logic
If both windows are enabled on the same layer, they will be combined using either OR, AND, XOR or XNOR boolean logic as set by the Window mask logic registers (WBGLOG/WOBJLOG).

When the window mask logic bits are combined with the invert window flags they form 16 different configurations, 10 of which are unique.