Merge pull request #984 from LegendOfDragoon/master
Optimize UpdateTimers
This commit is contained in:
commit
1c7a42274f
|
@ -161,13 +161,27 @@ void CSystemTimer::UpdateTimers()
|
||||||
int TimeTaken = m_LastUpdate - m_NextTimer;
|
int TimeTaken = m_LastUpdate - m_NextTimer;
|
||||||
if (TimeTaken != 0)
|
if (TimeTaken != 0)
|
||||||
{
|
{
|
||||||
|
uint32_t random, wired;
|
||||||
m_LastUpdate = m_NextTimer;
|
m_LastUpdate = m_NextTimer;
|
||||||
g_Reg->COUNT_REGISTER += TimeTaken;
|
g_Reg->COUNT_REGISTER += TimeTaken;
|
||||||
g_Reg->RANDOM_REGISTER -= TimeTaken / g_System->CountPerOp();
|
random = g_Reg->RANDOM_REGISTER - (TimeTaken / g_System->CountPerOp());
|
||||||
while ((int)g_Reg->RANDOM_REGISTER < (int)g_Reg->WIRED_REGISTER)
|
wired = g_Reg->WIRED_REGISTER;
|
||||||
|
if ((int)random < (int)wired)
|
||||||
{
|
{
|
||||||
g_Reg->RANDOM_REGISTER += 32 - g_Reg->WIRED_REGISTER;
|
if (wired == 0)
|
||||||
|
{
|
||||||
|
random &= 31;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint32_t increment = 32 - wired;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
random += increment;
|
||||||
|
} while ((int)random < (int)wired);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_Reg->RANDOM_REGISTER = random;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue