CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches
pal Namespace Reference

The palette: themes, fades, flashes and colour cycling. More...

Enumerations

enum  Theme : uint8_t {
  GREEN ,
  BLUE_FELT ,
  RED_FELT ,
  PURPLE ,
  THEME_COUNT
}
 The felt colours: FELT_DK, FELT and FELT_LT can be re-dyed as a whole. More...
 
enum  Mode : uint8_t {
  CASINO ,
  TARGETS ,
  HOVER ,
  FIRE
}
 What FX_A and FX_B do by themselves while cycling is on (setMode()). More...
 

Functions

void init (const uint16_t *base=HOUSE)
 Load a set of colours and commit them at once.
 
void setThemes (const uint16_t(*felts)[3], uint8_t count)
 Replace the built-in felt themes with a game's own.
 
void setTheme (uint8_t theme)
 Re-dye the felt (FELT_DK, FELT, FELT_LT).
 
uint8_t theme ()
 The current felt theme.
 
void setMode (uint8_t mode)
 Choose what FX_A and FX_B animate as.
 
void setFade (uint8_t level)
 Fade the whole screen toward black.
 
uint8_t fade ()
 The current fade level.
 
void setDesaturate (uint8_t amount)
 Wash the colours toward grey (a paused game, a game over).
 
void flash (uint8_t index, uint16_t rgb444, uint8_t frames)
 Show one palette index in another colour for a few frames (a hit, a win).
 
void setFx (uint8_t index, uint16_t rgb444)
 Set a colour by hand.
 
void setCycling (bool on)
 Whether FX_A/FX_B animate by themselves.
 
void tick ()
 Advance the colour cycling and any flash by one tick.
 
void resetClock ()
 Restart the FX_A/FX_B cycle from its beginning.
 
void commit ()
 Work out the final colours and hand them to CHGfx if any changed.
 
uint16_t rgb444 (uint8_t index)
 A staged colour, before fade, flash and desaturation.
 

Variables

const uint16_t HOUSE [16]
 The house colours above, RGB444, in index order. pal::init()'s default.
 
const uint16_t FELTS [THEME_COUNT][3]
 The built-in felts: FELT_DK, FELT, FELT_LT in RGB444 for each Theme.
 

Detailed Description

The palette: themes, fades, flashes and colour cycling.

Enumeration Type Documentation

◆ Theme

enum pal::Theme : uint8_t

The felt colours: FELT_DK, FELT and FELT_LT can be re-dyed as a whole.

Enumerator
GREEN 

The classic green felt (the default).

BLUE_FELT 

Blue felt.

RED_FELT 

Red felt.

PURPLE 

Purple felt.

THEME_COUNT 

The number of built-in themes.

◆ Mode

enum pal::Mode : uint8_t

What FX_A and FX_B do by themselves while cycling is on (setMode()).

Enumerator
CASINO 

FX_A runs through a rainbow (banner outlines, sparkle); FX_B shimmers gold - white - gold.

The default.

TARGETS 

FX_A shimmers cyan - white (squares a piece can go to); FX_B pulses red - gold (pieces it can take).

HOVER 

FX_A fades black - white - black about once a second (a cursor outline); FX_B as CASINO.

FIRE 

FX_A flickers red - gold - white (a hot hand); FX_B as CASINO.

Function Documentation

◆ init()

void pal::init ( const uint16_t *  base = HOUSE)

Load a set of colours and commit them at once.

Parameters
baseSixteen RGB444 colours, in index order (default: HOUSE, the green felt). FELT_DK..FELT_LT come from here until setTheme().

Call once in setup(), after gfx_begin().

◆ setThemes()

void pal::setThemes ( const uint16_t(*)  felts[3],
uint8_t  count 
)

Replace the built-in felt themes with a game's own.

Parameters
feltsA table of count themes, each FELT_DK, FELT, FELT_LT in RGB444 (kept by pointer: it must stay valid).
countThe number of themes in the table.

◆ setTheme()

void pal::setTheme ( uint8_t  theme)

Re-dye the felt (FELT_DK, FELT, FELT_LT).

Parameters
themeA Theme, or an index into the table given to setThemes(); an index past the end selects theme 0.

◆ theme()

uint8_t pal::theme ( )

The current felt theme.

Returns
The index last given to setTheme() (0 at start).

◆ setMode()

void pal::setMode ( uint8_t  mode)

Choose what FX_A and FX_B animate as.

Parameters
modeA Mode (default CASINO).

◆ setFade()

void pal::setFade ( uint8_t  level)

Fade the whole screen toward black.

Parameters
level0 = black .. 16 = full colour (the default); larger values are 16.

Fade in or out by stepping the level a frame at a time.

◆ fade()

uint8_t pal::fade ( )

The current fade level.

Returns
0 (black) .. 16 (full colour).

◆ setDesaturate()

void pal::setDesaturate ( uint8_t  amount)

Wash the colours toward grey (a paused game, a game over).

Parameters
amount0 = full colour (the default) .. 16 = grey.

◆ flash()

void pal::flash ( uint8_t  index,
uint16_t  rgb444,
uint8_t  frames 
)

Show one palette index in another colour for a few frames (a hit, a win).

Parameters
indexThe palette index to flash (0-15).
rgb444The colour to show it in.
framesHow many tick()s the flash lasts. One flash at a time: a new one replaces the last.

◆ setFx()

void pal::setFx ( uint8_t  index,
uint16_t  rgb444 
)

Set a colour by hand.

Parameters
indexThe palette index (0-15); for FX_A/FX_B, turn cycling off first or tick() overwrites it.
rgb444The colour.

◆ setCycling()

void pal::setCycling ( bool  on)

Whether FX_A/FX_B animate by themselves.

Parameters
ontrue (the default) to cycle as setMode() says; false to leave them as set with setFx().

◆ tick()

void pal::tick ( )

Advance the colour cycling and any flash by one tick.

Call once per logic tick, before commit().

◆ resetClock()

void pal::resetClock ( )

Restart the FX_A/FX_B cycle from its beginning.

The debug protocol uses it so scripted runs repeat exactly.

◆ commit()

void pal::commit ( )

Work out the final colours and hand them to CHGfx if any changed.

Call once per frame, before the flush (after gfx_wait() is the usual place, but any time is safe: CHGfx stages the palette for the next flush). A frame where nothing changed costs a few comparisons.

◆ rgb444()

uint16_t pal::rgb444 ( uint8_t  index)

A staged colour, before fade, flash and desaturation.

Parameters
indexThe palette index (0-15).
Returns
Its colour, RGB444.

Variable Documentation

◆ HOUSE

const uint16_t pal::HOUSE[16]
extern

The house colours above, RGB444, in index order. pal::init()'s default.

◆ FELTS

const uint16_t pal::FELTS[THEME_COUNT][3]
extern

The built-in felts: FELT_DK, FELT, FELT_LT in RGB444 for each Theme.