Skip to content

Commit

Permalink
Added PAL_isManualFadeDone() method (let you know if manual fading pr…
Browse files Browse the repository at this point in the history
…ocess is complete).
  • Loading branch information
Stephane-D committed Oct 20, 2024
1 parent fb08f94 commit de738ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
18 changes: 15 additions & 3 deletions inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,28 @@ void PAL_setPalette(u16 numPal, const u16* pal, TransferMethod tm);
* Duration of palette fading in number of frame.
*
* \see PAL_doFadeStep(..)
* \see PAL_isManualFadeDone(..)
*/
bool PAL_initFade(u16 fromCol, u16 toCol, const u16* palSrc, const u16* palDst, u16 numFrame);
/**
* \brief
* Update palette to process one iteration of current fade operation (see #PAL_initFade(..) method)
*
* \return TRUE when fading operation is not yet complete, FALSE otherwise
* \return TRUE if fading operation is not yet complete, FALSE otherwise
*
* \see PAL_initFade(..)
* \see PAL_isManualFadeDone(..)
*/
bool PAL_doFadeStep(void);
/**
* \brief
* Returns TRUE if the *manual* fading operation is complete, FALSE otherwise.<br>
* WARNING: This method is not related to #PAL_isDoingFade() which is about *asynchronous* fading process.
*
* \see PAL_initFade(..)
* \see PAL_doFadeStep(..)
*/
bool PAL_isManualFadeDone(void);

/**
* \brief
Expand Down Expand Up @@ -468,12 +479,13 @@ void PAL_fadeInAll(const u16* pal, u16 numFrame, bool async);

/**
* \brief
* Returns TRUE if currently doing a asynchronous fade operation.
* Returns TRUE if we are currently doing an asynchronous palette fading operation.<br>
* WARNING: This method is not related to #PAL_isManualFadeDone() which is about *manual fading* processed with #PAL_doFadeStep()
*/
bool PAL_isDoingFade(void);
/**
* \brief
* Wait for palette fading operation to complete (for asynchrone fading).
* Wait for (asynchronous) palette fading operation to complete.
*/
void PAL_waitFadeCompletion(void);
/**
Expand Down
Binary file modified lib/libmd.a
Binary file not shown.
9 changes: 7 additions & 2 deletions src/pal.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ bool NO_INLINE PAL_doFadeStep(void)
return (--fadeCounter > 0);
}

void PAL_interruptFade(void)
bool PAL_isManualFadeDone(void)
{
VBlankProcess &= ~PROCESS_PALETTE_FADING;
return (fadeCounter > 0)?TRUE:FALSE;
}

void PAL_fade(u16 fromCol, u16 toCol, const u16* palSrc, const u16* palDst, u16 numFrame, bool async)
Expand Down Expand Up @@ -474,3 +474,8 @@ void PAL_waitFadeCompletion()
// need to do VBlank process otherwise we can wait a long time for completion ^^
while (PAL_isDoingFade()) SYS_doVBlankProcess();
}

void PAL_interruptFade(void)
{
VBlankProcess &= ~PROCESS_PALETTE_FADING;
}

0 comments on commit de738ff

Please sign in to comment.