mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Name the possible return values of palette fading functions
Also replace implicit conversion from gPalette.active into a status with if statements, to make the return value clear. I've also added comments when the check is redundant.
This commit is contained in:
parent
6f1d2b870c
commit
37bea25b01
@ -9,6 +9,11 @@
|
|||||||
#define PLTT_BUFFER_SIZE 0x200
|
#define PLTT_BUFFER_SIZE 0x200
|
||||||
#define PLTT_DECOMP_BUFFER_SIZE (PLTT_BUFFER_SIZE * 2)
|
#define PLTT_DECOMP_BUFFER_SIZE (PLTT_BUFFER_SIZE * 2)
|
||||||
|
|
||||||
|
#define PALETTE_FADE_STATUS_DELAY 2
|
||||||
|
#define PALETTE_FADE_STATUS_ACTIVE 1
|
||||||
|
#define PALETTE_FADE_STATUS_DONE 0
|
||||||
|
#define PALETTE_FADE_STATUS_LOADING -1
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
FAST_FADE_IN_FROM_WHITE,
|
FAST_FADE_IN_FROM_WHITE,
|
||||||
|
@ -115,7 +115,7 @@ u8 UpdatePaletteFade(void)
|
|||||||
u8 dummy = 0;
|
u8 dummy = 0;
|
||||||
|
|
||||||
if (sPlttBufferTransferPending)
|
if (sPlttBufferTransferPending)
|
||||||
return -1;
|
return PALETTE_FADE_STATUS_LOADING;
|
||||||
|
|
||||||
if (gPaletteFade.mode == NORMAL_FADE)
|
if (gPaletteFade.mode == NORMAL_FADE)
|
||||||
result = UpdateNormalPaletteFade();
|
result = UpdateNormalPaletteFade();
|
||||||
@ -409,11 +409,11 @@ static u8 UpdateNormalPaletteFade(void)
|
|||||||
u16 selectedPalettes;
|
u16 selectedPalettes;
|
||||||
|
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
return 0;
|
return PALETTE_FADE_STATUS_DONE;
|
||||||
|
|
||||||
if (IsSoftwarePaletteFadeFinishing())
|
if (IsSoftwarePaletteFadeFinishing())
|
||||||
{
|
{
|
||||||
return gPaletteFade.active;
|
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -483,7 +483,9 @@ static u8 UpdateNormalPaletteFade(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return gPaletteFade.active;
|
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||||
|
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||||
|
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,10 +580,11 @@ static u8 UpdateFastPaletteFade(void)
|
|||||||
s8 b;
|
s8 b;
|
||||||
|
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
return 0;
|
return PALETTE_FADE_STATUS_DONE;
|
||||||
|
|
||||||
if (IsSoftwarePaletteFadeFinishing())
|
if (IsSoftwarePaletteFadeFinishing())
|
||||||
return gPaletteFade.active;
|
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||||
|
|
||||||
|
|
||||||
if (gPaletteFade.objPaletteToggle)
|
if (gPaletteFade.objPaletteToggle)
|
||||||
{
|
{
|
||||||
@ -688,7 +691,9 @@ static u8 UpdateFastPaletteFade(void)
|
|||||||
gPaletteFade.objPaletteToggle ^= 1;
|
gPaletteFade.objPaletteToggle ^= 1;
|
||||||
|
|
||||||
if (gPaletteFade.objPaletteToggle)
|
if (gPaletteFade.objPaletteToggle)
|
||||||
return gPaletteFade.active;
|
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||||
|
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||||
|
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||||
|
|
||||||
if (gPaletteFade.y - gPaletteFade.deltaY < 0)
|
if (gPaletteFade.y - gPaletteFade.deltaY < 0)
|
||||||
gPaletteFade.y = 0;
|
gPaletteFade.y = 0;
|
||||||
@ -714,8 +719,10 @@ static u8 UpdateFastPaletteFade(void)
|
|||||||
gPaletteFade.mode = NORMAL_FADE;
|
gPaletteFade.mode = NORMAL_FADE;
|
||||||
gPaletteFade.softwareFadeFinishing = 1;
|
gPaletteFade.softwareFadeFinishing = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gPaletteFade.active;
|
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||||
|
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||||
|
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(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 shouldResetBlendRegisters)
|
||||||
@ -739,12 +746,12 @@ void BeginHardwarePaletteFade(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 should
|
|||||||
static u8 UpdateHardwarePaletteFade(void)
|
static u8 UpdateHardwarePaletteFade(void)
|
||||||
{
|
{
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
return 0;
|
return PALETTE_FADE_STATUS_DONE;
|
||||||
|
|
||||||
if (gPaletteFade.delayCounter < gPaletteFade_delay)
|
if (gPaletteFade.delayCounter < gPaletteFade_delay)
|
||||||
{
|
{
|
||||||
gPaletteFade.delayCounter++;
|
gPaletteFade.delayCounter++;
|
||||||
return 2;
|
return PALETTE_FADE_STATUS_DELAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
gPaletteFade.delayCounter = 0;
|
gPaletteFade.delayCounter = 0;
|
||||||
@ -778,7 +785,9 @@ static u8 UpdateHardwarePaletteFade(void)
|
|||||||
gPaletteFade.shouldResetBlendRegisters = 0;
|
gPaletteFade.shouldResetBlendRegisters = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gPaletteFade.active;
|
// gPaletteFade.active cannot change since the last time it was checked. So this
|
||||||
|
// is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;`
|
||||||
|
return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateBlendRegisters(void)
|
static void UpdateBlendRegisters(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user