Implement/match MxMediaPresenter::Tickle and related (#277)

* Bootstrap MxMediaPresenter

* Implement/match MxMediaPresenter::Tickle and related

* Implement AppendChunk and Enable
This commit is contained in:
Christian Semmler
2023-11-13 06:25:27 -05:00
committed by GitHub
parent a087c666b4
commit ba82821501
9 changed files with 194 additions and 43 deletions

View File

@@ -5,6 +5,7 @@
#include "mxcompositepresenter.h"
#include "mxnotificationmanager.h"
#include "mxstreamchunk.h"
#include "mxtimer.h"
DECOMP_SIZE_ASSERT(MxMediaPresenter, 0x50);
@@ -49,8 +50,7 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
MxStreamChunk* chunk;
while (cursor.Next(chunk))
if (chunk->m_unk18)
delete[] chunk->m_unk18;
chunk->Release();
delete m_chunks;
}
@@ -62,23 +62,104 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
MxPresenter::Destroy();
}
// OFFSET: LEGO1 0x100b5d10 STUB
// OFFSET: LEGO1 0x100b5650
MxStreamChunk* MxMediaPresenter::FUN_100b5650()
{
MxStreamChunk* result = NULL;
if (m_subscriber) {
result = m_subscriber->FUN_100b8360();
if (result && result->GetFlags() & MxDSChunk::Flag_Bit3) {
m_action->SetFlags(m_action->GetFlags() | MxDSAction::Flag_Bit7);
m_subscriber->FUN_100b8250();
m_subscriber->FUN_100b8390(result);
result = NULL;
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
m_currentTickleState = TickleState_Done;
}
}
return result;
}
// OFFSET: LEGO1 0x100b56b0
MxStreamChunk* MxMediaPresenter::NextChunk()
{
MxStreamChunk* result = NULL;
if (m_subscriber) {
result = m_subscriber->FUN_100b8250();
if (result && result->GetFlags() & MxDSChunk::Flag_Bit3) {
m_action->SetFlags(m_action->GetFlags() | MxDSAction::Flag_Bit7);
m_subscriber->FUN_100b8390(result);
result = NULL;
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
m_currentTickleState = TickleState_Done;
}
}
return result;
}
// OFFSET: LEGO1 0x100b5d10
MxResult MxMediaPresenter::Tickle()
{
// TODO
return SUCCESS;
MxAutoLocker lock(&m_criticalSection);
FUN_100b5650();
return MxPresenter::Tickle();
}
// OFFSET: LEGO1 0x100b5d90 STUB
// OFFSET: LEGO1 0x100b5d90
void MxMediaPresenter::StreamingTickle()
{
// TODO
if (!m_currentChunk) {
m_currentChunk = NextChunk();
if (m_currentChunk) {
if (m_currentChunk->GetFlags() & MxDSChunk::Flag_Bit2) {
m_subscriber->FUN_100b8390(m_currentChunk);
m_currentChunk = NULL;
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
m_currentTickleState = TickleState_Repeating;
}
else if (m_action->GetFlags() & MxDSAction::Flag_Looping) {
AppendChunk(m_currentChunk);
if (!MxPresenter::IsEnabled()) {
m_subscriber->FUN_100b8390(m_currentChunk);
m_currentChunk = NULL;
}
}
}
}
}
// OFFSET: LEGO1 0x100b5e10 STUB
// OFFSET: LEGO1 0x100b5e10
void MxMediaPresenter::RepeatingTickle()
{
// TODO
if (MxPresenter::IsEnabled() && !m_currentChunk) {
if (m_cursor)
if (!m_cursor->Next(m_currentChunk))
m_cursor->Next(m_currentChunk);
if (m_currentChunk) {
MxLong time = m_currentChunk->GetTime();
if (time <= m_action->GetElapsedTime() % m_action->GetLoopCount()) {
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
m_currentTickleState = TickleState_unk5;
}
}
else {
if (m_action->GetElapsedTime() <= m_action->GetStartTime() + m_action->GetDuration()) {
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
m_currentTickleState = TickleState_unk5;
}
}
}
}
// OFFSET: LEGO1 0x100b5ef0
@@ -89,10 +170,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
@@ -158,8 +253,16 @@ void MxMediaPresenter::EndAction()
}
}
// OFFSET: LEGO1 0x100b5f10 STUB
void MxMediaPresenter::VTable0x58()
// 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);
}