diff --git a/asm/rel/d/a/d_a_movie_player/d_a_movie_player/daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj.s b/asm/rel/d/a/d_a_movie_player/d_a_movie_player/daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj.s index fd342b22f70..9e69aedd9f7 100644 --- a/asm/rel/d/a/d_a_movie_player/d_a_movie_player/daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj.s +++ b/asm/rel/d/a/d_a_movie_player/d_a_movie_player/daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj.s @@ -112,12 +112,12 @@ lbl_8087667C: /* 80876834 38 80 00 01 */ li r4, 1 /* 80876838 38 A0 00 04 */ li r5, 4 /* 8087683C 38 C0 00 3C */ li r6, 0x3c -/* 80876840 48 00 03 69 */ bl GXSetTexCoordGen +/* 80876840 48 00 03 69 */ bl i_GXSetTexCoordGen /* 80876844 38 60 00 01 */ li r3, 1 /* 80876848 38 80 00 01 */ li r4, 1 /* 8087684C 38 A0 00 04 */ li r5, 4 /* 80876850 38 C0 00 3C */ li r6, 0x3c -/* 80876854 48 00 03 55 */ bl GXSetTexCoordGen +/* 80876854 48 00 03 55 */ bl i_GXSetTexCoordGen /* 80876858 4B AE 7E 0D */ bl GXInvalidateTexAll /* 8087685C 4B AE 4D 31 */ bl GXClearVtxDesc /* 80876860 38 60 00 09 */ li r3, 9 diff --git a/include/JSystem/J2DGraph/J2DPicture.h b/include/JSystem/J2DGraph/J2DPicture.h index a3fc4f4d621..b3ff43f6eee 100644 --- a/include/JSystem/J2DGraph/J2DPicture.h +++ b/include/JSystem/J2DGraph/J2DPicture.h @@ -119,7 +119,7 @@ public: protected: /* 0x100 */ JUTTexture* mTexture[2]; - /* 0x108 */ u8 mTextureCount; + /* 0x108 */ u8 mTextureNum; /* 0x109 */ u8 field_0x109; /* 0x10A */ JGeometry::TVec2 field_0x10a[4]; /* 0x11C */ f32 field_0x11c[2]; @@ -128,8 +128,8 @@ protected: /* 0x130 */ JUtility::TColor mWhite; /* 0x134 */ JUtility::TColor mBlack; /* 0x138 */ JUtility::TColor mCornerColor[4]; - /* 0x148 */ JUtility::TColor field_0x148; - /* 0x14C */ JUtility::TColor field_0x14c; + /* 0x148 */ JUtility::TColor mBlendKonstColor; + /* 0x14C */ JUtility::TColor mBlendKonstAlpha; }; #endif /* J2DPICTURE_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/include/JSystem/J3DGraphAnimator/J3DAnimation.h index 81afd9898f4..a35eed551d0 100644 --- a/include/JSystem/J3DGraphAnimator/J3DAnimation.h +++ b/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -64,7 +64,7 @@ struct J3DAnmTransformFullTable { struct J3DAnmTexPatternFullTable { /* 0x00 */ u16 mMaxFrame; /* 0x02 */ u16 mOffset; - /* 0x04 */ u8 _4; + /* 0x04 */ u8 mTexNo; /* 0x06 */ u16 _6; }; // Size = 0x8 @@ -421,13 +421,18 @@ public: /* 8032BD20 */ virtual ~J3DAnmTexPattern(); /* 8032BD94 */ virtual s32 getKind() const; + u16 getUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx]; } + u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; } + bool isValidUpdateMaterialID(u16 id) const { return mUpdateMaterialID[id] != 0xFFFF; } + J3DAnmTexPatternFullTable* getAnmTable() { return mAnmTable; } + private: /* 0x0C */ void* field_0xc; - /* 0x10 */ void* mAnmTable; + /* 0x10 */ J3DAnmTexPatternFullTable* mAnmTable; /* 0x14 */ u16 field_0x14; /* 0x16 */ u16 mUpdateMaterialNum; - /* 0x18 */ u16* field_0x18; - /* 0x1C */ JUTNameTab field_0x1c; + /* 0x18 */ u16* mUpdateMaterialID; + /* 0x1C */ JUTNameTab mUpdateMaterialName; }; // Size: 0x2C class J3DAnmTevRegKey : public J3DAnmBase { diff --git a/include/JSystem/J3DGraphAnimator/J3DCluster.h b/include/JSystem/J3DGraphAnimator/J3DCluster.h index 511c17eed2b..4db7189f2da 100644 --- a/include/JSystem/J3DGraphAnimator/J3DCluster.h +++ b/include/JSystem/J3DGraphAnimator/J3DCluster.h @@ -4,21 +4,59 @@ #include "dolphin/types.h" class J3DDeformer; +class J3DClusterKey; +class J3DClusterVertex; +class J3DVertexBuffer; +class J3DModel; +class J3DAnmCluster; +class JUTNameTab; -struct J3DCluster { - /* 0x00 */ f32 field_0x0; - /* 0x04 */ f32 field_0x4; - /* 0x08 */ int field_0x8; - /* 0x0C */ int field_0xc; - /* 0x10 */ u16 field_0x10; - /* 0x12 */ u16 field_0x12; +class J3DCluster { +public: + J3DDeformer* getDeformer() { return mDeformer; } + void setDeformer(J3DDeformer* deformer) { mDeformer = deformer; } + + /* 0x00 */ f32 mMaxAngle; + /* 0x04 */ f32 mMinAngle; + /* 0x08 */ J3DClusterKey* mClusterKey; + /* 0x0C */ u8 mFlags; + /* 0x0E */ u8 field_0xe[0x10 - 0xD]; + /* 0x10 */ u16 mKeyNum; + /* 0x12 */ u16 mPosNum; /* 0x14 */ u16 field_0x14; /* 0x16 */ u16 field_0x16; - /* 0x18 */ u16 field_0x18[2]; - /* 0x1C */ int field_0x1c; + /* 0x18 */ u16* field_0x18; + /* 0x1C */ J3DClusterVertex* mClusterVertex; /* 0x20 */ J3DDeformer* mDeformer; }; struct J3DClusterKey {}; +class J3DDeformData { +public: + /* 8032E1F8 */ J3DDeformData(); + /* 8032E230 */ void offAllFlag(u32); + /* 8032E298 */ void deform(J3DVertexBuffer*); + /* 8032E274 */ void deform(J3DModel*); + /* 8032E364 */ void setAnm(J3DAnmCluster*); + + J3DCluster* getClusterPointer(u16 index) { + return &mClusterPointer[index]; + } + +private: + /* 0x00 */ u16 mClusterNum; + /* 0x02 */ u16 mClusterKeyNum; + /* 0x04 */ u16 mClusterVertexNum; + /* 0x08 */ J3DCluster* mClusterPointer; + /* 0x0C */ J3DClusterKey* mClusterKeyPointer; + /* 0x10 */ J3DClusterVertex* mClusterVertex; + /* 0x14 */ u16 mVtxPosNum; + /* 0x16 */ u16 mVtxNrmNum; + /* 0x18 */ f32* mVtxPos; + /* 0x1C */ f32* mVtxNrm; + /* 0x20 */ JUTNameTab* mClusterName; + /* 0x24 */ JUTNameTab* mClusterKeyName; +}; // Size: 0x28 + #endif /* J3DCLUSTER_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h index 1844f2f15e0..ac68a974897 100644 --- a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h +++ b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h @@ -8,29 +8,8 @@ class J3DModel; class J3DAnmCluster; - -class J3DDeformData { -public: - /* 8032E1F8 */ J3DDeformData(); - /* 8032E230 */ void offAllFlag(u32); - /* 8032E298 */ void deform(J3DVertexBuffer*); - /* 8032E274 */ void deform(J3DModel*); - /* 8032E364 */ void setAnm(J3DAnmCluster*); - -private: - /* 0x00 */ u16 mClusterNum; - /* 0x02 */ u16 mClusterKeyNum; - /* 0x04 */ u16 field_0x4; - /* 0x08 */ J3DCluster** mClusterPointer; - /* 0x0C */ J3DClusterKey** mClusterKeyPointer; - /* 0x10 */ int field_0x10; - /* 0x14 */ u16 field_0x14; - /* 0x16 */ u16 field_0x16; - /* 0x18 */ void* mVtxPos; - /* 0x1C */ void* mVtxNrm; - /* 0x20 */ int field_0x20; - /* 0x24 */ int field_0x24; -}; // Size: 0x28 +class J3DClusterVertex; +class JUTNameTab; struct J3DSkinNList { /* 8032C6E4 */ J3DSkinNList(); @@ -98,11 +77,14 @@ public: /* 8032E60C */ void deform_VtxNrmF32(J3DVertexBuffer*, J3DCluster*, J3DClusterKey*, f32*); /* 8032EBCC */ void normalizeWeight(int, f32*); + void offFlag(u32 i_flag) { mFlags &= ~i_flag; } + void setAnmCluster(J3DAnmCluster* anm) { mAnmCluster = anm; } + private: /* 0x00 */ J3DDeformData* mDeformData; /* 0x04 */ J3DAnmCluster* mAnmCluster; - /* 0x08 */ int field_0x8; - /* 0x0C */ int field_0xc; + /* 0x08 */ f32* field_0x8; + /* 0x0C */ f32* field_0xc; /* 0x10 */ u32 mFlags; }; // Size: 0x14 diff --git a/include/JSystem/J3DGraphBase/J3DVertex.h b/include/JSystem/J3DGraphBase/J3DVertex.h index 1f0c7c421bc..4e5129a3bf4 100644 --- a/include/JSystem/J3DGraphBase/J3DVertex.h +++ b/include/JSystem/J3DGraphBase/J3DVertex.h @@ -105,6 +105,26 @@ public: mTransformedVtxNrmArray[1] = tmp; } + void swapVtxPosArrayPointer() { + void* temp = mVtxPosArray[0]; + mVtxPosArray[0] = mVtxPosArray[1]; + mVtxPosArray[1] = temp; + } + + void swapVtxNrmArrayPointer() { + void* temp = mVtxNrmArray[0]; + mVtxNrmArray[0] = mVtxNrmArray[1]; + mVtxNrmArray[1] = temp; + } + + void* getVtxPosArrayPointer(int index) { + return mVtxPosArray[index]; + } + + void* getVtxNrmArrayPointer(int index) { + return mVtxNrmArray[index]; + } + private: /* 0x00 */ J3DVertexData* mVtxData; /* 0x04 */ void* mVtxPosArray[2]; diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index 848a79e1a55..325d4f7432b 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -296,8 +296,11 @@ struct TVec3 { template struct TVec2 { TVec2() {} + TVec2(T v) { set(v); } TVec2(T x, T y) { set(x, y); } + void set(T v) { y = x = v; } + void set(T x, T y) { this->x = x; this->y = y; diff --git a/include/JSystem/JUtility/TColor.h b/include/JSystem/JUtility/TColor.h index 6550a48c0af..fd11ee8a7b6 100644 --- a/include/JSystem/JUtility/TColor.h +++ b/include/JSystem/JUtility/TColor.h @@ -11,10 +11,6 @@ struct TColor : public GXColor { TColor(GXColor color) { set(color); } // TColor(const TColor& other) { set(other.toUInt32()); } - TColor& operator=(const TColor& other) { - ((GXColor*)this)->operator=(other); - return *this; - } operator u32() const { return toUInt32(); } u32 toUInt32() const { return *(u32*)&r; } diff --git a/include/dolphin/gx/GXAttr.h b/include/dolphin/gx/GXAttr.h index d820e969798..667c7f33db8 100644 --- a/include/dolphin/gx/GXAttr.h +++ b/include/dolphin/gx/GXAttr.h @@ -38,6 +38,10 @@ void GXGetVtxAttrFmt(GXVtxFmt param_0, int param_1, GXCompCnt* param_2, GXCompTy u8* param_4); void GXGetVtxDescv(GXVtxDescList* attrPtr); +static inline void GXSetTexCoordGen(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 mtx) { + GXSetTexCoordGen2(dst, type, src, mtx, GX_FALSE, GX_PTIDENTITY); +} + #ifdef __cplusplus }; #endif diff --git a/libs/JSystem/J2DGraph/J2DGrafContext.cpp b/libs/JSystem/J2DGraph/J2DGrafContext.cpp index 06c6572062d..c90dc8fa939 100644 --- a/libs/JSystem/J2DGraph/J2DGrafContext.cpp +++ b/libs/JSystem/J2DGraph/J2DGrafContext.cpp @@ -25,10 +25,6 @@ void J2DGrafContext::setPort() { GXSetViewport(bounds.i.x, bounds.i.y, bounds.getWidth(), bounds.getHeight(), 0.0f, 1.0f); } -static inline void GXSetTexCoordGen(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 mtx) { - GXSetTexCoordGen2(dst, type, src, mtx, GX_FALSE, GX_PTIDENTITY); -} - /* 802E8C44-802E8E20 2E3584 01DC+00 1/0 1/0 0/0 .text setup2D__14J2DGrafContextFv */ void J2DGrafContext::setup2D() { GXSetNumIndStages(0); diff --git a/libs/JSystem/J2DGraph/J2DMatBlock.cpp b/libs/JSystem/J2DGraph/J2DMatBlock.cpp index a7224a9ab1f..31528716172 100644 --- a/libs/JSystem/J2DGraph/J2DMatBlock.cpp +++ b/libs/JSystem/J2DGraph/J2DMatBlock.cpp @@ -406,10 +406,6 @@ void J2DTexGenBlock::initialize() { } } -static inline void GXSetTexCoordGen(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 mtx) { - GXSetTexCoordGen2(dst, type, src, mtx, GX_FALSE, GX_PTIDENTITY); -} - /* 802EB570-802EB620 2E5EB0 00B0+00 0/0 1/1 0/0 .text setGX__14J2DTexGenBlockFv */ void J2DTexGenBlock::setGX() { GXSetNumTexGens(mTexGenNum); diff --git a/libs/JSystem/J2DGraph/J2DMaterial.cpp b/libs/JSystem/J2DGraph/J2DMaterial.cpp index 65acc3a261d..6c0ff561680 100644 --- a/libs/JSystem/J2DGraph/J2DMaterial.cpp +++ b/libs/JSystem/J2DGraph/J2DMaterial.cpp @@ -342,7 +342,7 @@ void J2DMaterial::setAnimation(J2DAnmTexPattern* anm) { u16 matID = anm->getUpdateMaterialID(i); if (index == matID) { - mAnmPointer->field_0x22[anmTbl[i]._4] = i; + mAnmPointer->field_0x22[anmTbl[i].mTexNo] = i; } } } diff --git a/libs/JSystem/J2DGraph/J2DPicture.cpp b/libs/JSystem/J2DGraph/J2DPicture.cpp index 171775c74ad..4d71f60c503 100644 --- a/libs/JSystem/J2DGraph/J2DPicture.cpp +++ b/libs/JSystem/J2DGraph/J2DPicture.cpp @@ -4,7 +4,11 @@ // #include "JSystem/J2DGraph/J2DPicture.h" +#include "JSystem/J2DGraph/J2DMaterial.h" #include "JSystem/J2DGraph/J2DScreen.h" +#include "JSystem/JSupport/JSURandomInputStream.h" +#include "JSystem/JUtility/JUTPalette.h" +#include "JSystem/JUtility/JUTResource.h" #include "JSystem/JUtility/JUTTexture.h" #include "dol2asm.h" #include "dolphin/gx.h" @@ -251,16 +255,15 @@ SECTION_DATA extern void* __vt__10J2DPicture[83 + 1 /* padding */] = { }; /* 802FC050-802FC118 2F6990 00C8+00 0/0 2/2 0/0 .text __ct__10J2DPictureFv */ +// matches with weak functions setup (TVec2 ctor needs to be later) #ifdef NONMATCHING -J2DPicture::J2DPicture() - : field_0x10a(), mPalette(NULL), mWhite(), mBlack(), mCornerColor(), field_0x148(), - field_0x14c() { +J2DPicture::J2DPicture() : mPalette(NULL) { for (int i = 0; i < 2; i++) { mTexture[i] = NULL; } field_0x109 = 0; - mTextureCount = 0; + mTextureNum = 0; initinfo(); } #else @@ -276,10 +279,10 @@ asm J2DPicture::J2DPicture() { /* 802FC118-802FC1D4 2F6A58 00BC+00 0/0 1/1 0/0 .text * __ct__10J2DPictureFP7J2DPaneP20JSURandomInputStreamP10JKRArchive */ +// matches with weak functions setup (TVec2 ctor needs to be later) #ifdef NONMATCHING J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, JKRArchive* p_archive) - : field_0x10a(), mPalette(NULL), mWhite(), mBlack(), mCornerColor(), field_0x148(), - field_0x14c() { + : mPalette(NULL) { private_readStream(p_pane, p_stream, p_archive); } #else @@ -299,10 +302,10 @@ SECTION_SDATA2 static f64 lit_1739 = 4503599627370496.0 /* cast u32 to float */; /* 802FC1D4-802FC708 2F6B14 0534+00 0/0 1/1 0/0 .text * __ct__10J2DPictureFP7J2DPaneP20JSURandomInputStreamP11J2DMaterial */ +// matches with literals and weak functions setup (TVec2 ctor needs to be later) #ifdef NONMATCHING J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, J2DMaterial* p_material) - : field_0x10a(), mPalette(NULL), mWhite(), mBlack(), mCornerColor(), field_0x148(), - field_0x14c() { + : mPalette(NULL) { int position = p_stream->getPosition(); J2DPicHeader header; @@ -313,7 +316,7 @@ J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, J2DMater J2DPaneHeader panHeader; p_stream->peek(&panHeader, sizeof(panHeader)); - p_pane->makePaneExStream(p_pane, p_stream); + makePaneExStream(p_pane, p_stream); p_stream->seek(position2 + panHeader.mSize, JSUStreamSeekFrom_SET); J2DScrnBlockPictureParameter picInfo; @@ -339,13 +342,14 @@ J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, J2DMater mBlack = JUtility::TColor(0); mWhite = JUtility::TColor(0xFFFFFFFF); - mTextureCount = 0; + mTextureNum = 0; if (material != NULL && material->getTevBlock() != NULL) { u8 texgenNum = material->getTexGenBlock()->getTexGenNum(); u32 stageNum = material->getTevBlock()->getTevStageNum(); - if ((texgenNum == 1 && stageNum != 1) || (texgenNum != 1 && (int)stageNum != texgenNum + 1)) { + if ((texgenNum == 1 && stageNum != 1) || (texgenNum != 1 && (int)stageNum != texgenNum + 1)) + { J2DGXColorS10* color0p = material->getTevBlock()->getTevColor(0); GXColorS10 color0; color0.r = color0p->r; @@ -361,15 +365,12 @@ J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, J2DMater color1.a = color1p->a; mBlack = JUtility::TColor(((u8)color0.r << 0x18) | ((u8)color0.g << 0x10) | - ((u8)color0.b << 8) | (u8)color0.a); + ((u8)color0.b << 8) | (u8)color0.a); mWhite = JUtility::TColor(((u8)color1.r << 0x18) | ((u8)color1.g << 0x10) | - ((u8)color1.b << 8) | (u8)color1.a); + ((u8)color1.b << 8) | (u8)color1.a); } - if (texgenNum <= 2) { - texgenNum = 2; - } - mTextureCount = texgenNum; + mTextureNum = texgenNum <= 2 ? texgenNum : 2; } field_0x109 = 0; @@ -419,16 +420,15 @@ asm J2DPicture::J2DPicture(J2DPane* param_0, JSURandomInputStream* param_1, J2DM SECTION_SDATA2 static f32 lit_1767 = 1.0f; /* 802FC708-802FC800 2F7048 00F8+00 0/0 20/20 1/1 .text __ct__10J2DPictureFPC7ResTIMG */ +// matches with literals and weak functions setup (TVec2 ctor needs to be later) #ifdef NONMATCHING -J2DPicture::J2DPicture(ResTIMG const* p_timg) - : field_0x10a(), mWhite(), mBlack(), mCornerColor(), field_0x148(), - field_0x14c() { +J2DPicture::J2DPicture(ResTIMG const* p_timg) { for (int i = 0; i < 2; i++) { mTexture[i] = NULL; } field_0x109 = 0; - mTextureCount = 0; + mTextureNum = 0; if (p_timg != NULL) { append(p_timg, 1.0f); @@ -449,17 +449,17 @@ asm J2DPicture::J2DPicture(ResTIMG const* param_0) { /* 802FC800-802FC8E8 2F7140 00E8+00 0/0 5/5 0/0 .text * __ct__10J2DPictureFUxRCQ29JGeometry8TBox2PC7ResTIMGPC7ResTLUT */ +// matches with weak functions setup (TVec2 ctor needs to be later) #ifdef NONMATCHING -J2DPicture::J2DPicture(u64 tag, JGeometry::TBox2 const& bounds, - ResTIMG const* p_timg, ResTLUT const* p_tlut) - : J2DPane(tag, bounds), field_0x10a(), mPalette(NULL), mWhite(), mBlack(), mCornerColor(), field_0x148(), - field_0x14c() { +J2DPicture::J2DPicture(u64 tag, JGeometry::TBox2 const& bounds, ResTIMG const* p_timg, + ResTLUT const* p_tlut) + : J2DPane(tag, bounds), mPalette(NULL) { for (int i = 0; i < 2; i++) { mTexture[i] = NULL; } field_0x109 = 0; - mTextureCount = 0; + mTextureNum = 0; private_initiate(p_timg, p_tlut); initinfo(); @@ -478,6 +478,82 @@ asm J2DPicture::J2DPicture(u64 param_0, JGeometry::TBox2 const& param_1, /* 802FC8E8-802FCCDC 2F7228 03F4+00 1/1 0/0 0/0 .text * private_readStream__10J2DPictureFP7J2DPaneP20JSURandomInputStreamP10JKRArchive */ +// matches with literals +#ifdef NONMATCHING +void J2DPicture::private_readStream(J2DPane* parent, JSURandomInputStream* stream, + JKRArchive* archive) { + J2DScrnBlockHeader header; + int headerPosition = stream->getPosition(); + + stream->read(&header, sizeof(J2DScrnBlockHeader)); + mKind = header.mTag; + makePaneStream(parent, stream); + + JUTResReference ref; + + ResTIMG* img; + ResTLUT* lut; + u32 var_r27 = 0; + u8 var_r26 = stream->readU8(); + + img = (ResTIMG*)getPointer(stream, 'TIMG', archive); + lut = (ResTLUT*)getPointer(stream, 'TLUT', archive); + + u8 spA = stream->read8b(); + + var_r26 -= 3; + if (var_r26 != 0) { + var_r27 = stream->read8b(); + var_r26--; + } + + if (var_r26 != 0) { + stream->read8b(); + var_r26--; + } + + mBlack = 0; + mWhite = 0xFFFFFFFF; + + if (var_r26 != 0) { + mBlack = stream->readU32(); + var_r26--; + } + + if (var_r26 != 0) { + mWhite = stream->readU32(); + var_r26--; + } + + setCornerColor(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); + for (int i = 0; var_r26 != 0 && i < 4; i++) { + mCornerColor[i] = stream->readU32(); + var_r26--; + } + + stream->seek(headerPosition + header.mSize, JSUStreamSeekFrom_SET); + + for (int i = 0; i < 2; i++) { + mTexture[i] = NULL; + } + + mTextureNum = 0; + field_0x109 = 1; + + if (img != NULL) { + mTexture[0] = new JUTTexture(img, 0); + mTextureNum++; + } + + if (lut != NULL) { + mPalette = new JUTPalette(GX_TLUT0, lut); + mTexture[0]->attachPalette(mPalette); + } + + setTexCoord(mTexture[0], (J2DBinding)spA, (J2DMirror)(var_r27 & 3), (bool)((var_r27 >> 2) & 1)); + setBlendRatio(1.0f, 1.0f); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -487,6 +563,7 @@ asm void J2DPicture::private_readStream(J2DPane* param_0, JSURandomInputStream* #include "asm/JSystem/J2DGraph/J2DPicture/private_readStream__10J2DPictureFP7J2DPaneP20JSURandomInputStreamP10JKRArchive.s" } #pragma pop +#endif /* ############################################################################################## */ /* 8045626C-80456270 00486C 0004+00 9/9 0/0 0/0 .sdata2 @2017 */ @@ -502,6 +579,17 @@ SECTION_SDATA2 static f64 lit_2021 = 4503601774854144.0 /* cast s32 to float */; /* 802FCCDC-802FCD70 2F761C 0094+00 1/0 0/0 0/0 .text initiate__10J2DPictureFPC7ResTIMGPC7ResTLUT */ +// matches with literals +#ifdef NONMATCHING +void J2DPicture::initiate(const ResTIMG* img, const ResTLUT* lut) { + private_initiate(img, lut); + if (mTexture[0] == NULL) { + return; + } + + place(JGeometry::TBox2(0.0f, 0.0f, mTexture[0]->getWidth(), mTexture[0]->getHeight())); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -510,17 +598,37 @@ asm void J2DPicture::initiate(ResTIMG const* param_0, ResTLUT const* param_1) { #include "asm/JSystem/J2DGraph/J2DPicture/initiate__10J2DPictureFPC7ResTIMGPC7ResTLUT.s" } #pragma pop +#endif /* 802FCD70-802FCE9C 2F76B0 012C+00 2/2 0/0 0/0 .text * private_initiate__10J2DPictureFPC7ResTIMGPC7ResTLUT */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DPicture::private_initiate(ResTIMG const* param_0, ResTLUT const* param_1) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/private_initiate__10J2DPictureFPC7ResTIMGPC7ResTLUT.s" +void J2DPicture::private_initiate(const ResTIMG* timg, const ResTLUT* tlut) { + if (mTextureNum != 0) { + return; + } + + if (timg != NULL) { + if (mTexture[0] == NULL) { + mTexture[0] = new JUTTexture(timg, 0); + if (mTexture[0] != NULL) { + mTextureNum++; + field_0x109 = (field_0x109 & 2) | 1; + } + } else { + mTexture[0]->storeTIMG(timg, (u8)0); + mTextureNum++; + field_0x109 = (field_0x109 & 2) | 1; + } + } + + mPalette = NULL; + if (tlut && mPalette == NULL) { + mPalette = new JUTPalette(GX_TLUT0, const_cast(tlut)); + if (mTexture[0] != NULL) { + mTexture[0]->attachPalette(mPalette); + } + } } -#pragma pop /* 802FCE9C-802FCFF0 2F77DC 0154+00 3/3 0/0 0/0 .text initinfo__10J2DPictureFv */ // matches with real literal @@ -552,6 +660,7 @@ J2DPicture::~J2DPicture() { delete mTexture[i]; } } + delete mPalette; } @@ -577,6 +686,81 @@ bool J2DPicture::prepareTexture(u8 param_0) { /* 802FD168-802FD4B4 2F7AA8 034C+00 1/0 0/0 0/0 .text * insert__10J2DPictureFPC7ResTIMGP10JUTPaletteUcf */ +// matches with literals +#ifdef NONMATCHING +bool J2DPicture::insert(ResTIMG const* img, JUTPalette* palette, u8 param_2, f32 param_3) { + if (img == NULL || mTextureNum >= 2 || param_2 >= 2 || param_2 > mTextureNum) { + return false; + } + + u8 var_r26 = 0; + if (img->indexTexture != 0 && palette == NULL) { + var_r26 = getUsableTlut(mTextureNum); + } + + JUTTexture* var_r31; + if (mTexture[mTextureNum] == NULL) { + var_r31 = new JUTTexture(img, var_r26); + + if (palette != NULL) { + var_r31->storeTIMG(img, palette); + } + + for (u8 i = 1; i > param_2; i--) { + mTexture[i] = mTexture[i - 1]; + field_0x11c[i] = field_0x11c[i - 1]; + field_0x124[i] = field_0x124[i - 1]; + } + + field_0x109 = + (field_0x109 & ((1 << param_2) - 1)) | ((field_0x109 & ~((1 << param_2) - 1)) * 2); + field_0x109 |= (1 << param_2); + } else { + var_r31 = mTexture[mTextureNum]; + if (palette == NULL) { + mTexture[mTextureNum]->storeTIMG(img, var_r26); + } else { + mTexture[mTextureNum]->storeTIMG(img, palette); + } + + u8 sp8[2]; + for (u8 i = 0; i < 2; i++) { + sp8[i] = (field_0x109 & (1 << i)) != 0; + } + + for (u8 i = mTextureNum; i > param_2; i--) { + mTexture[i] = mTexture[i - 1]; + sp8[i] = sp8[i - 1]; + field_0x11c[i] = field_0x11c[i - 1]; + field_0x124[i] = field_0x124[i - 1]; + } + + field_0x109 = 0; + + for (u8 i = 0; i < 2; i++) { + if (sp8[i] != 0) { + field_0x109 |= (1 << i); + } + } + + field_0x109 |= (1 << param_2); + } + + mTexture[param_2] = var_r31; + field_0x11c[param_2] = param_3; + field_0x124[param_2] = param_3; + + if (mTextureNum == 0 && mTexture[0] != NULL) { + place(JGeometry::TBox2(0.0f, 0.0f, mTexture[0]->getWidth(), mTexture[0]->getHeight())); + setTexCoord(NULL, BIND15, MIRROR0, false); + } + + mTextureNum++; + setBlendKonstColor(); + setBlendKonstAlpha(); + return true; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -585,14 +769,52 @@ asm bool J2DPicture::insert(ResTIMG const* param_0, JUTPalette* param_1, u8 para #include "asm/JSystem/J2DGraph/J2DPicture/insert__10J2DPictureFPC7ResTIMGP10JUTPaletteUcf.s" } #pragma pop +#endif /* 802FD4B4-802FD524 2F7DF4 0070+00 1/0 0/0 0/0 .text insert__10J2DPictureFPCcP10JUTPaletteUcf */ -bool J2DPicture::insert(char const* param_0, JUTPalette* param_1, u8 param_2, f32 param_3) { - void* resource = J2DScreen::getNameResource(param_0); - return insert((ResTIMG*)resource, param_1, param_2, param_3); +bool J2DPicture::insert(char const* resName, JUTPalette* palette, u8 param_2, f32 param_3) { + void* resource = J2DScreen::getNameResource(resName); + return insert((ResTIMG*)resource, palette, param_2, param_3); } /* 802FD524-802FD6F4 2F7E64 01D0+00 1/0 0/0 0/0 .text insert__10J2DPictureFP10JUTTextureUcf */ +// matches with literals +#ifdef NONMATCHING +bool J2DPicture::insert(JUTTexture* texture, u8 param_1, f32 param_2) { + if (texture == NULL || mTextureNum >= 2 || param_1 >= 2 || param_1 > mTextureNum) { + return false; + } + + if (mTexture[1] != NULL && field_0x109 & 2) { + delete mTexture[1]; + field_0x109 &= 1; + } + + for (u8 i = 1; i > param_1; i--) { + mTexture[i] = mTexture[i - 1]; + field_0x11c[i] = field_0x11c[i - 1]; + field_0x124[i] = field_0x124[i - 1]; + } + + field_0x109 = + (field_0x109 & ((1 << param_1) - 1)) | ((field_0x109 & ~((1 << param_1) - 1)) * 2); + mTexture[param_1] = texture; + field_0x109 &= ~(1 << param_1); + + field_0x11c[param_1] = param_2; + field_0x124[param_1] = param_2; + + if (mTextureNum == 0 && &mTexture[0] != NULL) { + place(JGeometry::TBox2(0.0f, 0.0f, mTexture[0]->getWidth(), mTexture[0]->getHeight())); + setTexCoord(NULL, BIND15, MIRROR0, false); + } + + mTextureNum++; + setBlendKonstColor(); + setBlendKonstAlpha(); + return true; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -601,22 +823,39 @@ asm bool J2DPicture::insert(JUTTexture* param_0, u8 param_1, f32 param_2) { #include "asm/JSystem/J2DGraph/J2DPicture/insert__10J2DPictureFP10JUTTextureUcf.s" } #pragma pop +#endif /* 802FD6F4-802FD814 2F8034 0120+00 1/0 0/0 0/0 .text remove__10J2DPictureFUc */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool J2DPicture::remove(u8 param_0) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/remove__10J2DPictureFUc.s" +bool J2DPicture::remove(u8 param_0) { + if (mTextureNum <= param_0 || mTextureNum == 1) { + return false; + } + + if (field_0x109 & (1 << param_0)) { + delete mTexture[param_0]; + } + + for (u8 i = param_0; i < mTextureNum - 1; i++) { + mTexture[i] = mTexture[i + 1]; + field_0x11c[i] = field_0x11c[i + 1]; + field_0x124[i] = field_0x124[i + 1]; + } + + mTexture[mTextureNum - 1] = NULL; + field_0x109 = + (field_0x109 & ((1 << param_0) - 1)) | ((field_0x109 & ~((1 << (param_0 + 1)) - 1)) >> 1); + + mTextureNum--; + setBlendKonstColor(); + setBlendKonstAlpha(); + return true; } -#pragma pop /* 802FD814-802FD874 2F8154 0060+00 1/0 0/0 0/0 .text remove__10J2DPictureFP10JUTTexture */ bool J2DPicture::remove(JUTTexture* param_0) { u8 i = 0; - for (; i < mTextureCount; i++) { + for (; i < mTextureNum; i++) { if (mTexture[i] == param_0) { break; } @@ -625,6 +864,30 @@ bool J2DPicture::remove(JUTTexture* param_0) { } /* 802FD874-802FD964 2F81B4 00F0+00 1/0 0/0 0/0 .text changeTexture__10J2DPictureFPC7ResTIMGUc */ +// matches with literals +#ifdef NONMATCHING +const ResTIMG* J2DPicture::changeTexture(ResTIMG const* img, u8 texIndex) { + if (texIndex > mTextureNum || 2 <= texIndex || img == NULL) { + return NULL; + } + + const ResTIMG* result; + if (texIndex < mTextureNum) { + JUTTexture* tex = getTexture(texIndex); + result = tex->getTexInfo(); + + u8 var_r30 = 0; + if (img->indexTexture != 0) { + var_r30 = getUsableTlut(texIndex); + } + getTexture(texIndex)->storeTIMG(img, var_r30); + return result; + } + + append(img, 1.0f); + return NULL; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -633,24 +896,51 @@ asm const ResTIMG* J2DPicture::changeTexture(ResTIMG const* param_0, u8 param_1) #include "asm/JSystem/J2DGraph/J2DPicture/changeTexture__10J2DPictureFPC7ResTIMGUc.s" } #pragma pop +#endif /* 802FD964-802FD9BC 2F82A4 0058+00 1/0 0/0 0/0 .text changeTexture__10J2DPictureFPCcUc */ -const ResTIMG* J2DPicture::changeTexture(char const* param_0, u8 param_1) { - void* resource = J2DScreen::getNameResource(param_0); +const ResTIMG* J2DPicture::changeTexture(char const* resName, u8 param_1) { + void* resource = J2DScreen::getNameResource(resName); return changeTexture((ResTIMG*)resource, param_1); } /* 802FD9BC-802FDAC8 2F82FC 010C+00 1/0 0/0 0/0 .text * changeTexture__10J2DPictureFPC7ResTIMGUcP10JUTPalette */ +// matches with literals +#ifdef NONMATCHING +const ResTIMG* J2DPicture::changeTexture(ResTIMG const* img, u8 texIndex, JUTPalette* palette) { + if (texIndex > mTextureNum || 2 <= texIndex || img == NULL) { + return NULL; + } + + const ResTIMG* result; + if (texIndex < mTextureNum) { + JUTTexture* tex = getTexture(texIndex); + result = tex->getTexInfo(); + + GXTlut var_r30 = GX_TLUT0; + if (img->indexTexture != 0) { + var_r30 = getTlutID(img, getUsableTlut(texIndex)); + } + getTexture(texIndex)->storeTIMG(img, palette, var_r30); + return result; + } + + append(img, palette, 1.0f); + return NULL; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm const ResTIMG* J2DPicture::changeTexture(ResTIMG const* param_0, u8 param_1, JUTPalette* param_2) { +asm const ResTIMG* J2DPicture::changeTexture(ResTIMG const* param_0, u8 param_1, + JUTPalette* param_2) { nofralloc #include "asm/JSystem/J2DGraph/J2DPicture/changeTexture__10J2DPictureFPC7ResTIMGUcP10JUTPalette.s" } #pragma pop +#endif /* 802FDAC8-802FDB28 2F8408 0060+00 1/0 0/0 0/0 .text * changeTexture__10J2DPictureFPCcUcP10JUTPalette */ @@ -670,7 +960,7 @@ void J2DPicture::drawSelf(f32 param_0, f32 param_1) { /* 802FDB90-802FDBFC 2F84D0 006C+00 1/0 0/0 0/0 .text drawSelf__10J2DPictureFffPA3_A4_f */ void J2DPicture::drawSelf(f32 param_0, f32 param_1, Mtx* param_2) { - if (mTexture[0] != NULL && mTextureCount != 0) { + if (mTexture[0] != NULL && mTextureNum != 0) { drawFullSet(mGlobalBounds.i.x + param_0, mGlobalBounds.i.y + param_1, mBounds.f.x - mBounds.i.x, mBounds.f.y - mBounds.i.y, param_2); } @@ -678,7 +968,7 @@ void J2DPicture::drawSelf(f32 param_0, f32 param_1, Mtx* param_2) { /* 802FDBFC-802FDC70 2F853C 0074+00 1/0 0/0 0/0 .text drawFullSet__10J2DPictureFffffPA3_A4_f */ void J2DPicture::drawFullSet(f32 param_0, f32 param_1, f32 param_2, f32 param_3, Mtx* param_4) { - if (mTexture[0] != NULL && mTextureCount != 0) { + if (mTexture[0] != NULL && mTextureNum != 0) { drawTexCoord(mBounds.i.x, mBounds.i.y, param_2, param_3, field_0x10a[0].x, field_0x10a[0].y, field_0x10a[1].x, field_0x10a[1].y, field_0x10a[2].x, field_0x10a[2].y, field_0x10a[3].x, field_0x10a[3].y, param_4); @@ -686,6 +976,67 @@ void J2DPicture::drawFullSet(f32 param_0, f32 param_1, f32 param_2, f32 param_3, } /* 802FDC70-802FDF88 2F85B0 0318+00 1/0 1/1 0/0 .text draw__10J2DPictureFffffbbb */ +// matches with literals +#ifdef NONMATCHING +void J2DPicture::draw(f32 x, f32 y, f32 width, f32 height, bool mirrorX, bool mirrorY, + bool rotate90) { + if (isVisible() && mTextureNum != 0 && mTexture[0] != NULL) { + for (u8 i = 0; i < mTextureNum; i++) { + load(i); + } + + GXSetNumTexGens(mTextureNum); + mColorAlpha = mAlpha; + JUtility::TColor color[4]; + getNewColor(color); + + setTevMode(); + makeMatrix(x, y, 0.0f, 0.0f); + GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0); + GXSetCurrentMtx(GX_PNMTX0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + + JGeometry::TVec2 coords[4]; + setTexCoord(coords, mTexture[0], BIND15, (J2DMirror)((mirrorX << 1) | mirrorY), rotate90); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_POS_XYZ, GX_S16, 8); + + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + GXPosition3f32(0.0f, 0.0f, 0.0f); + GXColor1u32(color[0]); + GXTexCoord2s16(coords[0].x, coords[0].y); + + GXPosition3f32(width, 0.0f, 0.0f); + GXColor1u32(color[1]); + GXTexCoord2s16(coords[1].x, coords[1].y); + + GXPosition3f32(width, height, 0.0f); + GXColor1u32(color[3]); + GXTexCoord2s16(coords[3].x, coords[3].y); + + GXPosition3f32(0.0f, height, 0.0f); + GXColor1u32(color[2]); + GXTexCoord2s16(coords[2].x, coords[2].y); + GXEnd(); + + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_POS_XYZ, GX_U16, 15); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + + Mtx m; + MTXIdentity(m); + GXLoadPosMtxImm(m, GX_PNMTX0); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, + GX_AF_NONE); + GXSetVtxDesc(GX_VA_TEX0, GX_NONE); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -695,9 +1046,69 @@ asm void J2DPicture::draw(f32 param_0, f32 param_1, f32 param_2, f32 param_3, bo #include "asm/JSystem/J2DGraph/J2DPicture/draw__10J2DPictureFffffbbb.s" } #pragma pop +#endif /* 802FDF88-802FE380 2F88C8 03F8+00 1/0 0/0 0/0 .text * drawOut__10J2DPictureFRCQ29JGeometry8TBox2RCQ29JGeometry8TBox2 */ +// matches with literals +#ifdef NONMATCHING +void J2DPicture::drawOut(JGeometry::TBox2 const& posBox, + JGeometry::TBox2 const& texRect) { + if (isVisible() && mTextureNum != 0 && mTexture[0] != NULL) { + for (u8 i = 0; i < mTextureNum; i++) { + load(i); + } + + GXSetNumTexGens(mTextureNum); + + f32 s0 = (posBox.i.x - texRect.i.x) / texRect.getWidth(); + f32 s1 = (posBox.f.x - texRect.f.x) / texRect.getWidth() + 1.0f; + + f32 t0 = (posBox.i.y - texRect.i.y) / texRect.getHeight(); + f32 t1 = (posBox.f.y - texRect.f.y) / texRect.getHeight() + 1.0f; + + mColorAlpha = mAlpha; + JUtility::TColor color[4]; + getNewColor(color); + setTevMode(); + + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + GXPosition3f32((s16)posBox.i.x, (s16)posBox.i.y, 0.0f); + GXColor1u32(color[0]); + GXTexCoord2f32(s0, t0); + + GXPosition3f32((s16)posBox.f.x, (s16)posBox.i.y, 0.0f); + GXColor1u32(color[1]); + GXTexCoord2f32(s1, t0); + + GXPosition3f32((s16)posBox.f.x, (s16)posBox.f.y, 0.0f); + GXColor1u32(color[3]); + GXTexCoord2f32(s1, t1); + + GXPosition3f32((s16)posBox.i.x, (s16)posBox.f.y, 0.0f); + GXColor1u32(color[2]); + GXTexCoord2f32(s0, t1); + GXEnd(); + + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U16, 15); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, + GX_AF_NONE); + GXSetVtxDesc(GX_VA_TEX0, GX_NONE); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -707,24 +1118,24 @@ asm void J2DPicture::drawOut(JGeometry::TBox2 const& param_0, #include "asm/JSystem/J2DGraph/J2DPicture/func_802FDF88.s" } #pragma pop +#endif /* 802FE380-802FE5D0 2F8CC0 0250+00 1/0 0/0 0/0 .text * drawTexCoord__10J2DPictureFffffssssssssPA3_A4_f */ #ifdef NONMATCHING // matches with literals void J2DPicture::drawTexCoord(f32 param_0, f32 param_1, f32 param_2, f32 param_3, s16 param_4, - s16 param_5, s16 param_6, s16 param_7, s16 param_8, s16 param_9, - s16 param_10, s16 param_11, Mtx* param_12) { - - if (mTextureCount != 0) { - for (u8 i = 0; i < mTextureCount; i++) { + s16 param_5, s16 param_6, s16 param_7, s16 param_8, s16 param_9, + s16 param_10, s16 param_11, Mtx* param_12) { + if (mTextureNum != 0) { + for (u8 i = 0; i < mTextureNum; i++) { load(i); } f32 tmp1 = param_0 + param_2; f32 tmp2 = param_1 + param_3; - GXSetNumTexGens(mTextureCount); + GXSetNumTexGens(mTextureNum); JUtility::TColor black[4]; @@ -732,37 +1143,37 @@ void J2DPicture::drawTexCoord(f32 param_0, f32 param_1, f32 param_2, f32 param_3 getNewColor(black); setTevMode(); - MTXConcat((MtxP)param_12,mGlobalMtx,outputMtx); + MTXConcat((MtxP)param_12, mGlobalMtx, outputMtx); - GXLoadPosMtxImm(outputMtx,0); + GXLoadPosMtxImm(outputMtx, 0); GXClearVtxDesc(); - GXSetVtxDesc(GX_VA_POS,GX_DIRECT); - GXSetVtxDesc(GX_VA_CLR0,GX_DIRECT); - GXSetVtxDesc(GX_VA_TEX0,GX_DIRECT); - GXSetVtxAttrFmt(GX_VTXFMT0,GX_VA_POS,GX_CLR_RGBA,GX_F32,0); - GXSetVtxAttrFmt(GX_VTXFMT0,GX_VA_TEX0,GX_CLR_RGBA,GX_RGBA4,8); - GXBegin(GX_QUADS,GX_VTXFMT0,4); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBA4, 8); + GXBegin(GX_QUADS, GX_VTXFMT0, 4); - GXPosition3f32(param_0,param_1,0.0f); + GXPosition3f32(param_0, param_1, 0.0f); GXColor1u32(black[0]); - GXTexCoord2s16(param_4,param_5); + GXTexCoord2s16(param_4, param_5); - GXPosition3f32(tmp1,param_1,0.0f); + GXPosition3f32(tmp1, param_1, 0.0f); GXColor1u32(black[1]); - GXTexCoord2s16(param_6,param_7); + GXTexCoord2s16(param_6, param_7); - GXPosition3f32(tmp1,tmp2,0.0f); + GXPosition3f32(tmp1, tmp2, 0.0f); GXColor1u32(black[3]); - GXTexCoord2s16(param_10,param_11); + GXTexCoord2s16(param_10, param_11); - GXPosition3f32(param_0,tmp2,0.0f); + GXPosition3f32(param_0, tmp2, 0.0f); GXColor1u32(black[2]); - GXTexCoord2s16(param_8,param_9); + GXTexCoord2s16(param_8, param_9); GXEnd(); - GXSetVtxAttrFmt(GX_VTXFMT0,GX_VA_TEX0,GX_CLR_RGBA,GX_RGBX8,0xf); - GXSetVtxAttrFmt(GX_VTXFMT0,GX_VA_POS,GX_CLR_RGBA,GX_RGBA4,0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0xf); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0); } } #else @@ -779,14 +1190,89 @@ asm void J2DPicture::drawTexCoord(f32 param_0, f32 param_1, f32 param_2, f32 par #endif /* 802FE5D0-802FEA60 2F8F10 0490+00 3/3 0/0 0/0 .text setTevMode__10J2DPictureFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DPicture::setTevMode() { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/setTevMode__10J2DPictureFv.s" +void J2DPicture::setTevMode() { + u8 i; + for (i = 0; i < mTextureNum; i++) { + GXSetTevOrder(GXTevStageID(i), GXTexCoordID(i), GXTexMapID(i), GX_COLOR_NULL); + } + + GXSetTevColor(GX_TEVREG2, JUtility::TColor(0xFFFFFFFF)); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_TEXC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + + if (mTexture[0] == NULL) { + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A2, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + } else if (mTexture[0]->getTransparency()) { + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_TEXA, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + } else { + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A2, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + } + + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevKColor(GX_KCOLOR0, mBlendKonstColor); + GXSetTevKColor(GX_KCOLOR2, mBlendKonstAlpha); + + for (i = 1; i < mTextureNum; i++) { + GXSetTevKColorSel(GXTevStageID(i), GXTevKColorSel(0x20 - i * 4)); + GXSetTevKAlphaSel(GXTevStageID(i), GXTevKAlphaSel(0x22 - i * 4)); + GXSetTevColorIn(GXTevStageID(i), GX_CC_CPREV, GX_CC_TEXC, GX_CC_KONST, GX_CC_ZERO); + + if (mTexture[i] == NULL) { + GXSetTevAlphaIn(GXTevStageID(i), GX_CA_APREV, GX_CA_A2, GX_CA_KONST, GX_CA_ZERO); + } else if (mTexture[i]->getTransparency()) { + GXSetTevAlphaIn(GXTevStageID(i), GX_CA_APREV, GX_CA_TEXA, GX_CA_KONST, GX_CA_ZERO); + } else { + GXSetTevAlphaIn(GXTevStageID(i), GX_CA_APREV, GX_CA_A2, GX_CA_KONST, GX_CA_ZERO); + } + + GXSetTevColorOp(GXTevStageID(i), GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, + GX_TEVPREV); + GXSetTevAlphaOp(GXTevStageID(i), GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, + GX_TEVPREV); + } + + if (mBlack != 0 || mWhite != 0xFFFFFFFF) { + GXSetTevOrder(GXTevStageID(i), GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); + GXSetTevColor(GX_TEVREG0, mBlack); + GXSetTevColor(GX_TEVREG1, mWhite); + GXSetTevColorIn(GXTevStageID(i), GX_CC_C0, GX_CC_C1, GX_CC_CPREV, GX_CC_ZERO); + GXSetTevAlphaIn(GXTevStageID(i), GX_CA_A0, GX_CA_A1, GX_CA_APREV, GX_CA_ZERO); + GXSetTevColorOp(GXTevStageID(i), GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, + GX_TEVPREV); + GXSetTevAlphaOp(GXTevStageID(i), GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, + GX_TEVPREV); + i++; + } + + if (mColorAlpha != 0xFF || mCornerColor[0] != 0xFFFFFFFF || mCornerColor[1] != 0xFFFFFFFF || + mCornerColor[2] != 0xFFFFFFFF || mCornerColor[3] != 0xFFFFFFFF) + { + GXSetTevOrder(GXTevStageID(i), GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GXTevStageID(i), GX_CC_ZERO, GX_CC_CPREV, GX_CC_RASC, GX_CC_ZERO); + GXSetTevAlphaIn(GXTevStageID(i), GX_CA_ZERO, GX_CA_APREV, GX_CA_RASA, GX_CA_ZERO); + GXSetTevColorOp(GXTevStageID(i), GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, + GX_TEVPREV); + GXSetTevAlphaOp(GXTevStageID(i), GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, + GX_TEVPREV); + i++; + } + + GXSetNumTevStages(u8(i)); + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRC_ALPHA, GX_BL_INV_SRC_ALPHA, GX_LO_SET); + + for (i = 0; i < mTextureNum; i++) { + GXSetTexCoordGen(GXTexCoordID(i), GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + } + + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, + GX_AF_NONE); + GXSetNumIndStages(0); + + for (int i = GX_TEVSTAGE0; i < GX_MAX_TEVSTAGE; i++) { + GXSetTevDirect((GXTevStageID)i); + } } -#pragma pop /* 802FEA60-802FEA74 2F93A0 0014+00 1/1 0/0 0/0 .text swap__10J2DPictureFRfRf */ void J2DPicture::swap(f32& lhs, f32& rhs) { @@ -821,7 +1307,7 @@ SECTION_SDATA2 static f32 lit_2758 = 255.0f; #ifdef NONMATCHING void J2DPicture::setBlendKonstColor() { int uvar3 = 0; - for (u8 i = 1; i < mTextureCount; i++) { + for (u8 i = 1; i < mTextureNum; i++) { f32 tmp = 0.0f; for (u8 j = 0; j < i; j++) { tmp += field_0x11c[j]; @@ -833,7 +1319,7 @@ void J2DPicture::setBlendKonstColor() { uvar3 |= (u8)(255.0f * (1.0f - tmp / tmp2)) << (i - 1) * 8; } } - field_0x148 = uvar3; + mBlendKonstColor = uvar3; } #else #pragma push @@ -848,6 +1334,25 @@ asm void J2DPicture::setBlendKonstColor() { /* 802FEB94-802FEC64 2F94D4 00D0+00 4/4 0/0 0/0 .text setBlendKonstAlpha__10J2DPictureFv */ +// matches with real literals +#ifdef NONMATCHING +void J2DPicture::setBlendKonstAlpha() { + int uvar3 = 0; + for (u8 i = 1; i < mTextureNum; i++) { + f32 tmp = 0.0f; + for (u8 j = 0; j < i; j++) { + tmp += field_0x124[j]; + } + + f32 tmp2 = tmp + field_0x124[i]; + if (tmp2 != 0.0f) { + // probably fake match but idk whats happening here + uvar3 |= (u8)(255.0f * (1.0f - tmp / tmp2)) << (i - 1) * 8; + } + } + mBlendKonstAlpha = uvar3; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -856,17 +1361,23 @@ asm void J2DPicture::setBlendKonstAlpha() { #include "asm/JSystem/J2DGraph/J2DPicture/setBlendKonstAlpha__10J2DPictureFv.s" } #pragma pop +#endif /* 802FEC64-802FED44 2F95A4 00E0+00 3/3 0/0 0/0 .text * getNewColor__10J2DPictureFPQ28JUtility6TColor */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DPicture::getNewColor(JUtility::TColor* param_0) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/getNewColor__10J2DPictureFPQ28JUtility6TColor.s" +void J2DPicture::getNewColor(JUtility::TColor* param_0) { + param_0[0] = mCornerColor[0]; + param_0[1] = mCornerColor[1]; + param_0[2] = mCornerColor[2]; + param_0[3] = mCornerColor[3]; + + if (mColorAlpha != 0xFF) { + param_0[0].a = (param_0[0].a * mColorAlpha) / 0xFF; + param_0[1].a = (param_0[1].a * mColorAlpha) / 0xFF; + param_0[2].a = (param_0[2].a * mColorAlpha) / 0xFF; + param_0[3].a = (param_0[3].a * mColorAlpha) / 0xFF; + } } -#pragma pop /* 802FED44-802FED84 2F9684 0040+00 4/4 0/0 0/0 .text * setTexCoord__10J2DPictureFPC10JUTTexture10J2DBinding9J2DMirrorb */ @@ -881,6 +1392,118 @@ SECTION_SDATA2 static f32 lit_2933 = 0.5f; /* 802FED84-802FF09C 2F96C4 0318+00 2/2 0/0 0/0 .text * setTexCoord__10J2DPictureFPQ29JGeometry8TVec2PC10JUTTexture10J2DBinding9J2DMirrorb */ +#ifdef NONMATCHING +void J2DPicture::setTexCoord(JGeometry::TVec2* param_0, JUTTexture const* param_1, + J2DBinding param_2, J2DMirror param_3, bool param_4) { + u8 var_r0; + u8 var_r4; + u8 var_r7; + u8 var_r9; + + f32 sp14; + f32 sp10; + f32 spC; + f32 sp8; + + f32 var_f0; + f32 var_f2; + f32 var_f3; + f32 var_f4; + f32 var_f5; + + if (!param_4) { + var_r0 = (param_3 & 2) ? (param_2 & 4) : (param_2 & 8); + var_r4 = (param_3 & 2) ? (param_2 & 8) : (param_2 & 4); + var_r7 = (param_3 & 1) ? (param_2 & 1) : (param_2 & 2); + var_r9 = (param_3 & 1) ? (param_2 & 1) : (param_2 & 2); + } else { + var_r0 = (param_3 & 2) ? (param_2 & 1) : (param_2 & 2); + var_r4 = (param_3 & 2) ? (param_2 & 2) : (param_2 & 1); + var_r7 = (param_3 & 1) ? (param_2 & 8) : (param_2 & 4); + var_r9 = (param_3 & 1) ? (param_2 & 4) : (param_2 & 8); + } + + if (!param_4) { + var_f2 = getHeight(); + } else { + var_f2 = getWidth(); + } + + if (!param_4) { + var_f3 = getWidth(); + } else { + var_f3 = getHeight(); + } + + if (param_1 == NULL) { + var_f4 = var_f2; + var_f5 = var_f3; + } else { + var_f4 = param_1->getWidth(); + var_f5 = param_1->getHeight(); + } + + if (var_r0 != 0) { + sp14 = 0.0f; + if (var_r4 != 0) { + var_f0 = 1.0f; + } else { + var_f0 = var_f2 / var_f4; + } + spC = var_f0; + } else if (var_r4 != 0) { + sp14 = 1.0f - (var_f2 / var_f4); + spC = 1.0f; + } else { + sp14 = 0.5f - ((var_f2 / var_f4) * 0.5f); + spC = 0.5f + ((var_f2 / var_f4) * 0.5f); + } + + if (var_r7 != 0) { + sp10 = 0.0f; + + f32 var_f0_2; + if (var_r9 != 0) { + var_f0_2 = 1.0f; + } else { + var_f0_2 = var_f3 / var_f5; + } + + sp8 = var_f0_2; + } else if (var_r9 != 0) { + sp10 = 1.0f - (var_f3 / var_f5); + sp8 = 1.0f; + } else { + sp10 = 0.5f - ((var_f3 / var_f5) * 0.5f); + sp8 = 0.5f + ((var_f3 / var_f5) * 0.5f); + } + + if (param_3 & 2) { + swap(sp14, spC); + } + + if (param_3 & 1) { + swap(sp10, sp8); + } + + s16 temp_r27 = J2DCast_F32_to_S16(sp14, 8); + s16 temp_r28 = J2DCast_F32_to_S16(spC, 8); + s16 temp_r30 = J2DCast_F32_to_S16(sp10, 8); + s16 temp_r31 = J2DCast_F32_to_S16(sp8, 8); + + if (!param_4) { + param_0[0].set(temp_r27, temp_r30); + param_0[1].set(temp_r28, temp_r30); + param_0[2].set(temp_r28, temp_r31); + param_0[3].set(temp_r27, temp_r31); + } else { + param_0[0].set(temp_r27, temp_r31); + param_0[1].set(temp_r27, temp_r30); + param_0[2].set(temp_r28, temp_r31); + param_0[3].set(temp_r28, temp_r30); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -890,10 +1513,11 @@ asm void J2DPicture::setTexCoord(JGeometry::TVec2* param_0, JUTTexture cons #include "asm/JSystem/J2DGraph/J2DPicture/func_802FED84.s" } #pragma pop +#endif /* 802FF09C-802FF100 2F99DC 0064+00 1/0 0/0 0/0 .text isUsed__10J2DPictureFPC7ResTIMG */ bool J2DPicture::isUsed(ResTIMG const* param_0) { - for (u8 i = 0; i < mTextureCount; i++) { + for (u8 i = 0; i < mTextureNum; i++) { if (mTexture[i] != NULL && mTexture[i]->getTexInfo() == param_0) { return true; } @@ -903,24 +1527,44 @@ bool J2DPicture::isUsed(ResTIMG const* param_0) { } /* 802FF100-802FF1D0 2F9A40 00D0+00 1/0 0/0 0/0 .text getUsableTlut__10J2DPictureFUc */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm u8 J2DPicture::getUsableTlut(u8 param_0) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/getUsableTlut__10J2DPictureFUc.s" +u8 J2DPicture::getUsableTlut(u8 param_0) { + u8 var_r8 = 0; + + for (u8 i = 0; i < mTextureNum; i++) { + if (i != param_0 && mTexture[i] != NULL) { + const ResTIMG* img = mTexture[i]->getTexInfo(); + + if (img != NULL && img->indexTexture != 0) { + int name = mTexture[i]->getTlutName(); + int var_r0 = name >= GX_MAX_TLUT ? GX_MAX_TLUT : GX_TLUT0; + + u8 temp_r0 = name - var_r0; + if (temp_r0 < 2) { + var_r8 |= (1 << temp_r0); + } + } + } + } + + u8 var_r26 = 0; + for (u8 i = 0; i < 2; i++) { + if (!(var_r8 & (1 << i))) { + var_r26 = i; + break; + } + } + + return var_r26; } -#pragma pop /* 802FF1D0-802FF204 2F9B10 0034+00 1/1 1/1 0/0 .text getTlutID__10J2DPictureFPC7ResTIMGUc */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm GXTlut J2DPicture::getTlutID(ResTIMG const* param_0, u8 param_1) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/getTlutID__10J2DPictureFPC7ResTIMGUc.s" +GXTlut J2DPicture::getTlutID(ResTIMG const* img, u8 param_1) { + if (img->numColors > 256) { + return (GXTlut)((param_1 % 4) + 0x10); + } + + return (GXTlut)param_1; } -#pragma pop /* 802FF204-802FF208 2F9B44 0004+00 5/5 1/1 0/0 .text __ct__Q29JGeometry8TVec2Fv */ extern "C" void func_802FF204(void* _this) { @@ -930,13 +1574,13 @@ extern "C" void func_802FF204(void* _this) { /* 802FF208-802FF238 2F9B48 0030+00 1/0 0/0 0/0 .text append__10J2DPictureFP10JUTTexturef */ bool J2DPicture::append(JUTTexture* param_0, f32 param_1) { - return insert(param_0, mTextureCount, param_1); + return insert(param_0, mTextureNum, param_1); } /* 802FF238-802FF268 2F9B78 0030+00 1/0 0/0 0/0 .text * append__10J2DPictureFPC7ResTIMGP10JUTPalettef */ bool J2DPicture::append(ResTIMG const* param_0, JUTPalette* param_1, f32 param_2) { - return insert(param_0, param_1, mTextureCount, param_2); + return insert(param_0, param_1, mTextureNum, param_2); } /* 802FF268-802FF29C 2F9BA8 0034+00 1/0 0/0 0/0 .text load__10J2DPictureFUc */ @@ -947,7 +1591,7 @@ void J2DPicture::load(u8 param_0) { /* 802FF29C-802FF2E8 2F9BDC 004C+00 1/0 0/0 0/0 .text load__10J2DPictureF11_GXTexMapIDUc */ void J2DPicture::load(_GXTexMapID param_0, u8 param_1) { - if (param_1 < mTextureCount && param_1 < 2 && mTexture[param_1] != NULL) { + if (param_1 < mTextureNum && param_1 < 2 && mTexture[param_1] != NULL) { mTexture[param_1]->load(param_0); } } @@ -959,7 +1603,7 @@ u16 J2DPicture::getTypeID() const { /* 802FF2F0-802FF320 2F9C30 0030+00 1/0 0/0 0/0 .text append__10J2DPictureFPCcP10JUTPalettef */ bool J2DPicture::append(char const* param_0, JUTPalette* param_1, f32 param_2) { - return insert(param_0, param_1, mTextureCount, param_2); + return insert(param_0, param_1, mTextureNum, param_2); } /* 802FF320-802FF350 2F9C60 0030+00 1/0 0/0 0/0 .text prepend__10J2DPictureFP10JUTTexturef */ @@ -991,10 +1635,20 @@ void J2DPicture::prepend(ResTIMG const* param_0, f32 param_1) { /* 802FF410-802FF448 2F9D50 0038+00 1/0 0/0 0/0 .text remove__10J2DPictureFv */ bool J2DPicture::remove() { - return remove(mTextureCount - 1); + return remove(mTextureNum - 1); } /* 802FF448-802FF4E0 2F9D88 0098+00 1/0 0/0 0/0 .text draw__10J2DPictureFffUcbbb */ +// matches with literals +#ifdef NONMATCHING +void J2DPicture::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); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -1004,29 +1658,32 @@ asm void J2DPicture::draw(f32 param_0, f32 param_1, u8 param_2, bool param_3, bo #include "asm/JSystem/J2DGraph/J2DPicture/draw__10J2DPictureFffUcbbb.s" } #pragma pop +#endif /* 802FF4E0-802FF524 2F9E20 0044+00 1/0 0/0 0/0 .text draw__10J2DPictureFffbbb */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DPicture::draw(f32 param_0, f32 param_1, bool param_2, bool param_3, bool param_4) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/draw__10J2DPictureFffbbb.s" +void J2DPicture::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); } -#pragma pop /* 802FF524-802FF588 2F9E64 0064+00 1/0 0/0 0/0 .text drawOut__10J2DPictureFffffffff */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DPicture::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) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DPicture/drawOut__10J2DPictureFffffffff.s" +void J2DPicture::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(param_0, param_1, param_0 + param_2, param_1 + param_3), + JGeometry::TBox2(param_4, param_5, param_4 + param_6, param_5 + param_7)); } -#pragma pop /* 802FF588-802FF634 2F9EC8 00AC+00 1/0 0/0 0/0 .text drawOut__10J2DPictureFffffff */ +// matches with literals +#ifdef NONMATCHING +void J2DPicture::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(param_0, param_1, param_0 + param_2, param_1 + param_3), + JGeometry::TBox2(param_4, param_5, param_4 + mTexture[0]->getWidth(), + param_5 + mTexture[0]->getHeight())); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -1036,10 +1693,11 @@ asm void J2DPicture::drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, #include "asm/JSystem/J2DGraph/J2DPicture/drawOut__10J2DPictureFffffff.s" } #pragma pop +#endif /* 802FF634-802FF63C 2F9F74 0008+00 1/0 0/0 0/0 .text getTextureCount__10J2DPictureCFv */ u8 J2DPicture::getTextureCount() const { - return mTextureCount; + return mTextureNum; } /* 802FF63C-802FF65C 2F9F7C 0020+00 1/0 0/0 0/0 .text isUsed__10J2DPictureFPC7ResFONT */ diff --git a/libs/JSystem/J2DGraph/J2DScreen.cpp b/libs/JSystem/J2DGraph/J2DScreen.cpp index 20430c62f62..89884a5ab08 100644 --- a/libs/JSystem/J2DGraph/J2DScreen.cpp +++ b/libs/JSystem/J2DGraph/J2DScreen.cpp @@ -208,7 +208,7 @@ SECTION_SDATA2 static f32 lit_1563[1 + 1 /* padding */] = { // almost #ifdef NONMATCHING J2DScreen::J2DScreen() - : J2DPane(NULL, true, 'root', JGeometry::TBox2(0.0f, 0.0f, 0.0f, 0.0f)), mColor() { + : J2DPane(NULL, true, 'root', JGeometry::TBox2(0.0f, 0.0f, 640.0f, 480.0f)), mColor() { field_0x4 = -1; mScissor = false; mMaterialNum = 0; @@ -342,14 +342,12 @@ bool J2DScreen::getScreenInformation(JSURandomInputStream* p_stream) { /* 802F8990-802F8B98 2F32D0 0208+00 1/1 0/0 0/0 .text * makeHierarchyPanes__9J2DScreenFP7J2DPaneP20JSURandomInputStreamUlP10JKRArchive */ -// goto can probably be replaced s32 J2DScreen::makeHierarchyPanes(J2DPane* p_basePane, JSURandomInputStream* p_stream, u32 param_2, JKRArchive* p_archive) { - J2DScrnBlockHeader header; J2DPane* next_pane = p_basePane; - do { - loop: + while (true) { + J2DScrnBlockHeader header; p_stream->peek(&header, sizeof(J2DScrnBlockHeader)); switch (header.mTag) { @@ -360,10 +358,10 @@ s32 J2DScreen::makeHierarchyPanes(J2DPane* p_basePane, JSURandomInputStream* p_s p_stream->seek(header.mSize, JSUStreamSeekFrom_CUR); int ret = makeHierarchyPanes(next_pane, p_stream, param_2, p_archive); - if (ret == 0) { - goto loop; + if (ret != 0) { + return ret; } - return ret; + break; case 'END1': p_stream->seek(header.mSize, JSUStreamSeekFrom_CUR); return 0; @@ -371,33 +369,36 @@ s32 J2DScreen::makeHierarchyPanes(J2DPane* p_basePane, JSURandomInputStream* p_s J2DResReference* texRes = getResReference(p_stream, param_2); mTexRes = texRes; - if (texRes != NULL) { - goto loop; + if (texRes == NULL) { + return 2; } - return 2; + break; case 'FNT1': J2DResReference* fntRes = getResReference(p_stream, param_2); mFontRes = fntRes; - if (fntRes != NULL) { - goto loop; + if (fntRes == NULL) { + return 2; } - return 2; + break; case 'MAT1': - if (createMaterial(p_stream, param_2, p_archive)) { - goto loop; + if (!createMaterial(p_stream, param_2, p_archive)) { + return 2; + } + break; + default: + if (p_archive == NULL) { + next_pane = createPane(header, p_stream, p_basePane, param_2); + } else { + next_pane = createPane(header, p_stream, p_basePane, param_2, p_archive); } - return 2; - } - if (p_archive == NULL) { - next_pane = createPane(header, p_stream, p_basePane, param_2); - } else { - next_pane = createPane(header, p_stream, p_basePane, param_2, p_archive); + if (next_pane == NULL) { + return 2; + } + break; } - } while (next_pane != NULL); - - return 2; + } } /* 802F8B98-802F8ED4 2F34D8 033C+00 1/0 0/0 0/0 .text diff --git a/libs/JSystem/J2DGraph/J2DWindow.cpp b/libs/JSystem/J2DGraph/J2DWindow.cpp index 8b99716073d..fc09ffef485 100644 --- a/libs/JSystem/J2DGraph/J2DWindow.cpp +++ b/libs/JSystem/J2DGraph/J2DWindow.cpp @@ -557,10 +557,6 @@ void J2DWindow::drawContentsTexture(f32 param_0, f32 param_1, f32 param_2, f32 p GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); } -static inline void GXSetTexCoordGen(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 mtx) { - GXSetTexCoordGen2(dst, type, src, mtx, GX_FALSE, GX_PTIDENTITY); -} - /* 802FBB90-802FBE60 2F64D0 02D0+00 2/2 0/0 0/0 .text * setTevMode__9J2DWindowFP10JUTTextureQ28JUtility6TColorQ28JUtility6TColor */ void J2DWindow::setTevMode(JUTTexture* param_0, JUtility::TColor param_1, diff --git a/libs/JSystem/J3DGraphAnimator/J3DAnimation.cpp b/libs/JSystem/J3DGraphAnimator/J3DAnimation.cpp index d3d8b7e17da..c3163f36d5d 100644 --- a/libs/JSystem/J3DGraphAnimator/J3DAnimation.cpp +++ b/libs/JSystem/J3DGraphAnimator/J3DAnimation.cpp @@ -786,11 +786,11 @@ asm void J3DAnmTexPattern::getTexNo(u16 param_0, u16* param_1) const { * searchUpdateMaterialID__16J3DAnmTexPatternFP16J3DMaterialTable */ void J3DAnmTexPattern::searchUpdateMaterialID(J3DMaterialTable* param_0) { for (u16 i = 0; i < mUpdateMaterialNum; i++) { - s32 r3 = param_0->getMaterialName()->getIndex(field_0x1c.getName(i)); + s32 r3 = param_0->getMaterialName()->getIndex(mUpdateMaterialName.getName(i)); if (r3 != -1) { - field_0x18[i] = r3; + mUpdateMaterialID[i] = r3; } else { - field_0x18[i] = -1; + mUpdateMaterialID[i] = -1; } } } diff --git a/libs/JSystem/J3DGraphAnimator/J3DCluster.cpp b/libs/JSystem/J3DGraphAnimator/J3DCluster.cpp index c7a5ac5d7c2..bd16ca89845 100644 --- a/libs/JSystem/J3DGraphAnimator/J3DCluster.cpp +++ b/libs/JSystem/J3DGraphAnimator/J3DCluster.cpp @@ -4,38 +4,24 @@ // #include "JSystem/J3DGraphAnimator/J3DCluster.h" +#include "JSystem/J3DGraphAnimator/J3DAnimation.h" +#include "JSystem/J3DGraphAnimator/J3DModel.h" +#include "JSystem/J3DGraphAnimator/J3DSkinDeform.h" +#include "JSystem/JMath/JMath.h" +#include "JSystem/JUtility/JUTAssert.h" #include "dol2asm.h" +#include "dolphin/os.h" -// -// Types: -// - -struct JMath { - static f32 asinAcosTable_[1032]; -}; - -struct J3DVertexBuffer {}; - -struct J3DModel {}; - -struct J3DAnmCluster {}; - -struct J3DDeformData { - /* 8032E1F8 */ J3DDeformData(); - /* 8032E230 */ void offAllFlag(u32); - /* 8032E298 */ void deform(J3DVertexBuffer*); - /* 8032E274 */ void deform(J3DModel*); - /* 8032E364 */ void setAnm(J3DAnmCluster*); -}; - -struct J3DDeformer { - /* 8032E39C */ J3DDeformer(J3DDeformData*); - /* 8032EAB4 */ void deform(J3DVertexBuffer*, u16, f32*); - /* 8032E3BC */ void deform(J3DVertexBuffer*, u16); - /* 8032E4A4 */ void deform_VtxPosF32(J3DVertexBuffer*, J3DCluster*, J3DClusterKey*, f32*); - /* 8032E60C */ void deform_VtxNrmF32(J3DVertexBuffer*, J3DCluster*, J3DClusterKey*, f32*); - /* 8032EBCC */ void normalizeWeight(int, f32*); -}; +#ifdef DEBUG +#define J3D_ASSERT(COND) \ + if ((COND) == 0) { \ + JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, __LINE__, \ + "Error : null pointer"); \ + OSPanic(__FILE__, __LINE__, "Halt"); \ + } +#else +#define J3D_ASSERT(COND) +#endif // // Forward References: @@ -58,8 +44,6 @@ extern "C" void normalizeWeight__11J3DDeformerFiPf(); // extern "C" void PPCSync(); -extern "C" void DCStoreRangeNoSync(); -extern "C" void PSVECNormalize(); extern "C" void __cvt_fp2unsigned(); extern "C" void _savegpr_21(); extern "C" void _savegpr_26(); @@ -76,77 +60,93 @@ extern "C" f32 asinAcosTable___5JMath[1032]; // /* 8032E1F8-8032E230 328B38 0038+00 0/0 1/1 0/0 .text __ct__13J3DDeformDataFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm J3DDeformData::J3DDeformData() { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DCluster/__ct__13J3DDeformDataFv.s" +J3DDeformData::J3DDeformData() { + mClusterNum = 0; + mClusterKeyNum = 0; + mClusterVertexNum = 0; + mClusterPointer = NULL; + mClusterKeyPointer = NULL; + mClusterVertex = NULL; + mVtxPosNum = 0; + mVtxNrmNum = 0; + mVtxPos = NULL; + mVtxNrm = NULL; + mClusterName = NULL; + mClusterKeyName = NULL; } -#pragma pop /* 8032E230-8032E274 328B70 0044+00 0/0 1/1 0/0 .text offAllFlag__13J3DDeformDataFUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J3DDeformData::offAllFlag(u32 param_0) { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DCluster/offAllFlag__13J3DDeformDataFUl.s" +void J3DDeformData::offAllFlag(u32 i_flag) { + for (u16 i = 0; i < mClusterNum; i++) { + mClusterPointer[i].getDeformer()->offFlag(i_flag); + } } -#pragma pop /* 8032E274-8032E298 328BB4 0024+00 0/0 1/1 0/0 .text deform__13J3DDeformDataFP8J3DModel */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J3DDeformData::deform(J3DModel* param_0) { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DCluster/deform__13J3DDeformDataFP8J3DModel.s" +void J3DDeformData::deform(J3DModel* model) { + J3D_ASSERT(model != NULL); + + deform(model->getVertexBuffer()); } -#pragma pop /* 8032E298-8032E364 328BD8 00CC+00 1/1 0/0 0/0 .text deform__13J3DDeformDataFP15J3DVertexBuffer */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J3DDeformData::deform(J3DVertexBuffer* param_0) { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DCluster/deform__13J3DDeformDataFP15J3DVertexBuffer.s" +void J3DDeformData::deform(J3DVertexBuffer* buffer) { + J3D_ASSERT(buffer != NULL); + + buffer->swapVtxPosArrayPointer(); + buffer->swapVtxNrmArrayPointer(); + + for (u16 i = 0; i < mClusterNum; i++) { + mClusterPointer[i].getDeformer()->deform(buffer, i); + } + + DCStoreRangeNoSync(buffer->getVtxPosArrayPointer(0), + buffer->getVertexData()->getVtxNum() * sizeof(Vec)); + DCStoreRangeNoSync(buffer->getVtxNrmArrayPointer(0), + buffer->getVertexData()->getNrmNum() * sizeof(Vec)); + PPCSync(); + + buffer->setCurrentVtxPos(buffer->getVtxPosArrayPointer(0)); + buffer->setCurrentVtxNrm(buffer->getVtxNrmArrayPointer(0)); } -#pragma pop /* 8032E364-8032E39C 328CA4 0038+00 0/0 1/1 0/0 .text setAnm__13J3DDeformDataFP13J3DAnmCluster */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J3DDeformData::setAnm(J3DAnmCluster* param_0) { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DCluster/setAnm__13J3DDeformDataFP13J3DAnmCluster.s" +void J3DDeformData::setAnm(J3DAnmCluster* anm) { + for (u16 i = 0; i < mClusterNum; i++) { + mClusterPointer[i].getDeformer()->setAnmCluster(anm); + } } -#pragma pop /* 8032E39C-8032E3BC 328CDC 0020+00 0/0 1/1 0/0 .text __ct__11J3DDeformerFP13J3DDeformData */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm J3DDeformer::J3DDeformer(J3DDeformData* param_0) { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DCluster/__ct__11J3DDeformerFP13J3DDeformData.s" +J3DDeformer::J3DDeformer(J3DDeformData* data) { + mDeformData = data; + mAnmCluster = NULL; + field_0x8 = NULL; + field_0xc = NULL; + mFlags = 3; } -#pragma pop /* 8032E3BC-8032E4A4 328CFC 00E8+00 1/1 0/0 0/0 .text deform__11J3DDeformerFP15J3DVertexBufferUs */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J3DDeformer::deform(J3DVertexBuffer* param_0, u16 param_1) { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DCluster/deform__11J3DDeformerFP15J3DVertexBufferUs.s" +void J3DDeformer::deform(J3DVertexBuffer* buffer, u16 param_1) { + J3D_ASSERT(buffer != 0); + + u16 var_r31 = 0; + if (mAnmCluster != NULL) { + for (u16 i = 0; i < param_1; i++) { + var_r31 += mDeformData->getClusterPointer(i)->mKeyNum; + } + + u16 num = mDeformData->getClusterPointer(param_1)->mKeyNum; + for (u16 i = 0; i < num; i++) { + field_0x8[i] = mAnmCluster->getWeight(var_r31++); + } + + deform(buffer, param_1, field_0x8); + } } -#pragma pop /* ############################################################################################## */ /* 80456470-80456474 004A70 0004+00 2/2 0/0 0/0 .sdata2 @830 */ diff --git a/libs/JSystem/J3DGraphAnimator/J3DJoint.cpp b/libs/JSystem/J3DGraphAnimator/J3DJoint.cpp index a67100907a8..6cd22cdc44f 100644 --- a/libs/JSystem/J3DGraphAnimator/J3DJoint.cpp +++ b/libs/JSystem/J3DGraphAnimator/J3DJoint.cpp @@ -1,34 +1,12 @@ -// -// Generated By: dol2asm -// Translation Unit: J3DJoint -// - #include "JSystem/J3DGraphAnimator/J3DJoint.h" -#include "JSystem/J3DGraphAnimator/J3DModel.h" #include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h" +#include "JSystem/J3DGraphAnimator/J3DModel.h" #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" #include "JSystem/JMath/JMath.h" #include "dol2asm.h" -#include "dolphin/types.h" #include "m_Do/m_Do_mtx.h" -// -// Types: -// - -// -// Forward References: -// - -// -// External References: -// - -// -// Declarations: -// - /* 8032EC28-8032ECAC 329568 0084+00 0/0 1/1 0/0 .text * init__25J3DMtxCalcJ3DSysInitBasicFRC3VecRA3_A4_Cf */ void J3DMtxCalcJ3DSysInitBasic::init(Vec const& scale, Mtx const& mtx) { @@ -181,7 +159,7 @@ void J3DJoint::appendChild(J3DJoint* pChild) { #pragma push #pragma force_active on /* dead data */ -SECTION_DEAD static u32 const pad_803A2080[2] = {0,0}; +SECTION_DEAD static u32 const pad_803A2080[2] = {0, 0}; #pragma pop /* 8032F170-8032F254 329AB0 00E4+00 0/0 1/1 0/0 .text __ct__8J3DJointFv */ @@ -210,12 +188,13 @@ void J3DJoint::entryIn() { MtxP anmMtx = j3dSys.getModel()->i_getAnmMtx(mJntNo); j3dSys.getDrawBuffer(0)->setZMtx(anmMtx); j3dSys.getDrawBuffer(1)->setZMtx(anmMtx); - for (J3DMaterial* mesh = mMesh; mesh != NULL; ) { + for (J3DMaterial* mesh = mMesh; mesh != NULL;) { if (mesh->getShape()->checkFlag(1)) { mesh = mesh->getNext(); } else { J3DMatPacket* matPacket = j3dSys.getModel()->getMatPacket(mesh->getIndex()); - J3DShapePacket* shapePacket = j3dSys.getModel()->getShapePacket(mesh->getShape()->getIndex()); + J3DShapePacket* shapePacket = + j3dSys.getModel()->getShapePacket(mesh->getShape()->getIndex()); if (!matPacket->isLocked()) { if (mesh->getMaterialAnm()) { J3DMaterialAnm* piVar8 = mesh->getMaterialAnm(); @@ -276,7 +255,7 @@ void J3DJoint::recursiveCalc() { child->recursiveCalc(); } mDoMtx_copy(prevCurrentMtx, J3DSys::mCurrentMtx); - + J3DSys::mCurrentS.x = currentX; J3DSys::mCurrentS.y = currentY; J3DSys::mCurrentS.z = currentZ; diff --git a/libs/JSystem/J3DGraphAnimator/J3DJointTree.cpp b/libs/JSystem/J3DGraphAnimator/J3DJointTree.cpp index f2a6d16ef5f..f93a6a9703c 100644 --- a/libs/JSystem/J3DGraphAnimator/J3DJointTree.cpp +++ b/libs/JSystem/J3DGraphAnimator/J3DJointTree.cpp @@ -1,13 +1,7 @@ -// -// Generated By: dol2asm -// Translation Unit: J3DJointTree -// - #include "JSystem/J3DGraphAnimator/J3DJointTree.h" #include "JSystem/J3DGraphAnimator/J3DMaterialAttach.h" #include "JSystem/J3DGraphAnimator/J3DShapeTable.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" -#include "dolphin/types.h" /* 80325A18-80325A9C 320358 0084+00 0/0 1/1 0/0 .text __ct__12J3DJointTreeFv */ J3DJointTree::J3DJointTree() diff --git a/libs/JSystem/J3DGraphAnimator/J3DMaterialAttach.cpp b/libs/JSystem/J3DGraphAnimator/J3DMaterialAttach.cpp index 97a8bc6dae6..728ea33ad93 100644 --- a/libs/JSystem/J3DGraphAnimator/J3DMaterialAttach.cpp +++ b/libs/JSystem/J3DGraphAnimator/J3DMaterialAttach.cpp @@ -111,6 +111,29 @@ int J3DMaterialTable::removeMatColorAnimator(J3DAnmColor* pAnmColor) { /* 8032F6F8-8032F7B4 32A038 00BC+00 0/0 5/5 10/10 .text * removeTexNoAnimator__16J3DMaterialTableFP16J3DAnmTexPattern */ +// regalloc +#ifdef NONMATCHING +int J3DMaterialTable::removeTexNoAnimator(J3DAnmTexPattern* anm) { + int ret = 0; + u16 materialNum = anm->getUpdateMaterialNum(); + J3DAnmTexPatternFullTable* anm_table = anm->getAnmTable(); + + for (u16 i = 0; i < materialNum; i++) { + if (anm->isValidUpdateMaterialID(i)) { + u16 materialID = anm->getUpdateMaterialID(i); + + J3DMaterialAnm* pMatAnm = getMaterialNodePointer(materialID)->getMaterialAnm(); + u8 texNo = anm_table[i].mTexNo; + if (pMatAnm == NULL) + ret = 1; + else + pMatAnm->setTexNoAnm(texNo, NULL); + } + } + + return ret; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -119,6 +142,7 @@ asm int J3DMaterialTable::removeTexNoAnimator(J3DAnmTexPattern* param_0) { #include "asm/JSystem/J3DGraphAnimator/J3DMaterialAttach/removeTexNoAnimator__16J3DMaterialTableFP16J3DAnmTexPattern.s" } #pragma pop +#endif /* 8032F7B4-8032F880 32A0F4 00CC+00 0/0 4/4 26/26 .text * removeTexMtxAnimator__16J3DMaterialTableFP19J3DAnmTextureSRTKey */ diff --git a/libs/JSystem/JMath/JMath.cpp b/libs/JSystem/JMath/JMath.cpp index aec17e65f8d..0ce312a5a32 100644 --- a/libs/JSystem/JMath/JMath.cpp +++ b/libs/JSystem/JMath/JMath.cpp @@ -40,7 +40,7 @@ void JMAEulerToQuat(s16 x, s16 y, s16 z, Quaternion* quat) { f32 cyz = cosY * cosZ; f32 syz = sinY * sinZ; quat->w = cosX * (cyz) + sinX * (syz); - quat->x = sinX * (cyz) - cosX * (syz); + quat->x = sinX * (cyz)-cosX * (syz); quat->y = cosZ * (cosX * sinY) + sinZ * (sinX * cosY); quat->z = sinZ * (cosX * cosY) - cosZ * (sinX * sinY); } @@ -61,8 +61,10 @@ void JMAQuatLerp(register const Quaternion* p, register const Quaternion* q, f32 Quaternion* dst) { register f32 pxy, pzw, qxy, qzw; register f32 dp; - __asm // compute dot product - { + +#ifdef __MWERKS__ // clang-format off + // compute dot product + asm { psq_l pxy, 0(p), 0, 0 psq_l qxy, 0(q), 0, 0 ps_mul dp, pxy, qxy @@ -73,14 +75,14 @@ void JMAQuatLerp(register const Quaternion* p, register const Quaternion* q, f32 ps_sum0 dp, dp, dp, dp } +#endif // clang-format on if (dp < 0.0) { dst->x = -t * (p->x + q->x) + p->x; dst->y = -t * (p->y + q->y) + p->y; dst->z = -t * (p->z + q->z) + p->z; dst->w = -t * (p->w + q->w) + p->w; - } - else { + } else { dst->x = -t * (p->x - q->x) + p->x; dst->y = -t * (p->y - q->y) + p->y; dst->z = -t * (p->z - q->z) + p->z; @@ -90,42 +92,78 @@ void JMAQuatLerp(register const Quaternion* p, register const Quaternion* q, f32 /* 80339A30-80339A5C 334370 002C+00 0/0 1/1 0/0 .text JMAFastVECNormalize__FPC3VecP3Vec */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JMAFastVECNormalize(Vec const* param_0, Vec* param_1) { - nofralloc -#include "asm/JSystem/JMath/JMath/JMAFastVECNormalize__FPC3VecP3Vec.s" +void JMAFastVECNormalize(register const Vec* src, register Vec* dst) { + register f32 vxy, rxy, vz, length; +#ifdef __MWERKS__ // clang-format off + asm { + psq_l vxy, 0(src), 0, 0 + ps_mul rxy, vxy, vxy + lfs vz, src->z + ps_madd length, vz, vz, rxy + ps_sum0 length, length, rxy, rxy + frsqrte length, length + ps_muls0 vxy, vxy, length; + psq_st vxy, 0(dst), 0, 0 + fmuls vz, vz, length + stfs vz, dst->z + } +#endif // clang-format on } -#pragma pop /* 80339A5C-80339A84 33439C 0028+00 0/0 1/1 0/0 .text JMAVECScaleAdd__FPC3VecPC3VecP3Vecf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JMAVECScaleAdd(Vec const* param_0, Vec const* param_1, Vec* param_2, f32 param_3) { - nofralloc -#include "asm/JSystem/JMath/JMath/JMAVECScaleAdd__FPC3VecPC3VecP3Vecf.s" -} -#pragma pop +void JMAVECScaleAdd(register const Vec* vec1, register const Vec* vec2, register Vec* dst, + register f32 scale) { + register f32 v1xy; + register f32 v2xy = scale; + register f32 rxy, v1z, v2z, rz; +#ifdef __MWERKS__ // clang-format off + asm { + psq_l v1xy, 0(vec1), 0, 0 + psq_l v2xy, 0(vec2), 0, 0 + ps_madds0 rxy, v1xy, scale, v2xy + psq_st rxy, 0(dst), 0, 0 -/* ############################################################################################## */ -/* 804564D0-804564D8 004AD0 0004+04 1/1 0/0 0/0 .sdata2 @411 */ -SECTION_SDATA2 static f32 lit_411[1 + 1 /* padding */] = { - 1.0f, - /* padding */ - 0.0f, -}; + psq_l v1z, 8(vec1), 1, 0 + psq_l v2z, 8(vec2), 1, 0 + ps_madds0 rz, v1z, scale, v2z + psq_st rz, 8(dst), 1, 0 + } +#endif // clang-format on +} /* 80339A84-80339AE4 3343C4 0060+00 0/0 5/5 0/0 .text JMAMTXApplyScale__FPA4_CfPA4_ffff */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JMAMTXApplyScale(f32 const (*param_0)[4], f32 (*param_1)[4], f32 param_2, f32 param_3, - f32 param_4) { - nofralloc -#include "asm/JSystem/JMath/JMath/JMAMTXApplyScale__FPA4_CfPA4_ffff.s" +void JMAMTXApplyScale(register const Mtx src, register Mtx dst, register f32 xScale, + register f32 yScale, register f32 zScale) { + register f32 scale = yScale; + register f32 x, y, z; + register f32 normal = 1.0f; +#ifdef __MWERKS__ // clang-format off + asm { + // scale first 2 components + ps_merge00 scale, xScale, scale + psq_l x, 0(src), 0, 0 + psq_l y, 16(src), 0, 0 + psq_l z, 32(src), 0, 0 + ps_mul x, x, scale + ps_mul y, y, scale + ps_mul z, z, scale + psq_st x, 0(dst), 0, 0 + psq_st y, 16(dst), 0, 0 + psq_st z, 32(dst), 0, 0 + + // scale last 2 components + ps_merge00 scale, zScale, normal + psq_l x, 8(src), 0, 0 + psq_l y, 24(src), 0, 0 + psq_l z, 40(src), 0, 0 + ps_mul x, x, scale + ps_mul y, y, scale + ps_mul z, z, scale + psq_st x, 8(dst), 0, 0 + psq_st y, 24(dst), 0, 0 + psq_st z, 40(dst), 0, 0 + } +#endif // clang-format on } -#pragma pop diff --git a/obj_files.mk b/obj_files.mk index ef2ca4c1725..560dcff04cb 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -1050,6 +1050,7 @@ O_FILES_SYM_ON := \ $(BUILD_DIR)/libs/JSystem/JUtility/JUTResFont.o \ $(BUILD_DIR)/libs/JSystem/JAudio2/JAUAudioArcLoader.o \ $(BUILD_DIR)/libs/JSystem/J2DGraph/J2DAnmLoader.o \ + $(BUILD_DIR)/libs/JSystem/J2DGraph/J2DPicture.o \ $(BUILD_DIR)/libs/JSystem/JUtility/JUTProcBar.o \ $(BUILD_DIR)/libs/Z2AudioLib/Z2AudioArcLoader.o \ $(BUILD_DIR)/src/c/c_dylink.o \ diff --git a/rel/d/a/d_a_mirror/d_a_mirror.cpp b/rel/d/a/d_a_mirror/d_a_mirror.cpp index f0d850cc34e..c750cc48119 100644 --- a/rel/d/a/d_a_mirror/d_a_mirror.cpp +++ b/rel/d/a/d_a_mirror/d_a_mirror.cpp @@ -249,10 +249,6 @@ SECTION_RODATA static f32 const lit_3948 = -100.0f; COMPILER_STRIP_GATE(0x808725A4, &lit_3948); #pragma pop -inline static void GXSetTexCoordGen(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 mtx) { - GXSetTexCoordGen2(dst, type, src, mtx, 0, 125); -} - inline static void damirror_GXEnd() { GXEnd(); } diff --git a/rel/d/a/d_a_movie_player/d_a_movie_player.cpp b/rel/d/a/d_a_movie_player/d_a_movie_player.cpp index 707b4eecf81..2ca00a3e6bb 100644 --- a/rel/d/a/d_a_movie_player/d_a_movie_player.cpp +++ b/rel/d/a/d_a_movie_player/d_a_movie_player.cpp @@ -129,7 +129,7 @@ extern "C" static void daMP_AudioDecodeThreadStart__Fv(); extern "C" static void daMP_AudioDecodeThreadCancel__Fv(); extern "C" static void daMP_THPGXRestore__Fv(); extern "C" static void daMP_THPGXYuv2RgbSetup__FPC16_GXRenderModeObj(); -extern "C" static void GXSetTexCoordGen(); +extern "C" static void i_GXSetTexCoordGen(); extern "C" static void daMP_THPGXYuv2RgbDraw__FPUcPUcPUcssssss(); extern "C" static void i_GXTexCoord2u16(); extern "C" static void daMP_MixAudio__FPsPsUl(); @@ -1315,7 +1315,7 @@ static asm void daMP_THPGXYuv2RgbSetup(_GXRenderModeObj const* param_0) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void GXSetTexCoordGen() { +static asm void i_GXSetTexCoordGen() { nofralloc #include "asm/rel/d/a/d_a_movie_player/d_a_movie_player/GXSetTexCoordGen.s" } diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 0c7cbbda028..6efa2a58010 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -187,10 +187,6 @@ public: /* 0x3c */ dDlst_shadowPoly_c* mPoly; }; -static inline void GXSetTexCoordGen(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 mtx) { - GXSetTexCoordGen2(dst, type, src, mtx, GX_FALSE, GX_PTIDENTITY); -} - // // Forward References: // diff --git a/src/f_op/f_op_msg_mng.cpp b/src/f_op/f_op_msg_mng.cpp index 5c955e7a625..67f287dd590 100644 --- a/src/f_op/f_op_msg_mng.cpp +++ b/src/f_op/f_op_msg_mng.cpp @@ -406,7 +406,7 @@ void J2DPicture::setBlendRatio(f32 param_0, f32 param_1) { /* 80020338-80020368 01AC78 0030+00 0/0 1/0 0/0 .text append__10J2DPictureFPCcf */ bool J2DPicture::append(char const* param_0, f32 param_1) { - return insert(param_0, mTextureCount, param_1); + return insert(param_0, mTextureNum, param_1); } /* 80020368-8002039C 01ACA8 0034+00 0/0 1/0 0/0 .text insert__10J2DPictureFPCcUcf */ diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 645a1d674fe..734761deac2 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -929,10 +929,6 @@ SECTION_SDATA2 static f64 lit_4595 = 4503599627370496.0 /* cast u32 to float */; /* 80456B60-80456B68 000000 0004+04 1/1 0/0 0/0 .sbss2 @4530 */ SECTION_SBSS2 static GXColor lit_4530; -static inline void GXSetTexCoordGen(GXTexCoordID param_1, GXTexGenType param_2, GXTexGenSrc param_3, u32 param_4){ - GXSetTexCoordGen2(param_1, param_2, param_3, param_4, GX_FALSE, 0x7d); -} - /* 80009650-8000A160 003F90 0B10+00 1/1 0/0 0/0 .text draw__Q213mDoGph_gInf_c7bloom_cFv */ // Matches with literals