Merge branch 'rings_semibright' into 'rings'

Rings semibright

See merge request KartKrew/Kart!137
This commit is contained in:
Sal 2019-05-01 22:31:38 -04:00
commit dce96662e7
9 changed files with 145 additions and 72 deletions

View file

@ -8548,9 +8548,13 @@ struct {
// Frame settings // Frame settings
{"FF_FRAMEMASK",FF_FRAMEMASK}, {"FF_FRAMEMASK",FF_FRAMEMASK},
{"FF_PAPERSPRITE",FF_PAPERSPRITE},
{"FF_ANIMATE",FF_ANIMATE}, {"FF_ANIMATE",FF_ANIMATE},
{"FF_RANDOMANIM",FF_RANDOMANIM},
{"FF_GLOBALANIM",FF_GLOBALANIM},
{"FF_FULLBRIGHT",FF_FULLBRIGHT}, {"FF_FULLBRIGHT",FF_FULLBRIGHT},
{"FF_SEMIBRIGHT",FF_SEMIBRIGHT},
{"FF_PAPERSPRITE",FF_PAPERSPRITE},
{"FF_VERTICALFLIP",FF_VERTICALFLIP},
{"FF_TRANSMASK",FF_TRANSMASK}, {"FF_TRANSMASK",FF_TRANSMASK},
{"FF_TRANSSHIFT",FF_TRANSSHIFT}, {"FF_TRANSSHIFT",FF_TRANSSHIFT},
// new preshifted translucency (used in source) // new preshifted translucency (used in source)

View file

@ -4832,7 +4832,7 @@ void G_WriteGhostTic(mobj_t *ghost)
} }
// Store the sprite frame. // Store the sprite frame.
frame = ghost->frame & 0xFF; frame = ghost->frame & FF_FRAMEMASK;
if (frame != oldghost.frame) if (frame != oldghost.frame)
{ {
oldghost.frame = frame; oldghost.frame = frame;

View file

@ -4220,7 +4220,11 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
INT32 light = R_GetPlaneLight(sector, spr->mobj->floorz, false); INT32 light = R_GetPlaneLight(sector, spr->mobj->floorz, false);
if (!(spr->mobj->frame & FF_FULLBRIGHT)) if (!(spr->mobj->frame & FF_FULLBRIGHT))
{
lightlevel = *sector->lightlist[light].lightlevel; lightlevel = *sector->lightlist[light].lightlevel;
if (spr->mobj->frame & FF_SEMIBRIGHT)
lightlevel = 128 + (lightlevel>>1);
}
if (sector->lightlist[light].extra_colormap) if (sector->lightlist[light].extra_colormap)
colormap = sector->lightlist[light].extra_colormap; colormap = sector->lightlist[light].extra_colormap;
@ -4392,16 +4396,20 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
alpha = Surf.FlatColor.s.alpha; alpha = Surf.FlatColor.s.alpha;
// Start with the lightlevel and colormap from the top of the sprite
lightlevel = *list[sector->numlights - 1].lightlevel;
colormap = list[sector->numlights - 1].extra_colormap;
i = 0;
temp = FLOAT_TO_FIXED(realtop); temp = FLOAT_TO_FIXED(realtop);
if (spr->mobj->frame & FF_FULLBRIGHT)
lightlevel = 255;
#ifdef ESLOPE #ifdef ESLOPE
// Start with the lightlevel and colormap from the top of the sprite
lightlevel = 255;
colormap = list[sector->numlights - 1].extra_colormap;
if (!(spr->mobj->frame & FF_FULLBRIGHT))
{
lightlevel = *list[sector->numlights - 1].lightlevel;
if (spr->mobj->frame & FF_SEMIBRIGHT)
lightlevel = 128 + (lightlevel>>1);
}
for (i = 1; i < sector->numlights; i++) for (i = 1; i < sector->numlights; i++)
{ {
fixed_t h = sector->lightlist[i].slope ? P_GetZAt(sector->lightlist[i].slope, spr->mobj->x, spr->mobj->y) fixed_t h = sector->lightlist[i].slope ? P_GetZAt(sector->lightlist[i].slope, spr->mobj->x, spr->mobj->y)
@ -4409,7 +4417,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (h <= temp) if (h <= temp)
{ {
if (!(spr->mobj->frame & FF_FULLBRIGHT)) if (!(spr->mobj->frame & FF_FULLBRIGHT))
{
lightlevel = *list[i-1].lightlevel; lightlevel = *list[i-1].lightlevel;
if (spr->mobj->frame & FF_SEMIBRIGHT)
lightlevel = 128 + (lightlevel>>1);
}
colormap = list[i-1].extra_colormap; colormap = list[i-1].extra_colormap;
break; break;
} }
@ -4417,7 +4429,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
#else #else
i = R_GetPlaneLight(sector, temp, false); i = R_GetPlaneLight(sector, temp, false);
if (!(spr->mobj->frame & FF_FULLBRIGHT)) if (!(spr->mobj->frame & FF_FULLBRIGHT))
{
lightlevel = *list[i].lightlevel; lightlevel = *list[i].lightlevel;
if (spr->mobj->frame & FF_SEMIBRIGHT)
lightlevel = 128 + (lightlevel>>1);
}
colormap = list[i].extra_colormap; colormap = list[i].extra_colormap;
#endif #endif
@ -4433,7 +4449,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES))
{ {
if (!(spr->mobj->frame & FF_FULLBRIGHT)) if (!(spr->mobj->frame & FF_FULLBRIGHT))
{
lightlevel = *list[i].lightlevel; lightlevel = *list[i].lightlevel;
if (spr->mobj->frame & FF_SEMIBRIGHT)
lightlevel = 128 + (lightlevel>>1);
}
colormap = list[i].extra_colormap; colormap = list[i].extra_colormap;
} }
@ -4680,7 +4700,11 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
extracolormap_t *colormap = sector->extra_colormap; extracolormap_t *colormap = sector->extra_colormap;
if (!(spr->mobj->frame & FF_FULLBRIGHT)) if (!(spr->mobj->frame & FF_FULLBRIGHT))
{
lightlevel = sector->lightlevel; lightlevel = sector->lightlevel;
if (spr->mobj->frame & FF_SEMIBRIGHT)
lightlevel = 128 + (lightlevel>>1);
}
if (colormap) if (colormap)
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false); Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false);
@ -4788,6 +4812,9 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
colormap = sector->extra_colormap; colormap = sector->extra_colormap;
} }
if (spr->mobj->frame & FF_SEMIBRIGHT)
lightlevel = 128 + (lightlevel>>1);
if (colormap) if (colormap)
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false); Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false);
else else
@ -5417,6 +5444,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
size_t lumpoff; size_t lumpoff;
unsigned rot; unsigned rot;
UINT8 flip; UINT8 flip;
boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP));
angle_t ang; angle_t ang;
INT32 heightsec, phs; INT32 heightsec, phs;
const boolean papersprite = (thing->frame & FF_PAPERSPRITE); const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
@ -5548,7 +5576,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
x1 = tr_x + x1 * rightcos; x1 = tr_x + x1 * rightcos;
x2 = tr_x - x2 * rightcos; x2 = tr_x - x2 * rightcos;
if (thing->eflags & MFE_VERTICALFLIP) if (vflip)
{ {
gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale; gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
gzt = gz + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale; gzt = gz + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale;
@ -5635,10 +5663,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
//CONS_Debug(DBG_RENDER, "------------------\nH: sprite : %d\nH: frame : %x\nH: type : %d\nH: sname : %s\n\n", //CONS_Debug(DBG_RENDER, "------------------\nH: sprite : %d\nH: frame : %x\nH: type : %d\nH: sname : %s\n\n",
// thing->sprite, thing->frame, thing->type, sprnames[thing->sprite]); // thing->sprite, thing->frame, thing->type, sprnames[thing->sprite]);
if (thing->eflags & MFE_VERTICALFLIP) vis->vflip = vflip;
vis->vflip = true;
else
vis->vflip = false;
vis->precip = false; vis->precip = false;
} }

