feat: hardware fades now affect BLDALPHA too
This commit is contained in:
parent
4047f9b764
commit
090c4f3936
@ -599,6 +599,7 @@
|
||||
#define BLDCNT_EFFECT_BLEND (1 << 6) // 1st+2nd targets mixed (controlled by BLDALPHA)
|
||||
#define BLDCNT_EFFECT_LIGHTEN (2 << 6) // 1st target becomes whiter (controlled by BLDY)
|
||||
#define BLDCNT_EFFECT_DARKEN (3 << 6) // 1st target becomes blacker (controlled by BLDY)
|
||||
#define BLDCNT_EFFECT_EFF_MASK (3 << 6) // mask to check effect
|
||||
// Bits 8-13 select layers for the 2nd target
|
||||
#define BLDCNT_TGT2_BG0 (1 << 8)
|
||||
#define BLDCNT_TGT2_BG1 (1 << 9)
|
||||
@ -611,6 +612,8 @@
|
||||
|
||||
// BLDALPHA
|
||||
#define BLDALPHA_BLEND(target1, target2) (((target2) << 8) | (target1))
|
||||
#define BLDALPHA_TGT1(bld) ((bld) & 0x1F)
|
||||
#define BLDALPHA_TGT2(bld) (((bld) >> 8) & 0x1F)
|
||||
|
||||
// SOUNDCNT_H
|
||||
#define SOUND_CGB_MIX_QUARTER 0x0000
|
||||
|
||||
@ -962,10 +962,43 @@ static u8 UpdateHardwarePaletteFade(void)
|
||||
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||
}
|
||||
|
||||
// Only called for hardware fades
|
||||
static void UpdateBlendRegisters(void)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, (u16)gPaletteFade_blendCnt);
|
||||
SetGpuReg(REG_OFFSET_BLDY, gPaletteFade.y);
|
||||
// If fade-out, also adjust BLDALPHA and DISPCNT
|
||||
if (!gPaletteFade.yDec /*&& gPaletteFade.mode == HARDWARE_FADE*/) {
|
||||
u16 bldAlpha = GetGpuReg(REG_OFFSET_BLDALPHA);
|
||||
u8 tgt1 = BLDALPHA_TGT1(bldAlpha);
|
||||
u8 tgt2 = BLDALPHA_TGT2(bldAlpha);
|
||||
u8 bldFade;
|
||||
|
||||
switch (gPaletteFade_blendCnt & BLDCNT_EFFECT_EFF_MASK)
|
||||
{
|
||||
// FADE_TO_BLACK
|
||||
case BLDCNT_EFFECT_DARKEN:
|
||||
bldFade = BLDALPHA_TGT1(max(0, 16 - gPaletteFade.y));
|
||||
SetGpuReg(
|
||||
REG_OFFSET_BLDALPHA,
|
||||
BLDALPHA_BLEND(min(tgt1, bldFade), min(tgt2, bldFade))
|
||||
);
|
||||
break;
|
||||
// FADE_TO_WHITE
|
||||
case BLDCNT_EFFECT_LIGHTEN:
|
||||
SetGpuReg(
|
||||
REG_OFFSET_BLDALPHA,
|
||||
BLDALPHA_BLEND(min(++tgt1, 31), min(++tgt2, 31))
|
||||
);
|
||||
// cause display to show white when finished
|
||||
// (otherwise blend-mode sprites will still be visible)
|
||||
if (gPaletteFade.hardwareFadeFinishing && gPaletteFade.y >= 16)
|
||||
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
|
||||
|
||||
if (gPaletteFade.hardwareFadeFinishing)
|
||||
{
|
||||
gPaletteFade.hardwareFadeFinishing = FALSE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user