OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
main.c File Reference

Pseudo-hires: a 50 % blend of two layers without colour math. More...

#include <snes.h>
#include <snes/tile.h>

Macros

#define MAP_PAL1   0x0400
 Tilemap entry bits: palette 1 (CGRAM 16-31).
#define VRAM_BG1_MAP   0x2000
#define VRAM_BG2_MAP   0x2400
#define VRAM_CHR   0x0000
 VRAM word addresses: shared char block, the two maps.

Functions

int main (void)

Variables

u16 bg2_x
 Probe oracle: BG2's horizontal scroll.
static u16 maprow [32]
 One tilemap row being built.
static const u16 palettes [32]
 BG palettes 0 and 1: transparent + red, transparent + blue.
u8 ph_on
 Probe oracle: 1 while pseudo-hires is on.
static u8 px [64]
 One tile's pixels and its 4bpp encoding.
static u8 tilebuf [32]

Detailed Description

Pseudo-hires: a 50 % blend of two layers without colour math.

SETINI bit 3 (pseudo-hires) makes the PPU output 512 pixels per line in any BG mode, taking every other one from the sub screen: the sub screen fills the even columns, the main screen the odd ones. A CRT on composite blurs the two neighbours together, so what you see is a half-and-half blend — the effect some games used for transparency, with colour math left free for something else.

Here BG1 (red horizontal bars) is on the main screen and BG2 (blue vertical bars, scrolling) on the sub screen. Colour math is off: without pseudo-hires the sub screen is not shown at all. Press A to toggle it.

SNES Concepts
  • SETINI ($2133) bit 3 through videoSetPseudoHires() (the lib keeps a shadow of the write-only register)
  • Main screen / sub screen designation (setMainScreen, setSubScreen) without colour math: the sub screen is only seen through pseudo-hires
  • The interleave: sub screen on even columns, main screen on odd ones
  • Tiles built at run time (tileEncode4bpp), no asset file
What to Observe
  • Purple where the bars cross, half-bright red and blue elsewhere (the emulator's 256-pixel view averages each pixel pair, like a CRT).
  • Press A: pseudo-hires off, only the red bars remain; press A again.
  • With an emulator's native 512-pixel output (luna --native-res), the alternating columns are visible one by one.
Modules Used
console (videoSetPseudoHires), dma, background, input, tile
See also
video.h (videoSetPseudoHires), docs/tutorials/colormath.md

Macro Definition Documentation

◆ MAP_PAL1

#define MAP_PAL1   0x0400

Tilemap entry bits: palette 1 (CGRAM 16-31).

◆ VRAM_BG1_MAP

#define VRAM_BG1_MAP   0x2000

◆ VRAM_BG2_MAP

#define VRAM_BG2_MAP   0x2400

◆ VRAM_CHR

#define VRAM_CHR   0x0000

VRAM word addresses: shared char block, the two maps.

Function Documentation

◆ main()

int main ( void )

Variable Documentation

◆ bg2_x

u16 bg2_x

Probe oracle: BG2's horizontal scroll.

◆ maprow

u16 maprow[32]
static

One tilemap row being built.

◆ palettes

const u16 palettes[32]
static
Initial value:
= {
RGB(0, 0, 0), RGB(31, 4, 4), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
RGB(0, 0, 0), RGB(6, 10, 31), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}
#define RGB(r, g, b)
Create RGB color value.
Definition video.h:88

BG palettes 0 and 1: transparent + red, transparent + blue.

◆ ph_on

u8 ph_on

Probe oracle: 1 while pseudo-hires is on.

◆ px

u8 px[64]
static

One tile's pixels and its 4bpp encoding.

◆ tilebuf

u8 tilebuf[32]
static