Windows

From SNESdev Wiki
Revision as of 02:15, 13 October 2022 by Rainwarrior (talk | contribs) (→‎Window: invert does nothing if not enabled)
Jump to navigationJump to search

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:

Registers

See: PPU registers: Windows

Name Address Bits Type Notes
W12SEL $2123 DdCc BbAa W8 Enable (ABCD) and Invert (abcd) windows for BG1 (AB) and BG2 (CD).
W34SEL $2124 DdCc BbAa W8 Enable (EFGH) and Invert (efgh) windows for BG3 (EF) and BG2 (GH).
WOBJSEL $2125 LlKk JjIi W8 Enable (IJKL) and Invert (ijkl) windows for OBJ (IJ) and color (KL).
WH0 $2126 LLLL LLLL W8 Window 1 left position.
WH1 $2127 RRRR RRRR W8 Window 1 right position.
WH2 $2128 LLLL LLLL W8 Window 2 left position.
WH3 $2129 RRRR RRRR W8 Window 2 right position.
WBGLOG $212A 4433 2211 W8 Window mask logic for BG layers (00=OR, 01=AND, 10=XOR, 11=XNOR).
WOBJLOG $212B .... CCOO W8 Window mask logic for OBJ (O) and color (C).
TMW $212E ...O 4321 W8 Main screen layer window enable.
TSW $212F ...O 4321 W8 Sub screen layer window enable.
CGWSEL $2130 MMSS ..AD W8 main/sub screen color window black/transparent regions (MS), fixed/subscreen (A), direct color (D).

Window

The SNES has two window devices.

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 is disabled (all 0 output). HDMA can be used to create shapes by adjusting the left/right position for each scanline.

If the window is inverted (W12SEL/W34SEL), the left/right position instead defines where the window should not hide the affected layers. Invert has no effect if the window is not also enabled.

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).

See Also