2023-06-19 01:36:07 -04:00
|
|
|
#include "mxomni.h"
|
|
|
|
|
2023-10-07 11:30:04 -04:00
|
|
|
#include "mxatomidcounter.h"
|
|
|
|
#include "mxeventmanager.h"
|
2023-10-07 13:12:59 -04:00
|
|
|
#include "mxmusicmanager.h"
|
2023-10-07 11:30:04 -04:00
|
|
|
#include "mxnotificationmanager.h"
|
|
|
|
#include "mxobjectfactory.h"
|
|
|
|
#include "mxomnicreateparam.h"
|
|
|
|
#include "mxsoundmanager.h"
|
|
|
|
#include "mxstreamer.h"
|
|
|
|
#include "mxticklemanager.h"
|
|
|
|
#include "mxtimer.h"
|
|
|
|
#include "mxvideomanager.h"
|
2023-10-07 14:05:45 -04:00
|
|
|
#include "mxautolocker.h"
|
2023-10-07 11:30:04 -04:00
|
|
|
|
2023-06-30 14:34:39 -04:00
|
|
|
// 0x101015b8
|
|
|
|
char g_hdPath[1024];
|
|
|
|
|
|
|
|
// 0x101019b8
|
|
|
|
char g_cdPath[1024];
|
|
|
|
|
|
|
|
// 0x10101db8
|
|
|
|
MxBool g_use3dSound;
|
|
|
|
|
2023-06-19 01:36:07 -04:00
|
|
|
// 0x101015b0
|
2023-06-29 13:02:47 -04:00
|
|
|
MxOmni *MxOmni::g_instance = NULL;
|
2023-06-19 01:36:07 -04:00
|
|
|
|
2023-06-19 02:19:40 -04:00
|
|
|
// OFFSET: LEGO1 0x100aef10
|
|
|
|
MxOmni::MxOmni()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100aeff0
|
|
|
|
MxOmni::~MxOmni()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2023-06-19 13:56:53 -04:00
|
|
|
// OFFSET: LEGO1 0x100af080
|
2023-06-19 02:19:40 -04:00
|
|
|
void MxOmni::Init()
|
|
|
|
{
|
|
|
|
m_windowHandle = NULL;
|
|
|
|
m_objectFactory = NULL;
|
|
|
|
m_variableTable = NULL;
|
|
|
|
m_tickleManager = NULL;
|
|
|
|
m_notificationManager = NULL;
|
|
|
|
m_videoManager = NULL;
|
|
|
|
m_soundManager = NULL;
|
|
|
|
m_musicManager = NULL;
|
|
|
|
m_eventManager = NULL;
|
|
|
|
m_timer = NULL;
|
|
|
|
m_streamer = NULL;
|
2023-08-16 13:09:44 -04:00
|
|
|
m_atomIdCounterSet = NULL;
|
2023-10-07 13:12:59 -04:00
|
|
|
m_timerRunning = NULL;
|
2023-06-19 02:19:40 -04:00
|
|
|
}
|
|
|
|
|
2023-10-07 09:05:44 -04:00
|
|
|
// OFFSET: LEGO1 0x100b0090
|
|
|
|
MxResult MxOmni::Start(MxDSAction* p_dsAction)
|
2023-09-13 03:44:03 -04:00
|
|
|
{
|
2023-10-07 09:05:44 -04:00
|
|
|
MxResult result = FAILURE;
|
|
|
|
if(p_dsAction->GetAtomId().GetInternal() != NULL && p_dsAction->GetObjectId() != -1 && m_streamer != NULL)
|
|
|
|
{
|
|
|
|
result = m_streamer->Unknown100b99b0(p_dsAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2023-09-13 03:44:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b00c0 STUB
|
2023-09-25 16:28:25 -04:00
|
|
|
void MxOmni::DeleteObject(MxDSAction &ds)
|
2023-09-13 03:44:03 -04:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b09a0 STUB
|
2023-09-25 16:28:25 -04:00
|
|
|
MxBool MxOmni::DoesEntityExist(MxDSAction &ds)
|
2023-09-13 03:44:03 -04:00
|
|
|
{
|
|
|
|
// TODO
|
2023-09-25 16:28:25 -04:00
|
|
|
return FALSE;
|
2023-09-13 03:44:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b00e0 STUB
|
|
|
|
void MxOmni::vtable0x2c()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100aefb0 STUB
|
|
|
|
int MxOmni::vtable0x30(char*, int, MxCore*)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100aefc0 STUB
|
|
|
|
void MxOmni::NotifyCurrentEntity()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2023-10-07 13:12:59 -04:00
|
|
|
// OFFSET: LEGO1 0x100b09d0
|
2023-09-13 03:44:03 -04:00
|
|
|
void MxOmni::StartTimer()
|
|
|
|
{
|
2023-10-07 13:12:59 -04:00
|
|
|
if (m_timerRunning == FALSE && m_timer != NULL && m_soundManager != NULL)
|
|
|
|
{
|
|
|
|
m_timer->Start();
|
|
|
|
m_soundManager->vtable0x34();
|
|
|
|
m_timerRunning = TRUE;
|
|
|
|
}
|
2023-09-13 03:44:03 -04:00
|
|
|
}
|
|
|
|
|
2023-10-07 13:12:59 -04:00
|
|
|
// OFFSET: LEGO1 0x100b0a00
|
|
|
|
void MxOmni::StopTimer()
|
2023-09-13 03:44:03 -04:00
|
|
|
{
|
2023-10-07 13:12:59 -04:00
|
|
|
if (m_timerRunning != FALSE && m_timer != NULL && m_soundManager != NULL)
|
|
|
|
{
|
|
|
|
m_timer->Stop();
|
|
|
|
m_soundManager->vtable0x38();
|
|
|
|
m_timerRunning = FALSE;
|
|
|
|
}
|
2023-09-13 03:44:03 -04:00
|
|
|
}
|
|
|
|
|
2023-06-29 13:02:47 -04:00
|
|
|
// OFFSET: LEGO1 0x100b0690
|
|
|
|
void MxOmni::DestroyInstance()
|
|
|
|
{
|
|
|
|
if (g_instance != NULL)
|
|
|
|
{
|
|
|
|
delete g_instance;
|
|
|
|
g_instance = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-30 14:34:39 -04:00
|
|
|
// OFFSET: LEGO1 0x100b0900
|
|
|
|
const char *MxOmni::GetHD()
|
|
|
|
{
|
|
|
|
return g_hdPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b0940
|
|
|
|
const char *MxOmni::GetCD()
|
|
|
|
{
|
|
|
|
return g_cdPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b0980
|
|
|
|
MxBool MxOmni::IsSound3D()
|
|
|
|
{
|
|
|
|
return g_use3dSound;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b0910
|
|
|
|
void MxOmni::SetHD(const char *p_hd)
|
|
|
|
{
|
|
|
|
strcpy(g_hdPath, p_hd);
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b0950
|
|
|
|
void MxOmni::SetCD(const char *p_cd)
|
|
|
|
{
|
|
|
|
strcpy(g_cdPath, p_cd);
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b0990
|
|
|
|
void MxOmni::SetSound3D(MxBool p_3dsound)
|
|
|
|
{
|
|
|
|
g_use3dSound = p_3dsound;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-19 01:36:07 -04:00
|
|
|
// OFFSET: LEGO1 0x100b0680
|
|
|
|
MxOmni *MxOmni::GetInstance()
|
|
|
|
{
|
2023-06-29 13:02:47 -04:00
|
|
|
return g_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100af0b0
|
|
|
|
void MxOmni::SetInstance(MxOmni *instance)
|
|
|
|
{
|
|
|
|
g_instance = instance;
|
2023-06-19 01:36:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100af0c0
|
|
|
|
MxResult MxOmni::Create(MxOmniCreateParam &p)
|
|
|
|
{
|
2023-10-07 14:05:45 -04:00
|
|
|
MxResult result = FAILURE;
|
2023-08-16 13:09:44 -04:00
|
|
|
m_atomIdCounterSet = new MxAtomIdCounterSet();
|
2023-10-07 14:05:45 -04:00
|
|
|
if (m_atomIdCounterSet == NULL)
|
|
|
|
{
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
m_mediaPath = p.GetMediaPath();
|
|
|
|
m_windowHandle = p.GetWindowHandle();
|
|
|
|
if (p.CreateFlags().CreateObjectFactory())
|
|
|
|
{
|
|
|
|
MxObjectFactory *objectFactory = new MxObjectFactory();
|
|
|
|
this->m_objectFactory = objectFactory;
|
|
|
|
|
|
|
|
if (objectFactory == NULL)
|
|
|
|
goto failure;
|
|
|
|
}
|
2023-08-16 13:09:44 -04:00
|
|
|
|
2023-08-03 20:13:41 -04:00
|
|
|
if (p.CreateFlags().CreateVariableTable())
|
|
|
|
{
|
|
|
|
MxVariableTable *variableTable = new MxVariableTable();
|
|
|
|
this->m_variableTable = variableTable;
|
|
|
|
|
|
|
|
if (variableTable == NULL)
|
2023-10-07 14:05:45 -04:00
|
|
|
goto failure;
|
2023-08-03 20:13:41 -04:00
|
|
|
}
|
|
|
|
|
2023-06-19 01:36:07 -04:00
|
|
|
if (p.CreateFlags().CreateTimer())
|
|
|
|
{
|
|
|
|
MxTimer *timer = new MxTimer();
|
|
|
|
this->m_timer = timer;
|
|
|
|
|
|
|
|
if (timer == NULL)
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2023-10-07 14:05:45 -04:00
|
|
|
if (p.CreateFlags().CreateTickleManager())
|
|
|
|
{
|
|
|
|
this->m_tickleManager = new MxTickleManager();
|
|
|
|
|
|
|
|
if (m_tickleManager == NULL)
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p.CreateFlags().CreateNotificationManager())
|
|
|
|
{
|
|
|
|
MxNotificationManager *notificationManager = new MxNotificationManager();
|
|
|
|
this->m_notificationManager = notificationManager;
|
|
|
|
|
|
|
|
if (notificationManager == NULL || notificationManager->Create(100, 0) != SUCCESS)
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p.CreateFlags().CreateStreamer())
|
|
|
|
{
|
|
|
|
MxStreamer *streamer = new MxStreamer();
|
|
|
|
this->m_streamer = streamer;
|
|
|
|
|
|
|
|
if (streamer == NULL || streamer->Init() != SUCCESS)
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p.CreateFlags().CreateVideoManager())
|
|
|
|
{
|
|
|
|
MxVideoManager *videoManager = new MxVideoManager();
|
|
|
|
this->m_videoManager = videoManager;
|
|
|
|
|
|
|
|
if (videoManager != NULL && videoManager->vtable0x2c(p.GetVideoParam(), 100, 0) != SUCCESS)
|
|
|
|
{
|
|
|
|
delete m_videoManager;
|
|
|
|
m_videoManager = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p.CreateFlags().CreateSoundManager())
|
|
|
|
{
|
|
|
|
MxSoundManager *soundManager = new MxSoundManager();
|
|
|
|
this->m_soundManager = soundManager;
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
if (soundManager != NULL && soundManager->StartDirectSound(10, 0) != SUCCESS)
|
|
|
|
{
|
|
|
|
delete m_soundManager;
|
|
|
|
m_soundManager = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p.CreateFlags().CreateMusicManager())
|
|
|
|
{
|
|
|
|
MxMusicManager *musicManager = new MxMusicManager();
|
|
|
|
this->m_musicManager = musicManager;
|
|
|
|
if (musicManager != NULL && musicManager->StartMIDIThread(50, 0) != SUCCESS)
|
|
|
|
{
|
|
|
|
delete m_musicManager;
|
|
|
|
m_musicManager = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p.CreateFlags().CreateEventManager())
|
|
|
|
{
|
|
|
|
MxEventManager *eventManager = new MxEventManager();
|
|
|
|
this->m_eventManager = eventManager;
|
|
|
|
if (m_eventManager != NULL && m_eventManager->vtable0x28(50, 0) != SUCCESS)
|
|
|
|
{
|
|
|
|
delete m_eventManager;
|
|
|
|
m_eventManager = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result = SUCCESS;
|
|
|
|
failure:
|
|
|
|
if (result != SUCCESS)
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2023-06-19 01:36:07 -04:00
|
|
|
}
|
2023-06-19 02:19:40 -04:00
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100afe90
|
|
|
|
void MxOmni::Destroy()
|
|
|
|
{
|
|
|
|
// FIXME: Stub
|
2023-08-16 13:09:44 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
// TODO: private members
|
|
|
|
if (m_notificationManager) {
|
|
|
|
while (m_notificationManager->m_queue->size()) {
|
|
|
|
m_notificationManager->Tickle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_notificationManager->m_active = 0;
|
|
|
|
*/
|
|
|
|
|
|
|
|
delete m_eventManager;
|
|
|
|
delete m_soundManager;
|
|
|
|
delete m_musicManager;
|
|
|
|
delete m_videoManager;
|
|
|
|
delete m_streamer;
|
|
|
|
delete m_timer;
|
|
|
|
delete m_objectFactory;
|
|
|
|
delete m_variableTable;
|
|
|
|
delete m_notificationManager;
|
|
|
|
delete m_tickleManager;
|
|
|
|
|
|
|
|
// There could be a tree/iterator function that does this inline
|
|
|
|
if (m_atomIdCounterSet) {
|
|
|
|
while (!m_atomIdCounterSet->empty()) {
|
|
|
|
// Pop each node and delete its value
|
|
|
|
MxAtomIdCounterSet::iterator begin = m_atomIdCounterSet->begin();
|
|
|
|
MxAtomIdCounter *value = *begin;
|
|
|
|
m_atomIdCounterSet->erase(begin);
|
|
|
|
delete value;
|
|
|
|
}
|
|
|
|
delete m_atomIdCounterSet;
|
|
|
|
}
|
2023-06-19 02:19:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b07f0
|
2023-07-02 04:05:49 -04:00
|
|
|
MxLong MxOmni::Notify(MxParam &p)
|
2023-06-19 02:19:40 -04:00
|
|
|
{
|
2023-10-07 14:05:45 -04:00
|
|
|
MxAutoLocker lock(&this->m_criticalsection);
|
|
|
|
|
|
|
|
if (p.GetType() != MXSTREAMER_UNKNOWN)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return HandleNotificationType2(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b0880 STUB
|
|
|
|
MxResult MxOmni::HandleNotificationType2(MxParam& p_param)
|
|
|
|
{
|
|
|
|
// TODO STUB
|
|
|
|
return FAILURE;
|
2023-06-19 02:19:40 -04:00
|
|
|
}
|
2023-06-19 04:34:58 -04:00
|
|
|
|
2023-06-29 13:02:47 -04:00
|
|
|
// OFFSET: LEGO1 0x100acea0
|
|
|
|
MxObjectFactory *ObjectFactory()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetObjectFactory();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100aceb0
|
|
|
|
MxNotificationManager *NotificationManager()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetNotificationManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100acec0
|
|
|
|
MxTickleManager *TickleManager()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetTickleManager();
|
|
|
|
}
|
|
|
|
|
2023-06-19 04:34:58 -04:00
|
|
|
// OFFSET: LEGO1 0x100aced0
|
|
|
|
MxTimer *Timer()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetTimer();
|
|
|
|
}
|
2023-06-29 13:02:47 -04:00
|
|
|
|
2023-08-16 13:09:44 -04:00
|
|
|
// OFFSET: LEGO1 0x100acee0
|
|
|
|
MxAtomIdCounterSet *AtomIdCounterSet()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetAtomIdCounterSet();
|
|
|
|
}
|
|
|
|
|
2023-06-29 13:02:47 -04:00
|
|
|
// OFFSET: LEGO1 0x100acef0
|
|
|
|
MxStreamer* Streamer()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetStreamer();
|
2023-10-07 09:05:44 -04:00
|
|
|
}
|
2023-06-29 13:02:47 -04:00
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100acf00
|
|
|
|
MxSoundManager* MSoundManager()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetSoundManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100acf10
|
|
|
|
MxVideoManager* MVideoManager()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetVideoManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100acf20
|
|
|
|
MxVariableTable* VariableTable()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetVariableTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100acf30
|
|
|
|
MxMusicManager* MusicManager()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetMusicManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100acf40
|
|
|
|
MxEventManager* EventManager()
|
|
|
|
{
|
|
|
|
return MxOmni::GetInstance()->GetEventManager();
|
2023-10-07 09:05:44 -04:00
|
|
|
}
|