2023-07-02 03:00:28 -04:00
|
|
|
#include "mxmidipresenter.h"
|
|
|
|
|
|
|
|
#include "decomp.h"
|
2023-10-14 09:25:53 -04:00
|
|
|
#include "legoomni.h"
|
2023-11-24 12:21:26 -05:00
|
|
|
#include "mxautolocker.h"
|
|
|
|
#include "mxdssound.h"
|
2023-10-14 09:25:53 -04:00
|
|
|
#include "mxmusicmanager.h"
|
2023-07-02 03:00:28 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxMIDIPresenter, 0x58);
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c25e0
|
2023-10-14 09:25:53 -04:00
|
|
|
MxMIDIPresenter::MxMIDIPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-07-02 03:00:28 -04:00
|
|
|
}
|
|
|
|
|
2023-10-14 09:25:53 -04:00
|
|
|
// OFFSET: LEGO1 0x100c27c0
|
|
|
|
MxMIDIPresenter::~MxMIDIPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy(TRUE);
|
2023-10-14 09:25:53 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x100c2820
|
|
|
|
void MxMIDIPresenter::Init()
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
m_chunk = NULL;
|
2023-07-02 03:00:28 -04:00
|
|
|
}
|
2023-10-14 09:25:53 -04:00
|
|
|
|
2023-11-24 12:21:26 -05:00
|
|
|
// OFFSET: LEGO1 0x100c2830
|
2023-10-14 09:25:53 -04:00
|
|
|
void MxMIDIPresenter::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
if (MusicManager()) {
|
|
|
|
MusicManager()->DeinitializeMIDI();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_criticalSection.Enter();
|
|
|
|
|
|
|
|
if (m_subscriber && m_chunk)
|
|
|
|
m_subscriber->FUN_100b8390(m_chunk);
|
|
|
|
Init();
|
|
|
|
|
|
|
|
m_criticalSection.Leave();
|
|
|
|
|
|
|
|
if (!p_fromDestructor)
|
|
|
|
MxMusicPresenter::Destroy();
|
2023-10-14 09:25:53 -04:00
|
|
|
}
|
|
|
|
|
2023-11-24 12:21:26 -05:00
|
|
|
// OFFSET: LEGO1 0x100c2890
|
2023-11-14 15:10:43 -05:00
|
|
|
void MxMIDIPresenter::ReadyTickle()
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
MxStreamChunk* chunk = NextChunk();
|
|
|
|
|
|
|
|
if (chunk) {
|
|
|
|
m_subscriber->FUN_100b8390(chunk);
|
|
|
|
ParseExtra();
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Starting;
|
|
|
|
}
|
2023-11-14 15:10:43 -05:00
|
|
|
}
|
|
|
|
|
2023-11-24 12:21:26 -05:00
|
|
|
// OFFSET: LEGO1 0x100c28d0
|
2023-11-14 15:10:43 -05:00
|
|
|
void MxMIDIPresenter::StartingTickle()
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
MxStreamChunk* chunk = FUN_100b5650();
|
|
|
|
|
|
|
|
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Streaming;
|
|
|
|
}
|
2023-11-14 15:10:43 -05:00
|
|
|
}
|
|
|
|
|
2023-11-24 12:21:26 -05:00
|
|
|
// OFFSET: LEGO1 0x100c2910
|
2023-11-14 15:10:43 -05:00
|
|
|
void MxMIDIPresenter::StreamingTickle()
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
if (m_chunk) {
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Done;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_chunk = NextChunk();
|
2023-11-14 15:10:43 -05:00
|
|
|
}
|
|
|
|
|
2023-10-14 09:25:53 -04:00
|
|
|
// OFFSET: LEGO1 0x100c2940
|
|
|
|
void MxMIDIPresenter::DoneTickle()
|
|
|
|
{
|
2023-11-14 15:10:43 -05:00
|
|
|
if (!MusicManager()->GetMIDIInitialized())
|
|
|
|
EndAction();
|
|
|
|
}
|
|
|
|
|
2023-11-24 12:21:26 -05:00
|
|
|
// OFFSET: LEGO1 0x100c2960
|
2023-11-14 15:10:43 -05:00
|
|
|
void MxMIDIPresenter::Destroy()
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
Destroy(FALSE);
|
2023-11-14 15:10:43 -05:00
|
|
|
}
|
|
|
|
|
2023-11-24 12:21:26 -05:00
|
|
|
// OFFSET: LEGO1 0x100c2970
|
2023-11-14 15:10:43 -05:00
|
|
|
undefined4 MxMIDIPresenter::PutData()
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
m_criticalSection.Enter();
|
|
|
|
|
|
|
|
if (m_currentTickleState == TickleState_Streaming && m_chunk && !MusicManager()->GetMIDIInitialized()) {
|
|
|
|
SetVolume(((MxDSSound*) m_action)->GetVolume());
|
|
|
|
|
|
|
|
if (MusicManager()->FUN_100c09c0(m_chunk->GetData(), 1))
|
|
|
|
EndAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_criticalSection.Leave();
|
2023-11-14 15:10:43 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-11-24 12:21:26 -05:00
|
|
|
// OFFSET: LEGO1 0x100c29e0
|
2023-11-14 15:10:43 -05:00
|
|
|
void MxMIDIPresenter::EndAction()
|
|
|
|
{
|
2023-11-24 12:21:26 -05:00
|
|
|
if (m_action) {
|
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
MxMediaPresenter::EndAction();
|
|
|
|
MusicManager()->DeinitializeMIDI();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c2a60
|
|
|
|
void MxMIDIPresenter::SetVolume(MxS32 p_volume)
|
|
|
|
{
|
|
|
|
m_volume = p_volume;
|
|
|
|
MusicManager()->SetMultiplier(p_volume);
|
2023-10-25 14:51:59 -04:00
|
|
|
}
|