mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 04:00:42 +00:00
- Blood: Re-time menu's blood dripping based on reworked timer and QAV struct code.
This commit is contained in:
parent
502b76af70
commit
c75778c08d
3 changed files with 30 additions and 28 deletions
|
@ -41,8 +41,7 @@ BEGIN_BLD_NS
|
|||
class CGameMenuItemQAV
|
||||
{
|
||||
public:
|
||||
int m_nX, m_nY;
|
||||
TArray<uint8_t> raw;
|
||||
QAV* data;
|
||||
int duration;
|
||||
int lastTick;
|
||||
bool bWideScreen;
|
||||
|
@ -54,25 +53,20 @@ public:
|
|||
|
||||
CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground)
|
||||
{
|
||||
m_nY = a4;
|
||||
m_nX = a3;
|
||||
bWideScreen = widescreen;
|
||||
bClearBackground = clearbackground;
|
||||
filename = name;
|
||||
|
||||
if (name)
|
||||
{
|
||||
// NBlood read this directly from the file system cache, but let's better store the data locally for robustness.
|
||||
raw = fileSystem.LoadFile(name, 0);
|
||||
if (raw.Size() != 0)
|
||||
data = getQAV(fileSystem.GetResourceId(fileSystem.FindFile(name)));
|
||||
if (data)
|
||||
{
|
||||
auto data = (QAV*)raw.Data();
|
||||
data->nSprite = -1;
|
||||
data->x = m_nX;
|
||||
data->y = m_nY;
|
||||
//data->Preload();
|
||||
data->x = a3;
|
||||
data->y = a4;
|
||||
duration = data->duration;
|
||||
lastTick = I_GetTime();
|
||||
lastTick = I_GetTime(data->ticrate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,29 +76,18 @@ void CGameMenuItemQAV::Draw(void)
|
|||
if (bClearBackground)
|
||||
twod->ClearScreen();
|
||||
|
||||
if (raw.Size() > 0)
|
||||
if (data)
|
||||
{
|
||||
auto data = (QAV*)raw.Data();
|
||||
|
||||
auto thisTick = I_GetTime();
|
||||
if (!lastTick)
|
||||
{
|
||||
lastTick = thisTick;
|
||||
}
|
||||
if (lastTick < thisTick)
|
||||
{
|
||||
lastTick = thisTick;
|
||||
duration -= 4;
|
||||
}
|
||||
qavProcessTicker(data, &duration, &lastTick);
|
||||
|
||||
if (duration <= 0 || duration > data->duration)
|
||||
{
|
||||
duration = data->duration;
|
||||
}
|
||||
auto currentDuration = data->duration - duration;
|
||||
auto smoothratio = I_GetTimeFrac() * MaxSmoothRatio;
|
||||
auto smoothratio = I_GetTimeFrac(data->ticrate) * MaxSmoothRatio;
|
||||
|
||||
data->Play(currentDuration - 4, currentDuration, -1, NULL);
|
||||
data->Play(currentDuration - data->ticksPerFrame, currentDuration, -1, NULL);
|
||||
|
||||
if (bWideScreen)
|
||||
{
|
||||
|
|
|
@ -221,6 +221,21 @@ void QAV::Precache(int palette)
|
|||
}
|
||||
}
|
||||
|
||||
void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick)
|
||||
{
|
||||
if (*duration > 0)
|
||||
{
|
||||
auto thisTick = I_GetTime(pQAV->ticrate);
|
||||
auto numTicks = thisTick - (*lastTick);
|
||||
if (numTicks)
|
||||
{
|
||||
*lastTick = thisTick;
|
||||
*duration -= pQAV->ticksPerFrame * numTicks;
|
||||
}
|
||||
}
|
||||
*duration = ClipLow(*duration, 0);
|
||||
}
|
||||
|
||||
|
||||
// This is to eliminate a huge design issue in NBlood that was apparently copied verbatim from the DOS-Version.
|
||||
// Sequences were cached in the resource and directly returned from there in writable form, with byte swapping directly performed in the cache on Big Endian systems.
|
||||
|
@ -279,6 +294,9 @@ QAV* getQAV(int res_id)
|
|||
}
|
||||
}
|
||||
|
||||
// Write out additions.
|
||||
qavdata->ticrate = 120. / qavdata->ticksPerFrame;
|
||||
|
||||
qavcache.Insert(res_id, qavdata);
|
||||
return qavdata;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ struct FRAMEINFO
|
|||
|
||||
struct QAV
|
||||
{
|
||||
char pad1[8]; // 0
|
||||
double ticrate; // 0
|
||||
int nFrames; // 8
|
||||
int ticksPerFrame; // C
|
||||
int duration; // 10
|
||||
|
@ -85,5 +85,6 @@ struct QAV
|
|||
};
|
||||
|
||||
QAV* getQAV(int res_id);
|
||||
void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick);
|
||||
|
||||
END_BLD_NS
|
||||
|
|
Loading…
Reference in a new issue