diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2022-10-19 00:38:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-19 00:38:01 -0700 |
| commit | f03b959831d308b63ba72d79f7814faaa6818481 (patch) | |
| tree | e5b31e52e6755877e7402cd81f8f490565b1855c /include/JSystem | |
| parent | 4913395dbd1a33d794028ceb82579b4baffe954d (diff) | |
| parent | c3a6d117295705a486bbd67cc0c84991b4d139c3 (diff) | |
Merge pull request #211 from TakaRikka/work1
d_attention / d_a_player / d_demo + misc
Diffstat (limited to 'include/JSystem')
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DJoint.h | 4 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DJointTree.h | 1 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DModelData.h | 1 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DDrawBuffer.h | 39 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DPacket.h | 20 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DShape.h | 16 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DShapeMtx.h | 36 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DSys.h | 3 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DTransform.h | 7 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DJointFactory.h | 45 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DShapeFactory.h | 74 | ||||
| -rw-r--r-- | include/JSystem/JGeometry.h | 26 | ||||
| -rw-r--r-- | include/JSystem/JStudio/JStudio/jstudio-object.h | 30 | ||||
| -rw-r--r-- | include/JSystem/JStudio/JStudio/stb-data-parse.h | 2 | ||||
| -rw-r--r-- | include/JSystem/JStudio/JStudio/stb.h | 40 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSupport.h | 2 |
16 files changed, 312 insertions, 34 deletions
diff --git a/include/JSystem/J3DGraphAnimator/J3DJoint.h b/include/JSystem/J3DGraphAnimator/J3DJoint.h index 0474f4eb5a..94ce45c74d 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJoint.h +++ b/include/JSystem/J3DGraphAnimator/J3DJoint.h @@ -68,13 +68,15 @@ public: static J3DMtxCalc* mCurrentMtxCalc; private: + friend struct J3DJointFactory; + /* 0x00 */ void* mCallBackUserData; /* 0x04 */ J3DJointCallBack mCallBack; /* 0x08 */ void* field_0x8; /* 0x0C */ J3DJoint* mChild; /* 0x10 */ J3DJoint* mYounger; /* 0x14 */ u16 mJntNo; - /* 0x16 */ u8 mMtxType; + /* 0x16 */ u8 mKind; /* 0x17 */ u8 mScaleCompensate; /* 0x18 */ J3DTransformInfo mTransformInfo; /* 0x38 */ f32 mBoundingSphereRadius; diff --git a/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/include/JSystem/J3DGraphAnimator/J3DJointTree.h index b8e8267339..4937fdae32 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJointTree.h +++ b/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -34,6 +34,7 @@ public: u16 getWEvlpMtxNum() const { return mWEvlpMtxNum; } u16 getJointNum() const { return mJointNum; } u16 getDrawMtxNum() const { return mDrawMtxData.mEntryNum; } + JUTNameTab* getJointName() const { return mJointName; } J3DJoint* getRootNode() { return mRootNode; } J3DJoint* getJointNodePointer(u16 idx) const { return mJointNodePointer[idx]; } J3DMtxCalc* getBasicMtxCalc() const { return mBasicMtxCalc; } diff --git a/include/JSystem/J3DGraphAnimator/J3DModelData.h b/include/JSystem/J3DGraphAnimator/J3DModelData.h index 5371f8113a..bc4c2ba9a6 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModelData.h +++ b/include/JSystem/J3DGraphAnimator/J3DModelData.h @@ -33,6 +33,7 @@ public: J3DShape* getShapeNodePointer(u16 idx) const { return mShapeTable.getShapeNodePointer(idx); } J3DJoint* getJointNodePointer(u16 idx) const { return mJointTree.getJointNodePointer(idx); } J3DJointTree& getJointTree() { return mJointTree; } + JUTNameTab* getJointName() const { return mJointTree.getJointName(); } Mtx& getInvJointMtx(s32 idx) const { return mJointTree.getInvJointMtx(idx); } J3DTexture* getTexture() const { return mMaterialTable.getTexture(); } JUTNameTab* getTextureName() const { return mMaterialTable.getTextureName(); } diff --git a/include/JSystem/J3DGraphBase/J3DDrawBuffer.h b/include/JSystem/J3DGraphBase/J3DDrawBuffer.h index 38cc0e08c2..b937d16387 100644 --- a/include/JSystem/J3DGraphBase/J3DDrawBuffer.h +++ b/include/JSystem/J3DGraphBase/J3DDrawBuffer.h @@ -11,22 +11,37 @@ class J3DDrawPacket; class J3DMatPacket; class J3DShapePacket; -typedef void (*J3DDrawBuffer_DrawFunc)(const J3DDrawBuffer* this_); +typedef int (J3DDrawBuffer::*sortFunc)(J3DMatPacket*); +typedef void (J3DDrawBuffer::*drawFunc)() const; class J3DDrawBuffer { public: + enum EDrawType { + DRAW_HEAD, + DRAW_TAIL, + }; + + enum ESortType { + SORT_MAT, + SORT_MAT_ANM, + SORT_Z, + SORT_MODEL, + SORT_INVALID, + SORT_NON, + }; + J3DDrawBuffer() { initialize(); } ~J3DDrawBuffer(); void initialize(); J3DError allocBuffer(u32); void frameInit(); - void entryMatSort(J3DMatPacket*); - void entryMatAnmSort(J3DMatPacket*); - void entryZSort(J3DMatPacket*); - void entryModelSort(J3DMatPacket*); - void entryInvalidSort(J3DMatPacket*); - bool entryNonSort(J3DMatPacket*); - bool entryImm(J3DPacket* pPacket, u16 index); + int entryMatSort(J3DMatPacket*); + int entryMatAnmSort(J3DMatPacket*); + int entryZSort(J3DMatPacket*); + int entryModelSort(J3DMatPacket*); + int entryInvalidSort(J3DMatPacket*); + int entryNonSort(J3DMatPacket*); + int entryImm(J3DPacket* pPacket, u16 index); void draw() const; void drawHead() const; void drawTail() const; @@ -43,12 +58,12 @@ public: /* 0x10 */ f32 mZNear; /* 0x14 */ f32 mZFar; /* 0x18 */ f32 mZRatio; - /* 0x1C */ Mtx* mpZMtx; + /* 0x1C */ MtxP mpZMtx; /* 0x20 */ J3DPacket* mpCallBackPacket; - static u8 sortFuncTable[72]; - static u8 drawFuncTable[24]; - static u8 entryNum[4 + 4 /* padding */]; + static sortFunc sortFuncTable[6]; + static drawFunc drawFuncTable[2]; + static int entryNum; }; #endif /* J3DDRAWBUFFER_H */ diff --git a/include/JSystem/J3DGraphBase/J3DPacket.h b/include/JSystem/J3DGraphBase/J3DPacket.h index 6552c461af..232db283d3 100644 --- a/include/JSystem/J3DGraphBase/J3DPacket.h +++ b/include/JSystem/J3DGraphBase/J3DPacket.h @@ -51,27 +51,29 @@ public: class J3DPacket { public: J3DPacket() { - mpNextSibling = NULL; + mpNextPacket = NULL; mpFirstChild = NULL; mpUserData = NULL; } void addChildPacket(J3DPacket*); - J3DPacket* getNextPacket() const { return mpNextSibling; } + + J3DPacket* getNextPacket() const { return mpNextPacket; } + void setNextPacket(J3DPacket* i_packet) { mpNextPacket = i_packet; } - inline void clear() { - mpNextSibling = NULL; + void drawClear() { + mpNextPacket = NULL; mpFirstChild = NULL; } void setUserArea(u32 area) { mpUserData = (void*)area; } - virtual bool entry(J3DDrawBuffer*); + virtual int entry(J3DDrawBuffer*); virtual void draw(); virtual ~J3DPacket() {} public: - /* 0x04 */ J3DPacket* mpNextSibling; + /* 0x04 */ J3DPacket* mpNextPacket; /* 0x08 */ J3DPacket* mpFirstChild; /* 0x0C */ void* mpUserData; }; // Size: 0x10 @@ -143,19 +145,21 @@ public: void endDiff(); bool isSame(J3DMatPacket*) const; + J3DMaterial* getMaterial() const { return mpMaterial; } J3DShapePacket* getShapePacket() const { return mpShapePacket; } void setShapePacket(J3DShapePacket* packet) { mpShapePacket = packet; } void setInitShapePacket(J3DShapePacket* packet) { mpInitShapePacket = packet; } + bool isChanged() const { return mDiffFlag < 0; } virtual ~J3DMatPacket(); - virtual bool entry(J3DDrawBuffer*); + virtual int entry(J3DDrawBuffer*); virtual void draw(); public: /* 0x28 */ J3DShapePacket* mpInitShapePacket; /* 0x2C */ J3DShapePacket* mpShapePacket; /* 0x30 */ J3DMaterial* mpMaterial; - /* 0x34 */ u32 mSortFlags; + /* 0x34 */ u32 mDiffFlag; /* 0x38 */ J3DTexture* mpTexture; /* 0x3C */ J3DMaterialAnm* mpMaterialAnm; }; // Size: 0x40 diff --git a/include/JSystem/J3DGraphBase/J3DShape.h b/include/JSystem/J3DGraphBase/J3DShape.h index f18551d7ed..85cf0da8e9 100644 --- a/include/JSystem/J3DGraphBase/J3DShape.h +++ b/include/JSystem/J3DGraphBase/J3DShape.h @@ -27,6 +27,11 @@ static inline void J3DFifoWriteXFCmd(u16 cmd, u16 len) { class J3DCurrentMtx : public J3DCurrentMtxInfo { public: + J3DCurrentMtx() { + mMtxIdxRegA = 0x3cf3cf00; + mMtxIdxRegB = 0x00f3cf3c; + } + u32 getMtxIdxRegA() const { return mMtxIdxRegA; } u32 getMtxIdxRegB() const { return mMtxIdxRegB; } @@ -54,6 +59,14 @@ enum J3DShpFlag { class J3DShape { public: + J3DShape() { + initialize(); + } + + enum { + kVcdVatDLSize = 0xC0, + }; + /* 80314B48 */ void initialize(); /* 80314BB8 */ void addTexMtxIndexInDL(_GXAttr, u32); /* 80314CBC */ void addTexMtxIndexInVcd(_GXAttr); @@ -93,11 +106,14 @@ public: inline u32 getMtxGroupNum() const { return mMtxGroupNum; } inline J3DShapeDraw* getShapeDraw(u32 idx) const { return mShapeDraw[idx]; } inline J3DShapeMtx* getShapeMtx(u32 idx) const { return mShapeMtx[idx]; } + static void resetVcdVatCache() { sOldVcdVatCmd = NULL; } static void* sOldVcdVatCmd; private: + friend struct J3DShapeFactory; + /* 0x04 */ J3DMaterial* mMaterial; /* 0x08 */ u16 mIndex; /* 0x0A */ u16 mMtxGroupNum; diff --git a/include/JSystem/J3DGraphBase/J3DShapeMtx.h b/include/JSystem/J3DGraphBase/J3DShapeMtx.h index 0a346b2068..1b745e5fc1 100644 --- a/include/JSystem/J3DGraphBase/J3DShapeMtx.h +++ b/include/JSystem/J3DGraphBase/J3DShapeMtx.h @@ -24,6 +24,10 @@ extern u8 struct_804515B0[4]; class J3DShapeMtx { public: + J3DShapeMtx(u16 useMtxIndex) + : mUseMtxIndex(useMtxIndex) + {} + /* 803130A8 */ void resetMtxLoadCache(); /* 803130E4 */ void loadMtxIndx_PNGP(int, u16) const; /* 80313128 */ void loadMtxIndx_PCPU(int, u16) const; @@ -54,6 +58,10 @@ private: class J3DShapeMtxConcatView : public J3DShapeMtx { public: + J3DShapeMtxConcatView(u16 useMtxIndex) + : J3DShapeMtx(useMtxIndex) + {} + /* 80314730 */ virtual ~J3DShapeMtxConcatView(); /* 803147E0 */ virtual u32 getType() const; /* 80313C54 */ virtual void load() const; @@ -73,6 +81,10 @@ public: class J3DShapeMtxYBBoardConcatView : public J3DShapeMtxConcatView { public: + J3DShapeMtxYBBoardConcatView(u16 useMtxIndex) + : J3DShapeMtxConcatView(useMtxIndex) + {} + /* 80314520 */ virtual ~J3DShapeMtxYBBoardConcatView(); /* 803147E0 */ virtual u32 getType() const; /* 803143E4 */ virtual void load() const; @@ -80,6 +92,10 @@ public: class J3DShapeMtxBBoardConcatView : public J3DShapeMtxConcatView { public: + J3DShapeMtxBBoardConcatView(u16 useMtxIndex) + : J3DShapeMtxConcatView(useMtxIndex) + {} + /* 803145A4 */ virtual ~J3DShapeMtxBBoardConcatView(); /* 803147E0 */ virtual u32 getType() const; /* 803142D4 */ virtual void load() const; @@ -87,6 +103,12 @@ public: class J3DShapeMtxMulti : public J3DShapeMtx { public: + J3DShapeMtxMulti(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable) + : J3DShapeMtx(useMtxIndex) + , mUseMtxNum(useMtxNum) + , mUseMtxIndexTable(useMtxIndexTable) + {} + /* 803146B0 */ virtual ~J3DShapeMtxMulti(); /* 803147E0 */ virtual u32 getType() const; /* 80273E08 */ virtual u32 getUseMtxNum() const; @@ -96,11 +118,17 @@ public: private: /* 0x6 */ u16 mUseMtxNum; - /* 0x8 */ u16* mUseMtxIndex; + /* 0x8 */ u16* mUseMtxIndexTable; }; -class J3DShapeMtxMultiConcatView : public J3DShapeMtx { +class J3DShapeMtxMultiConcatView : public J3DShapeMtxConcatView { public: + J3DShapeMtxMultiConcatView(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable) + : J3DShapeMtxConcatView(useMtxIndex) + , mUseMtxNum(useMtxNum) + , mUseMtxIndexTable(useMtxIndexTable) + {} + /* 8031461C */ virtual ~J3DShapeMtxMultiConcatView(); /* 803147E0 */ virtual u32 getType() const; /* 80273E08 */ virtual u32 getUseMtxNum() const; @@ -111,7 +139,7 @@ public: private: /* 0x6 */ u16 mUseMtxNum; - /* 0x8 */ u16* mUseMtxIndex; + /* 0x8 */ u16* mUseMtxIndexTable; }; -#endif /* J3DSHAPEMTX_H */ +#endif /* J3DSHAPEMTX_H */
\ No newline at end of file diff --git a/include/JSystem/J3DGraphBase/J3DSys.h b/include/JSystem/J3DGraphBase/J3DSys.h index fd75fc48f7..01f882e3f4 100644 --- a/include/JSystem/J3DGraphBase/J3DSys.h +++ b/include/JSystem/J3DGraphBase/J3DSys.h @@ -93,6 +93,9 @@ struct J3DSys { void setMaterialMode(u32 mode) { mMaterialMode = mode; } void setTexture(J3DTexture* pTex) { mTexture = pTex; } + J3DTexture* getTexture() { return mTexture; } + + void setNBTScale(Vec* scale) { mNBTScale = scale; } void onFlag(u32 flag) { mFlags |= flag; } diff --git a/include/JSystem/J3DGraphBase/J3DTransform.h b/include/JSystem/J3DGraphBase/J3DTransform.h index 1bdc7ebb88..a162bd5b7c 100644 --- a/include/JSystem/J3DGraphBase/J3DTransform.h +++ b/include/JSystem/J3DGraphBase/J3DTransform.h @@ -1,13 +1,14 @@ #ifndef J3DTRANSFORM_H #define J3DTRANSFORM_H +#include "JSystem/JGeometry.h" #include "dolphin/mtx/mtxvec.h" #include "dolphin/types.h" struct J3DTransformInfo { - /* 0x00 */ Vec mScale; - /* 0x0C */ SVec mRotation; - /* 0x14 */ Vec mTranslate; + /* 0x00 */ JGeometry::TVec3<f32> mScale; + /* 0x0C */ JGeometry::TVec3<s16> mRotation; + /* 0x14 */ JGeometry::TVec3<f32> mTranslate; }; // Size: 0x20 extern J3DTransformInfo const j3dDefaultTransformInfo; diff --git a/include/JSystem/J3DGraphLoader/J3DJointFactory.h b/include/JSystem/J3DGraphLoader/J3DJointFactory.h index 2e992b48f3..98409802a7 100644 --- a/include/JSystem/J3DGraphLoader/J3DJointFactory.h +++ b/include/JSystem/J3DGraphLoader/J3DJointFactory.h @@ -1,6 +1,49 @@ #ifndef J3DJOINTFACTORY_H #define J3DJOINTFACTORY_H +#include "JSystem/J3DGraphBase/J3DTransform.h" +#include "JSystem/JGeometry.h" #include "dolphin/types.h" -#endif /* J3DJOINTFACTORY_H */ +struct J3DJoint; +struct ResNTAB; + +struct J3DJointInitData { + /* 0x00 */ u16 mKind; + /* 0x02 */ bool mScaleCompensate; + /* 0x04 */ J3DTransformInfo mTransformInfo; + /* 0x24 */ f32 mRadius; + /* 0x28 */ Vec mMin; + /* 0x2C */ Vec mMax; +}; // Size: 0x30 + +struct J3DJointBlock { + /* 0x00 */ u8 mMagic[4]; + /* 0x04 */ u32 mSize; + + /* 0x08 */ u16 mJointNum; + /* 0x0A */ u16 _pad; + + /* 0x0C */ J3DJointInitData* mJointInitData; + /* 0x10 */ u16* mIndexTable; + /* 0x14 */ ResNTAB* mNameTable; +}; + +struct J3DJointFactory { + /* 80337178 */ J3DJointFactory(J3DJointBlock const&); + /* 803371D0 */ J3DJoint* create(int); + + J3DJointInitData* mJointInitData; + u16* mIndexTable; + + u16 getKind(int no) const { return mJointInitData[mIndexTable[no]].mKind; } + u8 getScaleCompensate(int no) const { return mJointInitData[mIndexTable[no]].mScaleCompensate; } + const J3DTransformInfo& getTransformInfo(int no) const { + return mJointInitData[mIndexTable[no]].mTransformInfo; + } + f32 getRadius(int no) const { return mJointInitData[mIndexTable[no]].mRadius; } + Vec& getMin(int no) const { return mJointInitData[mIndexTable[no]].mMin; } + Vec& getMax(int no) const { return mJointInitData[mIndexTable[no]].mMax; } +}; + +#endif /* J3DJOINTFACTORY_H */
\ No newline at end of file diff --git a/include/JSystem/J3DGraphLoader/J3DShapeFactory.h b/include/JSystem/J3DGraphLoader/J3DShapeFactory.h index 6f1f64ce13..385a217e25 100644 --- a/include/JSystem/J3DGraphLoader/J3DShapeFactory.h +++ b/include/JSystem/J3DGraphLoader/J3DShapeFactory.h @@ -1,6 +1,78 @@ #ifndef J3DSHAPEFACTORY_H #define J3DSHAPEFACTORY_H +#include "dolphin/gx/GX.h" #include "dolphin/types.h" -#endif /* J3DSHAPEFACTORY_H */ +struct J3DShape; +struct J3DShapeMtx; +struct J3DShapeDraw; +struct ResNTAB; + +struct J3DShapeInitData { + /* 0x00 */ u8 mShapeMtxType; + /* 0x02 */ u16 mMtxGroupNum; + /* 0x04 */ u16 mVtxDescListIndex; + /* 0x06 */ u16 mMtxInitDataIndex; + /* 0x08 */ u16 mDrawInitDataIndex; + /* 0x0C */ f32 mRadius; + /* 0x10 */ Vec mMin; + /* 0x1C */ Vec mMax; +}; + +struct J3DShapeMtxInitData { + /* 0x00 */ u16 mUseMtxIndex; + /* 0x02 */ u16 mUseMtxCount; + /* 0x04 */ u32 mFirstUseMtxIndex; +}; + +struct J3DShapeDrawInitData { + /* 0x00 */ u32 mDisplayListSize; + /* 0x04 */ u32 mDisplayListIndex; +}; + +struct J3DShapeBlock { + /* 0x00 */ u8 mMagic[4]; + /* 0x04 */ u32 mSize; + + /* 0x08 */ u16 mShapeNum; + /* 0x0A */ u16 _pad; + + /* 0x0C */ J3DShapeInitData* mShapeInitData; + /* 0x10 */ u16* mIndexTable; + /* 0x14 */ ResNTAB* mNameTable; + /* 0x18 */ GXVtxDescList* mVtxDescList; + /* 0x1C */ u16* mMtxTable; + /* 0x20 */ u8* mDisplayListData; + /* 0x24 */ J3DShapeMtxInitData* mMtxInitData; + /* 0x28 */ J3DShapeDrawInitData* mDrawInitData; +}; + +struct J3DShapeFactory { + /* 80337350 */ J3DShapeFactory(J3DShapeBlock const&); + /* 80337400 */ J3DShape* create(int, u32, GXVtxDescList*); + /* 803375BC */ J3DShapeMtx* newShapeMtx(u32, int, int) const; + /* 8033784C */ J3DShapeDraw* newShapeDraw(int, int) const; + /* 803378D8 */ void allocVcdVatCmdBuffer(u32); + /* 80337944 */ s32 calcSize(int, u32); + /* 803379D8 */ s32 calcSizeVcdVatCmdBuffer(u32); + /* 803379E8 */ s32 calcSizeShapeMtx(u32, int, int) const; + + /* 0x00 */ J3DShapeInitData* mShapeInitData; + /* 0x04 */ u16* mIndexTable; + /* 0x08 */ GXVtxDescList* mVtxDescList; + /* 0x0C */ u16* mMtxTable; + /* 0x10 */ u8* mDisplayListData; + /* 0x14 */ J3DShapeMtxInitData* mMtxInitData; + /* 0x18 */ J3DShapeDrawInitData* mDrawInitData; + /* 0x1C */ u8* mVcdVatCmdBuffer; + + u32 getMtxGroupNum(int no) const { return mShapeInitData[mIndexTable[no]].mMtxGroupNum; } + GXVtxDescList* getVtxDescList(int no) const { return (GXVtxDescList*)((u8*)mVtxDescList + mShapeInitData[mIndexTable[no]].mVtxDescListIndex); } + f32 getRadius(int no) const { return mShapeInitData[mIndexTable[no]].mRadius; } + Vec& getMin(int no) const { return mShapeInitData[mIndexTable[no]].mMin; } + Vec& getMax(int no) const { return mShapeInitData[mIndexTable[no]].mMax; } +}; + + +#endif /* J3DSHAPEFACTORY_H */
\ No newline at end of file diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index 42e505a7b5..6eb88b0279 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -20,6 +20,18 @@ struct TVec3 { }; template <> +struct TVec3<s16> { + s16 x, y, z; + + TVec3& operator=(const TVec3& b) { + // Force copies to use lwz/lha + *((s32*)this) = *((s32*)&b); + z = b.z; + return *this; + } +}; + +template <> struct TVec3<f32> { f32 x; f32 y; @@ -47,6 +59,20 @@ struct TVec3<f32> { y = a.y * b.y; z = a.z * b.z; } + + inline TVec3<f32>& operator=(const TVec3<f32>& b) { + register f32* dst = &x; + const register f32* src = &b.x; + register f32 x_y; + register f32 z; + asm { + psq_l x_y, 0(src), 0, 0 + psq_st x_y, 0(dst), 0, 0 + lfs z, 8(src) + stfs z, 8(dst) + }; + return *this; + } }; template <typename T> diff --git a/include/JSystem/JStudio/JStudio/jstudio-object.h b/include/JSystem/JStudio/JStudio/jstudio-object.h index 9f78474e13..b0da5a2045 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-object.h +++ b/include/JSystem/JStudio/JStudio/jstudio-object.h @@ -9,7 +9,9 @@ namespace JStudio { namespace data { - struct TEOperationData {}; + enum TEOperationData { + UNK_0x19 = 0x19, + }; }; struct TAdaptor; @@ -50,6 +52,26 @@ public: /* 8028680C */ virtual void do_wait(u32); /* 8028682C */ virtual void do_data(void const*, u32, void const*, u32); + void prepareAdaptor() { + if (mpAdaptor != NULL) { + // mpAdaptor->adaptor_setObject_(this); + // mpAdaptor->adaptor_do_begin(); + } + } + + template<class T> + T* createFromAdaptor(const stb::data::TParse_TBlock_object& param_0, T* param_1) { + T* n = new T(param_0, param_1); + + if (n == NULL) { + return NULL; + } + + n->prepareAdaptor(); + + return n; + } + /* 0x34 */ TAdaptor* mpAdaptor; }; @@ -86,7 +108,11 @@ struct TAdaptor { /* 80286648 */ void adaptor_setVariableValue_FVR_INDEX_(JStudio::TAdaptor*, JStudio::TControl*, u32, void const*, u32); - /* 0x4 */ TObject* pObject_; + void adaptor_setObject_(const TObject* pObject) { + pObject_ = pObject; + } + + /* 0x4 */ const TObject* pObject_; /* 0x8 */ TVariableValue* pValue_; /* 0xC */ u32 u; }; diff --git a/include/JSystem/JStudio/JStudio/stb-data-parse.h b/include/JSystem/JStudio/JStudio/stb-data-parse.h index ef96a0d35f..b21486fcfb 100644 --- a/include/JSystem/JStudio/JStudio/stb-data-parse.h +++ b/include/JSystem/JStudio/JStudio/stb-data-parse.h @@ -73,7 +73,7 @@ struct TParse_TParagraph_data : public TParseData_aligned<4> { }; TParse_TParagraph_data(const void* content) : TParseData_aligned<4>(content) {} - /* 80289A80 */ void getData(TData*) const; + /* 80289A80 */ void getData(TData* pData) const; }; // Parses a TObject ("demo object") diff --git a/include/JSystem/JStudio/JStudio/stb.h b/include/JSystem/JStudio/JStudio/stb.h index e54ddb4b83..ec5dfbb2e8 100644 --- a/include/JSystem/JStudio/JStudio/stb.h +++ b/include/JSystem/JStudio/JStudio/stb.h @@ -152,6 +152,46 @@ private: /* 0x54 */ s32 _54; }; +template <int T> +struct TParseData { + TParseData(const void* pContent) { + data::TParse_TParagraph_data data(pContent); + set(data); + } + + void set(const data::TParse_TParagraph_data& data) { + //data::TParse_TParagraph_data::TData* p = (data::TParse_TParagraph_data::TData*)this; + data.getData(m_data); + } + + bool isEnd() const { + return m_data->_0 == 0; + } + + bool empty() const { + return m_data->_c == NULL; + } + + bool isValid() const { + return !empty() && m_data->_0 == 50; + } + + data::TParse_TParagraph_data::TData* m_data; +}; + +template <int T> +struct TParseData_fixed : public TParseData<T> { + TParseData_fixed(const void* pContent) : TParseData(pContent) {} + + const void* getNext() const { + return m_data->_c; + } + + bool isValid() const { + return TParseData::isValid() && getNext() != NULL; + } +}; + } // namespace stb } // namespace JStudio diff --git a/include/JSystem/JSupport/JSupport.h b/include/JSystem/JSupport/JSupport.h index 7c1d91058a..e98dee1f98 100644 --- a/include/JSystem/JSupport/JSupport.h +++ b/include/JSystem/JSupport/JSupport.h @@ -3,7 +3,7 @@ template <typename T> T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) { - if (ptr == NULL) { + if (offset == NULL) { return NULL; } else { return (T*)((s32)ptr + (s32)offset); |
