feat: added FadeScreenHardware utility
This commit is contained in:
parent
faf773a54b
commit
4047f9b764
@ -152,6 +152,7 @@ void SetCurrentAndNextWeatherNoDelay(u8 weather);
|
||||
void ApplyWeatherColorMapIfIdle(s8 colorMapIndex);
|
||||
void ApplyWeatherColorMapIfIdle_Gradual(u8 colorMapIndex, u8 targetColorMapIndex, u8 colorMapStepDelay);
|
||||
void FadeScreen(u8 mode, s8 delay);
|
||||
u16 FadeScreenHardware(u8 mode, s8 delay);
|
||||
bool8 IsWeatherNotFadingIn(void);
|
||||
void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex, bool8 allowFog);
|
||||
void ApplyWeatherColorMapToPal(u8 paletteIndex);
|
||||
|
||||
@ -99,7 +99,7 @@ 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);
|
||||
void BeginHardwarePaletteFade(u16 blendCnt, u8 delay, u8 y, u8 targetY, u8 shouldResetBlendRegisters);
|
||||
void BlendPalettes(u32 selectedPalettes, u8 coeff, u16 color);
|
||||
void BlendPalettesFine(u32 palettes, u16 *src, u16 *dst, u32 coeff, u32 color);
|
||||
void BlendPalettesUnfaded(u32 selectedPalettes, u8 coeff, u16 color);
|
||||
|
||||
@ -815,6 +815,35 @@ void FadeScreen(u8 mode, s8 delay)
|
||||
}
|
||||
}
|
||||
|
||||
// fades screen using BLDY
|
||||
// Note: This enables blending in all windows;
|
||||
// These bits may need to be disabled later
|
||||
u16 FadeScreenHardware(u8 mode, s8 delay) {
|
||||
u16 bldCnt = GetGpuReg(REG_OFFSET_BLDCNT) & BLDCNT_TGT2_ALL;
|
||||
bldCnt |= BLDCNT_TGT1_ALL;
|
||||
// enable blend in all windows
|
||||
SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR | WININ_WIN1_CLR);
|
||||
SetGpuRegBits(REG_OFFSET_WINOUT, WINOUT_WIN01_CLR);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case FADE_FROM_BLACK:
|
||||
BeginHardwarePaletteFade(bldCnt | BLDCNT_EFFECT_DARKEN, delay, 16, 0, TRUE);
|
||||
break;
|
||||
case FADE_TO_BLACK:
|
||||
BeginHardwarePaletteFade(bldCnt | BLDCNT_EFFECT_DARKEN, delay, 0, 16, FALSE);
|
||||
break;
|
||||
case FADE_FROM_WHITE:
|
||||
BeginHardwarePaletteFade(bldCnt | BLDCNT_EFFECT_LIGHTEN, delay, 16, 0, TRUE);
|
||||
break;
|
||||
case FADE_TO_WHITE:
|
||||
BeginHardwarePaletteFade(bldCnt | BLDCNT_EFFECT_LIGHTEN, delay, 0, 16, FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool8 IsWeatherNotFadingIn(void)
|
||||
{
|
||||
return (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_IN);
|
||||
|
||||
@ -896,7 +896,7 @@ static u8 UpdateFastPaletteFade(void)
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
}
|
||||
|
||||
void BeginHardwarePaletteFade(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 shouldResetBlendRegisters)
|
||||
void BeginHardwarePaletteFade(u16 blendCnt, u8 delay, u8 y, u8 targetY, u8 shouldResetBlendRegisters)
|
||||
{
|
||||
gPaletteFade_blendCnt = blendCnt;
|
||||
gPaletteFade.delayCounter = delay;
|
||||
@ -950,7 +950,8 @@ static u8 UpdateHardwarePaletteFade(void)
|
||||
{
|
||||
if (gPaletteFade.shouldResetBlendRegisters)
|
||||
{
|
||||
gPaletteFade_blendCnt = 0;
|
||||
// clear TGT1
|
||||
gPaletteFade_blendCnt &= ~0xFF;
|
||||
gPaletteFade.y = 0;
|
||||
}
|
||||
gPaletteFade.shouldResetBlendRegisters = FALSE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user