![]() |
CHGame 0.3.0
Libraries for the CHGame handheld
|
The house palette: sixteen named colours, and the tricks a palette allows. More...
#include <stdint.h>Go to the source code of this file.
Namespaces | |
| namespace | pal |
| The palette: themes, fades, flashes and colour cycling. | |
Enumerations | |
| enum | : uint8_t { INK = 0 , WHITE , FELT_DK , FELT , FELT_LT , SILVER , RED , WINE , GOLD , WOOD , BLUE , NAVY , SKIN , CYAN , FX_A , FX_B } |
| The house colours, by palette index. More... | |
| enum | pal::Theme : uint8_t { pal::GREEN , pal::BLUE_FELT , pal::RED_FELT , pal::PURPLE , pal::THEME_COUNT } |
| The felt colours: FELT_DK, FELT and FELT_LT can be re-dyed as a whole. More... | |
| enum | pal::Mode : uint8_t { pal::CASINO , pal::TARGETS , pal::HOVER , pal::FIRE } |
| What FX_A and FX_B do by themselves while cycling is on (setMode()). More... | |
Functions | |
| void | pal::init (const uint16_t *base=HOUSE) |
| Load a set of colours and commit them at once. | |
| void | pal::setThemes (const uint16_t(*felts)[3], uint8_t count) |
| Replace the built-in felt themes with a game's own. | |
| void | pal::setTheme (uint8_t theme) |
| Re-dye the felt (FELT_DK, FELT, FELT_LT). | |
| uint8_t | pal::theme () |
| The current felt theme. | |
| void | pal::setMode (uint8_t mode) |
| Choose what FX_A and FX_B animate as. | |
| void | pal::setFade (uint8_t level) |
| Fade the whole screen toward black. | |
| 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). | |
| 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). | |
| void | pal::setFx (uint8_t index, uint16_t rgb444) |
| Set a colour by hand. | |
| void | pal::setCycling (bool on) |
| Whether FX_A/FX_B animate by themselves. | |
| void | pal::tick () |
| Advance the colour cycling and any flash by one tick. | |
| void | pal::resetClock () |
| Restart the FX_A/FX_B cycle from its beginning. | |
| void | pal::commit () |
| Work out the final colours and hand them to CHGfx if any changed. | |
| uint16_t | pal::rgb444 (uint8_t index) |
| A staged colour, before fade, flash and desaturation. | |
Variables | |
| const uint16_t | pal::HOUSE [16] |
| The house colours above, RGB444, in index order. pal::init()'s default. | |
| const uint16_t | pal::FELTS [THEME_COUNT][3] |
| The built-in felts: FELT_DK, FELT, FELT_LT in RGB444 for each Theme. | |
The house palette: sixteen named colours, and the tricks a palette allows.
CHGfx draws with palette indices (0-15) and applies the palette while it converts the framebuffer for the panel, so recolouring an index recolours every pixel that uses it, for free. pal:: keeps a staging copy in RGB444 (the 12 bpp panel's own grid, so output, fades and the simulator agree) and pal::commit() works out the final colours once a frame: the felt theme, FX_A/FX_B colour cycling, a flash, desaturation and the fade. CHGfx stages gfx_setPalette() itself (it takes effect when the next flush starts), so commit() may run while a frame is still going out; it only calls it when a colour really changed, because each change costs CHGfx a lookup-table rebuild.
Every frame: pal::tick() once per logic tick, pal::commit() before the flush.