2023-06-29 04:10:08 -04:00
|
|
|
#include "mxpresenter.h"
|
2023-09-04 18:33:38 -04:00
|
|
|
#include "mxautolocker.h"
|
2023-09-13 03:44:03 -04:00
|
|
|
#include "mxparam.h"
|
|
|
|
#include "legoomni.h"
|
|
|
|
#include <string.h>
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
#include "decomp.h"
|
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxPresenter, 0x40);
|
|
|
|
|
2023-09-13 03:44:03 -04:00
|
|
|
// 0x10101eac
|
|
|
|
char *g_parseExtraTokens = ":;";
|
|
|
|
|
|
|
|
// 0x10101edc
|
|
|
|
char *g_strWORLD = "WORLD";
|
|
|
|
|
2023-06-29 04:10:08 -04:00
|
|
|
// OFFSET: LEGO1 0x100b4d50
|
|
|
|
void MxPresenter::Init()
|
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
m_currentTickleState = TickleState_Idle;
|
2023-06-29 04:10:08 -04:00
|
|
|
m_action = NULL;
|
2023-09-19 17:45:16 -04:00
|
|
|
m_location = MxPoint32(0, 0);
|
2023-09-19 23:00:34 -04:00
|
|
|
m_displayZ = 0;
|
2023-09-13 03:44:03 -04:00
|
|
|
m_unkPresenter = NULL;
|
2023-09-04 18:33:38 -04:00
|
|
|
m_previousTickleStates = 0;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-09-13 03:44:03 -04:00
|
|
|
// OFFSET: LEGO1 0x100b4fc0
|
2023-06-29 04:10:08 -04:00
|
|
|
void MxPresenter::ParseExtra()
|
|
|
|
{
|
2023-09-13 03:44:03 -04:00
|
|
|
|
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
MxU32 len = m_action->GetExtraLength();
|
|
|
|
char *extraData = m_action->GetExtraData();
|
|
|
|
|
|
|
|
if (len) {
|
|
|
|
len &= MAXWORD;
|
|
|
|
char extraCopy[512];
|
|
|
|
memcpy(extraCopy, extraData, len);
|
|
|
|
extraCopy[len] = '\0';
|
|
|
|
|
|
|
|
char t_worldValue[512];
|
|
|
|
if (KeyValueStringParse(t_worldValue, g_strWORLD, extraCopy)) {
|
|
|
|
char *token = strtok(t_worldValue, g_parseExtraTokens);
|
|
|
|
char t_token[256];
|
|
|
|
strcpy(t_token, token);
|
|
|
|
|
|
|
|
token = strtok(NULL, g_parseExtraTokens);
|
|
|
|
int val = token ? atoi(token) : 0;
|
|
|
|
|
|
|
|
int result = MxOmni::GetInstance()->vtable0x30(t_token, val, this);
|
|
|
|
|
|
|
|
m_action->SetFlags(m_action->GetFlags() | MxDSAction::Flag_Parsed);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
SendTo_unkPresenter(MxOmni::GetInstance());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b5120
|
|
|
|
void MxPresenter::SendTo_unkPresenter(MxOmni *p_omni)
|
|
|
|
{
|
|
|
|
if (m_unkPresenter) {
|
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
// TOOD: magic number used for notification type. replace with enum
|
|
|
|
NotificationManager()->Send(m_unkPresenter, &MxParam(5, this));
|
|
|
|
|
|
|
|
m_action->SetOmni(p_omni ? p_omni : MxOmni::GetInstance());
|
|
|
|
m_unkPresenter = NULL;
|
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000bf00
|
2023-06-29 04:10:08 -04:00
|
|
|
MxPresenter::~MxPresenter()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-09-04 18:33:38 -04:00
|
|
|
// OFFSET: LEGO1 0x100b5200
|
2023-07-02 04:05:49 -04:00
|
|
|
MxLong MxPresenter::Tickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
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;
|
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2023-09-19 17:45:16 -04:00
|
|
|
return SUCCESS;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-09-19 17:45:16 -04:00
|
|
|
// OFFSET: LEGO1 0x100b4d80
|
|
|
|
MxLong MxPresenter::StartAction(MxStreamController *, MxDSAction *p_action)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-19 17:45:16 -04:00
|
|
|
MxAutoLocker lock(&this->m_criticalSection);
|
|
|
|
|
|
|
|
this->m_action = p_action;
|
|
|
|
|
|
|
|
const MxVector3Data& location = this->m_action->GetLocation();
|
|
|
|
MxS32 previousTickleState = this->m_currentTickleState;
|
|
|
|
|
|
|
|
this->m_location = MxPoint32(location[0], location[1]);
|
2023-09-19 23:00:34 -04:00
|
|
|
this->m_displayZ = location[2];
|
2023-09-19 17:45:16 -04:00
|
|
|
this->m_previousTickleStates |= 1 << (unsigned char)previousTickleState;
|
|
|
|
this->m_currentTickleState = TickleState_Ready;
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2023-09-19 17:45:16 -04:00
|
|
|
return SUCCESS;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x100b4e40 STUB
|
2023-06-29 04:10:08 -04:00
|
|
|
void MxPresenter::EndAction()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2023-09-04 18:33:38 -04:00
|
|
|
// OFFSET: LEGO1 0x100b52d0
|
|
|
|
void MxPresenter::Enable(MxBool p_enable)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100b54c0
|
|
|
|
MxBool MxPresenter::IsEnabled()
|
|
|
|
{
|
|
|
|
return this->m_action && this->m_action->GetFlags() & MxDSAction::Flag_Enabled;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000be30
|
2023-06-29 04:10:08 -04:00
|
|
|
void MxPresenter::VTable0x14()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000be40
|
2023-09-04 18:33:38 -04:00
|
|
|
void MxPresenter::ReadyTickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-07-02 03:00:28 -04:00
|
|
|
ParseExtra();
|
2023-09-04 18:33:38 -04:00
|
|
|
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char)m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Starting;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000be60
|
2023-09-04 18:33:38 -04:00
|
|
|
void MxPresenter::StartingTickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
m_previousTickleStates |= 1 << (unsigned char)m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Streaming;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000be80
|
2023-09-04 18:33:38 -04:00
|
|
|
void MxPresenter::StreamingTickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
m_previousTickleStates |= 1 << (unsigned char)m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Repeating;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000bea0
|
2023-09-04 18:33:38 -04:00
|
|
|
void MxPresenter::RepeatingTickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
m_previousTickleStates |= 1 << (unsigned char)m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_unk5;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000bec0
|
2023-09-04 18:33:38 -04:00
|
|
|
void MxPresenter::Unk5Tickle()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
m_previousTickleStates |= 1 << (unsigned char)m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x1000bee0
|
|
|
|
void MxPresenter::DoneTickle()
|
|
|
|
{
|
|
|
|
m_previousTickleStates |= 1 << m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Idle;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x1000bf70
|
|
|
|
undefined4 MxPresenter::VTable0x34()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x1000bf80
|
|
|
|
void MxPresenter::InitVirtual()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
2023-09-04 18:33:38 -04:00
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000bf90
|
2023-09-04 18:33:38 -04:00
|
|
|
void MxPresenter::SetTickleState(TickleState p_tickleState)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
m_previousTickleStates |= 1 << (unsigned char)m_currentTickleState;
|
|
|
|
m_currentTickleState = p_tickleState;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000bfb0
|
2023-09-04 18:33:38 -04:00
|
|
|
MxBool MxPresenter::HasTickleStatePassed(TickleState p_tickleState)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-04 18:33:38 -04:00
|
|
|
return m_previousTickleStates & (1 << (unsigned char)p_tickleState);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x1000bfc0
|
2023-09-19 23:00:34 -04:00
|
|
|
undefined4 MxPresenter::PutData()
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x1000bfd0
|
2023-09-19 23:00:34 -04:00
|
|
|
MxBool MxPresenter::IsHit(MxS32 p_x, MxS32 p_y)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2023-09-19 23:00:34 -04:00
|
|
|
return FALSE;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|