SNES Video / PPU Functions. More...
#include <snes/types.h>Go to the source code of this file.
Macros | |
| #define | BG3_MODE1_PRIORITY_HIGH 0x08 |
| #define | BG_MODE0 0 |
| #define | BG_MODE1 1 |
| #define | BG_MODE2 2 |
| #define | BG_MODE3 3 |
| #define | BG_MODE4 4 |
| #define | BG_MODE5 5 |
| #define | BG_MODE6 6 |
| #define | BG_MODE7 7 |
| #define | LAYER_BG1 0x01 |
| #define | LAYER_BG2 0x02 |
| #define | LAYER_BG3 0x04 |
| #define | LAYER_BG4 0x08 |
| #define | LAYER_OBJ 0x10 |
| #define | RGB(r, g, b) |
| Create RGB color value. | |
| #define | RGB24(r, g, b) |
| Convert 24-bit RGB to SNES format. | |
| #define | SCREEN_HEIGHT 224 |
| Visible screen height in pixels (NTSC, 224 lines). | |
| #define | SCREEN_WIDTH 256 |
| Visible screen width in pixels. | |
| #define | setColor(index, color) |
| Set a single CGRAM color. | |
| #define | setMainScreen(layers) |
| Enable layers on the main screen. | |
| #define | setSubScreen(layers) |
| Enable layers on the sub screen. | |
Functions | |
| void | setMode (u8 mode, u8 flags) |
| Set background mode. | |
| void | videoSetInterlace (u8 on) |
| Enable/disable screen interlace (SETINI bit 0). | |
| void | videoSetObjInterlace (u8 on) |
| Enable/disable sprite interlace (SETINI bit 1). | |
| void | videoSetOverscan (u8 on) |
| Enable/disable overscan (SETINI bit 2). | |
| void | videoSetPseudoHires (u8 on) |
| Enable/disable pseudo-hires (SETINI bit 3). | |
SNES Video / PPU Functions.
Low-level video functions for PPU control, palette management, and screen modes.
| #define RGB | ( | r, | |
| g, | |||
| b ) |
Create RGB color value.
| r | Red (0-31; masked to 5 bits) |
| g | Green (0-31; masked to 5 bits) |
| b | Blue (0-31; masked to 5 bits) |
| #define RGB24 | ( | r, | |
| g, | |||
| b ) |
| #define SCREEN_HEIGHT 224 |
Visible screen height in pixels (NTSC, 224 lines).
| #define SCREEN_WIDTH 256 |
Visible screen width in pixels.
| #define setColor | ( | index, | |
| color ) |
Set a single CGRAM color.
Writes a 15-bit BGR color to the specified palette index. Works during VBlank or force blank only.
| #define setMainScreen | ( | layers | ) |
Enable layers on the main screen.
Sets which layers are visible on the main screen (REG_TM $212C). Forgetting to call this (or set REG_TM directly) is the #1 cause of blank screens after consoleInit().
| layers | OR'd combination of LAYER_BG1..LAYER_OBJ |
| #define setSubScreen | ( | layers | ) |
Enable layers on the sub screen.
Sets which layers are visible on the sub screen (REG_TS $212D). The sub screen is used as the second operand for color math.
| layers | OR'd combination of LAYER_BG1..LAYER_OBJ |
Set background mode.
| mode | Background mode (BG_MODE0-BG_MODE7), optionally OR'd with priority flags |
Mode overview:
| void videoSetInterlace | ( | u8 | on | ) |
Enable/disable screen interlace (SETINI bit 0).
With BG Mode 5/6 this doubles the vertical resolution to 448 visible lines (the PPU alternates odd/even fields). Modes 5/6 also render 512 pixels horizontally and use 16x8 tiles.
| on | 1 to enable, 0 to disable |
| void videoSetObjInterlace | ( | u8 | on | ) |
Enable/disable sprite interlace (SETINI bit 1).
In interlace mode, sprites are halved vertically and rendered per field — doubles apparent sprite vertical resolution.
| on | 1 to enable, 0 to disable |
| void videoSetOverscan | ( | u8 | on | ) |
Enable/disable overscan (SETINI bit 2).
Extends the visible frame from 224 to 239 lines (PAL-style height on NTSC). VBlank starts at line 240 instead of 225 — the VBlank budget for DMA shrinks by ~15 lines.
| on | 1 to enable, 0 to disable |
| void videoSetPseudoHires | ( | u8 | on | ) |
Enable/disable pseudo-hires (SETINI bit 3).
Renders 512 horizontal pixels in ANY BG mode by alternating main and sub screen pixels — the poor man's Mode 5 (used for cross-fade blend effects). Configure the sub screen layers before enabling.
| on | 1 to enable, 0 to disable |