2017-03-05 05:43:34 +01:00
|
|
|
#ifndef GUARD_PALETTE_H
|
|
|
|
#define GUARD_PALETTE_H
|
|
|
|
|
|
|
|
#define gPaletteFade_selectedPalettes (gPaletteFade.multipurpose1) // normal and fast fade
|
|
|
|
#define gPaletteFade_blendCnt (gPaletteFade.multipurpose1) // hardware fade
|
|
|
|
#define gPaletteFade_delay (gPaletteFade.multipurpose2) // normal and hardware fade
|
|
|
|
#define gPaletteFade_submode (gPaletteFade.multipurpose2) // fast fade
|
|
|
|
|
2023-05-23 19:16:18 +02:00
|
|
|
#define PLTT_BUFFER_SIZE (PLTT_SIZE / sizeof(u16))
|
2017-10-12 09:06:19 +02:00
|
|
|
|
2019-02-10 03:50:12 +01:00
|
|
|
#define PALETTE_FADE_STATUS_DELAY 2
|
|
|
|
#define PALETTE_FADE_STATUS_ACTIVE 1
|
|
|
|
#define PALETTE_FADE_STATUS_DONE 0
|
2019-02-10 04:02:56 +01:00
|
|
|
#define PALETTE_FADE_STATUS_LOADING 0xFF
|
2019-02-10 03:50:12 +01:00
|
|
|
|
2021-02-24 17:01:02 +01:00
|
|
|
#define PALETTES_BG 0x0000FFFF
|
|
|
|
#define PALETTES_OBJECTS 0xFFFF0000
|
|
|
|
#define PALETTES_ALL (PALETTES_BG | PALETTES_OBJECTS)
|
|
|
|
|
2022-08-19 16:29:35 +02:00
|
|
|
#define PLTT_ID(n) ((n) * 16)
|
|
|
|
#define BG_PLTT_OFFSET 0x000
|
|
|
|
#define OBJ_PLTT_OFFSET 0x100
|
|
|
|
#define BG_PLTT_ID(n) (BG_PLTT_OFFSET + PLTT_ID(n))
|
|
|
|
#define OBJ_PLTT_ID(n) (OBJ_PLTT_OFFSET + PLTT_ID(n))
|
|
|
|
#define OBJ_PLTT_ID2(n) (PLTT_ID((n) + 16))
|
|
|
|
|
2017-03-05 05:43:34 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
FAST_FADE_IN_FROM_WHITE,
|
2017-12-22 08:03:16 +01:00
|
|
|
FAST_FADE_OUT_TO_WHITE,
|
2017-03-05 05:43:34 +01:00
|
|
|
FAST_FADE_IN_FROM_BLACK,
|
|
|
|
FAST_FADE_OUT_TO_BLACK,
|
|
|
|
};
|
|
|
|
|
2023-11-11 20:08:20 +01:00
|
|
|
struct BlendSettings
|
|
|
|
{
|
|
|
|
u32 blendColor:24;
|
|
|
|
u32 isTint:1;
|
|
|
|
u32 coeff:5;
|
|
|
|
};
|
|
|
|
|
2017-03-05 05:43:34 +01:00
|
|
|
struct PaletteFadeControl
|
|
|
|
{
|
|
|
|
u32 multipurpose1;
|
2023-11-11 20:08:20 +01:00
|
|
|
struct BlendSettings *bld0;
|
|
|
|
struct BlendSettings *bld1;
|
|
|
|
u16 weight:9;
|
2017-03-05 05:43:34 +01:00
|
|
|
u8 delayCounter:6;
|
|
|
|
u16 y:5; // blend coefficient
|
|
|
|
u16 targetY:5; // target blend coefficient
|
|
|
|
u16 blendColor:15;
|
2018-07-15 13:23:38 +02:00
|
|
|
bool16 active:1;
|
2017-03-05 05:43:34 +01:00
|
|
|
u16 multipurpose2:6;
|
2018-07-15 13:23:38 +02:00
|
|
|
bool16 yDec:1; // whether blend coefficient is decreasing
|
|
|
|
bool16 bufferTransferDisabled:1;
|
2017-03-05 05:43:34 +01:00
|
|
|
u16 mode:2;
|
2018-07-15 13:23:38 +02:00
|
|
|
bool16 shouldResetBlendRegisters:1;
|
|
|
|
bool16 hardwareFadeFinishing:1;
|
2017-03-05 05:43:34 +01:00
|
|
|
u16 softwareFadeFinishingCounter:5;
|
2018-07-15 13:23:38 +02:00
|
|
|
bool16 softwareFadeFinishing:1;
|
|
|
|
bool16 objPaletteToggle:1;
|
2017-03-05 05:43:34 +01:00
|
|
|
u8 deltaY:4; // rate of change of blend coefficient
|
|
|
|
};
|
|
|
|
|
2023-11-11 20:08:20 +01:00
|
|
|
extern const struct BlendSettings gTimeOfDayBlend[];
|
2017-03-05 05:43:34 +01:00
|
|
|
extern struct PaletteFadeControl gPaletteFade;
|
|
|
|
extern u32 gPlttBufferTransferPending;
|
2023-07-24 20:04:23 +02:00
|
|
|
extern u8 ALIGNED(4) gPaletteDecompressionBuffer[];
|
|
|
|
extern u16 ALIGNED(4) gPlttBufferUnfaded[PLTT_BUFFER_SIZE];
|
|
|
|
extern u16 ALIGNED(4) gPlttBufferFaded[PLTT_BUFFER_SIZE];
|
2017-03-05 05:43:34 +01:00
|
|
|
|
2022-09-13 02:14:15 +02:00
|
|
|
void LoadCompressedPalette(const u32 *src, u16 offset, u16 size);
|
|
|
|
void LoadPalette(const void *src, u16 offset, u16 size);
|
2023-11-11 20:08:20 +01:00
|
|
|
void LoadPaletteFast(const void *src, u16 offset, u16 size);
|
2022-09-13 02:14:15 +02:00
|
|
|
void FillPalette(u16 value, u16 offset, u16 size);
|
2017-03-05 05:43:34 +01:00
|
|
|
void TransferPlttBuffer(void);
|
|
|
|
u8 UpdatePaletteFade(void);
|
|
|
|
void ResetPaletteFade(void);
|
2022-09-13 02:14:15 +02:00
|
|
|
bool8 BeginNormalPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targetY, u16 blendColor);
|
|
|
|
void PaletteStruct_ResetById(u16 id);
|
2018-10-14 20:00:14 +02:00
|
|
|
void ResetPaletteFadeControl(void);
|
2022-09-13 02:14:15 +02:00
|
|
|
void InvertPlttBuffer(u32 selectedPalettes);
|
|
|
|
void TintPlttBuffer(u32 selectedPalettes, s8 r, s8 g, s8 b);
|
|
|
|
void UnfadePlttBuffer(u32 selectedPalettes);
|
|
|
|
void BeginFastPaletteFade(u8 submode);
|
|
|
|
void BeginHardwarePaletteFade(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 shouldResetBlendRegisters);
|
2019-01-26 14:50:24 +01:00
|
|
|
void BlendPalettes(u32 selectedPalettes, u8 coeff, u16 color);
|
2022-09-13 02:14:15 +02:00
|
|
|
void BlendPalettesUnfaded(u32 selectedPalettes, u8 coeff, u16 color);
|
2020-08-26 22:31:37 +02:00
|
|
|
void BlendPalettesGradually(u32 selectedPalettes, s8 delay, u8 coeff, u8 coeffTarget, u16 color, u8 priority, u8 id);
|
2019-01-20 18:24:35 +01:00
|
|
|
void TintPalette_GrayScale(u16 *palette, u16 count);
|
|
|
|
void TintPalette_GrayScale2(u16 *palette, u16 count);
|
|
|
|
void TintPalette_SepiaTone(u16 *palette, u16 count);
|
|
|
|
void TintPalette_CustomTone(u16 *palette, u16 count, u16 rTone, u16 gTone, u16 bTone);
|
2023-11-11 20:08:20 +01:00
|
|
|
bool8 BeginTimeOfDayPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targetY, struct BlendSettings *bld0, struct BlendSettings *bld1, u16 weight, u16 color);
|
|
|
|
void BlendPalettesFine(u32 palettes, u16 *src, u16 *dst, u32 coeff, u32 color);
|
|
|
|
void TimeMixPalettes(u32 palettes, u16 *src, u16 *dst, struct BlendSettings *blend0, struct BlendSettings *blend1, u16 weight0);
|
|
|
|
void AvgPaletteWeighted(u16 *src0, u16 *src1, u16 *dst, u16 weight0);
|
2017-03-05 05:43:34 +01:00
|
|
|
|
2022-08-19 16:47:50 +02:00
|
|
|
static inline void SetBackdropFromColor(u16 color)
|
2022-08-19 16:29:35 +02:00
|
|
|
{
|
2022-08-19 17:32:00 +02:00
|
|
|
FillPalette(color, 0, PLTT_SIZEOF(1));
|
2022-08-19 16:29:35 +02:00
|
|
|
}
|
|
|
|
|
2022-08-19 16:47:50 +02:00
|
|
|
static inline void SetBackdropFromPalette(const u16 *palette)
|
2022-08-19 16:29:35 +02:00
|
|
|
{
|
2022-08-19 17:32:00 +02:00
|
|
|
LoadPalette(palette, 0, PLTT_SIZEOF(1));
|
2022-08-19 16:29:35 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 05:43:34 +01:00
|
|
|
#endif // GUARD_PALETTE_H
|