diff --git a/LEGO1/omni/include/mxdsaction.h b/LEGO1/omni/include/mxdsaction.h index 32b47b08..3a654258 100644 --- a/LEGO1/omni/include/mxdsaction.h +++ b/LEGO1/omni/include/mxdsaction.h @@ -48,17 +48,17 @@ class MxDSAction : public MxDSObject { return !strcmp(p_name, MxDSAction::ClassName()) || MxDSObject::IsA(p_name); } - undefined4 VTable0x14() override; // vtable+14; - MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; - virtual MxLong GetDuration(); // vtable+24; - virtual void SetDuration(MxLong p_duration); // vtable+28; - virtual MxDSAction* Clone(); // vtable+2c; - virtual void MergeFrom(MxDSAction& p_dsAction); // vtable+30; - virtual MxBool HasId(MxU32 p_objectId); // vtable+34; - virtual void SetUnknown90(MxLong p_unk0x90); // vtable+38; - virtual MxLong GetUnknown90(); // vtable+3c; - virtual MxLong GetElapsedTime(); // vtable+40; + undefined4 VTable0x14() override; // vtable+0x14 + MxU32 GetSizeOnDisk() override; // vtable+0x18 + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+0x1c + virtual MxLong GetDuration(); // vtable+0x24 + virtual void SetDuration(MxLong p_duration); // vtable+0x28 + virtual MxDSAction* Clone(); // vtable+0x2c + virtual void MergeFrom(MxDSAction& p_dsAction); // vtable+0x30 + virtual MxBool HasId(MxU32 p_objectId); // vtable+0x34 + virtual void SetUnknown90(MxLong p_unk0x90); // vtable+0x38 + virtual MxLong GetUnknown90(); // vtable+0x3c + virtual MxLong GetElapsedTime(); // vtable+0x40 void AppendExtra(MxU16 p_extraLength, const char* p_extraData); diff --git a/LEGO1/omni/include/mxdsactionlist.h b/LEGO1/omni/include/mxdsactionlist.h index 0124188d..a38a307e 100644 --- a/LEGO1/omni/include/mxdsactionlist.h +++ b/LEGO1/omni/include/mxdsactionlist.h @@ -29,6 +29,7 @@ class MxDSActionList : public MxList { } // vtable+0x14 // FUNCTION: LEGO1 0x100c9cb0 + // FUNCTION: BETA10 0x1015add0 static void Destroy(MxDSAction* p_action) { delete p_action; } // SYNTHETIC: LEGO1 0x100c9dc0 @@ -139,4 +140,7 @@ class MxDSActionListCursor : public MxListCursor { // TEMPLATE: BETA10 0x1015bd90 // MxList::DeleteAll +// TEMPLATE: BETA10 0x1015be20 +// MxListCursor::HasMatch + #endif // MXDSACTIONLIST_H diff --git a/LEGO1/omni/include/mxdsanim.h b/LEGO1/omni/include/mxdsanim.h index 68be4e12..817e3c5b 100644 --- a/LEGO1/omni/include/mxdsanim.h +++ b/LEGO1/omni/include/mxdsanim.h @@ -9,6 +9,7 @@ class MxDSAnim : public MxDSMediaAction { public: MxDSAnim(); + MxDSAnim(MxDSAnim& p_dsAnim); ~MxDSAnim() override; void CopyFrom(MxDSAnim& p_dsAnim); @@ -23,14 +24,16 @@ class MxDSAnim : public MxDSMediaAction { } // FUNCTION: LEGO1 0x100c9070 + // FUNCTION: BETA10 0x1015d8b0 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSAnim::ClassName()) || MxDSMediaAction::IsA(p_name); } - MxDSAction* Clone() override; // vtable+2c; + MxDSAction* Clone() override; // vtable+0x2c // SYNTHETIC: LEGO1 0x100c9180 + // SYNTHETIC: BETA10 0x1015d910 // MxDSAnim::`scalar deleting destructor' }; diff --git a/LEGO1/omni/include/mxdsevent.h b/LEGO1/omni/include/mxdsevent.h index 961a4bcf..14e42ad7 100644 --- a/LEGO1/omni/include/mxdsevent.h +++ b/LEGO1/omni/include/mxdsevent.h @@ -8,6 +8,7 @@ class MxDSEvent : public MxDSMediaAction { public: MxDSEvent(); + MxDSEvent(MxDSEvent& p_dsEvent); ~MxDSEvent() override; void CopyFrom(MxDSEvent& p_dsEvent); @@ -22,14 +23,16 @@ class MxDSEvent : public MxDSMediaAction { } // FUNCTION: LEGO1 0x100c9670 + // FUNCTION: BETA10 0x1015da30 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSEvent::ClassName()) || MxDSMediaAction::IsA(p_name); } - MxDSAction* Clone() override; // vtable+2c; + MxDSAction* Clone() override; // vtable+0x2c // SYNTHETIC: LEGO1 0x100c9780 + // SYNTHETIC: BETA10 0x1015da90 // MxDSEvent::`scalar deleting destructor' }; diff --git a/LEGO1/omni/include/mxdsmediaaction.h b/LEGO1/omni/include/mxdsmediaaction.h index 3c41dc84..359061ca 100644 --- a/LEGO1/omni/include/mxdsmediaaction.h +++ b/LEGO1/omni/include/mxdsmediaaction.h @@ -10,10 +10,10 @@ class MxDSMediaAction : public MxDSAction { public: MxDSMediaAction(); + MxDSMediaAction(MxDSMediaAction& p_dsMediaAction); ~MxDSMediaAction() override; void CopyFrom(MxDSMediaAction& p_dsMediaAction); - MxDSMediaAction(MxDSMediaAction& p_dsMediaAction); MxDSMediaAction& operator=(MxDSMediaAction& p_dsMediaAction); // FUNCTION: LEGO1 0x100c8be0 @@ -35,10 +35,10 @@ class MxDSMediaAction : public MxDSAction { // SYNTHETIC: BETA10 0x1015d810 // MxDSMediaAction::`scalar deleting destructor' - undefined4 VTable0x14() override; // vtable+14; - MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; - MxDSAction* Clone() override; // vtable+2c; + undefined4 VTable0x14() override; // vtable+0x14 + MxU32 GetSizeOnDisk() override; // vtable+0x18 + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+0x1c + MxDSAction* Clone() override; // vtable+0x2c void CopyMediaSrcPath(const char* p_mediaSrcPath); diff --git a/LEGO1/omni/include/mxdsmultiaction.h b/LEGO1/omni/include/mxdsmultiaction.h index 5267a792..90cc5192 100644 --- a/LEGO1/omni/include/mxdsmultiaction.h +++ b/LEGO1/omni/include/mxdsmultiaction.h @@ -10,6 +10,7 @@ class MxDSMultiAction : public MxDSAction { public: MxDSMultiAction(); + MxDSMultiAction(MxDSMultiAction& p_dsMultiAction); ~MxDSMultiAction() override; void CopyFrom(MxDSMultiAction& p_dsMultiAction); @@ -24,29 +25,31 @@ class MxDSMultiAction : public MxDSAction { } // FUNCTION: LEGO1 0x100c9f60 + // FUNCTION: BETA10 0x1015b1b0 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSMultiAction::ClassName()) || MxDSAction::IsA(p_name); } - undefined4 VTable0x14() override; // vtable+14; - MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; - void SetAtomId(MxAtomId p_atomId) override; // vtable+20; - MxDSAction* Clone() override; // vtable+2c; - void MergeFrom(MxDSAction& p_dsAction) override; // vtable+30; - MxBool HasId(MxU32 p_objectId) override; // vtable+34; - void SetUnknown90(MxLong p_unk0x90) override; // vtable+38; + undefined4 VTable0x14() override; // vtable+0x14 + MxU32 GetSizeOnDisk() override; // vtable+0x18 + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+0x1c + void SetAtomId(MxAtomId p_atomId) override; // vtable+0x20 + MxDSAction* Clone() override; // vtable+0x2c + void MergeFrom(MxDSAction& p_dsAction) override; // vtable+0x30 + MxBool HasId(MxU32 p_objectId) override; // vtable+0x34 + void SetUnknown90(MxLong p_unk0x90) override; // vtable+0x38 // FUNCTION: BETA10 0x1004e180 - MxDSActionList* GetActionList() const { return m_actions; } + MxDSActionList* GetActionList() const { return m_actionList; } // SYNTHETIC: LEGO1 0x100ca040 + // SYNTHETIC: BETA10 0x1015b210 // MxDSMultiAction::`scalar deleting destructor' protected: - MxU32 m_sizeOnDisk; // 0x94 - MxDSActionList* m_actions; // 0x98 + MxU32 m_sizeOnDisk; // 0x94 + MxDSActionList* m_actionList; // 0x98 }; // SYNTHETIC: LEGO1 0x1004ad10 diff --git a/LEGO1/omni/include/mxdsobject.h b/LEGO1/omni/include/mxdsobject.h index a0a5cb16..5f60bfee 100644 --- a/LEGO1/omni/include/mxdsobject.h +++ b/LEGO1/omni/include/mxdsobject.h @@ -55,23 +55,23 @@ class MxDSObject : public MxCore { // FUNCTION: LEGO1 0x100bf730 // FUNCTION: BETA10 0x1012bdd0 - const char* ClassName() const override { return "MxDSObject"; } // vtable+0c + const char* ClassName() const override { return "MxDSObject"; } // vtable+0x0c // FUNCTION: LEGO1 0x100bf740 // FUNCTION: BETA10 0x1012bd70 MxBool IsA(const char* p_name) const override { return !strcmp(p_name, MxDSObject::ClassName()) || MxCore::IsA(p_name); - } // vtable+10; + } // vtable+0x10 - virtual undefined4 VTable0x14(); // vtable+14; - virtual MxU32 GetSizeOnDisk(); // vtable+18; - virtual void Deserialize(MxU8*& p_source, MxS16 p_unk0x24); // vtable+1c; + virtual undefined4 VTable0x14(); // vtable+0x14 + virtual MxU32 GetSizeOnDisk(); // vtable+0x18 + virtual void Deserialize(MxU8*& p_source, MxS16 p_unk0x24); // vtable+0x1c // FUNCTION: ISLE 0x401c40 // FUNCTION: LEGO1 0x10005530 // FUNCTION: BETA10 0x100152e0 - virtual void SetAtomId(MxAtomId p_atomId) { m_atomId = p_atomId; } // vtable+20; + virtual void SetAtomId(MxAtomId p_atomId) { m_atomId = p_atomId; } // vtable+0x20 // FUNCTION: BETA10 0x1012ef90 Type GetType() const { return (Type) m_type; } diff --git a/LEGO1/omni/include/mxdsobjectaction.h b/LEGO1/omni/include/mxdsobjectaction.h index c734c2c3..0482139a 100644 --- a/LEGO1/omni/include/mxdsobjectaction.h +++ b/LEGO1/omni/include/mxdsobjectaction.h @@ -9,6 +9,7 @@ class MxDSObjectAction : public MxDSMediaAction { public: MxDSObjectAction(); + MxDSObjectAction(MxDSObjectAction& p_dsObjectAction); ~MxDSObjectAction() override; MxDSObjectAction& operator=(MxDSObjectAction& p_dsObjectAction); @@ -22,15 +23,17 @@ class MxDSObjectAction : public MxDSMediaAction { } // FUNCTION: LEGO1 0x100c88f0 + // FUNCTION: BETA10 0x1015c640 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSObjectAction::ClassName()) || MxDSMediaAction::IsA(p_name); } - MxDSAction* Clone() override; // vtable+2c; - virtual void CopyFrom(MxDSObjectAction& p_dsObjectAction); // vtable+44; + MxDSAction* Clone() override; // vtable+0x2c + virtual void CopyFrom(MxDSObjectAction& p_dsObjectAction); // vtable+0x44 // SYNTHETIC: LEGO1 0x100c8a00 + // SYNTHETIC: BETA10 0x1015c720 // MxDSObjectAction::`scalar deleting destructor' }; diff --git a/LEGO1/omni/include/mxdsparallelaction.h b/LEGO1/omni/include/mxdsparallelaction.h index e96b46de..76e9fd44 100644 --- a/LEGO1/omni/include/mxdsparallelaction.h +++ b/LEGO1/omni/include/mxdsparallelaction.h @@ -9,6 +9,7 @@ class MxDSParallelAction : public MxDSMultiAction { public: MxDSParallelAction(); + MxDSParallelAction(MxDSParallelAction& p_dsParallelAction); ~MxDSParallelAction() override; void CopyFrom(MxDSParallelAction& p_dsParallelAction); @@ -23,20 +24,23 @@ class MxDSParallelAction : public MxDSMultiAction { } // FUNCTION: LEGO1 0x100caf10 + // FUNCTION: BETA10 0x1015b3c0 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSParallelAction::ClassName()) || MxDSMultiAction::IsA(p_name); } - // SYNTHETIC: LEGO1 0x100cb020 - // MxDSParallelAction::`scalar deleting destructor' - - MxLong GetDuration() override; // vtable+24; + MxLong GetDuration() override; // vtable+0x24 // FUNCTION: LEGO1 0x100caef0 + // FUNCTION: BETA10 0x1015b370 void SetDuration(MxLong p_duration) override { m_duration = p_duration; } // vtable+0x28 - MxDSAction* Clone() override; // vtable+2c; + MxDSAction* Clone() override; // vtable+0x2c + + // SYNTHETIC: LEGO1 0x100cb020 + // SYNTHETIC: BETA10 0x1015b420 + // MxDSParallelAction::`scalar deleting destructor' }; #endif // MXDSPARALLELACTION_H diff --git a/LEGO1/omni/include/mxdsselectaction.h b/LEGO1/omni/include/mxdsselectaction.h index 10605e66..ed3bca56 100644 --- a/LEGO1/omni/include/mxdsselectaction.h +++ b/LEGO1/omni/include/mxdsselectaction.h @@ -11,6 +11,7 @@ class MxDSSelectAction : public MxDSParallelAction { public: MxDSSelectAction(); + MxDSSelectAction(MxDSSelectAction& p_dsSelectAction); ~MxDSSelectAction() override; void CopyFrom(MxDSSelectAction& p_dsSelectAction); @@ -25,16 +26,18 @@ class MxDSSelectAction : public MxDSParallelAction { } // FUNCTION: LEGO1 0x100cb700 + // FUNCTION: BETA10 0x1015b480 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSSelectAction::ClassName()) || MxDSParallelAction::IsA(p_name); } - MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; - MxDSAction* Clone() override; // vtable+2c; + MxU32 GetSizeOnDisk() override; // vtable+0x18 + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+0x1c + MxDSAction* Clone() override; // vtable+0x2c // SYNTHETIC: LEGO1 0x100cb840 + // SYNTHETIC: BETA10 0x1015b4e0 // MxDSSelectAction::`scalar deleting destructor' private: diff --git a/LEGO1/omni/include/mxdsserialaction.h b/LEGO1/omni/include/mxdsserialaction.h index a95d226d..5e8a4fbd 100644 --- a/LEGO1/omni/include/mxdsserialaction.h +++ b/LEGO1/omni/include/mxdsserialaction.h @@ -10,6 +10,7 @@ class MxDSSerialAction : public MxDSMultiAction { public: MxDSSerialAction(); + MxDSSerialAction(MxDSSerialAction& p_dsSerialAction); ~MxDSSerialAction() override; void CopyFrom(MxDSSerialAction& p_dsSerialAction); @@ -24,22 +25,24 @@ class MxDSSerialAction : public MxDSMultiAction { } // FUNCTION: LEGO1 0x100caae0 + // FUNCTION: BETA10 0x1015b2d0 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSSerialAction::ClassName()) || MxDSMultiAction::IsA(p_name); } - MxLong GetDuration() override; // vtable+24; - void SetDuration(MxLong p_duration) override; // vtable+28; - MxDSAction* Clone() override; // vtable+2c; + MxLong GetDuration() override; // vtable+0x24 + void SetDuration(MxLong p_duration) override; // vtable+0x28 + MxDSAction* Clone() override; // vtable+0x2c // SYNTHETIC: LEGO1 0x100cabf0 + // SYNTHETIC: BETA10 0x1015b330 // MxDSSerialAction::`scalar deleting destructor' private: - MxDSActionListCursor* m_cursor; - undefined4 m_unk0xa0; - undefined4 m_unk0xa4; + MxDSActionListCursor* m_cursor; // 0x9c + undefined4 m_unk0xa0; // 0xa0 + undefined4 m_unk0xa4; // 0xa4 }; #endif // MXDSSERIALACTION_H diff --git a/LEGO1/omni/include/mxdssound.h b/LEGO1/omni/include/mxdssound.h index 33fd42dd..8a5457cd 100644 --- a/LEGO1/omni/include/mxdssound.h +++ b/LEGO1/omni/include/mxdssound.h @@ -9,6 +9,7 @@ class MxDSSound : public MxDSMediaAction { public: MxDSSound(); + MxDSSound(MxDSSound& p_dsSound); ~MxDSSound() override; void CopyFrom(MxDSSound& p_dsSound); @@ -23,19 +24,21 @@ class MxDSSound : public MxDSMediaAction { } // FUNCTION: LEGO1 0x100c9340 + // FUNCTION: BETA10 0x1015d970 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSSound::ClassName()) || MxDSMediaAction::IsA(p_name); } - MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; - MxDSAction* Clone() override; // vtable+2c; + MxU32 GetSizeOnDisk() override; // vtable+0x18 + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+0x1c + MxDSAction* Clone() override; // vtable+0x2c // FUNCTION: BETA10 0x1008d060 MxS32 GetVolume() const { return m_volume; } // SYNTHETIC: LEGO1 0x100c9450 + // SYNTHETIC: BETA10 0x1015d9d0 // MxDSSound::`scalar deleting destructor' private: diff --git a/LEGO1/omni/include/mxdsstill.h b/LEGO1/omni/include/mxdsstill.h index aee7a498..b937a7cf 100644 --- a/LEGO1/omni/include/mxdsstill.h +++ b/LEGO1/omni/include/mxdsstill.h @@ -9,6 +9,7 @@ class MxDSStill : public MxDSMediaAction { public: MxDSStill(); + MxDSStill(MxDSStill& p_dsStill); ~MxDSStill() override; void CopyFrom(MxDSStill& p_dsStill); @@ -23,14 +24,16 @@ class MxDSStill : public MxDSMediaAction { } // FUNCTION: LEGO1 0x100c9940 + // FUNCTION: BETA10 0x1015daf0 MxBool IsA(const char* p_name) const override // vtable+0x10 { return !strcmp(p_name, MxDSStill::ClassName()) || MxDSMediaAction::IsA(p_name); } - MxDSAction* Clone() override; // vtable+2c; + MxDSAction* Clone() override; // vtable+0x2c // SYNTHETIC: LEGO1 0x100c9a50 + // SYNTHETIC: BETA10 0x1015db50 // MxDSStill::`scalar deleting destructor' }; diff --git a/LEGO1/omni/include/mxdsstreamingaction.h b/LEGO1/omni/include/mxdsstreamingaction.h index 96be50e5..22ccd62d 100644 --- a/LEGO1/omni/include/mxdsstreamingaction.h +++ b/LEGO1/omni/include/mxdsstreamingaction.h @@ -16,7 +16,7 @@ class MxDSStreamingAction : public MxDSAction { MxDSStreamingAction* CopyFrom(MxDSStreamingAction& p_dsStreamingAction); - MxBool HasId(MxU32 p_objectId) override; // vtable+0x34; + MxBool HasId(MxU32 p_objectId) override; // vtable+0x34 void Init(); void SetInternalAction(MxDSAction* p_dsAction); diff --git a/LEGO1/omni/include/mxvideopresenter.h b/LEGO1/omni/include/mxvideopresenter.h index c95445b9..5a51c625 100644 --- a/LEGO1/omni/include/mxvideopresenter.h +++ b/LEGO1/omni/include/mxvideopresenter.h @@ -48,10 +48,13 @@ class MxVideoPresenter : public MxMediaPresenter { virtual MxBool VTable0x7c() { return m_frameBitmap != NULL || m_alpha != NULL; } // vtable+0x7c // FUNCTION: LEGO1 0x1000c7e0 - virtual MxS32 GetWidth() { return m_alpha ? m_alpha->m_width : m_frameBitmap->GetBmiWidth(); } // vtable+0x80 + virtual MxS32 GetWidth() { return m_alpha ? m_alpha->GetWidth() : m_frameBitmap->GetBmiWidth(); } // vtable+0x80 // FUNCTION: LEGO1 0x1000c800 - virtual MxS32 GetHeight() { return m_alpha ? m_alpha->m_height : m_frameBitmap->GetBmiHeightAbs(); } // vtable+0x84 + virtual MxS32 GetHeight() + { + return m_alpha ? m_alpha->GetHeight() : m_frameBitmap->GetBmiHeightAbs(); + } // vtable+0x84 // FUNCTION: BETA10 0x100551b0 static const char* HandlerClassName() @@ -85,19 +88,24 @@ class MxVideoPresenter : public MxMediaPresenter { // VTABLE: LEGO1 0x100dc2bc // SIZE 0x0c - struct AlphaMask { - MxU8* m_bitmask; - MxU16 m_width; - MxU16 m_height; - + class AlphaMask { + public: AlphaMask(const MxBitmap&); AlphaMask(const AlphaMask&); virtual ~AlphaMask(); MxS32 IsHit(MxU32 p_x, MxU32 p_y); + MxS32 GetWidth() const { return m_width; } + MxS32 GetHeight() const { return m_height; } + // SYNTHETIC: LEGO1 0x100b2650 // MxVideoPresenter::AlphaMask::`scalar deleting destructor' + + private: + MxU8* m_bitmask; // 0x00 + MxU16 m_width; // 0x04 + MxU16 m_height; // 0x08 }; inline MxS32 PrepareRects(RECT& p_rectDest, RECT& p_rectSrc); diff --git a/LEGO1/omni/src/action/mxdsanim.cpp b/LEGO1/omni/src/action/mxdsanim.cpp index fd15ce70..ca4a4c05 100644 --- a/LEGO1/omni/src/action/mxdsanim.cpp +++ b/LEGO1/omni/src/action/mxdsanim.cpp @@ -6,20 +6,29 @@ DECOMP_SIZE_ASSERT(MxDSAnim, 0xb8) // FUNCTION: BETA10 0x1015cd71 MxDSAnim::MxDSAnim() { - this->SetType(e_anim); + m_type = e_anim; } // FUNCTION: LEGO1 0x100c91a0 +// FUNCTION: BETA10 0x1015cde9 MxDSAnim::~MxDSAnim() { } // FUNCTION: LEGO1 0x100c91f0 +// FUNCTION: BETA10 0x1015ce51 void MxDSAnim::CopyFrom(MxDSAnim& p_dsAnim) { } +// FUNCTION: BETA10 0x1015ce69 +MxDSAnim::MxDSAnim(MxDSAnim& p_dsAnim) : MxDSMediaAction(p_dsAnim) +{ + CopyFrom(p_dsAnim); +} + // FUNCTION: LEGO1 0x100c9200 +// FUNCTION: BETA10 0x1015ceea MxDSAnim& MxDSAnim::operator=(MxDSAnim& p_dsAnim) { if (this == &p_dsAnim) { @@ -27,11 +36,12 @@ MxDSAnim& MxDSAnim::operator=(MxDSAnim& p_dsAnim) } MxDSMediaAction::operator=(p_dsAnim); - this->CopyFrom(p_dsAnim); + CopyFrom(p_dsAnim); return *this; } // FUNCTION: LEGO1 0x100c9230 +// FUNCTION: BETA10 0x1015cf31 MxDSAction* MxDSAnim::Clone() { MxDSAnim* clone = new MxDSAnim(); diff --git a/LEGO1/omni/src/action/mxdsevent.cpp b/LEGO1/omni/src/action/mxdsevent.cpp index fbbc2bdb..75dfbcfa 100644 --- a/LEGO1/omni/src/action/mxdsevent.cpp +++ b/LEGO1/omni/src/action/mxdsevent.cpp @@ -6,20 +6,29 @@ DECOMP_SIZE_ASSERT(MxDSEvent, 0xb8) // FUNCTION: BETA10 0x1015d2e5 MxDSEvent::MxDSEvent() { - this->SetType(e_event); + m_type = e_event; } // FUNCTION: LEGO1 0x100c97a0 +// FUNCTION: BETA10 0x1015d35d MxDSEvent::~MxDSEvent() { } // FUNCTION: LEGO1 0x100c97f0 +// FUNCTION: BETA10 0x1015d3c5 void MxDSEvent::CopyFrom(MxDSEvent& p_dsEvent) { } +// FUNCTION: BETA10 0x1015d3dd +MxDSEvent::MxDSEvent(MxDSEvent& p_dsEvent) : MxDSMediaAction(p_dsEvent) +{ + CopyFrom(p_dsEvent); +} + // FUNCTION: LEGO1 0x100c9800 +// FUNCTION: BETA10 0x1015d45e MxDSEvent& MxDSEvent::operator=(MxDSEvent& p_dsEvent) { if (this == &p_dsEvent) { @@ -27,11 +36,12 @@ MxDSEvent& MxDSEvent::operator=(MxDSEvent& p_dsEvent) } MxDSMediaAction::operator=(p_dsEvent); - this->CopyFrom(p_dsEvent); + CopyFrom(p_dsEvent); return *this; } // FUNCTION: LEGO1 0x100c9830 +// FUNCTION: BETA10 0x1015d4a5 MxDSAction* MxDSEvent::Clone() { MxDSEvent* clone = new MxDSEvent(); diff --git a/LEGO1/omni/src/action/mxdsmediaaction.cpp b/LEGO1/omni/src/action/mxdsmediaaction.cpp index 68d4dd2a..00ed247a 100644 --- a/LEGO1/omni/src/action/mxdsmediaaction.cpp +++ b/LEGO1/omni/src/action/mxdsmediaaction.cpp @@ -87,8 +87,9 @@ void MxDSMediaAction::CopyMediaSrcPath(const char* p_mediaSrcPath) if (m_mediaSrcPath) { strcpy(m_mediaSrcPath, p_mediaSrcPath); } - - MxTrace("MxDSMediaAction: name allocation failed: %s.\n", p_mediaSrcPath); + else { + MxTrace("MxDSMediaAction: name allocation failed: %s.\n", p_mediaSrcPath); + } } else { m_mediaSrcPath = NULL; diff --git a/LEGO1/omni/src/action/mxdsmultiaction.cpp b/LEGO1/omni/src/action/mxdsmultiaction.cpp index 0425b508..d1214d3d 100644 --- a/LEGO1/omni/src/action/mxdsmultiaction.cpp +++ b/LEGO1/omni/src/action/mxdsmultiaction.cpp @@ -1,5 +1,7 @@ #include "mxdsmultiaction.h" +#include + DECOMP_SIZE_ASSERT(MxDSMultiAction, 0x9c) DECOMP_SIZE_ASSERT(MxDSActionList, 0x1c); DECOMP_SIZE_ASSERT(MxDSActionListCursor, 0x10); @@ -8,33 +10,40 @@ DECOMP_SIZE_ASSERT(MxDSActionListCursor, 0x10); // FUNCTION: BETA10 0x10159410 MxDSMultiAction::MxDSMultiAction() { - this->SetType(e_multiAction); - this->m_actions = new MxDSActionList; - this->m_actions->SetDestroy(MxDSActionList::Destroy); + m_type = e_multiAction; + m_actionList = new MxDSActionList; + assert(m_actionList); + m_actionList->SetDestroy(MxDSActionList::Destroy); } // FUNCTION: LEGO1 0x100ca060 +// FUNCTION: BETA10 0x10159518 MxDSMultiAction::~MxDSMultiAction() { - if (this->m_actions) { - delete this->m_actions; - } + delete m_actionList; } // FUNCTION: LEGO1 0x100ca0d0 // FUNCTION: BETA10 0x101595ad void MxDSMultiAction::CopyFrom(MxDSMultiAction& p_dsMultiAction) { - this->m_actions->DeleteAll(); + m_actionList->DeleteAll(); - MxDSActionListCursor cursor(p_dsMultiAction.m_actions); + MxDSActionListCursor cursor(p_dsMultiAction.m_actionList); MxDSAction* action; while (cursor.Next(action)) { - this->m_actions->Append(action->Clone()); + m_actionList->Append(action->Clone()); } } +// FUNCTION: BETA10 0x10159660 +MxDSMultiAction::MxDSMultiAction(MxDSMultiAction& p_dsMultiAction) : MxDSAction(p_dsMultiAction) +{ + CopyFrom(p_dsMultiAction); +} + // FUNCTION: LEGO1 0x100ca260 +// FUNCTION: BETA10 0x101596e1 MxDSMultiAction& MxDSMultiAction::operator=(MxDSMultiAction& p_dsMultiAction) { if (this == &p_dsMultiAction) { @@ -42,16 +51,17 @@ MxDSMultiAction& MxDSMultiAction::operator=(MxDSMultiAction& p_dsMultiAction) } MxDSAction::operator=(p_dsMultiAction); - this->CopyFrom(p_dsMultiAction); + CopyFrom(p_dsMultiAction); return *this; } // FUNCTION: LEGO1 0x100ca290 +// FUNCTION: BETA10 0x10159728 void MxDSMultiAction::SetUnknown90(MxLong p_unk0x90) { - this->m_unk0x90 = p_unk0x90; + m_unk0x90 = p_unk0x90; - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { action->SetUnknown90(p_unk0x90); @@ -59,11 +69,12 @@ void MxDSMultiAction::SetUnknown90(MxLong p_unk0x90) } // FUNCTION: LEGO1 0x100ca370 +// FUNCTION: BETA10 0x101597ce void MxDSMultiAction::MergeFrom(MxDSAction& p_dsMultiAction) { MxDSAction::MergeFrom(p_dsMultiAction); - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { action->MergeFrom(p_dsMultiAction); @@ -71,13 +82,14 @@ void MxDSMultiAction::MergeFrom(MxDSAction& p_dsMultiAction) } // FUNCTION: LEGO1 0x100ca450 +// FUNCTION: BETA10 0x10159874 MxBool MxDSMultiAction::HasId(MxU32 p_objectId) { - if (this->GetObjectId() == p_objectId) { + if (GetObjectId() == p_objectId) { return TRUE; } - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { if (action->HasId(p_objectId)) { @@ -89,6 +101,7 @@ MxBool MxDSMultiAction::HasId(MxU32 p_objectId) } // FUNCTION: LEGO1 0x100ca550 +// FUNCTION: BETA10 0x10159959 MxDSAction* MxDSMultiAction::Clone() { MxDSMultiAction* clone = new MxDSMultiAction(); @@ -101,11 +114,12 @@ MxDSAction* MxDSMultiAction::Clone() } // FUNCTION: LEGO1 0x100ca5e0 +// FUNCTION: BETA10 0x10159a03 undefined4 MxDSMultiAction::VTable0x14() { undefined4 result = MxDSAction::VTable0x14(); - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { result += action->VTable0x14(); @@ -115,22 +129,26 @@ undefined4 MxDSMultiAction::VTable0x14() } // FUNCTION: LEGO1 0x100ca6c0 +// FUNCTION: BETA10 0x10159aaf MxU32 MxDSMultiAction::GetSizeOnDisk() { - MxU32 totalSizeOnDisk = MxDSAction::GetSizeOnDisk() + 16; + MxU32 totalSizeOnDisk = MxDSAction::GetSizeOnDisk(); + totalSizeOnDisk += 12; + totalSizeOnDisk += 4; - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { totalSizeOnDisk += action->GetSizeOnDisk(); } - this->m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk(); + m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk(); return totalSizeOnDisk; } // FUNCTION: LEGO1 0x100ca7b0 +// FUNCTION: BETA10 0x10159b79 void MxDSMultiAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { MxDSAction::Deserialize(p_source, p_unk0x24); @@ -149,7 +167,7 @@ void MxDSMultiAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24); p_source += extraFlag; - this->m_actions->Append(action); + m_actionList->Append(action); } } @@ -157,11 +175,12 @@ void MxDSMultiAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) } // FUNCTION: LEGO1 0x100ca8c0 +// FUNCTION: BETA10 0x10159c37 void MxDSMultiAction::SetAtomId(MxAtomId p_atomId) { MxDSAction::SetAtomId(p_atomId); - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { action->SetAtomId(p_atomId); diff --git a/LEGO1/omni/src/action/mxdsobjectaction.cpp b/LEGO1/omni/src/action/mxdsobjectaction.cpp index dbfcce10..e4185769 100644 --- a/LEGO1/omni/src/action/mxdsobjectaction.cpp +++ b/LEGO1/omni/src/action/mxdsobjectaction.cpp @@ -6,20 +6,29 @@ DECOMP_SIZE_ASSERT(MxDSObjectAction, 0xb8) // FUNCTION: BETA10 0x1015c3b0 MxDSObjectAction::MxDSObjectAction() { - this->SetType(e_objectAction); + m_type = e_objectAction; } // FUNCTION: LEGO1 0x100c8a20 +// FUNCTION: BETA10 0x1015c428 MxDSObjectAction::~MxDSObjectAction() { } // FUNCTION: LEGO1 0x100c8a70 +// FUNCTION: BETA10 0x1015c490 void MxDSObjectAction::CopyFrom(MxDSObjectAction& p_dsObjectAction) { } +// FUNCTION: BETA10 0x1015c4a8 +MxDSObjectAction::MxDSObjectAction(MxDSObjectAction& p_dsObjectAction) : MxDSMediaAction(p_dsObjectAction) +{ + CopyFrom(p_dsObjectAction); +} + // FUNCTION: LEGO1 0x100c8a80 +// FUNCTION: BETA10 0x1015c529 MxDSObjectAction& MxDSObjectAction::operator=(MxDSObjectAction& p_dsObjectAction) { if (this == &p_dsObjectAction) { @@ -27,11 +36,12 @@ MxDSObjectAction& MxDSObjectAction::operator=(MxDSObjectAction& p_dsObjectAction } MxDSMediaAction::operator=(p_dsObjectAction); - this->CopyFrom(p_dsObjectAction); + CopyFrom(p_dsObjectAction); return *this; } // FUNCTION: LEGO1 0x100c8ab0 +// FUNCTION: BETA10 0x1015c573 MxDSAction* MxDSObjectAction::Clone() { MxDSObjectAction* clone = new MxDSObjectAction(); diff --git a/LEGO1/omni/src/action/mxdsparallelaction.cpp b/LEGO1/omni/src/action/mxdsparallelaction.cpp index 4ea4f6ea..55a59e57 100644 --- a/LEGO1/omni/src/action/mxdsparallelaction.cpp +++ b/LEGO1/omni/src/action/mxdsparallelaction.cpp @@ -8,20 +8,29 @@ DECOMP_SIZE_ASSERT(MxDSParallelAction, 0x9c) // FUNCTION: BETA10 0x1015a14d MxDSParallelAction::MxDSParallelAction() { - this->SetType(e_parallelAction); + m_type = e_parallelAction; } // FUNCTION: LEGO1 0x100cb040 +// FUNCTION: BETA10 0x1015a1c5 MxDSParallelAction::~MxDSParallelAction() { } // FUNCTION: LEGO1 0x100cb090 +// FUNCTION: BETA10 0x1015a22d void MxDSParallelAction::CopyFrom(MxDSParallelAction& p_dsParallelAction) { } +// FUNCTION: BETA10 0x1015a245 +MxDSParallelAction::MxDSParallelAction(MxDSParallelAction& p_dsParallelAction) : MxDSMultiAction(p_dsParallelAction) +{ + CopyFrom(p_dsParallelAction); +} + // FUNCTION: LEGO1 0x100cb0a0 +// FUNCTION: BETA10 0x1015a2c6 MxDSParallelAction& MxDSParallelAction::operator=(MxDSParallelAction& p_dsParallelAction) { if (this == &p_dsParallelAction) { @@ -29,11 +38,12 @@ MxDSParallelAction& MxDSParallelAction::operator=(MxDSParallelAction& p_dsParall } MxDSMultiAction::operator=(p_dsParallelAction); - this->CopyFrom(p_dsParallelAction); + CopyFrom(p_dsParallelAction); return *this; } // FUNCTION: LEGO1 0x100cb0d0 +// FUNCTION: BETA10 0x1015a30d MxDSAction* MxDSParallelAction::Clone() { MxDSParallelAction* clone = new MxDSParallelAction(); @@ -46,13 +56,14 @@ MxDSAction* MxDSParallelAction::Clone() } // FUNCTION: LEGO1 0x100cb160 +// FUNCTION: BETA10 0x1015a3b7 MxLong MxDSParallelAction::GetDuration() { - if (this->m_duration) { - return this->m_duration; + if (m_duration) { + return m_duration; } - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { @@ -62,7 +73,7 @@ MxLong MxDSParallelAction::GetDuration() MxLong duration = action->GetDuration(); if (duration == -1) { - this->m_duration = -1; + m_duration = -1; break; } @@ -79,18 +90,18 @@ MxLong MxDSParallelAction::GetDuration() } if (duration == -1) { - this->m_duration = -1; + m_duration = -1; break; } - if (this->m_duration < duration) { - this->m_duration = duration; + if (m_duration < duration) { + m_duration = duration; } } - if (this->IsBit3()) { - this->m_duration *= this->m_loopCount; + if (IsBit3()) { + m_duration *= m_loopCount; } - return this->m_duration; + return m_duration; } diff --git a/LEGO1/omni/src/action/mxdsselectaction.cpp b/LEGO1/omni/src/action/mxdsselectaction.cpp index 44395767..7eff733e 100644 --- a/LEGO1/omni/src/action/mxdsselectaction.cpp +++ b/LEGO1/omni/src/action/mxdsselectaction.cpp @@ -15,44 +15,51 @@ DECOMP_SIZE_ASSERT(MxListEntry, 0x18) // FUNCTION: BETA10 0x1015a515 MxDSSelectAction::MxDSSelectAction() { - this->SetType(e_selectAction); - this->m_unk0xac = new MxStringList; + m_type = e_selectAction; + m_unk0xac = new MxStringList; } // FUNCTION: LEGO1 0x100cb8d0 +// FUNCTION: BETA10 0x1015a5fd MxDSSelectAction::~MxDSSelectAction() { - if (this->m_unk0xac) { - delete this->m_unk0xac; - } + delete m_unk0xac; } // FUNCTION: LEGO1 0x100cb950 // FUNCTION: BETA10 0x1015a6ae void MxDSSelectAction::CopyFrom(MxDSSelectAction& p_dsSelectAction) { - this->m_unk0x9c = p_dsSelectAction.m_unk0x9c; + m_unk0x9c = p_dsSelectAction.m_unk0x9c; - this->m_unk0xac->DeleteAll(); + m_unk0xac->DeleteAll(); MxStringListCursor cursor(p_dsSelectAction.m_unk0xac); MxString string; while (cursor.Next(string)) { - this->m_unk0xac->Append(string); + m_unk0xac->Append(string); } } +// FUNCTION: BETA10 0x1015a7ad +MxDSSelectAction::MxDSSelectAction(MxDSSelectAction& p_dsSelectAction) : MxDSParallelAction(p_dsSelectAction) +{ + CopyFrom(p_dsSelectAction); +} + // FUNCTION: LEGO1 0x100cbd50 +// FUNCTION: BETA10 0x1015a84f MxDSSelectAction& MxDSSelectAction::operator=(MxDSSelectAction& p_dsSelectAction) { if (this != &p_dsSelectAction) { MxDSParallelAction::operator=(p_dsSelectAction); - this->CopyFrom(p_dsSelectAction); + CopyFrom(p_dsSelectAction); } return *this; } // FUNCTION: LEGO1 0x100cbd80 +// FUNCTION: BETA10 0x1015a88e MxDSAction* MxDSSelectAction::Clone() { MxDSSelectAction* clone = new MxDSSelectAction(); @@ -65,13 +72,14 @@ MxDSAction* MxDSSelectAction::Clone() } // FUNCTION: LEGO1 0x100cbe10 +// FUNCTION: BETA10 0x1015a938 MxU32 MxDSSelectAction::GetSizeOnDisk() { MxU32 totalSizeOnDisk = MxDSParallelAction::GetSizeOnDisk(); - totalSizeOnDisk += strlen(this->m_unk0x9c.GetData()) + 1; + totalSizeOnDisk += strlen(m_unk0x9c.GetData()) + 1; - MxStringListCursor cursor(this->m_unk0xac); + MxStringListCursor cursor(m_unk0xac); MxString string; while (cursor.Next(string)) { totalSizeOnDisk += strlen(string.GetData()) + 1; @@ -79,7 +87,7 @@ MxU32 MxDSSelectAction::GetSizeOnDisk() // Note: unlike the other classes, MxDSSelectAction does not have its own // sizeOnDisk member. Instead, it overrides the one from MxDSMultiAction. - this->m_sizeOnDisk = totalSizeOnDisk; + m_sizeOnDisk = totalSizeOnDisk; return totalSizeOnDisk; } @@ -88,25 +96,26 @@ MxU32 MxDSSelectAction::GetSizeOnDisk() // FUNCTION: BETA10 0x1015aa30 void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { + MxDSAction* action = NULL; MxString string; MxDSAction::Deserialize(p_source, p_unk0x24); MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; p_source += 12; - this->m_unk0x9c = (char*) p_source; + m_unk0x9c = (char*) p_source; - if (!SDL_strncasecmp(this->m_unk0x9c.GetData(), "RANDOM_", strlen("RANDOM_"))) { + if (SDL_strncasecmp(m_unk0x9c.GetData(), "RANDOM_", strlen("RANDOM_")) != 0) { + string = VariableTable()->GetVariable((char*) p_source); + } + else { char buffer[10]; - MxS16 value = atoi(&this->m_unk0x9c.GetData()[strlen("RANDOM_")]); + MxS16 value = atoi(&m_unk0x9c.GetData()[strlen("RANDOM_")]); srand(Timer()->GetTime()); MxS32 random = rand() % value; string = SDL_itoa((MxS16) random, buffer, 10); } - else { - string = VariableTable()->GetVariable((char*) p_source); - } p_source += strlen((char*) p_source) + 1; @@ -115,7 +124,7 @@ void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) if (count) { MxS32 index = -1; - this->m_unk0xac->DeleteAll(); + m_unk0xac->DeleteAll(); MxU32 i; for (i = 0; i < count; i++) { @@ -123,7 +132,7 @@ void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) index = i; } - this->m_unk0xac->Append((char*) p_source); + m_unk0xac->Append((char*) p_source); p_source += strlen((char*) p_source) + 1; } @@ -131,10 +140,10 @@ void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; p_source += 8; - MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24); + action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24); if (index == i) { - this->m_actions->Append(action); + m_actionList->Append(action); } else { delete action; diff --git a/LEGO1/omni/src/action/mxdsserialaction.cpp b/LEGO1/omni/src/action/mxdsserialaction.cpp index d258dee8..71e952fb 100644 --- a/LEGO1/omni/src/action/mxdsserialaction.cpp +++ b/LEGO1/omni/src/action/mxdsserialaction.cpp @@ -1,5 +1,6 @@ #include "mxdsserialaction.h" +#include "mxdebug.h" #include "mxdsmediaaction.h" DECOMP_SIZE_ASSERT(MxDSSerialAction, 0xa8) @@ -8,33 +9,43 @@ DECOMP_SIZE_ASSERT(MxDSSerialAction, 0xa8) // FUNCTION: BETA10 0x10159cf3 MxDSSerialAction::MxDSSerialAction() { - this->SetType(e_serialAction); - this->m_cursor = new MxDSActionListCursor(this->m_actions); - this->m_unk0xa0 = 0; + m_type = e_serialAction; + m_cursor = new MxDSActionListCursor(m_actionList); + m_unk0xa0 = 0; } // FUNCTION: LEGO1 0x100caac0 +// FUNCTION: BETA10 0x1015b280 void MxDSSerialAction::SetDuration(MxLong p_duration) { - this->m_duration = p_duration; + m_duration = p_duration; } // FUNCTION: LEGO1 0x100cac10 +// FUNCTION: BETA10 0x10159dd1 MxDSSerialAction::~MxDSSerialAction() { - if (this->m_cursor) { - delete this->m_cursor; - } - - this->m_cursor = NULL; + delete m_cursor; + m_cursor = NULL; } // FUNCTION: LEGO1 0x100cac90 +// FUNCTION: BETA10 0x10159e73 void MxDSSerialAction::CopyFrom(MxDSSerialAction& p_dsSerialAction) { + if (p_dsSerialAction.m_cursor->HasMatch() || p_dsSerialAction.m_unk0xa0) { + MxTrace("copying a serialAction while someone is traversing it's list\n"); + } +} + +// FUNCTION: BETA10 0x10159ec2 +MxDSSerialAction::MxDSSerialAction(MxDSSerialAction& p_dsSerialAction) : MxDSMultiAction(p_dsSerialAction) +{ + CopyFrom(p_dsSerialAction); } // FUNCTION: LEGO1 0x100caca0 +// FUNCTION: BETA10 0x10159f43 MxDSSerialAction& MxDSSerialAction::operator=(MxDSSerialAction& p_dsSerialAction) { if (this == &p_dsSerialAction) { @@ -42,11 +53,12 @@ MxDSSerialAction& MxDSSerialAction::operator=(MxDSSerialAction& p_dsSerialAction } MxDSMultiAction::operator=(p_dsSerialAction); - this->CopyFrom(p_dsSerialAction); + CopyFrom(p_dsSerialAction); return *this; } // FUNCTION: LEGO1 0x100cacd0 +// FUNCTION: BETA10 0x10159f8a MxDSAction* MxDSSerialAction::Clone() { MxDSSerialAction* clone = new MxDSSerialAction(); @@ -59,30 +71,29 @@ MxDSAction* MxDSSerialAction::Clone() } // FUNCTION: LEGO1 0x100cad60 +// FUNCTION: BETA10 0x1015a034 MxLong MxDSSerialAction::GetDuration() { - if (this->m_duration) { - return this->m_duration; + if (m_duration) { + return m_duration; } - MxDSActionListCursor cursor(this->m_actions); + MxDSActionListCursor cursor(m_actionList); MxDSAction* action; while (cursor.Next(action)) { - if (!action) { - continue; - } + if (action) { + m_duration += action->GetDuration() + action->GetStartTime(); - this->m_duration += action->GetDuration() + action->GetStartTime(); + if (action->IsA("MxDSMediaAction")) { + MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime(); - if (action->IsA("MxDSMediaAction")) { - MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime(); - - if (sustainTime && sustainTime != -1) { - this->m_duration += sustainTime; + if (sustainTime && sustainTime != -1) { + m_duration += sustainTime; + } } } } - return this->m_duration; + return m_duration; } diff --git a/LEGO1/omni/src/action/mxdssound.cpp b/LEGO1/omni/src/action/mxdssound.cpp index 7dc8d69a..5a12aa90 100644 --- a/LEGO1/omni/src/action/mxdssound.cpp +++ b/LEGO1/omni/src/action/mxdssound.cpp @@ -1,30 +1,37 @@ #include "mxdssound.h" -#include "mxutilities.h" - DECOMP_SIZE_ASSERT(MxDSSound, 0xc0) // FUNCTION: LEGO1 0x100c92c0 // FUNCTION: BETA10 0x1015cfdb MxDSSound::MxDSSound() { - this->m_volume = 0x4f; - this->SetType(e_sound); + m_type = e_sound; + m_volume = 0x4f; } // FUNCTION: LEGO1 0x100c9470 +// FUNCTION: BETA10 0x1015d060 MxDSSound::~MxDSSound() { } // FUNCTION: LEGO1 0x100c94c0 +// FUNCTION: BETA10 0x1015d0c8 void MxDSSound::CopyFrom(MxDSSound& p_dsSound) { - this->SetType(p_dsSound.GetType()); - this->m_volume = p_dsSound.m_volume; + m_type = p_dsSound.m_type; + m_volume = p_dsSound.m_volume; +} + +// FUNCTION: BETA10 0x1015d100 +MxDSSound::MxDSSound(MxDSSound& p_dsSound) : MxDSMediaAction(p_dsSound) +{ + CopyFrom(p_dsSound); } // FUNCTION: LEGO1 0x100c94e0 +// FUNCTION: BETA10 0x1015d181 MxDSSound& MxDSSound::operator=(MxDSSound& p_dsSound) { if (this == &p_dsSound) { @@ -32,11 +39,12 @@ MxDSSound& MxDSSound::operator=(MxDSSound& p_dsSound) } MxDSMediaAction::operator=(p_dsSound); - this->CopyFrom(p_dsSound); + CopyFrom(p_dsSound); return *this; } // FUNCTION: LEGO1 0x100c9510 +// FUNCTION: BETA10 0x1015d1c8 MxDSAction* MxDSSound::Clone() { MxDSSound* clone = new MxDSSound(); @@ -49,18 +57,21 @@ MxDSAction* MxDSSound::Clone() } // FUNCTION: LEGO1 0x100c95a0 +// FUNCTION: BETA10 0x1015d272 void MxDSSound::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { MxDSMediaAction::Deserialize(p_source, p_unk0x24); - - GetScalar(p_source, this->m_volume); + m_volume = *(MxS32*) p_source; + p_source += sizeof(m_volume); } // FUNCTION: LEGO1 0x100c95d0 +// FUNCTION: BETA10 0x1015d2b0 MxU32 MxDSSound::GetSizeOnDisk() { MxU32 totalSizeOnDisk = MxDSMediaAction::GetSizeOnDisk(); + totalSizeOnDisk += sizeof(m_volume); - this->m_sizeOnDisk = sizeof(this->m_volume); - return totalSizeOnDisk + 4; + m_sizeOnDisk = sizeof(m_volume); + return totalSizeOnDisk; } diff --git a/LEGO1/omni/src/action/mxdsstill.cpp b/LEGO1/omni/src/action/mxdsstill.cpp index 7e6df18b..fe220d48 100644 --- a/LEGO1/omni/src/action/mxdsstill.cpp +++ b/LEGO1/omni/src/action/mxdsstill.cpp @@ -6,20 +6,29 @@ DECOMP_SIZE_ASSERT(MxDSStill, 0xb8) // FUNCTION: BETA10 0x1015d54f MxDSStill::MxDSStill() { - this->SetType(e_still); + m_type = e_still; } // FUNCTION: LEGO1 0x100c9a70 +// FUNCTION: BETA10 0x1015d5c7 MxDSStill::~MxDSStill() { } // FUNCTION: LEGO1 0x100c9ac0 +// FUNCTION: BETA10 0x1015d62f void MxDSStill::CopyFrom(MxDSStill& p_dsStill) { } +// FUNCTION: BETA10 0x1015d647 +MxDSStill::MxDSStill(MxDSStill& p_dsStill) : MxDSMediaAction(p_dsStill) +{ + CopyFrom(p_dsStill); +} + // FUNCTION: LEGO1 0x100c9ad0 +// FUNCTION: BETA10 0x1015d6c8 MxDSStill& MxDSStill::operator=(MxDSStill& p_dsStill) { if (this == &p_dsStill) { @@ -27,11 +36,12 @@ MxDSStill& MxDSStill::operator=(MxDSStill& p_dsStill) } MxDSMediaAction::operator=(p_dsStill); - this->CopyFrom(p_dsStill); + CopyFrom(p_dsStill); return *this; } // FUNCTION: LEGO1 0x100c9b00 +// FUNCTION: BETA10 0x1015d70f MxDSAction* MxDSStill::Clone() { MxDSStill* clone = new MxDSStill(); diff --git a/LEGO1/tgl/d3drm/camera.cpp b/LEGO1/tgl/d3drm/camera.cpp index c7bc06f9..9b64a25e 100644 --- a/LEGO1/tgl/d3drm/camera.cpp +++ b/LEGO1/tgl/d3drm/camera.cpp @@ -6,6 +6,7 @@ DECOMP_SIZE_ASSERT(Camera, 0x04); DECOMP_SIZE_ASSERT(CameraImpl, 0x08); // FUNCTION: LEGO1 0x100a36f0 +// FUNCTION: BETA10 0x1016f2e0 void* CameraImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); diff --git a/LEGO1/tgl/d3drm/device.cpp b/LEGO1/tgl/d3drm/device.cpp index a1c7b0c8..2d17a5c9 100644 --- a/LEGO1/tgl/d3drm/device.cpp +++ b/LEGO1/tgl/d3drm/device.cpp @@ -1,10 +1,12 @@ #include "impl.h" +#include #include using namespace TglImpl; // FUNCTION: LEGO1 0x100a2bf0 +// FUNCTION: BETA10 0x1016ddf0 void* DeviceImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); @@ -28,13 +30,20 @@ Result DeviceImpl::SetColorModel(ColorModel) return Success; } +// FUNCTION: BETA10 0x1016e020 +inline Result DeviceSetShadingModel(IDirect3DRMDevice2* pDevice, ShadingModel model) +{ + D3DRMRENDERQUALITY renderQuality = Translate(model); + return ResultVal(pDevice->SetQuality(renderQuality)); +} + // FUNCTION: LEGO1 0x100a2c30 +// FUNCTION: BETA10 0x1016dfc0 Result DeviceImpl::SetShadingModel(ShadingModel model) { - // Doesn't match well even though we know this is exactly - // the original code thanks to the jump table. - D3DRMRENDERQUALITY renderQuality = Translate(model); - return ResultVal(m_data->SetQuality(renderQuality)); + assert(m_data); + + return DeviceSetShadingModel(m_data, model); } // FUNCTION: LEGO1 0x100a2ca0 diff --git a/LEGO1/tgl/d3drm/group.cpp b/LEGO1/tgl/d3drm/group.cpp index 912cc137..686b1540 100644 --- a/LEGO1/tgl/d3drm/group.cpp +++ b/LEGO1/tgl/d3drm/group.cpp @@ -3,6 +3,7 @@ using namespace TglImpl; // FUNCTION: LEGO1 0x100a31d0 +// FUNCTION: BETA10 0x1016a480 void* GroupImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index b9fbe7ae..9f84bbf6 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -26,6 +26,7 @@ namespace TglImpl using namespace Tgl; // Utility function used by implementations +// FUNCTION: BETA10 0x10169cf0 inline Result ResultVal(HRESULT result) { return SUCCEEDED(result) ? Success : Error; @@ -43,9 +44,13 @@ class TextureImpl; class MeshBuilderImpl; // VTABLE: LEGO1 0x100db910 +// VTABLE: BETA10 0x101c30d8 class RendererImpl : public Renderer { public: + // FUNCTION: BETA10 0x10169a20 RendererImpl() : m_data(0) {} + + // FUNCTION: BETA10 0x10169d20 ~RendererImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -90,18 +95,49 @@ class RendererImpl : public Renderer { return m_data->CreateTextureFromSurface(pSurface, pTexture2); } - IDirect3DRM2* ImplementationData() const { return m_data; } + typedef IDirect3DRM2* RendererDataType; + + const RendererDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x10174c10 + RendererDataType& ImplementationData() { return m_data; } public: inline Result Create(); inline void Destroy(); + inline Result CreateLight(LightType type, float r, float g, float b, LightImpl& rLight); + inline Result CreateView( + const DeviceImpl& rDevice, + const CameraImpl& rCamera, + unsigned long x, + unsigned long y, + unsigned long width, + unsigned long height, + ViewImpl& rView + ); + inline Result CreateMeshBuilder(MeshBuilderImpl& rMesh); + inline Result CreateCamera(CameraImpl& rCamera); + inline Result CreateTexture(TextureImpl& rTexture); + inline Result CreateTexture( + TextureImpl& rTexture, + int width, + int height, + int bitsPerTexel, + const void* pTexels, + int texelsArePersistent, + int paletteEntryCount, + const PaletteEntry* pEntries + ); + inline Result CreateDevice(const DeviceDirect3DCreateData& rCreateData, DeviceImpl& rDevice); + inline Result CreateDevice(const DeviceDirectDrawCreateData& rCreateData, DeviceImpl& rDevice); private: - IDirect3DRM2* m_data; + RendererDataType m_data; }; extern IDirect3DRM2* g_pD3DRM; +// FUNCTION: BETA10 0x1016dd20 inline void RendererDestroy(IDirect3DRM2* pRenderer) { int refCount = pRenderer->Release(); @@ -111,6 +147,7 @@ inline void RendererDestroy(IDirect3DRM2* pRenderer) } // Inlined only +// FUNCTION: BETA10 0x1016dce0 void RendererImpl::Destroy() { if (m_data) { @@ -120,16 +157,14 @@ void RendererImpl::Destroy() } // VTABLE: LEGO1 0x100db988 +// VTABLE: BETA10 0x101c31f0 class DeviceImpl : public Device { public: + // FUNCTION: BETA10 0x1016b2e0 DeviceImpl() : m_data(0) {} - ~DeviceImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x1016dd80 + ~DeviceImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -148,26 +183,48 @@ class DeviceImpl : public Device { void HandleActivate(WORD) override; void HandlePaint(HDC) override; - IDirect3DRMDevice2* ImplementationData() const { return m_data; } + typedef IDirect3DRMDevice2* DeviceDataType; + + // FUNCTION: BETA10 0x101708e0 + const DeviceDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x100d9540 + DeviceDataType& ImplementationData() { return m_data; } + void SetImplementationData(IDirect3DRMDevice2* device) { m_data = device; } + inline void Destroy(); + friend class RendererImpl; private: - IDirect3DRMDevice2* m_data; + DeviceDataType m_data; }; +// FUNCTION: BETA10 0x101708c0 +inline void DeviceDestroy(IDirect3DRMDevice2* pDevice) +{ + pDevice->Release(); +} + +// FUNCTION: BETA10 0x10170880 +void DeviceImpl::Destroy() +{ + if (m_data) { + DeviceDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100db9e8 +// VTABLE: BETA10 0x101c3220 class ViewImpl : public View { public: + // FUNCTION: BETA10 0x1016b360 ViewImpl() : m_data(0) {} - ~ViewImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x1016e5d0 + ~ViewImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -199,53 +256,107 @@ class ViewImpl : public View { int& rPickedGroupCount ) override; - IDirect3DRMViewport* ImplementationData() const { return m_data; } + typedef IDirect3DRMViewport* ViewDataType; + + const ViewDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x101711c0 + ViewDataType& ImplementationData() { return m_data; } + void SetImplementationData(IDirect3DRMViewport* viewport) { m_data = viewport; } static Result ViewportCreateAppData(IDirect3DRM2*, IDirect3DRMViewport*, IDirect3DRMFrame2*); + inline void Destroy(); + Result Add(const LightImpl& rLight); + Result Remove(const LightImpl& rLight); + Result SetCamera(const CameraImpl& rCamera); + Result Render(const GroupImpl& rScene); + Result Pick( + unsigned long x, + unsigned long y, + const GroupImpl** ppGroupsToPickFrom, + int groupsToPickFromCount, + const Group**& rppPickedGroups, + int& rPickedGroupCount + ); + friend class RendererImpl; private: - IDirect3DRMViewport* m_data; + ViewDataType m_data; }; +// FUNCTION: BETA10 0x101711a0 +inline void ViewDestroy(IDirect3DRMViewport* pView) +{ + pView->Release(); +} + +// FUNCTION: BETA10 0x10171160 +void ViewImpl::Destroy() +{ + if (m_data) { + ViewDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbad8 +// VTABLE: BETA10 0x101c3260 class CameraImpl : public Camera { public: + // FUNCTION: BETA10 0x1016b3e0 CameraImpl() : m_data(0) {} - ~CameraImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x1016f200 + ~CameraImpl() override { Destroy(); } void* ImplementationDataPtr() override; // vtable+0x08 Result SetTransformation(FloatMatrix4&) override; - IDirect3DRMFrame2* ImplementationData() const { return m_data; } + typedef IDirect3DRMFrame2* CameraDataType; + + // FUNCTION: BETA10 0x10170960 + const CameraDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x10170980 + CameraDataType& ImplementationData() { return m_data; } + + inline void Destroy(); friend class RendererImpl; private: - IDirect3DRMFrame2* m_data; + CameraDataType m_data; }; +// FUNCTION: BETA10 0x10170940 +inline void CameraDestroy(IDirect3DRMFrame2* pFrame) +{ + pFrame->Release(); +} + +// FUNCTION: BETA10 0x10170900 +void CameraImpl::Destroy() +{ + if (m_data) { + CameraDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbaf8 +// VTABLE: BETA10 0x101c3270 class LightImpl : public Light { public: + // FUNCTION: BETA10 0x1016b460 LightImpl() : m_data(0) {} - ~LightImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x1016f5c0 + ~LightImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -253,25 +364,46 @@ class LightImpl : public Light { Result SetTransformation(FloatMatrix4&) override; Result SetColor(float r, float g, float b) override; - IDirect3DRMFrame2* ImplementationData() const { return m_data; } + typedef IDirect3DRMFrame2* LightDataType; + + // FUNCTION: BETA10 0x10171b90 + const LightDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x10171240 + LightDataType& ImplementationData() { return m_data; } + + inline void Destroy(); friend class RendererImpl; private: - IDirect3DRMFrame2* m_data; + LightDataType m_data; }; +// FUNCTION: BETA10 0x10171220 +inline void LightDestroy(IDirect3DRMFrame2* pLight) +{ + pLight->Release(); +} + +// FUNCTION: BETA10 0x101711e0 +void LightImpl::Destroy() +{ + if (m_data) { + LightDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbb88 +// VTABLE: BETA10 0x101c3340 class MeshImpl : public Mesh { public: + // FUNCTION: BETA10 0x1016f970 MeshImpl() : m_data(0) {} - ~MeshImpl() override - { - if (m_data) { - delete m_data; - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x10170460 + ~MeshImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -296,25 +428,43 @@ class MeshImpl : public Mesh { typedef MeshData* MeshDataType; const MeshDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x10171b70 MeshDataType& ImplementationData() { return m_data; } + inline void Destroy(); + inline Mesh* DeepClone(const MeshBuilderImpl& rMesh); + friend class RendererImpl; private: MeshDataType m_data; }; +// FUNCTION: BETA10 0x10171b40 +inline void MeshDestroy(MeshImpl::MeshDataType pMesh) +{ + delete pMesh; +} + +// FUNCTION: BETA10 0x10171b00 +void MeshImpl::Destroy() +{ + if (m_data) { + MeshDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dba68 +// VTABLE: BETA10 0x101c3150 class GroupImpl : public Group { public: + // FUNCTION: BETA10 0x1016a240 GroupImpl() : m_data(0) {} - ~GroupImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x1016a410 + ~GroupImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -337,25 +487,46 @@ class GroupImpl : public Group { // vtable+0x30 Result Bounds(D3DVECTOR* p_min, D3DVECTOR* p_max) override; - IDirect3DRMFrame2* ImplementationData() const { return m_data; } + typedef IDirect3DRMFrame2* GroupDataType; + + // FUNCTION: BETA10 0x1016fc20 + const GroupDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x1016fce0 + GroupDataType& ImplementationData() { return m_data; } + + inline void Destroy(); friend class RendererImpl; private: - IDirect3DRMFrame2* m_data; + GroupDataType m_data; }; +// FUNCTION: BETA10 0x1016c2b0 +inline void GroupDestroy(IDirect3DRMFrame2* pGroup) +{ + pGroup->Release(); +} + +// FUNCTION: BETA10 0x1016c270 +void GroupImpl::Destroy() +{ + if (m_data) { + GroupDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbb18 +// VTABLE: BETA10 0x101c31e0 class MeshBuilderImpl : public MeshBuilder { public: + // FUNCTION: BETA10 0x1016b260 MeshBuilderImpl() : m_data(0) {} - ~MeshBuilderImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x1016c7e0 + ~MeshBuilderImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -375,7 +546,15 @@ class MeshBuilderImpl : public MeshBuilder { // vtable+0x10 MeshBuilder* Clone() override; - IDirect3DRMMesh* ImplementationData() const { return m_data; } + typedef IDirect3DRMMesh* MeshBuilderDataType; + + // FUNCTION: BETA10 0x10170420 + const MeshBuilderDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x10170440 + MeshBuilderDataType& ImplementationData() { return m_data; } + + inline void Destroy(); friend class RendererImpl; @@ -392,9 +571,24 @@ class MeshBuilderImpl : public MeshBuilder { ShadingModel shadingModel ); - IDirect3DRMMesh* m_data; + MeshBuilderDataType m_data; }; +// FUNCTION: BETA10 0x10170390 +inline void MeshBuilderDestroy(IDirect3DRMMesh* pMeshBuilder) +{ + pMeshBuilder->Release(); +} + +// FUNCTION: BETA10 0x10170350 +void MeshBuilderImpl::Destroy() +{ + if (m_data) { + MeshBuilderDestroy(m_data); + m_data = NULL; + } +} + // No vtable, this is just a simple wrapper around D3DRMIMAGE class TglD3DRMIMAGE { public: @@ -419,16 +613,14 @@ class TglD3DRMIMAGE { }; // VTABLE: LEGO1 0x100dbb48 +// VTABLE: BETA10 0x101c31c0 class TextureImpl : public Texture { public: + // FUNCTION: BETA10 0x1016b1e0 TextureImpl() : m_data(0) {} - ~TextureImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + + // FUNCTION: BETA10 0x1016c2d0 + ~TextureImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -448,18 +640,43 @@ class TextureImpl : public Texture { ) override; Result SetPalette(int entryCount, PaletteEntry* entries) override; - IDirect3DRMTexture* ImplementationData() const { return m_data; } + typedef IDirect3DRMTexture* TextureDataType; + + // FUNCTION: BETA10 0x1016fd60 + const TextureDataType& ImplementationData() const { return m_data; } + + // FUNCTION: BETA10 0x1016fe20 + TextureDataType& ImplementationData() { return m_data; } + void SetImplementation(IDirect3DRMTexture* pData) { m_data = pData; } + inline void Destroy(); + friend class RendererImpl; static Result SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage); private: - IDirect3DRMTexture* m_data; + TextureDataType m_data; }; +// FUNCTION: BETA10 0x1016fd40 +inline void TextureDestroy(IDirect3DRMTexture* pTexture) +{ + pTexture->Release(); +} + +// FUNCTION: BETA10 0x1016fd00 +void TextureImpl::Destroy() +{ + if (m_data) { + TextureDestroy(m_data); + m_data = NULL; + } +} + // Translation helpers +// FUNCTION: BETA10 0x1016fc40 inline D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel) { D3DRMRENDERQUALITY renderQuality; @@ -488,6 +705,7 @@ inline D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel) return renderQuality; } +// FUNCTION: BETA10 0x101703b0 inline D3DRMPROJECTIONTYPE Translate(ProjectionType tglProjectionType) { D3DRMPROJECTIONTYPE projectionType; @@ -518,33 +736,85 @@ inline D3DRMMATRIX4D* Translate(FloatMatrix4& tglMatrix4x4, D3DRMMATRIX4D& rD3DR return &rD3DRMMatrix4x4; } +// FUNCTION: BETA10 0x1016fba0 +inline D3DVECTOR* Translate(const float tglVector[3], D3DVECTOR& rD3DVector) +{ + rD3DVector.x = D3DVAL(tglVector[0]); + rD3DVector.y = D3DVAL(tglVector[1]); + rD3DVector.z = D3DVAL(tglVector[2]); + + return &rD3DVector; +} + +// FUNCTION: BETA10 0x1016fd80 +inline D3DRMLIGHTTYPE Translate(LightType tglLightType) +{ + D3DRMLIGHTTYPE lightType; + + // ??? use lookup table + switch (tglLightType) { + case Ambient: + lightType = D3DRMLIGHT_AMBIENT; + break; + case Point: + lightType = D3DRMLIGHT_POINT; + break; + case Spot: + lightType = D3DRMLIGHT_SPOT; + break; + case Directional: + lightType = D3DRMLIGHT_DIRECTIONAL; + break; + case ParallelPoint: + lightType = D3DRMLIGHT_PARALLELPOINT; + break; + default: + lightType = D3DRMLIGHT_AMBIENT; + break; + } + + return lightType; +} + // SYNTHETIC: LEGO1 0x100a16d0 +// SYNTHETIC: BETA10 0x10169aa0 // TglImpl::RendererImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a22c0 +// SYNTHETIC: BETA10 0x1016b700 // TglImpl::DeviceImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a23a0 +// SYNTHETIC: BETA10 0x1016b810 // TglImpl::ViewImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a2480 +// SYNTHETIC: BETA10 0x1016a2c0 // TglImpl::GroupImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a2560 +// SYNTHETIC: BETA10 0x1016b920 // TglImpl::CameraImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a2640 +// SYNTHETIC: BETA10 0x1016ba30 // TglImpl::LightImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a2720 +// SYNTHETIC: BETA10 0x1016b5f0 // TglImpl::MeshBuilderImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a2800 +// SYNTHETIC: BETA10 0x1016b4e0 // TglImpl::TextureImpl::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100a3d80 +// SYNTHETIC: BETA10 0x1016fa90 // TglImpl::MeshImpl::`scalar deleting destructor' +// SYNTHETIC: BETA10 0x10169960 +// ViewportAppData::`scalar deleting destructor' + // GLOBAL: LEGO1 0x100dd1e0 // IID_IDirect3DRMMeshBuilder diff --git a/LEGO1/tgl/d3drm/light.cpp b/LEGO1/tgl/d3drm/light.cpp index 0fe66bfb..50d8271e 100644 --- a/LEGO1/tgl/d3drm/light.cpp +++ b/LEGO1/tgl/d3drm/light.cpp @@ -6,6 +6,7 @@ DECOMP_SIZE_ASSERT(Light, 0x04); DECOMP_SIZE_ASSERT(LightImpl, 0x08); // FUNCTION: LEGO1 0x100a3770 +// FUNCTION: BETA10 0x1016f630 void* LightImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); diff --git a/LEGO1/tgl/d3drm/mesh.cpp b/LEGO1/tgl/d3drm/mesh.cpp index 9c3f32b4..2c6ef1f6 100644 --- a/LEGO1/tgl/d3drm/mesh.cpp +++ b/LEGO1/tgl/d3drm/mesh.cpp @@ -1,5 +1,7 @@ #include "impl.h" +#include + using namespace TglImpl; DECOMP_SIZE_ASSERT(D3DRMVERTEX, 0x24); @@ -8,6 +10,7 @@ DECOMP_SIZE_ASSERT(Mesh, 0x04); DECOMP_SIZE_ASSERT(MeshImpl, 0x08); // FUNCTION: LEGO1 0x100a3ed0 +// FUNCTION: BETA10 0x101704d0 void* MeshImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); @@ -48,73 +51,112 @@ Result MeshImpl::SetTextureMappingMode(TextureMappingMode mode) } } -// FUNCTION: LEGO1 0x100a3fc0 -Result MeshImpl::SetShadingModel(ShadingModel model) +// FUNCTION: BETA10 0x10170750 +inline Result MeshSetShadingModel(MeshImpl::MeshData* pMesh, ShadingModel model) { - D3DRMRENDERQUALITY mode; - switch (model) { - case Wireframe: - mode = D3DRMRENDER_WIREFRAME; - break; - case UnlitFlat: - mode = D3DRMRENDER_UNLITFLAT; - break; - case Flat: - mode = D3DRMRENDER_FLAT; - break; - case Gouraud: - mode = D3DRMRENDER_GOURAUD; - break; - case Phong: - mode = D3DRMRENDER_PHONG; - break; - } - return ResultVal(m_data->groupMesh->SetGroupQuality(m_data->groupIndex, mode)); + D3DRMRENDERQUALITY mode = Translate(model); + return ResultVal(pMesh->groupMesh->SetGroupQuality(pMesh->groupIndex, mode)); } -// FUNCTION: LEGO1 0x100a4030 -Mesh* MeshImpl::DeepClone(MeshBuilder* pMeshBuilder) +// FUNCTION: LEGO1 0x100a3fc0 +// FUNCTION: BETA10 0x101706f0 +Result MeshImpl::SetShadingModel(ShadingModel model) { - // Create group - MeshImpl* newMesh = new MeshImpl(); - MeshData* data = new MeshData(); - newMesh->m_data = data; + assert(m_data); + return MeshSetShadingModel(m_data, model); +} + +// FUNCTION: BETA10 0x101714e0 +inline Result MeshDeepClone(MeshImpl::MeshData* pSource, MeshImpl::MeshData*& rpTarget, IDirect3DRMMesh* pMesh) +{ + rpTarget = new MeshImpl::MeshData(); + rpTarget->groupMesh = pMesh; // Query information from old group DWORD dataSize; unsigned int vcount, fcount, vperface; - m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL); + + Result result = + ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL)); + assert(Succeeded(result)); + unsigned int* faceBuffer = new unsigned int[dataSize]; - m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer); + result = + ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer) + ); + assert(Succeeded(result)); + // We expect vertex to be sized 0x24, checked at start of file. D3DRMVERTEX* vertexBuffer = new D3DRMVERTEX[vcount]; - m_data->groupMesh->GetVertices(m_data->groupIndex, 0, vcount, vertexBuffer); + result = ResultVal(pSource->groupMesh->GetVertices(pSource->groupIndex, 0, vcount, vertexBuffer)); + assert(Succeeded(result)); + LPDIRECT3DRMTEXTURE textureRef; - m_data->groupMesh->GetGroupTexture(m_data->groupIndex, &textureRef); - D3DRMMAPPING mapping = m_data->groupMesh->GetGroupMapping(m_data->groupIndex); - D3DRMRENDERQUALITY quality = m_data->groupMesh->GetGroupQuality(m_data->groupIndex); - D3DCOLOR color = m_data->groupMesh->GetGroupColor(m_data->groupIndex); + result = ResultVal(pSource->groupMesh->GetGroupTexture(pSource->groupIndex, &textureRef)); + assert(Succeeded(result)); + + D3DRMMAPPING mapping = pSource->groupMesh->GetGroupMapping(pSource->groupIndex); + D3DRMRENDERQUALITY quality = pSource->groupMesh->GetGroupQuality(pSource->groupIndex); + D3DCOLOR color = pSource->groupMesh->GetGroupColor(pSource->groupIndex); // Push information to new group - MeshBuilderImpl* target = static_cast(pMeshBuilder); D3DRMGROUPINDEX index; - target->ImplementationData()->AddGroup(vcount, fcount, vperface, faceBuffer, &index); - newMesh->m_data->groupIndex = index; - target->ImplementationData()->SetVertices(index, 0, vcount, vertexBuffer); - target->ImplementationData()->SetGroupTexture(index, textureRef); - target->ImplementationData()->SetGroupMapping(index, mapping); - target->ImplementationData()->SetGroupQuality(index, quality); - Result result = ResultVal(target->ImplementationData()->SetGroupColor(index, color)); + result = ResultVal(pMesh->AddGroup(vcount, fcount, 3, faceBuffer, &index)); + assert(Succeeded(result)); + + rpTarget->groupIndex = index; + result = ResultVal(pMesh->SetVertices(index, 0, vcount, vertexBuffer)); + assert(Succeeded(result)); + + result = ResultVal(pMesh->SetGroupTexture(index, textureRef)); + assert(Succeeded(result)); + + result = ResultVal(pMesh->SetGroupMapping(index, mapping)); + assert(Succeeded(result)); + + result = ResultVal(pMesh->SetGroupQuality(index, quality)); + assert(Succeeded(result)); + + result = ResultVal(pMesh->SetGroupColor(index, color)); + assert(Succeeded(result)); // Cleanup - delete[] faceBuffer; - delete[] vertexBuffer; - if (result == Error) { - delete newMesh; - newMesh = NULL; + if (faceBuffer) { + delete[] faceBuffer; } - return newMesh; + if (vertexBuffer) { + delete[] vertexBuffer; + } + + return result; +} + +// FUNCTION: BETA10 0x10171360 +inline Mesh* MeshImpl::DeepClone(const MeshBuilderImpl& rMesh) +{ + assert(m_data); + assert(rMesh.ImplementationData()); + + MeshImpl* clone = new MeshImpl(); + assert(!clone->ImplementationData()); + + if (!MeshDeepClone(m_data, clone->ImplementationData(), rMesh.ImplementationData())) { + delete clone; + clone = NULL; + } + + return clone; +} + +// FUNCTION: LEGO1 0x100a4030 +// FUNCTION: BETA10 0x101707a0 +Mesh* MeshImpl::DeepClone(MeshBuilder* pMesh) +{ + assert(m_data); + assert(pMesh); + + return DeepClone(*static_cast(pMesh)); } // FUNCTION: LEGO1 0x100a4240 diff --git a/LEGO1/tgl/d3drm/meshbuilder.cpp b/LEGO1/tgl/d3drm/meshbuilder.cpp index 2766827b..be7119f3 100644 --- a/LEGO1/tgl/d3drm/meshbuilder.cpp +++ b/LEGO1/tgl/d3drm/meshbuilder.cpp @@ -1,11 +1,14 @@ #include "impl.h" +#include + using namespace TglImpl; DECOMP_SIZE_ASSERT(MeshBuilder, 0x04); DECOMP_SIZE_ASSERT(MeshBuilderImpl, 0x08); // FUNCTION: LEGO1 0x100a3830 +// FUNCTION: BETA10 0x1016c9f0 void* MeshBuilderImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); @@ -158,12 +161,12 @@ inline Result MeshBuilderImpl::CreateMeshImpl( ); } -// FUNCTION: LEGO1 0x100a3ae0 -Result MeshBuilderImpl::GetBoundingBox(float min[3], float max[3]) const +// FUNCTION: BETA10 0x1016e060 +inline Result MeshBuilderGetBoundingBox(IDirect3DRMMesh* pMesh, float min[3], float max[3]) { D3DRMBOX box; - Result result = ResultVal(m_data->GetBox(&box)); - if (result == Success) { + Result result = ResultVal(pMesh->GetBox(&box)); + if (Succeeded(result)) { min[0] = box.min.x; min[1] = box.min.y; min[2] = box.min.z; @@ -174,6 +177,15 @@ Result MeshBuilderImpl::GetBoundingBox(float min[3], float max[3]) const return result; } +// FUNCTION: LEGO1 0x100a3ae0 +// FUNCTION: BETA10 0x1016ce00 +Result MeshBuilderImpl::GetBoundingBox(float min[3], float max[3]) const +{ + assert(m_data); + + return MeshBuilderGetBoundingBox(m_data, min, max); +} + // FUNCTION: LEGO1 0x100a3b40 MeshBuilder* MeshBuilderImpl::Clone() { diff --git a/LEGO1/tgl/d3drm/renderer.cpp b/LEGO1/tgl/d3drm/renderer.cpp index e94f3592..e2aedb1a 100644 --- a/LEGO1/tgl/d3drm/renderer.cpp +++ b/LEGO1/tgl/d3drm/renderer.cpp @@ -1,5 +1,7 @@ #include "impl.h" +#include + using namespace TglImpl; // FUNCTION: LEGO1 0x100a15e0 @@ -34,64 +36,158 @@ Result RendererImpl::Create() return (m_data != NULL) ? Success : Error; } +// FUNCTION: BETA10 0x1016cf00 +inline Result RendererCreateDevice( + IDirect3DRM2* pD3DRM, + const DeviceDirect3DCreateData& rCreateData, + IDirect3DRMDevice2*& rpDevice +) +{ + Result result = + ResultVal(pD3DRM->CreateDeviceFromD3D(rCreateData.m_pDirect3D, rCreateData.m_pDirect3DDevice, &rpDevice)); + return result; +} + +// FUNCTION: BETA10 0x1016ce60 +inline Result RendererImpl::CreateDevice(const DeviceDirect3DCreateData& rCreateData, DeviceImpl& rDevice) +{ + assert(m_data); + assert(!rDevice.ImplementationData()); + + return RendererCreateDevice(m_data, rCreateData, rDevice.ImplementationData()); +} + // FUNCTION: LEGO1 0x100a1830 +// FUNCTION: BETA10 0x10169d90 Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& data) { + assert(m_data); DeviceImpl* device = new DeviceImpl(); - HRESULT result = m_data->CreateDeviceFromD3D(data.m_pDirect3D, data.m_pDirect3DDevice, &device->m_data); - if (!SUCCEEDED(result)) { + + if (!CreateDevice(data, *device)) { delete device; device = NULL; } + return device; } +// FUNCTION: BETA10 0x1016cfe0 +inline Result RendererCreateDevice( + IDirect3DRM2* pD3DRM, + const DeviceDirectDrawCreateData& rCreateData, + IDirect3DRMDevice2*& rpDevice +) +{ + Result result = ResultVal(pD3DRM->CreateDeviceFromSurface( + const_cast(rCreateData.m_driverGUID), + rCreateData.m_pDirectDraw, + rCreateData.m_pBackBuffer, + &rpDevice + )); + + if (Succeeded(result)) { + if (rCreateData.m_pBackBuffer) { + // LEGO1 0x10101040 + // GLOBAL: BETA10 0x102055f4 + static int g_setBufferCount = 1; + if (g_setBufferCount) { + Result result2 = ResultVal(rpDevice->SetBufferCount(2)); + assert(Succeeded(result)); + } + } + } + + return result; +} + +// FUNCTION: BETA10 0x1016cf40 +inline Result RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& rCreateData, DeviceImpl& rDevice) +{ + assert(m_data); + assert(!rDevice.ImplementationData()); + + return RendererCreateDevice(m_data, rCreateData, rDevice.ImplementationData()); +} + // FUNCTION: LEGO1 0x100a1900 +// FUNCTION: BETA10 0x10169ea0 Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& data) { - // at LEGO1 0x10101040, needs no annotation - static int g_SetBufferCount = 1; - + assert(m_data); DeviceImpl* device = new DeviceImpl(); - HRESULT result = m_data->CreateDeviceFromSurface( - const_cast(data.m_driverGUID), - data.m_pDirectDraw, - data.m_pBackBuffer, - &device->m_data - ); - if (SUCCEEDED(result) && data.m_pBackBuffer && g_SetBufferCount) { - device->m_data->SetBufferCount(2); - } - if (!SUCCEEDED(result)) { + + if (!CreateDevice(data, *device)) { delete device; device = NULL; } + return device; } +// FUNCTION: BETA10 0x1016d1d0 inline Result RendererCreateView( IDirect3DRM2* pRenderer, - IDirect3DRMDevice2* pDevice, - IDirect3DRMFrame2* pCamera, - IDirect3DRMViewport*& rpView, + const IDirect3DRMDevice2* pDevice, + const IDirect3DRMFrame2* pCamera, unsigned long x, unsigned long y, unsigned long width, - unsigned long height + unsigned long height, + IDirect3DRMViewport*& rpView ) { - Result result = ResultVal(pRenderer->CreateViewport(pDevice, pCamera, x, y, width, height, &rpView)); + Result result = ResultVal(pRenderer->CreateViewport( + const_cast(pDevice), + const_cast(pCamera), + x, + y, + width, + height, + &rpView + )); + if (Succeeded(result)) { - result = ViewImpl::ViewportCreateAppData(pRenderer, rpView, pCamera); + result = ViewImpl::ViewportCreateAppData(pRenderer, rpView, const_cast(pCamera)); if (!Succeeded(result)) { rpView->Release(); rpView = NULL; } } + return result; } +// FUNCTION: BETA10 0x1016d0b0 +inline Result RendererImpl::CreateView( + const DeviceImpl& rDevice, + const CameraImpl& rCamera, + unsigned long x, + unsigned long y, + unsigned long width, + unsigned long height, + ViewImpl& rView +) +{ + assert(m_data); + assert(rDevice.ImplementationData()); + assert(rCamera.ImplementationData()); + assert(!rView.ImplementationData()); + + return RendererCreateView( + m_data, + rDevice.ImplementationData(), + rCamera.ImplementationData(), + x, + y, + width, + height, + rView.ImplementationData() + ); +} + // FUNCTION: LEGO1 0x100a1a00 +// FUNCTION: BETA10 0x10169fb0 View* RendererImpl::CreateView( const Device* pDevice, const Camera* pCamera, @@ -101,21 +197,24 @@ View* RendererImpl::CreateView( unsigned long height ) { + assert(m_data); + assert(pDevice); + assert(pCamera); + ViewImpl* view = new ViewImpl(); - Result result = RendererCreateView( - m_data, - static_cast(pDevice)->m_data, - static_cast(pCamera)->m_data, - view->m_data, - x, - y, - width, - height - ); - if (!result) { + if (!CreateView( + *static_cast(pDevice), + *static_cast(pCamera), + x, + y, + width, + height, + *view + )) { delete view; view = NULL; } + return view; } @@ -145,113 +244,214 @@ Group* RendererImpl::CreateGroup(const Group* pParent) return group; } +// FUNCTION: BETA10 0x1016d4b0 +inline Result RendererCreateCamera(IDirect3DRM2* pD3DRM, IDirect3DRMFrame2*& rpCamera) +{ + return ResultVal(pD3DRM->CreateFrame(NULL, &rpCamera)); +} + +// FUNCTION: BETA10 0x1016d420 +inline Result RendererImpl::CreateCamera(CameraImpl& rCamera) +{ + assert(m_data); + assert(!rCamera.ImplementationData()); + + return RendererCreateCamera(m_data, rCamera.ImplementationData()); +} + // FUNCTION: LEGO1 0x100a1c30 +// FUNCTION: BETA10 0x1016a980 Camera* RendererImpl::CreateCamera() { + assert(m_data); CameraImpl* camera = new CameraImpl(); - if (FAILED(m_data->CreateFrame(NULL, &camera->m_data))) { + + if (!CreateCamera(*camera)) { delete camera; camera = NULL; } + return camera; } +// FUNCTION: BETA10 0x1016d580 +inline Result RendererCreateLight( + IDirect3DRM2* pD3DRM, + LightType type, + float r, + float g, + float b, + IDirect3DRMFrame2*& rpLight +) +{ + D3DRMLIGHTTYPE lightType = Translate(type); + IDirect3DRMFrame2* pLightFrame; + IDirect3DRMLight* pLight; + Result result; + + result = ResultVal(pD3DRM->CreateFrame(NULL, &pLightFrame)); + assert(Succeeded(result)); + if (!Succeeded(result)) { + return result; + } + // pLightFrame ref count is now 1 + assert((pLightFrame->AddRef(), pLightFrame->Release()) == 1); + + result = ResultVal(pD3DRM->CreateLightRGB(lightType, D3DVAL(r), D3DVAL(g), D3DVAL(b), &pLight)); + assert(Succeeded(result)); + if (!Succeeded(result)) { + pLightFrame->Release(); + return result; + } + // pLight ref count is now 1 + assert((pLight->AddRef(), pLight->Release()) == 1); + + result = ResultVal(pLightFrame->AddLight(pLight)); + assert(Succeeded(result)); + if (!Succeeded(result)) { + pLightFrame->Release(); + pLight->Release(); + return result; + } + // pLightFrame ref count is still 1 + assert((pLightFrame->AddRef(), pLightFrame->Release()) == 1); + + // pLight ref count is now 2 + assert((pLight->AddRef(), pLight->Release()) == 2); + + // Release() pLight so it gets deleted when pLightFrame is Release() + pLight->Release(); + + rpLight = pLightFrame; + + return result; +} + +// FUNCTION: BETA10 0x1016d4e0 +inline Result RendererImpl::CreateLight(LightType type, float r, float g, float b, LightImpl& rLight) +{ + assert(m_data); + assert(!rLight.ImplementationData()); + + return RendererCreateLight(m_data, type, r, g, b, rLight.ImplementationData()); +} + // FUNCTION: LEGO1 0x100a1cf0 +// FUNCTION: BETA10 0x1016aa90 Light* RendererImpl::CreateLight(LightType type, float r, float g, float b) { - LightImpl* newLight = new LightImpl(); - D3DRMLIGHTTYPE translatedType; - switch (type) { - case Ambient: - translatedType = D3DRMLIGHT_AMBIENT; - break; - case Point: - translatedType = D3DRMLIGHT_POINT; - break; - case Spot: - translatedType = D3DRMLIGHT_SPOT; - break; - case Directional: - translatedType = D3DRMLIGHT_DIRECTIONAL; - break; - case ParallelPoint: - translatedType = D3DRMLIGHT_PARALLELPOINT; - break; - default: - translatedType = D3DRMLIGHT_AMBIENT; + assert(m_data); + + LightImpl* pLightImpl = new LightImpl; + + if (!CreateLight(type, r, g, b, *pLightImpl)) { + delete pLightImpl; + pLightImpl = 0; } - LPDIRECT3DRMFRAME2 frame; - Result result = ResultVal(m_data->CreateFrame(NULL, &frame)); - if (Succeeded(result)) { - LPDIRECT3DRMLIGHT d3dLight; - result = ResultVal(m_data->CreateLightRGB(translatedType, r, g, b, &d3dLight)); - if (!Succeeded(result)) { - frame->Release(); - } - else { - result = ResultVal(frame->AddLight(d3dLight)); - if (!Succeeded(result)) { - d3dLight->Release(); - frame->Release(); - } - else { - d3dLight->Release(); - newLight->m_data = frame; - } - } - } - if (!Succeeded(result)) { - delete newLight; - newLight = NULL; - } - return newLight; + return pLightImpl; +} + +// FUNCTION: BETA10 0x1016d8e0 +inline Result RendererCreateMeshBuilder(IDirect3DRM2* pD3DRM, IDirect3DRMMesh*& rpMesh) +{ + return ResultVal(pD3DRM->CreateMesh(&rpMesh)); +} + +// FUNCTION: BETA10 0x1016d850 +inline Result RendererImpl::CreateMeshBuilder(MeshBuilderImpl& rMesh) +{ + assert(m_data); + assert(!rMesh.ImplementationData()); + + return RendererCreateMeshBuilder(m_data, rMesh.ImplementationData()); } // FUNCTION: LEGO1 0x100a1e90 +// FUNCTION: BETA10 0x1016abf0 MeshBuilder* RendererImpl::CreateMeshBuilder() { + assert(m_data); MeshBuilderImpl* meshBuilder = new MeshBuilderImpl(); - if (FAILED(m_data->CreateMesh(&meshBuilder->m_data))) { + + if (!CreateMeshBuilder(*static_cast(meshBuilder))) { delete meshBuilder; meshBuilder = NULL; } + return meshBuilder; } +// FUNCTION: BETA10 0x1016d9c0 inline Result RendererCreateTexture( - IDirect3DRM2* renderer, - IDirect3DRMTexture*& texture, + IDirect3DRM2* pRenderer, int width, int height, int bytesPerPixel, void* pBuffer, int useBuffer, int paletteSize, - PaletteEntry* pEntries + PaletteEntry* pEntries, + IDirect3DRMTexture*& rpTexture ) { - TglD3DRMIMAGE* image; Result result; - image = new TglD3DRMIMAGE(width, height, bytesPerPixel, pBuffer, useBuffer, paletteSize, pEntries); + TglD3DRMIMAGE* pImage = new TglD3DRMIMAGE(width, height, bytesPerPixel, pBuffer, useBuffer, paletteSize, pEntries); + assert(pImage); + // TODO: LPDIRECT3DRMTEXTURE2? - result = ResultVal(renderer->CreateTexture(&image->m_image, (LPDIRECT3DRMTEXTURE2*) &texture)); + result = ResultVal(pRenderer->CreateTexture(&pImage->m_image, (LPDIRECT3DRMTEXTURE2*) &rpTexture)); + assert(Succeeded(result)); + assert((rpTexture->AddRef(), rpTexture->Release()) == 1); + if (Succeeded(result)) { - result = TextureImpl::SetImage(texture, image); + result = TextureImpl::SetImage(rpTexture, pImage); + assert(Succeeded(result)); + if (!Succeeded(result)) { - texture->Release(); - texture = NULL; - delete image; + rpTexture->Release(); + rpTexture = NULL; + delete pImage; } } else { - delete image; + delete pImage; } + return result; } +// FUNCTION: BETA10 0x1016d910 +inline Result RendererImpl::CreateTexture( + TextureImpl& rTexture, + int width, + int height, + int bitsPerTexel, + const void* pTexels, + int texelsArePersistent, + int paletteEntryCount, + const PaletteEntry* pEntries +) +{ + assert(m_data); + assert(!rTexture.ImplementationData()); + + return RendererCreateTexture( + m_data, + width, + height, + bitsPerTexel, + const_cast(pTexels), + texelsArePersistent, + paletteEntryCount, + const_cast(pEntries), + rTexture.ImplementationData() + ); +} + // FUNCTION: LEGO1 0x100a1f50 +// FUNCTION: BETA10 0x1016ad00 Texture* RendererImpl::CreateTexture( int width, int height, @@ -262,10 +462,11 @@ Texture* RendererImpl::CreateTexture( const PaletteEntry* pEntries ) { + assert(m_data); + TextureImpl* texture = new TextureImpl(); - if (!Succeeded(RendererCreateTexture( - m_data, - texture->m_data, + if (!CreateTexture( + *texture, width, height, bitsPerTexel, @@ -273,21 +474,40 @@ Texture* RendererImpl::CreateTexture( texelsArePersistent, paletteEntryCount, const_cast(pEntries) - ))) { + )) { delete texture; texture = NULL; } return texture; } +// FUNCTION: BETA10 0x1016dcb0 +inline Result RendererCreateTexture(IDirect3DRM2* pRenderer, IDirect3DRMTexture*& rpTexture) +{ + return RendererCreateTexture(pRenderer, 0, 0, 0, NULL, FALSE, 0, NULL, rpTexture); +} + +// FUNCTION: BETA10 0x1016dc20 +inline Result RendererImpl::CreateTexture(TextureImpl& rTexture) +{ + assert(m_data); + assert(!rTexture.ImplementationData()); + + return RendererCreateTexture(m_data, rTexture.ImplementationData()); +} + // FUNCTION: LEGO1 0x100a20d0 +// FUNCTION: BETA10 0x1016ae20 Texture* RendererImpl::CreateTexture() { + assert(m_data); + TextureImpl* texture = new TextureImpl(); - if (!Succeeded(RendererCreateTexture(m_data, texture->m_data, 0, 0, 0, NULL, FALSE, 0, NULL))) { + if (!CreateTexture(*texture)) { delete texture; texture = NULL; } + return texture; } @@ -304,6 +524,7 @@ Result RendererImpl::SetTextureDefaultColorCount(unsigned long colorCount) } // FUNCTION: LEGO1 0x100a22b0 +// FUNCTION: BETA10 0x1016b050 void* RendererImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); diff --git a/LEGO1/tgl/d3drm/texture.cpp b/LEGO1/tgl/d3drm/texture.cpp index ea8ef1b0..5944d7ba 100644 --- a/LEGO1/tgl/d3drm/texture.cpp +++ b/LEGO1/tgl/d3drm/texture.cpp @@ -224,6 +224,7 @@ Result TextureImpl::SetPalette(int entryCount, PaletteEntry* pEntries) } // FUNCTION: LEGO1 0x100a3d70 +// FUNCTION: BETA10 0x1016c760 void* TextureImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); diff --git a/LEGO1/tgl/d3drm/view.cpp b/LEGO1/tgl/d3drm/view.cpp index 3c2ea1d9..aba7df5a 100644 --- a/LEGO1/tgl/d3drm/view.cpp +++ b/LEGO1/tgl/d3drm/view.cpp @@ -1,5 +1,7 @@ #include "impl.h" +#include + using namespace TglImpl; struct ViewportAppData { @@ -17,9 +19,12 @@ struct ViewportAppData { DECOMP_SIZE_ASSERT(ViewportAppData, 0x18); // FUNCTION: LEGO1 0x100a10b0 +// FUNCTION: BETA10 0x10168920 ViewportAppData::ViewportAppData(IDirect3DRM2* pRenderer) { - pRenderer->CreateFrame(NULL, &m_pLightFrame); + Result result = ResultVal(pRenderer->CreateFrame(NULL, &m_pLightFrame)); + assert(Succeeded(result)); + m_pCamera = NULL; m_pLastRenderedFrame = NULL; m_backgroundColorRed = 0.0f; @@ -28,39 +33,68 @@ ViewportAppData::ViewportAppData(IDirect3DRM2* pRenderer) } // FUNCTION: LEGO1 0x100a10e0 +// FUNCTION: BETA10 0x101689bd ViewportAppData::~ViewportAppData() { + int refCount; IDirect3DRMFrameArray* pChildFrames; IDirect3DRMFrame* pChildFrame = NULL; - m_pLightFrame->GetChildren(&pChildFrames); + Result result = ResultVal(m_pLightFrame->GetChildren(&pChildFrames)); + assert(Succeeded(result)); + for (int i = 0; i < (int) pChildFrames->GetSize(); i++) { - pChildFrames->GetElement(i, &pChildFrame); - m_pLightFrame->DeleteChild(pChildFrame); - pChildFrame->Release(); // GetElement() does AddRef() + result = ResultVal(pChildFrames->GetElement(i, &pChildFrame)); + assert(Succeeded(result)); + + result = ResultVal(m_pLightFrame->DeleteChild(pChildFrame)); + assert(Succeeded(result)); + + refCount = pChildFrame->Release(); // GetElement() does AddRef() + assert(refCount >= 1); } - pChildFrames->Release(); - m_pLightFrame->Release(); + + refCount = pChildFrames->Release(); + assert(refCount == 0); + + refCount = m_pLightFrame->Release(); + assert(refCount == 0); } // Forward declare to satisfy order check void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg); // FUNCTION: LEGO1 0x100a1160 -Result ViewImpl::ViewportCreateAppData(IDirect3DRM2* pDevice, IDirect3DRMViewport* pView, IDirect3DRMFrame2* pCamera) +// FUNCTION: BETA10 0x10168ba5 +Result ViewImpl::ViewportCreateAppData( + IDirect3DRM2* pDevice, + IDirect3DRMViewport* pViewport, + IDirect3DRMFrame2* pCamera +) { - ViewportAppData* data = new ViewportAppData(pDevice); - data->m_pCamera = pCamera; - Result result = ResultVal(pView->SetAppData(reinterpret_cast(data))); + ViewportAppData* pViewportAppData = new ViewportAppData(pDevice); + assert(pViewportAppData); + + pViewportAppData->m_pCamera = pCamera; + assert(!pViewport->GetAppData()); + + Result result = ResultVal(pViewport->SetAppData(reinterpret_cast(pViewportAppData))); + assert(Succeeded(result)); + assert(reinterpret_cast(pViewport->GetAppData()) == pViewportAppData); + if (Succeeded(result)) { - result = ResultVal(pView->AddDestroyCallback(ViewportDestroyCallback, data)); + result = ResultVal(pViewport->AddDestroyCallback(ViewportDestroyCallback, pViewportAppData)); + assert(Succeeded(result)); } + if (!Succeeded(result)) { - delete data; - pView->SetAppData(0); + delete pViewportAppData; + pViewport->SetAppData(0); } + return result; } +// FUNCTION: BETA10 0x1016bd80 inline Result ViewRestoreFrameAfterRender( IDirect3DRMFrame* pFrame, IDirect3DRMFrame* pCamera, @@ -72,7 +106,11 @@ inline Result ViewRestoreFrameAfterRender( // remove camera and light frame from frame that was rendered // this doesn't destroy the camera as it is still the camera of the viewport... result = ResultVal(pFrame->DeleteChild(pCamera)); + assert(Succeeded(result)); + assert((pCamera->AddRef(), pCamera->Release()) > 0); + result = ResultVal(pFrame->DeleteChild(pLightFrame)); + assert(Succeeded(result)); // decrease frame's ref count (it was increased in ViewPrepareFrameForRender()) pFrame->Release(); @@ -83,25 +121,31 @@ inline Result ViewRestoreFrameAfterRender( // FIXME: from LEGO1/tgl/d3drm/view.cpp // FUNCTION: LEGO1 0x100a1240 +// FUNCTION: BETA10 0x10168dc9 void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg) { ViewportAppData* pViewportAppData = reinterpret_cast(pArg); + assert(static_cast(pObject)); + assert(pViewportAppData); - ViewRestoreFrameAfterRender( + Result result = ViewRestoreFrameAfterRender( pViewportAppData->m_pLastRenderedFrame, pViewportAppData->m_pCamera, pViewportAppData->m_pLightFrame ); + assert(Succeeded(result)); + delete pViewportAppData; } // FUNCTION: LEGO1 0x100a1290 +// FUNCTION: BETA10 0x10168eab Result ViewportPickImpl( IDirect3DRMViewport* pViewport, int x, int y, - const Group** ppGroupsToPickFrom, + const GroupImpl** ppGroupsToPickFrom, int groupsToPickFromCount, const Group**& rppPickedGroups, int& rPickedGroupCount @@ -116,108 +160,230 @@ inline ViewportAppData* ViewportGetData(IDirect3DRMViewport* pViewport) return reinterpret_cast(pViewport->GetAppData()); } +// FUNCTION: BETA10 0x10170ab0 inline IDirect3DRMFrame* ViewportGetLightFrame(IDirect3DRMViewport* pViewport) { - return ViewportGetData(pViewport)->m_pLightFrame; + assert(pViewport->GetAppData()); + return reinterpret_cast(pViewport->GetAppData())->m_pLightFrame; } // FUNCTION: LEGO1 0x100a2d80 +// FUNCTION: BETA10 0x1016e640 void* ViewImpl::ImplementationDataPtr() { return reinterpret_cast(&m_data); } +// FUNCTION: BETA10 0x10170a40 +inline Result ViewAddLight(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame* pLight) +{ + IDirect3DRMFrame* pLightFrame = ViewportGetLightFrame(pViewport); + + assert(pLightFrame); + return ResultVal(pLightFrame->AddChild(const_cast(pLight))); +} + +// FUNCTION: BETA10 0x101709a0 +inline Result ViewImpl::Add(const LightImpl& rLight) +{ + assert(m_data); + assert(rLight.ImplementationData()); + + return ViewAddLight(m_data, rLight.ImplementationData()); +} + // FUNCTION: LEGO1 0x100a2d90 +// FUNCTION: BETA10 0x1016e690 Result ViewImpl::Add(const Light* pLight) { - const LightImpl* light = static_cast(pLight); - IDirect3DRMFrame* frame = light->ImplementationData(); - return ResultVal(ViewportGetLightFrame(m_data)->AddChild(frame)); + assert(m_data); + assert(pLight); + + return Add(*static_cast(pLight)); +} + +// FUNCTION: BETA10 0x10170bb0 +inline Result ViewRemoveLight(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame* pLight) +{ + IDirect3DRMFrame* pLightFrame = ViewportGetLightFrame(pViewport); + + assert(pLightFrame); + return ResultVal(pLightFrame->DeleteChild(const_cast(pLight))); +} + +// FUNCTION: BETA10 0x10170b10 +inline Result ViewImpl::Remove(const LightImpl& rLight) +{ + assert(m_data); + assert(rLight.ImplementationData()); + + return ViewRemoveLight(m_data, rLight.ImplementationData()); } // FUNCTION: LEGO1 0x100a2dc0 +// FUNCTION: BETA10 0x1016e710 Result ViewImpl::Remove(const Light* pLight) { - const LightImpl* light = static_cast(pLight); - IDirect3DRMFrame* frame = light->ImplementationData(); - return ResultVal(ViewportGetLightFrame(m_data)->DeleteChild(frame)); + assert(m_data); + assert(pLight); + + return Remove(*static_cast(pLight)); } -// FUNCTION: LEGO1 0x100a2df0 -Result ViewImpl::SetCamera(const Camera* pCamera) +// FUNCTION: BETA10 0x10170cc0 +inline Result ViewSetCamera(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame2* pCamera) { - const CameraImpl* camera = static_cast(pCamera); - IDirect3DRMFrame2* frame = camera->ImplementationData(); - ViewportAppData* pViewportAppData; Result result; - pViewportAppData = reinterpret_cast(m_data->GetAppData()); + pViewportAppData = reinterpret_cast(pViewport->GetAppData()); + assert(pViewportAppData); + result = ViewRestoreFrameAfterRender( pViewportAppData->m_pLastRenderedFrame, pViewportAppData->m_pCamera, pViewportAppData->m_pLightFrame ); - pViewportAppData->m_pCamera = frame; + assert(Succeeded(result)); + pViewportAppData->m_pCamera = const_cast(pCamera); pViewportAppData->m_pLastRenderedFrame = 0; - return ResultVal(m_data->SetCamera(frame)); + return ResultVal(pViewport->SetCamera(const_cast(pCamera))); +} + +// FUNCTION: BETA10 0x10170c20 +inline Result ViewImpl::SetCamera(const CameraImpl& rCamera) +{ + assert(m_data); + assert(rCamera.ImplementationData()); + + return ViewSetCamera(m_data, rCamera.ImplementationData()); +} + +// FUNCTION: LEGO1 0x100a2df0 +// FUNCTION: BETA10 0x1016e790 +Result ViewImpl::SetCamera(const Camera* pCamera) +{ + assert(m_data); + assert(pCamera); + + return SetCamera(*static_cast(pCamera)); +} + +// FUNCTION: BETA10 0x1016e870 +inline Result ViewSetProjection(IDirect3DRMViewport* pViewport, ProjectionType type) +{ + D3DRMPROJECTIONTYPE projectionType = Translate(type); + + return ResultVal(pViewport->SetProjection(projectionType)); } // FUNCTION: LEGO1 0x100a2e70 +// FUNCTION: BETA10 0x1016e810 Result ViewImpl::SetProjection(ProjectionType type) { - return ResultVal(m_data->SetProjection(Translate(type))); + assert(m_data); + + return ViewSetProjection(m_data, type); } -// FUNCTION: LEGO1 0x100a2eb0 -Result ViewImpl::SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees) +// FUNCTION: BETA10 0x1016e920 +inline Result ViewSetFrustrum( + IDirect3DRMViewport* pViewport, + float frontClippingDistance, + float backClippingDistance, + float degrees +) { float field = frontClippingDistance * tan(DegreesToRadians(degrees / 2)); Result result; - result = ResultVal(m_data->SetFront(frontClippingDistance)); + result = ResultVal(pViewport->SetFront(frontClippingDistance)); if (Succeeded(result)) { - result = ResultVal(m_data->SetBack(backClippingDistance)); + result = ResultVal(pViewport->SetBack(backClippingDistance)); } if (Succeeded(result)) { - result = ResultVal(m_data->SetField(field)); + result = ResultVal(pViewport->SetField(field)); + } + + return result; +} + +// FUNCTION: LEGO1 0x100a2eb0 +// FUNCTION: BETA10 0x1016e8b0 +Result ViewImpl::SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees) +{ + assert(m_data); + + return ViewSetFrustrum(m_data, frontClippingDistance, backClippingDistance, degrees); +} + +// FUNCTION: BETA10 0x1016ea70 +inline Result ViewSetBackgroundColor(IDirect3DRMViewport* pViewport, float r, float g, float b) +{ + Result result = Success; + + ViewportAppData* pViewportAppData = reinterpret_cast(pViewport->GetAppData()); + assert(pViewportAppData); + + pViewportAppData->m_backgroundColorRed = r; + pViewportAppData->m_backgroundColorGreen = g; + pViewportAppData->m_backgroundColorBlue = b; + + if (pViewportAppData->m_pLastRenderedFrame) { + result = ResultVal(pViewportAppData->m_pLastRenderedFrame->SetSceneBackgroundRGB(r, g, b)); + assert(Succeeded(result)); } return result; } // FUNCTION: LEGO1 0x100a2f30 +// FUNCTION: BETA10 0x1016ea00 Result ViewImpl::SetBackgroundColor(float r, float g, float b) { - Result ret = Success; - // Note, this method in the shipped game is very diverged from - // the Tgl leak code. - ViewportAppData* data = ViewportGetData(m_data); - data->m_backgroundColorRed = r; - data->m_backgroundColorGreen = g; - data->m_backgroundColorBlue = b; - if (data->m_pLastRenderedFrame) { - ret = ResultVal(data->m_pLastRenderedFrame->SetSceneBackgroundRGB(r, g, b)); - } - return ret; + assert(m_data); + + return ViewSetBackgroundColor(m_data, r, g, b); } -// FUNCTION: LEGO1 0x100a2f80 -Result ViewImpl::GetBackgroundColor(float* r, float* g, float* b) +// FUNCTION: BETA10 0x1016ebd0 +inline Result ViewGetBackgroundColor(IDirect3DRMViewport* pViewport, float* r, float* g, float* b) { - ViewportAppData* data = ViewportGetData(m_data); - *r = data->m_backgroundColorRed; - *g = data->m_backgroundColorGreen; - *b = data->m_backgroundColorBlue; + ViewportAppData* pViewportAppData = reinterpret_cast(pViewport->GetAppData()); + assert(pViewportAppData); + + *r = pViewportAppData->m_backgroundColorRed; + *g = pViewportAppData->m_backgroundColorGreen; + *b = pViewportAppData->m_backgroundColorBlue; + return Success; } -// FUNCTION: LEGO1 0x100a2fb0 -Result ViewImpl::Clear() +// FUNCTION: LEGO1 0x100a2f80 +// FUNCTION: BETA10 0x1016eb60 +Result ViewImpl::GetBackgroundColor(float* r, float* g, float* b) { - return ResultVal(m_data->Clear()); + assert(m_data); + + return ViewGetBackgroundColor(m_data, r, g, b); } +// FUNCTION: BETA10 0x1016ecb0 +inline Result ViewClear(IDirect3DRMViewport* pViewport) +{ + return ResultVal(pViewport->Clear()); +} + +// FUNCTION: LEGO1 0x100a2fb0 +// FUNCTION: BETA10 0x1016ec50 +Result ViewImpl::Clear() +{ + assert(m_data); + + return ViewClear(m_data); +} + +// FUNCTION: BETA10 0x10170fb0 inline Result ViewPrepareFrameForRender( IDirect3DRMFrame* pFrame, IDirect3DRMFrame* pCamera, @@ -232,12 +398,15 @@ inline Result ViewPrepareFrameForRender( if (pFrame) { // set background color result = ResultVal(pFrame->SetSceneBackgroundRGB(backgroundRed, backgroundGreen, backgroundBlue)); + assert(Succeeded(result)); // add camera to frame to be rendered result = ResultVal(pFrame->AddChild(pCamera)); + assert(Succeeded(result)); // add light frame to frame to be rendered result = ResultVal(pFrame->AddChild(pLightFrame)); + assert(Succeeded(result)); // increase ref count of frame to ensure it does not get deleted underneath us pFrame->AddRef(); @@ -246,12 +415,14 @@ inline Result ViewPrepareFrameForRender( return result; } +// FUNCTION: BETA10 0x10170e30 inline Result ViewRender(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame2* pGroup) { ViewportAppData* pViewportAppData; Result result; pViewportAppData = reinterpret_cast(pViewport->GetAppData()); + assert(pViewportAppData); if (pViewportAppData->m_pLastRenderedFrame != pGroup) { result = ViewRestoreFrameAfterRender( @@ -260,6 +431,8 @@ inline Result ViewRender(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame2 pViewportAppData->m_pLightFrame ); + assert(Succeeded(result)); + pViewportAppData->m_pLastRenderedFrame = const_cast(pGroup); result = ViewPrepareFrameForRender( @@ -272,32 +445,66 @@ inline Result ViewRender(IDirect3DRMViewport* pViewport, const IDirect3DRMFrame2 ); } + assert(Succeeded(result)); + result = ResultVal(pViewport->Render(const_cast(pGroup))); + assert(Succeeded(result)); + return result; } +// FUNCTION: BETA10 0x10170d90 +inline Result ViewImpl::Render(const GroupImpl& rScene) +{ + assert(m_data); + assert(rScene.ImplementationData()); + + return ViewRender(m_data, rScene.ImplementationData()); +} + // FUNCTION: LEGO1 0x100a2fd0 +// FUNCTION: BETA10 0x1016ece0 Result ViewImpl::Render(const Group* pGroup) { - return ViewRender(m_data, static_cast(pGroup)->ImplementationData()); + assert(m_data); + assert(pGroup); + + return Render(*static_cast(pGroup)); +} + +// FUNCTION: BETA10 0x1016edd0 +inline Result ViewForceUpdate( + IDirect3DRMViewport* pViewport, + unsigned long x, + unsigned long y, + unsigned long width, + unsigned long height +) +{ + return ResultVal(pViewport->ForceUpdate(x, y, x + width - 1, y + height - 1)); } // FUNCTION: LEGO1 0x100a3080 +// FUNCTION: BETA10 0x1016ed60 Result ViewImpl::ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height) { - return ResultVal(m_data->ForceUpdate(x, y, x + width - 1, y + height - 1)); + assert(m_data); + + return ViewForceUpdate(m_data, x, y, width, height); } -// FUNCTION: LEGO1 0x100a30c0 -Result ViewImpl::Pick( +// FUNCTION: BETA10 0x101710f0 +inline Result ViewImpl::Pick( unsigned long x, unsigned long y, - const Group** ppGroupsToPickFrom, + const GroupImpl** ppGroupsToPickFrom, int groupsToPickFromCount, const Group**& rppPickedGroups, int& rPickedGroupCount ) { + assert(m_data); + return ViewportPickImpl( m_data, x, @@ -309,17 +516,38 @@ Result ViewImpl::Pick( ); } -// FUNCTION: LEGO1 0x100a30f0 -Result ViewImpl::TransformWorldToScreen(const float world[3], float screen[4]) +// FUNCTION: LEGO1 0x100a30c0 +// FUNCTION: BETA10 0x1016ee10 +Result ViewImpl::Pick( + unsigned long x, + unsigned long y, + const Group** ppGroupsToPickFrom, + int groupsToPickFromCount, + const Group**& rppPickedGroups, + int& rPickedGroupCount +) +{ + assert(m_data); + + return Pick( + x, + y, + reinterpret_cast(ppGroupsToPickFrom), + groupsToPickFromCount, + rppPickedGroups, + rPickedGroupCount + ); +} + +// FUNCTION: BETA10 0x1016eff0 +inline Result ViewTransformWorldToScreen(IDirect3DRMViewport* pViewport, const float world[3], float screen[4]) { D3DRMVECTOR4D d3dRMScreen; D3DVECTOR d3dRMWorld; - d3dRMWorld.x = world[0]; - d3dRMWorld.y = world[1]; - d3dRMWorld.z = world[2]; + D3DVECTOR* pD3DRMWorld = Translate(world, d3dRMWorld); Result result; - result = ResultVal(m_data->Transform(&d3dRMScreen, &d3dRMWorld)); + result = ResultVal(pViewport->Transform(&d3dRMScreen, pD3DRMWorld)); if (Succeeded(result)) { screen[0] = d3dRMScreen.x; @@ -331,10 +559,18 @@ Result ViewImpl::TransformWorldToScreen(const float world[3], float screen[4]) return result; } -// FUNCTION: LEGO1 0x100a3160 -Result ViewImpl::TransformScreenToWorld(const float screen[4], float world[3]) +// FUNCTION: LEGO1 0x100a30f0 +// FUNCTION: BETA10 0x1016ef90 +Result ViewImpl::TransformWorldToScreen(const float world[3], float screen[4]) +{ + assert(m_data); + + return ViewTransformWorldToScreen(m_data, world, screen); +} + +// FUNCTION: BETA10 0x1016f0d0 +inline Result ViewTransformScreenToWorld(IDirect3DRMViewport* pViewport, const float screen[4], float world[3]) { - // 100% match minus instruction reordering. D3DVECTOR d3dRMWorld; D3DRMVECTOR4D d3dScreen; d3dScreen.x = screen[0]; @@ -343,7 +579,7 @@ Result ViewImpl::TransformScreenToWorld(const float screen[4], float world[3]) d3dScreen.w = screen[3]; Result result; - result = ResultVal(m_data->InverseTransform(&d3dRMWorld, &d3dScreen)); + result = ResultVal(pViewport->InverseTransform(&d3dRMWorld, &d3dScreen)); if (Succeeded(result)) { world[0] = d3dRMWorld.x; @@ -353,3 +589,12 @@ Result ViewImpl::TransformScreenToWorld(const float screen[4], float world[3]) return result; } + +// FUNCTION: LEGO1 0x100a3160 +// FUNCTION: BETA10 0x1016f070 +Result ViewImpl::TransformScreenToWorld(const float screen[4], float world[3]) +{ + assert(m_data); + + return ViewTransformScreenToWorld(m_data, screen, world); +} diff --git a/LEGO1/tgl/tgl.h b/LEGO1/tgl/tgl.h index 34b1d5ee..c519cf05 100644 --- a/LEGO1/tgl/tgl.h +++ b/LEGO1/tgl/tgl.h @@ -81,6 +81,7 @@ enum Result { Success = 1 }; +// FUNCTION: BETA10 0x10169c60 inline int Succeeded(Result result) { return (result == Success); @@ -99,18 +100,25 @@ class Texture; class MeshBuilder; // VTABLE: LEGO1 0x100db980 +// VTABLE: BETA10 0x101c3148 class Object { public: // FUNCTION: LEGO1 0x100a2240 + // FUNCTION: BETA10 0x10169c90 virtual ~Object() {} virtual void* ImplementationDataPtr() = 0; + // SYNTHETIC: BETA10 0x10169b50 + // Tgl::Object::Object + // SYNTHETIC: LEGO1 0x100a2250 + // SYNTHETIC: BETA10 0x10169cb0 // Tgl::Object::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100db948 +// VTABLE: BETA10 0x101c3110 class Renderer : public Object { public: // vtable+0x08 @@ -147,16 +155,22 @@ class Renderer : public Object { // vtable+0x30 virtual Result SetTextureDefaultColorCount(unsigned long) = 0; + // SYNTHETIC: BETA10 0x10169ae0 + // Tgl::Renderer::Renderer + // SYNTHETIC: LEGO1 0x100a1770 + // SYNTHETIC: BETA10 0x10169b80 // Tgl::Renderer::~Renderer // SYNTHETIC: LEGO1 0x100a17c0 + // SYNTHETIC: BETA10 0x10169be0 // Tgl::Renderer::`scalar deleting destructor' }; Renderer* CreateRenderer(); // VTABLE: LEGO1 0x100db9b8 +// VTABLE: BETA10 0x101c32b0 class Device : public Object { public: // vtable+0x08 @@ -174,14 +188,20 @@ class Device : public Object { virtual void HandleActivate(WORD) = 0; virtual void HandlePaint(HDC) = 0; + // SYNTHETIC: BETA10 0x1016b740 + // Tgl::Device::Device + // SYNTHETIC: LEGO1 0x100a2350 + // SYNTHETIC: BETA10 0x1016b7b0 // Tgl::Device::~Device // SYNTHETIC: LEGO1 0x100a28e0 + // SYNTHETIC: BETA10 0x1016bbc0 // Tgl::Device::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100dba28 +// VTABLE: BETA10 0x101c32e0 class View : public Object { public: virtual Result Add(const Light*) = 0; @@ -234,44 +254,59 @@ class View : public Object { int& rPickedGroupCount ) = 0; + // SYNTHETIC: BETA10 0x1016b850 + // Tgl::View::View + // SYNTHETIC: LEGO1 0x100a2430 + // SYNTHETIC: BETA10 0x1016b8c0 // Tgl::View::~View // SYNTHETIC: LEGO1 0x100a2950 + // SYNTHETIC: BETA10 0x1016bc00 // Tgl::View::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100dbae8 +// VTABLE: BETA10 0x101c3320 class Camera : public Object { public: virtual Result SetTransformation(FloatMatrix4&) = 0; + // SYNTHETIC: BETA10 0x1016b960 + // Tgl::Camera::Camera + // SYNTHETIC: LEGO1 0x100a25f0 + // SYNTHETIC: BETA10 0x1016b9d0 // Tgl::Camera::~Camera // SYNTHETIC: LEGO1 0x100a2a30 + // SYNTHETIC: BETA10 0x1016bc40 // Tgl::Camera::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100dbb08 +// VTABLE: BETA10 0x101c3330 class Light : public Object { public: virtual Result SetTransformation(FloatMatrix4&) = 0; virtual Result SetColor(float r, float g, float b) = 0; + // SYNTHETIC: BETA10 0x1016ba70 + // Tgl::Light::Light + // SYNTHETIC: LEGO1 0x100a26d0 + // SYNTHETIC: BETA10 0x1016bae0 // Tgl::Light::~Light // SYNTHETIC: LEGO1 0x100a2aa0 + // SYNTHETIC: BETA10 0x1016bc80 // Tgl::Light::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100dbbb0 +// VTABLE: BETA10 0x101c3360 class Mesh : public Object { public: - // SYNTHETIC: LEGO1 0x100a3e10 - // Tgl::Mesh::~Mesh - virtual Result SetColor(float r, float g, float b, float a) = 0; virtual Result SetTexture(const Texture*) = 0; virtual Result GetTexture(Texture*&) = 0; @@ -285,11 +320,20 @@ class Mesh : public Object { // Just get another Group pointing to the same underlying data virtual Mesh* ShallowClone(MeshBuilder*) = 0; + // SYNTHETIC: BETA10 0x1016fad0 + // Tgl::Mesh::Mesh + + // SYNTHETIC: LEGO1 0x100a3e10 + // SYNTHETIC: BETA10 0x1016fb40 + // Tgl::Mesh::~Mesh + // SYNTHETIC: LEGO1 0x100a3e60 + // SYNTHETIC: BETA10 0x1016fbe0 // Tgl::Mesh::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100dbaa0 +// VTABLE: BETA10 0x101c3188 class Group : public Object { public: virtual Result SetTransformation(FloatMatrix4&) = 0; @@ -307,10 +351,15 @@ class Group : public Object { // to have been replaced by something else in the shipped code. virtual Result Bounds(D3DVECTOR*, D3DVECTOR*) = 0; + // SYNTHETIC: BETA10 0x1016a300 + // Tgl::Group::Group + // SYNTHETIC: LEGO1 0x100a2510 + // SYNTHETIC: BETA10 0x1016a370 // Tgl::Group::~Group // SYNTHETIC: LEGO1 0x100a29c0 + // SYNTHETIC: BETA10 0x1016a3d0 // Tgl::Group::`scalar deleting destructor' }; @@ -318,6 +367,7 @@ class Group : public Object { // was not in the leaked Tgl code. My suspicion is that it's // some kind of builder class for creating meshes. // VTABLE: LEGO1 0x100dbb30 +// VTABLE: BETA10 0x101c32a0 class MeshBuilder : public Object { public: virtual Mesh* CreateMesh( @@ -333,14 +383,20 @@ class MeshBuilder : public Object { virtual Result GetBoundingBox(float min[3], float max[3]) const = 0; virtual MeshBuilder* Clone() = 0; + // SYNTHETIC: BETA10 0x1016b630 + // Tgl::MeshBuilder::MeshBuilder + // SYNTHETIC: LEGO1 0x100a27b0 + // SYNTHETIC: BETA10 0x1016b6a0 // Tgl::MeshBuilder::~MeshBuilder // SYNTHETIC: LEGO1 0x100a2b10 + // SYNTHETIC: BETA10 0x1016bb80 // Tgl::MeshBuilder::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100dbb68 +// VTABLE: BETA10 0x101c3280 class Texture : public Object { public: // vtable+0x08 @@ -359,10 +415,15 @@ class Texture : public Object { ) = 0; virtual Result SetPalette(int entryCount, PaletteEntry* pEntries) = 0; + // SYNTHETIC: BETA10 0x1016b520 + // Tgl::Texture::Texture + // SYNTHETIC: LEGO1 0x100a2890 + // SYNTHETIC: BETA10 0x1016b590 // Tgl::Texture::~Texture // SYNTHETIC: LEGO1 0x100a2b80 + // SYNTHETIC: BETA10 0x1016bb40 // Tgl::Texture::`scalar deleting destructor' };