mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 20:00:49 +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
|
class CGameMenuItemQAV
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int m_nX, m_nY;
|
QAV* data;
|
||||||
TArray<uint8_t> raw;
|
|
||||||
int duration;
|
int duration;
|
||||||
int lastTick;
|
int lastTick;
|
||||||
bool bWideScreen;
|
bool bWideScreen;
|
||||||
|
@ -54,25 +53,20 @@ public:
|
||||||
|
|
||||||
CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground)
|
CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground)
|
||||||
{
|
{
|
||||||
m_nY = a4;
|
|
||||||
m_nX = a3;
|
|
||||||
bWideScreen = widescreen;
|
bWideScreen = widescreen;
|
||||||
bClearBackground = clearbackground;
|
bClearBackground = clearbackground;
|
||||||
filename = name;
|
filename = name;
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
// NBlood read this directly from the file system cache, but let's better store the data locally for robustness.
|
data = getQAV(fileSystem.GetResourceId(fileSystem.FindFile(name)));
|
||||||
raw = fileSystem.LoadFile(name, 0);
|
if (data)
|
||||||
if (raw.Size() != 0)
|
|
||||||
{
|
{
|
||||||
auto data = (QAV*)raw.Data();
|
|
||||||
data->nSprite = -1;
|
data->nSprite = -1;
|
||||||
data->x = m_nX;
|
data->x = a3;
|
||||||
data->y = m_nY;
|
data->y = a4;
|
||||||
//data->Preload();
|
|
||||||
duration = data->duration;
|
duration = data->duration;
|
||||||
lastTick = I_GetTime();
|
lastTick = I_GetTime(data->ticrate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,29 +76,18 @@ void CGameMenuItemQAV::Draw(void)
|
||||||
if (bClearBackground)
|
if (bClearBackground)
|
||||||
twod->ClearScreen();
|
twod->ClearScreen();
|
||||||
|
|
||||||
if (raw.Size() > 0)
|
if (data)
|
||||||
{
|
{
|
||||||
auto data = (QAV*)raw.Data();
|
qavProcessTicker(data, &duration, &lastTick);
|
||||||
|
|
||||||
auto thisTick = I_GetTime();
|
|
||||||
if (!lastTick)
|
|
||||||
{
|
|
||||||
lastTick = thisTick;
|
|
||||||
}
|
|
||||||
if (lastTick < thisTick)
|
|
||||||
{
|
|
||||||
lastTick = thisTick;
|
|
||||||
duration -= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (duration <= 0 || duration > data->duration)
|
if (duration <= 0 || duration > data->duration)
|
||||||
{
|
{
|
||||||
duration = data->duration;
|
duration = data->duration;
|
||||||
}
|
}
|
||||||
auto currentDuration = data->duration - 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)
|
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.
|
// 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.
|
// 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);
|
qavcache.Insert(res_id, qavdata);
|
||||||
return qavdata;
|
return qavdata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct FRAMEINFO
|
||||||
|
|
||||||
struct QAV
|
struct QAV
|
||||||
{
|
{
|
||||||
char pad1[8]; // 0
|
double ticrate; // 0
|
||||||
int nFrames; // 8
|
int nFrames; // 8
|
||||||
int ticksPerFrame; // C
|
int ticksPerFrame; // C
|
||||||
int duration; // 10
|
int duration; // 10
|
||||||
|
@ -85,5 +85,6 @@ struct QAV
|
||||||
};
|
};
|
||||||
|
|
||||||
QAV* getQAV(int res_id);
|
QAV* getQAV(int res_id);
|
||||||
|
void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick);
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
Loading…
Reference in a new issue