View file

@ -969,7 +969,7 @@ state_t states[NUMSTATES] =
{SPR_MSCF, FF_FULLBRIGHT|FF_TRANS30|11, 1, {NULL}, 0, 0, S_MSSHIELD_F1}, // S_MSSHIELD_F12 {SPR_MSCF, FF_FULLBRIGHT|FF_TRANS30|11, 1, {NULL}, 0, 0, S_MSSHIELD_F1}, // S_MSSHIELD_F12
// Ring // Ring
{SPR_RING, FF_ANIMATE, -1, {NULL}, 23, 1, S_RING}, // S_RING {SPR_RING, FF_SEMIBRIGHT|FF_ANIMATE|FF_GLOBALANIM, -1, {NULL}, 23, 1, S_RING}, // S_RING
{SPR_RING, 0, 1, {NULL}, 0, 0, S_FASTRING2}, // S_FASTRING1 {SPR_RING, 0, 1, {NULL}, 0, 0, S_FASTRING2}, // S_FASTRING1
{SPR_RING, 2, 1, {NULL}, 0, 0, S_FASTRING3}, // S_FASTRING2 {SPR_RING, 2, 1, {NULL}, 0, 0, S_FASTRING3}, // S_FASTRING2
{SPR_RING, 4, 1, {NULL}, 0, 0, S_FASTRING4}, // S_FASTRING3 {SPR_RING, 4, 1, {NULL}, 0, 0, S_FASTRING4}, // S_FASTRING3

