Implement MxOmni::Create (#182)

* implement mxomni::create, and match MxStreamController::Open

* Use enum for mxparam type

* Fix return type

* Match MxOmni::Notify

* Remove unused variable

* Added override keywords

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha 2023-10-07 14:05:45 -04:00 committed by GitHub
parent 4a674d823b
commit 62b97b8f1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 164 additions and 24 deletions

View file

@ -15,4 +15,11 @@ MxEventManager::~MxEventManager()
// OFFSET: LEGO1 0x100c0450
void MxEventManager::Init()
{
}
}
// OFFSET: LEGO1 0x100c04a0 STUB
MxResult MxEventManager::vtable0x28(undefined4 p_unknown1, undefined p_unknown2)
{
//TODO
return FAILURE;
}

View file

@ -2,6 +2,7 @@
#define MXEVENTMANAGER_H
#include "mxmediamanager.h"
#include "decomp.h"
// VTABLE 0x100dc900
// SIZE 0x2c
@ -10,7 +11,7 @@ class MxEventManager : public MxMediaManager
public:
MxEventManager();
virtual ~MxEventManager() override;
virtual MxResult vtable0x28(undefined4 p_unknown1, MxU8 p_unknown2); // vtable+28
private:
void Init();
};

View file

@ -15,7 +15,7 @@ public:
MxMediaManager();
virtual ~MxMediaManager() override;
virtual MxResult Tickle(); // vtable+08
virtual MxResult Tickle() override; // vtable+08
virtual MxResult InitPresenters(); // vtable+14
virtual void Destroy(); // vtable+18
virtual void AddPresenter(MxPresenter &p_presenter); // vtable+1c

View file

@ -11,6 +11,7 @@
#include "mxticklemanager.h"
#include "mxtimer.h"
#include "mxvideomanager.h"
#include "mxautolocker.h"
// 0x101015b8
char g_hdPath[1024];
@ -182,7 +183,22 @@ void MxOmni::SetInstance(MxOmni *instance)
// OFFSET: LEGO1 0x100af0c0
MxResult MxOmni::Create(MxOmniCreateParam &p)
{
MxResult result = FAILURE;
m_atomIdCounterSet = new MxAtomIdCounterSet();
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;
}
if (p.CreateFlags().CreateVariableTable())
{
@ -190,7 +206,7 @@ MxResult MxOmni::Create(MxOmniCreateParam &p)
this->m_variableTable = variableTable;
if (variableTable == NULL)
return FAILURE;
goto failure;
}
if (p.CreateFlags().CreateTimer())
@ -202,7 +218,87 @@ MxResult MxOmni::Create(MxOmniCreateParam &p)
return FAILURE;
}
return SUCCESS;
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;
}
// OFFSET: LEGO1 0x100afe90
@ -248,8 +344,19 @@ void MxOmni::Destroy()
// OFFSET: LEGO1 0x100b07f0
MxLong MxOmni::Notify(MxParam &p)
{
// FIXME: Stub
return 0;
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;
}
// OFFSET: LEGO1 0x100acea0

View file

@ -61,6 +61,7 @@ public:
MxMusicManager* GetMusicManager() const { return this->m_musicManager; }
MxEventManager* GetEventManager() const { return this->m_eventManager; }
MxAtomIdCounterSet* GetAtomIdCounterSet() const { return this->m_atomIdCounterSet; }
MxResult HandleNotificationType2(MxParam& p_param);
protected:
static MxOmni* g_instance;

View file

@ -14,6 +14,9 @@ public:
__declspec(dllexport) MxOmniCreateParam(const char *mediaPath, struct HWND__ *windowHandle, MxVideoParam &vparam, MxOmniCreateFlags flags);
const MxOmniCreateFlags& CreateFlags() const { return this->m_createFlags; }
const MxString GetMediaPath() const { return m_mediaPath; }
const HWND GetWindowHandle() const { return m_windowHandle; }
MxVideoParam& GetVideoParam() { return m_videoParam; }
private:
MxString m_mediaPath;

View file

@ -7,16 +7,24 @@
class MxCore;
enum MxParamType
{
MXSTREAMER_UNKNOWN = 2,
MXPRESENTER_NOTIFICATION = 5,
MXSTREAMER_DELETE_NOTIFY = 6,
MXTRANSITIONMANAGER_TRANSITIONENDED = 24
};
// VTABLE 0x100d56e0
class MxParam : public MxOmniCreateParamBase
{
public:
inline MxParam(MxS32 p_type, MxCore *p_sender) : MxOmniCreateParamBase(), m_type(p_type), m_sender(p_sender){}
inline MxParam(MxParamType p_type, MxCore *p_sender) : MxOmniCreateParamBase(), m_type(p_type), m_sender(p_sender){}
virtual ~MxParam() override {} // vtable+0x0 (scalar deleting destructor)
virtual MxParam *Clone(); // vtable+0x4
inline MxS32 GetType() const
inline MxParamType GetType() const
{
return m_type;
}
@ -27,7 +35,7 @@ public:
}
protected:
MxS32 m_type; // 0x4
MxParamType m_type; // 0x4
MxCore *m_sender; // 0x8
};

