2023-06-24 13:09:46 -04:00
|
|
|
#include "mxvideomanager.h"
|
2023-09-19 23:00:34 -04:00
|
|
|
#include "mxautolocker.h"
|
|
|
|
#include "mxpresenter.h"
|
2023-10-14 14:46:00 -04:00
|
|
|
#include "mxticklemanager.h"
|
|
|
|
#include "legoomni.h"
|
2023-09-19 23:00:34 -04:00
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100be1f0
|
|
|
|
MxVideoManager::MxVideoManager()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
2023-06-24 13:09:46 -04:00
|
|
|
|
2023-10-14 14:46:00 -04:00
|
|
|
// OFFSET: LEGO1 0x100be2a0
|
2023-06-29 04:10:08 -04:00
|
|
|
MxVideoManager::~MxVideoManager()
|
|
|
|
{
|
2023-10-14 14:46:00 -04:00
|
|
|
Destroy(TRUE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-09-19 23:00:34 -04:00
|
|
|
// OFFSET: LEGO1 0x100bea90
|
2023-09-21 14:51:24 -04:00
|
|
|
MxResult MxVideoManager::Tickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-19 23:00:34 -04:00
|
|
|
MxAutoLocker lock(&this->m_criticalSection);
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2023-09-19 23:00:34 -04:00
|
|
|
SortPresenterList();
|
|
|
|
|
|
|
|
MxPresenter *presenter;
|
|
|
|
MxPresenterListCursor cursor(this->m_presenters);
|
|
|
|
|
|
|
|
while (cursor.Next(presenter))
|
|
|
|
presenter->Tickle();
|
|
|
|
|
|
|
|
cursor.Reset();
|
|
|
|
|
|
|
|
while (cursor.Next(presenter))
|
|
|
|
presenter->PutData();
|
|
|
|
|
|
|
|
UpdateRegion();
|
|
|
|
m_region->Reset();
|
2023-10-07 14:05:45 -04:00
|
|
|
|
2023-09-19 23:00:34 -04:00
|
|
|
return SUCCESS;
|
2023-06-24 13:09:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100be320
|
2023-09-19 23:00:34 -04:00
|
|
|
MxResult MxVideoManager::Init()
|
2023-06-24 13:09:46 -04:00
|
|
|
{
|
2023-07-16 01:51:24 -04:00
|
|
|
this->m_pDirectDraw = NULL;
|
2023-09-19 23:00:34 -04:00
|
|
|
this->m_pDDSurface = NULL;
|
2023-07-21 21:28:13 -04:00
|
|
|
this->m_displaySurface = NULL;
|
2023-09-19 23:00:34 -04:00
|
|
|
this->m_region = NULL;
|
2023-06-24 13:09:46 -04:00
|
|
|
this->m_videoParam.SetPalette(NULL);
|
2023-06-27 22:04:07 -04:00
|
|
|
this->m_unk60 = FALSE;
|
2023-09-19 23:00:34 -04:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-10-14 14:46:00 -04:00
|
|
|
// OFFSET: LEGO1 0x100be340
|
|
|
|
void MxVideoManager::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
|
|
|
if (m_thread) {
|
|
|
|
m_thread->Terminate();
|
|
|
|
delete m_thread;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TickleManager()->UnregisterClient(this);
|
|
|
|
|
|
|
|
m_criticalSection.Enter();
|
|
|
|
|
|
|
|
if (m_displaySurface)
|
|
|
|
delete m_displaySurface;
|
|
|
|
|
|
|
|
if (m_region)
|
|
|
|
delete m_region;
|
|
|
|
|
|
|
|
if (m_videoParam.GetPalette())
|
|
|
|
delete m_videoParam.GetPalette();
|
|
|
|
|
|
|
|
if (m_unk60) {
|
|
|
|
if (m_pDirectDraw)
|
|
|
|
m_pDirectDraw->Release();
|
|
|
|
if (m_pDDSurface)
|
|
|
|
m_pDDSurface->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
Init();
|
|
|
|
m_criticalSection.Leave();
|
|
|
|
|
|
|
|
if (!p_fromDestructor)
|
|
|
|
MxMediaManager::Destroy();
|
|
|
|
}
|
|
|
|
|
2023-09-19 23:00:34 -04:00
|
|
|
// OFFSET: LEGO1 0x100be440
|
|
|
|
void MxVideoManager::SortPresenterList()
|
|
|
|
{
|
|
|
|
if (this->m_presenters->GetCount() <= 1)
|
2023-10-07 14:05:45 -04:00
|
|
|
return;
|
2023-09-19 23:00:34 -04:00
|
|
|
|
|
|
|
MxPresenterListCursor a(this->m_presenters);
|
|
|
|
MxPresenterListCursor b(this->m_presenters);
|
|
|
|
MxU32 count = this->m_presenters->GetCount() - 1;
|
|
|
|
MxBool finished;
|
2023-10-07 14:05:45 -04:00
|
|
|
|
2023-09-19 23:00:34 -04:00
|
|
|
if (count != 0) {
|
|
|
|
do {
|
|
|
|
a.Reset();
|
|
|
|
b.Head();
|
|
|
|
|
|
|
|
finished = TRUE;
|
|
|
|
for (MxU32 i = count; i != 0; i--) {
|
|
|
|
MxPresenter *p_a, *p_b;
|
|
|
|
|
|
|
|
a.Next(p_a);
|
|
|
|
b.Next(p_b);
|
|
|
|
|
|
|
|
if (p_a->GetDisplayZ() < p_b->GetDisplayZ()) {
|
|
|
|
a.SetValue(p_b);
|
|
|
|
b.SetValue(p_a);
|
|
|
|
finished = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!finished && --count != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100be3e0 STUB
|
|
|
|
void MxVideoManager::UpdateRegion()
|
|
|
|
{
|
|
|
|
// TODO
|
2023-06-24 13:09:46 -04:00
|
|
|
}
|
|
|
|
|
2023-10-14 14:46:00 -04:00
|
|
|
// OFFSET: LEGO1 0x100bea50
|
|
|
|
void MxVideoManager::Destroy()
|
|
|
|
{
|
|
|
|
Destroy(FALSE);
|
|
|
|
}
|
|
|
|
|
2023-06-30 14:34:39 -04:00
|
|
|
// OFFSET: LEGO1 0x100bea60 STUB
|
|
|
|
void MxVideoManager::InvalidateRect(MxRect32 &p_rect)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2023-06-24 13:09:46 -04:00
|
|
|
// OFFSET: LEGO1 0x100bebe0
|
2023-07-02 04:05:49 -04:00
|
|
|
MxLong MxVideoManager::RealizePalette(MxPalette *p_palette)
|
2023-06-24 13:09:46 -04:00
|
|
|
{
|
|
|
|
PALETTEENTRY paletteEntries[256];
|
|
|
|
|
|
|
|
this->m_criticalSection.Enter();
|
|
|
|
|
2023-07-21 21:28:13 -04:00
|
|
|
if (p_palette && this->m_videoParam.GetPalette()) {
|
2023-06-24 13:09:46 -04:00
|
|
|
p_palette->GetEntries(paletteEntries);
|
2023-07-21 21:28:13 -04:00
|
|
|
this->m_videoParam.GetPalette()->SetEntries(paletteEntries);
|
|
|
|
this->m_displaySurface->SetPalette(this->m_videoParam.GetPalette());
|
2023-06-24 13:09:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this->m_criticalSection.Leave();
|
|
|
|
return 0;
|
2023-06-27 22:04:07 -04:00
|
|
|
}
|
2023-10-07 14:05:45 -04:00
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100be600 STUB
|
|
|
|
void MxVideoManager::vtable0x28()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100bebe0 STUB
|
|
|
|
MxResult MxVideoManager::vtable0x2c(MxVideoParam& p_videoParam, undefined4 p_unknown1, MxU8 p_unknown2)
|
|
|
|
{
|
|
|
|
return FAILURE;
|
|
|
|
}
|