mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-03 12:31:15 +00:00
Update
This commit is contained in:
parent
534eea0f77
commit
9ced7f8526
@ -1,45 +1,11 @@
|
|||||||
#include "mxthread.h"
|
#include "mxthread.h"
|
||||||
|
|
||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
#include "mxmisc.h"
|
|
||||||
#include "mxtimer.h"
|
|
||||||
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(MxThread, 0x1c)
|
DECOMP_SIZE_ASSERT(MxThread, 0x1c)
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100bf510
|
// FUNCTION: LEGO1 0x100bf510
|
||||||
MxThread::MxThread()
|
MxThread::MxThread()
|
||||||
@ -63,12 +29,14 @@ typedef unsigned(__stdcall* ThreadFunc)(void*);
|
|||||||
MxResult MxThread::Start(MxS32 p_stack, MxS32 p_flag)
|
MxResult MxThread::Start(MxS32 p_stack, MxS32 p_flag)
|
||||||
{
|
{
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
|
|
||||||
if (m_semaphore.Init(0, 1) == SUCCESS) {
|
if (m_semaphore.Init(0, 1) == SUCCESS) {
|
||||||
if ((m_hThread =
|
if ((m_hThread =
|
||||||
_beginthreadex(NULL, p_stack << 2, (ThreadFunc) &MxThread::ThreadProc, this, p_flag, &m_threadId))) {
|
_beginthreadex(NULL, p_stack << 2, (ThreadFunc) &MxThread::ThreadProc, this, p_flag, &m_threadId))) {
|
||||||
result = SUCCESS;
|
result = SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user