Complete LegoCarBuildAnimPresenter (#1114)

* Complete `LegoCarBuildAnimPresenter`

* fix CI errors

* Drive-by BETA10 fixes

* Address review comments

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
This commit is contained in:
jonschz 2024-10-20 23:00:44 +02:00 committed by GitHub
parent 91205be031
commit b5fee6b240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 188 additions and 25 deletions

View file

@ -9,6 +9,10 @@
// SIZE 0x150
class LegoCarBuildAnimPresenter : public LegoAnimPresenter {
public:
enum {
c_bit1 = 0x01
};
// SIZE 0x0c
struct UnknownListEntry {
// FUNCTION: LEGO1 0x100795c0
@ -67,7 +71,8 @@ class LegoCarBuildAnimPresenter : public LegoAnimPresenter {
LegoTreeNode* FindNodeByName(LegoTreeNode* p_treeNode, const LegoChar* p_name);
void RotateAroundYAxis(MxFloat p_angle);
MxBool FUN_10079c30(const LegoChar* p_name);
MxBool FUN_10079ca0(const LegoChar* p_name);
MxBool PartIsPlaced(const LegoChar* p_name);
void FUN_10079a90();
MxBool StringEqualsPlatform(const LegoChar* p_string);
MxBool StringEqualsShelf(const LegoChar* p_string);
MxBool FUN_10079cf0(const LegoChar* p_string);
@ -84,7 +89,9 @@ class LegoCarBuildAnimPresenter : public LegoAnimPresenter {
// LegoCarBuildAnimPresenter::`scalar deleting destructor'
private:
undefined2 m_unk0xbc; // 0xbc
void Beta10Inline0x100733d0();
MxU16 m_unk0xbc; // 0xbc
// variable name verified by BETA10 0x1007184f
MxS16 m_numberOfParts; // 0xbe
@ -100,10 +107,10 @@ class LegoCarBuildAnimPresenter : public LegoAnimPresenter {
UnknownListEntry* m_parts; // 0x128
MxFloat m_unk0x12c; // 0x12c
undefined4 m_unk0x130; // 0x130
MxFloat m_unk0x130; // 0x130
MxFloat m_unk0x134; // 0x134
MxFloat m_unk0x138; // 0x138
undefined4 m_unk0x13c; // 0x13c
MxLong m_unk0x13c; // 0x13c
LegoEntity* m_unk0x140; // 0x140
MxS32 m_unk0x144; // 0x144
MxS32 m_unk0x148; // 0x148

View file

@ -6,7 +6,7 @@
// VTABLE: LEGO1 0x100d6c00 LegoAnimActor
// VTABLE: LEGO1 0x100d6c10 LegoPathActor
// VTABLE: LEGO1 0x100d6cdc LegoExtraActor
// VTABLE: BETA10 0x101bc2b8 LegoAnimActor
// VTABLE: BETA10 0x101bc2b8 LegoPathActor
// SIZE 0x1dc
class LegoExtraActor : public virtual LegoAnimActor {
public:

View file

@ -35,6 +35,7 @@ class LegoRaceActor : public virtual LegoAnimActor {
MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94
// FUNCTION: LEGO1 0x10014aa0
// FUNCTION: BETA10 0x100ca038
virtual MxResult FUN_10014aa0() { return SUCCESS; }
// SYNTHETIC: LEGO1 0x10012c10

View file

@ -218,7 +218,7 @@ void LegoCarBuild::FUN_10022f30()
FUN_10024f70(FALSE);
FUN_100250e0(FALSE);
if (m_unk0x258->FUN_10079ca0(m_unk0x110->GetName())) {
if (m_unk0x258->PartIsPlaced(m_unk0x110->GetName())) {
m_PlaceBrick_Sound->Enable(FALSE);
m_PlaceBrick_Sound->Enable(TRUE);
}
@ -408,7 +408,7 @@ MxResult LegoCarBuild::Tickle()
}
if (m_unk0x110) {
if (m_unk0x258->FUN_10079ca0(m_unk0x110->GetName())) {
if (m_unk0x258->PartIsPlaced(m_unk0x110->GetName())) {
FUN_10022f30();
}
}
@ -697,7 +697,7 @@ undefined4 LegoCarBuild::FUN_100244e0(MxLong p_x, MxLong p_y)
FUN_100250e0(TRUE);
}
if (m_unk0x100 == 5 && m_unk0x258->FUN_10079ca0(m_unk0x110->GetName())) {
if (m_unk0x100 == 5 && m_unk0x258->PartIsPlaced(m_unk0x110->GetName())) {
m_unk0x2d4 = TRUE;
}
else {
@ -706,7 +706,7 @@ undefined4 LegoCarBuild::FUN_100244e0(MxLong p_x, MxLong p_y)
FUN_10025450();
VTable0x70();
if (m_unk0x258->FUN_10079ca0(m_unk0x110->GetName())) {
if (m_unk0x258->PartIsPlaced(m_unk0x110->GetName())) {
if (m_unk0x100 != 5) {
m_unk0x250[0] += m_unk0x290[0] - m_unk0x298[0];
m_unk0x250[1] += m_unk0x290[1] - m_unk0x298[1];

View file

@ -11,6 +11,8 @@
#include "misc.h"
#include "mxautolock.h"
#include "mxcompositepresenter.h"
#include "mxmisc.h"
#include "mxtimer.h"
#include "realtime/realtime.h"
DECOMP_SIZE_ASSERT(LegoCarBuildAnimPresenter::UnknownListEntry, 0x0c)
@ -62,10 +64,75 @@ LegoCarBuildAnimPresenter::~LegoCarBuildAnimPresenter()
}
}
// STUB: LEGO1 0x10078790
// FUNCTION: BETA10 0x100733d0
inline void LegoCarBuildAnimPresenter::Beta10Inline0x100733d0()
{
MxLong time = Timer()->GetTime();
MxLong bvar5;
if (m_unk0x13c < time) {
bvar5 = FALSE;
// I have no idea why this conditional is so convoluted
if (m_unk0x13c & c_bit1) {
bvar5 = TRUE;
m_unk0x13c = time + 400;
}
else {
m_unk0x13c = time + 200;
}
if (bvar5) {
m_unk0x13c &= ~c_bit1;
}
else {
m_unk0x13c |= c_bit1;
}
if (m_placedPartCount < m_numberOfParts) {
const LegoChar* wiredName = m_parts[m_placedPartCount].m_wiredName;
if (wiredName) {
for (MxS32 i = 1; i <= m_roiMapSize; i++) {
LegoROI* roi = m_roiMap[i];
if (roi) {
const LegoChar* name = roi->GetName();
if (name && stricmp(wiredName, name) == 0) {
if (bvar5) {
roi->SetVisibility(TRUE);
}
else {
roi->SetVisibility(FALSE);
}
}
}
}
}
}
}
}
// FUNCTION: LEGO1 0x10078790
// FUNCTION: BETA10 0x10070ab1
void LegoCarBuildAnimPresenter::PutFrame()
{
// TODO
switch (m_unk0xbc) {
case 0:
break;
case 2:
FUN_10079a90();
case 1:
if (m_unk0x140->GetROI()) {
FUN_1006b9a0(m_anim, m_unk0x12c, NULL);
}
default:
break;
}
Beta10Inline0x100733d0();
}
// FUNCTION: LEGO1 0x100788c0
@ -351,18 +418,42 @@ void LegoCarBuildAnimPresenter::FUN_10079160()
m_unk0xc8.SetRoot(destNode);
}
// STUB: LEGO1 0x100795d0
// STUB: BETA10 0x10071d96
// FUNCTION: LEGO1 0x100795d0
// FUNCTION: BETA10 0x10071d96
void LegoCarBuildAnimPresenter::FUN_100795d0(LegoChar* p_param)
{
// TODO
LegoAnimNodeData* data = FindNodeDataByName(m_anim->GetRoot(), p_param);
if (data) {
LegoMorphKey* oldMorphKeys = data->GetMorphKeys();
LegoMorphKey* newHideKey = new LegoMorphKey();
assert(newHideKey);
newHideKey->SetTime(0);
newHideKey->SetUnknown0x08(FALSE);
data->SetNumMorphKeys(1);
data->SetMorphKeys(newHideKey);
delete oldMorphKeys;
}
}
// STUB: LEGO1 0x10079680
// STUB: BETA10 0x10071ec5
// FUNCTION: LEGO1 0x10079680
// FUNCTION: BETA10 0x10071ec5
void LegoCarBuildAnimPresenter::FUN_10079680(LegoChar* p_param)
{
// TODO
LegoAnimNodeData* data = FindNodeDataByName(m_anim->GetRoot(), p_param);
if (data) {
LegoMorphKey* oldMorphKeys = data->GetMorphKeys();
data->SetNumMorphKeys(0);
data->SetMorphKeys(NULL);
delete oldMorphKeys;
}
}
// FUNCTION: LEGO1 0x100796b0
@ -449,6 +540,25 @@ void LegoCarBuildAnimPresenter::RotateAroundYAxis(MxFloat p_angle)
}
}
// FUNCTION: LEGO1 0x10079a90
// FUNCTION: BETA10 0x10072412
void LegoCarBuildAnimPresenter::FUN_10079a90()
{
if (m_unk0x12c >= m_unk0x134) {
m_unk0x130 = 0.0;
m_unk0x12c = m_unk0x130;
m_unk0xbc = 1;
}
else if (m_unk0x12c >= m_unk0x138 + m_unk0x130) {
m_unk0x130 = m_unk0x138 + m_unk0x130;
m_unk0x12c = m_unk0x130;
m_unk0xbc = 1;
}
else {
m_unk0x12c = m_unk0x138 / 10.0f + m_unk0x12c;
}
}
// FUNCTION: LEGO1 0x10079b20
// FUNCTION: BETA10 0x100724fa
MxBool LegoCarBuildAnimPresenter::StringEqualsPlatform(const LegoChar* p_string)
@ -478,17 +588,21 @@ MxBool LegoCarBuildAnimPresenter::StringEqualsShelf(const LegoChar* p_string)
return strnicmp(p_string, "SHELF", strlen("SHELF")) == 0;
}
// STUB: LEGO1 0x10079c30
// STUB: BETA10 0x100726a6
// FUNCTION: LEGO1 0x10079c30
// FUNCTION: BETA10 0x100726a6
MxBool LegoCarBuildAnimPresenter::FUN_10079c30(const LegoChar* p_name)
{
// TODO
return FALSE;
if (PartIsPlaced(p_name)) {
return FALSE;
}
return m_placedPartCount < m_numberOfParts &&
strnicmp(p_name, m_parts[m_placedPartCount].m_name, strlen(p_name) - 3) == 0;
}
// FUNCTION: LEGO1 0x10079ca0
// FUNCTION: BETA10 0x10072740
MxBool LegoCarBuildAnimPresenter::FUN_10079ca0(const LegoChar* p_name)
MxBool LegoCarBuildAnimPresenter::PartIsPlaced(const LegoChar* p_name)
{
for (MxS16 i = 0; i < m_placedPartCount; i++) {
if (strcmpi(p_name, m_parts[i].m_name) == 0) {

View file

@ -904,6 +904,7 @@ void LegoAnimPresenter::FUN_1006b900(LegoAnim* p_anim, MxLong p_time, Matrix4* p
}
// FUNCTION: LEGO1 0x1006b9a0
// FUNCTION: BETA10 0x1005118b
void LegoAnimPresenter::FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, Matrix4* p_matrix)
{
LegoTreeNode* root = p_anim->GetRoot();

View file

@ -221,10 +221,11 @@ LegoResult LegoAnimScene::FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix)
}
// FUNCTION: LEGO1 0x1009f900
// FUNCTION: BETA10 0x1017df90
LegoAnimKey::LegoAnimKey()
{
m_flags = 0;
m_time = 0;
m_flags = 0;
}
// FUNCTION: LEGO1 0x1009f910
@ -907,6 +908,7 @@ undefined4 LegoAnim::GetActorUnknown0x04(LegoU32 p_index)
}
// FUNCTION: LEGO1 0x100a0f60
// FUNCTION: BETA10 0x1018027c
LegoMorphKey::LegoMorphKey()
{
m_unk0x08 = 0;

View file

@ -19,7 +19,11 @@ class LegoAnimKey {
LegoAnimKey();
LegoResult Read(LegoStorage* p_storage);
LegoFloat GetTime() { return m_time; }
void SetTime(LegoFloat p_time) { m_time = p_time; }
// The different types (LegoFloat vs. MxS32) are correct according to BETA10
// FUNCTION: BETA10 0x100738a0
void SetTime(MxS32 p_time) { m_time = p_time; }
LegoU32 TestBit1() { return m_flags & c_bit1; }
LegoU32 TestBit2() { return m_flags & c_bit2; }
LegoU32 TestBit3() { return m_flags & c_bit3; }
@ -120,6 +124,9 @@ class LegoMorphKey : public LegoAnimKey {
LegoResult Read(LegoStorage* p_storage);
LegoBool GetUnknown0x08() { return m_unk0x08; }
// FUNCTION: BETA10 0x100738d0
void SetUnknown0x08(LegoBool p_unk0x08) { m_unk0x08 = p_unk0x08; }
protected:
LegoBool m_unk0x08; // 0x08
};
@ -186,6 +193,19 @@ class LegoAnimNodeData : public LegoTreeNodeData {
void SetScaleIndex(LegoU32 p_scaleIndex) { m_scaleIndex = p_scaleIndex; }
void SetMorphIndex(LegoU32 p_morphIndex) { m_morphIndex = p_morphIndex; }
// FUNCTION: BETA10 0x10073930
LegoMorphKey* GetMorphKeys() { return m_morphKeys; }
// FUNCTION: BETA10 0x10073960
void SetMorphKeys(LegoMorphKey* p_morphKeys)
{
m_morphKeys = p_morphKeys;
m_morphIndex = 0;
}
// FUNCTION: BETA10 0x10073900
void SetNumMorphKeys(LegoU16 p_numMorphKeys) { m_numMorphKeys = p_numMorphKeys; }
// FUNCTION: BETA10 0x10059600
void SetUnknown0x20(LegoU16 p_unk0x20) { m_unk0x20 = p_unk0x20; }

View file

@ -17,6 +17,7 @@ LegoTreeNode::LegoTreeNode()
}
// FUNCTION: LEGO1 0x10099da0
// FUNCTION: BETA10 0x10187e10
LegoTreeNode::~LegoTreeNode()
{
if (m_data) {

View file

@ -9,11 +9,11 @@
class LegoStorage;
// VTABLE: LEGO1 0x100db778
// VTABLE: BETA10 0x101c37f4
// SIZE 0x04
class LegoTreeNodeData {
public:
LegoTreeNodeData() {}
// FUNCTION: LEGO1 0x1009a0e0
virtual ~LegoTreeNodeData() {}
@ -28,6 +28,7 @@ class LegoTreeNodeData {
};
// VTABLE: LEGO1 0x100db764
// VTABLE: BETA10 0x101c37f4
// SIZE 0x10
class LegoTreeNode {
public:
@ -58,6 +59,7 @@ class LegoTreeNode {
void SetChildren(LegoTreeNode** p_children) { m_children = p_children; }
// SYNTHETIC: LEGO1 0x10099d80
// SYNTHETIC: BETA10 0x10188cb0
// LegoTreeNode::`scalar deleting destructor'
protected:

View file

@ -98,6 +98,7 @@ class MxPresenter : public MxCore {
virtual void EndAction(); // vtable+0x40
// FUNCTION: LEGO1 0x1000bf90
// FUNCTION: BETA10 0x10054a50
virtual void SetTickleState(TickleState p_tickleState) { ProgressTickleState(p_tickleState); } // vtable+0x44
// FUNCTION: LEGO1 0x1000bfb0

View file

@ -7,10 +7,13 @@ class MxDSBuffer;
class MxStreamListMxDSSubscriber;
// VTABLE: LEGO1 0x100dc2a8
// VTABLE: BETA10 0x101c1d20
// SIZE 0x20
class MxStreamChunk : public MxDSChunk {
public:
// FUNCTION: BETA10 0x10134420
MxStreamChunk() : m_buffer(NULL) {}
~MxStreamChunk() override;
// FUNCTION: LEGO1 0x100b1fe0

View file

@ -52,14 +52,17 @@ class MxVideoPresenter : public MxMediaPresenter {
MxBool IsHit(MxS32 p_x, MxS32 p_y) override; // vtable+0x50
// FUNCTION: LEGO1 0x1000c700
// FUNCTION: BETA10 0x10054a80
virtual void LoadHeader(MxStreamChunk* p_chunk) {} // vtable+0x5c
// FUNCTION: LEGO1 0x1000c710
// FUNCTION: BETA10 0x10054aa0
virtual void CreateBitmap() {} // vtable+0x60
virtual void NextFrame(); // vtable+0x64
// FUNCTION: LEGO1 0x1000c720
// FUNCTION: BETA10 0x10054ac0
virtual void LoadFrame(MxStreamChunk* p_chunk) {} // vtable+0x68
virtual void PutFrame(); // vtable+0x6c

View file

@ -229,6 +229,7 @@ void MxMediaPresenter::DoneTickle()
}
// FUNCTION: LEGO1 0x100b5f10
// FUNCTION: BETA10 0x101366e9
void MxMediaPresenter::LoopChunk(MxStreamChunk* p_chunk)
{
MxStreamChunk* chunk = new MxStreamChunk;
@ -243,6 +244,7 @@ void MxMediaPresenter::LoopChunk(MxStreamChunk* p_chunk)
}
// FUNCTION: LEGO1 0x100b6030
// FUNCTION: BETA10 0x10136814
void MxMediaPresenter::Enable(MxBool p_enable)
{
if (IsEnabled() != p_enable) {

View file

@ -263,6 +263,7 @@ MxEntity* MxPresenter::CreateEntity(const char* p_defaultName)
}
// FUNCTION: LEGO1 0x100b54c0
// FUNCTION: BETA10 0x1012ebaf
MxBool MxPresenter::IsEnabled()
{
return this->m_action && this->m_action->GetFlags() & MxDSAction::c_enabled;

View file

@ -176,6 +176,7 @@ void MxVideoPresenter::Destroy(MxBool p_fromDestructor)
}
// FUNCTION: LEGO1 0x100b28b0
// FUNCTION: BETA10 0x101389c1
void MxVideoPresenter::NextFrame()
{
MxStreamChunk* chunk = NextChunk();
@ -191,6 +192,7 @@ void MxVideoPresenter::NextFrame()
}
// FUNCTION: LEGO1 0x100b2900
// FUNCTION: BETA10 0x10138a3a
MxBool MxVideoPresenter::IsHit(MxS32 p_x, MxS32 p_y)
{
MxDSAction* action = GetAction();
@ -563,6 +565,7 @@ void MxVideoPresenter::EndAction()
}
// FUNCTION: LEGO1 0x100b3280
// FUNCTION: BETA10 0x101397c0
MxResult MxVideoPresenter::PutData()
{
AUTOLOCK(m_criticalSection);

View file

@ -118,6 +118,8 @@ class ROI {
const CompoundObject* GetComp() const { return comp; }
unsigned char GetVisibility() { return m_visible; }
// FUNCTION: BETA10 0x10011720
void SetVisibility(unsigned char p_visible) { m_visible = p_visible; }
// SYNTHETIC: LEGO1 0x100a5d60