2023-06-29 04:10:08 -04:00
|
|
|
#include "mxsmkpresenter.h"
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
#include "decomp.h"
|
2023-12-21 10:52:42 -05:00
|
|
|
#include "mxdsmediaaction.h"
|
2023-10-30 12:46:38 -04:00
|
|
|
#include "mxvideomanager.h"
|
2023-07-02 03:00:28 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxSmkPresenter, 0x720);
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b3650
|
2023-06-29 04:10:08 -04:00
|
|
|
MxSmkPresenter::MxSmkPresenter()
|
|
|
|
{
|
2023-10-27 13:00:20 -04:00
|
|
|
Init();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b3870
|
2023-10-27 13:00:20 -04:00
|
|
|
MxSmkPresenter::~MxSmkPresenter()
|
|
|
|
{
|
|
|
|
Destroy(TRUE);
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b38d0
|
2023-06-29 04:10:08 -04:00
|
|
|
void MxSmkPresenter::Init()
|
|
|
|
{
|
2023-12-22 14:05:42 -05:00
|
|
|
m_currentFrame = 0;
|
2023-10-27 13:00:20 -04:00
|
|
|
memset(&m_mxSmack, 0, sizeof(m_mxSmack));
|
|
|
|
m_flags &= 0xfd;
|
|
|
|
m_flags &= 0xfb;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b3900
|
2023-10-27 13:00:20 -04:00
|
|
|
void MxSmkPresenter::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
|
|
|
m_criticalSection.Enter();
|
|
|
|
|
2023-12-20 20:07:48 -05:00
|
|
|
MxSmack::Destroy(&m_mxSmack);
|
2023-10-27 13:00:20 -04:00
|
|
|
Init();
|
|
|
|
|
|
|
|
m_criticalSection.Leave();
|
|
|
|
|
|
|
|
if (!p_fromDestructor) {
|
|
|
|
MxVideoPresenter::Destroy(FALSE);
|
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-10-07 12:48:36 -04:00
|
|
|
|
2023-12-20 20:07:48 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b3940
|
2023-11-25 14:08:10 -05:00
|
|
|
void MxSmkPresenter::LoadHeader(MxStreamChunk* p_chunk)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
2023-12-21 21:11:14 -05:00
|
|
|
MxSmack::LoadHeader(p_chunk->GetData(), &m_mxSmack);
|
2023-11-21 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b3960
|
2023-11-25 14:08:10 -05:00
|
|
|
void MxSmkPresenter::CreateBitmap()
|
2023-10-07 12:48:36 -04:00
|
|
|
{
|
2023-11-25 14:08:10 -05:00
|
|
|
if (m_bitmap)
|
2023-10-24 19:38:27 -04:00
|
|
|
delete m_bitmap;
|
2023-10-07 12:48:36 -04:00
|
|
|
|
2023-11-25 14:08:10 -05:00
|
|
|
m_bitmap = new MxBitmap;
|
2023-12-20 20:07:48 -05:00
|
|
|
m_bitmap->SetSize(m_mxSmack.m_smackTag.Width, m_mxSmack.m_smackTag.Height, NULL, FALSE);
|
2023-10-27 13:00:20 -04:00
|
|
|
}
|
|
|
|
|
2023-12-21 10:52:42 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b3a00
|
2023-11-25 14:08:10 -05:00
|
|
|
void MxSmkPresenter::LoadFrame(MxStreamChunk* p_chunk)
|
2023-10-30 12:46:38 -04:00
|
|
|
{
|
2023-12-21 10:52:42 -05:00
|
|
|
MxBITMAPINFO* bitmapInfo = m_bitmap->GetBitmapInfo();
|
|
|
|
MxU8* bitmapData = m_bitmap->GetBitmapData();
|
|
|
|
MxU8* chunkData = p_chunk->GetData();
|
|
|
|
|
2023-12-22 14:05:42 -05:00
|
|
|
MxBool paletteChanged = m_mxSmack.m_frameTypes[m_currentFrame] & 1;
|
|
|
|
m_currentFrame++;
|
2023-12-21 10:52:42 -05:00
|
|
|
VTable0x88();
|
|
|
|
|
|
|
|
MxRectList list(TRUE);
|
2023-12-21 21:11:14 -05:00
|
|
|
MxSmack::LoadFrame(bitmapInfo, bitmapData, &m_mxSmack, chunkData, paletteChanged, &list);
|
2023-12-21 10:52:42 -05:00
|
|
|
|
2023-12-21 21:11:14 -05:00
|
|
|
if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && paletteChanged)
|
2023-12-21 10:52:42 -05:00
|
|
|
RealizePalette();
|
|
|
|
|
|
|
|
MxRect32 invalidateRect;
|
|
|
|
MxRectListCursor cursor(&list);
|
|
|
|
MxRect32* rect;
|
|
|
|
|
|
|
|
while (cursor.Next(rect)) {
|
|
|
|
invalidateRect = *rect;
|
|
|
|
invalidateRect.AddPoint(GetLocation());
|
|
|
|
MVideoManager()->InvalidateRect(invalidateRect);
|
|
|
|
}
|
2023-10-30 12:46:38 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b4260
|
2023-12-20 20:07:48 -05:00
|
|
|
void MxSmkPresenter::VTable0x88()
|
2023-10-30 12:46:38 -04:00
|
|
|
{
|
2023-12-20 20:07:48 -05:00
|
|
|
if ((m_mxSmack.m_smackTag.SmackerType & 1) != 0) {
|
2023-12-22 14:05:42 -05:00
|
|
|
MxU32 und = (m_currentFrame % m_mxSmack.m_smackTag.Frames);
|
|
|
|
if (1 < m_currentFrame && und == 1)
|
|
|
|
m_currentFrame = 1;
|
2023-10-30 12:46:38 -04:00
|
|
|
}
|
|
|
|
else {
|
2023-12-22 14:05:42 -05:00
|
|
|
if (m_mxSmack.m_smackTag.Frames == m_currentFrame) {
|
|
|
|
m_currentFrame = 0;
|
2023-12-20 20:07:48 -05:00
|
|
|
// TODO: struct incorrect, Palette at wrong offset?
|
2023-12-21 21:11:14 -05:00
|
|
|
memset(&m_mxSmack.m_smackTag.Palette[4], 0, sizeof(m_mxSmack.m_smackTag.Palette));
|
2023-10-30 12:46:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b42c0
|
2023-12-07 07:13:31 -05:00
|
|
|
void MxSmkPresenter::RealizePalette()
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
|
|
|
MxPalette* palette = m_bitmap->CreatePalette();
|
|
|
|
MVideoManager()->RealizePalette(palette);
|
|
|
|
delete palette;
|
|
|
|
}
|
|
|
|
|
2023-12-22 14:05:42 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b42f0
|
|
|
|
MxResult MxSmkPresenter::AddToManager()
|
|
|
|
{
|
|
|
|
return MxVideoPresenter::AddToManager();
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b4300
|
2023-11-21 03:44:45 -05:00
|
|
|
void MxSmkPresenter::Destroy()
|
|
|
|
{
|
|
|
|
Destroy(FALSE);
|
|
|
|
}
|