Skip to Content
The Alchemy Project

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

NameDescription
structTITLE_PALETTE_FADEA colour buffer for all 512 palette colours: the source palette, the shown and target colour channels, their steps, and two pages of packed colours.
structPALETTE_FADEThe 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

NameDescription
#defineTITLE_PALETTE_FADE_CHANNELS (512 * 3)The colour channels a TITLE_PALETTE_FADE moves: B, G and R for each of its 512 colours.
#definePALETTE_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.
#definePALETTE_FADE_OBJ_COLORS (14 * PALETTE_COLORS)
#definePALETTE_FADE_CHANNELSThe colour channels a PALETTE_FADE moves: B, G and R for each of its BG and OBJ colours.
#definePALETTE_LIST_END 65535The entry that ends a Uint16 list of palette slots or of colours.
#defineBRIGHTNESS_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.
#defineBRIGHTNESS_GREEN_SHIFT (RGB_BLUE_SHIFT - RGB_GREEN_SHIFT + 2)
#defineCUSTOM_TINT_DIVISOR 96PALETTE_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.
#defineSEPIA_SHADE_DIVISOR 10PALETTE_TINT_SEPIA's shade is a colour's R + G + B over this, 0 to 9.
#defineSEPIA_LEVEL_MIN 8PALETTE_TINT_SEPIA holds each channel to these levels.
#defineSEPIA_LEVEL_MAX 28
#defineMUTED_RED_MIN 10The title's PALETTE_TINT_MUTED holds each channel to its own range.
#defineMUTED_RED_MAX 28
#defineMUTED_GREEN_MIN 16
#defineMUTED_GREEN_MAX 24
#defineMUTED_BLUE_MIN 16
#defineMUTED_BLUE_MAX 26

Enumerations

NameDescription
enumPALETTE_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.
enumPALETTE_SELECTION { PALETTES_ALL, PALETTES_BG, PALETTES_OBJECTS }Which palettes mnTitlePaletteFadeBuildColors builds.

Functions

NameDescription
voidmnTitlePaletteFadeBuildColors (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).
voidmnTitlePaletteFadeInit (void)Allocates the palette fade, saves both hardware palettes in it as the starting colours and adds the event mnTitlePaletteFadeUpdate.
voidmnTitlePaletteFadeUpdate (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.
voidmnTitlePaletteFadeSetTarget (Sint32 tint, Sint32 selectedPalettes)Sets the fade target by tinting the saved background and/or sprite palettes with the requested tint.
voidmnTitlePaletteFadeSetBackdrop (Sint32 color)Unused: replaces the first saved colour, the backdrop.
voidmnTitlePaletteFadeStart (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.
voidmnTitlePaletteFadeCalculateSteps (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).
voidmnTitlePaletteFadeRelease (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.

EnumeratorValueDescription
PALETTE_TINT_FROM_SOURCERGB_WHITE + 1The backdrop colour (palette RAM's first colour) for all.
PALETTE_TINT_NONE0x10000Each colour unchanged.
PALETTE_TINT_GRAYSCALEGrey of brightness (2R + 4G + B) / 7.
PALETTE_TINT_SEPIABrownish 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_WARMHalf 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_MUTEDEach 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_PALEHalf of each channel, plus their mean.
PALETTE_TINT_REDR plus an eighth of G and of B; G and B two thirds.
PALETTE_TINT_WARM_DARKHalf R + 6, two thirds G + 4, B - 6.
PALETTE_TINT_DIM_BRIGHTA fifth off each channel of a bright colour.
PALETTE_TINT_DIM_GRAYA third of R + G + B, B three steps darker.
PALETTE_TINT_FLAGS0x100000From 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_CUSTOM0x200000The brightness (2R + 4G + B) times the colour carried.
PALETTE_TINT_BLEND0x400000The brightness R + G + B shared out in the proportions of the colour carried.
PALETTE_TINT_SPLIT0x800000Each colour unchanged.

Definition at line 109 of file palette_buffers.h.

PALETTE_SELECTION

enum PALETTE_SELECTION

Which palettes mnTitlePaletteFadeBuildColors builds.

EnumeratorValueDescription
PALETTES_ALL0
PALETTES_BG1
PALETTES_OBJECTS2

Definition at line 183 of file palette_buffers.h.