View file

@ -49,9 +49,9 @@ void MxPresenter::ParseExtra()
int val = token ? atoi(token) : 0;
int result = MxOmni::GetInstance()->vtable0x30(t_token, val, this);
m_action->SetFlags(m_action->GetFlags() | MxDSAction::Flag_Parsed);
if (result)
SendTo_unkPresenter(MxOmni::GetInstance());
@ -65,8 +65,7 @@ void MxPresenter::SendTo_unkPresenter(MxOmni *p_omni)
if (m_unkPresenter) {
MxAutoLocker lock(&m_criticalSection);
// TOOD: magic number used for notification type. replace with enum
NotificationManager()->Send(m_unkPresenter, &MxParam(5, this));
NotificationManager()->Send(m_unkPresenter, &MxParam(MXPRESENTER_NOTIFICATION, this));
m_action->SetOmni(p_omni ? p_omni : MxOmni::GetInstance());
m_unkPresenter = NULL;

View file

@ -1,6 +1,7 @@
#include "mxstreamcontroller.h"
#include "mxautolocker.h"
#include "legoomni.h"
// OFFSET: LEGO1 0x100c0b90 STUB
MxStreamController::MxStreamController()
@ -24,10 +25,11 @@ MxBool MxStreamController::FUN_100c20d0(MxDSObject &p_obj)
// OFFSET: LEGO1 0x100c1520
MxResult MxStreamController::Open(const char *p_filename)
{
char sourceName [256];
MxAutoLocker locker(&m_criticalSection);
// TODO
MakeSourceName(sourceName, p_filename);
this->atom = MxAtomId(sourceName, LookupMode_LowerCase2);
return SUCCESS;
}

View file

@ -9,8 +9,6 @@
DECOMP_SIZE_ASSERT(MxStreamer, 0x2c);
#define MXSTREAMER_DELETE_NOTIFY 6
// OFFSET: LEGO1 0x100b8f00
MxStreamer::MxStreamer()
{

View file

@ -43,7 +43,7 @@ public:
class MxStreamerNotification : public MxParam
{
public:
inline MxStreamerNotification(MxS32 p_type, MxCore *p_sender, MxStreamController *p_ctrlr) : MxParam(p_type, p_sender)
inline MxStreamerNotification(MxParamType p_type, MxCore *p_sender, MxStreamController *p_ctrlr) : MxParam(p_type, p_sender)
{
m_controller = p_ctrlr;
}

View file

@ -85,7 +85,7 @@ void MxTransitionManager::EndTransition(MxBool p_notifyWorld)
LegoWorld *world = GetCurrentWorld();
if (world) {
world->Notify(MxParam(0x18, this));
world->Notify(MxParam(MXTRANSITIONMANAGER_TRANSITIONENDED, this));
}
}
}

View file

@ -34,7 +34,7 @@ MxResult MxVideoManager::Tickle()
UpdateRegion();
m_region->Reset();
return SUCCESS;
}
@ -54,13 +54,13 @@ MxResult MxVideoManager::Init()
void MxVideoManager::SortPresenterList()
{
if (this->m_presenters->GetCount() <= 1)
return;
return;
MxPresenterListCursor a(this->m_presenters);
MxPresenterListCursor b(this->m_presenters);
MxU32 count = this->m_presenters->GetCount() - 1;
MxBool finished;
if (count != 0) {
do {
a.Reset();
@ -111,3 +111,15 @@ MxLong MxVideoManager::RealizePalette(MxPalette *p_palette)
this->m_criticalSection.Leave();
return 0;
}
// OFFSET: LEGO1 0x100be600 STUB
void MxVideoManager::vtable0x28()
{
}
// OFFSET: LEGO1 0x100bebe0 STUB
MxResult MxVideoManager::vtable0x2c(MxVideoParam& p_videoParam, undefined4 p_unknown1, MxU8 p_unknown2)
{
return FAILURE;
}

View file

@ -13,7 +13,9 @@ class MxVideoManager : public MxMediaManager
public:
virtual ~MxVideoManager();
virtual MxResult Tickle(); // vtable+0x8
virtual MxResult Tickle() override; // vtable+0x8
virtual void vtable0x28(); // vtable+0x28 (TODO ARGUMENTS)
virtual MxResult vtable0x2c(MxVideoParam& p_videoParam, undefined4 p_unknown1, MxU8 p_unknown2); // vtable+0x2c
__declspec(dllexport) void InvalidateRect(MxRect32 &);
__declspec(dllexport) virtual MxLong RealizePalette(MxPalette *); // vtable+0x30