Implement AppendChunk and Enable

This commit is contained in:
Christian Semmler 2023-11-10 06:40:30 -05:00
parent 71e8c25d2a
commit ec5c2177f5
5 changed files with 49 additions and 16 deletions

View File

@ -6,16 +6,16 @@ DECOMP_SIZE_ASSERT(MxDSChunk, 0x1c);
MxDSChunk::MxDSChunk() MxDSChunk::MxDSChunk()
{ {
m_flags = 0; m_flags = 0;
m_unk18 = NULL; m_data = NULL;
m_unk0c = -1; m_unk0c = -1;
m_time = 0; m_time = 0;
m_unk14 = 0; m_length = 0;
} }
// OFFSET: LEGO1 0x100be170 // OFFSET: LEGO1 0x100be170
MxDSChunk::~MxDSChunk() MxDSChunk::~MxDSChunk()
{ {
if (m_flags & Flag_Bit1) { if (m_flags & Flag_Bit1) {
delete[] m_unk18; delete[] m_data;
} }
} }

View File

@ -31,21 +31,27 @@ class MxDSChunk : public MxCore {
return !strcmp(name, MxDSChunk::ClassName()) || MxCore::IsA(name); 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 MxU16 GetFlags() { return m_flags; }
inline MxLong GetTime() { return m_time; } 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) if (m_data)
delete[] m_unk18; delete[] m_data;
} }
private: private:
MxU16 m_flags; // 0x8 MxU16 m_flags; // 0x8
undefined4 m_unk0c; // 0xc undefined4 m_unk0c; // 0xc
MxLong m_time; // 0x10 MxLong m_time; // 0x10
undefined4 m_unk14; // 0x14 MxU32 m_length; // 0x14
MxU8* m_unk18; // 0x18 MxU8* m_data; // 0x18
}; };
#endif // MXDSCHUNK_H #endif // MXDSCHUNK_H

View File

@ -2,6 +2,7 @@
#include "mxautolocker.h" #include "mxautolocker.h"
#include "mxstreamchunk.h" #include "mxstreamchunk.h"
#include "mxtimer.h"
DECOMP_SIZE_ASSERT(MxMediaPresenter, 0x50); DECOMP_SIZE_ASSERT(MxMediaPresenter, 0x50);
@ -46,7 +47,7 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
MxStreamChunk* chunk; MxStreamChunk* chunk;
while (cursor.Next(chunk)) while (cursor.Next(chunk))
chunk->ReleaseUnk18(); chunk->Release();
delete m_chunks; delete m_chunks;
} }
@ -123,7 +124,7 @@ void MxMediaPresenter::StreamingTickle()
m_currentTickleState = TickleState_Repeating; m_currentTickleState = TickleState_Repeating;
} }
else if (m_action->GetFlags() & MxDSAction::Flag_Looping) { else if (m_action->GetFlags() & MxDSAction::Flag_Looping) {
VTable0x58(m_currentChunk); AppendChunk(m_currentChunk);
if (!MxPresenter::IsEnabled()) { if (!MxPresenter::IsEnabled()) {
m_subscriber->FUN_100b8390(m_currentChunk); m_subscriber->FUN_100b8390(m_currentChunk);
@ -166,10 +167,24 @@ void MxMediaPresenter::DoneTickle()
EndAction(); EndAction();
} }
// OFFSET: LEGO1 0x100b6030 STUB // OFFSET: LEGO1 0x100b6030
void MxMediaPresenter::Enable(MxBool p_enable) 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 // OFFSET: LEGO1 0x100b5700
@ -208,8 +223,16 @@ void MxMediaPresenter::EndAction()
// TODO // TODO
} }
// OFFSET: LEGO1 0x100b5f10 STUB // OFFSET: LEGO1 0x100b5f10
void MxMediaPresenter::VTable0x58(MxStreamChunk* p_chunk) 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);
} }

View File

@ -35,7 +35,7 @@ class MxMediaPresenter : public MxPresenter {
virtual MxResult StartAction(MxStreamController*, MxDSAction*) override; // vtable+0x3c virtual MxResult StartAction(MxStreamController*, MxDSAction*) override; // vtable+0x3c
virtual void EndAction() override; // vtable+0x40 virtual void EndAction() override; // vtable+0x40
virtual void Enable(MxBool p_enable) override; // vtable+0x54 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: protected:
MxDSSubscriber* m_subscriber; // 0x40 MxDSSubscriber* m_subscriber; // 0x40

View File

@ -6,6 +6,9 @@
// VTABLE 0x100dc2a8 // VTABLE 0x100dc2a8
// SIZE 0x20 // SIZE 0x20
class MxStreamChunk : public MxDSChunk { class MxStreamChunk : public MxDSChunk {
public:
inline MxStreamChunk() : m_unk1c(NULL) {}
// OFFSET: LEGO1 0x100b1fe0 // OFFSET: LEGO1 0x100b1fe0
inline virtual const char* ClassName() const override // vtable+0xc 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); return !strcmp(name, MxStreamChunk::ClassName()) || MxDSChunk::IsA(name);
} }
private:
void* m_unk1c; // 0x1c void* m_unk1c; // 0x1c
}; };