SNES Window/Masking System. More...
#include <snes/types.h>Go to the source code of this file.
Macros | |
| #define | WINDOW_1 0 |
| Window 1. | |
| #define | WINDOW_2 1 |
| Window 2. | |
| #define | WINDOW_ALL (WINDOW_ALL_BG | WINDOW_OBJ) |
| All layers including sprites. | |
| #define | WINDOW_ALL_BG (WINDOW_BG1 | WINDOW_BG2 | WINDOW_BG3 | WINDOW_BG4) |
| All background layers. | |
| #define | WINDOW_BG1 BIT(0) |
| BG1 layer. | |
| #define | WINDOW_BG2 BIT(1) |
| BG2 layer. | |
| #define | WINDOW_BG3 BIT(2) |
| BG3 layer. | |
| #define | WINDOW_BG4 BIT(3) |
| BG4 layer. | |
| #define | WINDOW_LOGIC_AND 1 |
| AND: mask if inside window 1 AND window 2. | |
| #define | WINDOW_LOGIC_OR 0 |
| OR: mask if inside window 1 OR window 2. | |
| #define | WINDOW_LOGIC_XNOR 3 |
| XNOR: mask if inside both or neither window. | |
| #define | WINDOW_LOGIC_XOR 2 |
| XOR: mask if inside exactly one window. | |
| #define | WINDOW_MAIN_SCREEN 0 |
| Apply window to main screen. | |
| #define | WINDOW_MASK_INSIDE 0 |
| Show layer inside window, hide outside. | |
| #define | WINDOW_MASK_OUTSIDE 1 |
| Show layer outside window, hide inside. | |
| #define | WINDOW_MATH BIT(5) |
| Color math (affects color blending) | |
| #define | WINDOW_OBJ BIT(4) |
| Sprites (OBJ) layer. | |
| #define | WINDOW_SUB_SCREEN 1 |
| Apply window to sub screen. | |
Functions | |
| void | windowCentered (u8 window, u8 width) |
| Create a centered rectangular window. | |
| void | windowDisable (u8 window, u8 layers) |
| Disable window for specified layers. | |
| void | windowDisableAll (void) |
| Disable all windows. | |
| void | windowEnable (u8 window, u8 layers) |
| Enable window for specified layers. | |
| void | windowInit (void) |
| Initialize window system. | |
| void | windowSetInvert (u8 window, u8 layers, u8 invert) |
| Set window inversion for layers. | |
| void | windowSetLogic (u8 layer, u8 logic) |
| Set logic operation for combining windows. | |
| void | windowSetMainMask (u8 layers) |
| Set main screen window masking. | |
| void | windowSetPos (u8 window, u8 left, u8 right) |
| Set window boundaries. | |
| void | windowSetSubMask (u8 layers) |
| Set sub screen window masking. | |
| void | windowSplit (u8 splitX) |
| Create a vertical split at the specified X position. | |
SNES Window/Masking System.
Windows are rectangular regions that can mask (hide or show) portions of background layers and sprites. The SNES has two windows that can be combined using logic operations.
Each window has left and right boundaries (0-255 pixel positions). Pixels inside the window are treated differently than pixels outside. Windows can be enabled independently for each layer (BG1-4, OBJ).
When both windows affect a layer, they can be combined:
| #define WINDOW_1 0 |
Window 1.
| #define WINDOW_2 1 |
Window 2.
| #define WINDOW_ALL (WINDOW_ALL_BG | WINDOW_OBJ) |
All layers including sprites.
| #define WINDOW_ALL_BG (WINDOW_BG1 | WINDOW_BG2 | WINDOW_BG3 | WINDOW_BG4) |
All background layers.
| #define WINDOW_BG1 BIT(0) |
BG1 layer.
| #define WINDOW_BG2 BIT(1) |
BG2 layer.
| #define WINDOW_BG3 BIT(2) |
BG3 layer.
| #define WINDOW_BG4 BIT(3) |
BG4 layer.
| #define WINDOW_LOGIC_AND 1 |
AND: mask if inside window 1 AND window 2.
| #define WINDOW_LOGIC_OR 0 |
OR: mask if inside window 1 OR window 2.
| #define WINDOW_LOGIC_XNOR 3 |
XNOR: mask if inside both or neither window.
| #define WINDOW_LOGIC_XOR 2 |
XOR: mask if inside exactly one window.
| #define WINDOW_MAIN_SCREEN 0 |
Apply window to main screen.
| #define WINDOW_MASK_INSIDE 0 |
Show layer inside window, hide outside.
| #define WINDOW_MASK_OUTSIDE 1 |
Show layer outside window, hide inside.
| #define WINDOW_MATH BIT(5) |
Color math (affects color blending)
| #define WINDOW_OBJ BIT(4) |
Sprites (OBJ) layer.
| #define WINDOW_SUB_SCREEN 1 |
Apply window to sub screen.
Create a centered rectangular window.
Convenience function to set up a window centered on screen.
| window | Window number |
| width | Width in pixels (1-256) |
Disable window for specified layers.
| window | Window number (WINDOW_1 or WINDOW_2) |
| layers | Layer mask |
| void windowDisableAll | ( | void | ) |
Disable all windows.
Convenience function to turn off all window effects.
Enable window for specified layers.
Enables a window to affect the specified layers. The window's masking behavior depends on the invert setting (see windowSetInvert).
| window | Window number (WINDOW_1 or WINDOW_2) |
| layers | Layer mask (WINDOW_BG1, WINDOW_BG2, etc.) |
| void windowInit | ( | void | ) |
Initialize window system.
Resets all window settings to defaults (windows disabled, full screen).
Set window inversion for layers.
Controls whether pixels inside the window are shown or hidden.
| window | Window number (WINDOW_1 or WINDOW_2) |
| layers | Layer mask |
| invert | 0 = mask inside (show inside), 1 = mask outside (show outside) |
Set logic operation for combining windows.
When both windows affect a layer, this sets how they combine.
| layer | Single layer (WINDOW_BG1, WINDOW_BG2, etc.) |
| logic | Logic operation (WINDOW_LOGIC_*) |
| void windowSetMainMask | ( | u8 | layers | ) |
Set main screen window masking.
Controls which layers use window masking on the main screen.
| layers | Layer mask for main screen windowing |
Set window boundaries.
Sets the left and right pixel positions for a window. Valid range is 0-255. If left > right, window is empty.
| window | Window number (WINDOW_1 or WINDOW_2) |
| left | Left boundary (0-255) |
| right | Right boundary (0-255) |
| void windowSetSubMask | ( | u8 | layers | ) |
Set sub screen window masking.
Controls which layers use window masking on the sub screen.
| layers | Layer mask for sub screen windowing |
| void windowSplit | ( | u8 | splitX | ) |
Create a vertical split at the specified X position.
Sets up Window 1 for left side, Window 2 for right side. Useful for split-screen or scene transitions.
| splitX | X position of the split (0-255) |