diff --git a/src/s_sound.c b/src/s_sound.c index 6ac886034..862cf12c5 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -586,7 +586,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) closedcaptions[set].c = &channels[cnum]; closedcaptions[set].s = sfx; - closedcaptions[set].t = TICRATE+2; + closedcaptions[set].t = MAXCAPTIONTICS+2; } // Assigns the handle to one of the channels in the @@ -694,7 +694,7 @@ dontplay: closedcaptions[set].c = &channels[cnum]; closedcaptions[set].s = sfx; - closedcaptions[set].t = TICRATE+2; + closedcaptions[set].t = MAXCAPTIONTICS+2; } // Assigns the handle to one of the channels in the @@ -973,21 +973,22 @@ notinlevel: for (i = 0; i < NUMCAPTIONS; i++) // update captions { - boolean cond = (closedcaptions[i].c && I_SoundIsPlaying(closedcaptions[i].c->handle)); + if (!closedcaptions[i].s) + continue; - if (closedcaptions[i].t <= TICRATE) + if (closedcaptions[i].t <= MAXCAPTIONTICS) closedcaptions[i].t--; - if (cond || (closedcaptions[i].s && closedcaptions[i].t)) - { - if (!cond) - closedcaptions[i].c = NULL; - } if (!closedcaptions[i].t) { closedcaptions[i].c = NULL; closedcaptions[i].s = NULL; - closedcaptions[i].t = 0; + } + else if (closedcaptions[i].c && !I_SoundIsPlaying(closedcaptions[i].c->handle)) + { + closedcaptions[i].c = NULL; + if (closedcaptions[i].t > CAPTIONFADETICS) + closedcaptions[i].t = CAPTIONFADETICS; } } } diff --git a/src/s_sound.h b/src/s_sound.h index dc0dfaf69..467cbf33b 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -86,6 +86,8 @@ typedef struct { } caption_t; #define NUMCAPTIONS 8 +#define MAXCAPTIONTICS (2*TICRATE) +#define CAPTIONFADETICS 20 extern caption_t closedcaptions[NUMCAPTIONS]; diff --git a/src/screen.c b/src/screen.c index 477225869..64f69fe7f 100644 --- a/src/screen.c +++ b/src/screen.c @@ -449,10 +449,10 @@ void SCR_ClosedCaptions(void) INT32 flags = V_NOSCALESTART|V_ALLOWLOWERCASE; INT32 y = vid.height-((i + 2)*10*vid.dupy); char dir = ' '; - if (closedcaptions[i].t < 20) - flags |= (((20-closedcaptions[i].t)/2)*V_10TRANS); - else if (closedcaptions[i].t > TICRATE) - y -= (closedcaptions[i].t-- - TICRATE)*vid.dupy; + if (closedcaptions[i].t < CAPTIONFADETICS) + flags |= (((CAPTIONFADETICS-closedcaptions[i].t)/2)*V_10TRANS); + else if (closedcaptions[i].t > MAXCAPTIONTICS) + y -= (closedcaptions[i].t-- - MAXCAPTIONTICS)*vid.dupy; if (closedcaptions[i].c && closedcaptions[i].c->origin) dir = '\x1E'; V_DrawRightAlignedString(vid.width-(20*vid.dupx), y,