![]() |
CHGame 0.3.0
Libraries for the CHGame handheld
|
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. | |
The palette: themes, fades, flashes and colour cycling.
| enum pal::Theme : uint8_t |
| enum pal::Mode : uint8_t |
What FX_A and FX_B do by themselves while cycling is on (setMode()).
| void pal::init | ( | const uint16_t * | base = HOUSE | ) |
Load a set of colours and commit them at once.
| base | Sixteen 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().
| void pal::setThemes | ( | const uint16_t(*) | felts[3], |
| uint8_t | count | ||
| ) |
Replace the built-in felt themes with a game's own.
| felts | A table of count themes, each FELT_DK, FELT, FELT_LT in RGB444 (kept by pointer: it must stay valid). |
| count | The number of themes in the table. |
| void pal::setTheme | ( | uint8_t | theme | ) |
Re-dye the felt (FELT_DK, FELT, FELT_LT).
| theme | A Theme, or an index into the table given to setThemes(); an index past the end selects theme 0. |
| uint8_t pal::theme | ( | ) |
The current felt theme.
| void pal::setMode | ( | uint8_t | mode | ) |
Choose what FX_A and FX_B animate as.
| mode | A Mode (default CASINO). |
| void pal::setFade | ( | uint8_t | level | ) |
Fade the whole screen toward black.
| level | 0 = black .. 16 = full colour (the default); larger values are 16. |
Fade in or out by stepping the level a frame at a time.
| uint8_t pal::fade | ( | ) |
The current fade level.
| void pal::setDesaturate | ( | uint8_t | amount | ) |
Wash the colours toward grey (a paused game, a game over).
| amount | 0 = full colour (the default) .. 16 = grey. |
| 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).
| index | The palette index to flash (0-15). |
| rgb444 | The colour to show it in. |
| frames | How many tick()s the flash lasts. One flash at a time: a new one replaces the last. |
| void pal::setFx | ( | uint8_t | index, |
| uint16_t | rgb444 | ||
| ) |
Set a colour by hand.
| index | The palette index (0-15); for FX_A/FX_B, turn cycling off first or tick() overwrites it. |
| rgb444 | The colour. |
| void pal::setCycling | ( | bool | on | ) |
| void pal::tick | ( | ) |
Advance the colour cycling and any flash by one tick.
Call once per logic tick, before commit().
| void pal::resetClock | ( | ) |
Restart the FX_A/FX_B cycle from its beginning.
The debug protocol uses it so scripted runs repeat exactly.
| 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.
| uint16_t pal::rgb444 | ( | uint8_t | index | ) |
A staged colour, before fade, flash and desaturation.
| index | The palette index (0-15). |
|
extern |
The house colours above, RGB444, in index order. pal::init()'s default.
|
extern |
The built-in felts: FELT_DK, FELT, FELT_LT in RGB444 for each Theme.