Style refactor omni/system components (#974)

* Style refactor omni/system components

* Fix

* Fix
This commit is contained in:
Christian Semmler
2024-05-30 15:03:43 -04:00
committed by GitHub
parent ac41854149
commit 76435d803f
16 changed files with 106 additions and 84 deletions

View 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();
}