View file

@ -3607,12 +3607,6 @@ void A_AttractChase(mobj_t *actor)
} }
else // Collecting else // Collecting
{ {
// Flicker fullbright
if (leveltime & 1)
actor->frame |= FF_FULLBRIGHT;
else
actor->frame &= ~FF_FULLBRIGHT;
if (actor->extravalue1 >= 16) if (actor->extravalue1 >= 16)
{ {
if (actor->target->player->kartstuff[k_rings] >= 20) if (actor->target->player->kartstuff[k_rings] >= 20)
@ -3647,12 +3641,6 @@ void A_AttractChase(mobj_t *actor)
} }
else else
{ {
// Flicker fullbright
if (leveltime & 1)
actor->frame |= FF_FULLBRIGHT;
else
actor->frame &= ~FF_FULLBRIGHT;
// Don't immediately pick up spilled rings // Don't immediately pick up spilled rings
if (actor->threshold > 0) if (actor->threshold > 0)
actor->threshold--; actor->threshold--;

View file

@ -85,6 +85,37 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum)
actioncachehead.prev = newaction; actioncachehead.prev = newaction;
} }
//
// P_SetupStateAnimation
//
FUNCINLINE static ATTRINLINE void P_SetupStateAnimation(mobj_t *mobj, state_t *st)
{
if (!(st->frame & FF_ANIMATE))
return;
if (st->var1 <= 0 || st->var2 == 0)
{
mobj->frame &= ~FF_ANIMATE;
return; // Crash/stupidity prevention
}
mobj->anim_duration = (UINT16)st->var2;
if (st->frame & FF_GLOBALANIM)
{
// Attempt to account for the pre-ticker for objects spawned on load
if (!leveltime) return;
mobj->anim_duration -= (leveltime + 2) % st->var2; // Duration synced to timer
mobj->frame += ((leveltime + 2) / st->var2) % (st->var1 + 1); // Frame synced to timer (duration taken into account)
}
else if (st->frame & FF_RANDOMANIM)
{
mobj->frame += P_RandomKey(st->var1 + 1); // Random starting frame
mobj->anim_duration -= P_RandomKey(st->var2); // Random duration for first frame
}
}
// //
// P_CycleStateAnimation // P_CycleStateAnimation
// //
@ -93,6 +124,7 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj)
// var2 determines delay between animation frames // var2 determines delay between animation frames
if (!(mobj->frame & FF_ANIMATE) || --mobj->anim_duration != 0) if (!(mobj->frame & FF_ANIMATE) || --mobj->anim_duration != 0)
return; return;
mobj->anim_duration = (UINT16)mobj->state->var2; mobj->anim_duration = (UINT16)mobj->state->var2;
// compare the current sprite frame to the one we started from // compare the current sprite frame to the one we started from
@ -212,7 +244,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
mobj->tics = st->tics; mobj->tics = st->tics;
mobj->sprite = st->sprite; mobj->sprite = st->sprite;
mobj->frame = st->frame; mobj->frame = st->frame;
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set P_SetupStateAnimation(mobj, st);
// Modified handling. // Modified handling.
// Call action functions when the state is set // Call action functions when the state is set
@ -280,7 +312,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
mobj->tics = st->tics; mobj->tics = st->tics;
mobj->sprite = st->sprite; mobj->sprite = st->sprite;
mobj->frame = st->frame; mobj->frame = st->frame;
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set P_SetupStateAnimation(mobj, st);
// Modified handling. // Modified handling.
// Call action functions when the state is set // Call action functions when the state is set
@ -334,7 +366,7 @@ boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state)
mobj->tics = st->tics; mobj->tics = st->tics;
mobj->sprite = st->sprite; mobj->sprite = st->sprite;
mobj->frame = st->frame; mobj->frame = st->frame;
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set P_SetupStateAnimation(mobj, st);
return true; return true;
} }
@ -353,7 +385,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state)
mobj->tics = st->tics; mobj->tics = st->tics;
mobj->sprite = st->sprite; mobj->sprite = st->sprite;
mobj->frame = st->frame; mobj->frame = st->frame;
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set P_SetupStateAnimation((mobj_t*)mobj, st);
return true; return true;
} }
@ -3983,9 +4015,6 @@ static void P_RingThinker(mobj_t *mobj)
return; return;
} }
if (mobj->state == &states[S_RING]) // sync map rings to a global timer
mobj->frame = (leveltime % ((UINT32)mobj->state->var1)) | (mobj->state->frame & ~FF_FRAMEMASK);
else
P_CycleMobjState(mobj); P_CycleMobjState(mobj);
} }
@ -9688,7 +9717,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->tics = st->tics; mobj->tics = st->tics;
mobj->sprite = st->sprite; mobj->sprite = st->sprite;
mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits..
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set P_SetupStateAnimation(mobj, st);
mobj->friction = ORIG_FRICTION; mobj->friction = ORIG_FRICTION;
@ -10139,6 +10168,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster)
mobj->tics = st->tics; mobj->tics = st->tics;
mobj->sprite = st->sprite; mobj->sprite = st->sprite;
mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits..
P_SetupStateAnimation(mobj, st);
mobj->friction = ORIG_FRICTION; mobj->friction = ORIG_FRICTION;
@ -10231,7 +10261,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
mobj->tics = st->tics; mobj->tics = st->tics;
mobj->sprite = st->sprite; mobj->sprite = st->sprite;
mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits..
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set P_SetupStateAnimation((mobj_t*)mobj, st);
// set subsector and/or block links // set subsector and/or block links
P_SetPrecipitationThingPosition(mobj); P_SetPrecipitationThingPosition(mobj);

