mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-22 11:31:57 -04:00
Clear unknowns in MxBackgroundAudioManager
(#1516)
* Clear unknowns in `MxBackgroundAudioManager` * Apply suggestions from code review --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
parent
4e49712391
commit
90b5c27a8b
@ -37,11 +37,11 @@ public:
|
|||||||
|
|
||||||
void StartAction(MxParam& p_param);
|
void StartAction(MxParam& p_param);
|
||||||
void StopAction(MxParam& p_param);
|
void StopAction(MxParam& p_param);
|
||||||
MxResult PlayMusic(MxDSAction& p_action, undefined4 p_speed, MxPresenter::TickleState p_tickleState);
|
MxResult PlayMusic(MxDSAction& p_action, MxS32 p_speed, MxPresenter::TickleState p_tickleState);
|
||||||
|
|
||||||
void FUN_1007ee70();
|
void MakePendingPresenterActive();
|
||||||
void FUN_1007ef40();
|
void FadeInPendingPresenter();
|
||||||
void FadeInOrFadeOut();
|
void FadeToTargetVolume();
|
||||||
|
|
||||||
void Enable(MxBool p_enable);
|
void Enable(MxBool p_enable);
|
||||||
virtual MxResult Create(MxAtomId& p_script, MxU32 p_frequencyMS);
|
virtual MxResult Create(MxAtomId& p_script, MxU32 p_frequencyMS);
|
||||||
@ -50,7 +50,7 @@ public:
|
|||||||
void Stop();
|
void Stop();
|
||||||
void LowerVolume();
|
void LowerVolume();
|
||||||
void RaiseVolume();
|
void RaiseVolume();
|
||||||
undefined4 FUN_1007f610(MxPresenter* p_unk0x138, MxS32 p_speed, MxPresenter::TickleState p_tickleState);
|
MxResult SetPendingPresenter(MxPresenter* p_presenter, MxS32 p_speed, MxPresenter::TickleState p_tickleState);
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x1007ec00
|
// SYNTHETIC: LEGO1 0x1007ec00
|
||||||
// MxBackgroundAudioManager::`scalar deleting destructor'
|
// MxBackgroundAudioManager::`scalar deleting destructor'
|
||||||
@ -59,11 +59,11 @@ private:
|
|||||||
MxResult OpenMusic(MxAtomId& p_script);
|
MxResult OpenMusic(MxAtomId& p_script);
|
||||||
void DestroyMusic();
|
void DestroyMusic();
|
||||||
|
|
||||||
MxBool m_enabled; // 0x08
|
MxBool m_enabled; // 0x08
|
||||||
MxDSAction m_action1; // 0x0c
|
MxDSAction m_action1; // 0x0c
|
||||||
MxAudioPresenter* m_unk0xa0; // 0xa0
|
MxAudioPresenter* m_activePresenter; // 0xa0
|
||||||
MxDSAction m_action2; // 0xa4
|
MxDSAction m_action2; // 0xa4
|
||||||
MxAudioPresenter* m_unk0x138; // 0x138
|
MxAudioPresenter* m_pendingPresenter; // 0x138
|
||||||
|
|
||||||
// name is inferred from context
|
// name is inferred from context
|
||||||
MxPresenter::TickleState m_tickleState; // 0x13c
|
MxPresenter::TickleState m_tickleState; // 0x13c
|
||||||
@ -71,9 +71,9 @@ private:
|
|||||||
// name inferred from parameter p_speed
|
// name inferred from parameter p_speed
|
||||||
MxS32 m_speed; // 0x140
|
MxS32 m_speed; // 0x140
|
||||||
|
|
||||||
MxS32 m_targetVolume; // 0x144
|
MxS32 m_targetVolume; // 0x144
|
||||||
MxS16 m_unk0x148; // 0x148
|
MxS16 m_volumeSuppressionAmount; // 0x148
|
||||||
MxAtomId m_script; // 0x14c
|
MxAtomId m_script; // 0x14c
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MXBACKGROUNDAUDIOMANAGER_H
|
#endif // MXBACKGROUNDAUDIOMANAGER_H
|
||||||
|
@ -18,12 +18,12 @@ DECOMP_SIZE_ASSERT(MxBackgroundAudioManager, 0x150)
|
|||||||
MxBackgroundAudioManager::MxBackgroundAudioManager()
|
MxBackgroundAudioManager::MxBackgroundAudioManager()
|
||||||
{
|
{
|
||||||
NotificationManager()->Register(this);
|
NotificationManager()->Register(this);
|
||||||
m_unk0xa0 = 0;
|
m_activePresenter = NULL;
|
||||||
m_unk0x138 = 0;
|
m_pendingPresenter = NULL;
|
||||||
m_tickleState = MxPresenter::e_idle;
|
m_tickleState = MxPresenter::e_idle;
|
||||||
m_speed = 0;
|
m_speed = 0;
|
||||||
m_targetVolume = 0;
|
m_targetVolume = 0;
|
||||||
m_unk0x148 = 0;
|
m_volumeSuppressionAmount = 0;
|
||||||
m_enabled = FALSE;
|
m_enabled = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,29 +83,29 @@ MxResult MxBackgroundAudioManager::Tickle()
|
|||||||
{
|
{
|
||||||
switch (m_tickleState) {
|
switch (m_tickleState) {
|
||||||
case MxPresenter::e_starting:
|
case MxPresenter::e_starting:
|
||||||
FadeInOrFadeOut();
|
FadeToTargetVolume();
|
||||||
break;
|
break;
|
||||||
case MxPresenter::e_streaming:
|
case MxPresenter::e_streaming:
|
||||||
FUN_1007ee70();
|
MakePendingPresenterActive();
|
||||||
break;
|
break;
|
||||||
case MxPresenter::e_repeating:
|
case MxPresenter::e_repeating:
|
||||||
FUN_1007ef40();
|
FadeInPendingPresenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1007ee70
|
// FUNCTION: LEGO1 0x1007ee70
|
||||||
void MxBackgroundAudioManager::FUN_1007ee70()
|
void MxBackgroundAudioManager::MakePendingPresenterActive()
|
||||||
{
|
{
|
||||||
if (m_unk0xa0 && m_unk0xa0->GetAction()) {
|
if (m_activePresenter && m_activePresenter->GetAction()) {
|
||||||
DeleteObject(*m_unk0x138->GetAction());
|
DeleteObject(*m_pendingPresenter->GetAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_unk0x138) {
|
if (m_pendingPresenter) {
|
||||||
m_unk0xa0 = m_unk0x138;
|
m_activePresenter = m_pendingPresenter;
|
||||||
m_action1 = m_action2;
|
m_action1 = m_action2;
|
||||||
m_unk0x138 = NULL;
|
m_pendingPresenter = NULL;
|
||||||
m_action2.SetObjectId(-1);
|
m_action2.SetObjectId(-1);
|
||||||
m_action2.SetAtomId(MxAtomId());
|
m_action2.SetAtomId(MxAtomId());
|
||||||
m_tickleState = MxPresenter::e_idle;
|
m_tickleState = MxPresenter::e_idle;
|
||||||
@ -113,65 +113,65 @@ void MxBackgroundAudioManager::FUN_1007ee70()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1007ef40
|
// FUNCTION: LEGO1 0x1007ef40
|
||||||
void MxBackgroundAudioManager::FUN_1007ef40()
|
void MxBackgroundAudioManager::FadeInPendingPresenter()
|
||||||
{
|
{
|
||||||
MxS32 compare, volume;
|
MxS32 compare, volume;
|
||||||
|
|
||||||
if (m_unk0xa0 == NULL) {
|
if (m_activePresenter == NULL) {
|
||||||
if (m_unk0x138) {
|
if (m_pendingPresenter) {
|
||||||
if (m_unk0x148 != 0) {
|
if (m_volumeSuppressionAmount != 0) {
|
||||||
compare = 30;
|
compare = 30;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
compare = m_targetVolume;
|
compare = m_targetVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
volume = m_unk0x138->GetVolume();
|
volume = m_pendingPresenter->GetVolume();
|
||||||
if (volume < compare) {
|
if (volume < compare) {
|
||||||
if (m_speed + m_unk0x138->GetVolume() <= compare) {
|
if (m_speed + m_pendingPresenter->GetVolume() <= compare) {
|
||||||
compare = m_speed + m_unk0x138->GetVolume();
|
compare = m_speed + m_pendingPresenter->GetVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unk0x138->SetVolume(compare);
|
m_pendingPresenter->SetVolume(compare);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_unk0x138->SetVolume(compare);
|
m_pendingPresenter->SetVolume(compare);
|
||||||
m_unk0xa0 = m_unk0x138;
|
m_activePresenter = m_pendingPresenter;
|
||||||
m_action1 = m_action2;
|
m_action1 = m_action2;
|
||||||
m_unk0x138 = NULL;
|
m_pendingPresenter = NULL;
|
||||||
m_action2.SetObjectId(-1);
|
m_action2.SetObjectId(-1);
|
||||||
m_action2.SetAtomId(MxAtomId());
|
m_action2.SetAtomId(MxAtomId());
|
||||||
m_tickleState = MxPresenter::e_idle;
|
m_tickleState = MxPresenter::e_idle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_unk0xa0->GetAction() != NULL) {
|
else if (m_activePresenter->GetAction() != NULL) {
|
||||||
if (m_unk0xa0->GetVolume() == 0) {
|
if (m_activePresenter->GetVolume() == 0) {
|
||||||
DeleteObject(*m_unk0xa0->GetAction());
|
DeleteObject(*m_activePresenter->GetAction());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m_unk0xa0->GetVolume() - m_speed > 0) {
|
if (m_activePresenter->GetVolume() - m_speed > 0) {
|
||||||
volume = m_unk0xa0->GetVolume() - m_speed;
|
volume = m_activePresenter->GetVolume() - m_speed;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
volume = 0;
|
volume = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unk0xa0->SetVolume(volume);
|
m_activePresenter->SetVolume(volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1007f0e0
|
// FUNCTION: LEGO1 0x1007f0e0
|
||||||
// FUNCTION: BETA10 0x100e8d8d
|
// FUNCTION: BETA10 0x100e8d8d
|
||||||
void MxBackgroundAudioManager::FadeInOrFadeOut()
|
void MxBackgroundAudioManager::FadeToTargetVolume()
|
||||||
{
|
{
|
||||||
MxS32 volume, compare;
|
MxS32 volume, compare;
|
||||||
|
|
||||||
if (m_unk0xa0 != NULL) {
|
if (m_activePresenter != NULL) {
|
||||||
volume = m_unk0xa0->GetVolume();
|
volume = m_activePresenter->GetVolume();
|
||||||
|
|
||||||
if (m_unk0x148 != 0) {
|
if (m_volumeSuppressionAmount != 0) {
|
||||||
compare = 30;
|
compare = 30;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -179,13 +179,13 @@ void MxBackgroundAudioManager::FadeInOrFadeOut()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (volume < compare) {
|
if (volume < compare) {
|
||||||
m_unk0xa0->SetVolume(volume + m_speed < compare ? volume + m_speed : compare);
|
m_activePresenter->SetVolume(volume + m_speed < compare ? volume + m_speed : compare);
|
||||||
}
|
}
|
||||||
else if (compare < volume) {
|
else if (compare < volume) {
|
||||||
m_unk0xa0->SetVolume(volume - m_speed > compare ? volume - m_speed : compare);
|
m_activePresenter->SetVolume(volume - m_speed > compare ? volume - m_speed : compare);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_unk0xa0->SetVolume(volume);
|
m_activePresenter->SetVolume(volume);
|
||||||
m_tickleState = MxPresenter::e_idle;
|
m_tickleState = MxPresenter::e_idle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,23 +215,23 @@ MxLong MxBackgroundAudioManager::Notify(MxParam& p_param)
|
|||||||
void MxBackgroundAudioManager::StartAction(MxParam& p_param)
|
void MxBackgroundAudioManager::StartAction(MxParam& p_param)
|
||||||
{
|
{
|
||||||
// TODO: the sender is most likely a MxAudioPresenter?
|
// TODO: the sender is most likely a MxAudioPresenter?
|
||||||
m_unk0x138 = (MxAudioPresenter*) ((MxNotificationParam&) p_param).GetSender();
|
m_pendingPresenter = (MxAudioPresenter*) ((MxNotificationParam&) p_param).GetSender();
|
||||||
m_action2.SetAtomId(m_unk0x138->GetAction()->GetAtomId());
|
m_action2.SetAtomId(m_pendingPresenter->GetAction()->GetAtomId());
|
||||||
m_action2.SetObjectId(m_unk0x138->GetAction()->GetObjectId());
|
m_action2.SetObjectId(m_pendingPresenter->GetAction()->GetObjectId());
|
||||||
m_targetVolume = ((MxDSSound*) (m_unk0x138->GetAction()))->GetVolume();
|
m_targetVolume = ((MxDSSound*) (m_pendingPresenter->GetAction()))->GetVolume();
|
||||||
m_unk0x138->SetVolume(0);
|
m_pendingPresenter->SetVolume(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1007f200
|
// FUNCTION: LEGO1 0x1007f200
|
||||||
void MxBackgroundAudioManager::StopAction(MxParam& p_param)
|
void MxBackgroundAudioManager::StopAction(MxParam& p_param)
|
||||||
{
|
{
|
||||||
if (((MxNotificationParam&) p_param).GetSender() == m_unk0xa0) {
|
if (((MxNotificationParam&) p_param).GetSender() == m_activePresenter) {
|
||||||
m_unk0xa0 = NULL;
|
m_activePresenter = NULL;
|
||||||
m_action1.SetAtomId(MxAtomId());
|
m_action1.SetAtomId(MxAtomId());
|
||||||
m_action1.SetObjectId(-1);
|
m_action1.SetObjectId(-1);
|
||||||
}
|
}
|
||||||
else if (((MxNotificationParam&) p_param).GetSender() == m_unk0x138) {
|
else if (((MxNotificationParam&) p_param).GetSender() == m_pendingPresenter) {
|
||||||
m_unk0x138 = NULL;
|
m_pendingPresenter = NULL;
|
||||||
m_action2.SetAtomId(MxAtomId());
|
m_action2.SetAtomId(MxAtomId());
|
||||||
m_action2.SetObjectId(-1);
|
m_action2.SetObjectId(-1);
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ void MxBackgroundAudioManager::StopAction(MxParam& p_param)
|
|||||||
// FUNCTION: BETA10 0x100e90fc
|
// FUNCTION: BETA10 0x100e90fc
|
||||||
MxResult MxBackgroundAudioManager::PlayMusic(
|
MxResult MxBackgroundAudioManager::PlayMusic(
|
||||||
MxDSAction& p_action,
|
MxDSAction& p_action,
|
||||||
undefined4 p_speed,
|
MxS32 p_speed,
|
||||||
MxPresenter::TickleState p_tickleState
|
MxPresenter::TickleState p_tickleState
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -289,7 +289,7 @@ void MxBackgroundAudioManager::Stop()
|
|||||||
DeleteObject(m_action2);
|
DeleteObject(m_action2);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unk0x138 = 0;
|
m_pendingPresenter = NULL;
|
||||||
m_action2.SetAtomId(MxAtomId());
|
m_action2.SetAtomId(MxAtomId());
|
||||||
m_action2.SetObjectId(-1);
|
m_action2.SetObjectId(-1);
|
||||||
|
|
||||||
@ -297,9 +297,9 @@ void MxBackgroundAudioManager::Stop()
|
|||||||
DeleteObject(m_action1);
|
DeleteObject(m_action1);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unk0xa0 = 0;
|
m_activePresenter = NULL;
|
||||||
m_action1.SetAtomId(MxAtomId());
|
m_action1.SetAtomId(MxAtomId());
|
||||||
m_unk0x148 = 0;
|
m_volumeSuppressionAmount = 0;
|
||||||
m_action1.SetObjectId(-1);
|
m_action1.SetObjectId(-1);
|
||||||
m_tickleState = MxPresenter::e_idle;
|
m_tickleState = MxPresenter::e_idle;
|
||||||
}
|
}
|
||||||
@ -308,22 +308,22 @@ void MxBackgroundAudioManager::Stop()
|
|||||||
// FUNCTION: BETA10 0x100e94e6
|
// FUNCTION: BETA10 0x100e94e6
|
||||||
void MxBackgroundAudioManager::LowerVolume()
|
void MxBackgroundAudioManager::LowerVolume()
|
||||||
{
|
{
|
||||||
if (m_unk0x148 == 0) {
|
if (m_volumeSuppressionAmount == 0) {
|
||||||
if (m_tickleState == 0) {
|
if (m_tickleState == 0) {
|
||||||
m_tickleState = MxPresenter::e_starting;
|
m_tickleState = MxPresenter::e_starting;
|
||||||
}
|
}
|
||||||
m_speed = 20;
|
m_speed = 20;
|
||||||
}
|
}
|
||||||
m_unk0x148++;
|
m_volumeSuppressionAmount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1007f5b0
|
// FUNCTION: LEGO1 0x1007f5b0
|
||||||
// FUNCTION: BETA10 0x100e9543
|
// FUNCTION: BETA10 0x100e9543
|
||||||
void MxBackgroundAudioManager::RaiseVolume()
|
void MxBackgroundAudioManager::RaiseVolume()
|
||||||
{
|
{
|
||||||
if (m_unk0x148 != 0) {
|
if (m_volumeSuppressionAmount != 0) {
|
||||||
m_unk0x148--;
|
m_volumeSuppressionAmount--;
|
||||||
if (m_unk0x148 == 0) {
|
if (m_volumeSuppressionAmount == 0) {
|
||||||
if (m_tickleState == 0) {
|
if (m_tickleState == 0) {
|
||||||
m_tickleState = MxPresenter::e_starting;
|
m_tickleState = MxPresenter::e_starting;
|
||||||
}
|
}
|
||||||
@ -346,27 +346,27 @@ void MxBackgroundAudioManager::Enable(MxBool p_enable)
|
|||||||
|
|
||||||
// FUNCTION: LEGO1 0x1007f610
|
// FUNCTION: LEGO1 0x1007f610
|
||||||
// FUNCTION: BETA10 0x100e95ee
|
// FUNCTION: BETA10 0x100e95ee
|
||||||
undefined4 MxBackgroundAudioManager::FUN_1007f610(
|
MxResult MxBackgroundAudioManager::SetPendingPresenter(
|
||||||
MxPresenter* p_unk0x138,
|
MxPresenter* p_presenter,
|
||||||
MxS32 p_speed,
|
MxS32 p_speed,
|
||||||
MxPresenter::TickleState p_tickleState
|
MxPresenter::TickleState p_tickleState
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
m_unk0x138 = (MxAudioPresenter*) p_unk0x138;
|
m_pendingPresenter = (MxAudioPresenter*) p_presenter;
|
||||||
m_targetVolume = ((MxDSSound*) m_unk0x138->GetAction())->GetVolume();
|
m_targetVolume = ((MxDSSound*) m_pendingPresenter->GetAction())->GetVolume();
|
||||||
|
|
||||||
((MxCompositePresenter*) m_unk0x138)->VTable0x60(NULL);
|
((MxCompositePresenter*) m_pendingPresenter)->VTable0x60(NULL);
|
||||||
|
|
||||||
m_speed = p_speed;
|
m_speed = p_speed;
|
||||||
m_tickleState = p_tickleState;
|
m_tickleState = p_tickleState;
|
||||||
return 0;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1007f650
|
// FUNCTION: LEGO1 0x1007f650
|
||||||
// FUNCTION: BETA10 0x100e9663
|
// FUNCTION: BETA10 0x100e9663
|
||||||
void MxBackgroundAudioManager::Init()
|
void MxBackgroundAudioManager::Init()
|
||||||
{
|
{
|
||||||
this->m_unk0xa0 = 0;
|
this->m_activePresenter = NULL;
|
||||||
this->m_tickleState = MxPresenter::e_idle;
|
this->m_tickleState = MxPresenter::e_idle;
|
||||||
}
|
}
|
||||||
|
@ -1231,7 +1231,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param)
|
|||||||
m_unk0x338 = SoundManager()->FUN_100aebd0(*g_jukeboxScript, jukeboxScript);
|
m_unk0x338 = SoundManager()->FUN_100aebd0(*g_jukeboxScript, jukeboxScript);
|
||||||
|
|
||||||
if (m_unk0x338) {
|
if (m_unk0x338) {
|
||||||
BackgroundAudioManager()->FUN_1007f610(m_unk0x338, 5, MxPresenter::e_repeating);
|
BackgroundAudioManager()->SetPendingPresenter(m_unk0x338, 5, MxPresenter::e_repeating);
|
||||||
FUN_10024ef0();
|
FUN_10024ef0();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user