mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-28 18:51:16 +00:00
Fixes/improvements
This commit is contained in:
parent
f7cf2ec2f0
commit
2f5512d227
@ -8,7 +8,7 @@ DECOMP_SIZE_ASSERT(LegoMeterPresenter, 0x94)
|
|||||||
|
|
||||||
// GLOBAL: LEGO1 0x1010207c
|
// GLOBAL: LEGO1 0x1010207c
|
||||||
// STRING: LEGO1 0x10101fb4
|
// STRING: LEGO1 0x10101fb4
|
||||||
const char* g_filterIndex = "FILTER_INDEX";
|
const char* g_filterIndex = "FILLER_INDEX";
|
||||||
|
|
||||||
// GLOBAL: LEGO1 0x10102094
|
// GLOBAL: LEGO1 0x10102094
|
||||||
// STRING: LEGO1 0x10101f70
|
// STRING: LEGO1 0x10101f70
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
#include "mxaudiomanager.h"
|
#include "mxaudiomanager.h"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100dc930
|
// VTABLE: LEGO1 0x100dc930
|
||||||
// SIZE 0x58
|
// SIZE 0x58
|
||||||
class MxMusicManager : public MxAudioManager {
|
class MxMusicManager : public MxAudioManager {
|
||||||
@ -18,7 +20,7 @@ class MxMusicManager : public MxAudioManager {
|
|||||||
inline MxBool GetMIDIInitialized() { return m_midiInitialized; }
|
inline MxBool GetMIDIInitialized() { return m_midiInitialized; }
|
||||||
inline void GetMIDIVolume(DWORD& p_volume)
|
inline void GetMIDIVolume(DWORD& p_volume)
|
||||||
{
|
{
|
||||||
if (midiOutGetVolume(m_midiStreamH, &p_volume)) {
|
if (midiOutGetVolume((HMIDIOUT) m_midiStreamH, &p_volume)) {
|
||||||
p_volume = CalculateVolume(100);
|
p_volume = CalculateVolume(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,6 +37,9 @@ class MxMusicManager : public MxAudioManager {
|
|||||||
MxS32 CalculateVolume(MxS32 p_volume);
|
MxS32 CalculateVolume(MxS32 p_volume);
|
||||||
void SetMIDIVolume();
|
void SetMIDIVolume();
|
||||||
|
|
||||||
|
static void CALLBACK
|
||||||
|
MidiCallbackProc(HMIDIOUT p_hmo, UINT p_wMsg, DWORD_PTR p_dwInstance, DWORD_PTR p_dwParam1, DWORD_PTR p_dwParam2);
|
||||||
|
|
||||||
HMIDISTRM m_midiStreamH; // 0x30
|
HMIDISTRM m_midiStreamH; // 0x30
|
||||||
MxBool m_midiInitialized; // 0x34
|
MxBool m_midiInitialized; // 0x34
|
||||||
MxU32 m_bufferSize; // 0x38
|
MxU32 m_bufferSize; // 0x38
|
||||||
|
|||||||
@ -119,6 +119,6 @@ class MxStreamController : public MxCore {
|
|||||||
// List<MxNextActionDataStart *>::~List<MxNextActionDataStart *>
|
// List<MxNextActionDataStart *>::~List<MxNextActionDataStart *>
|
||||||
|
|
||||||
// TEMPLATE: LEGO1 0x100c1bc0
|
// TEMPLATE: LEGO1 0x100c1bc0
|
||||||
// List<MxDSAction *>::insert
|
// list<MxDSAction *,allocator<MxDSAction *> >::insert
|
||||||
|
|
||||||
#endif // MXSTREAMCONTROLLER_H
|
#endif // MXSTREAMCONTROLLER_H
|
||||||
|
|||||||
@ -66,38 +66,46 @@ void MxMusicManager::Destroy(MxBool p_fromDestructor)
|
|||||||
MxResult MxMusicManager::ResetStream()
|
MxResult MxMusicManager::ResetStream()
|
||||||
{
|
{
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
|
|
||||||
if (m_midiInitialized) {
|
if (m_midiInitialized) {
|
||||||
if (m_bufferCurrentSize == 0) {
|
if (m_bufferCurrentSize == 0) {
|
||||||
if (m_loopCount != -1) {
|
if (m_loopCount != -1) {
|
||||||
m_loopCount += -1;
|
m_loopCount += -1;
|
||||||
|
|
||||||
if (!m_loopCount) {
|
if (!m_loopCount) {
|
||||||
DeinitializeMIDI();
|
DeinitializeMIDI();
|
||||||
return result;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetBuffer();
|
ResetBuffer();
|
||||||
}
|
}
|
||||||
do {
|
|
||||||
if (m_midiHdrP->dwFlags & (MHDR_DONE | MHDR_PREPARED)) {
|
if (m_midiHdrP->dwFlags & (MHDR_DONE | MHDR_PREPARED)) {
|
||||||
if (midiOutUnprepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR)))
|
if (midiOutUnprepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR)) != MMSYSERR_NOERROR)
|
||||||
break;
|
goto done;
|
||||||
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
|
|
||||||
|
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bufferCurrentOffset += 4;
|
||||||
|
DWORD length = *((DWORD*) m_bufferCurrentOffset);
|
||||||
|
m_bufferCurrentOffset += sizeof(DWORD);
|
||||||
|
|
||||||
|
m_midiHdrP->lpData = (LPSTR) m_bufferCurrentOffset;
|
||||||
|
m_midiHdrP->dwBufferLength = length;
|
||||||
|
m_midiHdrP->dwBytesRecorded = length;
|
||||||
|
|
||||||
|
if (!midiOutPrepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR))) {
|
||||||
|
if (!midiStreamOut(m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR))) {
|
||||||
|
result = SUCCESS;
|
||||||
|
m_bufferCurrentOffset += length;
|
||||||
|
m_bufferCurrentSize--;
|
||||||
}
|
}
|
||||||
m_bufferCurrentOffset += 4;
|
}
|
||||||
DWORD length = *((DWORD*) m_bufferCurrentOffset);
|
|
||||||
m_bufferCurrentOffset += 4;
|
|
||||||
m_midiHdrP->lpData = (LPSTR) m_bufferCurrentOffset;
|
|
||||||
m_midiHdrP->dwBufferLength = length;
|
|
||||||
m_midiHdrP->dwBytesRecorded = length;
|
|
||||||
if (!midiOutPrepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR))) {
|
|
||||||
if (!midiStreamOut(m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR))) {
|
|
||||||
result = SUCCESS;
|
|
||||||
m_bufferCurrentOffset += length;
|
|
||||||
m_bufferCurrentSize--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +129,16 @@ void MxMusicManager::SetMIDIVolume()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100c0820
|
// FUNCTION: LEGO1 0x100c0820
|
||||||
static void CALLBACK
|
void CALLBACK MxMusicManager::MidiCallbackProc(
|
||||||
MidiCallbackProc(HMIDIOUT p_hmo, UINT p_wMsg, MxMusicManager* p_dwInstance, MxU32* p_dwParam1, MxU32* p_dwParam2)
|
HMIDIOUT p_hmo,
|
||||||
|
UINT p_wMsg,
|
||||||
|
DWORD_PTR p_dwInstance,
|
||||||
|
DWORD_PTR p_dwParam1,
|
||||||
|
DWORD_PTR p_dwParam2
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (p_wMsg == MOM_DONE)
|
if (p_wMsg == MOM_DONE)
|
||||||
p_dwInstance->ResetStream();
|
((MxMusicManager*) p_dwInstance)->ResetStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100c0840
|
// FUNCTION: LEGO1 0x100c0840
|
||||||
@ -194,54 +207,62 @@ MxS32 MxMusicManager::CalculateVolume(MxS32 p_volume)
|
|||||||
undefined4 MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
|
undefined4 MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
|
||||||
{
|
{
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
|
|
||||||
m_criticalSection.Enter();
|
m_criticalSection.Enter();
|
||||||
do {
|
|
||||||
if (m_midiInitialized)
|
if (!m_midiInitialized) {
|
||||||
break;
|
|
||||||
MxU32 total = midiOutGetNumDevs();
|
MxU32 total = midiOutGetNumDevs();
|
||||||
MxU32 device = 0;
|
MxU32 device = 0;
|
||||||
|
|
||||||
for (; device < total; device++) {
|
for (; device < total; device++) {
|
||||||
MIDIOUTCAPSA caps;
|
MIDIOUTCAPSA caps;
|
||||||
midiOutGetDevCapsA(device, &caps, sizeof(MIDIOUTCAPSA));
|
midiOutGetDevCapsA(device, &caps, sizeof(MIDIOUTCAPSA));
|
||||||
if (caps.wTechnology == MOD_FMSYNTH)
|
if (caps.wTechnology == MOD_FMSYNTH)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (device == total)
|
|
||||||
|
if (device >= total)
|
||||||
device = -1;
|
device = -1;
|
||||||
if (midiStreamOpen(
|
|
||||||
(LPHMIDIOUT) &m_midiStreamH,
|
if (midiStreamOpen(&m_midiStreamH, &device, 1, (DWORD) MidiCallbackProc, (DWORD) this, CALLBACK_FUNCTION) !=
|
||||||
&device,
|
MMSYSERR_NOERROR)
|
||||||
1,
|
goto done;
|
||||||
(DWORD) MidiCallbackProc,
|
|
||||||
(DWORD) this,
|
|
||||||
CALLBACK_FUNCTION
|
|
||||||
))
|
|
||||||
break;
|
|
||||||
GetMIDIVolume(m_midiVolume);
|
GetMIDIVolume(m_midiVolume);
|
||||||
|
|
||||||
m_midiHdrP = new MIDIHDR();
|
m_midiHdrP = new MIDIHDR();
|
||||||
if (!m_midiHdrP)
|
if (!m_midiHdrP)
|
||||||
break;
|
goto done;
|
||||||
|
|
||||||
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
|
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
|
||||||
|
|
||||||
MIDIPROPTIMEDIV timediv;
|
MIDIPROPTIMEDIV timediv;
|
||||||
timediv.cbStruct = 8;
|
timediv.cbStruct = 8;
|
||||||
m_bufferOffset = p_data;
|
m_bufferOffset = p_data;
|
||||||
m_bufferOffset += 0x14;
|
m_bufferOffset += 0x14;
|
||||||
timediv.dwTimeDiv = *((DWORD*) m_bufferOffset);
|
timediv.dwTimeDiv = *((DWORD*) m_bufferOffset);
|
||||||
if (midiStreamProperty(m_midiStreamH, (LPBYTE) &timediv, MIDIPROP_SET | MIDIPROP_TIMEDIV))
|
|
||||||
break;
|
if (midiStreamProperty(m_midiStreamH, (LPBYTE) &timediv, MIDIPROP_SET | MIDIPROP_TIMEDIV) != MMSYSERR_NOERROR)
|
||||||
|
goto done;
|
||||||
|
|
||||||
m_bufferOffset += 0x14;
|
m_bufferOffset += 0x14;
|
||||||
m_bufferSize = *((MxU32*) m_bufferOffset);
|
m_bufferSize = *((MxU32*) m_bufferOffset);
|
||||||
m_bufferOffset += 0x4;
|
m_bufferOffset += sizeof(MxU32);
|
||||||
m_loopCount = p_loopCount;
|
m_loopCount = p_loopCount;
|
||||||
m_midiInitialized = TRUE;
|
m_midiInitialized = TRUE;
|
||||||
|
|
||||||
ResetBuffer();
|
ResetBuffer();
|
||||||
if (ResetStream() != SUCCESS)
|
if (ResetStream() != SUCCESS)
|
||||||
break;
|
goto done;
|
||||||
|
|
||||||
SetMIDIVolume();
|
SetMIDIVolume();
|
||||||
if (midiStreamRestart(m_midiStreamH))
|
if (midiStreamRestart(m_midiStreamH) != MMSYSERR_NOERROR)
|
||||||
break;
|
goto done;
|
||||||
|
|
||||||
result = SUCCESS;
|
result = SUCCESS;
|
||||||
} while (FALSE);
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
m_criticalSection.Leave();
|
m_criticalSection.Leave();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,11 @@
|
|||||||
#define COMPAT_CONST
|
#define COMPAT_CONST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// DWORD_PTR didn't exist in older Windows SDKs
|
||||||
|
#if (defined(_MSC_VER) && _MSC_VER < 1100)
|
||||||
|
typedef unsigned long DWORD_PTR, *PDWORD_PTR;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Disable "identifier was truncated to '255' characters" warning.
|
// Disable "identifier was truncated to '255' characters" warning.
|
||||||
// Impossible to avoid this if using STL map or set.
|
// Impossible to avoid this if using STL map or set.
|
||||||
// This removes most (but not all) occurrences of the warning.
|
// This removes most (but not all) occurrences of the warning.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user