Implement/match MxLoopingMIDIPresenter (#302)

* Implement/match MxLoopingMIDIPresenter

* Move declarations
This commit is contained in:
Christian Semmler 2023-11-25 13:26:44 -05:00 committed by GitHub
parent 5aa548c449
commit fb0d1ccb62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 4 deletions

View file

@ -1,5 +1,59 @@
#include "mxloopingmidipresenter.h"
#include "decomp.h"
#include "mxdssound.h"
#include "mxmusicmanager.h"
#include "mxomni.h"
DECOMP_SIZE_ASSERT(MxLoopingMIDIPresenter, 0x58);
// OFFSET: LEGO1 0x100b1830 TEMPLATE
// MxLoopingMIDIPresenter::ClassName
// OFFSET: LEGO1 0x100b1840 TEMPLATE
// MxLoopingMIDIPresenter::IsA
// OFFSET: LEGO1 0x100b19c0 TEMPLATE
// MxLoopingMIDIPresenter::`scalar deleting destructor'
// OFFSET: LEGO1 0x100c2a80
void MxLoopingMIDIPresenter::StreamingTickle()
{
if (m_action->GetLoopCount()) {
MxMIDIPresenter::StreamingTickle();
return;
}
if (!m_chunk) {
m_chunk = NextChunk();
return;
}
if (m_chunk->GetTime() + m_action->GetDuration() <= m_action->GetElapsedTime()) {
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
m_currentTickleState = TickleState_Done;
}
}
// OFFSET: LEGO1 0x100c2ae0
void MxLoopingMIDIPresenter::DoneTickle()
{
if (m_action->GetLoopCount())
MxMIDIPresenter::DoneTickle();
else
EndAction();
}
// OFFSET: LEGO1 0x100c2b00
undefined4 MxLoopingMIDIPresenter::PutData()
{
m_criticalSection.Enter();
if (m_currentTickleState == TickleState_Streaming && m_chunk && !MusicManager()->GetMIDIInitialized()) {
SetVolume(((MxDSSound*) m_action)->GetVolume());
MusicManager()->FUN_100c09c0(m_chunk->GetData(), !m_action->GetLoopCount() ? -1 : m_action->GetLoopCount());
}
m_criticalSection.Leave();
return 0;
}

View file

@ -7,18 +7,20 @@
// SIZE 0x58
class MxLoopingMIDIPresenter : public MxMIDIPresenter {
public:
// OFFSET: LEGO1 0x100b1830
inline virtual const char* ClassName() const override // vtable+0xc
{
// 0x10101de0
return "MxLoopingMIDIPresenter";
}
// OFFSET: LEGO1 0x100b1840
inline virtual MxBool IsA(const char* name) const override // vtable+0x10
{
return !strcmp(name, MxLoopingMIDIPresenter::ClassName()) || MxMIDIPresenter::IsA(name);
}
virtual void StreamingTickle() override; // vtable+0x20
virtual void DoneTickle() override; // vtable+0x2c
virtual undefined4 PutData() override; // vtable+0x4c
};
#endif // MXLOOPINGMIDIPRESENTER_H

View file

@ -37,6 +37,7 @@ class MxMIDIPresenter : public MxMusicPresenter {
void Init();
void Destroy(MxBool p_fromDestructor);
protected:
MxStreamChunk* m_chunk;
};

View file

@ -137,7 +137,7 @@ MxS32 MxMusicManager::CalculateVolume(MxS32 p_volume)
}
// OFFSET: LEGO1 0x100c09c0 STUB
undefined4 MxMusicManager::FUN_100c09c0(MxU8* p_data, undefined4)
undefined4 MxMusicManager::FUN_100c09c0(MxU8* p_data, MxS32 p_loopCount)
{
// TODO
return 0;

View file

@ -18,7 +18,7 @@ class MxMusicManager : public MxAudioManager {
inline MxBool GetMIDIInitialized() { return m_MIDIInitialized; }
void DeinitializeMIDI();
undefined4 FUN_100c09c0(MxU8* p_data, undefined4);
undefined4 FUN_100c09c0(MxU8* p_data, MxS32 p_loopCount);
void SetMultiplier(MxS32 p_multiplier);
private: