Prepare MxMidiPresenter vtable and refactoring (#278)

This commit is contained in:
Christian Semmler 2023-11-14 15:10:43 -05:00 committed by GitHub
parent e86d6f0cc7
commit c626f18b03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 91 additions and 37 deletions

View file

@ -5,13 +5,13 @@
DECOMP_SIZE_ASSERT(MxAudioPresenter, 0x54); DECOMP_SIZE_ASSERT(MxAudioPresenter, 0x54);
// OFFSET: LEGO1 0x1000d260 // OFFSET: LEGO1 0x1000d260
undefined4 MxAudioPresenter::vtable5c() MxU32 MxAudioPresenter::GetVolume()
{ {
return this->m_unk50; return m_volume;
} }
// OFFSET: LEGO1 0x1000d270 // OFFSET: LEGO1 0x1000d270
void MxAudioPresenter::vtable60(undefined4 p_unk50) void MxAudioPresenter::SetVolume(MxU32 p_volume)
{ {
this->m_unk50 = p_unk50; m_volume = p_volume;
} }

View file

@ -5,9 +5,10 @@
#include "mxmediapresenter.h" #include "mxmediapresenter.h"
// VTABLE 0x100d4c70 // VTABLE 0x100d4c70
// SIZE 0x54
class MxAudioPresenter : public MxMediaPresenter { class MxAudioPresenter : public MxMediaPresenter {
public: public:
MxAudioPresenter() { m_unk50 = 100; } MxAudioPresenter() { m_volume = 100; }
// OFFSET: LEGO1 0x1000d280 // OFFSET: LEGO1 0x1000d280
inline virtual const char* ClassName() const override // vtable+0x0c inline virtual const char* ClassName() const override // vtable+0x0c
@ -22,10 +23,11 @@ class MxAudioPresenter : public MxMediaPresenter {
return !strcmp(name, MxAudioPresenter::ClassName()) || MxMediaPresenter::IsA(name); return !strcmp(name, MxAudioPresenter::ClassName()) || MxMediaPresenter::IsA(name);
} }
virtual undefined4 vtable5c(); virtual MxU32 GetVolume(); // vtable+0x5c
virtual void vtable60(undefined4); virtual void SetVolume(MxU32 p_volume); // vtable+0x60
undefined4 m_unk50; private:
MxU32 m_volume;
}; };
#endif // MXAUDIOPRESENTER_H #endif // MXAUDIOPRESENTER_H

View file

