mirror of
https://github.com/isledecomp/isle-portable.git
synced 2024-11-26 17:36:12 -05:00
494a556f8e
* Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
162 lines
3 KiB
C++
162 lines
3 KiB
C++
#include "mxmusicmanager.h"
|
|
|
|
#include "mxomni.h"
|
|
#include "mxticklemanager.h"
|
|
|
|
#include <windows.h>
|
|
|
|
DECOMP_SIZE_ASSERT(MxMusicManager, 0x58);
|
|
|
|
// FUNCTION: LEGO1 0x100c05a0
|
|
MxMusicManager::MxMusicManager()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c0630
|
|
MxMusicManager::~MxMusicManager()
|
|
{
|
|
Destroy(TRUE);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c0690
|
|
void MxMusicManager::Init()
|
|
{
|
|
m_multiplier = 100;
|
|
InitData();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c06a0
|
|
void MxMusicManager::InitData()
|
|
{
|
|
m_MIDIStreamH = 0;
|
|
m_MIDIInitialized = FALSE;
|
|
m_unk38 = 0;
|
|
m_unk3c = 0;
|
|
m_unk40 = 0;
|
|
m_unk44 = 0;
|
|
m_unk48 = 0;
|
|
m_MIDIHdrP = NULL;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c06c0
|
|
void MxMusicManager::Destroy(MxBool p_fromDestructor)
|
|
{
|
|
if (m_thread) {
|
|
m_thread->Terminate();
|
|
if (m_thread) {
|
|
delete m_thread;
|
|
}
|
|
}
|
|
else {
|
|
TickleManager()->UnregisterClient(this);
|
|
}
|
|
|
|
m_criticalSection.Enter();
|
|
DeinitializeMIDI();
|
|
Init();
|
|
m_criticalSection.Leave();
|
|
|
|
if (!p_fromDestructor) {
|
|
MxAudioManager::Destroy();
|
|
}
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c07f0
|
|
void MxMusicManager::SetMIDIVolume()
|
|
{
|
|
MxS32 result = (m_volume * m_multiplier) / 0x64;
|
|
HMIDISTRM streamHandle = m_MIDIStreamH;
|
|
|
|
if (streamHandle) {
|
|
MxS32 volume = CalculateVolume(result);
|
|
midiOutSetVolume((HMIDIOUT) streamHandle, volume);
|
|
}
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c0840
|
|
MxResult MxMusicManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
|
|
{
|
|
MxResult status = FAILURE;
|
|
MxBool locked = FALSE;
|
|
|
|
if (MxAudioManager::InitPresenters() == SUCCESS) {
|
|
if (p_createThread) {
|
|
m_criticalSection.Enter();
|
|
locked = TRUE;
|
|
m_thread = new MxTickleThread(this, p_frequencyMS);
|
|
|
|
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
|
|
goto done;
|
|
}
|
|
else
|
|
TickleManager()->RegisterClient(this, p_frequencyMS);
|
|
|
|
status = SUCCESS;
|
|
}
|
|
|
|
done:
|
|
if (status != SUCCESS)
|
|
Destroy();
|
|
|
|
if (locked)
|
|
m_criticalSection.Leave();
|
|
|
|
return status;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c0930
|
|
void MxMusicManager::Destroy()
|
|
{
|
|
Destroy(FALSE);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c0940
|
|
void MxMusicManager::SetVolume(MxS32 p_volume)
|
|
{
|
|
MxAudioManager::SetVolume(p_volume);
|
|
m_criticalSection.Enter();
|
|
SetMIDIVolume();
|
|
m_criticalSection.Leave();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c0970
|
|
void MxMusicManager::SetMultiplier(MxS32 p_multiplier)
|
|
{
|
|
m_criticalSection.Enter();
|
|
m_multiplier = p_multiplier;
|
|
SetMIDIVolume();
|
|
m_criticalSection.Leave();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c09a0
|
|
MxS32 MxMusicManager::CalculateVolume(MxS32 p_volume)
|
|
{
|
|
MxS32 result = (p_volume * 0xffff) / 100;
|
|
return (result << 0x10) | result;
|
|
}
|
|
|
|
// STUB: LEGO1 0x100c09c0
|
|
undefined4 MxMusicManager::FUN_100c09c0(MxU8* p_data, MxS32 p_loopCount)
|
|
{
|
|
// TODO
|
|
return 0;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100c0b20
|
|
void MxMusicManager::DeinitializeMIDI()
|
|
{
|
|
m_criticalSection.Enter();
|
|
|
|
if (m_MIDIInitialized) {
|
|
m_MIDIInitialized = FALSE;
|
|
midiStreamStop(m_MIDIStreamH);
|
|
midiOutUnprepareHeader((HMIDIOUT) m_MIDIStreamH, m_MIDIHdrP, sizeof(MIDIHDR));
|
|
midiOutSetVolume((HMIDIOUT) m_MIDIStreamH, m_MIDIVolume);
|
|
midiStreamClose(m_MIDIStreamH);
|
|
delete m_MIDIHdrP;
|
|
InitData();
|
|
}
|
|
|
|
m_criticalSection.Leave();
|
|
}
|