diff --git a/LEGO1/mxdschunk.cpp b/LEGO1/mxdschunk.cpp index 83a2d914..489a1611 100644 --- a/LEGO1/mxdschunk.cpp +++ b/LEGO1/mxdschunk.cpp @@ -6,16 +6,16 @@ DECOMP_SIZE_ASSERT(MxDSChunk, 0x1c); MxDSChunk::MxDSChunk() { m_flags = 0; - m_unk18 = NULL; + m_data = NULL; m_unk0c = -1; m_time = 0; - m_unk14 = 0; + m_length = 0; } // OFFSET: LEGO1 0x100be170 MxDSChunk::~MxDSChunk() { if (m_flags & Flag_Bit1) { - delete[] m_unk18; + delete[] m_data; } } diff --git a/LEGO1/mxdschunk.h b/LEGO1/mxdschunk.h index 1fe00460..e626d70b 100644 --- a/LEGO1/mxdschunk.h +++ b/LEGO1/mxdschunk.h @@ -31,21 +31,27 @@ class MxDSChunk : public MxCore { return !strcmp(name, MxDSChunk::ClassName()) || MxCore::IsA(name); } + inline void SetTime(MxLong p_time) { m_time = p_time; } + inline void SetLength(MxU32 p_length) { m_length = p_length; } + inline void SetData(MxU8* p_data) { m_data = p_data; } + inline MxU16 GetFlags() { return m_flags; } inline MxLong GetTime() { return m_time; } + inline MxU32 GetLength() { return m_length; } + inline MxU8* GetData() { return m_data; } - inline void ReleaseUnk18() + inline void Release() { - if (m_unk18) - delete[] m_unk18; + if (m_data) + delete[] m_data; } private: MxU16 m_flags; // 0x8 undefined4 m_unk0c; // 0xc MxLong m_time; // 0x10 - undefined4 m_unk14; // 0x14 - MxU8* m_unk18; // 0x18 + MxU32 m_length; // 0x14 + MxU8* m_data; // 0x18 }; #endif // MXDSCHUNK_H diff --git a/LEGO1/mxmediapresenter.cpp b/LEGO1/mxmediapresenter.cpp index ae18354c..4e25cc25 100644 --- a/LEGO1/mxmediapresenter.cpp +++ b/LEGO1/mxmediapresenter.cpp @@ -2,6 +2,7 @@ #include "mxautolocker.h" #include "mxstreamchunk.h" +#include "mxtimer.h" DECOMP_SIZE_ASSERT(MxMediaPresenter, 0x50); @@ -46,7 +47,7 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor) MxStreamChunk* chunk; while (cursor.Next(chunk)) - chunk->ReleaseUnk18(); + chunk->Release(); delete m_chunks; } @@ -123,7 +124,7 @@ void MxMediaPresenter::StreamingTickle() m_currentTickleState = TickleState_Repeating; } else if (m_action->GetFlags() & MxDSAction::Flag_Looping) { - VTable0x58(m_currentChunk); + AppendChunk(m_currentChunk); if (!MxPresenter::IsEnabled()) { m_subscriber->FUN_100b8390(m_currentChunk); @@ -166,10 +167,24 @@ void MxMediaPresenter::DoneTickle() EndAction(); } -// OFFSET: LEGO1 0x100b6030 STUB +// OFFSET: LEGO1 0x100b6030 void MxMediaPresenter::Enable(MxBool p_enable) { - // TODO + if (MxPresenter::IsEnabled() != p_enable) { + MxPresenter::Enable(p_enable); + + if (p_enable) { + MxLong time = Timer()->GetTime(); + m_action->SetUnkTimingField(time); + SetTickleState(TickleState_Repeating); + } + else { + if (m_cursor) + m_cursor->Reset(); + m_currentChunk = NULL; + SetTickleState(TickleState_Done); + } + } } // OFFSET: LEGO1 0x100b5700 @@ -208,8 +223,16 @@ void MxMediaPresenter::EndAction() // TODO } -// OFFSET: LEGO1 0x100b5f10 STUB -void MxMediaPresenter::VTable0x58(MxStreamChunk* p_chunk) +// OFFSET: LEGO1 0x100b5f10 +void MxMediaPresenter::AppendChunk(MxStreamChunk* p_chunk) { - // TODO + MxStreamChunk* chunk = new MxStreamChunk; + + MxU32 length = p_chunk->GetLength(); + chunk->SetLength(length); + chunk->SetData(new MxU8[length]); + chunk->SetTime(p_chunk->GetTime()); + + memcpy(chunk->GetData(), p_chunk->GetData(), chunk->GetLength()); + m_chunks->Append(chunk); } diff --git a/LEGO1/mxmediapresenter.h b/LEGO1/mxmediapresenter.h index 4fb35f7b..3706b225 100644 --- a/LEGO1/mxmediapresenter.h +++ b/LEGO1/mxmediapresenter.h @@ -35,7 +35,7 @@ class MxMediaPresenter : public MxPresenter { virtual MxResult StartAction(MxStreamController*, MxDSAction*) override; // vtable+0x3c virtual void EndAction() override; // vtable+0x40 virtual void Enable(MxBool p_enable) override; // vtable+0x54 - virtual void VTable0x58(MxStreamChunk* p_chunk); // vtable+0x58 + virtual void AppendChunk(MxStreamChunk* p_chunk); // vtable+0x58 protected: MxDSSubscriber* m_subscriber; // 0x40 diff --git a/LEGO1/mxstreamchunk.h b/LEGO1/mxstreamchunk.h index 92d7094e..f31f891a 100644 --- a/LEGO1/mxstreamchunk.h +++ b/LEGO1/mxstreamchunk.h @@ -6,6 +6,9 @@ // VTABLE 0x100dc2a8 // SIZE 0x20 class MxStreamChunk : public MxDSChunk { +public: + inline MxStreamChunk() : m_unk1c(NULL) {} + // OFFSET: LEGO1 0x100b1fe0 inline virtual const char* ClassName() const override // vtable+0xc { @@ -19,6 +22,7 @@ class MxStreamChunk : public MxDSChunk { return !strcmp(name, MxStreamChunk::ClassName()) || MxDSChunk::IsA(name); } +private: void* m_unk1c; // 0x1c };