implement LegoLoadCacheSoundPresenter (#475)

* fix

* fixes

* Fix WaveFormat, match LegoLoadCacheSoundPresenter

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha 2024-01-21 10:30:19 -05:00 committed by GitHub
parent 3f35302e76
commit 8e1197d14c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 52 additions and 24 deletions

View file

@ -1,6 +1,7 @@
#ifndef LEGOCACHESOUND_H #ifndef LEGOCACHESOUND_H
#define LEGOCACHESOUND_H #define LEGOCACHESOUND_H
#include "decomp.h"
#include "mxcore.h" #include "mxcore.h"
// VTABLE: LEGO1 0x100d4718 // VTABLE: LEGO1 0x100d4718
@ -28,6 +29,8 @@ class LegoCacheSound : public MxCore {
private: private:
void Init(); void Init();
undefined m_padding0x08[0x80]; // 0x08
}; };
#endif // LEGOCACHESOUND_H #endif // LEGOCACHESOUND_H

View file

@ -4,6 +4,8 @@
#include "decomp.h" #include "decomp.h"
#include "mxwavepresenter.h" #include "mxwavepresenter.h"
class LegoCacheSound;
// VTABLE: LEGO1 0x100d5fa8 // VTABLE: LEGO1 0x100d5fa8
// SIZE 0x90 // SIZE 0x90
class LegoLoadCacheSoundPresenter : public MxWavePresenter { class LegoLoadCacheSoundPresenter : public MxWavePresenter {
@ -27,12 +29,12 @@ class LegoLoadCacheSoundPresenter : public MxWavePresenter {
void Init(); void Init();
void Destroy(MxBool p_fromDestructor); void Destroy(MxBool p_fromDestructor);
undefined4* m_unk0x6c; // 0x6c LegoCacheSound* m_cacheSound; // 0x6c
undefined4* m_unk0x70; // 0x70 undefined* m_unk0x70; // 0x70
undefined4 m_unk0x74; // 0x74 undefined* m_unk0x74; // 0x74
undefined4 m_unk0x78; // 0x78 undefined4 m_unk0x78; // 0x78
undefined m_unk0x7c; // 0x7c undefined m_unk0x7c; // 0x7c
undefined4 m_unk0x80[4]; // 0x80 PCMWAVEFORMAT m_pcmWaveFormat; // 0x7d
}; };
// SYNTHETIC: LEGO1 0x10018460 // SYNTHETIC: LEGO1 0x10018460

View file

@ -1,5 +1,7 @@
#include "legocachesound.h" #include "legocachesound.h"
DECOMP_SIZE_ASSERT(LegoCacheSound, 0x88)
// FUNCTION: LEGO1 0x100064d0 // FUNCTION: LEGO1 0x100064d0
LegoCacheSound::LegoCacheSound() LegoCacheSound::LegoCacheSound()
{ {

View file

@ -1,5 +1,9 @@
#include "legoloadcachesoundpresenter.h" #include "legoloadcachesoundpresenter.h"
#include "legocachesound.h"
#include "mxstreamchunk.h"
#include "mxwavepresenter.h"
DECOMP_SIZE_ASSERT(LegoLoadCacheSoundPresenter, 0x90) DECOMP_SIZE_ASSERT(LegoLoadCacheSoundPresenter, 0x90)
// FUNCTION: LEGO1 0x10018340 // FUNCTION: LEGO1 0x10018340
@ -25,26 +29,44 @@ void LegoLoadCacheSoundPresenter::Init()
// FUNCTION: LEGO1 0x100184f0 // FUNCTION: LEGO1 0x100184f0
void LegoLoadCacheSoundPresenter::Destroy(MxBool p_fromDestructor) void LegoLoadCacheSoundPresenter::Destroy(MxBool p_fromDestructor)
{ {
delete this->m_unk0x70; delete[] this->m_unk0x70;
MxWavePresenter::Destroy(p_fromDestructor); MxWavePresenter::Destroy(p_fromDestructor);
} }
// STUB: LEGO1 0x10018510 // FUNCTION: LEGO1 0x10018510
void LegoLoadCacheSoundPresenter::ReadyTickle() void LegoLoadCacheSoundPresenter::ReadyTickle()
{ {
// TODO MxStreamChunk* chunk = NextChunk();
if (chunk) {
WaveFormat* header = (WaveFormat*) chunk->GetData();
m_unk0x78 = 0;
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);
}
} }
// STUB: LEGO1 0x100185f0 // STUB: LEGO1 0x100185f0
void LegoLoadCacheSoundPresenter::StreamingTickle() void LegoLoadCacheSoundPresenter::StreamingTickle()
{ {
// TODO // TODO
EndAction();
} }
// STUB: LEGO1 0x100186f0 // FUNCTION: LEGO1 0x100186f0
void LegoLoadCacheSoundPresenter::DoneTickle() void LegoLoadCacheSoundPresenter::DoneTickle()
{ {
// TODO if (m_unk0x7c != 0) {
EndAction();
}
} }
// STUB: LEGO1 0x10018700 // STUB: LEGO1 0x10018700

View file

@ -49,12 +49,11 @@ class MxWavePresenter : public MxSoundPresenter {
// FUNCTION: LEGO1 0x1000d6b0 // FUNCTION: LEGO1 0x1000d6b0
virtual MxBool IsPaused() { return m_paused; }; // vtable+0x6c virtual MxBool IsPaused() { return m_paused; }; // vtable+0x6c
// Reference: https://github.com/itsmattkc/SIEdit/blob/master/lib/othertypes.h // SIZE 0x18
// SIZE 0x1c
struct WaveFormat { struct WaveFormat {
WAVEFORMATEX m_waveFormatEx; PCMWAVEFORMAT m_pcmWaveFormat; // 0x00
MxU32 m_dataSize; MxU32 m_dataSize; // 0x10
MxU32 m_flags; MxU32 m_flags; // 0x14
}; };
// SYNTHETIC: LEGO1 0x1000d810 // SYNTHETIC: LEGO1 0x1000d810

View file

@ -9,7 +9,7 @@
#include "mxutil.h" #include "mxutil.h"
DECOMP_SIZE_ASSERT(MxWavePresenter, 0x6c); DECOMP_SIZE_ASSERT(MxWavePresenter, 0x6c);
DECOMP_SIZE_ASSERT(MxWavePresenter::WaveFormat, 0x1c); DECOMP_SIZE_ASSERT(MxWavePresenter::WaveFormat, 0x18);
// FUNCTION: LEGO1 0x100b1ad0 // FUNCTION: LEGO1 0x100b1ad0
void MxWavePresenter::Init() void MxWavePresenter::Init()
@ -134,12 +134,12 @@ void MxWavePresenter::StartingTickle()
m_chunkLength = length; m_chunkLength = length;
memset(&waveFormatEx, 0, sizeof(waveFormatEx)); memset(&waveFormatEx, 0, sizeof(waveFormatEx));
waveFormatEx.wFormatTag = m_waveFormat->m_waveFormatEx.wFormatTag; waveFormatEx.wFormatTag = m_waveFormat->m_pcmWaveFormat.wf.wFormatTag;
waveFormatEx.nChannels = m_waveFormat->m_waveFormatEx.nChannels; waveFormatEx.nChannels = m_waveFormat->m_pcmWaveFormat.wf.nChannels;
waveFormatEx.nSamplesPerSec = m_waveFormat->m_waveFormatEx.nSamplesPerSec; waveFormatEx.nSamplesPerSec = m_waveFormat->m_pcmWaveFormat.wf.nSamplesPerSec;
waveFormatEx.nAvgBytesPerSec = m_waveFormat->m_waveFormatEx.nAvgBytesPerSec; waveFormatEx.nAvgBytesPerSec = m_waveFormat->m_pcmWaveFormat.wf.nAvgBytesPerSec;
waveFormatEx.nBlockAlign = m_waveFormat->m_waveFormatEx.nBlockAlign; waveFormatEx.nBlockAlign = m_waveFormat->m_pcmWaveFormat.wf.nBlockAlign;
waveFormatEx.wBitsPerSample = m_waveFormat->m_waveFormatEx.wBitsPerSample; waveFormatEx.wBitsPerSample = m_waveFormat->m_pcmWaveFormat.wBitsPerSample;
if (waveFormatEx.wBitsPerSample == 8) if (waveFormatEx.wBitsPerSample == 8)
m_silenceData = 0x7F; m_silenceData = 0x7F;
@ -157,7 +157,7 @@ void MxWavePresenter::StartingTickle()
desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME; desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
if (m_action->GetFlags() & MxDSAction::c_looping) 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; (m_action->GetDuration() / m_action->GetLoopCount()) / 1000;
else else
desc.dwBufferBytes = 2 * length; desc.dwBufferBytes = 2 * length;