MxBackgroundAudioManager additional functions

This commit is contained in:
Misha 2023-11-04 17:11:03 -04:00
parent 22ac0b9296
commit 746749a3d2
No known key found for this signature in database
GPG Key ID: 8441D12AEF33FED8
7 changed files with 101 additions and 6 deletions

View File

@ -1,6 +1,10 @@
#include "mxbackgroundaudiomanager.h"
#include "legoomni.h"
#include "mxcompositepresenter.h"
#include "mxdssound.h"
#include "mxomni.h"
#include "mxpresenter.h"
#include "mxstreamer.h"
#include "mxticklemanager.h"
@ -47,6 +51,32 @@ void MxBackgroundAudioManager::Stop()
m_unk13c = 0;
}
// OFFSET: LEGO1 0x1007f570
void MxBackgroundAudioManager::FUN_1007f570()
{
if (m_unk148 == 0) {
if (m_unk13c == 0) {
m_unk13c = 2;
}
m_unk140 = 20;
}
m_unk148++;
}
// OFFSET: LEGO1 0x1007f5b0
void MxBackgroundAudioManager::FUN_1007f5b0()
{
if (m_unk148 != 0) {
m_unk148--;
if (m_unk148 == 0) {
if (m_unk13c == 0) {
m_unk13c = 2;
}
m_unk140 = 10;
}
}
}
// OFFSET: LEGO1 0x1007f5f0
void MxBackgroundAudioManager::Enable(MxBool p)
{
@ -106,3 +136,56 @@ void MxBackgroundAudioManager::DestroyMusic()
m_musicEnabled = FALSE;
}
}
// OFFSET: LEGO1 0x1007f170
MxResult MxBackgroundAudioManager::Notify(MxParam& p)
{
if (((MxNotificationParam&) p).GetNotification() == c_notificationStartAction) {
StartAction(p);
return 1;
}
if (((MxNotificationParam&) p).GetNotification() != c_notificationEndAction) {
return 0;
}
StopAction(p);
return 1;
}
// Matches but register allocation is is different.
// OFFSET: LEGO1 0x1007f1b0
void MxBackgroundAudioManager::StartAction(MxParam& p)
{
// TODO: the sender is most likely a MxCompositePresenter?
m_unk138 = (MxCompositePresenter*) ((MxNotificationParam&) p).GetSender();
m_action2.SetAtomId(m_unk138->GetAction()->GetAtomId());
m_action2.SetObjectId(m_unk138->GetAction()->GetObjectId());
m_unk144 = ((MxDSSound*)(m_unk138->GetAction()))->GetVolume();
m_unk138->VTable0x60(0);
}
// OFFSET: LEGO1 0x1007f200
void MxBackgroundAudioManager::StopAction(MxParam& p)
{
if (((MxNotificationParam&) p).GetSender() == m_unka0) {
m_unka0 = NULL;
m_action1.SetAtomId(MxAtomId());
m_action1.SetObjectId(-1);
}
else {
if (((MxNotificationParam&) p).GetSender() == m_unk138) {
m_unk138 = NULL;
m_action2.SetAtomId(MxAtomId());
m_action2.SetObjectId(-1);
}
}
Lego()->HandleNotificationType2(p);
}
// OFFSET: LEGO1 0x1007ee40 STUB
MxResult MxBackgroundAudioManager::Tickle()
{
// TODO
return FAILURE;
}

View File

@ -1,9 +1,11 @@
#ifndef MXBACKGROUNDAUDIOMANAGER_H
#define MXBACKGROUNDAUDIOMANAGER_H
#include "mxcompositepresenter.h"
#include "mxcore.h"
#include "mxdsaction.h"
#include "mxnotificationmanager.h"
#include "mxpresenter.h"
#include "mxtypes.h"
// VTABLE 0x100d9fe8
@ -26,10 +28,18 @@ class MxBackgroundAudioManager : public MxCore {
return !strcmp(name, MxBackgroundAudioManager::ClassName()) || MxCore::IsA(name);
}
virtual MxResult Notify(MxParam& p) override;
void StartAction(MxParam& p);
void StopAction(MxParam& p);
virtual MxResult Tickle() override;
__declspec(dllexport) void Enable(unsigned char p);
virtual MxResult Create(MxAtomId& p_script, MxU32 p_frequencyMS);
void Stop();
void FUN_1007f570();
void FUN_1007f5b0();
private:
void Init();
@ -38,9 +48,9 @@ class MxBackgroundAudioManager : public MxCore {
MxBool m_musicEnabled; // 0x8
MxDSAction m_action1; // 0xc
MxS32 m_unka0;
MxCore* m_unka0;
MxDSAction m_action2; // 0xa4
MxS32 m_unk138;
MxCompositePresenter* m_unk138;
MxS32 m_unk13c;
MxS32 m_unk140;
MxS32 m_unk144;

View File

@ -30,7 +30,7 @@ void MxCompositePresenter::VTable0x5c()
}
// OFFSET: LEGO1 0x100b6b40 STUB
void MxCompositePresenter::VTable0x60()
void MxCompositePresenter::VTable0x60(undefined4 p_unknown)
{
// TODO
}

View File

@ -26,7 +26,7 @@ class MxCompositePresenter : public MxPresenter {
virtual void VTable0x58();
virtual void VTable0x5c();
virtual void VTable0x60();
virtual void VTable0x60(undefined4 p_unknown);
virtual void VTable0x64();
private:

View File

@ -30,6 +30,8 @@ class MxDSSound : public MxDSMediaAction {
virtual void Deserialize(char** p_source, MxS16 p_unk24) override; // vtable+1c;
virtual MxDSAction* Clone() override; // vtable+2c;
virtual inline MxS32 GetVolume() const { return m_volume; }
private:
MxU32 m_sizeOnDisk;
MxS32 m_volume; // 0xbc

View File

@ -9,7 +9,7 @@ class MxCore;
enum MxParamType {
PARAM_NONE = 0,
PAINT = 1, // 100dc210:100d8350
c_notificationStartAction = 1, // 100dc210:100d8350
c_notificationEndAction = 2, // 100d8358:100d8350
TYPE4 = 4, // 100dc208:100d8350
MXPRESENTER_NOTIFICATION = 5,

View File

@ -41,7 +41,7 @@ MxLong Score::Notify(MxParam& p)
LegoWorld::Notify(p);
if (m_unkf6) {
switch (((MxNotificationParam&) p).GetNotification()) {
case PAINT:
case c_notificationStartAction:
ret = 1;
Paint();
break;