Skip to Content
The Alchemy Project

include/graphics/palette_buffers.h

Palette fades: the colours a fade moves from and to, and the tints (grey, sepia, dusk and the rest) a scene or the title intro builds a target from.

Included by field_effect_tables.c and speaker.h.

Structures

NameDescription
structTITLE_PALETTE_FADEThe title intro's palette fade, over every BG and sprite colour: 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 sprite 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 (PLTT_COLORS * 3)The colour channels a TITLE_PALETTE_FADE moves: B, G and R for each of the palette's colours.
#definePALETTE_FADE_BG_COLORS (14 * PALETTE_COLORS)The background colours a PALETTE_FADE moves, palettes 0 to 13; as many sprite colours follow them.
#definePALETTE_FADE_CHANNELS (2 * PALETTE_FADE_BG_COLORS * 3)The colour channels a PALETTE_FADE moves: B, G and R for each of its background and sprite colours.
#defineBRIGHTNESS_RED_SHIFT (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 (BLUE_SHIFT - 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 10PALETTE_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: below PALETTE_TINT_FROM_SOURCE, one RGB555 colour for all.
enumPALETTE_SELECTION { PALETTES_ALL, PALETTES_BG, PALETTES_SPRITES }Which palettes mnTitlePaletteFadeBuildColors builds.

Variables

NameDescription
extern Uint16TitlePaletteFadeChannelCurve [32]The title intro's own copies of the colour channel curves its tints read: each maps a 5-bit channel to a fade channel shifted up 10 bits, plain, lighter, or with more contrast.
extern Uint16TitlePaletteFadeChannelCurveLight [32]A brighter curve
extern Uint16TitlePaletteFadeChannelCurveContrast [32]A high-contrast curve (25 and above are full)

Description

Palette fades: the colours a fade moves from and to, and the tints (grey, sepia, dusk and the rest) a scene or the title intro builds a target from.

Macros in detail

TITLE_PALETTE_FADE_CHANNELS

#define TITLE_PALETTE_FADE_CHANNELS (PLTT_COLORS * 3)

The colour channels a TITLE_PALETTE_FADE moves: B, G and R for each of the palette's colours.

Referenced by mnTitlePaletteFadeCalculateSteps() and mnTitlePaletteFadeUpdate().

Definition at line 14 of file palette_buffers.h.

PALETTE_FADE_BG_COLORS

#define PALETTE_FADE_BG_COLORS (14 * PALETTE_COLORS)

The background colours a PALETTE_FADE moves, palettes 0 to 13; as many sprite colours follow them.

Referenced by mnShopSaveAndTintFieldPalette(), scKolimaPaletteCapture() and scKolimaPaletteCurse().

Definition at line 18 of file palette_buffers.h.

PALETTE_FADE_CHANNELS

#define PALETTE_FADE_CHANNELS (2 * PALETTE_FADE_BG_COLORS * 3)

The colour channels a PALETTE_FADE moves: B, G and R for each of its background and sprite colours.

Referenced by fdPaletteFadeCalculateSteps() and fdPaletteFadeUpdate().

Definition at line 21 of file palette_buffers.h.

BRIGHTNESS_RED_SHIFT

#define BRIGHTNESS_RED_SHIFT (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 mnTitlePaletteFadeBuildColors().

Definition at line 156 of file palette_buffers.h.

BRIGHTNESS_GREEN_SHIFT

#define BRIGHTNESS_GREEN_SHIFT (BLUE_SHIFT - GREEN_SHIFT + 2)

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 157 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 161 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 164 of file palette_buffers.h.

SEPIA_LEVEL_MIN

#define SEPIA_LEVEL_MIN 8

PALETTE_TINT_SEPIA holds each channel to these levels.

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 166 of file palette_buffers.h.

SEPIA_LEVEL_MAX

#define SEPIA_LEVEL_MAX 28

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 167 of file palette_buffers.h.

MUTED_RED_MIN

#define MUTED_RED_MIN 10

PALETTE_TINT_MUTED holds each channel to its own range.

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 170 of file palette_buffers.h.

MUTED_RED_MAX

#define MUTED_RED_MAX 28

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 171 of file palette_buffers.h.

MUTED_GREEN_MIN

#define MUTED_GREEN_MIN 16

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 172 of file palette_buffers.h.

MUTED_GREEN_MAX

#define MUTED_GREEN_MAX 24

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 173 of file palette_buffers.h.

MUTED_BLUE_MIN

#define MUTED_BLUE_MIN 16

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 174 of file palette_buffers.h.

MUTED_BLUE_MAX

#define MUTED_BLUE_MAX 26

Referenced by mnTitlePaletteFadeBuildColors().

Definition at line 175 of file palette_buffers.h.

Enumerations in detail

PALETTE_TINT

enum PALETTE_TINT

A palette tint, a palette fade's build mode: below PALETTE_TINT_FROM_SOURCE, one RGB555 colour for all.

EnumeratorValueDescription
PALETTE_TINT_FROM_SOURCE0x8000The backdrop colour (palette RAM's first colour) for all.
PALETTE_TINT_NONE0x10000Each colour unchanged; the tints after it are numbered on from it.
PALETTE_TINT_GRAYSCALEGrey of brightness (2R + 4G + B) / 7.
PALETTE_TINT_SEPIABrownish grey, as when Ivan reports to Layana in Hammet Palace: the shade (R + G + B) / SEPIA_SHADE_DIVISOR, red at 4 times it plus 5, green and blue 3 times plus 5, each held to SEPIA_LEVEL_MIN to SEPIA_LEVEL_MAX.
PALETTE_TINT_DIMThe storm's gloom: Vale's grass and paths go a dull, dark olive while the sprites keep their colours, between the lightning's flashes and at the ending's darkened sea. Half R + 10, two thirds G + 8, B - 7; black stays black.
PALETTE_TINT_MUTEDThe backgrounds World Map fades to as Venus Lighthouse shakes after its beacon is lit: each channel held to a narrow range (MUTED_RED_MIN to MUTED_RED_MAX and so on), then G and B + 2.
PALETTE_TINT_PALEA lightning flash: the storm's backgrounds wash out almost to white. Half of each channel, plus their mean.
PALETTE_TINT_REDThe red Vale's eruption lightning flashes to from PALETTE_TINT_DIM: R plus an eighth of G and of B; G and B two thirds.
PALETTE_TINT_DIMMERPALETTE_TINT_DIM darker: half R + 6, two thirds G + 4, B - 6. The title's intro builds PALETTE_TINT_DIM with this recipe.
PALETTE_TINT_FLAGS0x100000From here the TINT, BLEND and SPLIT bits are tested, TINT 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, over CUSTOM_TINT_DIVISOR.
PALETTE_TINT_BLEND0x400000The brightness R + G + B shared out in the proportions of the colour carried.
PALETTE_TINT_SPLIT0x800000Each colour unchanged.

Definition at line 100 of file palette_buffers.h.

PALETTE_SELECTION

enum PALETTE_SELECTION

Which palettes mnTitlePaletteFadeBuildColors builds.

EnumeratorValueDescription
PALETTES_ALL0
PALETTES_BG1
PALETTES_SPRITES2

Definition at line 178 of file palette_buffers.h.