Merge branch 'gacha-prep' into 'master'

Add FF_REVERSEANIM and FF_INVERT, extern P_InstaScale

See merge request KartKrew/Kart!1285
This commit is contained in:
Sal 2023-06-14 00:25:50 +00:00
commit 0f909bdb46
5 changed files with 25 additions and 9 deletions

View file

@ -6,13 +6,6 @@
#include "../p_local.h"
#include "../s_sound.h"
// TODO: generic function
static void P_InstaScale(mobj_t *thing, fixed_t scale)
{
P_SetScale(thing, scale);
thing->destscale = scale;
}
/* An object may not be visible on the same tic:
1) that it spawned
2) that it cycles to the next state */

View file

@ -154,11 +154,17 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj)
if (mobj->sprite != SPR_PLAY)
{
const UINT8 start = mobj->state->frame & FF_FRAMEMASK;
UINT8 frame = mobj->frame & FF_FRAMEMASK;
// compare the current sprite frame to the one we started from
// if more than var1 away from it, swap back to the original
// else just advance by one
if (((++mobj->frame) & FF_FRAMEMASK) - (mobj->state->frame & FF_FRAMEMASK) > (UINT32)mobj->state->var1)
mobj->frame = (mobj->state->frame & FF_FRAMEMASK) | (mobj->frame & ~FF_FRAMEMASK);
if ((mobj->frame & FF_REVERSEANIM ? (start - (--frame)) : ((++frame) - start)) > mobj->state->var1)
frame = start;
mobj->frame = frame | (mobj->frame & ~FF_FRAMEMASK);
return;
}
@ -4948,6 +4954,17 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale)
}
}
//
// P_InstaScale
//
// Set the object's current scale and destscale together
//
void P_InstaScale(mobj_t *thing, fixed_t scale)
{
P_SetScale(thing, scale);
thing->destscale = scale;
}
void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target
{
fixed_t dist, ndist, speedmul;

View file

@ -552,6 +552,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj);
void P_NullPrecipThinker(precipmobj_t *mobj);
void P_FreePrecipMobj(precipmobj_t *mobj);
void P_SetScale(mobj_t *mobj, fixed_t newscale);
void P_InstaScale(mobj_t *mobj, fixed_t newscale);
void P_XYMovement(mobj_t *mo);
void P_RingXYMovement(mobj_t *mo);
void P_SceneryXYMovement(mobj_t *mo);

View file

@ -59,6 +59,8 @@ extern "C" {
#define FF_REVERSESUBTRACT ((AST_REVERSESUBTRACT-1)<<FF_BLENDSHIFT)
#define FF_MODULATE ((AST_MODULATE-1)<<FF_BLENDSHIFT)
#define FF_OVERLAY ((AST_OVERLAY-1)<<FF_BLENDSHIFT)
/// \brief Frame flags: B/W inverted colors (hitlag flashing)
#define FF_INVERT 0x8000
/// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table
#define FF_TRANSMASK 0xf0000
@ -100,6 +102,8 @@ extern "C" {
#define FF_GLOBALANIM 0x20000000
/// \brief Frame flags - Animate: Start at a random place in the animation (mutually exclusive with above)
#define FF_RANDOMANIM 0x40000000
/// \brief Frame flags - Animate: Animate in reverse
#define FF_REVERSEANIM 0x80000000
/** \brief translucency tables

View file

@ -815,6 +815,7 @@ static boolean baddie_is_flashing(mobj_t *thing)
boolean R_ThingIsFlashing(mobj_t *thing)
{
return
(thing->frame & FF_INVERT) ||
hitlag_is_flashing(thing) ||
baddie_is_flashing(thing);
}