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

"3840 colors" — RGB channel-split blend across two backgrounds More...

#include <snes.h>

Macros

#define VRAM_BG1_GFX   0x0000
 VRAM plan: BG1 8bpp tiles at $0000w, BG2 4bpp at $4000w, maps at $7800w / $7C00w.
#define VRAM_BG1_MAP   0x7800
#define VRAM_BG2_GFX   0x4000
#define VRAM_BG2_MAP   0x7C00

Functions

int main (void)

Variables

u8 blend_pal []
u8 blend_pal_end []
u8 gb_map []
u8 gb_map_end []
u8 gb_tiles []
u8 gb_tiles_end []
u8 r_map []
u8 r_map_end []
u8 r_tiles []
u8 r_tiles_end []

Detailed Description

"3840 colors" — RGB channel-split blend across two backgrounds

Port of krom (Peter Lemon)'s HiColor3840 demo (PeterLemon/SNES, PPU/Blend/HiColor/HiColor3840). The trick: the image's green+blue channels live on BG1 as a 240-color Mode 3 layer (main screen); the red channel lives on BG2 as a 16-level 4bpp layer (sub screen); color math ADDs them back together per pixel — 240 x 16 = "3840 colors" from a static screen, no HDMA and no IRQ.

This is the corpus's first pure colormath dogfood: the audit rated colormath.h "good primitives" on inspection; this port proves SetSource/SetOp/Enable against a reference.

SNES Concepts
  • RGB channel splitting across main/sub screens
  • colorMathSetSource(SUBSCREEN) + colorMathSetOp(ADD) + colorMathEnable(BG1|BACKDROP) — CGWSEL $02 / CGADSUB $21
  • Mode 3: 8bpp BG1 + 4bpp BG2 sharing VRAM
What to Observe
A shaded color wheel with full-RGB depth. Mentally split it: BG1 alone would have no red at all, BG2 alone is a pure red ramp.
Modules Used
console, dma, background, colormath
See also
https://github.com/PeterLemon/SNES — original demo
colormath.h

Macro Definition Documentation

◆ VRAM_BG1_GFX

#define VRAM_BG1_GFX   0x0000

VRAM plan: BG1 8bpp tiles at $0000w, BG2 4bpp at $4000w, maps at $7800w / $7C00w.

◆ VRAM_BG1_MAP

#define VRAM_BG1_MAP   0x7800

◆ VRAM_BG2_GFX

#define VRAM_BG2_GFX   0x4000

◆ VRAM_BG2_MAP

#define VRAM_BG2_MAP   0x7C00

Function Documentation

◆ main()

int main ( void )

Variable Documentation

◆ blend_pal

u8 blend_pal[]
extern

◆ blend_pal_end

u8 blend_pal_end[]

◆ gb_map

u8 gb_map[]

◆ gb_map_end

u8 gb_map_end[]

◆ gb_tiles

u8 gb_tiles[]
extern

◆ gb_tiles_end

u8 gb_tiles_end[]

◆ r_map

u8 r_map[]

◆ r_map_end

u8 r_map_end[]

◆ r_tiles

u8 r_tiles[]
extern

◆ r_tiles_end

u8 r_tiles_end[]