diff options
| author | Caroline Madsen <69010899+randomsalience@users.noreply.github.com> | 2025-04-09 16:45:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-09 13:45:30 -0700 |
| commit | c6f76e7240dde8bbcf40a88d6d88cf87cab616b4 (patch) | |
| tree | bf9afbb1c32e66f45bdba30f61a9e4f0d92f804a /include | |
| parent | 6672817e41064e04951ec28d51070b66fc8377ac (diff) | |
Various JSystem work (#2383)
* JKernel and JStudio cleanup
* JMessage cleanup
* JAudio cleanup
* JASBNKParser work
* functionvalue work
* fvb work
* J2D and J3D cleanup
* steal from tww
* J2DPictureEx mostly done
* fix build
Diffstat (limited to 'include')
33 files changed, 500 insertions, 179 deletions
diff --git a/include/JSystem/J2DGraph/J2DMatBlock.h b/include/JSystem/J2DGraph/J2DMatBlock.h index 68e54ed36e..ae7edfb061 100644 --- a/include/JSystem/J2DGraph/J2DMatBlock.h +++ b/include/JSystem/J2DGraph/J2DMatBlock.h @@ -774,6 +774,7 @@ public: void setTexGenNum(u32 num) { mTexGenNum = num; } void setTexCoord(u32 i, J2DTexCoord coord) { mTexGenCoord[i] = coord; } void setTexMtx(u32 i, J2DTexMtx* mtx) { mTexMtx[i] = mtx; } + J2DTexMtx& getTexMtx(u32 i) { return *mTexMtx[i]; } J2DTexCoord& getTexCoord(u32 i) { return mTexGenCoord[i]; } /* 802EB620 */ virtual ~J2DTexGenBlock(); @@ -783,43 +784,6 @@ public: * @ingroup jsystem-j2d * */ -struct J2DColorChanInfo { - /* 0x0 */ u8 field_0x0; - /* 0x0 */ u8 field_0x1; - /* 0x0 */ u8 field_0x2; - /* 0x0 */ u8 field_0x3; -}; - -inline u8 J2DCalcColorChanID(const J2DColorChanInfo& info) { return info.field_0x1; } -extern const J2DColorChanInfo j2dDefaultColorChanInfo; - -/** - * @ingroup jsystem-j2d - * - */ -class J2DColorChan { -public: - /* 802EB280 */ J2DColorChan() { - setColorChanInfo(j2dDefaultColorChanInfo); - } - J2DColorChan(const J2DColorChanInfo& info) { - mColorChan = J2DCalcColorChanID(info); - } - - void setColorChanInfo(const J2DColorChanInfo& info) { - mColorChan = J2DCalcColorChanID(info); - } - - u16 getMatSrc() const { return mColorChan & 1; } - -private: - /* 0x0 */ u16 mColorChan; -}; - -/** - * @ingroup jsystem-j2d - * - */ class J2DColorBlock { private: /* 0x00 */ JUtility::TColor mMatColor[2]; diff --git a/include/JSystem/J2DGraph/J2DPicture.h b/include/JSystem/J2DGraph/J2DPicture.h index 34206551b6..af827f9e4e 100644 --- a/include/JSystem/J2DGraph/J2DPicture.h +++ b/include/JSystem/J2DGraph/J2DPicture.h @@ -2,11 +2,11 @@ #define J2DPICTURE_H #include "JSystem/J2DGraph/J2DPane.h" +#include "JSystem/JUtility/JUTTexture.h" #include "JSystem/JUtility/TColor.h" class J2DMaterial; class JUTPalette; -class JUTTexture; struct ResTIMG; struct ResTLUT; @@ -55,28 +55,42 @@ struct J2DScrnBlockPictureParameter { class J2DPicture : public J2DPane { public: /* 802FCFF0 */ virtual ~J2DPicture(); - /* 802FF2E8 */ virtual u16 getTypeID() const; + /* 802FF2E8 */ virtual u16 getTypeID() const { return 18; } /* 802FDB28 */ virtual void drawSelf(f32, f32); /* 802FDB90 */ virtual void drawSelf(f32, f32, Mtx*); - /* 802FF09C */ virtual bool isUsed(ResTIMG const*); - /* 802FF63C */ virtual bool isUsed(ResFONT const*); - /* 802FF65C */ virtual void rewriteAlpha(); /* 802FCCDC */ virtual void initiate(ResTIMG const*, ResTLUT const*); /* 802FD098 */ virtual bool prepareTexture(u8); - /* 801BDD40 */ virtual bool append(ResTIMG const*, f32); - /* 802FF238 */ virtual bool append(ResTIMG const*, JUTPalette*, f32); + /* 801BDD40 */ virtual bool append(ResTIMG const* param_0, f32 param_1) { + return insert(param_0, mTextureNum, param_1); + } + /* 802FF238 */ virtual bool append(ResTIMG const* param_0, JUTPalette* param_1, f32 param_2) { + return insert(param_0, param_1, mTextureNum, param_2); + } /* 80020338 */ virtual bool append(char const* param_0, f32 param_1) { return insert(param_0, mTextureNum, param_1); } - - /* 802FF2F0 */ virtual bool append(char const*, JUTPalette*, f32); - /* 802FF208 */ virtual bool append(JUTTexture*, f32); - /* 802FF3E0 */ virtual void prepend(ResTIMG const*, f32); - /* 802FF3B0 */ virtual void prepend(ResTIMG const*, JUTPalette*, f32); - /* 802FF380 */ virtual void prepend(char const*, f32); - /* 802FF350 */ virtual void prepend(char const*, JUTPalette*, f32); - /* 802FF320 */ virtual void prepend(JUTTexture*, f32); - /* 801BDD70 */ virtual void insert(ResTIMG const*, u8, f32); + /* 802FF2F0 */ virtual bool append(char const* param_0, JUTPalette* param_1, f32 param_2) { + return insert(param_0, param_1, mTextureNum, param_2); + } + /* 802FF208 */ virtual bool append(JUTTexture* param_0, f32 param_1) { + return insert(param_0, mTextureNum, param_1); + } + /* 802FF3E0 */ virtual void prepend(ResTIMG const* param_0, f32 param_1) { + insert(param_0, 0, param_1); + } + /* 802FF3B0 */ virtual void prepend(ResTIMG const* param_0, JUTPalette* param_1, f32 param_2) { + insert(param_0, param_1, 0, param_2); + } + /* 802FF380 */ virtual void prepend(char const* param_0, f32 param_1) { + insert(param_0, 0, param_1); + } + /* 802FF350 */ virtual void prepend(char const* param_0, JUTPalette* param_1, f32 param_2) { + insert(param_0, param_1, 0, param_2); + } + /* 802FF320 */ virtual void prepend(JUTTexture* param_0, f32 param_1) { + insert(param_0, 0, param_1); + } + /* 801BDD70 */ virtual bool insert(ResTIMG const*, u8, f32); /* 802FD168 */ virtual bool insert(ResTIMG const*, JUTPalette*, u8, f32); /* 80020368 */ virtual bool insert(char const* param_0, u8 param_1, f32 param_2) { return insert(param_0, NULL, param_1, param_2); @@ -84,16 +98,40 @@ public: /* 802FD4B4 */ virtual bool insert(char const*, JUTPalette*, u8, f32); /* 802FD524 */ virtual bool insert(JUTTexture*, u8, f32); /* 802FD6F4 */ virtual bool remove(u8); - /* 802FF410 */ virtual bool remove(); + /* 802FF410 */ virtual bool remove() { return remove(mTextureNum - 1); } /* 802FD814 */ virtual bool remove(JUTTexture*); - /* 802FF4E0 */ virtual void draw(f32, f32, bool, bool, bool); - /* 802FF448 */ virtual void draw(f32, f32, u8, bool, bool, bool); + /* 802FF4E0 */ virtual void draw(f32 param_0, f32 param_1, bool param_2, bool param_3, + bool param_4) { + draw(param_0, param_1, 0, param_2, param_3, param_4); + } + /* 802FF448 */ virtual void draw(f32 param_0, f32 param_1, u8 param_2, bool param_3, + bool param_4, bool param_5) { + if (param_2 < mTextureNum && mTexture[param_2] != NULL) { + draw(param_0, param_1, mTexture[param_2]->getWidth(), mTexture[param_2]->getHeight(), + param_3, param_4, param_5); + } + } /* 802FDC70 */ virtual void draw(f32, f32, f32, f32, bool, bool, bool); - /* 802FF588 */ virtual void drawOut(f32, f32, f32, f32, f32, f32); - /* 802FF524 */ virtual void drawOut(f32, f32, f32, f32, f32, f32, f32, f32); + /* 802FF588 */ virtual void drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, + f32 param_4, f32 param_5) { + if (mTexture[0] != NULL) { + drawOut(JGeometry::TBox2<f32>(param_0, param_1, param_0 + param_2, param_1 + param_3), + JGeometry::TBox2<f32>(param_4, param_5, param_4 + mTexture[0]->getWidth(), + param_5 + mTexture[0]->getHeight())); + } + } + /* 802FF524 */ virtual void drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, + f32 param_4, f32 param_5, f32 param_6, f32 param_7) { + drawOut(JGeometry::TBox2<f32>(param_0, param_1, param_0 + param_2, param_1 + param_3), + JGeometry::TBox2<f32>(param_4, param_5, param_4 + param_6, param_5 + param_7)); + } /* 802FDF88 */ virtual void drawOut(JGeometry::TBox2<f32> const&, JGeometry::TBox2<f32> const&); - /* 802FF29C */ virtual void load(_GXTexMapID, u8); - /* 802FF268 */ virtual void load(u8); + /* 802FF29C */ virtual void load(_GXTexMapID param_0, u8 param_1) { + if (param_1 < mTextureNum && param_1 < 2 && mTexture[param_1] != NULL) { + mTexture[param_1]->load(param_0); + } + } + /* 802FF268 */ virtual void load(u8 param_0) { load((_GXTexMapID)param_0, param_0); } /* 800202CC */ virtual void setBlendRatio(f32 param_0, f32 param_1) { setBlendColorRatio(param_0, param_1); setBlendAlphaRatio(param_0, param_1); @@ -105,7 +143,7 @@ public: /* 802FD9BC */ virtual const ResTIMG* changeTexture(ResTIMG const*, u8, JUTPalette*); /* 802FDAC8 */ virtual const ResTIMG* changeTexture(char const*, u8, JUTPalette*); /* 800539DC */ virtual JUTTexture* getTexture(u8) const; - /* 802FF634 */ virtual u8 getTextureCount() const; + /* 802FF634 */ virtual u8 getTextureCount() const { return mTextureNum; } /* 80053C6C */ virtual bool setBlack(JUtility::TColor i_black) { mBlack = i_black; return true; @@ -130,6 +168,9 @@ public: /* 802FE380 */ virtual void drawTexCoord(f32, f32, f32, f32, s16, s16, s16, s16, s16, s16, s16, s16, Mtx*); /* 802FF100 */ virtual u8 getUsableTlut(u8); + /* 802FF09C */ virtual bool isUsed(ResTIMG const*); + /* 802FF63C */ virtual bool isUsed(ResFONT const* param_0) { return J2DPane::isUsed(param_0); } + /* 802FF65C */ virtual void rewriteAlpha() {} /* 802FC800 */ J2DPicture(u64, JGeometry::TBox2<f32> const&, ResTIMG const*, ResTLUT const*); /* 802FC708 */ J2DPicture(ResTIMG const*); diff --git a/include/JSystem/J2DGraph/J2DPictureEx.h b/include/JSystem/J2DGraph/J2DPictureEx.h index e8252bb4f5..9d7e86bb6f 100644 --- a/include/JSystem/J2DGraph/J2DPictureEx.h +++ b/include/JSystem/J2DGraph/J2DPictureEx.h @@ -12,7 +12,16 @@ class J2DMaterial; */ class J2DPictureEx : public J2DPicture { public: - enum stage_enum {}; + enum stage_enum { + STAGE_0, + STAGE_1, + STAGE_2, + STAGE_3, + STAGE_4, + STAGE_5, + STAGE_6, + STAGE_7, + }; /* 803036EC */ J2DPictureEx(J2DPane*, JSURandomInputStream*, u32, J2DMaterial*); /* 803040E4 */ void insertCommon(u8, f32); @@ -57,7 +66,7 @@ public: /* 80306F94 */ virtual void prepend(char const*, f32); /* 80306F64 */ virtual void prepend(char const*, JUTPalette*, f32); /* 80306F34 */ virtual void prepend(JUTTexture*, f32); - /* 80307058 */ virtual void insert(ResTIMG const*, u8, f32); + /* 80307058 */ virtual bool insert(ResTIMG const*, u8, f32); /* 80303F34 */ virtual bool insert(ResTIMG const*, JUTPalette*, u8, f32); /* 80307024 */ virtual bool insert(char const*, u8, f32); /* 80303FD8 */ virtual bool insert(char const*, JUTPalette*, u8, f32); @@ -100,8 +109,9 @@ private: /* 0x160 */ f32 field_0x160[6]; // related to blend color ratio /* 0x178 */ f32 field_0x178[6]; // related to blend alpha ratio /* 0x190 */ u8 field_0x190; - /* 0x194 */ int field_0x194; - /* 0x198 */ int field_0x198; + /* 0x194 */ J2DAnmVisibilityFull* field_0x194; + /* 0x198 */ J2DAnmVtxColor* field_0x198; + /* 0x19C */ u8 field_0x19c; }; #endif /* J2DPICTUREEX_H */ diff --git a/include/JSystem/J2DGraph/J2DTevs.h b/include/JSystem/J2DGraph/J2DTevs.h index a1c31301f9..845b94e89d 100644 --- a/include/JSystem/J2DGraph/J2DTevs.h +++ b/include/JSystem/J2DGraph/J2DTevs.h @@ -279,11 +279,11 @@ extern J2DTexCoordInfo const j2dDefaultTexCoordInfo[8]; class J2DTexCoord { public: /* 802EB260 */ inline J2DTexCoord() { - *(J2DTexCoordInfo*)this = j2dDefaultTexCoordInfo[0]; + mTexCoordInfo = j2dDefaultTexCoordInfo[0]; } J2DTexCoord(const J2DTexCoordInfo& info) { - *(J2DTexCoordInfo*)this = info; + mTexCoordInfo = info; } void setTexCoordInfo(const J2DTexCoordInfo& info) { mTexCoordInfo = info; } void setTexGenMtx(u8 texGenMtx) { mTexCoordInfo.mTexGenMtx = texGenMtx; } @@ -553,6 +553,43 @@ private: /* 0x0 */ u8 field_0x0; }; +/** + * @ingroup jsystem-j2d + * + */ +struct J2DColorChanInfo { + /* 0x0 */ u8 field_0x0; + /* 0x0 */ u8 field_0x1; + /* 0x0 */ u8 field_0x2; + /* 0x0 */ u8 field_0x3; +}; + +inline u8 J2DCalcColorChanID(const J2DColorChanInfo& info) { return info.field_0x1; } +extern const J2DColorChanInfo j2dDefaultColorChanInfo; + +/** + * @ingroup jsystem-j2d + * + */ +class J2DColorChan { +public: + /* 802EB280 */ J2DColorChan() { + setColorChanInfo(j2dDefaultColorChanInfo); + } + J2DColorChan(const J2DColorChanInfo& info) { + mColorChan = J2DCalcColorChanID(info); + } + + void setColorChanInfo(const J2DColorChanInfo& info) { + mColorChan = J2DCalcColorChanID(info); + } + + u16 getMatSrc() const { return mColorChan & 1; } + +private: + /* 0x0 */ u16 mColorChan; +}; + extern const GXColor j2dDefaultColInfo; extern const GXColorS10 j2dDefaultTevColor; extern const GXColor j2dDefaultTevKColor; diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index ae838de450..6e6d20ef13 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -31,7 +31,8 @@ struct J3DGXColor : public GXColor { /* 8000E538 */ J3DGXColor() {} J3DGXColor(J3DGXColor const& other) { __memcpy(this, &other, sizeof(J3DGXColor)); } J3DGXColor(GXColor const& color) : GXColor(color) {} - J3DGXColor& operator=(const GXColor& color) { + // making color a reference breaks J3DColorBlockLightOff::initialize et al + J3DGXColor& operator=(GXColor color) { *(GXColor*)this = color; return *this; } @@ -1054,8 +1055,8 @@ public: /* 80317414 */ virtual void setIndTexMtx(u32, J3DIndTexMtx const*) {} /* 8000E060 */ virtual void setIndTexMtx(u32, J3DIndTexMtx) {} /* 8000DF6C */ virtual J3DIndTexMtx* getIndTexMtx(u32) { return NULL; } - /* 8000E020 */ virtual void setIndTexCoordScale(u32, J3DIndTexCoordScale) {} /* 80317418 */ virtual void setIndTexCoordScale(u32, J3DIndTexCoordScale const*) {} + /* 8000E020 */ virtual void setIndTexCoordScale(u32, J3DIndTexCoordScale) {} /* 8000DF64 */ virtual J3DIndTexCoordScale* getIndTexCoordScale(u32) { return NULL; } /* 8031726C */ virtual ~J3DIndBlock() {} }; @@ -1066,9 +1067,9 @@ public: */ class J3DIndBlockNull : public J3DIndBlock { public: - /* 803173A0 */ virtual void reset(J3DIndBlock*) {} /* 80317398 */ virtual void diff(u32) {} /* 8031739C */ virtual void load() {} + /* 803173A0 */ virtual void reset(J3DIndBlock*) {} /* 803173A4 */ virtual u32 getType() { return 'IBLN'; } /* 803173B0 */ virtual ~J3DIndBlockNull() {} }; diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h index 43a7c2edc2..3100e58ced 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -94,7 +94,7 @@ struct J3DTexCoord : public J3DTexCoordInfo { u8 getTexGenType() const { return mTexGenType; } u8 getTexGenSrc() const { return mTexGenSrc; } u8 getTexGenMtx() const { return mTexGenMtx; } - u16 getTexMtxReg() const { return mTexMtxReg & 0xff; } + u32 getTexMtxReg() const { return mTexMtxReg & 0xff; } void setTexGenMtx(u8 param_1) { mTexGenMtx = param_1; } void setTexMtxReg(u16 reg) { mTexMtxReg = reg; } J3DTexCoord& operator=(const J3DTexCoord& other) { diff --git a/include/JSystem/JAudio2/JASBNKParser.h b/include/JSystem/JAudio2/JASBNKParser.h index 9c2d23e955..29a2d9140e 100644 --- a/include/JSystem/JAudio2/JASBNKParser.h +++ b/include/JSystem/JAudio2/JASBNKParser.h @@ -2,6 +2,7 @@ #define JASBNKPARSER_H #include "JSystem/JAudio2/JASOscillator.h" +#include "JSystem/JSupport/JSupport.h" class JASBank; class JASBasicBank; @@ -53,24 +54,85 @@ namespace JASBNKParser { /* 0xC */ u32 mOffsets[0]; }; - /* 80299600 */ static TChunk* findChunk(void const*, u32); - /* 8029963C */ static JASBasicBank* createBasicBank(void const*, JKRHeap*); + /* 80299600 */ TChunk* findChunk(void const*, u32); + /* 8029963C */ JASBasicBank* createBasicBank(void const*, JKRHeap*); }; namespace Ver0 { - struct THeader {}; + template<typename T> + struct TOffset { + /* 0x0 */ u32 offset; + T* ptr(void const* stream) const { return JSUConvertOffsetToPtr<T>(stream, offset); } + }; + + struct TOsc { + /* 0x00 */ u8 mTarget; + /* 0x04 */ f32 field_0x4; + /* 0x08 */ TOffset<JASOscillator::Point> mPointOffset; + /* 0x0C */ TOffset<JASOscillator::Point> field_0xc; + /* 0x10 */ f32 mScale; + /* 0x14 */ f32 field_0x14; + }; + + struct TVmap { + /* 0x00 */ u8 field_0x0[4]; + /* 0x04 */ u32 field_0x4; + /* 0x08 */ f32 field_0x8; + /* 0x0C */ f32 field_0xc; + }; + + struct TKeymap { + /* 0x00 */ u8 mHighKey; + /* 0x01 */ u8 field_0x1[7]; + /* 0x08 */ TOffset<TVmap> mVmapOffset; + }; + + struct TInst { + /* 0x00 */ u8 field_0x0[8]; + /* 0x08 */ f32 mVolume; + /* 0x0C */ f32 mPitch; + /* 0x10 */ TOffset<TOsc> mOscOffset[2]; + /* 0x18 */ u8 field_0x18[0x10]; + /* 0x28 */ u32 mKeyRegionCount; + /* 0x2C */ TOffset<TKeymap> mKeymapOffset[0]; + }; - struct TOsc {}; + struct TPmap { + /* 0x00 */ f32 mVolume; + /* 0x04 */ f32 mPitch; + /* 0x08 */ u8 field_0x8[0xc]; + /* 0x14 */ TOffset<TVmap> mVmapOffset; + }; + + struct TPerc { + /* 0x000 */ u32 mMagic; + /* 0x000 */ u8 field_0x0[0x84]; + /* 0x088 */ TOffset<TPmap> mPmapOffset[0x80]; + /* 0x288 */ s8 mPan[0x80]; + /* 0x308 */ u16 mRelease[0x80]; + }; + + struct TOffsetData { + /* 0x000 */ u8 field_0x20[4]; + /* 0x004 */ TOffset<TInst> mInstOffset[0x80]; + /* 0x204 */ u8 field_0x204[0x190]; + /* 0x394 */ TOffset<TPerc> mPercOffset[12]; + }; + + struct THeader { + /* 0x00 */ u8 field_0x0[0x20]; + /* 0x20 */ TOffsetData mOffsets; + }; - /* 80299A3C */ static JASBasicBank* createBasicBank(void const*, JKRHeap*); - /* 80299E68 */ static void findOscPtr(JASBasicBank*, THeader const*, TOsc const*); - /* 80299F8C */ static void getOscTableEndPtr(JASOscillator::Point const*); + /* 80299A3C */ JASBasicBank* createBasicBank(void const*, JKRHeap*); + /* 80299E68 */ JASOscillator::Data* findOscPtr(JASBasicBank*, THeader const*, TOsc const*); + /* 80299F8C */ JASOscillator::Point const* getOscTableEndPtr(JASOscillator::Point const*); }; - /* 80299538 */ static JASBank* createBank(void const*, JKRHeap*); - /* 80299558 */ static JASBasicBank* createBasicBank(void const*, JKRHeap*); + /* 80299538 */ JASBank* createBank(void const*, JKRHeap*); + /* 80299558 */ JASBasicBank* createBasicBank(void const*, JKRHeap*); - inline static u32 getBankNumber(const void* param_0) { return ((u32*)param_0)[2]; } + inline u32 getBankNumber(const void* param_0) { return ((u32*)param_0)[2]; } extern u32 sUsedHeapSize; }; diff --git a/include/JSystem/JAudio2/JASHeapCtrl.h b/include/JSystem/JAudio2/JASHeapCtrl.h index 18a5a627d8..e0f4be1822 100644 --- a/include/JSystem/JAudio2/JASHeapCtrl.h +++ b/include/JSystem/JAudio2/JASHeapCtrl.h @@ -68,13 +68,11 @@ namespace JASThreadingModel { }; }; - + template <typename A0> struct ObjectLevelLockable { - // Should be templated on the chunk memory but couldn't initialize it inside the class itself - //template <typename A0> struct Lock { - Lock(OSMutex* mutex) { - mMutex = mutex; + Lock(A0 const& mutex) { + mMutex = (A0*)&mutex; OSLockMutex(mMutex); } @@ -82,7 +80,7 @@ namespace JASThreadingModel { OSUnlockMutex(mMutex); } - OSMutex* mMutex; + A0* mMutex; }; }; }; @@ -105,8 +103,8 @@ namespace JASKernel { JKRHeap* getSystemHeap(); }; * @ingroup jsystem-jaudio * */ -template<u32 ChunkSize, typename T> -class JASMemChunkPool { +template<u32 ChunkSize, template<typename> class T> +class JASMemChunkPool : public OSMutex { struct MemoryChunk { MemoryChunk(MemoryChunk* nextChunk) { mNextChunk = nextChunk; @@ -156,7 +154,7 @@ class JASMemChunkPool { }; public: JASMemChunkPool() { - OSInitMutex(&mMutex); + OSInitMutex(this); field_0x18 = NULL; createNewChunk(); } @@ -185,7 +183,7 @@ public: } void* alloc(u32 size) { - typename T::Lock lock(&mMutex); + typename T<JASMemChunkPool<ChunkSize, T> >::Lock lock(*this); if (field_0x18->getFreeSize() < size) { if (ChunkSize < size) { return NULL; @@ -198,7 +196,7 @@ public: } void free(void* ptr) { - typename T::Lock lock(&mMutex); + typename T<JASMemChunkPool<ChunkSize, T> >::Lock lock(*this); MemoryChunk* chunk = field_0x18; MemoryChunk* prevChunk = NULL; while (chunk != NULL) { @@ -216,7 +214,6 @@ public: } } - /* 0x00 */ OSMutex mMutex; /* 0x18 */ MemoryChunk* field_0x18; }; diff --git a/include/JSystem/JAudio2/JASTrack.h b/include/JSystem/JAudio2/JASTrack.h index d6b8df2660..85e729cb72 100644 --- a/include/JSystem/JAudio2/JASTrack.h +++ b/include/JSystem/JAudio2/JASTrack.h @@ -7,6 +7,7 @@ #include "JSystem/JAudio2/JASSeqCtrl.h" #include "JSystem/JAudio2/JASTrackPort.h" #include "JSystem/JGadget/linklist.h" +#include "global.h" struct JASSoundParams; diff --git a/include/JSystem/JGadget/binary.h b/include/JSystem/JGadget/binary.h index cb1b18ed7d..3f4485803b 100644 --- a/include/JSystem/JGadget/binary.h +++ b/include/JSystem/JGadget/binary.h @@ -40,7 +40,7 @@ struct TParseData_aligned : public TParseData { // Base for header and/or block parsing struct TParse_header_block { - virtual ~TParse_header_block(); + virtual ~TParse_header_block() = 0; virtual bool parseHeader_next(const void** ppData_inout, u32* puBlock_out, u32 arg2) = 0; virtual bool parseBlock_next(const void** ppData_inout, u32* puData_out, u32 arg2) = 0; diff --git a/include/JSystem/JGadget/linklist.h b/include/JSystem/JGadget/linklist.h index a64c92733f..5147a9a0ce 100644 --- a/include/JSystem/JGadget/linklist.h +++ b/include/JSystem/JGadget/linklist.h @@ -2,6 +2,7 @@ #define LINKLIST_H #include "JSystem/JUtility/JUTAssert.h" +#include <iterator.h> namespace JGadget { struct TLinkListNode { @@ -146,6 +147,12 @@ struct TLinkList : public TNodeLinkList { T* operator->() const { return Element_toValue(base.operator->()); } T& operator*() const { return *operator->(); } + typedef s32 difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef std::bidirectional_iterator_tag iterator_category; + public: /* 0x00 */ TNodeLinkList::iterator base; }; @@ -221,7 +228,7 @@ struct TLinkList : public TNodeLinkList { template <typename T, int I> struct TLinkList_factory : public TLinkList<T, I> { - virtual ~TLinkList_factory() {} + inline virtual ~TLinkList_factory() = 0; virtual T* Do_create() = 0; virtual void Do_destroy(T*) = 0; void Clear_destroy() { @@ -233,6 +240,9 @@ struct TLinkList_factory : public TLinkList<T, I> { } }; +template <typename T, int I> +TLinkList_factory<T, I>::~TLinkList_factory() {} + template <typename T> struct TEnumerator { inline TEnumerator(T _current, T _end) diff --git a/include/JSystem/JGadget/search.h b/include/JSystem/JGadget/search.h index 0ef191d046..1e6b7561af 100644 --- a/include/JSystem/JGadget/search.h +++ b/include/JSystem/JGadget/search.h @@ -2,9 +2,24 @@ #define SEARCH_H #include "dolphin/os.h" +#include <iterator.h> +#include <functional.h> +#include <algorithm.h> namespace JGadget { +namespace search { + +template <typename T> +struct TExpandStride_ {}; + +template <> +struct TExpandStride_<s32> { + static s32 get(s32 n) { return n << 3; } +}; + +} // namespace search + //! @todo: mangled name isn't correct, fix this //! Current: toValueFromIndex<PFdd_d>__7JGadgetFiPCPFdd_dUlRCPFdd_d //! Target: toValueFromIndex<PFdd_d>__7JGadgetFiPCPFdd_dUlRCPFdd_d_RCPFdd_d @@ -14,6 +29,92 @@ inline const T& toValueFromIndex(int idx, const T* pValue, u32 count, const T& f return (idx >= count) ? fallback : pValue[idx]; } +template <typename Iterator, typename T, typename Predicate> +inline Iterator findUpperBound_binary_all(Iterator first, Iterator last, const T& val, Predicate p) { + return upper_bound(first, last, val, p); +} + +template <typename Iterator, typename T, typename Predicate> +inline Iterator findUpperBound_binary_begin(Iterator first, Iterator last, const T& val, Predicate p) { + if (first == last) { + return last; + } + + typedef typename std::iterator_traits<Iterator>::difference_type difference_type; + difference_type dist = std::distance(first, last); + difference_type stride = 1; + search::TExpandStride_<difference_type> expand; + Iterator i = first; + + while (true) { + if (p(val, *i)) { + if (stride == 1) { + return i; + } else { + break; + } + } + first = i; + dist -= stride; + if (dist <= 0) { + i = last; + break; + } + i += stride; + stride = expand.get(stride); + } + + return findUpperBound_binary_all(first, i, val, p); +} + +template <typename Iterator, typename T, typename Predicate> +inline Iterator findUpperBound_binary_end(Iterator first, Iterator last, const T& val, Predicate p) { + if (first == last) { + return last; + } + + typedef typename std::iterator_traits<Iterator>::difference_type difference_type; + --last; + difference_type dist = std::distance(first, last); + difference_type stride = 1; + search::TExpandStride_<difference_type> expand; + Iterator i = last; + + while (true) { + if (!p(val, *i)) { + if (stride == 1) { + return ++i; + } else { + break; + } + } + last = i; + dist -= stride; + if (dist <= 0) { + i = first; + break; + } + i -= stride; + stride = expand.get(stride); + } + + return findUpperBound_binary_all(i, ++last, val, p); +} + +template <typename Iterator, typename T, typename Predicate> +Iterator findUpperBound_binary_current(Iterator first, Iterator last, Iterator current, const T& val, Predicate p) { + return current == last || p(val, *current) ? + findUpperBound_binary_end(first, current, val, p) + : findUpperBound_binary_begin(current, last, val, p); +} + +// NONMATCHING stack alloc +template <typename Iterator, typename T> +Iterator findUpperBound_binary_current(Iterator first, Iterator last, Iterator current, const T& val) { + std::less<T> less; + return findUpperBound_binary_current(first, last, current, val, less); +} + } // namespace JGadget #endif /* SEARCH_H */ diff --git a/include/JSystem/JGadget/std-vector.h b/include/JSystem/JGadget/std-vector.h index d8c765f941..95fb777644 100644 --- a/include/JSystem/JGadget/std-vector.h +++ b/include/JSystem/JGadget/std-vector.h @@ -2,8 +2,8 @@ #define STD_VECTOR_H #include "JSystem/JGadget/std-memory.h" -#include "algorithm.h" -#include "msl_memory.h" +#include <algorithm.h> +#include <msl_memory.h> namespace JGadget { namespace vector { @@ -41,12 +41,6 @@ struct TVector { mAllocator.deallocate(pBegin_, 0); } - T* insert(T* pos, const T& val) { - u32 diff = (int)((u32)pos - (u32)begin()) / 4; - insert(pos, 1, val); - return pBegin_ + diff; - } - void insert(T* pos, u32 count, const T& val) { if (count != 0) { T* ptr = Insert_raw(pos, count); @@ -110,11 +104,17 @@ struct TVector { return endOfCopy; } - T* begin() { return pBegin_; } + T* insert(T* pos, const T& val) { + u32 diff = (int)((u32)pos - (u32)begin()) / 4; + insert(pos, 1, val); + return pBegin_ + diff; + } + + T* begin() const { return pBegin_; } - T* end() { return pEnd_; } + T* end() const { return pEnd_; } - u32 size() { + u32 size() const { if (pBegin_ == 0) { return 0; } @@ -171,6 +171,23 @@ struct TVector_pointer_void : public TVector<void*, TAllocator<void*> > { void clear() { erase(begin(), end()); } void push_back(const void*& value) { insert(end(), (void* const&)value); } }; + +template <typename T> +struct TVector_pointer : TVector_pointer_void { + TVector_pointer(const TAllocator<void*>& allocator) : TVector_pointer_void(allocator) {} + ~TVector_pointer() {} + + const T* begin() const { return (const T*)TVector_pointer_void::begin(); } + T* begin() { return (T*)TVector_pointer_void::begin(); } + + const T* end() const { return (const T*)TVector_pointer_void::end(); } + T* end() { return (T*)TVector_pointer_void::end(); } + + void push_back(const T& ref) { + static_cast<TVector_pointer_void*>(this)->push_back((const void*&)ref); + } +}; + } // namespace JGadget #endif /* STD_VECTOR_H */ diff --git a/include/JSystem/JGadget/vector.h b/include/JSystem/JGadget/vector.h index 41d1bdce8d..6372f183a5 100644 --- a/include/JSystem/JGadget/vector.h +++ b/include/JSystem/JGadget/vector.h @@ -1,9 +1,9 @@ #ifndef VECTOR_H #define VECTOR_H +#include <dolphin/types.h> extern u8 data_804511E0; -extern u8 lit_569[]; namespace JGadget { @@ -18,7 +18,7 @@ typedef u32 (*ExtendFunc)(u32, u32, u32); template <typename T> struct TAllocator { static TAllocator get() {} - inline TAllocator() { _0 = lit_569[0]; } + inline TAllocator(u8 param_0) { _0 = param_0; } /* 0x0 */ u8 _0; /* 0x4 */ u32 _4; /* 0x8 */ u32 _8; @@ -83,4 +83,4 @@ struct TVector_pointer : TVector_pointer_void { } // namespace JGadget -#endif /* VECTOR_H */
\ No newline at end of file +#endif /* VECTOR_H */ diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index fca7ba42f5..5fa7081aba 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -46,8 +46,8 @@ template<> struct TUtil<double> { static inline double epsilon() { return 32.0f * FLT_EPSILON; } static inline double one() { return 1.0; } - static inline double atan2(double x, double y) { return atan2(x, y); } - static inline double asin(double x) { return asin(x); } + static inline double atan2(double x, double y) { return ::atan2(x, y); } + static inline double asin(double x) { return ::asin(x); } static inline double halfPI() { return 1.5707963267948966; } }; diff --git a/include/JSystem/JKernel/JKRAramArchive.h b/include/JSystem/JKernel/JKRAramArchive.h index 8ff04ebaa7..2ea5f2863b 100644 --- a/include/JSystem/JKernel/JKRAramArchive.h +++ b/include/JSystem/JKernel/JKRAramArchive.h @@ -4,7 +4,7 @@ #include "JSystem/JKernel/JKRArchive.h" class JKRAramBlock; -class JKRDvdFile; +class JKRFile; /** * @ingroup jsystem-jkernel @@ -31,7 +31,7 @@ private: /* 0x00 */ // vtable /* 0x04 */ // JKRArchive /* 0x64 */ JKRAramBlock* mBlock; - /* 0x68 */ JKRDvdFile* mDvdFile; + /* 0x68 */ JKRFile* mDvdFile; }; // Size = 0x6C #endif /* JKRARAMARCHIVE_H */ diff --git a/include/JSystem/JKernel/JKRDvdAramRipper.h b/include/JSystem/JKernel/JKRDvdAramRipper.h index fe12c61c39..1e0f05ac15 100644 --- a/include/JSystem/JKernel/JKRDvdAramRipper.h +++ b/include/JSystem/JKernel/JKRDvdAramRipper.h @@ -51,6 +51,7 @@ public: static bool syncAram(JKRADCommand*, int); static void setSZSBufferSize(u32 size) { sSZSBufferSize = size; } + static bool isErrorRetry() { return errorRetry; } // TODO: fix type static JSUList<JKRADCommand> sDvdAramAsyncList; diff --git a/include/JSystem/JMessage/data.h b/include/JSystem/JMessage/data.h index a89f6e1d70..6dcf003652 100644 --- a/include/JSystem/JMessage/data.h +++ b/include/JSystem/JMessage/data.h @@ -45,8 +45,8 @@ struct data { char* get() const { return (char*)getRaw(); } u8 get_formSupplement() const { return *(u8*)(get() + 0xB); } - u16 get_number() const { return *(u16*)(get() + 0x8); } - char* getContent() const { return (char*)get() + 0x10; } + int get_number() const { return *(u16*)(get() + 0x8); } + u32* getContent() const { return (u32*)((u32)getRaw() + 0x10); } u8 get_form() const { return *(u8*)(get() + 0xA) & 0xF; } bool get_isOrdered() const { return *(u8*)(get() + 0xA) & 0xF0; } }; diff --git a/include/JSystem/JMessage/processor.h b/include/JSystem/JMessage/processor.h index 0d55e8d00f..858aa27f93 100644 --- a/include/JSystem/JMessage/processor.h +++ b/include/JSystem/JMessage/processor.h @@ -108,8 +108,10 @@ struct TProcessor { /* 802A82F4 */ static bool process_onCharacterEnd_select_(JMessage::TProcessor*); /* 802A833C */ static const char* process_onSelect_limited_(JMessage::TProcessor*); /* 802A8358 */ static const char* process_onSelect_(JMessage::TProcessor*); - /* 802A8C24 */ const char* on_message(u32) const; - /* 802A8C44 */ const char* getMessageText_messageCode(u32) const; + /* 802A8C24 */ const char* on_message(u32 param_0) const { return getMessageText_messageCode(param_0); } + /* 802A8C44 */ const char* getMessageText_messageCode(u32 param_0) const { + return getMessageText_messageCode(param_0 >> 0x10, param_0 & 0xFFFF); + } /* 802A7B48 */ virtual ~TProcessor(); /* 802A7FC0 */ virtual void do_reset(); diff --git a/include/JSystem/JMessage/resource.h b/include/JSystem/JMessage/resource.h index 4a4b990dc3..9462b3b34d 100644 --- a/include/JSystem/JMessage/resource.h +++ b/include/JSystem/JMessage/resource.h @@ -4,7 +4,6 @@ #include "JSystem/JGadget/linklist.h" #include "JSystem/JMessage/data.h" #include "JSystem/JMessage/locale.h" -#include "JSystem/JStudio/JStudio/fvb-data.h" namespace JMessage { @@ -114,7 +113,7 @@ struct TResourceContainer { static JMessage::locale::parseCharacter_function sapfnParseCharacter_[5]; /* 0x00 */ u8 mEncodingType; - /* 0x04 */ int (*pfnParseCharacter_)(const char** string); + /* 0x04 */ JMessage::locale::parseCharacter_function pfnParseCharacter_; /* 0x08 */ TCResource resContainer_; /* 0x18 */ TResource_color resColor_; }; diff --git a/include/JSystem/JStudio/JStudio/ctb.h b/include/JSystem/JStudio/JStudio/ctb.h index 6e303cd47f..d45b3e74bc 100644 --- a/include/JSystem/JStudio/JStudio/ctb.h +++ b/include/JSystem/JStudio/JStudio/ctb.h @@ -112,7 +112,7 @@ struct data { struct TObject_TxyzRy : public TObject { /* 80280F60 */ TObject_TxyzRy(JStudio::ctb::data::TParse_TBlock const&); - /* 80281554 */ virtual ~TObject_TxyzRy(); + /* 80281554 */ virtual ~TObject_TxyzRy() {} /* 80280FBC */ virtual int getScheme() const; }; diff --git a/include/JSystem/JStudio/JStudio/functionvalue.h b/include/JSystem/JStudio/JStudio/functionvalue.h index c6833d4294..6152f05fdb 100644 --- a/include/JSystem/JStudio/JStudio/functionvalue.h +++ b/include/JSystem/JStudio/JStudio/functionvalue.h @@ -1,9 +1,11 @@ #ifndef FUNCTIONVALUE_H #define FUNCTIONVALUE_H -#include "JSystem/JGadget/search.h" -#include "JSystem/JGadget/vector.h" -#include "global.h" +#include "JSystem/JGadget/std-vector.h" +#include "dolphin/os.h" +#include <iterator.h> + +extern u8 lit_569; namespace JStudio { @@ -66,20 +68,19 @@ public: : TFunctionValueAttributeSet_const(refer, range, interp) {} TFunctionValueAttribute_refer* refer_get() const { - return static_cast<const TFunctionValueAttributeSet_const*>(this)->refer_get(); + return TFunctionValueAttributeSet_const::refer_get(); } TFunctionValueAttribute_range* range_get() const { - return static_cast<const TFunctionValueAttributeSet_const*>(this)->range_get(); + return TFunctionValueAttributeSet_const::range_get(); } TFunctionValueAttribute_interpolate* interpolate_get() const { - return static_cast<const TFunctionValueAttributeSet_const*>(this)->interpolate_get(); + return TFunctionValueAttributeSet_const::interpolate_get(); } }; class TFunctionValueAttribute_refer : public JGadget::TVector_pointer<TFunctionValue*> { public: - TFunctionValueAttribute_refer() : - JGadget::TVector_pointer<TFunctionValue*>(JGadget::TAllocator<void*>()) {} + inline TFunctionValueAttribute_refer(); ~TFunctionValueAttribute_refer() {} /* 802816E8 */ void refer_initialize(); @@ -191,7 +192,7 @@ public: }; typedef f64 (*UnkFunc)(f64, const TFunctionValueAttribute_refer*, const TFunctionValue_composite::TData*); - typedef f64 (*CompositeFunc)(const JGadget::TVector_pointer<TFunctionValue>&, + typedef f64 (*CompositeFunc)(const JGadget::TVector_pointer<TFunctionValue*>&, const TFunctionValue_composite::TData&, f64); /* 80281D5C */ TFunctionValue_composite(); @@ -227,7 +228,7 @@ public: TData data; }; -class TFunctionValue_transition : TFunctionValue, +class TFunctionValue_transition : public TFunctionValue, TFunctionValueAttribute_range, TFunctionValueAttribute_interpolate { public: @@ -252,7 +253,7 @@ private: /* 0x50 */ f64 _50; }; -class TFunctionValue_list : TFunctionValue, +class TFunctionValue_list : public TFunctionValue, TFunctionValueAttribute_range, TFunctionValueAttribute_interpolate { public: @@ -303,25 +304,44 @@ private: /* 0x58 */ update_INTERPOLATE pfnUpdate_; }; -class TFunctionValue_list_parameter : TFunctionValue, +class TFunctionValue_list_parameter : public TFunctionValue, TFunctionValueAttribute_range, TFunctionValueAttribute_interpolate { public: struct TIterator_data_ { TIterator_data_(const f32* value) : value_(value) {} - TIterator_data_(const TIterator_data_& other) : value_(other.value_) {} - - void operator=(const TIterator_data_& rhs) { value_ = rhs.value_; } TIterator_data_& operator--() { value_ -= 2; return *this; } + TIterator_data_& operator-=(s32 n) { + value_ -= n * 2; + return *this; + } + s32 operator-(const TIterator_data_& other) { + return (u32)(value_ - other.value_) >> 1; + } + TIterator_data_& operator++() { + value_ += 2; + return *this; + } + TIterator_data_& operator+=(s32 n) { + value_ += n * 2; + return *this; + } friend bool operator==(const TIterator_data_& lhs, const TIterator_data_& rhs) { return lhs.value_ == rhs.value_; } + f32 operator*() { return *value_; } const f32* get() const { return value_; } void set(const f32* value) { value_ = value; } const f32* value_; + + typedef s32 difference_type; + typedef f32 value_type; + typedef const f32* pointer; + typedef const f32& reference; + typedef std::random_access_iterator_tag iterator_category; }; typedef f64 (*update_INTERPOLATE)(const TFunctionValue_list_parameter&, f64); @@ -358,7 +378,7 @@ private: /* 0x58 */ update_INTERPOLATE pfnUpdate_; }; -class TFunctionValue_hermite : TFunctionValue, TFunctionValueAttribute_range { +class TFunctionValue_hermite : public TFunctionValue, TFunctionValueAttribute_range { public: struct TIterator_data_ { TIterator_data_(const TFunctionValue_hermite& rParent, const f32* value) { @@ -374,14 +394,36 @@ public: } friend bool operator==(const TIterator_data_& lhs, const TIterator_data_& rhs) { return lhs.value_ == rhs.value_; } + f32 operator*() { return *value_; } TIterator_data_& operator--() { value_ -= size_; return *this; } + TIterator_data_& operator-=(s32 n) { + value_ -= size_ * n; + return *this; + } + s32 operator-(const TIterator_data_& other) { + return (value_ - other.value_) / size_; + } + TIterator_data_& operator++() { + value_ += size_; + return *this; + } + TIterator_data_& operator+=(s32 n) { + value_ += size_ * n; + return *this; + } /* 0x00 */ const f32* value_; /* 0x04 */ u32 size_; + + typedef s32 difference_type; + typedef f32 value_type; + typedef const f32* pointer; + typedef const f32& reference; + typedef std::random_access_iterator_tag iterator_category; }; /* 802832C4 */ TFunctionValue_hermite(); diff --git a/include/JSystem/JStudio/JStudio/fvb-data-parse.h b/include/JSystem/JStudio/JStudio/fvb-data-parse.h index 16b3627827..776d86c321 100644 --- a/include/JSystem/JStudio/JStudio/fvb-data-parse.h +++ b/include/JSystem/JStudio/JStudio/fvb-data-parse.h @@ -36,10 +36,10 @@ public: class TParse_TParagraph : public TParseData_aligned<4> { public: struct TData { - /* 0x04 */ u32 u32Size; - /* 0x08 */ u32 u32Type; - /* 0x0C */ const void* pContent; - /* 0x10 */ const void* next; + /* 0x00 */ u32 u32Size; + /* 0x04 */ u32 u32Type; + /* 0x08 */ const void* pContent; + /* 0x0C */ const void* next; }; TParse_TParagraph(const void* content) : TParseData_aligned<4>(content) {} diff --git a/include/JSystem/JStudio/JStudio/fvb-data.h b/include/JSystem/JStudio/JStudio/fvb-data.h index 6469a31645..cacc41cafd 100644 --- a/include/JSystem/JStudio/JStudio/fvb-data.h +++ b/include/JSystem/JStudio/JStudio/fvb-data.h @@ -26,7 +26,10 @@ typedef enum TEComposite { /* 0x8 */ COMPOSITE_ENUM_SIZE, }; -typedef const void* (*CompositeOperation)(TFunctionValue_composite::TData); +struct CompositeOperation { + TFunctionValue_composite::CompositeFunc composite; + TFunctionValue_composite::TData (*getCompositeData)(const void*); +}; struct TBlock { /* 0x0 */ u32 size; diff --git a/include/JSystem/JStudio/JStudio/fvb.h b/include/JSystem/JStudio/JStudio/fvb.h index 8da397eb49..5ccf0d0f1c 100644 --- a/include/JSystem/JStudio/JStudio/fvb.h +++ b/include/JSystem/JStudio/JStudio/fvb.h @@ -72,7 +72,7 @@ public: private: /* 0x4 */ TFactory* pFactory; - /* 0x8 */ JGadget::TLinkList<TObject, 12> ocObject_; + /* 0x8 */ JGadget::TLinkList<TObject, -12> ocObject_; }; // Size: 0x14 class TObject_composite : public TObject { diff --git a/include/JSystem/JStudio/JStudio/jstudio-math.h b/include/JSystem/JStudio/JStudio/jstudio-math.h index c02f19f37d..0e061b6ab8 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-math.h +++ b/include/JSystem/JStudio/JStudio/jstudio-math.h @@ -44,16 +44,16 @@ namespace math { return VECMag(&local_18); } - inline void getFromTransformation_S(CMtxP param_1, Vec* param_2) { - param_2->x = getFromTransformation_Sn(param_1, 0); - param_2->y = getFromTransformation_Sn(param_1, 1); - param_2->z = getFromTransformation_Sn(param_1, 2); + inline void getFromTransformation_S(Vec* param_1, CMtxP param_2) { + param_1->x = getFromTransformation_Sn(param_2, 0); + param_1->y = getFromTransformation_Sn(param_2, 1); + param_1->z = getFromTransformation_Sn(param_2, 2); } - inline void getFromTransformation_T(CMtxP param_1, Vec* param_2) { - param_2->x = param_1[0][3]; - param_2->y = param_1[1][3]; - param_2->z = param_1[2][3]; + inline void getFromTransformation_T(Vec* param_1, CMtxP param_2) { + param_1->x = param_2[0][3]; + param_1->y = param_2[1][3]; + param_1->z = param_2[2][3]; } inline void getTransformation_T(Mtx mtx, const Vec* param_2) { diff --git a/include/JSystem/JStudio/JStudio/jstudio-object.h b/include/JSystem/JStudio/JStudio/jstudio-object.h index 1c87b6ba03..1eb93d5abb 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-object.h +++ b/include/JSystem/JStudio/JStudio/jstudio-object.h @@ -2,6 +2,7 @@ #define JSTUDIO_OBJECT_H #include "JSystem/JStudio/JStudio/jstudio-control.h" +#include "global.h" #include "limits.h" #include "math.h" @@ -27,7 +28,7 @@ struct TVariableValue { /* 80285E0C */ virtual ~TOutput() = 0; }; - struct TOutput_none_ { + struct TOutput_none_ : TOutput { /* 80285F6C */ ~TOutput_none_(); /* 80285FCC */ void operator()(f32, JStudio::TAdaptor*) const; }; @@ -36,7 +37,7 @@ struct TVariableValue { /* 80285EB8 */ static void update_immediate_(JStudio::TVariableValue*, f64); /* 80285ECC */ static void update_time_(JStudio::TVariableValue*, f64); /* 80285F08 */ static void update_functionValue_(JStudio::TVariableValue*, f64); - /* 8028B568 */ TVariableValue() : field_0x4(0), field_0x8(NULL), pOutput_((TOutput*)soOutput_none_) {} + /* 8028B568 */ TVariableValue() : field_0x4(0), field_0x8(NULL), pOutput_(&soOutput_none_) {} void setValue_immediate(f32 value) { field_0x8 = &update_immediate_; @@ -83,10 +84,10 @@ struct TVariableValue { } void setOutput(const TOutput* param_1) { - pOutput_ = (param_1 != NULL) ? param_1 : (TOutput*)soOutput_none_; + pOutput_ = (param_1 != NULL) ? param_1 : &soOutput_none_; } - static u8 soOutput_none_[4 + 4 /* padding */]; + static TOutput_none_ soOutput_none_; /* 0x00 */ f32 mValue; /* 0x04 */ u32 field_0x4; diff --git a/include/JSystem/JStudio/JStudio/object-id.h b/include/JSystem/JStudio/JStudio/object-id.h index fbcfb0e414..4b0113f0b2 100644 --- a/include/JSystem/JStudio/JStudio/object-id.h +++ b/include/JSystem/JStudio/JStudio/object-id.h @@ -15,17 +15,20 @@ public: inline const u8* getID() const { return (const u8*)mID; } inline u32 getIDSize() const { return mID_size; } -private: +protected: /* 0x00 */ const void* mID; /* 0x04 */ u32 mID_size; }; -struct TPRObject_ID_equal : public TIDData { - TPRObject_ID_equal(const void* id, u32 id_size) : TIDData(id, id_size) {} -}; - struct TObject_ID : public TIDData { TObject_ID(const void* id, u32 id_size) : TIDData(id, id_size) {} + TIDData const& getIDData() const { return *this; } +}; + +struct TPRObject_ID_equal : public TIDData { + TPRObject_ID_equal(const void* id, u32 id_size) : TIDData(id, id_size) {} + TPRObject_ID_equal(const TPRObject_ID_equal& other) : TIDData(other.mID, other.mID_size) {} + bool operator()(TObject_ID const& id) const { return TIDData::isEqual(id.getIDData(), *this); } }; } // namespace object diff --git a/include/JSystem/JStudio/JStudio/stb.h b/include/JSystem/JStudio/JStudio/stb.h index d1846bdb49..6582961688 100644 --- a/include/JSystem/JStudio/JStudio/stb.h +++ b/include/JSystem/JStudio/JStudio/stb.h @@ -44,7 +44,7 @@ public: /* 80288B78 */ void setFlag_operation(u8, int); /* 80288BD0 */ void reset(void const*); - /* 80288BE8 */ u8 forward(u32); + /* 80288BE8 */ bool forward(u32); /* 80288E18 */ virtual void do_begin(); /* 80288E1C */ virtual void do_end(); /* 80288E20 */ virtual void do_paragraph(u32, void const*, u32); @@ -133,7 +133,7 @@ public: /* 80289300 */ void destroyObject_all(); /* 80289364 */ TObject* getObject(void const*, u32); /* 80289404 */ void reset(); - /* 802894B4 */ u8 forward(u32); + /* 802894B4 */ bool forward(u32); void setStatus_(u32 status) { mStatus = status; } void resetStatus_() { setStatus_(0); } diff --git a/include/JSystem/JStudio/JStudio_JStage/control.h b/include/JSystem/JStudio/JStudio_JStage/control.h index 04da734dbb..c595055640 100644 --- a/include/JSystem/JStudio/JStudio_JStage/control.h +++ b/include/JSystem/JStudio/JStudio_JStage/control.h @@ -1,6 +1,7 @@ #ifndef JSTUDIO_JSTAGE_CONTROL_H #define JSTUDIO_JSTAGE_CONTROL_H +#include "JSystem/JGadget/pointer.h" #include "JSystem/JStage/JSGActor.h" #include "JSystem/JStage/JSGAmbientLight.h" #include "JSystem/JStage/JSGCamera.h" @@ -51,6 +52,10 @@ struct TAdaptor_actor : public JStudio::TAdaptor_actor, public JStudio_JStage::T typedef f32 (JStage::TActor::*Getter)() const; typedef f32 (JStage::TActor::*MaxGetter)() const; + enum TEVariableValue { + TEACTOR_1 = 1, + }; + struct TVVOutput_ANIMATION_FRAME_ : public JStudio::TVariableValue::TOutput { @@ -300,7 +305,7 @@ inline bool transform_toGlobalFromLocal(JStudio::TControl::TTransform_position* if (!transform_toGlobalFromLocal(afStack_38, param_2, param_3, param_4)) { return false; } - JStudio::math::getFromTransformation_T(afStack_38, param_1); + JStudio::math::getFromTransformation_T(param_1, afStack_38); return true; } /* 8028A328 */ bool @@ -310,6 +315,28 @@ inline bool transform_toGlobalFromLocal(JStudio::TControl::TTransform_position* /* 8028A3CC */ bool transform_toLocalFromGlobal(f32 (*)[4], JStudio::TControl::TTransform_position const&, JStage::TObject const*, u32); + +namespace { + +template <class AdaptorT, class ObjectT> +JStudio::TObject* createObject_JSG_(const JStudio::stb::data::TParse_TBlock_object& param_1, + JStage::TObject* param_2, const JStage::TSystem* param_3) { + ObjectT* objt = (ObjectT*)param_2; + AdaptorT* pAdaptor = new AdaptorT(param_3, objt); + if (pAdaptor == NULL) { + return NULL; + } + JGadget::TPointer_delete<AdaptorT> adaptorGuard(pAdaptor); + JStudio::TObject* pObj = JStudio::TCreateObject::createFromAdaptor<AdaptorT>(param_1, pAdaptor); + if (pObj == NULL) { + return NULL; + } + adaptorGuard.set(NULL); + return pObj; +} + +} // namespace + }; // namespace JStudio_JStage #endif /* JSTUDIO_JSTAGE_CONTROL_H */ diff --git a/include/JSystem/JUtility/JUTTexture.h b/include/JSystem/JUtility/JUTTexture.h index 47d5638cd6..606cd5811c 100644 --- a/include/JSystem/JUtility/JUTTexture.h +++ b/include/JSystem/JUtility/JUTTexture.h @@ -68,7 +68,7 @@ public: void load(_GXTexMapID); const ResTIMG* getTexInfo() const { return mTexInfo; } - u8 getFormat() const { return mTexInfo->format; } + s32 getFormat() const { return mTexInfo->format; } s32 getTransparency() { return mTexInfo->alphaEnabled; } s32 getWidth() const { return mTexInfo->width; } s32 getHeight() const { return mTexInfo->height; } diff --git a/include/JSystem/TPosition3.hh b/include/JSystem/TPosition3.h index fdf4457e00..807ce4fea5 100644 --- a/include/JSystem/TPosition3.hh +++ b/include/JSystem/TPosition3.h @@ -35,7 +35,7 @@ struct SMatrix33C { return data[i][j]; } - inline T at(int i, int j) { + inline T at(int i, int j) const { return data[i][j]; } @@ -51,30 +51,32 @@ struct SMatrix33C { ref(2,1) = param_8; ref(2,2) = param_9; } +}; + +template <typename T> +struct TMatrix34 : public T {}; + +template <typename T> +struct TRotation3 : public T {}; - inline void getEulerXYZ(TVec3<T>* param_1) { - if (at(2, 0) - TUtil<T>::one() >= TUtil<T>::epsilon()) { - param_1->set(TUtil<T>::atan2(at(0,1), at(1,1)), -TUtil<T>::halfPI(), 0.0); +template<typename T> +struct TRotation3<SMatrix33C<T> > : public SMatrix33C<T> { + inline void getEulerXYZ(TVec3<T>* param_1) const { + if (at(2, 0) - TUtil<T>::one() >= -TUtil<T>::epsilon()) { + param_1->set(TUtil<T>::atan2(-at(0, 1), at(1, 1)), -TUtil<T>::halfPI(), 0.0); } else { - if (at(2, 0) - TUtil<T>::one() >= TUtil<T>::one() + TUtil<T>::epsilon()) { - param_1->set(TUtil<T>::atan2(at(0, 1), at(1, 1)), TUtil<T>::halfPI(), - 0.0); + if (at(2, 0) + TUtil<T>::one() <= TUtil<T>::epsilon()) { + param_1->set(TUtil<T>::atan2(at(0, 1), at(1, 1)), TUtil<T>::halfPI(), 0.0); } else { param_1->x = TUtil<T>::atan2(at(2, 1), at(2, 2)); - param_1->z = TUtil<T>::atan2(at(0, 1), at(0, 0)); - param_1->y = TUtil<T>::asin(at(2, 0)); + param_1->z = TUtil<T>::atan2(at(1, 0), at(0, 0)); + param_1->y = TUtil<T>::asin(-at(2, 0)); } } } }; template <typename T> -struct TMatrix34 : public T {}; - -template <typename T> -struct TRotation3 : public T {}; - -template <typename T> struct TPosition3 : public T {}; typedef TPosition3<TRotation3<TMatrix34<SMatrix34C<f32> > > > TPosition3f32; diff --git a/include/Z2AudioLib/Z2Audience.h b/include/Z2AudioLib/Z2Audience.h index e01b6d4b0f..ca8099c495 100644 --- a/include/Z2AudioLib/Z2Audience.h +++ b/include/Z2AudioLib/Z2Audience.h @@ -7,7 +7,7 @@ #include "JSystem/JAudio2/JASSoundParams.h" #include "JSystem/JAudio2/JASHeapCtrl.h" #include "JSystem/JAudio2/JAUAudibleParam.h" -#include "JSystem/TPosition3.hh" +#include "JSystem/TPosition3.h" struct Z2Audible; |
