isle/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp

134 lines
2.7 KiB
C++
Raw Normal View History

#include "mxloopingsmkpresenter.h"
#include "mxautolock.h"
#include "mxdsmediaaction.h"
Implement MxObjectFactory::{MxObjectFactory,Create} + match sizes of Mx.*Presenter objects created by it (#59) * Get Isle building on MinGW32 (#63) * Add MxUnknown100dc6b0::~MxUnknown100dc6b0 stub * Declare destructor of MxOmni and MxTransitionManager in class * inline attribute must go first * Stub LegoState::Vtable0x14 for Act3State * MxStreamer::VTable0x14 is not an override * Stub MxEntity::Destroy for LegoState::Destroy * Stub MxUnknown100dc6e0 for MxSoundManager * ::ClassName and ::IsA are const methods * methods in the class body don't need a namespace * MxSoundManager subclasses MxUnknown100dc6e0 * LegoInputManager subclasses MxPresenter * NotificationId is an enum, and does not need __declspec(dllexport) * Fix final #endif of legoomni.h and mxobjectfactory.h * Add const alternative for LegoOmni::Create and MxVideoParam, only available for MinGW * Alternative approach to MinGW compatibility * MinGW on Linux is case sensitve * Don't delete a member variable. C++ automatically destructs member variables --------- Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com> * MxatomId: implement inline operator== * Add decomp.h header, containing macro's only used when matching the original binaries * Add in-line constructor of MxPresenter * MxMediaPresenter: add members to match size * MxVideoPresenter: add members to match size * MxCompositePresenter: add members to match size * MxFlcPresenter: add members to match size * MxSmkPresenter: add members to match size * MxStillPresenter: add members to match size * MxAudioPresenter: add members to match size * MxWavePresenter: add members to match size * MxMIDIPresenter: add members to match size * MxEventPresenter: add members to match size * MxLoopingFlcPresenter: add members to match size * MxLoopingSmkPresenter: add members to match size * MxLoopingMIDIPresenter: add check for size * Implement MxObjectFactory::{MxObjectFactory,Create} Matching of MxObjectFactory::Create is not good, because none of the other objects have been implemented. * Implement a few MxPresenter methods * Fix size of LegoInputManager * Fix name of first padding member of legoinputmanager.h * add DECOMP_SIZE_ASSERT macro * Use DECOMP_SIZE_ASSERT macro + convert to hexadecimal * fixed minor typos --------- Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com> Co-authored-by: itsmattkc <itsmattkc@gmail.com>
2023-07-02 03:00:28 -04:00
DECOMP_SIZE_ASSERT(MxLoopingSmkPresenter, 0x724);
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// FUNCTION: LEGO1 0x100b48b0
MxLoopingSmkPresenter::MxLoopingSmkPresenter()
{
2023-10-24 19:38:27 -04:00
Init();
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// FUNCTION: LEGO1 0x100b4950
MxLoopingSmkPresenter::~MxLoopingSmkPresenter()
{
2023-10-24 19:38:27 -04:00
Destroy(TRUE);
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// FUNCTION: LEGO1 0x100b49b0
void MxLoopingSmkPresenter::Init()
{
m_elapsedDuration = 0;
SetBit1(FALSE);
SetBit2(FALSE);
}
// FUNCTION: LEGO1 0x100b49d0
void MxLoopingSmkPresenter::Destroy(MxBool p_fromDestructor)
{
m_criticalSection.Enter();
Init();
m_criticalSection.Leave();
if (!p_fromDestructor) {
MxSmkPresenter::Destroy();
}
}
// FUNCTION: LEGO1 0x100b4a00
void MxLoopingSmkPresenter::VTable0x88()
{
if (m_mxSmack.m_smackTag.Frames == m_currentFrame) {
m_currentFrame = 0;
// TODO: struct incorrect, Palette at wrong offset?
memset(&m_mxSmack.m_smackTag.Palette[4], 0, sizeof(m_mxSmack.m_smackTag.Palette));
}
}
// FUNCTION: LEGO1 0x100b4a30
void MxLoopingSmkPresenter::NextFrame()
{
MxStreamChunk* chunk = NextChunk();
if (chunk->GetFlags() & MxDSChunk::c_end) {
ProgressTickleState(e_repeating);
}
else {
LoadFrame(chunk);
LoopChunk(chunk);
m_elapsedDuration += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
}
2024-02-17 10:35:10 -05:00
m_subscriber->FreeDataChunk(chunk);
}
// FUNCTION: LEGO1 0x100b4a90
void MxLoopingSmkPresenter::VTable0x8c()
{
if (m_action->GetDuration() < m_elapsedDuration) {
ProgressTickleState(e_unk5);
}
else {
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
LoadFrame(chunk);
m_elapsedDuration += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
}
}
// FUNCTION: LEGO1 0x100b4b00
void MxLoopingSmkPresenter::RepeatingTickle()
{
for (MxS16 i = 0; i < m_unk0x5c; i++) {
if (!m_loopingChunkCursor->HasMatch()) {
MxStreamChunk* chunk;
MxStreamChunkListCursor cursor(m_loopingChunks);
cursor.Last(chunk);
MxLong time = chunk->GetTime();
cursor.First(chunk);
time -= chunk->GetTime();
time += 1000 / ((MxDSMediaAction*) m_action)->GetFramesPerSecond();
cursor.Reset();
while (cursor.Next(chunk)) {
chunk->SetTime(chunk->GetTime() + time);
}
m_loopingChunkCursor->Next();
}
MxStreamChunk* chunk;
m_loopingChunkCursor->Current(chunk);
if (m_action->GetElapsedTime() < chunk->GetTime()) {
break;
}
VTable0x8c();
m_loopingChunkCursor->Next(chunk);
if (m_currentTickleState != e_repeating) {
break;
}
}
}
// FUNCTION: LEGO1 0x100b4cd0
MxResult MxLoopingSmkPresenter::AddToManager()
{
AUTOLOCK(m_criticalSection);
return MxSmkPresenter::AddToManager();
}
// FUNCTION: LEGO1 0x100b4d40
void MxLoopingSmkPresenter::Destroy()
{
Destroy(FALSE);
}