implement most of MxBackgroundAudioManager

This commit is contained in:
Misha 2023-10-22 09:21:23 -04:00
parent ae908a74cc
commit 9945171c95
6 changed files with 90 additions and 9 deletions

View File

@ -11,6 +11,9 @@
// 0x100f4588
MxAtomId *g_nocdSourceName = NULL;
// 0x100f456c
MxAtomId *g_jukeboxScript = NULL;
// 0x101020e8
void (*g_omniUserMessage)(const char *,int);
@ -26,10 +29,13 @@ LegoOmni::~LegoOmni()
Destroy();
}
// OFFSET: LEGO1 0x1005b560 STUB
// OFFSET: LEGO1 0x1005b560
void LegoOmni::CreateBackgroundAudio()
{
// TODO
if (m_bkgAudioManager != NULL)
{
m_bkgAudioManager->Create(*g_jukeboxScript, 100);
}
}
// OFFSET: LEGO1 0x1005af10 STUB
@ -308,9 +314,10 @@ MxResult LegoOmni::Start(MxDSAction* action)
return result;
}
void LegoOmni::DeleteObject(MxDSAction &ds)
MxResult LegoOmni::DeleteObject(MxDSAction &ds)
{
// FIXME: Stub
return FAILURE;
}
MxBool LegoOmni::DoesEntityExist(MxDSAction &ds)

View File

@ -57,7 +57,7 @@ class LegoOmni : public MxOmni
virtual MxResult Create(COMPAT_CONST MxOmniCreateParam &p) override; // vtable+18
virtual void Destroy() override; // vtable+1c
virtual MxResult Start(MxDSAction* action) override;
virtual void DeleteObject(MxDSAction &ds) override;
virtual MxResult DeleteObject(MxDSAction &ds) override;
virtual MxBool DoesEntityExist(MxDSAction &ds) override;
virtual void vtable0x2c() override;
virtual int vtable0x30(char*, int, MxCore*) override;

View File

@ -1,6 +1,8 @@
#include "mxbackgroundaudiomanager.h"
#include "mxomni.h"
#include "mxstreamer.h"
#include "mxticklemanager.h"
DECOMP_SIZE_ASSERT(MxBackgroundAudioManager, 0x150)
@ -20,14 +22,31 @@ MxBackgroundAudioManager::MxBackgroundAudioManager()
// OFFSET: LEGO1 0x1007ec20
MxBackgroundAudioManager::~MxBackgroundAudioManager()
{
// TODO
TickleManager()->UnregisterClient(this);
NotificationManager()->Unregister(this);
DestroyMusic();
}
// OFFSET: LEGO1 0x1007f470
void MxBackgroundAudioManager::Stop()
{
// TODO
if (m_action2.GetObjectId() != -1)
{
DeleteObject(m_action2);
}
m_unk138 = 0;
m_action2.SetAtomId(MxAtomId());
m_action2.SetObjectId(-1);
if (m_action1.GetObjectId() != -1)
{
DeleteObject(m_action1);
}
m_unka0 = 0;
m_action1.SetAtomId(MxAtomId());
m_unk148 = 0;
m_action1.SetObjectId(-1);
m_unk13c = 0;
}
// OFFSET: LEGO1 0x1007f5f0
@ -47,3 +66,47 @@ void MxBackgroundAudioManager::Init()
this->m_unka0 = 0;
this->m_unk13c = 0;
}
// OFFSET: LEGO1 0x1007ece0
MxResult MxBackgroundAudioManager::Create(MxAtomId& script, MxU32 p_interval)
{
MxResult result = OpenMusic(script);
if (result == SUCCESS)
{
TickleManager()->RegisterClient(this, p_interval);
m_musicEnabled = TRUE;
}
return result;
}
// OFFSET: LEGO1 0x1007ed20
MxResult MxBackgroundAudioManager::OpenMusic(MxAtomId& script)
{
MxResult result = FAILURE;
if (m_unk14c.GetInternal() != NULL)
{
DestroyMusic();
}
if (Streamer()->Open(script.GetInternal(), 0) != NULL)
{
result = SUCCESS;
m_unk14c = script;
}
return result;
}
// OFFSET: LEGO1 0x1007ed70
void MxBackgroundAudioManager::DestroyMusic()
{
if (m_unk14c.GetInternal() != NULL)
{
MxDSAction ds;
ds.SetAtomId(m_unk14c);
ds.SetUnknown24(-2);
DeleteObject(ds);
Streamer()->Close(m_unk14c.GetInternal());
m_musicEnabled = FALSE;
}
}

View File

@ -28,10 +28,13 @@ class MxBackgroundAudioManager : public MxCore
}
__declspec(dllexport) void Enable(unsigned char p);
virtual MxResult Create(MxAtomId& script, MxU32 p_interval);
void Stop();
private:
void Init();
MxResult OpenMusic(MxAtomId& script);
void DestroyMusic();
MxBool m_musicEnabled; // 0x8
MxDSAction m_action1; // 0xc

View File

@ -68,9 +68,16 @@ MxResult MxOmni::Start(MxDSAction* p_dsAction)
}
// OFFSET: LEGO1 0x100b00c0 STUB
void MxOmni::DeleteObject(MxDSAction &p_dsAction)
MxResult MxOmni::DeleteObject(MxDSAction &p_dsAction)
{
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x100acf70
MxResult DeleteObject(MxDSAction &ds)
{
return MxOmni::GetInstance()->DeleteObject(ds);
}
// OFFSET: LEGO1 0x100b09a0
@ -231,7 +238,7 @@ MxResult MxOmni::Create(MxOmniCreateParam &p)
}
if (p.CreateFlags().CreateStreamer()) {
if (!(m_streamer = new MxStreamer()) || m_streamer->Create() != SUCCESS)
if (!(m_streamer = new MxStreamer()) || m_streamer->Create() != SUCCESS)
goto done;
}

View File

@ -42,7 +42,7 @@ class MxOmni : public MxCore
virtual MxResult Create(COMPAT_CONST MxOmniCreateParam &p); // vtable+18
virtual void Destroy(); // vtable+1c
virtual MxResult Start(MxDSAction* p_dsAction); // vtable+20
virtual void DeleteObject(MxDSAction &p_dsAction); // vtable+24
virtual MxResult DeleteObject(MxDSAction &p_dsAction); // vtable+24
virtual MxBool DoesEntityExist(MxDSAction &p_dsAction); // vtable+28
virtual void vtable0x2c(); // vtable+2c
virtual int vtable0x30(char*, int, MxCore*); // vtable+30
@ -94,6 +94,7 @@ __declspec(dllexport) MxVariableTable * VariableTable();
__declspec(dllexport) MxMusicManager * MusicManager();
__declspec(dllexport) MxEventManager * EventManager();
__declspec(dllexport) MxNotificationManager * NotificationManager();
MxResult DeleteObject(MxDSAction &ds);
MxVideoManager *MVideoManager();
MxAtomIdCounterSet *AtomIdCounterSet();