@ -159,7 +159,7 @@ void MxBackgroundAudioManager::StartAction(MxParam& p)
m_action2.SetAtomId(m_unk138->GetAction()->GetAtomId()); m_action2.SetAtomId(m_unk138->GetAction()->GetAtomId());
m_action2.SetObjectId(m_unk138->GetAction()->GetObjectId()); m_action2.SetObjectId(m_unk138->GetAction()->GetObjectId());
m_targetVolume = ((MxDSSound*) (m_unk138->GetAction()))->GetVolume(); m_targetVolume = ((MxDSSound*) (m_unk138->GetAction()))->GetVolume();
m_unk138->vtable60(0); m_unk138->SetVolume(0);
} }
// OFFSET: LEGO1 0x1007f200 // OFFSET: LEGO1 0x1007f200
@ -257,15 +257,15 @@ void MxBackgroundAudioManager::FUN_1007ef40()
if (m_unk148 == 0) { if (m_unk148 == 0) {
compare = m_unk148; compare = m_unk148;
} }
volume = m_unk138->vtable5c(); volume = m_unk138->GetVolume();
if (volume < compare) { if (volume < compare) {
if (m_unk140 + m_unk138->vtable5c() <= compare) { if (m_unk140 + m_unk138->GetVolume() <= compare) {
compare = m_unk140 + compare; compare = m_unk140 + compare;
} }
m_unk138->vtable60(compare); m_unk138->SetVolume(compare);
} }
else { else {
m_unk138->vtable60(compare); m_unk138->SetVolume(compare);
m_unka0 = m_unk138; m_unka0 = m_unk138;
m_action1 = m_action2; m_action1 = m_action2;
m_unk138 = NULL; m_unk138 = NULL;
@ -276,16 +276,16 @@ void MxBackgroundAudioManager::FUN_1007ef40()
} }
} }
else if (m_unka0->GetAction() != NULL) { else if (m_unka0->GetAction() != NULL) {
if (m_unka0->vtable5c() == 0) { if (m_unka0->GetVolume() == 0) {
DeleteObject(*m_unka0->GetAction()); DeleteObject(*m_unka0->GetAction());
} }
else { else {
compare = m_unka0->vtable5c(); compare = m_unka0->GetVolume();
volume = 0; volume = 0;
if (compare != m_unk140 && -1 < compare - m_unk140) { if (compare != m_unk140 && -1 < compare - m_unk140) {
volume = m_unka0->vtable5c() - m_unk140; volume = m_unka0->GetVolume() - m_unk140;
} }
m_unk138->vtable60(volume); m_unk138->SetVolume(volume);
} }
} }
} }
@ -295,7 +295,7 @@ void MxBackgroundAudioManager::FadeInOrFadeOut()
{ {
// This function probably is the fade in/out routine // This function probably is the fade in/out routine
if (m_unka0 != NULL) { if (m_unka0 != NULL) {
undefined4 volume = m_unka0->vtable5c(); undefined4 volume = m_unka0->GetVolume();
MxU32 compare = 30; MxU32 compare = 30;
if (m_unk148 == 0) { if (m_unk148 == 0) {
compare = m_targetVolume; compare = m_targetVolume;
@ -306,17 +306,17 @@ void MxBackgroundAudioManager::FadeInOrFadeOut()
if (compare <= volume) { if (compare <= volume) {
volume = compare; volume = compare;
} }
m_unka0->vtable60(volume); m_unka0->SetVolume(volume);
} }
else if (compare < volume) { else if (compare < volume) {
volume = volume - m_unk140; volume = volume - m_unk140;
if (volume <= compare) { if (volume <= compare) {
volume = compare; volume = compare;
} }
m_unka0->vtable60(volume); m_unka0->SetVolume(volume);
} }
else { else {
m_unka0->vtable60(volume); m_unka0->SetVolume(volume);
m_unk13c = 0; m_unk13c = 0;
} }
} }

View file

@ -6,6 +6,13 @@
DECOMP_SIZE_ASSERT(MxMIDIPresenter, 0x58); DECOMP_SIZE_ASSERT(MxMIDIPresenter, 0x58);
// OFFSET: LEGO1 0x100c25a0 STUB
MxResult MxMIDIPresenter::AddToManager()
{
// TODO
return SUCCESS;
}
// OFFSET: LEGO1 0x100c25e0 // OFFSET: LEGO1 0x100c25e0
MxMIDIPresenter::MxMIDIPresenter() MxMIDIPresenter::MxMIDIPresenter()
{ {
@ -30,10 +37,46 @@ void MxMIDIPresenter::Destroy(MxBool p_fromDestructor)
// TODO // TODO
} }
// OFFSET: LEGO1 0x100c2890 STUB
void MxMIDIPresenter::ReadyTickle()
{
// TODO
}
// OFFSET: LEGO1 0x100c28d0 STUB
void MxMIDIPresenter::StartingTickle()
{
// TODO
}
// OFFSET: LEGO1 0x100c2910 STUB
void MxMIDIPresenter::StreamingTickle()
{
// TODO
}
// OFFSET: LEGO1 0x100c2940 // OFFSET: LEGO1 0x100c2940
void MxMIDIPresenter::DoneTickle() void MxMIDIPresenter::DoneTickle()
{ {
if (!MusicManager()->GetMIDIInitialized()) { if (!MusicManager()->GetMIDIInitialized())
this->EndAction(); EndAction();
} }
// OFFSET: LEGO1 0x100c2960 STUB
void MxMIDIPresenter::Destroy()
{
// TODO
}
// OFFSET: LEGO1 0x100c2970 STUB
undefined4 MxMIDIPresenter::PutData()
{
// TODO
return 0;
}
// OFFSET: LEGO1 0x100c29e0 STUB
void MxMIDIPresenter::EndAction()
{
// TODO
} }

View file

@ -4,6 +4,7 @@
#include "mxmusicpresenter.h" #include "mxmusicpresenter.h"
// VTABLE 0x100dca20 // VTABLE 0x100dca20
// SIZE 0x58
class MxMIDIPresenter : public MxMusicPresenter { class MxMIDIPresenter : public MxMusicPresenter {
public: public:
MxMIDIPresenter(); MxMIDIPresenter();
@ -22,11 +23,18 @@ class MxMIDIPresenter : public MxMusicPresenter {
return !strcmp(name, MxMIDIPresenter::ClassName()) || MxMusicPresenter::IsA(name); return !strcmp(name, MxMIDIPresenter::ClassName()) || MxMusicPresenter::IsA(name);
} }
virtual void ReadyTickle() override; // vtable+0x18
virtual void StartingTickle() override; // vtable+0x1c
virtual void StreamingTickle() override; // vtable+0x20
virtual void DoneTickle() override; // vtable+0x2c virtual void DoneTickle() override; // vtable+0x2c
virtual MxResult AddToManager() override; // vtable+0x34
virtual void Destroy() override; // vtable+0x38
virtual void EndAction() override; // vtable+0x40
virtual undefined4 PutData() override; // vtable+0x4c
private: private:
void Init(); void Init();
void Destroy(MxBool); void Destroy(MxBool p_fromDestructor);
undefined4 m_unk54; undefined4 m_unk54;
}; };

View file

@ -7,6 +7,9 @@
// SIZE 0x54 // SIZE 0x54
class MxMusicPresenter : public MxAudioPresenter { class MxMusicPresenter : public MxAudioPresenter {
public: public:
MxMusicPresenter();
virtual ~MxMusicPresenter() override;
// OFFSET: LEGO1 0x100c23a0 // OFFSET: LEGO1 0x100c23a0
inline virtual const char* ClassName() const override // vtable+0xc inline virtual const char* ClassName() const override // vtable+0xc
{ {
@ -20,9 +23,6 @@ class MxMusicPresenter : public MxAudioPresenter {
return !strcmp(name, MxMusicPresenter::ClassName()) || MxAudioPresenter::IsA(name); return !strcmp(name, MxMusicPresenter::ClassName()) || MxAudioPresenter::IsA(name);
} }
MxMusicPresenter();
virtual ~MxMusicPresenter() override;
virtual MxResult AddToManager() override; // vtable+0x34 virtual MxResult AddToManager() override; // vtable+0x34
virtual void Destroy() override; // vtable+0x38 virtual void Destroy() override; // vtable+0x38

View file

@ -145,7 +145,7 @@ void MxSoundManager::SetVolume(MxS32 p_volume)
MxPresenterListCursor cursor(m_presenters); MxPresenterListCursor cursor(m_presenters);
while (cursor.Next(presenter)) while (cursor.Next(presenter))
((MxAudioPresenter*) presenter)->vtable60(((MxAudioPresenter*) presenter)->vtable5c()); ((MxAudioPresenter*) presenter)->SetVolume(((MxAudioPresenter*) presenter)->GetVolume());
m_criticalSection.Leave(); m_criticalSection.Leave();
} }

View file

@ -11,6 +11,12 @@ MxSoundPresenter::~MxSoundPresenter()
Destroy(TRUE); Destroy(TRUE);
} }
// OFFSET: LEGO1 0x1000d490
void MxSoundPresenter::Destroy()
{
Destroy(FALSE);
}
// OFFSET: LEGO1 0x100b1a50 // OFFSET: LEGO1 0x100b1a50
void MxSoundPresenter::Destroy(MxBool p_fromDestructor) void MxSoundPresenter::Destroy(MxBool p_fromDestructor)
{ {
@ -37,9 +43,3 @@ MxResult MxSoundPresenter::AddToManager()
return ret; return ret;
} }
// OFFSET: LEGO1 0x1000d490
void MxSoundPresenter::Destroy()
{
Destroy(FALSE);
}

View file

@ -5,6 +5,7 @@
#include "mxomni.h" #include "mxomni.h"
// VTABLE 0x100d4b08 // VTABLE 0x100d4b08
// SIZE 0x54
class MxSoundPresenter : public MxAudioPresenter { class MxSoundPresenter : public MxAudioPresenter {
public: public:
virtual ~MxSoundPresenter() override; virtual ~MxSoundPresenter() override;
@ -26,7 +27,7 @@ class MxSoundPresenter : public MxAudioPresenter {
virtual void Destroy() override; // vtable+0x38 virtual void Destroy() override; // vtable+0x38
private: private:
void Destroy(MxBool); void Destroy(MxBool p_fromDestructor);
}; };
#endif // MXSOUNDPRESENTER_H #endif // MXSOUNDPRESENTER_H