Loading...
Searching...
No Matches
mosaic.h File Reference

SNES Mosaic Effects. More...

#include <snes/types.h>

Go to the source code of this file.

Macros

#define MOSAIC_BG1   0x01
 
#define MOSAIC_BG2   0x02
 
#define MOSAIC_BG3   0x04
 
#define MOSAIC_BG4   0x08
 
#define MOSAIC_BG_ALL   0x0F
 
#define MOSAIC_MAX   15
 
#define MOSAIC_MIN   0
 

Functions

void mosaicDisable (void)
 Disable mosaic effect for all backgrounds.
 
void mosaicEnable (u8 bgMask)
 Enable mosaic effect for specified backgrounds.
 
void mosaicFadeIn (u8 speed)
 Animate mosaic fade in (pixelated -> clear)
 
void mosaicFadeOut (u8 speed)
 Animate mosaic fade out (clear -> pixelated)
 
u8 mosaicGetSize (void)
 Get current mosaic size.
 
void mosaicInit (void)
 Initialize mosaic system.
 
void mosaicSetSize (u8 size)
 Set mosaic pixel block size.
 

Detailed Description

SNES Mosaic Effects.

Mosaic is a PPU effect that pixelates backgrounds, commonly used for:

  • Screen transitions (fade to mosaic, then change scene)
  • Damage/death effects
  • Retro visual styles

Hardware: Register $2106 (MOSAIC)

  • Bits 7-4: Mosaic size (0-15, block size = value + 1 pixels)
  • Bit 3: Enable mosaic for BG4
  • Bit 2: Enable mosaic for BG3
  • Bit 1: Enable mosaic for BG2
  • Bit 0: Enable mosaic for BG1
Author
OpenSNES Team

Macro Definition Documentation

◆ MOSAIC_BG1

#define MOSAIC_BG1   0x01

Enable mosaic for BG1

◆ MOSAIC_BG2

#define MOSAIC_BG2   0x02

Enable mosaic for BG2

◆ MOSAIC_BG3

#define MOSAIC_BG3   0x04

Enable mosaic for BG3

◆ MOSAIC_BG4

#define MOSAIC_BG4   0x08

Enable mosaic for BG4

◆ MOSAIC_BG_ALL

#define MOSAIC_BG_ALL   0x0F

Enable mosaic for all backgrounds

◆ MOSAIC_MAX

#define MOSAIC_MAX   15

Maximum mosaic (16x16 pixel blocks)

◆ MOSAIC_MIN

#define MOSAIC_MIN   0

Minimum mosaic (1x1, no visible effect)

Function Documentation

◆ mosaicDisable()

void mosaicDisable ( void  )

Disable mosaic effect for all backgrounds.

◆ mosaicEnable()

void mosaicEnable ( u8  bgMask)

Enable mosaic effect for specified backgrounds.

Parameters
bgMaskBitmask of backgrounds (MOSAIC_BG1 | MOSAIC_BG2 | etc.)

Example:

mosaicEnable(MOSAIC_BG1 | MOSAIC_BG2); // Enable for BG1 and BG2
mosaicEnable(MOSAIC_BG_ALL); // Enable for all backgrounds
#define MOSAIC_BG_ALL
Definition mosaic.h:34
#define MOSAIC_BG2
Definition mosaic.h:31
void mosaicEnable(u8 bgMask)
Enable mosaic effect for specified backgrounds.
#define MOSAIC_BG1
Definition mosaic.h:30

◆ mosaicFadeIn()

void mosaicFadeIn ( u8  speed)

Animate mosaic fade in (pixelated -> clear)

Smoothly decreases mosaic from current level to 0. Blocks until animation completes.

Parameters
speedFrames to wait between steps (1 = fast, higher = slower)

Example:

mosaicFadeIn(2); // Reveal screen over ~30 frames
void mosaicSetSize(u8 size)
Set mosaic pixel block size.
void mosaicFadeIn(u8 speed)
Animate mosaic fade in (pixelated -> clear)
#define MOSAIC_MAX
Definition mosaic.h:41

◆ mosaicFadeOut()

void mosaicFadeOut ( u8  speed)

Animate mosaic fade out (clear -> pixelated)

Smoothly increases mosaic from current level to maximum. Blocks until animation completes.

Parameters
speedFrames to wait between steps (1 = fast, higher = slower)

Example:

mosaicFadeOut(2); // Pixelate screen over ~30 frames
loadNewLevel();
mosaicFadeIn(2); // Reveal new content
void mosaicFadeOut(u8 speed)
Animate mosaic fade out (clear -> pixelated)

◆ mosaicGetSize()

u8 mosaicGetSize ( void  )

Get current mosaic size.

Returns
Current mosaic size (0-15)

◆ mosaicInit()

void mosaicInit ( void  )

Initialize mosaic system.

Disables all mosaic effects. Call this once during setup.

◆ mosaicSetSize()

void mosaicSetSize ( u8  size)

Set mosaic pixel block size.

Parameters
sizeMosaic level (0-15) 0 = 1x1 pixels (no visible effect) 15 = 16x16 pixel blocks (maximum pixelation)

Note: Mosaic must be enabled with mosaicEnable() to see the effect.