diff --git a/include/JSystem/JParticle/JPADraw.h b/include/JSystem/JParticle/JPADraw.h new file mode 100644 index 000000000..505b8566d --- /dev/null +++ b/include/JSystem/JParticle/JPADraw.h @@ -0,0 +1,80 @@ +#ifndef JPADRAW_H +#define JPADRAW_H + +#include "dolphin/types.h" +#include "dolphin/gx/GXStruct.h" +#include "dolphin/gx/GXEnum.h" +#include "JSystem/JParticle/JPAParticle.h" + +class JPABaseShapeArc; +class JPAExtraShapeArc; +class JPASweepShapeArc; +class JPAExTexShapeArc; +class JPATextureResource; + +class JPADraw; +class JPADrawExecEmitterVisitor; +class JPADrawExecParticleVisitor; + +class JPADrawContext { + /* 0x00 */ JPABaseEmitter* mpBaseEmitter; + /* 0x04 */ JPABaseShapeArc* mpBaseArc; + /* 0x08 */ JPAExtraShapeArc* mpExtraArc; + /* 0x0C */ JPASweepShapeArc* mpSweepArc; + /* 0x10 */ JPAExTexShapeArc* mpExTexShape; + /* 0x14 */ JPADraw* mpDraw; + /* 0x18 */ JSUPtrList* mpActiveParticles; + /* 0x1C */ JPATextureResource* mpTextureResource; + /* 0x20 */ s16* mpTexIdxArray; +}; + +class JPADraw { +public: + enum JPADrawVisitorDefFlags {}; + + void initialize(JPABaseEmitter*, JPATextureResource*); + void draw(float(*)[4]); + void calc(); + void calcParticle(JPABaseParticle*); + void calcChild(JPABaseParticle*); + void initParticle(JPABaseParticle*); + void initChild(JPABaseParticle*, JPABaseParticle*); + void loadTexture(unsigned char, _GXTexMapID); + void setDrawExecVisitorsBeforeCB(const JPADraw::JPADrawVisitorDefFlags&); + void setDrawExecVisitorsAfterCB(const JPADraw::JPADrawVisitorDefFlags&); + void setDrawCalcVisitors(const JPADraw::JPADrawVisitorDefFlags&); + void setParticleClipBoard(); + void setChildClipBoard(); + void drawParticle(); + void drawChild(); + void zDraw(); + void zDrawParticle(); + void zDrawChild(); + void loadYBBMtx(float(*)[4]); + + /* 0x00 */ JPADrawExecEmitterVisitor* mpExecEmtrVis[1]; + /* 0x04 */ JPADrawExecEmitterVisitor* mpExecEmtrPVis[5]; + /* 0x18 */ JPADrawExecEmitterVisitor* mpExecEmtrCVis[3]; + /* 0x24 */ JPADrawExecParticleVisitor* mpCalcEmtrVis[4]; + /* 0x34 */ JPADrawExecParticleVisitor* mpExecPtclVis[5]; + /* 0x48 */ JPADrawExecParticleVisitor* mpCalcPtclVis[10]; + /* 0x70 */ JPADrawExecParticleVisitor* mpExecChldVis[4]; + /* 0x80 */ JPADrawExecParticleVisitor* mpCalcChldVis[2]; + /* 0x88 */ u8 mExecEmtrVisNum; + /* 0x89 */ u8 mExecEmtrPVisNum; + /* 0x8A */ u8 mExecEmtrCVisNum; + /* 0x8B */ u8 mCalcEmtrVisNum; + /* 0x8C */ u8 mExecPtclVisNum; + /* 0x8D */ u8 mCalcPtclVisNum; + /* 0x8E */ u8 mExecChldVisNum; + /* 0x8F */ u8 mCalcChldVisNum; + /* 0x90 */ JPADrawContext mDrawContext; + /* 0xB4 */ f32 mScaleOut; + /* 0xB8 */ _GXColor mPrmColor; + /* 0xBC */ _GXColor mEnvColor; + /* 0xC0 */ s16 mTexIdx; + /* 0xC2 */ u8 field_0xc2; + /* 0xC3 */ u8 field_0xC3[0xC4 - 0xC3]; +}; + +#endif /* JPADRAW_H */ diff --git a/include/JSystem/JParticle/JPAEmitter.h b/include/JSystem/JParticle/JPAEmitter.h new file mode 100644 index 000000000..2d95efb20 --- /dev/null +++ b/include/JSystem/JParticle/JPAEmitter.h @@ -0,0 +1,113 @@ +#ifndef JPAEMITTER_H +#define JPAEMITTER_H + +#include "JSystem/JParticle/JPADraw.h" +#include "JSystem/JParticle/JPAField.h" +#include "JSystem/JParticle/JPAMath.h" +#include "JSystem/JSupport/JSUList.h" +#include "JSystem/JMath/random.h" +#include "JSystem/JGeometry.h" +#include "SSystem/SComponent/c_xyz.h" +#include "SSystem/SComponent/c_sxyz.h" +#include "dolphin/gx/GXStruct.h" +#include "dolphin/mtx/mtx.h" + +class JPACallBackBase; +class JPACallBackBase2; +class JPADataBlockLinkInfo; + +class JPABaseEmitter { +public: + typedef void (JPABaseEmitter::*VolumeFunc)(); + + void calcVolumePoint(); + void calcVolumeLine(); + void calcVolumeCircle(); + void calcVolumeCube(); + void calcVolumeSphere(); + void calcVolumeCylinder(); + void calcVolumeTorus(); + void create(JPADataBlockLinkInfo*); + void calcEmitterInfo(); + void calc(); + void calcCreatePtcls(); + void createChildren(JPABaseParticle*); + void createParticle(); + void calcParticle(); + void calcChild(); + void calcKey(); + void deleteParticle(JPABaseParticle*, JSUList*); + void deleteAllParticle(); + void getPtclFromVacList(); + void doStartFrameProcess(); + void doTerminationProcess(); + void calcEmitterGlobalPosition(JGeometry::TVec3&); + void calcgReRDirection(); + void getPivotX(); + void getPivotY(); + + u8 getGlobalAlpha() { return mGlobalPrmColor.a; } + void setGlobalAlpha(u8 alpha) { mGlobalPrmColor.a = alpha; } + void setGlobalRTMatrix(MtxP mtx) { + JPASetRMtxTVecfromMtx(mtx, mGlobalRotation, mGlobalTranslation); + } + + /* 0x000 */ VolumeFunc mVolumeFunc; + /* 0x00C */ cXyz mEmitterScale; + /* 0x018 */ cXyz mEmitterTranslation; + /* 0x024 */ csXyz mEmitterRot; + /* 0x02A */ u8 mVolumeType; + /* 0x02B */ u8 mRateStep; + /* 0x02C */ cXyz mEmitterDir; + /* 0x038 */ f32 mRate; + /* 0x03C */ f32 mRateRndm; + /* 0x040 */ f32 mAccel; + /* 0x044 */ f32 mAccelRndm; + /* 0x048 */ f32 mAirResist; + /* 0x04C */ f32 mAirResistRndm; + /* 0x050 */ f32 mMoment; + /* 0x054 */ f32 mMomentRndm; + /* 0x058 */ f32 mLifeTimeRndm; + /* 0x05C */ f32 mSpread; + /* 0x060 */ s32 mMaxFrame; + /* 0x064 */ s16 mLifeTime; + /* 0x066 */ s16 mStartFrame; + /* 0x068 */ s16 mVolumeSize; + /* 0x06A */ s16 mDivNumber; + /* 0x06C */ f32 mInitialVelOmni; + /* 0x070 */ f32 mInitialVelAxis; + /* 0x074 */ f32 mInitialVelDir; + /* 0x078 */ f32 mInitialVelRndm; + /* 0x07C */ f32 mInitialVelRatio; + /* 0x080 */ f32 mVolumeSweep; + /* 0x084 */ f32 mVolumeMinRad; + /* 0x088 */ s32 mDataFlag; + /* 0x08C */ s32 mUseKeyFlag; + /* 0x090 */ JSUPtrLink mLink; + /* 0x0A0 */ JPADraw mDraw; + /* 0x164 */ f32 mTick; + /* 0x168 */ f32 mTime; + /* 0x16C */ JPAFieldManager mFieldManager; + /* 0x17C */ JSUPtrList mActiveParticles; + /* 0x188 */ JSUPtrList mChildParticles; + /* 0x194 */ JSUPtrList* mpPtclVacList; + /* 0x198 */ JPADataBlockLinkInfo* mpDataLinkInfo; + /* 0x19C */ JPACallBackBase* mpEmitterCallBack; + /* 0x1A0 */ JPACallBackBase2* mpParticleCallBack; + /* 0x1A4 */ JMath::TRandom_fast_ mRandomSeed; + /* 0x1A8 */ Mtx mGlobalRotation; + /* 0x1D8 */ JGeometry::TVec3 mGlobalScale; + /* 0x1E4 */ JGeometry::TVec3 mGlobalTranslation; + /* 0x1F0 */ JGeometry::TVec3 mGlobalScale2D; + /* 0x1FC */ _GXColor mGlobalPrmColor; + /* 0x200 */ _GXColor mGlobalEnvColor; + /* 0x204 */ f32 mEmitCount; + /* 0x208 */ f32 mRateStepTimer; + /* 0x20C */ u32 mFlags; + /* 0x210 */ u32 mUserData; + /* 0x214 */ u8 mGroupID; + /* 0x215 */ u8 mResMgrID; + /* 0x216 */ u8 field_0x216[0x218 - 0x216]; +}; + +#endif /* JPAEMITTER_H */ diff --git a/include/JSystem/JParticle/JPAField.h b/include/JSystem/JParticle/JPAField.h new file mode 100644 index 000000000..12e5d612b --- /dev/null +++ b/include/JSystem/JParticle/JPAField.h @@ -0,0 +1,23 @@ +#ifndef JPAFIELD_H +#define JPAFIELD_H + +#include "JSystem/JParticle/JPAParticle.h" + +class JPADataBlockLinkInfo; +class JPAEmitterInfo; +class JPAFieldData; + +class JPAFieldManager { +public: + void initField(JPADataBlockLinkInfo*, JPAEmitterInfo*); + void init(JPABaseParticle*); + void preCalc(); + void calc(JPABaseParticle*); + void deleteField(JPAFieldData*); + void deleteAllField(); + + /* 0x00 */ JSUPtrList mList; + /* 0x0C */ JSUPtrList* field_0x0c; +}; + +#endif /* JPAFIELD_H */ diff --git a/include/JSystem/JParticle/JPAMath.h b/include/JSystem/JParticle/JPAMath.h new file mode 100644 index 000000000..93bf3b3f8 --- /dev/null +++ b/include/JSystem/JParticle/JPAMath.h @@ -0,0 +1,16 @@ +#ifndef JPAMATH_H +#define JPAMATH_H + +#include "JSystem/JGeometry.h" +#include "dolphin/types.h" + +void JPAGetYZRotateMtx(short, short, float(*)[4]); +void JPAGetXYZRotateMtx(short, short, short, float(*)[4]); +void JPAGetDirMtx(const JGeometry::TVec3&, float(*)[4]); +void JPASetSVecfromMtx(float(*)[4], JGeometry::TVec3&); +void JPASetRMtxTVecfromMtx(float(*)[4], float(*)[4], JGeometry::TVec3&); +void JPASetRMtxSTVecfromMtx(float(*)[4], float(*)[4], JGeometry::TVec3&, JGeometry::TVec3&); +void JPAGetKeyFrameValue(float, unsigned short, const float*); +void JPAGetUnitVec(short, short, JGeometry::TVec3&); + +#endif /* JPAMATH_H */ diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index f5d27db73..64f0054fb 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -405,6 +405,10 @@ inline u8 dComIfGs_getWalletSize() { return g_dComIfG_gameInfo.save.getPlayer().getPlayerStatusA().getWalletSize(); } +inline u8 dComIfGs_getMagic() { + return g_dComIfG_gameInfo.save.getPlayer().getPlayerStatusA().getMagic(); +} + inline u8 dComIfGs_getItem(int param_0) { return g_dComIfG_gameInfo.save.getPlayer().getItem().getItem(param_0); } @@ -1101,8 +1105,8 @@ inline JPABaseEmitter* dComIfGp_particle_set(u16 particleID, const cXyz* pos, co const GXColor* pPrmColor, const GXColor* pEnvColor, const cXyz* pScale2D) { dPa_control_c* pParticle = g_dComIfG_gameInfo.play.getParticle(); - return pParticle->set(0, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, - pEnvColor, pScale2D); + return pParticle->setNormal(particleID, pos, angle, scale, alpha, pCallBack, setupInfo, + pPrmColor, pEnvColor, pScale2D); } inline JPABaseEmitter* dComIfGp_particle_set(u16 particleID, const cXyz* pos, const csXyz* angle, @@ -1115,6 +1119,16 @@ inline void dComIfGp_particle_setStripes(u16 particleID, cXyz* pos, csXyz* angle pParticle->setNormalStripes(particleID, pos, angle, scale, param_4, param_5); } +inline JPABaseEmitter* dComIfGp_particle_setToon(u16 particleID, const cXyz* pos, + const csXyz* angle, const cXyz* scale, u8 alpha, + dPa_levelEcallBack* pCallBack, s8 setupInfo, + const GXColor* pPrmColor, const GXColor* pEnvColor, + const cXyz* pScale2D) { + dPa_control_c* pParticle = g_dComIfG_gameInfo.play.getParticle(); + return pParticle->setToon(particleID, pos, angle, scale, alpha, pCallBack, setupInfo, + pPrmColor, pEnvColor, pScale2D); +} + inline void dComIfGp_particle_calc3D() { g_dComIfG_gameInfo.play.getParticle()->calc3D(); } diff --git a/include/d/d_particle.h b/include/d/d_particle.h index a847e869f..5d3713edf 100644 --- a/include/d/d_particle.h +++ b/include/d/d_particle.h @@ -4,6 +4,7 @@ #include "JSystem/J3DGraphBase/J3DVertex.h" #include "JSystem/JGeometry.h" #include "JSystem/JParticle/JPAParticle.h" +#include "JSystem/JParticle/JPAEmitter.h" #include "f_pc/f_pc_node.h" class mDoDvdThd_toMainRam_c; @@ -14,6 +15,7 @@ class JPADrawInfo; class JKRHeap; class JPABaseEmitter; class JPAEmitterManager; +class J3DModelData; struct csXyz; class dPa_simpleData_c { @@ -27,11 +29,54 @@ public: /* 0x13 */ u8 mbAffectedByWind; }; -class dPa_levelEcallBack { +class JPACallBackBase { +public: + JPACallBackBase(); + virtual ~JPACallBackBase(); + + virtual void init(JPABaseEmitter*); + virtual void execute(JPABaseEmitter*); + virtual void executeAfter(JPABaseEmitter*); + virtual void draw(JPABaseEmitter*); +}; + +class dPa_levelEcallBack : public JPACallBackBase { public: virtual ~dPa_levelEcallBack() {} }; +class dPa_followEcallBack : public dPa_levelEcallBack { +public: + virtual ~dPa_followEcallBack(); + + virtual void execute(JPABaseEmitter*); + virtual void draw(JPABaseEmitter*); + virtual void setup(JPABaseEmitter*, cXyz const*, csXyz const*, s8); + virtual void end(); + + JPABaseEmitter* getEmitter() { return mpEmitter; } + + /* 0x04 */ JPABaseEmitter* mpEmitter; + /* 0x08 */ u8 field_0x08[0x10 - 0x08]; + /* 0x10 */ u8 field_0x10; + /* 0x11 */ u8 field_0x11; + /* 0x12 */ u8 field_0x12; + /* 0x13 */ u8 field_0x13; +}; + +STATIC_ASSERT(sizeof(dPa_followEcallBack) == 0x14); + +class dPa_smokeEcallBack : dPa_followEcallBack { +public: + /* 0x14 */ s8 field_0x14; + /* 0x15 */ u8 field_0x15; + /* 0x16 */ _GXColor field_0x16; + /* 0x1A */ u8 field_0x1A[0x1C - 0x1A]; + /* 0x1C */ dKy_tevstr_c* mTevstr; +}; + +STATIC_ASSERT(sizeof(dPa_smokeEcallBack) == 0x20); + class dPa_simpleEcallBack { public: dPa_simpleEcallBack(); @@ -200,6 +245,19 @@ public: void setSimple(u16, cXyz const*, u8, GXColor const&, GXColor const&, int); void getSimple(u16); + JPABaseEmitter* setNormal(u16 particleID, const cXyz* pos, const csXyz* angle, + const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack, + s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor, + const cXyz* pScale2D) { + return set(0, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D); + } + JPABaseEmitter* setToon(u16 particleID, const cXyz* pos, const csXyz* angle, + const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack, + s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor, + const cXyz* pScale2D) { + return set(1, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D); + } + void drawModelParticle() { mModelCtrl->draw(); } /* 0x0000 */ JKRHeap* mpHeap; diff --git a/include/d/d_save.h b/include/d/d_save.h index ba742e81c..22cffd4d6 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -8,9 +8,9 @@ class dSv_player_status_a_c { public: /* 800589A8 */ void init(); - u8 getSelectItemIndex(int i_no) const { return mSelectItem[i_no]; } - u8 getSelectEquip(int i_no) const { return mSelectEquip[i_no]; } - u8 getWalletSize() const { return mWalletSize; } + u8 getSelectEquip(int i_no) { return mSelectEquip[i_no]; } + u8 getWalletSize() { return mWalletSize; } + u8 getMagic() { return mMagic; } /* 0x00 */ u16 mMaxLife; /* 0x02 */ u16 mLife;