diff --git a/src/objects/broly.c b/src/objects/broly.c index 4c283a175..d8e2c8ffd 100644 --- a/src/objects/broly.c +++ b/src/objects/broly.c @@ -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 */ diff --git a/src/p_mobj.c b/src/p_mobj.c index 7e3cf6666..491921adb 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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; diff --git a/src/p_mobj.h b/src/p_mobj.h index b29bab014..df453b0c2 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -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); diff --git a/src/p_pspr.h b/src/p_pspr.h index 82fe1af74..9d3b78ea4 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -59,6 +59,8 @@ extern "C" { #define FF_REVERSESUBTRACT ((AST_REVERSESUBTRACT-1)<frame & FF_INVERT) || hitlag_is_flashing(thing) || baddie_is_flashing(thing); }