mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-24 17:04:17 +00:00
Reorganize sources and files (#414)
* Reorganize sources * Refactor * Remove relative paths * Renames * Fix gitignore * Remove stuff * Try fixing format script * Fix format * Fix format * Fix naming script * Test format * Fix format
This commit is contained in:
committed by
GitHub
parent
6a85e62406
commit
c47206617d
103
LEGO1/omni/src/common/mxatomid.cpp
Normal file
103
LEGO1/omni/src/common/mxatomid.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include "mxatomid.h"
|
||||
|
||||
#include "mxomni.h"
|
||||
|
||||
// FUNCTION: LEGO1 0x100acf90
|
||||
MxAtomId::MxAtomId(const char* p_str, LookupMode p_mode)
|
||||
{
|
||||
if (!MxOmni::GetInstance())
|
||||
return;
|
||||
|
||||
if (!AtomIdCounterSet())
|
||||
return;
|
||||
|
||||
MxAtomIdCounter* counter = GetCounter(p_str, p_mode);
|
||||
m_internal = counter->GetKey()->GetData();
|
||||
counter->Inc();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100acfd0
|
||||
MxAtomId::~MxAtomId()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100acfe0
|
||||
void MxAtomId::Destroy()
|
||||
{
|
||||
if (!m_internal)
|
||||
return;
|
||||
|
||||
if (!MxOmni::GetInstance())
|
||||
return;
|
||||
|
||||
if (!AtomIdCounterSet())
|
||||
return;
|
||||
|
||||
#ifdef COMPAT_MODE
|
||||
MxAtomIdCounterSet::iterator it;
|
||||
{
|
||||
MxAtomIdCounter id_counter(m_internal);
|
||||
it = AtomIdCounterSet()->find(&id_counter);
|
||||
}
|
||||
#else
|
||||
MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(&MxAtomIdCounter(m_internal));
|
||||
#endif
|
||||
|
||||
MxAtomIdCounter* counter = (MxAtomIdCounter*) (*it);
|
||||
counter->Dec();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ad1c0
|
||||
MxAtomId& MxAtomId::operator=(const MxAtomId& p_atomId)
|
||||
{
|
||||
if (m_internal)
|
||||
Destroy();
|
||||
|
||||
if (p_atomId.m_internal && MxOmni::GetInstance() && AtomIdCounterSet()) {
|
||||
MxAtomIdCounter* counter = GetCounter(p_atomId.m_internal, LookupMode_Exact);
|
||||
counter->Inc();
|
||||
}
|
||||
|
||||
m_internal = p_atomId.m_internal;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ad210
|
||||
MxAtomIdCounter* MxAtomId::GetCounter(const char* p_str, LookupMode p_mode)
|
||||
{
|
||||
MxAtomId unused;
|
||||
MxAtomIdCounter* counter = new MxAtomIdCounter(p_str);
|
||||
|
||||
switch (p_mode) {
|
||||
case LookupMode_LowerCase:
|
||||
case LookupMode_LowerCase2:
|
||||
counter->GetKey()->ToLowerCase();
|
||||
break;
|
||||
case LookupMode_UpperCase:
|
||||
counter->GetKey()->ToUpperCase();
|
||||
break;
|
||||
}
|
||||
|
||||
MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(counter);
|
||||
if (it != AtomIdCounterSet()->end()) {
|
||||
// Counter already in the set. Delete temp value and return it.
|
||||
delete counter;
|
||||
counter = *it;
|
||||
}
|
||||
else {
|
||||
// Counter is not in the set. Add it.
|
||||
AtomIdCounterSet()->insert(counter);
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ad7e0
|
||||
void MxAtomId::Clear()
|
||||
{
|
||||
// Reset but do not delete MxAtomId object.
|
||||
Destroy();
|
||||
m_internal = NULL;
|
||||
}
|
||||
19
LEGO1/omni/src/common/mxatomidcounter.cpp
Normal file
19
LEGO1/omni/src/common/mxatomidcounter.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "mxatomidcounter.h"
|
||||
|
||||
#include "decomp.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxAtomIdCounter, 0x14);
|
||||
DECOMP_SIZE_ASSERT(MxAtomIdCounterSet, 0x10);
|
||||
|
||||
// FUNCTION: LEGO1 0x100ad7f0
|
||||
void MxAtomIdCounter::Inc()
|
||||
{
|
||||
m_value++;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ad800
|
||||
void MxAtomIdCounter::Dec()
|
||||
{
|
||||
if (m_value)
|
||||
m_value--;
|
||||
}
|
||||
172
LEGO1/omni/src/common/mxcompositemediapresenter.cpp
Normal file
172
LEGO1/omni/src/common/mxcompositemediapresenter.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
#include "mxcompositemediapresenter.h"
|
||||
|
||||
#include "legoomni.h"
|
||||
#include "legosoundmanager.h"
|
||||
#include "legovideomanager.h"
|
||||
#include "mxautolocker.h"
|
||||
#include "mxdsmultiaction.h"
|
||||
#include "mxmediapresenter.h"
|
||||
#include "mxobjectfactory.h"
|
||||
#include "mxtimer.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxCompositeMediaPresenter, 0x50)
|
||||
|
||||
// FUNCTION: LEGO1 0x10073ea0
|
||||
MxCompositeMediaPresenter::MxCompositeMediaPresenter()
|
||||
{
|
||||
m_unk0x4c = 0;
|
||||
m_unk0x4e = FALSE;
|
||||
VideoManager()->AddPresenter(*this);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10074020
|
||||
MxCompositeMediaPresenter::~MxCompositeMediaPresenter()
|
||||
{
|
||||
VideoManager()->RemovePresenter(*this);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10074090
|
||||
MxResult MxCompositeMediaPresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action)
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
MxResult result = FAILURE;
|
||||
MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
|
||||
MxDSActionListCursor cursor(actions);
|
||||
MxDSAction* action;
|
||||
|
||||
if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
|
||||
// The usual cursor.Next() loop doesn't match here, even though
|
||||
// the logic is the same. It does match when "deconstructed" into
|
||||
// the following Head(), Current() and NextFragment() calls,
|
||||
// but this seems unlikely to be the original code.
|
||||
// The alpha debug build also uses Next().
|
||||
// cursor.Head();
|
||||
// while (cursor.Current(action)) {
|
||||
// cursor.NextFragment();
|
||||
while (cursor.Next(action)) {
|
||||
MxBool success = FALSE;
|
||||
|
||||
action->CopyFlags(m_action->GetFlags());
|
||||
|
||||
const char* presenterName = PresenterNameDispatch(*action);
|
||||
MxPresenter* presenter = (MxPresenter*) ObjectFactory()->Create(presenterName);
|
||||
|
||||
if (presenter && presenter->AddToManager() == SUCCESS) {
|
||||
presenter->SetCompositePresenter(this);
|
||||
if (presenter->StartAction(p_controller, action) == SUCCESS) {
|
||||
presenter->SetTickleState(TickleState_Idle);
|
||||
|
||||
if (presenter->IsA("MxVideoPresenter"))
|
||||
VideoManager()->RemovePresenter(*presenter);
|
||||
else if (presenter->IsA("MxAudioPresenter"))
|
||||
SoundManager()->RemovePresenter(*presenter);
|
||||
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (success) {
|
||||
action->SetOrigin(this);
|
||||
m_list.push_back(presenter);
|
||||
}
|
||||
else if (presenter)
|
||||
delete presenter;
|
||||
}
|
||||
|
||||
if (!m_compositePresenter) {
|
||||
SetTickleState(TickleState_Ready);
|
||||
MxLong time = Timer()->GetTime();
|
||||
m_action->SetUnknown90(time);
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100742e0
|
||||
void MxCompositeMediaPresenter::StartingTickle()
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
if (!m_unk0x4e) {
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
if ((*it)->GetCurrentTickleState() < TickleState_Streaming) {
|
||||
(*it)->Tickle();
|
||||
|
||||
if ((*it)->GetCurrentTickleState() == TickleState_Streaming ||
|
||||
((*it)->GetAction() && (*it)->GetAction()->GetStartTime()))
|
||||
m_unk0x4c++;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_list.size() == m_unk0x4c) {
|
||||
m_unk0x4e = TRUE;
|
||||
m_unk0x4c = 0;
|
||||
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
if (!(*it)->GetAction()->GetStartTime())
|
||||
m_unk0x4c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
if (!(*it)->GetAction()->GetStartTime() && ((MxMediaPresenter*) *it)->FUN_100b5650() &&
|
||||
!((*it)->GetAction()->GetFlags() & MxDSAction::Flag_Bit9)) {
|
||||
(*it)->Tickle();
|
||||
(*it)->GetAction()->SetFlags((*it)->GetAction()->GetFlags() | MxDSAction::Flag_Bit9);
|
||||
m_unk0x4c--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_unk0x4c) {
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Streaming;
|
||||
MxLong time = Timer()->GetTime();
|
||||
m_action->SetUnknown90(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10074470
|
||||
MxResult MxCompositeMediaPresenter::Tickle()
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
switch (m_currentTickleState) {
|
||||
case TickleState_Ready:
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Starting;
|
||||
case TickleState_Starting:
|
||||
StartingTickle();
|
||||
break;
|
||||
case TickleState_Streaming:
|
||||
case TickleState_Repeating:
|
||||
case TickleState_unk5:
|
||||
case TickleState_Done: {
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++)
|
||||
(*it)->Tickle();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10074540
|
||||
MxResult MxCompositeMediaPresenter::PutData()
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
if (m_currentTickleState >= TickleState_Streaming && m_currentTickleState <= TickleState_Done) {
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++)
|
||||
(*it)->PutData();
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
265
LEGO1/omni/src/common/mxcompositepresenter.cpp
Normal file
265
LEGO1/omni/src/common/mxcompositepresenter.cpp
Normal file
@@ -0,0 +1,265 @@
|
||||
#include "mxcompositepresenter.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxautolocker.h"
|
||||
#include "mxdsmultiaction.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
#include "mxobjectfactory.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxCompositePresenter, 0x4c);
|
||||
|
||||
// FUNCTION: LEGO1 0x1000caf0
|
||||
MxBool MxCompositePresenter::VTable0x64(undefined4 p_undefined)
|
||||
{
|
||||
if (m_compositePresenter)
|
||||
return m_compositePresenter->VTable0x64(p_undefined);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b60b0
|
||||
MxCompositePresenter::MxCompositePresenter()
|
||||
{
|
||||
NotificationManager()->Register(this);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6390
|
||||
MxCompositePresenter::~MxCompositePresenter()
|
||||
{
|
||||
NotificationManager()->Unregister(this);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6410
|
||||
MxResult MxCompositePresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action)
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
MxResult result = FAILURE;
|
||||
MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
|
||||
MxObjectFactory* factory = ObjectFactory();
|
||||
MxDSActionListCursor cursor(actions);
|
||||
MxDSAction* action;
|
||||
|
||||
if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
|
||||
// The usual cursor.Next() loop doesn't match here, even though
|
||||
// the logic is the same. It does match when "deconstructed" into
|
||||
// the following Head(), Current() and NextFragment() calls,
|
||||
// but this seems unlikely to be the original code.
|
||||
// The alpha debug build also uses Next().
|
||||
cursor.Head();
|
||||
while (cursor.Current(action)) {
|
||||
cursor.NextFragment();
|
||||
|
||||
MxBool success = FALSE;
|
||||
|
||||
action->CopyFlags(m_action->GetFlags());
|
||||
|
||||
const char* presenterName = PresenterNameDispatch(*action);
|
||||
MxPresenter* presenter = (MxPresenter*) factory->Create(presenterName);
|
||||
|
||||
if (presenter && presenter->AddToManager() == SUCCESS) {
|
||||
presenter->SetCompositePresenter(this);
|
||||
if (presenter->StartAction(p_controller, action) == SUCCESS)
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
action->SetOrigin(this);
|
||||
m_list.push_back(presenter);
|
||||
}
|
||||
else if (presenter)
|
||||
delete presenter;
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b65e0
|
||||
void MxCompositePresenter::EndAction()
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
if (!m_action)
|
||||
return;
|
||||
|
||||
((MxDSMultiAction*) m_action)->GetActionList()->DeleteAll(FALSE);
|
||||
|
||||
while (!m_list.empty()) {
|
||||
MxPresenter* presenter = m_list.front();
|
||||
m_list.pop_front();
|
||||
presenter->SetCompositePresenter(NULL);
|
||||
presenter->EndAction();
|
||||
}
|
||||
|
||||
MxDSAction* action = m_action;
|
||||
MxPresenter::EndAction();
|
||||
|
||||
if (action && action->GetOrigin()) {
|
||||
#ifdef COMPAT_MODE
|
||||
{
|
||||
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
|
||||
NotificationManager()->Send(action->GetOrigin(), ¶m);
|
||||
}
|
||||
#else
|
||||
NotificationManager()->Send(
|
||||
action->GetOrigin(),
|
||||
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6760
|
||||
MxLong MxCompositePresenter::Notify(MxParam& p_param)
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
switch (((MxNotificationParam&) p_param).GetNotification()) {
|
||||
case c_notificationEndAction:
|
||||
VTable0x58((MxEndActionNotificationParam&) p_param);
|
||||
break;
|
||||
case MXPRESENTER_NOTIFICATION:
|
||||
VTable0x5c((MxNotificationParam&) p_param);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b67f0
|
||||
void MxCompositePresenter::VTable0x58(MxEndActionNotificationParam& p_param)
|
||||
{
|
||||
MxPresenter* presenter = (MxPresenter*) p_param.GetSender();
|
||||
MxDSAction* action = p_param.GetAction();
|
||||
MxCompositePresenterList::iterator it;
|
||||
|
||||
if (!m_list.empty()) {
|
||||
for (it = m_list.begin(); it != m_list.end(); it++) {
|
||||
if (*it == presenter) {
|
||||
m_list.erase(it++);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_action) {
|
||||
MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList();
|
||||
MxDSActionListCursor cursor(actions);
|
||||
|
||||
if (cursor.Find(action))
|
||||
cursor.Detach();
|
||||
}
|
||||
|
||||
if (presenter)
|
||||
delete presenter;
|
||||
|
||||
if (action)
|
||||
delete action;
|
||||
|
||||
if (m_list.empty()) {
|
||||
EndAction();
|
||||
}
|
||||
else {
|
||||
if (m_action->IsA("MxDSSerialAction") && it != m_list.end()) {
|
||||
MxPresenter* presenter = *it;
|
||||
if (presenter->GetCurrentTickleState() == TickleState_Idle)
|
||||
presenter->SetTickleState(TickleState_Ready);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b69b0
|
||||
void MxCompositePresenter::VTable0x5c(MxNotificationParam& p_param)
|
||||
{
|
||||
if (!m_list.empty()) {
|
||||
MxPresenter* presenter = (MxPresenter*) p_param.GetSender();
|
||||
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
if (*it == presenter) {
|
||||
m_list.erase(it++);
|
||||
|
||||
if (presenter->GetCurrentTickleState() == TickleState_Idle)
|
||||
presenter->SetTickleState(TickleState_Ready);
|
||||
|
||||
MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList();
|
||||
MxDSActionListCursor cursor(actions);
|
||||
|
||||
if (cursor.Find(presenter->GetAction()))
|
||||
cursor.Detach();
|
||||
|
||||
if (m_list.empty()) {
|
||||
EndAction();
|
||||
}
|
||||
else {
|
||||
if (m_action->IsA("MxDSSerialAction")) {
|
||||
MxPresenter* presenter = *it;
|
||||
if (presenter->GetCurrentTickleState() == TickleState_Idle)
|
||||
presenter->SetTickleState(TickleState_Ready);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NotificationManager()->Send(this, &p_param);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6b40
|
||||
void MxCompositePresenter::VTable0x60(MxPresenter* p_presenter)
|
||||
{
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
if (*it == p_presenter) {
|
||||
if (++it == m_list.end()) {
|
||||
if (m_compositePresenter)
|
||||
m_compositePresenter->VTable0x60(this);
|
||||
}
|
||||
else if (m_action->IsA("MxDSSerialAction")) {
|
||||
MxPresenter* presenter = *it;
|
||||
if (presenter->GetCurrentTickleState() == TickleState_Idle)
|
||||
presenter->SetTickleState(TickleState_Ready);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6bc0
|
||||
void MxCompositePresenter::SetTickleState(TickleState p_tickleState)
|
||||
{
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = p_tickleState;
|
||||
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
MxPresenter* presenter = *it;
|
||||
presenter->SetTickleState(p_tickleState);
|
||||
|
||||
if (m_action->IsA("MxDSSerialAction") && p_tickleState == TickleState_Ready)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6c30
|
||||
void MxCompositePresenter::Enable(MxBool p_enable)
|
||||
{
|
||||
MxPresenter::Enable(p_enable);
|
||||
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
MxPresenter* presenter = *it;
|
||||
presenter->Enable(p_enable);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6c80
|
||||
MxBool MxCompositePresenter::HasTickleStatePassed(TickleState p_tickleState)
|
||||
{
|
||||
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
MxPresenter* presenter = *it;
|
||||
if (!presenter->HasTickleStatePassed(p_tickleState))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
27
LEGO1/omni/src/common/mxcore.cpp
Normal file
27
LEGO1/omni/src/common/mxcore.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "mxcore.h"
|
||||
|
||||
#include "define.h"
|
||||
|
||||
// FUNCTION: LEGO1 0x10001f70
|
||||
MxResult MxCore::Tickle()
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae1a0
|
||||
MxCore::MxCore()
|
||||
{
|
||||
m_id = (MxU32) g_mxcoreCount[0];
|
||||
g_mxcoreCount[0]++;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae1e0
|
||||
MxCore::~MxCore()
|
||||
{
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae1f0
|
||||
MxLong MxCore::Notify(MxParam& p_param)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
104
LEGO1/omni/src/common/mxmediamanager.cpp
Normal file
104
LEGO1/omni/src/common/mxmediamanager.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include "mxmediamanager.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxautolocker.h"
|
||||
#include "mxomni.h"
|
||||
#include "mxpresenter.h"
|
||||
#include "mxticklemanager.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxMediaManager, 0x2c);
|
||||
DECOMP_SIZE_ASSERT(MxPresenterList, 0x18);
|
||||
DECOMP_SIZE_ASSERT(MxPresenterListCursor, 0x10);
|
||||
|
||||
// FUNCTION: LEGO1 0x100b84c0
|
||||
MxMediaManager::MxMediaManager()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b8560
|
||||
MxMediaManager::~MxMediaManager()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b85d0
|
||||
MxResult MxMediaManager::Init()
|
||||
{
|
||||
this->m_presenters = NULL;
|
||||
this->m_thread = NULL;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b85e0
|
||||
MxResult MxMediaManager::InitPresenters()
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
|
||||
this->m_presenters = new MxPresenterList;
|
||||
|
||||
if (!this->m_presenters) {
|
||||
this->Destroy();
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b8710
|
||||
void MxMediaManager::Destroy()
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
|
||||
if (this->m_presenters)
|
||||
delete this->m_presenters;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b8790
|
||||
MxResult MxMediaManager::Tickle()
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
MxPresenter* presenter;
|
||||
MxPresenterListCursor cursor(this->m_presenters);
|
||||
|
||||
while (cursor.Next(presenter))
|
||||
presenter->Tickle();
|
||||
|
||||
cursor.Reset();
|
||||
|
||||
while (cursor.Next(presenter))
|
||||
presenter->PutData();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b88c0
|
||||
void MxMediaManager::AddPresenter(MxPresenter& p_presenter)
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
|
||||
this->m_presenters->Append(&p_presenter);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b8980
|
||||
void MxMediaManager::RemovePresenter(MxPresenter& p_presenter)
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
MxPresenterListCursor cursor(this->m_presenters);
|
||||
|
||||
if (cursor.Find(&p_presenter))
|
||||
cursor.Detach();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b8ac0
|
||||
void MxMediaManager::StopPresenters()
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
MxPresenter* presenter;
|
||||
MxPresenterListCursor cursor(this->m_presenters);
|
||||
|
||||
while (cursor.Next(presenter))
|
||||
presenter->EndAction();
|
||||
}
|
||||
277
LEGO1/omni/src/common/mxmediapresenter.cpp
Normal file
277
LEGO1/omni/src/common/mxmediapresenter.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
#include "mxmediapresenter.h"
|
||||
|
||||
#include "mxactionnotificationparam.h"
|
||||
#include "mxautolocker.h"
|
||||
#include "mxcompositepresenter.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
#include "mxstreamchunk.h"
|
||||
#include "mxtimer.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxMediaPresenter, 0x50);
|
||||
DECOMP_SIZE_ASSERT(MxStreamChunkList, 0x18);
|
||||
DECOMP_SIZE_ASSERT(MxStreamChunkListCursor, 0x10);
|
||||
|
||||
// FUNCTION: LEGO1 0x1000c550
|
||||
MxMediaPresenter::~MxMediaPresenter()
|
||||
{
|
||||
Destroy(TRUE);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000c5b0
|
||||
void MxMediaPresenter::Destroy()
|
||||
{
|
||||
Destroy(FALSE);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b54e0
|
||||
void MxMediaPresenter::Init()
|
||||
{
|
||||
this->m_subscriber = NULL;
|
||||
this->m_chunks = NULL;
|
||||
this->m_cursor = NULL;
|
||||
this->m_currentChunk = NULL;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b54f0
|
||||
void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
|
||||
{
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
if (m_currentChunk && m_subscriber)
|
||||
m_subscriber->FUN_100b8390(m_currentChunk);
|
||||
|
||||
if (m_subscriber)
|
||||
delete m_subscriber;
|
||||
|
||||
if (m_cursor)
|
||||
delete m_cursor;
|
||||
|
||||
if (m_chunks) {
|
||||
MxStreamChunkListCursor cursor(m_chunks);
|
||||
MxStreamChunk* chunk;
|
||||
|
||||
while (cursor.Next(chunk))
|
||||
chunk->Release();
|
||||
|
||||
delete m_chunks;
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
if (!p_fromDestructor)
|
||||
MxPresenter::Destroy();
|
||||
}
|
||||
|
||||
// FUNCTION: 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;
|
||||
}
|
||||
|
||||
// FUNCTION: 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;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5700
|
||||
MxResult MxMediaPresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
|
||||
if (m_action->GetFlags() & MxDSAction::Flag_Looping) {
|
||||
m_chunks = new MxStreamChunkList;
|
||||
m_cursor = new MxStreamChunkListCursor(m_chunks);
|
||||
|
||||
if (!m_chunks && !m_cursor)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (p_controller) {
|
||||
m_subscriber = new MxDSSubscriber;
|
||||
|
||||
if (!m_subscriber ||
|
||||
m_subscriber->Create(p_controller, p_action->GetObjectId(), p_action->GetUnknown24()) != SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
}
|
||||
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5bc0
|
||||
void MxMediaPresenter::EndAction()
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
if (!m_action)
|
||||
return;
|
||||
|
||||
m_currentChunk = NULL;
|
||||
|
||||
if (m_action->GetFlags() & MxDSAction::Flag_World &&
|
||||
(!m_compositePresenter || !m_compositePresenter->VTable0x64(2))) {
|
||||
MxPresenter::Enable(FALSE);
|
||||
SetTickleState(TickleState_Idle);
|
||||
}
|
||||
else {
|
||||
MxDSAction* action = m_action;
|
||||
MxPresenter::EndAction();
|
||||
|
||||
if (m_subscriber) {
|
||||
delete m_subscriber;
|
||||
m_subscriber = NULL;
|
||||
}
|
||||
|
||||
if (action && action->GetOrigin()) {
|
||||
#ifdef COMPAT_MODE
|
||||
{
|
||||
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
|
||||
NotificationManager()->Send(action->GetOrigin(), ¶m);
|
||||
}
|
||||
#else
|
||||
NotificationManager()->Send(
|
||||
action->GetOrigin(),
|
||||
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5d10
|
||||
MxResult MxMediaPresenter::Tickle()
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
FUN_100b5650();
|
||||
|
||||
return MxPresenter::Tickle();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5d90
|
||||
void MxMediaPresenter::StreamingTickle()
|
||||
{
|
||||
if (!m_currentChunk) {
|
||||
m_currentChunk = NextChunk();
|
||||
|
||||
if (m_currentChunk) {
|
||||
if (m_currentChunk->GetFlags() & MxDSChunk::Flag_End) {
|
||||
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 (!IsEnabled()) {
|
||||
m_subscriber->FUN_100b8390(m_currentChunk);
|
||||
m_currentChunk = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5e10
|
||||
void MxMediaPresenter::RepeatingTickle()
|
||||
{
|
||||
if (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5ef0
|
||||
void MxMediaPresenter::DoneTickle()
|
||||
{
|
||||
m_previousTickleStates |= 1 << m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Idle;
|
||||
EndAction();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5f10
|
||||
void MxMediaPresenter::AppendChunk(MxStreamChunk* p_chunk)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b6030
|
||||
void MxMediaPresenter::Enable(MxBool p_enable)
|
||||
{
|
||||
if (IsEnabled() != p_enable) {
|
||||
MxPresenter::Enable(p_enable);
|
||||
|
||||
if (p_enable) {
|
||||
MxLong time = Timer()->GetTime();
|
||||
m_action->SetUnknown90(time);
|
||||
SetTickleState(TickleState_Repeating);
|
||||
}
|
||||
else {
|
||||
if (m_cursor)
|
||||
m_cursor->Reset();
|
||||
m_currentChunk = NULL;
|
||||
SetTickleState(TickleState_Done);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
LEGO1/omni/src/common/mxobjectfactory.cpp
Normal file
49
LEGO1/omni/src/common/mxobjectfactory.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "mxobjectfactory.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxcompositepresenter.h"
|
||||
#include "mxeventpresenter.h"
|
||||
#include "mxflcpresenter.h"
|
||||
#include "mxloopingflcpresenter.h"
|
||||
#include "mxloopingmidipresenter.h"
|
||||
#include "mxloopingsmkpresenter.h"
|
||||
#include "mxmidipresenter.h"
|
||||
#include "mxpresenter.h"
|
||||
#include "mxsmkpresenter.h"
|
||||
#include "mxstillpresenter.h"
|
||||
#include "mxvideopresenter.h"
|
||||
#include "mxwavepresenter.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxObjectFactory, 0x38); // 100af1db
|
||||
|
||||
// FUNCTION: LEGO1 0x100b0d80
|
||||
MxObjectFactory::MxObjectFactory()
|
||||
{
|
||||
#define X(V) this->m_id##V = MxAtomId(#V, LookupMode_Exact);
|
||||
FOR_MXOBJECTFACTORY_OBJECTS(X)
|
||||
#undef X
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b12c0
|
||||
MxCore* MxObjectFactory::Create(const char* p_name)
|
||||
{
|
||||
MxCore* object = NULL;
|
||||
MxAtomId atom(p_name, LookupMode_Exact);
|
||||
|
||||
if (0) {
|
||||
}
|
||||
#define X(V) \
|
||||
else if (this->m_id##V == atom) \
|
||||
{ \
|
||||
object = new V; \
|
||||
}
|
||||
FOR_MXOBJECTFACTORY_OBJECTS(X)
|
||||
#undef X
|
||||
return object;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b1a30
|
||||
void MxObjectFactory::Destroy(MxCore* p_object)
|
||||
{
|
||||
delete p_object;
|
||||
}
|
||||
348
LEGO1/omni/src/common/mxpresenter.cpp
Normal file
348
LEGO1/omni/src/common/mxpresenter.cpp
Normal file
@@ -0,0 +1,348 @@
|
||||
#include "mxpresenter.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "define.h"
|
||||
#include "legoobjectfactory.h"
|
||||
#include "legoomni.h"
|
||||
#include "mxactionnotificationparam.h"
|
||||
#include "mxautolocker.h"
|
||||
#include "mxcompositepresenter.h"
|
||||
#include "mxdsanim.h"
|
||||
#include "mxdssound.h"
|
||||
#include "mxentity.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
#include "mxparam.h"
|
||||
#include "mxstreamer.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxPresenter, 0x40);
|
||||
|
||||
// FUNCTION: LEGO1 0x1000be30
|
||||
void MxPresenter::VTable0x14()
|
||||
{
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000be40
|
||||
void MxPresenter::ReadyTickle()
|
||||
{
|
||||
ParseExtra();
|
||||
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Starting;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000be60
|
||||
void MxPresenter::StartingTickle()
|
||||
{
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Streaming;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000be80
|
||||
void MxPresenter::StreamingTickle()
|
||||
{
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Repeating;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bea0
|
||||
void MxPresenter::RepeatingTickle()
|
||||
{
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = TickleState_unk5;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bec0
|
||||
void MxPresenter::Unk5Tickle()
|
||||
{
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Done;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bee0
|
||||
void MxPresenter::DoneTickle()
|
||||
{
|
||||
m_previousTickleStates |= 1 << m_currentTickleState;
|
||||
m_currentTickleState = TickleState_Idle;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bf00
|
||||
MxPresenter::~MxPresenter()
|
||||
{
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bf70
|
||||
MxResult MxPresenter::AddToManager()
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bf80
|
||||
void MxPresenter::Destroy()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bf90
|
||||
void MxPresenter::SetTickleState(TickleState p_tickleState)
|
||||
{
|
||||
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
||||
m_currentTickleState = p_tickleState;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bfb0
|
||||
MxBool MxPresenter::HasTickleStatePassed(TickleState p_tickleState)
|
||||
{
|
||||
return m_previousTickleStates & (1 << (unsigned char) p_tickleState);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bfc0
|
||||
MxResult MxPresenter::PutData()
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1000bfd0
|
||||
MxBool MxPresenter::IsHit(MxS32 p_x, MxS32 p_y)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b4d50
|
||||
void MxPresenter::Init()
|
||||
{
|
||||
m_currentTickleState = TickleState_Idle;
|
||||
m_action = NULL;
|
||||
m_location = MxPoint32(0, 0);
|
||||
m_displayZ = 0;
|
||||
m_compositePresenter = NULL;
|
||||
m_previousTickleStates = 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b4d80
|
||||
MxResult MxPresenter::StartAction(MxStreamController*, MxDSAction* p_action)
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
|
||||
this->m_action = p_action;
|
||||
|
||||
const Vector3Data& location = this->m_action->GetLocation();
|
||||
MxS32 previousTickleState = this->m_currentTickleState;
|
||||
|
||||
this->m_location = MxPoint32(this->m_action->GetLocation()[0], this->m_action->GetLocation()[1]);
|
||||
this->m_displayZ = this->m_action->GetLocation()[2];
|
||||
this->m_previousTickleStates |= 1 << (unsigned char) previousTickleState;
|
||||
this->m_currentTickleState = TickleState_Ready;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b4e40
|
||||
void MxPresenter::EndAction()
|
||||
{
|
||||
if (this->m_action == NULL)
|
||||
return;
|
||||
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
|
||||
if (!this->m_compositePresenter) {
|
||||
#ifdef COMPAT_MODE
|
||||
{
|
||||
MxEndActionNotificationParam param(c_notificationEndAction, NULL, this->m_action, TRUE);
|
||||
MxOmni::GetInstance()->NotifyCurrentEntity(¶m);
|
||||
}
|
||||
#else
|
||||
MxOmni::GetInstance()->NotifyCurrentEntity(
|
||||
&MxEndActionNotificationParam(c_notificationEndAction, NULL, this->m_action, TRUE)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
this->m_action = NULL;
|
||||
MxS32 previousTickleState = 1 << m_currentTickleState;
|
||||
this->m_previousTickleStates |= previousTickleState;
|
||||
this->m_currentTickleState = TickleState_Idle;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b4fc0
|
||||
void MxPresenter::ParseExtra()
|
||||
{
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
MxU16 len = m_action->GetExtraLength();
|
||||
char* extraData = m_action->GetExtraData();
|
||||
|
||||
if (len) {
|
||||
// len &= MAXWORD;
|
||||
char extraCopy[512];
|
||||
memcpy(extraCopy, extraData, len);
|
||||
extraCopy[len] = '\0';
|
||||
|
||||
char worldValue[512];
|
||||
if (KeyValueStringParse(worldValue, g_strWORLD, extraCopy)) {
|
||||
char* token = strtok(worldValue, g_parseExtraTokens);
|
||||
char buf[256];
|
||||
strcpy(buf, token);
|
||||
|
||||
token = strtok(NULL, g_parseExtraTokens);
|
||||
MxS32 val = token ? atoi(token) : 0;
|
||||
MxEntity* result = MxOmni::GetInstance()->FindWorld(buf, val, this);
|
||||
|
||||
m_action->SetFlags(m_action->GetFlags() | MxDSAction::Flag_World);
|
||||
|
||||
if (result)
|
||||
SendToCompositePresenter(MxOmni::GetInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5120
|
||||
void MxPresenter::SendToCompositePresenter(MxOmni* p_omni)
|
||||
{
|
||||
if (m_compositePresenter) {
|
||||
MxAutoLocker lock(&m_criticalSection);
|
||||
|
||||
#ifdef COMPAT_MODE
|
||||
{
|
||||
MxNotificationParam param(MXPRESENTER_NOTIFICATION, this);
|
||||
NotificationManager()->Send(m_compositePresenter, ¶m);
|
||||
}
|
||||
#else
|
||||
NotificationManager()->Send(m_compositePresenter, &MxNotificationParam(MXPRESENTER_NOTIFICATION, this));
|
||||
#endif
|
||||
|
||||
m_action->SetOrigin(p_omni ? p_omni : MxOmni::GetInstance());
|
||||
m_compositePresenter = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5200
|
||||
MxResult MxPresenter::Tickle()
|
||||
{
|
||||
MxAutoLocker lock(&this->m_criticalSection);
|
||||
|
||||
switch (this->m_currentTickleState) {
|
||||
case TickleState_Ready:
|
||||
this->ReadyTickle();
|
||||
|
||||
if (m_currentTickleState != TickleState_Starting)
|
||||
break;
|
||||
case TickleState_Starting:
|
||||
this->StartingTickle();
|
||||
|
||||
if (m_currentTickleState != TickleState_Streaming)
|
||||
break;
|
||||
case TickleState_Streaming:
|
||||
this->StreamingTickle();
|
||||
|
||||
if (m_currentTickleState != TickleState_Repeating)
|
||||
break;
|
||||
case TickleState_Repeating:
|
||||
this->RepeatingTickle();
|
||||
|
||||
if (m_currentTickleState != TickleState_unk5)
|
||||
break;
|
||||
case TickleState_unk5:
|
||||
this->Unk5Tickle();
|
||||
|
||||
if (m_currentTickleState != TickleState_Done)
|
||||
break;
|
||||
case TickleState_Done:
|
||||
this->DoneTickle();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b52d0
|
||||
void MxPresenter::Enable(MxBool p_enable)
|
||||
{
|
||||
if (this->m_action && this->IsEnabled() != p_enable) {
|
||||
MxU32 flags = this->m_action->GetFlags();
|
||||
|
||||
if (p_enable)
|
||||
this->m_action->SetFlags(flags | MxDSAction::Flag_Enabled);
|
||||
else
|
||||
this->m_action->SetFlags(flags & ~MxDSAction::Flag_Enabled);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5310
|
||||
const char* PresenterNameDispatch(const MxDSAction& p_action)
|
||||
{
|
||||
const char* name = p_action.GetSourceName();
|
||||
MxS32 format;
|
||||
|
||||
if (!name || strlen(name) == 0) {
|
||||
switch (p_action.GetType()) {
|
||||
case MxDSType_Anim:
|
||||
format = ((MxDSAnim&) p_action).GetMediaFormat();
|
||||
switch (format) {
|
||||
case FOURCC(' ', 'F', 'L', 'C'):
|
||||
name = !p_action.IsLooping() ? "MxFlcPresenter" : "MxLoopingFlcPresenter";
|
||||
break;
|
||||
case FOURCC(' ', 'S', 'M', 'K'):
|
||||
name = !p_action.IsLooping() ? "MxSmkPresenter" : "MxLoopingSmkPresenter";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MxDSType_Sound:
|
||||
format = ((MxDSSound&) p_action).GetMediaFormat();
|
||||
switch (format) {
|
||||
case FOURCC(' ', 'M', 'I', 'D'):
|
||||
name = !p_action.IsLooping() ? "MxMIDIPresenter" : "MxLoopingMIDIPresenter";
|
||||
break;
|
||||
case FOURCC(' ', 'W', 'A', 'V'):
|
||||
name = "MxWavePresenter";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MxDSType_SerialAction:
|
||||
case MxDSType_ParallelAction:
|
||||
case MxDSType_SelectAction:
|
||||
name = "MxCompositePresenter";
|
||||
break;
|
||||
|
||||
case MxDSType_Event:
|
||||
name = "MxEventPresenter";
|
||||
break;
|
||||
|
||||
case MxDSType_Still:
|
||||
name = "MxStillPresenter";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b5410
|
||||
MxEntity* MxPresenter::CreateEntityBackend(const char* p_name)
|
||||
{
|
||||
char buffer[512];
|
||||
char buffer2[512];
|
||||
strcpy(buffer, p_name);
|
||||
|
||||
MxU16 extraLen = m_action->GetExtraLength();
|
||||
|
||||
buffer[0] = extraLen;
|
||||
buffer[1] = extraLen >> 8;
|
||||
if (extraLen) {
|
||||
extraLen &= MAXWORD;
|
||||
memcpy(buffer2 + 2, m_action->GetExtraData(), extraLen);
|
||||
buffer2[extraLen + 2] = 0;
|
||||
KeyValueStringParse(buffer, g_strOBJECT, buffer2 + 2);
|
||||
}
|
||||
|
||||
return (MxEntity*) ObjectFactory()->Create(buffer);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b54c0
|
||||
MxBool MxPresenter::IsEnabled()
|
||||
{
|
||||
return this->m_action && this->m_action->GetFlags() & MxDSAction::Flag_Enabled;
|
||||
}
|
||||
118
LEGO1/omni/src/common/mxstring.cpp
Normal file
118
LEGO1/omni/src/common/mxstring.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "mxstring.h"
|
||||
|
||||
#include "decomp.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxString, 0x10)
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae200
|
||||
MxString::MxString()
|
||||
{
|
||||
// Set string to one char in length and set that char to null terminator
|
||||
this->m_data = new char[1];
|
||||
this->m_data[0] = 0;
|
||||
this->m_length = 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae2a0
|
||||
MxString::MxString(const MxString& p_str)
|
||||
{
|
||||
this->m_length = p_str.m_length;
|
||||
this->m_data = new char[this->m_length + 1];
|
||||
strcpy(this->m_data, p_str.m_data);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae350
|
||||
MxString::MxString(const char* p_str)
|
||||
{
|
||||
if (p_str) {
|
||||
this->m_length = strlen(p_str);
|
||||
this->m_data = new char[this->m_length + 1];
|
||||
strcpy(this->m_data, p_str);
|
||||
}
|
||||
else {
|
||||
this->m_data = new char[1];
|
||||
this->m_data[0] = 0;
|
||||
this->m_length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae420
|
||||
MxString::~MxString()
|
||||
{
|
||||
delete[] this->m_data;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae490
|
||||
void MxString::ToUpperCase()
|
||||
{
|
||||
strupr(this->m_data);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae4a0
|
||||
void MxString::ToLowerCase()
|
||||
{
|
||||
strlwr(this->m_data);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae4b0
|
||||
MxString& MxString::operator=(const MxString& p_str)
|
||||
{
|
||||
if (this->m_data != p_str.m_data) {
|
||||
delete[] this->m_data;
|
||||
this->m_length = p_str.m_length;
|
||||
this->m_data = new char[this->m_length + 1];
|
||||
strcpy(this->m_data, p_str.m_data);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae510
|
||||
const MxString& MxString::operator=(const char* p_data)
|
||||
{
|
||||
if (this->m_data != p_data) {
|
||||
delete[] this->m_data;
|
||||
this->m_length = strlen(p_data);
|
||||
this->m_data = new char[this->m_length + 1];
|
||||
strcpy(this->m_data, p_data);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Return type is intentionally just MxString, not MxString&.
|
||||
// This forces MSVC to add $ReturnUdt$ to the stack for 100% match.
|
||||
// FUNCTION: LEGO1 0x100ae580
|
||||
MxString MxString::operator+(const char* p_str)
|
||||
{
|
||||
// MxString constructor allocates 1 byte for m_data, so free that first
|
||||
MxString tmp;
|
||||
delete[] tmp.m_data;
|
||||
|
||||
tmp.m_length = strlen(p_str) + this->m_length;
|
||||
tmp.m_data = new char[tmp.m_length + 1];
|
||||
|
||||
strcpy(tmp.m_data, this->m_data);
|
||||
strcpy(tmp.m_data + this->m_length, p_str);
|
||||
|
||||
return MxString(tmp);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae690
|
||||
MxString& MxString::operator+=(const char* p_str)
|
||||
{
|
||||
int newlen = this->m_length + strlen(p_str);
|
||||
|
||||
char* tmp = new char[newlen + 1];
|
||||
strcpy(tmp, this->m_data);
|
||||
strcpy(tmp + this->m_length, p_str);
|
||||
|
||||
delete[] this->m_data;
|
||||
this->m_length = newlen;
|
||||
this->m_data = tmp;
|
||||
|
||||
return *this;
|
||||
}
|
||||
112
LEGO1/omni/src/common/mxticklemanager.cpp
Normal file
112
LEGO1/omni/src/common/mxticklemanager.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "mxticklemanager.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxomni.h"
|
||||
#include "mxtimer.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
#define TICKLE_MANAGER_FLAG_DESTROY 0x1
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxTickleClient, 0x10);
|
||||
DECOMP_SIZE_ASSERT(MxTickleManager, 0x14);
|
||||
|
||||
// FUNCTION: LEGO1 0x100bdd10
|
||||
MxTickleClient::MxTickleClient(MxCore* p_client, MxTime p_interval)
|
||||
{
|
||||
m_flags = 0;
|
||||
m_client = p_client;
|
||||
m_interval = p_interval;
|
||||
m_lastUpdateTime = -m_interval;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100bdd30
|
||||
MxTickleManager::~MxTickleManager()
|
||||
{
|
||||
while (m_clients.size() != 0) {
|
||||
MxTickleClient* client = m_clients.front();
|
||||
m_clients.pop_front();
|
||||
delete client;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100bdde0
|
||||
MxResult MxTickleManager::Tickle()
|
||||
{
|
||||
MxTime time = Timer()->GetTime();
|
||||
|
||||
for (MxTickleClientPtrList::iterator it = m_clients.begin(); it != m_clients.end();) {
|
||||
MxTickleClient* client = *it;
|
||||
|
||||
// TODO: Match.
|
||||
if ((MxU8) client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) {
|
||||
m_clients.erase(it++);
|
||||
delete client;
|
||||
}
|
||||
else {
|
||||
it++;
|
||||
|
||||
if (client->GetLastUpdateTime() > time)
|
||||
client->SetLastUpdateTime(-client->GetTickleInterval());
|
||||
|
||||
if ((client->GetTickleInterval() + client->GetLastUpdateTime()) < time) {
|
||||
client->GetClient()->Tickle();
|
||||
client->SetLastUpdateTime(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100bde80
|
||||
void MxTickleManager::RegisterClient(MxCore* p_client, MxTime p_interval)
|
||||
{
|
||||
MxTime interval = GetClientTickleInterval(p_client);
|
||||
if (interval == TICKLE_MANAGER_NOT_FOUND) {
|
||||
MxTickleClient* client = new MxTickleClient(p_client, p_interval);
|
||||
if (client != NULL)
|
||||
m_clients.push_back(client);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100bdf60
|
||||
void MxTickleManager::UnregisterClient(MxCore* p_client)
|
||||
{
|
||||
MxTickleClientPtrList::iterator it = m_clients.begin();
|
||||
while (it != m_clients.end()) {
|
||||
MxTickleClient* client = *it;
|
||||
if (client->GetClient() == p_client) {
|
||||
client->SetFlags(client->GetFlags() | TICKLE_MANAGER_FLAG_DESTROY);
|
||||
return;
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100bdfa0
|
||||
void MxTickleManager::SetClientTickleInterval(MxCore* p_client, MxTime p_interval)
|
||||
{
|
||||
for (MxTickleClientPtrList::iterator it = m_clients.begin(); it != m_clients.end(); it++) {
|
||||
MxTickleClient* client = *it;
|
||||
if ((client->GetClient() == p_client) && ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0)) {
|
||||
client->SetTickleInterval(p_interval);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100be000
|
||||
MxTime MxTickleManager::GetClientTickleInterval(MxCore* p_client)
|
||||
{
|
||||
MxTickleClientPtrList::iterator it = m_clients.begin();
|
||||
while (it != m_clients.end()) {
|
||||
MxTickleClient* client = *it;
|
||||
if ((client->GetClient() == p_client) && ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0))
|
||||
return client->GetTickleInterval();
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
return TICKLE_MANAGER_NOT_FOUND;
|
||||
}
|
||||
42
LEGO1/omni/src/common/mxtimer.cpp
Normal file
42
LEGO1/omni/src/common/mxtimer.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "mxtimer.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// GLOBAL: LEGO1 0x10101414
|
||||
MxLong MxTimer::g_lastTimeCalculated = 0;
|
||||
|
||||
// GLOBAL: LEGO1 0x10101418
|
||||
MxLong MxTimer::g_lastTimeTimerStarted = 0;
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae060
|
||||
MxTimer::MxTimer()
|
||||
{
|
||||
this->m_isRunning = FALSE;
|
||||
m_startTime = timeGetTime();
|
||||
// yeah this is somehow what the asm is
|
||||
g_lastTimeCalculated = m_startTime;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae140
|
||||
MxLong MxTimer::GetRealTime()
|
||||
{
|
||||
MxTimer::g_lastTimeCalculated = timeGetTime();
|
||||
return MxTimer::g_lastTimeCalculated - this->m_startTime;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae160
|
||||
void MxTimer::Start()
|
||||
{
|
||||
g_lastTimeTimerStarted = this->GetRealTime();
|
||||
this->m_isRunning = TRUE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ae180
|
||||
void MxTimer::Stop()
|
||||
{
|
||||
MxLong elapsed = this->GetRealTime();
|
||||
MxLong startTime = elapsed - MxTimer::g_lastTimeTimerStarted;
|
||||
this->m_isRunning = FALSE;
|
||||
// this feels very stupid but it's what the assembly does
|
||||
this->m_startTime = this->m_startTime + startTime - 5;
|
||||
}
|
||||
24
LEGO1/omni/src/common/mxvariable.cpp
Normal file
24
LEGO1/omni/src/common/mxvariable.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "mxvariable.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxstring.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxVariable, 0x24)
|
||||
|
||||
// FUNCTION: LEGO1 0x1003bea0
|
||||
MxString* MxVariable::GetValue()
|
||||
{
|
||||
return &m_value;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1003beb0
|
||||
void MxVariable::SetValue(const char* p_value)
|
||||
{
|
||||
m_value = p_value;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1003bec0
|
||||
void MxVariable::Destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
66
LEGO1/omni/src/common/mxvariabletable.cpp
Normal file
66
LEGO1/omni/src/common/mxvariabletable.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "mxvariabletable.h"
|
||||
|
||||
// FUNCTION: LEGO1 0x100b7330
|
||||
MxS8 MxVariableTable::Compare(MxVariable* p_var0, MxVariable* p_var1)
|
||||
{
|
||||
return p_var0->GetKey()->Compare(*p_var1->GetKey());
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b7370
|
||||
MxU32 MxVariableTable::Hash(MxVariable* p_var)
|
||||
{
|
||||
const char* str = p_var->GetKey()->GetData();
|
||||
MxU32 value = 0;
|
||||
|
||||
for (int i = 0; str[i]; i++) {
|
||||
value += str[i];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b73a0
|
||||
void MxVariableTable::SetVariable(const char* p_key, const char* p_value)
|
||||
{
|
||||
MxHashTableCursor<MxVariable*> cursor(this);
|
||||
MxVariable* var = new MxVariable(p_key, p_value);
|
||||
|
||||
if (cursor.Find(var)) {
|
||||
delete var;
|
||||
cursor.Current(var);
|
||||
var->SetValue(p_value);
|
||||
}
|
||||
else {
|
||||
MxHashTable<MxVariable*>::Add(var);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b7740
|
||||
void MxVariableTable::SetVariable(MxVariable* p_var)
|
||||
{
|
||||
MxHashTableCursor<MxVariable*> cursor(this);
|
||||
MxBool found = cursor.Find(p_var);
|
||||
|
||||
if (found)
|
||||
cursor.DeleteMatch();
|
||||
|
||||
MxHashTable<MxVariable*>::Add(p_var);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b78f0
|
||||
const char* MxVariableTable::GetVariable(const char* p_key)
|
||||
{
|
||||
const char* value = "";
|
||||
MxHashTableCursor<MxVariable*> cursor(this);
|
||||
MxVariable* var = new MxVariable(p_key);
|
||||
|
||||
MxBool found = cursor.Find(var);
|
||||
delete var;
|
||||
|
||||
if (found) {
|
||||
cursor.Current(var);
|
||||
value = var->GetValue()->GetData();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user