From c626f18b03824091d6802aeda51cdc3b2104ee53 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Tue, 14 Nov 2023 15:10:43 -0500 Subject: [PATCH] Prepare MxMidiPresenter vtable and refactoring (#278) --- LEGO1/mxaudiopresenter.cpp | 8 ++--- LEGO1/mxaudiopresenter.h | 10 +++--- LEGO1/mxbackgroundaudiomanager.cpp | 26 ++++++++-------- LEGO1/mxmidipresenter.cpp | 49 ++++++++++++++++++++++++++++-- LEGO1/mxmidipresenter.h | 12 ++++++-- LEGO1/mxmusicpresenter.h | 6 ++-- LEGO1/mxsoundmanager.cpp | 2 +- LEGO1/mxsoundpresenter.cpp | 12 ++++---- LEGO1/mxsoundpresenter.h | 3 +- 9 files changed, 91 insertions(+), 37 deletions(-) diff --git a/LEGO1/mxaudiopresenter.cpp b/LEGO1/mxaudiopresenter.cpp index bd6a5c87..fcb8c0ea 100644 --- a/LEGO1/mxaudiopresenter.cpp +++ b/LEGO1/mxaudiopresenter.cpp @@ -5,13 +5,13 @@ DECOMP_SIZE_ASSERT(MxAudioPresenter, 0x54); // OFFSET: LEGO1 0x1000d260 -undefined4 MxAudioPresenter::vtable5c() +MxU32 MxAudioPresenter::GetVolume() { - return this->m_unk50; + return m_volume; } // OFFSET: LEGO1 0x1000d270 -void MxAudioPresenter::vtable60(undefined4 p_unk50) +void MxAudioPresenter::SetVolume(MxU32 p_volume) { - this->m_unk50 = p_unk50; + m_volume = p_volume; } diff --git a/LEGO1/mxaudiopresenter.h b/LEGO1/mxaudiopresenter.h index 717c8b4d..9fc92457 100644 --- a/LEGO1/mxaudiopresenter.h +++ b/LEGO1/mxaudiopresenter.h @@ -5,9 +5,10 @@ #include "mxmediapresenter.h" // VTABLE 0x100d4c70 +// SIZE 0x54 class MxAudioPresenter : public MxMediaPresenter { public: - MxAudioPresenter() { m_unk50 = 100; } + MxAudioPresenter() { m_volume = 100; } // OFFSET: LEGO1 0x1000d280 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); } - virtual undefined4 vtable5c(); - virtual void vtable60(undefined4); + virtual MxU32 GetVolume(); // vtable+0x5c + virtual void SetVolume(MxU32 p_volume); // vtable+0x60 - undefined4 m_unk50; +private: + MxU32 m_volume; }; #endif // MXAUDIOPRESENTER_H diff --git a/LEGO1/mxbackgroundaudiomanager.cpp b/LEGO1/mxbackgroundaudiomanager.cpp index 26d399f7..2099cbc4 100644 --- a/LEGO1/mxbackgroundaudiomanager.cpp +++ b/LEGO1/mxbackgroundaudiomanager.cpp @@ -159,7 +159,7 @@ void MxBackgroundAudioManager::StartAction(MxParam& p) m_action2.SetAtomId(m_unk138->GetAction()->GetAtomId()); m_action2.SetObjectId(m_unk138->GetAction()->GetObjectId()); m_targetVolume = ((MxDSSound*) (m_unk138->GetAction()))->GetVolume(); - m_unk138->vtable60(0); + m_unk138->SetVolume(0); } // OFFSET: LEGO1 0x1007f200 @@ -257,15 +257,15 @@ void MxBackgroundAudioManager::FUN_1007ef40() if (m_unk148 == 0) { compare = m_unk148; } - volume = m_unk138->vtable5c(); + volume = m_unk138->GetVolume(); if (volume < compare) { - if (m_unk140 + m_unk138->vtable5c() <= compare) { + if (m_unk140 + m_unk138->GetVolume() <= compare) { compare = m_unk140 + compare; } - m_unk138->vtable60(compare); + m_unk138->SetVolume(compare); } else { - m_unk138->vtable60(compare); + m_unk138->SetVolume(compare); m_unka0 = m_unk138; m_action1 = m_action2; m_unk138 = NULL; @@ -276,16 +276,16 @@ void MxBackgroundAudioManager::FUN_1007ef40() } } else if (m_unka0->GetAction() != NULL) { - if (m_unka0->vtable5c() == 0) { + if (m_unka0->GetVolume() == 0) { DeleteObject(*m_unka0->GetAction()); } else { - compare = m_unka0->vtable5c(); + compare = m_unka0->GetVolume(); volume = 0; 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 if (m_unka0 != NULL) { - undefined4 volume = m_unka0->vtable5c(); + undefined4 volume = m_unka0->GetVolume(); MxU32 compare = 30; if (m_unk148 == 0) { compare = m_targetVolume; @@ -306,17 +306,17 @@ void MxBackgroundAudioManager::FadeInOrFadeOut() if (compare <= volume) { volume = compare; } - m_unka0->vtable60(volume); + m_unka0->SetVolume(volume); } else if (compare < volume) { volume = volume - m_unk140; if (volume <= compare) { volume = compare; } - m_unka0->vtable60(volume); + m_unka0->SetVolume(volume); } else { - m_unka0->vtable60(volume); + m_unka0->SetVolume(volume); m_unk13c = 0; } } diff --git a/LEGO1/mxmidipresenter.cpp b/LEGO1/mxmidipresenter.cpp index 59e30fa3..37b6ea9c 100644 --- a/LEGO1/mxmidipresenter.cpp +++ b/LEGO1/mxmidipresenter.cpp @@ -6,6 +6,13 @@ DECOMP_SIZE_ASSERT(MxMIDIPresenter, 0x58); +// OFFSET: LEGO1 0x100c25a0 STUB +MxResult MxMIDIPresenter::AddToManager() +{ + // TODO + return SUCCESS; +} + // OFFSET: LEGO1 0x100c25e0 MxMIDIPresenter::MxMIDIPresenter() { @@ -30,10 +37,46 @@ void MxMIDIPresenter::Destroy(MxBool p_fromDestructor) // 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 void MxMIDIPresenter::DoneTickle() { - if (!MusicManager()->GetMIDIInitialized()) { - this->EndAction(); - } + if (!MusicManager()->GetMIDIInitialized()) + 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 } diff --git a/LEGO1/mxmidipresenter.h b/LEGO1/mxmidipresenter.h index 675f79b5..245adb34 100644 --- a/LEGO1/mxmidipresenter.h +++ b/LEGO1/mxmidipresenter.h @@ -4,6 +4,7 @@ #include "mxmusicpresenter.h" // VTABLE 0x100dca20 +// SIZE 0x58 class MxMIDIPresenter : public MxMusicPresenter { public: MxMIDIPresenter(); @@ -22,11 +23,18 @@ class MxMIDIPresenter : public MxMusicPresenter { return !strcmp(name, MxMIDIPresenter::ClassName()) || MxMusicPresenter::IsA(name); } - virtual void DoneTickle() override; // vtable+0x2c + 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 MxResult AddToManager() override; // vtable+0x34 + virtual void Destroy() override; // vtable+0x38 + virtual void EndAction() override; // vtable+0x40 + virtual undefined4 PutData() override; // vtable+0x4c private: void Init(); - void Destroy(MxBool); + void Destroy(MxBool p_fromDestructor); undefined4 m_unk54; }; diff --git a/LEGO1/mxmusicpresenter.h b/LEGO1/mxmusicpresenter.h index 02edf1a5..2f96d64e 100644 --- a/LEGO1/mxmusicpresenter.h +++ b/LEGO1/mxmusicpresenter.h @@ -7,6 +7,9 @@ // SIZE 0x54 class MxMusicPresenter : public MxAudioPresenter { public: + MxMusicPresenter(); + virtual ~MxMusicPresenter() override; + // OFFSET: LEGO1 0x100c23a0 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); } - MxMusicPresenter(); - virtual ~MxMusicPresenter() override; - virtual MxResult AddToManager() override; // vtable+0x34 virtual void Destroy() override; // vtable+0x38 diff --git a/LEGO1/mxsoundmanager.cpp b/LEGO1/mxsoundmanager.cpp index a57672d3..8e32345e 100644 --- a/LEGO1/mxsoundmanager.cpp +++ b/LEGO1/mxsoundmanager.cpp @@ -145,7 +145,7 @@ void MxSoundManager::SetVolume(MxS32 p_volume) MxPresenterListCursor cursor(m_presenters); while (cursor.Next(presenter)) - ((MxAudioPresenter*) presenter)->vtable60(((MxAudioPresenter*) presenter)->vtable5c()); + ((MxAudioPresenter*) presenter)->SetVolume(((MxAudioPresenter*) presenter)->GetVolume()); m_criticalSection.Leave(); } diff --git a/LEGO1/mxsoundpresenter.cpp b/LEGO1/mxsoundpresenter.cpp index 3935a97c..540dcbac 100644 --- a/LEGO1/mxsoundpresenter.cpp +++ b/LEGO1/mxsoundpresenter.cpp @@ -11,6 +11,12 @@ MxSoundPresenter::~MxSoundPresenter() Destroy(TRUE); } +// OFFSET: LEGO1 0x1000d490 +void MxSoundPresenter::Destroy() +{ + Destroy(FALSE); +} + // OFFSET: LEGO1 0x100b1a50 void MxSoundPresenter::Destroy(MxBool p_fromDestructor) { @@ -37,9 +43,3 @@ MxResult MxSoundPresenter::AddToManager() return ret; } - -// OFFSET: LEGO1 0x1000d490 -void MxSoundPresenter::Destroy() -{ - Destroy(FALSE); -} diff --git a/LEGO1/mxsoundpresenter.h b/LEGO1/mxsoundpresenter.h index 57997646..408dbe88 100644 --- a/LEGO1/mxsoundpresenter.h +++ b/LEGO1/mxsoundpresenter.h @@ -5,6 +5,7 @@ #include "mxomni.h" // VTABLE 0x100d4b08 +// SIZE 0x54 class MxSoundPresenter : public MxAudioPresenter { public: virtual ~MxSoundPresenter() override; @@ -26,7 +27,7 @@ class MxSoundPresenter : public MxAudioPresenter { virtual void Destroy() override; // vtable+0x38 private: - void Destroy(MxBool); + void Destroy(MxBool p_fromDestructor); }; #endif // MXSOUNDPRESENTER_H