mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-27 22:54:02 -04:00
Merge commit '76435d803f768be8da9821d72b98306a4b043ad2' into new-isle-decomp
This commit is contained in:
commit
fc76114a36
@ -278,6 +278,7 @@ add_library(omni STATIC
|
|||||||
LEGO1/omni/src/system/mxscheduler.cpp
|
LEGO1/omni/src/system/mxscheduler.cpp
|
||||||
LEGO1/omni/src/system/mxsemaphore.cpp
|
LEGO1/omni/src/system/mxsemaphore.cpp
|
||||||
LEGO1/omni/src/system/mxthread.cpp
|
LEGO1/omni/src/system/mxthread.cpp
|
||||||
|
LEGO1/omni/src/system/mxticklethread.cpp
|
||||||
LEGO1/omni/src/video/flic.cpp
|
LEGO1/omni/src/video/flic.cpp
|
||||||
LEGO1/omni/src/video/mxbitmap.cpp
|
LEGO1/omni/src/video/mxbitmap.cpp
|
||||||
LEGO1/omni/src/video/mxdisplaysurface.cpp
|
LEGO1/omni/src/video/mxdisplaysurface.cpp
|
||||||
|
@ -11,7 +11,7 @@ public:
|
|||||||
~MxAutoLock();
|
~MxAutoLock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MxCriticalSection* m_criticalSection;
|
MxCriticalSection* m_criticalSection; // 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MXAUTOLOCK_H
|
#endif // MXAUTOLOCK_H
|
||||||
|
@ -8,7 +8,9 @@ class MxCriticalSection {
|
|||||||
public:
|
public:
|
||||||
MxCriticalSection();
|
MxCriticalSection();
|
||||||
~MxCriticalSection();
|
~MxCriticalSection();
|
||||||
|
|
||||||
static void SetDoMutex();
|
static void SetDoMutex();
|
||||||
|
|
||||||
void Enter();
|
void Enter();
|
||||||
void Leave();
|
void Leave();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
class MxScheduler {
|
class MxScheduler {
|
||||||
public:
|
public:
|
||||||
static MxScheduler* GetInstance();
|
static MxScheduler* GetInstance();
|
||||||
|
|
||||||
void StartMultiTasking(MxULong);
|
void StartMultiTasking(MxULong);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef MX_SEMAPHORE_H
|
#ifndef MXSEMAPHORE_H
|
||||||
#define MX_SEMAPHORE_H
|
#define MXSEMAPHORE_H
|
||||||
|
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ private:
|
|||||||
SDL_Semaphore* m_semaphore; // 0x04
|
SDL_Semaphore* m_semaphore; // 0x04
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MX_SEMAPHORE_H
|
#endif // MXSEMAPHORE_H
|
||||||
|
@ -42,19 +42,4 @@ protected:
|
|||||||
MxCore* m_target; // 0x18
|
MxCore* m_target; // 0x18
|
||||||
};
|
};
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100dc6d8
|
|
||||||
// SIZE 0x20
|
|
||||||
class MxTickleThread : public MxThread {
|
|
||||||
public:
|
|
||||||
MxTickleThread(MxCore* p_target, MxS32 p_frequencyMS);
|
|
||||||
|
|
||||||
MxResult Run() override;
|
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100b8c20
|
|
||||||
// MxTickleThread::`scalar deleting destructor'
|
|
||||||
|
|
||||||
private:
|
|
||||||
MxS32 m_frequencyMS; // 0x1c
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MXTHREAD_H
|
#endif // MXTHREAD_H
|
||||||
|
21
LEGO1/omni/include/mxticklethread.h
Normal file
21
LEGO1/omni/include/mxticklethread.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef MXTICKLETHREAD_H
|
||||||
|
#define MXTICKLETHREAD_H
|
||||||
|
|
||||||
|
#include "mxthread.h"
|
||||||
|
|
||||||
|
// VTABLE: LEGO1 0x100dc6d8
|
||||||
|
// SIZE 0x20
|
||||||
|
class MxTickleThread : public MxThread {
|
||||||
|
public:
|
||||||
|
MxTickleThread(MxCore* p_target, MxS32 p_frequencyMS);
|
||||||
|
|
||||||
|
MxResult Run() override;
|
||||||
|
|
||||||
|
// SYNTHETIC: LEGO1 0x100b8c20
|
||||||
|
// MxTickleThread::`scalar deleting destructor'
|
||||||
|
|
||||||
|
private:
|
||||||
|
MxS32 m_frequencyMS; // 0x1c
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MXTICKLETHREAD_H
|
@ -1,8 +1,8 @@
|
|||||||
#include "mxmusicmanager.h"
|
#include "mxmusicmanager.h"
|
||||||
|
|
||||||
#include "mxmisc.h"
|
#include "mxmisc.h"
|
||||||
#include "mxthread.h"
|
|
||||||
#include "mxticklemanager.h"
|
#include "mxticklemanager.h"
|
||||||
|
#include "mxticklethread.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#include "mxmisc.h"
|
#include "mxmisc.h"
|
||||||
#include "mxomni.h"
|
#include "mxomni.h"
|
||||||
#include "mxpresenter.h"
|
#include "mxpresenter.h"
|
||||||
#include "mxthread.h"
|
|
||||||
#include "mxticklemanager.h"
|
#include "mxticklemanager.h"
|
||||||
|
#include "mxticklethread.h"
|
||||||
#include "mxwavepresenter.h"
|
#include "mxwavepresenter.h"
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(MxSoundManager, 0x3c);
|
DECOMP_SIZE_ASSERT(MxSoundManager, 0x3c);
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "mxcriticalsection.h"
|
#include "mxcriticalsection.h"
|
||||||
#include "mxmisc.h"
|
#include "mxmisc.h"
|
||||||
#include "mxthread.h"
|
|
||||||
#include "mxticklemanager.h"
|
#include "mxticklemanager.h"
|
||||||
|
#include "mxticklethread.h"
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100c0360
|
// FUNCTION: LEGO1 0x100c0360
|
||||||
MxEventManager::MxEventManager()
|
MxEventManager::MxEventManager()
|
||||||
|
@ -5,16 +5,17 @@
|
|||||||
// FUNCTION: LEGO1 0x100b8ed0
|
// FUNCTION: LEGO1 0x100b8ed0
|
||||||
MxAutoLock::MxAutoLock(MxCriticalSection* p_criticalSection)
|
MxAutoLock::MxAutoLock(MxCriticalSection* p_criticalSection)
|
||||||
{
|
{
|
||||||
this->m_criticalSection = p_criticalSection;
|
m_criticalSection = p_criticalSection;
|
||||||
if (this->m_criticalSection != 0) {
|
|
||||||
this->m_criticalSection->Enter();
|
if (m_criticalSection != NULL) {
|
||||||
|
m_criticalSection->Enter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b8ef0
|
// FUNCTION: LEGO1 0x100b8ef0
|
||||||
MxAutoLock::~MxAutoLock()
|
MxAutoLock::~MxAutoLock()
|
||||||
{
|
{
|
||||||
if (this->m_criticalSection != 0) {
|
if (m_criticalSection != NULL) {
|
||||||
this->m_criticalSection->Leave();
|
m_criticalSection->Leave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,35 +4,35 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(MxCriticalSection, 0x1c);
|
DECOMP_SIZE_ASSERT(MxCriticalSection, 0x1c)
|
||||||
|
|
||||||
// GLOBAL: LEGO1 0x10101e78
|
// GLOBAL: LEGO1 0x10101e78
|
||||||
int g_useMutex = 0;
|
BOOL g_useMutex = FALSE;
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b6d20
|
// FUNCTION: LEGO1 0x100b6d20
|
||||||
MxCriticalSection::MxCriticalSection()
|
MxCriticalSection::MxCriticalSection()
|
||||||
{
|
{
|
||||||
HANDLE mutex;
|
HANDLE mutex;
|
||||||
|
|
||||||
if (g_useMutex != 0) {
|
if (g_useMutex) {
|
||||||
mutex = CreateMutexA(NULL, FALSE, NULL);
|
mutex = CreateMutexA(NULL, FALSE, NULL);
|
||||||
this->m_mutex = mutex;
|
m_mutex = mutex;
|
||||||
return;
|
}
|
||||||
|
else {
|
||||||
|
InitializeCriticalSection(&m_criticalSection);
|
||||||
|
m_mutex = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeCriticalSection(&this->m_criticalSection);
|
|
||||||
this->m_mutex = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b6d60
|
// FUNCTION: LEGO1 0x100b6d60
|
||||||
MxCriticalSection::~MxCriticalSection()
|
MxCriticalSection::~MxCriticalSection()
|
||||||
{
|
{
|
||||||
if (this->m_mutex != NULL) {
|
if (m_mutex != NULL) {
|
||||||
CloseHandle(this->m_mutex);
|
CloseHandle(m_mutex);
|
||||||
return;
|
}
|
||||||
|
else {
|
||||||
|
DeleteCriticalSection(&m_criticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteCriticalSection(&this->m_criticalSection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b6d80
|
// FUNCTION: LEGO1 0x100b6d80
|
||||||
@ -41,8 +41,8 @@ void MxCriticalSection::Enter()
|
|||||||
DWORD result;
|
DWORD result;
|
||||||
FILE* file;
|
FILE* file;
|
||||||
|
|
||||||
if (this->m_mutex != NULL) {
|
if (m_mutex != NULL) {
|
||||||
result = WaitForSingleObject(this->m_mutex, 5000);
|
result = WaitForSingleObject(m_mutex, 5000);
|
||||||
if (result == WAIT_FAILED) {
|
if (result == WAIT_FAILED) {
|
||||||
file = fopen("C:\\DEADLOCK.TXT", "a");
|
file = fopen("C:\\DEADLOCK.TXT", "a");
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
@ -54,23 +54,23 @@ void MxCriticalSection::Enter()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
EnterCriticalSection(&this->m_criticalSection);
|
EnterCriticalSection(&m_criticalSection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b6de0
|
// FUNCTION: LEGO1 0x100b6de0
|
||||||
void MxCriticalSection::Leave()
|
void MxCriticalSection::Leave()
|
||||||
{
|
{
|
||||||
if (this->m_mutex != NULL) {
|
if (m_mutex != NULL) {
|
||||||
ReleaseMutex(this->m_mutex);
|
ReleaseMutex(m_mutex);
|
||||||
return;
|
}
|
||||||
|
else {
|
||||||
|
LeaveCriticalSection(&m_criticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&this->m_criticalSection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b6e00
|
// FUNCTION: LEGO1 0x100b6e00
|
||||||
void MxCriticalSection::SetDoMutex()
|
void MxCriticalSection::SetDoMutex()
|
||||||
{
|
{
|
||||||
g_useMutex = 1;
|
g_useMutex = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -7,8 +7,8 @@
|
|||||||
#include "mxpalette.h"
|
#include "mxpalette.h"
|
||||||
#include "mxpresenter.h"
|
#include "mxpresenter.h"
|
||||||
#include "mxregion.h"
|
#include "mxregion.h"
|
||||||
#include "mxthread.h"
|
|
||||||
#include "mxticklemanager.h"
|
#include "mxticklemanager.h"
|
||||||
|
#include "mxticklethread.h"
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(MxVideoManager, 0x64)
|
DECOMP_SIZE_ASSERT(MxVideoManager, 0x64)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user