diff --git a/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h b/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h index ffc8f3b5..47dc4e1f 100644 --- a/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h +++ b/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h @@ -29,15 +29,12 @@ class LegoLoadCacheSoundPresenter : public MxWavePresenter { void Init(); void Destroy(MxBool p_fromDestructor); - LegoCacheSound* m_cacheSound; // 0x6c - undefined4* m_unk0x70; // 0x70 - undefined4* m_unk0x74; // 0x74 - undefined4 m_unk0x78; // 0x78 - undefined m_unk0x7c; // 0x7c - undefined4 m_waveFormat2; // 0x7d - undefined4 m_samplesPerSec; // 0x81 - undefined4 m_avgBytesPerSec; // 0x85 - undefined4 m_blockalign; // 0x89 + LegoCacheSound* m_cacheSound; // 0x6c + undefined* m_unk0x70; // 0x70 + undefined* m_unk0x74; // 0x74 + undefined4 m_unk0x78; // 0x78 + undefined m_unk0x7c; // 0x7c + PCMWAVEFORMAT m_pcmWaveFormat; // 0x7d }; // SYNTHETIC: LEGO1 0x10018460 diff --git a/LEGO1/lego/legoomni/src/audio/legocachesound.cpp b/LEGO1/lego/legoomni/src/audio/legocachesound.cpp index eb58278c..a3855e88 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachesound.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachesound.cpp @@ -1,5 +1,7 @@ #include "legocachesound.h" +DECOMP_SIZE_ASSERT(LegoCacheSound, 0x88) + // FUNCTION: LEGO1 0x100064d0 LegoCacheSound::LegoCacheSound() { diff --git a/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp b/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp index 4d153cc9..753bf234 100644 --- a/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp +++ b/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp @@ -29,7 +29,7 @@ void LegoLoadCacheSoundPresenter::Init() // FUNCTION: LEGO1 0x100184f0 void LegoLoadCacheSoundPresenter::Destroy(MxBool p_fromDestructor) { - delete this->m_unk0x70; + delete[] this->m_unk0x70; MxWavePresenter::Destroy(p_fromDestructor); } @@ -37,19 +37,17 @@ void LegoLoadCacheSoundPresenter::Destroy(MxBool p_fromDestructor) void LegoLoadCacheSoundPresenter::ReadyTickle() { MxStreamChunk* chunk = NextChunk(); + if (chunk) { WaveFormat* header = (WaveFormat*) chunk->GetData(); m_unk0x78 = 0; - undefined4* buf = new undefined4[header->m_dataSize]; - m_unk0x70 = buf; - m_unk0x74 = buf; - m_cacheSound = new LegoCacheSound(); - // parse header - m_waveFormat2 = header->m_waveFormatEx.wFormatTag; // TODO: Match - m_samplesPerSec = header->m_waveFormatEx.nSamplesPerSec; - m_avgBytesPerSec = header->m_waveFormatEx.nAvgBytesPerSec; - m_blockalign = header->m_waveFormatEx.nBlockAlign; + MxU8* data = new MxU8[header->m_dataSize]; + m_unk0x70 = data; + m_unk0x74 = data; + + m_cacheSound = new LegoCacheSound; + memcpy(&m_pcmWaveFormat, &header->m_pcmWaveFormat.wf, sizeof(m_pcmWaveFormat)); m_subscriber->DestroyChunk(chunk); ProgressTickleState(e_streaming); diff --git a/LEGO1/omni/include/mxwavepresenter.h b/LEGO1/omni/include/mxwavepresenter.h index bffefe15..289fa879 100644 --- a/LEGO1/omni/include/mxwavepresenter.h +++ b/LEGO1/omni/include/mxwavepresenter.h @@ -49,12 +49,11 @@ class MxWavePresenter : public MxSoundPresenter { // FUNCTION: LEGO1 0x1000d6b0 virtual MxBool IsPaused() { return m_paused; }; // vtable+0x6c - // Reference: https://github.com/itsmattkc/SIEdit/blob/master/lib/othertypes.h - // SIZE 0x1c + // SIZE 0x18 struct WaveFormat { - WAVEFORMATEX m_waveFormatEx; - MxU32 m_dataSize; - MxU32 m_flags; + PCMWAVEFORMAT m_pcmWaveFormat; // 0x00 + MxU32 m_dataSize; // 0x10 + MxU32 m_flags; // 0x14 }; // SYNTHETIC: LEGO1 0x1000d810 diff --git a/LEGO1/omni/src/audio/mxwavepresenter.cpp b/LEGO1/omni/src/audio/mxwavepresenter.cpp index 831e0043..c0aaca7c 100644 --- a/LEGO1/omni/src/audio/mxwavepresenter.cpp +++ b/LEGO1/omni/src/audio/mxwavepresenter.cpp @@ -9,7 +9,7 @@ #include "mxutil.h" DECOMP_SIZE_ASSERT(MxWavePresenter, 0x6c); -DECOMP_SIZE_ASSERT(MxWavePresenter::WaveFormat, 0x1c); +DECOMP_SIZE_ASSERT(MxWavePresenter::WaveFormat, 0x18); // FUNCTION: LEGO1 0x100b1ad0 void MxWavePresenter::Init() @@ -134,12 +134,12 @@ void MxWavePresenter::StartingTickle() m_chunkLength = length; memset(&waveFormatEx, 0, sizeof(waveFormatEx)); - waveFormatEx.wFormatTag = m_waveFormat->m_waveFormatEx.wFormatTag; - waveFormatEx.nChannels = m_waveFormat->m_waveFormatEx.nChannels; - waveFormatEx.nSamplesPerSec = m_waveFormat->m_waveFormatEx.nSamplesPerSec; - waveFormatEx.nAvgBytesPerSec = m_waveFormat->m_waveFormatEx.nAvgBytesPerSec; - waveFormatEx.nBlockAlign = m_waveFormat->m_waveFormatEx.nBlockAlign; - waveFormatEx.wBitsPerSample = m_waveFormat->m_waveFormatEx.wBitsPerSample; + waveFormatEx.wFormatTag = m_waveFormat->m_pcmWaveFormat.wf.wFormatTag; + waveFormatEx.nChannels = m_waveFormat->m_pcmWaveFormat.wf.nChannels; + waveFormatEx.nSamplesPerSec = m_waveFormat->m_pcmWaveFormat.wf.nSamplesPerSec; + waveFormatEx.nAvgBytesPerSec = m_waveFormat->m_pcmWaveFormat.wf.nAvgBytesPerSec; + waveFormatEx.nBlockAlign = m_waveFormat->m_pcmWaveFormat.wf.nBlockAlign; + waveFormatEx.wBitsPerSample = m_waveFormat->m_pcmWaveFormat.wBitsPerSample; if (waveFormatEx.wBitsPerSample == 8) m_silenceData = 0x7F; @@ -157,7 +157,7 @@ void MxWavePresenter::StartingTickle() desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME; if (m_action->GetFlags() & MxDSAction::c_looping) - desc.dwBufferBytes = m_waveFormat->m_waveFormatEx.nAvgBytesPerSec * + desc.dwBufferBytes = m_waveFormat->m_pcmWaveFormat.wf.nAvgBytesPerSec * (m_action->GetDuration() / m_action->GetLoopCount()) / 1000; else desc.dwBufferBytes = 2 * length;