mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-28 19:04:06 +00:00
Style refactor omni/system components (#974)
* Style refactor omni/system components * Fix * Fix
This commit is contained in:
committed by
GitHub
parent
ac41854149
commit
76435d803f
41
LEGO1/omni/src/system/mxticklethread.cpp
Normal file
41
LEGO1/omni/src/system/mxticklethread.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "mxticklethread.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxmisc.h"
|
||||
#include "mxtimer.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxTickleThread, 0x20)
|
||||
|
||||
// FUNCTION: LEGO1 0x100b8bb0
|
||||
MxTickleThread::MxTickleThread(MxCore* p_target, MxS32 p_frequencyMS)
|
||||
{
|
||||
m_target = p_target;
|
||||
m_frequencyMS = p_frequencyMS;
|
||||
}
|
||||
|
||||
// Match except for register allocation
|
||||
// FUNCTION: LEGO1 0x100b8c90
|
||||
MxResult MxTickleThread::Run()
|
||||
{
|
||||
MxTimer* timer = Timer();
|
||||
MxS32 lastTickled = -m_frequencyMS;
|
||||
|
||||
while (IsRunning()) {
|
||||
MxLong currentTime = timer->GetTime();
|
||||
|
||||
if (currentTime < lastTickled) {
|
||||
lastTickled = -m_frequencyMS;
|
||||
}
|
||||
|
||||
MxS32 timeRemainingMS = (m_frequencyMS - currentTime) + lastTickled;
|
||||
if (timeRemainingMS <= 0) {
|
||||
m_target->Tickle();
|
||||
timeRemainingMS = 0;
|
||||
lastTickled = currentTime;
|
||||
}
|
||||
|
||||
Sleep(timeRemainingMS);
|
||||
}
|
||||
|
||||
return MxThread::Run();
|
||||
}
|
||||
Reference in New Issue
Block a user