View file

@ -35,14 +35,9 @@
#pragma interface #pragma interface
#endif #endif
/// \brief Frame flags: only the frame number /// \brief Frame flags: only the frame number (frames from 0 to 63, but a bit of headroom for 2.2 compat)
#define FF_FRAMEMASK 0x1ff #define FF_FRAMEMASK 0xff
/// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION)
#define FF_PAPERSPRITE 0x800
/// \brief Frame flags: Simple stateless animation
#define FF_ANIMATE 0x4000
/// \brief Frame flags: frame always appears full bright
#define FF_FULLBRIGHT 0x8000
/// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table /// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table
#define FF_TRANSMASK 0xf0000 #define FF_TRANSMASK 0xf0000
/// \brief shift for FF_TRANSMASK /// \brief shift for FF_TRANSMASK
@ -58,6 +53,23 @@
#define FF_TRANS80 (tr_trans80<<FF_TRANSSHIFT) #define FF_TRANS80 (tr_trans80<<FF_TRANSSHIFT)
#define FF_TRANS90 (tr_trans90<<FF_TRANSSHIFT) #define FF_TRANS90 (tr_trans90<<FF_TRANSSHIFT)
/// \brief Frame flags: frame always appears full bright (mutually exclusive with below, currently takes priority)
#define FF_FULLBRIGHT 0x00100000
/// \brief Frame flags: frame appears with moderate brightness (mutually exclusive with above)
#define FF_SEMIBRIGHT 0x00200000
/// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION)
#define FF_PAPERSPRITE 0x00400000
/// \brief Frame flags: Flip sprite vertically (relative to what it should be for its gravity)
#define FF_VERTICALFLIP 0x00800000
/// \brief Frame flags - Animate: Simple stateless animation
#define FF_ANIMATE 0x01000000
/// \brief Frame flags - Animate: Sync animation to global timer (mutually exclusive with below, currently takes priority)
#define FF_GLOBALANIM 0x02000000
/// \brief Frame flags - Animate: Start at a random place in the animation (mutually exclusive with above)
#define FF_RANDOMANIM 0x04000000
/** \brief translucency tables /** \brief translucency tables
\todo add another asm routine which use the fg and bg indexes in the \todo add another asm routine which use the fg and bg indexes in the

View file

@ -818,7 +818,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
colfunc = basecolfunc; // hack: this isn't resetting properly somewhere. colfunc = basecolfunc; // hack: this isn't resetting properly somewhere.
dc_colormap = vis->colormap; dc_colormap = vis->colormap;
if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" if (!(vis->cut & SC_PRECIP) && (vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
{ {
// translate certain pixels to white // translate certain pixels to white
colfunc = transcolfunc; colfunc = transcolfunc;
@ -889,18 +889,18 @@ static void R_DrawVisSprite(vissprite_t *vis)
frac = vis->startfrac; frac = vis->startfrac;
windowtop = windowbottom = sprbotscreen = INT32_MAX; windowtop = windowbottom = sprbotscreen = INT32_MAX;
if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES)
this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale); this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale);
if (this_scale <= 0) if (this_scale <= 0)
this_scale = 1; this_scale = 1;
if (this_scale != FRACUNIT) if (this_scale != FRACUNIT)
{ {
if (!vis->isScaled) if (!(vis->cut & SC_ISSCALED))
{ {
vis->scale = FixedMul(vis->scale, this_scale); vis->scale = FixedMul(vis->scale, this_scale);
vis->scalestep = FixedMul(vis->scalestep, this_scale); vis->scalestep = FixedMul(vis->scalestep, this_scale);
vis->xiscale = FixedDiv(vis->xiscale,this_scale); vis->xiscale = FixedDiv(vis->xiscale,this_scale);
vis->isScaled = true; vis->cut |= SC_ISSCALED;
} }
dc_texturemid = FixedDiv(dc_texturemid,this_scale); dc_texturemid = FixedDiv(dc_texturemid,this_scale);
} }
@ -946,7 +946,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
#else #else
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS]));
#endif #endif
if (vis->vflip) if (vis->cut & SC_VFLIP)
R_DrawFlippedMaskedColumn(column, patch->height); R_DrawFlippedMaskedColumn(column, patch->height);
else else
R_DrawMaskedColumn(column); R_DrawMaskedColumn(column);
@ -1026,7 +1026,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
// //
// R_SplitSprite // R_SplitSprite
// runs through a sector's lightlist and // runs through a sector's lightlist and
static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) static void R_SplitSprite(vissprite_t *sprite)
{ {
INT32 i, lightnum, lindex; INT32 i, lightnum, lindex;
INT16 cutfrac; INT16 cutfrac;
@ -1062,6 +1062,8 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
// adjust the heights. // adjust the heights.
newsprite = M_Memcpy(R_NewVisSprite(), sprite, sizeof (vissprite_t)); newsprite = M_Memcpy(R_NewVisSprite(), sprite, sizeof (vissprite_t));
newsprite->cut |= (sprite->cut & SC_FLAGMASK);
sprite->cut |= SC_BOTTOM; sprite->cut |= SC_BOTTOM;
sprite->gz = testheight; sprite->gz = testheight;
@ -1101,13 +1103,17 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
; ;
else else
*/ */
if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) if (!((newsprite->cut & SC_FULLBRIGHT)
&& (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1))))
{ {
lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT);
if (lindex >= MAXLIGHTSCALE) if (lindex >= MAXLIGHTSCALE)
lindex = MAXLIGHTSCALE-1; lindex = MAXLIGHTSCALE-1;
if (newsprite->cut & SC_SEMIBRIGHT)
lindex = (MAXLIGHTSCALE/2) + (lindex >> 1);
newsprite->colormap = spritelights[lindex]; newsprite->colormap = spritelights[lindex];
} }
} }
@ -1135,6 +1141,7 @@ static void R_ProjectSprite(mobj_t *thing)
size_t rot; size_t rot;
UINT8 flip; UINT8 flip;
boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP));
INT32 lindex; INT32 lindex;
@ -1340,7 +1347,7 @@ static void R_ProjectSprite(mobj_t *thing)
} }
//SoM: 3/17/2000: Disregard sprites that are out of view.. //SoM: 3/17/2000: Disregard sprites that are out of view..
if (thing->eflags & MFE_VERTICALFLIP) if (vflip)
{ {
// When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned.
// sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course.
@ -1482,7 +1489,12 @@ static void R_ProjectSprite(mobj_t *thing)
else if (thing->frame & FF_TRANSMASK) else if (thing->frame & FF_TRANSMASK)
vis->transmap = transtables + (thing->frame & FF_TRANSMASK) - 0x10000; vis->transmap = transtables + (thing->frame & FF_TRANSMASK) - 0x10000;
if (((thing->frame & FF_FULLBRIGHT) || (thing->flags2 & MF2_SHADOW)) if (thing->frame & FF_FULLBRIGHT || thing->flags2 & MF2_SHADOW)
vis->cut |= SC_FULLBRIGHT;
else if (thing->frame & FF_SEMIBRIGHT)
vis->cut |= SC_SEMIBRIGHT;
if (vis->cut & SC_FULLBRIGHT
&& (!vis->extra_colormap || !(vis->extra_colormap->fog & 1))) && (!vis->extra_colormap || !(vis->extra_colormap->fog & 1)))
{ {
// full bright: goggles // full bright: goggles
@ -1496,20 +1508,17 @@ static void R_ProjectSprite(mobj_t *thing)
if (lindex >= MAXLIGHTSCALE) if (lindex >= MAXLIGHTSCALE)
lindex = MAXLIGHTSCALE-1; lindex = MAXLIGHTSCALE-1;
if (vis->cut & SC_SEMIBRIGHT)
lindex = (MAXLIGHTSCALE/2) + (lindex >> 1);
vis->colormap = spritelights[lindex]; vis->colormap = spritelights[lindex];
} }
vis->precip = false; if (vflip)
vis->cut |= SC_VFLIP;
if (thing->eflags & MFE_VERTICALFLIP)
vis->vflip = true;
else
vis->vflip = false;
vis->isScaled = false;
if (thing->subsector->sector->numlights) if (thing->subsector->sector->numlights)
R_SplitSprite(vis, thing); R_SplitSprite(vis);
// Debug // Debug
++objectsdrawn; ++objectsdrawn;
@ -1681,15 +1690,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->transmap = NULL; vis->transmap = NULL;
vis->mobjflags = 0; vis->mobjflags = 0;
vis->cut = SC_NONE; vis->cut = SC_PRECIP;
vis->extra_colormap = thing->subsector->sector->extra_colormap; vis->extra_colormap = thing->subsector->sector->extra_colormap;
vis->heightsec = thing->subsector->sector->heightsec; vis->heightsec = thing->subsector->sector->heightsec;
// Fullbright // Fullbright
vis->colormap = colormaps; vis->colormap = colormaps;
vis->precip = true;
vis->vflip = false;
vis->isScaled = false;
} }
// R_AddSprites // R_AddSprites
@ -2482,7 +2488,7 @@ void R_DrawMasked(void)
next = r2->prev; next = r2->prev;
// Tails 08-18-2002 // Tails 08-18-2002
if (r2->sprite->precip == true) if (r2->sprite->cut & SC_PRECIP)
R_DrawPrecipitationSprite(r2->sprite); R_DrawPrecipitationSprite(r2->sprite);
else else
R_DrawSprite(r2->sprite); R_DrawSprite(r2->sprite);

View file

@ -102,9 +102,20 @@ typedef struct
// ----------- // -----------
typedef enum typedef enum
{ {
// actual cuts
SC_NONE = 0, SC_NONE = 0,
SC_TOP = 1, SC_TOP = 1,
SC_BOTTOM = 2 SC_BOTTOM = 1<<1,
// other flags
SC_PRECIP = 1<<2,
//SC_LINKDRAW = 1<<3, -- 2.2 compat
SC_FULLBRIGHT = 1<<4,
SC_SEMIBRIGHT = 1<<5,
SC_VFLIP = 1<<6,
SC_ISSCALED = 1>>7,
// masks
SC_CUTMASK = SC_TOP|SC_BOTTOM,
SC_FLAGMASK = ~SC_CUTMASK
} spritecut_e; } spritecut_e;
// A vissprite_t is a thing that will be drawn during a refresh, // A vissprite_t is a thing that will be drawn during a refresh,
@ -153,9 +164,6 @@ typedef struct vissprite_s
INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH];
boolean precip;
boolean vflip; // Flip vertically
boolean isScaled;
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
} vissprite_t; } vissprite_t;