include/graphics/palette_buffers.h
The palette fades, the title's and the field's, and the tints they fade to.
Included by field_engine_internal.h, field_world_map.c, script_commands_internal.h, title_intro.c, airs_rock.c, airs_rock_inside.c, alhafra_manor.c, anemos_inner_sanctum.c, anemos_inner_sanctum_dullahan.c, apojii_islands.c, aqua_rock.c, aqua_rock_inside.c, contigo.c, eastern_alhafra.c, gabomba_catacombs.c, gabomba_statue.c, gabomba_statue_chamber.c, gaia_rock_inside.c, garoh.c, idejima.c, islet_cave.c, jupiter_lighthouse_aerie_beacon.c, jupiter_lighthouse_terraces.c, jupiter_lighthouse_upper_hall.c, kibombo.c, lemurian_ship.c, lemurian_ship_deck.c, magma_rock_inside.c, mars_lighthouse_aerie.c, mars_lighthouse_entrance.c, mars_lighthouse_hall.c, mars_lighthouse_star_room.c, mt_aleph_summit.c, naribwe_rooms.c, northern_reaches.c, prox.c, sea_of_time.c, treasure_isle.c, world_map.c, yampi_desert_cave.c and shop_cursor.c.
Structures
| Name | Description | |
|---|---|---|
struct | TITLE_PALETTE_FADE | A colour buffer for all 512 palette colours: the source palette, the shown and target colour channels, their steps, and two pages of packed colours. |
struct | PALETTE_FADE | The palette fade (HEAP_SLOT_PALETTE_FADE) that fades the BG and OBJ palettes: the source palette, the shown and target colour channels, their per-tick steps, and two pages of packed RGB555 colours queued each tick. |
Macros
| Name | Description | |
|---|---|---|
#define | TITLE_PALETTE_FADE_CHANNELS (512 * 3) | The colour channels a TITLE_PALETTE_FADE moves: B, G and R for each of its 512 colours. |
#define | PALETTE_FADE_BG_COLORS (14 * PALETTE_COLORS) | The BG colours a PALETTE_FADE moves, palettes 0 to 13, and the OBJ colours that follow them, as many. |
#define | PALETTE_FADE_OBJ_COLORS (14 * PALETTE_COLORS) | |
#define | PALETTE_FADE_CHANNELS | The colour channels a PALETTE_FADE moves: B, G and R for each of its BG and OBJ colours. |
#define | PALETTE_LIST_END 65535 | The entry that ends a Uint16 list of palette slots or of colours. |
#define | BRIGHTNESS_RED_SHIFT (RGB_BLUE_SHIFT + 1) | The brightness 2R + 4G + B that PALETTE_TINT_GRAYSCALE and PALETTE_TINT_CUSTOM build, with each channel where a fade keeps it, in blue's place: red moved up and doubled, green moved up and doubled twice. |
#define | BRIGHTNESS_GREEN_SHIFT (RGB_BLUE_SHIFT - RGB_GREEN_SHIFT + 2) | |
#define | CUSTOM_TINT_DIVISOR 96 | PALETTE_TINT_CUSTOM gives each channel the brightness 2R + 4G + B times the tint's level over this, so white reaches full level under a tint level of 14. |
#define | SEPIA_SHADE_DIVISOR 10 | PALETTE_TINT_SEPIA's shade is a colour's R + G + B over this, 0 to 9. |
#define | SEPIA_LEVEL_MIN 8 | PALETTE_TINT_SEPIA holds each channel to these levels. |
#define | SEPIA_LEVEL_MAX 28 | |
#define | MUTED_RED_MIN 10 | The title's PALETTE_TINT_MUTED holds each channel to its own range. |
#define | MUTED_RED_MAX 28 | |
#define | MUTED_GREEN_MIN 16 | |
#define | MUTED_GREEN_MAX 24 | |
#define | MUTED_BLUE_MIN 16 | |
#define | MUTED_BLUE_MAX 26 |
Enumerations
| Name | Description | |
|---|---|---|
enum | PALETTE_TINT { PALETTE_TINT_FROM_SOURCE, PALETTE_TINT_NONE, PALETTE_TINT_GR … } | A palette tint, a palette fade's build mode: up to RGB_WHITE, one RGB555 colour for all. |
enum | PALETTE_SELECTION { PALETTES_ALL, PALETTES_BG, PALETTES_OBJECTS } | Which palettes mnTitlePaletteFadeBuildColors builds. |
Functions
| Name | Description | |
|---|---|---|
void | mnTitlePaletteFadeBuildColors (Uint32 tint, Uint16 *src, Uint16 *dest, Sint32 selectedPalettes) | Tints 512 source colours into destination components (three per colour, each in the high bits of a halfword). |
void | mnTitlePaletteFadeInit (void) | Allocates the palette fade, saves both hardware palettes in it as the starting colours and adds the event mnTitlePaletteFadeUpdate. |
void | mnTitlePaletteFadeUpdate (void) | An event added by mnTitlePaletteFadeInit: steps the palette fade each tick, adding the step to every colour component until the fade is done, packs the components into the spare RGB555 copy of the palettes and queues both palettes for VBlank. |
void | mnTitlePaletteFadeSetTarget (Sint32 tint, Sint32 selectedPalettes) | Sets the fade target by tinting the saved background and/or sprite palettes with the requested tint. |
void | mnTitlePaletteFadeSetBackdrop (Sint32 color) | Unused: replaces the first saved colour, the backdrop. |
void | mnTitlePaletteFadeStart (Sint32 ticks) | Starts fading the shown colours to the target over the requested ticks: each of the components (three for each of the 512 colours) steps by its distance divided by the ticks, the remainder kept in the ten bits below it, so every colour arrives together. |
void | mnTitlePaletteFadeCalculateSteps (Sint16 *current, Sint16 *target, Sint16 *step, Sint32 ticks) | Computes the change per tick of each of the TITLE_PALETTE_FADE_CHANNELS colour components, from the current components to the target (nothing when ticks is not positive). |
void | mnTitlePaletteFadeRelease (void) | Unused: removes the palette fade's event and frees its buffers. |
Description
The palette fades, the title's and the field's, and the tints they fade to.
Macros in detail
TITLE_PALETTE_FADE_CHANNELS
#define TITLE_PALETTE_FADE_CHANNELS (512 * 3)
The colour channels a TITLE_PALETTE_FADE moves: B, G and R for each of its
512 colours.
Referenced by mnTitlePaletteFadeCalculateSteps() and mnTitlePaletteFadeUpdate().
Definition at line 13 of file palette_buffers.h.
PALETTE_FADE_BG_COLORS
#define PALETTE_FADE_BG_COLORS (14 * PALETTE_COLORS)
The BG colours a PALETTE_FADE moves, palettes 0 to 13, and the OBJ colours
that follow them, as many.
Referenced by fdWorldMapLoadAreaGraphics(), fdWorldMapLoadGraphics(), fdWorldMapPreloadCurrentTileBlock(), mnShopSaveAndTintFieldPalette(), scInit(), scPaletteSetColorsFade(), scPrepareMap() and scSeaOfTimeAnimateSea().
Definition at line 17 of file palette_buffers.h.
PALETTE_FADE_OBJ_COLORS
#define PALETTE_FADE_OBJ_COLORS (14 * PALETTE_COLORS)
Definition at line 18 of file palette_buffers.h.
PALETTE_FADE_CHANNELS
#define PALETTE_FADE_CHANNELS
The colour channels a PALETTE_FADE moves: B, G and R for each of its BG and
OBJ colours.
Referenced by fdStartColorTransition().
Definition at line 21 of file palette_buffers.h.
PALETTE_LIST_END
#define PALETTE_LIST_END 65535
The entry that ends a Uint16 list of palette slots or of colours.
Referenced by scListCountEntries(), scPaletteSetColorsFade(), TeleportCircleColors, TeleportCirclePaletteSlots and TeleportCircleShimmerColors.
Definition at line 25 of file palette_buffers.h.
BRIGHTNESS_RED_SHIFT
#define BRIGHTNESS_RED_SHIFT (RGB_BLUE_SHIFT + 1)
The brightness 2R + 4G + B that PALETTE_TINT_GRAYSCALE and
PALETTE_TINT_CUSTOM build, with each channel where a fade keeps it, in blue's
place: red moved up and doubled, green moved up and doubled twice.
Referenced by fdPaletteFadeBuild() and mnTitlePaletteFadeBuildColors().
Definition at line 161 of file palette_buffers.h.
BRIGHTNESS_GREEN_SHIFT
#define BRIGHTNESS_GREEN_SHIFT (RGB_BLUE_SHIFT - RGB_GREEN_SHIFT + 2)
Referenced by fdPaletteFadeBuild() and mnTitlePaletteFadeBuildColors().
Definition at line 162 of file palette_buffers.h.
CUSTOM_TINT_DIVISOR
#define CUSTOM_TINT_DIVISOR 96
PALETTE_TINT_CUSTOM gives each channel the brightness 2R + 4G + B times the
tint's level over this, so white reaches full level under a tint level of 14.
Referenced by fdPaletteFadeBuild() and mnTitlePaletteFadeBuildColors().
Definition at line 166 of file palette_buffers.h.
SEPIA_SHADE_DIVISOR
#define SEPIA_SHADE_DIVISOR 10
PALETTE_TINT_SEPIA's shade is a colour's R + G + B over this, 0 to 9.
Referenced by fdPaletteFadeBuild() and mnTitlePaletteFadeBuildColors().
Definition at line 169 of file palette_buffers.h.
SEPIA_LEVEL_MIN
#define SEPIA_LEVEL_MIN 8
PALETTE_TINT_SEPIA holds each channel to these levels.
Referenced by fdPaletteFadeBuild() and mnTitlePaletteFadeBuildColors().
Definition at line 171 of file palette_buffers.h.
SEPIA_LEVEL_MAX
#define SEPIA_LEVEL_MAX 28
Referenced by fdPaletteFadeBuild() and mnTitlePaletteFadeBuildColors().
Definition at line 172 of file palette_buffers.h.
MUTED_RED_MIN
#define MUTED_RED_MIN 10
The title's PALETTE_TINT_MUTED holds each channel to its own range.
Referenced by mnTitlePaletteFadeBuildColors().
Definition at line 175 of file palette_buffers.h.
MUTED_RED_MAX
#define MUTED_RED_MAX 28
Referenced by mnTitlePaletteFadeBuildColors().
Definition at line 176 of file palette_buffers.h.
MUTED_GREEN_MIN
#define MUTED_GREEN_MIN 16
Referenced by mnTitlePaletteFadeBuildColors().
Definition at line 177 of file palette_buffers.h.
MUTED_GREEN_MAX
#define MUTED_GREEN_MAX 24
Referenced by mnTitlePaletteFadeBuildColors().
Definition at line 178 of file palette_buffers.h.
MUTED_BLUE_MIN
#define MUTED_BLUE_MIN 16
Referenced by mnTitlePaletteFadeBuildColors().
Definition at line 179 of file palette_buffers.h.
MUTED_BLUE_MAX
#define MUTED_BLUE_MAX 26
Referenced by mnTitlePaletteFadeBuildColors().
Definition at line 180 of file palette_buffers.h.
Enumerations in detail
PALETTE_TINT
enum PALETTE_TINT
A palette tint, a palette fade's build mode: up to RGB_WHITE, one RGB555
colour for all.
| Enumerator | Value | Description |
|---|---|---|
PALETTE_TINT_FROM_SOURCE | RGB_WHITE + 1 | The backdrop colour (palette RAM's first colour) for all. |
PALETTE_TINT_NONE | 0x10000 | Each colour unchanged. |
PALETTE_TINT_GRAYSCALE | Grey of brightness (2R + 4G + B) / 7. | |
PALETTE_TINT_SEPIA | Brownish grey: the brightness (R + G + B) / 10, red at 4 times it plus 5, green and blue 3 times plus 5, each held to 8 to 28. | |
PALETTE_TINT_WARM | Half R + 10, two thirds G + 8, B - 7; black stays black. The title's (TITLE_PALETTE_FADE) is PALETTE_TINT_WARM_DARK's, black included. | |
PALETTE_TINT_MUTED | Each channel held to a narrow range, then G and B + 2: the field's fade holds R 8 to 29, G 14 to 25, B 14 to 27 and leaves the first colour; the title's (TITLE_PALETTE_FADE) R 10 to 28, G 16 to 24, B 16 to 26. | |
PALETTE_TINT_PALE | Half of each channel, plus their mean. | |
PALETTE_TINT_RED | R plus an eighth of G and of B; G and B two thirds. | |
PALETTE_TINT_WARM_DARK | Half R + 6, two thirds G + 4, B - 6. | |
PALETTE_TINT_DIM_BRIGHT | A fifth off each channel of a bright colour. | |
PALETTE_TINT_DIM_GRAY | A third of R + G + B, B three steps darker. | |
PALETTE_TINT_FLAGS | 0x100000 | From here the CUSTOM, BLEND and SPLIT bits are tested, CUSTOM and BLEND carrying an RGB555 colour in the low 15 bits; any other value is the address of a ready buffer to copy. |
PALETTE_TINT_CUSTOM | 0x200000 | The brightness (2R + 4G + B) times the colour carried. |
PALETTE_TINT_BLEND | 0x400000 | The brightness R + G + B shared out in the proportions of the colour carried. |
PALETTE_TINT_SPLIT | 0x800000 | Each colour unchanged. |
Definition at line 109 of file palette_buffers.h.
PALETTE_SELECTION
enum PALETTE_SELECTION
Which palettes mnTitlePaletteFadeBuildColors builds.
| Enumerator | Value | Description |
|---|---|---|
PALETTES_ALL | 0 | |
PALETTES_BG | 1 | |
PALETTES_OBJECTS | 2 |
Definition at line 183 of file palette_buffers.h.