Interpolate captions

This commit is contained in:
Zwip-Zwap Zapony 2023-02-02 15:50:40 +01:00 committed by NepDisk
parent 2f20b9d9c9
commit 9090568eab
2 changed files with 12 additions and 6 deletions

View file

@ -493,7 +493,7 @@ void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan)
closedcaptions[set].c = ((cnum == -1) ? NULL : &channels[cnum]);
closedcaptions[set].s = sfx;
closedcaptions[set].t = lifespan;
closedcaptions[set].b = 2; // bob
closedcaptions[set].b = 3; // bob
}
static INT32 S_ScaleVolumeWithSplitscreen(INT32 volume)

View file

@ -665,7 +665,8 @@ void SCR_ClosedCaptions(void)
for (i = 0; i < NUMCAPTIONS; i++)
{
INT32 flags, y;
INT32 flags;
fixed_t y;
char dot;
boolean music;
@ -678,14 +679,19 @@ void SCR_ClosedCaptions(void)
continue;
flags = V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_ALLOWLOWERCASE;
y = basey-(i*10);
y = (basey-(i*10)) * FRACUNIT;
if (closedcaptions[i].b)
{
y -= closedcaptions[i].b * 4;
if (renderisnewtic)
{
closedcaptions[i].b--;
if (closedcaptions[i].b) // If the caption hasn't reached its final destination...
{
y -= closedcaptions[i].b * 4 * FRACUNIT; // ...move it per tic...
y += (rendertimefrac % FRACUNIT) * 4; // ...and interpolate it per frame
// We have to modulo it by FRACUNIT, so that it won't be a tic ahead with interpolation disabled
// Unlike everything else, captions are (intentionally) interpolated from T to T+1 instead of T-1 to T
}
}
@ -699,7 +705,7 @@ void SCR_ClosedCaptions(void)
else
dot = ' ';
V_DrawRightAlignedString(BASEVIDWIDTH - 20, y, flags,
V_DrawRightAlignedStringAtFixed((BASEVIDWIDTH-20) * FRACUNIT, y, flags,
va("%c [%s]", dot, (closedcaptions[i].s->caption[0] ? closedcaptions[i].s->caption : closedcaptions[i].s->name)));
}
}