diff --git a/include/JSystem/JStage/JSGLight.h b/include/JSystem/JStage/JSGLight.h index 91ef3d922..77a6193a9 100644 --- a/include/JSystem/JStage/JSGLight.h +++ b/include/JSystem/JStage/JSGLight.h @@ -6,7 +6,9 @@ #include "dolphin/gx/GXStruct.h" namespace JStage { - enum TELight {}; + enum TELight { + kLightMax = 0xFFFFFFFF, + }; struct TLight : public TObject { virtual ~TLight() = 0; diff --git a/include/JSystem/JStage/JSGSystem.h b/include/JSystem/JStage/JSGSystem.h index f08b2ca8f..9b060f89e 100644 --- a/include/JSystem/JStage/JSGSystem.h +++ b/include/JSystem/JStage/JSGSystem.h @@ -17,7 +17,7 @@ namespace JStage { struct TSystem : public TObject { virtual ~TSystem() = 0; virtual s32 JSGFGetType() const; - virtual bool JSGFindObject(char const*, JStage::TEObject) const; + virtual void* JSGFindObject(char const*, JStage::TEObject) const; virtual bool JSGCreateObject(char const*, JStage::TEObject, u32); virtual void JSGDestroyObject(JStage::TObject*); virtual bool JSGGetSystemData(u32); diff --git a/include/d/d_demo.h b/include/d/d_demo.h index 0fbbe19c8..eaeaeaaa0 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -8,24 +8,39 @@ #include "JSystem/JStage/JSGFog.h" #include "JSystem/JStage/JSGLight.h" #include "JSystem/JStage/JSGSystem.h" +#include "SSystem/SComponent/c_math.h" #include "SSystem/SComponent/c_xyz.h" #include "SSystem/SComponent/c_sxyz.h" #include "JSystem/J3DGraphAnimator/J3DModel.h" +#include "JSystem/J3DGraphAnimator/J3DModelData.h" +#include "JSystem/JUtility/JUTAssert.h" +#include "JSystem/JUtility/JUTNameTab.h" +#include "m_Do/m_Do_mtx.h" class dDemo_system_c; -class TControl; -class dMesg_tControl; +namespace JStudio { + class TControl { + public: + TControl(); + /* 0x00 */ u32 field_0x00[10]; + }; +} +class dMesg_tControl { +public: + dMesg_tControl(); + /* 0x00 */ u32 field_0x00[29]; +}; class fopAc_ac_c; class dDemo_actor_c : public JStage::TActor { public: dDemo_actor_c(); ~dDemo_actor_c(); - void getActor(); + fopAc_ac_c* getActor(); void setActor(fopAc_ac_c*); - void getP_BtpData(const char*); - void getP_BrkData(const char*); - void getP_BtkData(const char*); + void* getP_BtpData(const char*); + void* getP_BrkData(const char*); + void* getP_BtkData(const char*); void getPrm_Morf(); void JSGSetData(u32, const void*, u32); void JSGSetTranslation(const Vec&); @@ -37,13 +52,23 @@ public: void JSGSetAnimationTransition(f32); void JSGSetTextureAnimation(u32); void JSGSetTextureAnimationFrame(f32); - s32 JSGFindNodeID(const char*) const; - int JSGGetNodeTransformation(u32, f32(*)[4]) const; - f32 JSGGetAnimationFrameMax() const; - f32 JSGGetTextureAnimationFrameMax() const; - void JSGGetTranslation(Vec*) const; - void JSGGetScaling(Vec*) const; - void JSGGetRotation(Vec*) const; + s32 JSGFindNodeID(const char* name) const { + JUT_ASSERT(0x4d, mModel != 0); + return mModel->getModelData()->getJointName()->getIndex(name); + } + int JSGGetNodeTransformation(u32 no, Mtx dst) const { + JUT_ASSERT(0x52, mModel != 0); + cMtx_copy(mModel->getAnmMtx((u16)no), dst); + } + f32 JSGGetAnimationFrameMax() const { return mAnimationFrameMax; } + f32 JSGGetTextureAnimationFrameMax() const { return mTexAnimationFrameMax; } + void JSGGetTranslation(Vec* dst) const { *dst = mTranslation; } + void JSGGetScaling(Vec* dst) const { *dst = mScaling; } + void JSGGetRotation(Vec* dst) const { + dst->x = cM_sht2d(mRotation.x); + dst->y = cM_sht2d(mRotation.y); + dst->z = cM_sht2d(mRotation.z); + } bool checkEnable(u16 mask) { return mFlags & mask; } csXyz* getRatate() { return &mRotation; } @@ -81,10 +106,10 @@ public: /* 0x38 */ f32 mAnimationFrameMax; /* 0x3C */ s32 mTexAnimation; /* 0x40 */ f32 mTexAnimationFrame; - /* 0x44 */ void* mTexAnimationFrameMax; - /* 0x48 */ J3DModel* mpModel; + /* 0x44 */ f32 mTexAnimationFrameMax; + /* 0x48 */ J3DModel* mModel; /* 0x4C */ u32 field_0x4c; - /* 0x50 */ void* field_0x50; + /* 0x50 */ const void* field_0x50; /* 0x54 */ u32 field_0x54; /* 0x58 */ s32 mActorPcId; /* 0x5C */ s32 mBckId; @@ -95,7 +120,8 @@ public: class dDemo_camera_c : public JStage::TCamera { public: - ~dDemo_camera_c(); + dDemo_camera_c() { mFlags = 0; } + ~dDemo_camera_c() {} f32 JSGGetProjectionNear() const; void JSGSetProjectionNear(f32); f32 JSGGetProjectionFar() const; @@ -112,32 +138,69 @@ public: void JSGSetViewTargetPosition(const Vec&); f32 JSGGetViewRoll() const; void JSGSetViewRoll(f32); + +private: + /* 0x04 */ u8 mFlags; + /* 0x08 */ f32 mProjNear; + /* 0x0C */ f32 mProjFar; + /* 0x10 */ f32 mFovy; + /* 0x14 */ f32 mAspect; + /* 0x18 */ cXyz mViewPosition; + /* 0x24 */ cXyz mUpVector; + /* 0x30 */ cXyz mTargetPosition; + /* 0x3C */ f32 mRoll; }; class dDemo_ambient_c : public JStage::TAmbientLight { public: - ~dDemo_ambient_c(); - void JSGSetColor(_GXColor); + dDemo_ambient_c() { mFlags = 0; } + ~dDemo_ambient_c() {} + void JSGSetColor(GXColor color); + +private: + /* 0x04 */ u8 mFlags; + /* 0x08 */ GXColor mColor; }; class dDemo_light_c : public JStage::TLight { public: - ~dDemo_light_c(); + dDemo_light_c() { mFlags = 0; } + ~dDemo_light_c() {} void JSGSetLightType(JStage::TELight); void JSGSetPosition(const Vec&); void JSGSetColor(_GXColor); void JSGSetDistanceAttenuation(f32, f32, _GXDistAttnFn); void JSGSetAngleAttenuation(f32, _GXSpotFn); void JSGSetDirection(const Vec&); + +private: + /* 0x04 */ u8 mFlags; + /* 0x08 */ JStage::TELight mLightType; + /* 0x0C */ GXDistAttnFn mAttnFn; + /* 0x10 */ GXSpotFn mSpotFn; + /* 0x14 */ cXyz mPosition; + /* 0x20 */ GXColor mColor; + /* 0x24 */ f32 mDistAttn0; + /* 0x28 */ f32 mDistAttn1; + /* 0x2C */ f32 mAngleAttn; + /* 0x30 */ cXyz mDirection; }; class dDemo_fog_c : public JStage::TFog { public: - ~dDemo_fog_c(); + dDemo_fog_c() { mFlags = 0; } + ~dDemo_fog_c() {} void JSGSetFogFunction(_GXFogType); void JSGSetStartZ(f32); void JSGSetEndZ(f32); void JSGSetColor(_GXColor); + +private: + /* 0x04 */ u8 mFlags; + /* 0x05 */ u8 mFogType; + /* 0x08 */ f32 mStartZ; + /* 0x0C */ f32 mEndZ; + /* 0x10 */ GXColor mColor; }; class dDemo_object_c { @@ -145,13 +208,13 @@ public: dDemo_object_c(); ~dDemo_object_c(); - void appendActor(fopAc_ac_c*); + dDemo_actor_c* appendActor(fopAc_ac_c*); dDemo_actor_c* getActor(u8); - void createCamera(); - void getActiveCamera(); - void createAmbient(); - void appendLight(); - void createFog(); + dDemo_camera_c* createCamera(); + dDemo_camera_c* getActiveCamera(); + dDemo_ambient_c* createAmbient(); + dDemo_light_c* appendLight(); + dDemo_fog_c* createFog(); void remove(); /* 0x00 */ u8 mNumActor; @@ -160,13 +223,18 @@ public: /* 0x84 */ dDemo_camera_c* mpActiveCamera; /* 0x88 */ dDemo_ambient_c* mpAmbient; /* 0x8C */ dDemo_light_c* mpLight[8]; - /* 0xAC */ u8 field_0xac[4]; + /* 0xAC */ dDemo_fog_c* mpFog; }; class dDemo_system_c : public JStage::TSystem { public: + dDemo_system_c() : mObject(NULL) {} ~dDemo_system_c(); - bool JSGFindObject(const char*, JStage::TEObject) const; + void* JSGFindObject(const char*, JStage::TEObject) const; + void setObject(dDemo_object_c* obj) { mObject = obj; } + +private: + /* 0x04 */ dDemo_object_c* mObject; }; class dDemo_manager_c { @@ -183,7 +251,7 @@ public: s32 getMode() { return mMode; } /* 0x00 */ dDemo_system_c* mSystem; - /* 0x04 */ TControl* mControl; + /* 0x04 */ JStudio::TControl* mControl; /* 0x08 */ void* mStage; /* 0x0C */ void* mAudio; /* 0x10 */ void* mParticle; @@ -191,7 +259,7 @@ public: /* 0x18 */ dMesg_tControl* mMesgControl; /* 0x1C */ void* mMessage; /* 0x20 */ dDemo_object_c mDemoObj; - /* 0xD0 */ void* field_0xd0; + /* 0xD0 */ char* mCurFile; /* 0xD4 */ int mFrame; /* 0xD8 */ int mFrameNoMsg; /* 0xDC */ int mMode; diff --git a/src/JSystem/JStage/JSGSystem.cpp b/src/JSystem/JStage/JSGSystem.cpp index e448073bf..d5d27bffa 100644 --- a/src/JSystem/JStage/JSGSystem.cpp +++ b/src/JSystem/JStage/JSGSystem.cpp @@ -16,8 +16,8 @@ s32 JStage::TSystem::JSGFGetType() const { } /* 8026E060-8026E068 .text JSGFindObject__Q26JStage7TSystemCFPCcQ26JStage8TEObject */ -bool JStage::TSystem::JSGFindObject(const char*, JStage::TEObject) const { - return false; +void* JStage::TSystem::JSGFindObject(const char*, JStage::TEObject) const { + return NULL; } /* 8026E068-8026E070 .text JSGCreateObject__Q26JStage7TSystemFPCcQ26JStage8TEObjectUl */ diff --git a/src/d/d_demo.cpp b/src/d/d_demo.cpp index c66bb882f..908a066c7 100644 --- a/src/d/d_demo.cpp +++ b/src/d/d_demo.cpp @@ -4,11 +4,18 @@ // #include "d/d_demo.h" -#include "dolphin/types.h" +#include "f_op/f_op_camera_mng.h" +#include "d/d_com_inf_game.h" /* 800692C4-80069330 .text __ct__13dDemo_actor_cFv */ dDemo_actor_c::dDemo_actor_c() { - /* Nonmatching */ + mFlags = 0; + mTranslation.setall(0.0f); + mScaling.setall(1.0f); + mRotation.setall(0); + mModel = NULL; + mAnimationFrameMax = 3.402823e+38; + mTexAnimationFrameMax = 3.402823e+38; } /* 80069330-800693C0 .text __dt__13dDemo_actor_cFv */ @@ -17,27 +24,36 @@ dDemo_actor_c::~dDemo_actor_c() { } /* 800693C0-800693F4 .text getActor__13dDemo_actor_cFv */ -void dDemo_actor_c::getActor() { - /* Nonmatching */ +fopAc_ac_c* dDemo_actor_c::getActor() { + return fopAcM_SearchByID(mActorPcId); } /* 800693F4-80069434 .text setActor__13dDemo_actor_cFP10fopAc_ac_c */ -void dDemo_actor_c::setActor(fopAc_ac_c*) { - /* Nonmatching */ +void dDemo_actor_c::setActor(fopAc_ac_c* ac) { + if (ac == NULL) + mActorPcId = -1; + else + mActorPcId = fopAcM_GetID(ac); + mBckId = -1; + mBtpId = -1; + mBtkId = -1; + mBrkId = -1; } /* 80069434-80069550 .text getP_BtpData__13dDemo_actor_cFPCc */ -void dDemo_actor_c::getP_BtpData(const char*) { +void* dDemo_actor_c::getP_BtpData(const char* name) { /* Nonmatching */ + if (!(mFlags & 1)) + return NULL; } /* 80069550-800695E8 .text getP_BrkData__13dDemo_actor_cFPCc */ -void dDemo_actor_c::getP_BrkData(const char*) { +void* dDemo_actor_c::getP_BrkData(const char*) { /* Nonmatching */ } /* 800695E8-8006969C .text getP_BtkData__13dDemo_actor_cFPCc */ -void dDemo_actor_c::getP_BtkData(const char*) { +void* dDemo_actor_c::getP_BtkData(const char*) { /* Nonmatching */ } @@ -57,198 +73,275 @@ BOOL dDemo_setDemoData(fopAc_ac_c*, u8, mDoExt_McaMorf*, const char*, int, u16*, } /* 80069BC0-80069BDC .text JSGSetData__13dDemo_actor_cFUlPCvUl */ -void dDemo_actor_c::JSGSetData(u32, const void*, u32) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetData(u32 p0, const void* p1, u32 p2) { + field_0x4c = p0; + field_0x50 = p1; + field_0x54 = p2; + mFlags |= 0x01; } /* 80069BDC-80069C04 .text JSGSetTranslation__13dDemo_actor_cFRC3Vec */ -void dDemo_actor_c::JSGSetTranslation(const Vec&) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetTranslation(const Vec& v) { + mTranslation = v; + mFlags |= 0x02; } /* 80069C04-80069C2C .text JSGSetScaling__13dDemo_actor_cFRC3Vec */ -void dDemo_actor_c::JSGSetScaling(const Vec&) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetScaling(const Vec& v) { + mScaling = v; + mFlags |= 0x04; } /* 80069C2C-80069C90 .text JSGSetRotation__13dDemo_actor_cFRC3Vec */ -void dDemo_actor_c::JSGSetRotation(const Vec&) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetRotation(const Vec& v) { + mRotation.x = cM_deg2s(v.x); + mRotation.y = cM_deg2s(v.y); + mRotation.z = cM_deg2s(v.z); + mFlags |= 0x08; } /* 80069C90-80069CA4 .text JSGSetShape__13dDemo_actor_cFUl */ -void dDemo_actor_c::JSGSetShape(u32) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetShape(u32 id) { + mShapeId = id; + mFlags |= 0x10; } /* 80069CA4-80069CC0 .text JSGSetAnimation__13dDemo_actor_cFUl */ -void dDemo_actor_c::JSGSetAnimation(u32) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetAnimation(u32 no) { + mNextBckId = no; + mAnimationFrameMax = 3.402823e+38; + mFlags |= 0x20; } /* 80069CC0-80069CD4 .text JSGSetAnimationFrame__13dDemo_actor_cFf */ -void dDemo_actor_c::JSGSetAnimationFrame(f32) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetAnimationFrame(f32 v) { + mAnimationFrame = v; + mFlags |= 0x40; } /* 80069CD4-80069CE8 .text JSGSetAnimationTransition__13dDemo_actor_cFf */ -void dDemo_actor_c::JSGSetAnimationTransition(f32) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetAnimationTransition(f32 v) { + mAnimationTransition = v; + mFlags |= 0x40; } /* 80069CE8-80069CFC .text JSGSetTextureAnimation__13dDemo_actor_cFUl */ -void dDemo_actor_c::JSGSetTextureAnimation(u32) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetTextureAnimation(u32 no) { + mTexAnimation = no; + mFlags |= 0x80; } /* 80069CFC-80069D10 .text JSGSetTextureAnimationFrame__13dDemo_actor_cFf */ -void dDemo_actor_c::JSGSetTextureAnimationFrame(f32) { - /* Nonmatching */ +void dDemo_actor_c::JSGSetTextureAnimationFrame(f32 v) { + mTexAnimationFrame = v; + mFlags |= 0x100; } /* 80069D10-80069D44 .text getView__Fv */ -void getView() { - /* Nonmatching */ +camera_class* getView() { + if (dComIfGp_getWindowNum() == 0) + return NULL; + + return dComIfGp_getCamera(dComIfGp_getWindow(0)->getCameraID()); } /* 80069D44-80069D78 .text JSGGetProjectionNear__14dDemo_camera_cCFv */ f32 dDemo_camera_c::JSGGetProjectionNear() const { - /* Nonmatching */ + camera_class* view = getView(); + if (view == NULL) + return 0.0f; + return view->mNear; } /* 80069D78-80069D8C .text JSGSetProjectionNear__14dDemo_camera_cFf */ -void dDemo_camera_c::JSGSetProjectionNear(f32) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetProjectionNear(f32 v) { + mProjNear = v; + mFlags |= 0x01; } /* 80069D8C-80069DC0 .text JSGGetProjectionFar__14dDemo_camera_cCFv */ f32 dDemo_camera_c::JSGGetProjectionFar() const { - /* Nonmatching */ + camera_class* view = getView(); + if (view == NULL) + return 1.0f; + return view->mFar; } /* 80069DC0-80069DD4 .text JSGSetProjectionFar__14dDemo_camera_cFf */ -void dDemo_camera_c::JSGSetProjectionFar(f32) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetProjectionFar(f32 v) { + mProjFar = v; + mFlags |= 0x02; } /* 80069DD4-80069E08 .text JSGGetProjectionFovy__14dDemo_camera_cCFv */ f32 dDemo_camera_c::JSGGetProjectionFovy() const { - /* Nonmatching */ + camera_class* view = getView(); + if (view == NULL) + return 60.0f; + return view->mFovy; } /* 80069E08-80069E1C .text JSGSetProjectionFovy__14dDemo_camera_cFf */ -void dDemo_camera_c::JSGSetProjectionFovy(f32) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetProjectionFovy(f32 v) { + mFovy = v; + mFlags |= 0x04; } /* 80069E1C-80069E50 .text JSGGetProjectionAspect__14dDemo_camera_cCFv */ f32 dDemo_camera_c::JSGGetProjectionAspect() const { - /* Nonmatching */ + camera_class* view = getView(); + if (view == NULL) + return 1.3333f; + return view->mAspect; } /* 80069E50-80069E64 .text JSGSetProjectionAspect__14dDemo_camera_cFf */ -void dDemo_camera_c::JSGSetProjectionAspect(f32) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetProjectionAspect(f32 v) { + mAspect = v; + mFlags |= 0x08; } /* 80069E64-80069EC0 .text JSGGetViewPosition__14dDemo_camera_cCFP3Vec */ -void dDemo_camera_c::JSGGetViewPosition(Vec*) const { - /* Nonmatching */ +void dDemo_camera_c::JSGGetViewPosition(Vec* dst) const { + camera_class* view = getView(); + if (view == NULL) { + dst->x = 0.0f; + dst->y = 0.0f; + dst->z = 0.0f; + } + *dst = view->mLookat.mEye; } /* 80069EC0-80069EE8 .text JSGSetViewPosition__14dDemo_camera_cFRC3Vec */ -void dDemo_camera_c::JSGSetViewPosition(const Vec&) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetViewPosition(const Vec& v) { + mViewPosition = v; + mFlags |= 0x10; } /* 80069EE8-80069F48 .text JSGGetViewUpVector__14dDemo_camera_cCFP3Vec */ -void dDemo_camera_c::JSGGetViewUpVector(Vec*) const { - /* Nonmatching */ +void dDemo_camera_c::JSGGetViewUpVector(Vec* dst) const { + camera_class* view = getView(); + if (view == NULL) { + dst->x = 0.0f; + dst->y = 1.0f; + dst->z = 0.0f; + } + *dst = view->mLookat.mUp; } /* 80069F48-80069F70 .text JSGSetViewUpVector__14dDemo_camera_cFRC3Vec */ -void dDemo_camera_c::JSGSetViewUpVector(const Vec&) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetViewUpVector(const Vec& v) { + mUpVector = v; + mFlags |= 0x20; } /* 80069F70-80069FD0 .text JSGGetViewTargetPosition__14dDemo_camera_cCFP3Vec */ -void dDemo_camera_c::JSGGetViewTargetPosition(Vec*) const { - /* Nonmatching */ +void dDemo_camera_c::JSGGetViewTargetPosition(Vec* dst) const { + camera_class* view = getView(); + if (view == NULL) { + dst->x = 0.0f; + dst->y = 0.0f; + dst->z = 1.0f; + } + *dst = view->mLookat.mCenter; } /* 80069FD0-80069FF8 .text JSGSetViewTargetPosition__14dDemo_camera_cFRC3Vec */ -void dDemo_camera_c::JSGSetViewTargetPosition(const Vec&) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetViewTargetPosition(const Vec& v) { + mTargetPosition = v; + mFlags |= 0x40; } /* 80069FF8-8006A050 .text JSGGetViewRoll__14dDemo_camera_cCFv */ f32 dDemo_camera_c::JSGGetViewRoll() const { - /* Nonmatching */ + camera_class* view = getView(); + if (view == NULL) + return 0.0f; + return cM_sht2d(view->mBank); } /* 8006A050-8006A064 .text JSGSetViewRoll__14dDemo_camera_cFf */ -void dDemo_camera_c::JSGSetViewRoll(f32) { - /* Nonmatching */ +void dDemo_camera_c::JSGSetViewRoll(f32 v) { + mRoll = v; + mFlags |= 0x80; } /* 8006A064-8006A094 .text JSGSetColor__15dDemo_ambient_cF8_GXColor */ -void dDemo_ambient_c::JSGSetColor(_GXColor) { - /* Nonmatching */ +void dDemo_ambient_c::JSGSetColor(GXColor color) { + mColor = color; + mFlags |= 0x01; } /* 8006A094-8006A0A8 .text JSGSetLightType__13dDemo_light_cFQ26JStage7TELight */ -void dDemo_light_c::JSGSetLightType(JStage::TELight) { - /* Nonmatching */ +void dDemo_light_c::JSGSetLightType(JStage::TELight type) { + mLightType = type; + mFlags |= 0x01; } /* 8006A0A8-8006A0D0 .text JSGSetPosition__13dDemo_light_cFRC3Vec */ -void dDemo_light_c::JSGSetPosition(const Vec&) { - /* Nonmatching */ +void dDemo_light_c::JSGSetPosition(const Vec& v) { + mPosition = v; + mFlags |= 0x02; } /* 8006A0D0-8006A100 .text JSGSetColor__13dDemo_light_cF8_GXColor */ -void dDemo_light_c::JSGSetColor(_GXColor) { - /* Nonmatching */ +void dDemo_light_c::JSGSetColor(GXColor v) { + mColor = v; + mFlags |= 0x04; } /* 8006A100-8006A11C .text JSGSetDistanceAttenuation__13dDemo_light_cFff13_GXDistAttnFn */ -void dDemo_light_c::JSGSetDistanceAttenuation(f32, f32, _GXDistAttnFn) { - /* Nonmatching */ +void dDemo_light_c::JSGSetDistanceAttenuation(f32 ref0, f32 ref1, GXDistAttnFn fn) { + mDistAttn0 = ref0; + mDistAttn1 = ref1; + mAttnFn = fn; + mFlags |= 0x08; } /* 8006A11C-8006A134 .text JSGSetAngleAttenuation__13dDemo_light_cFf9_GXSpotFn */ -void dDemo_light_c::JSGSetAngleAttenuation(f32, _GXSpotFn) { - /* Nonmatching */ +void dDemo_light_c::JSGSetAngleAttenuation(f32 ref, GXSpotFn fn) { + mAngleAttn = ref; + mSpotFn = fn; + mFlags |= 0x10; } /* 8006A134-8006A15C .text JSGSetDirection__13dDemo_light_cFRC3Vec */ -void dDemo_light_c::JSGSetDirection(const Vec&) { - /* Nonmatching */ +void dDemo_light_c::JSGSetDirection(const Vec& v) { + mDirection = v; + mFlags |= 0x20; } /* 8006A15C-8006A170 .text JSGSetFogFunction__11dDemo_fog_cF10_GXFogType */ -void dDemo_fog_c::JSGSetFogFunction(_GXFogType) { - /* Nonmatching */ +void dDemo_fog_c::JSGSetFogFunction(GXFogType type) { + mFogType = type; + mFlags |= 0x01; } /* 8006A170-8006A184 .text JSGSetStartZ__11dDemo_fog_cFf */ -void dDemo_fog_c::JSGSetStartZ(f32) { - /* Nonmatching */ +void dDemo_fog_c::JSGSetStartZ(f32 v) { + mStartZ = v; + mFlags |= 0x02; } /* 8006A184-8006A198 .text JSGSetEndZ__11dDemo_fog_cFf */ -void dDemo_fog_c::JSGSetEndZ(f32) { - /* Nonmatching */ +void dDemo_fog_c::JSGSetEndZ(f32 v) { + mEndZ = v; + mFlags |= 0x04; } /* 8006A198-8006A1C8 .text JSGSetColor__11dDemo_fog_cF8_GXColor */ -void dDemo_fog_c::JSGSetColor(_GXColor) { - /* Nonmatching */ +void dDemo_fog_c::JSGSetColor(GXColor color) { + mColor = color; + mFlags |= 0x08; } /* 8006A1C8-8006A1E4 .text __ct__14dDemo_object_cFv */ dDemo_object_c::dDemo_object_c() { - /* Nonmatching */ + mNumActor = 0; + mNumLight = 0; + mpActiveCamera = NULL; + mpAmbient = NULL; + mpFog = NULL; } /* 8006A1E4-8006A234 .text __dt__14dDemo_object_cFv */ @@ -257,65 +350,150 @@ dDemo_object_c::~dDemo_object_c() { } /* 8006A234-8006A2F8 .text appendActor__14dDemo_object_cFP10fopAc_ac_c */ -void dDemo_object_c::appendActor(fopAc_ac_c*) { - /* Nonmatching */ +dDemo_actor_c* dDemo_object_c::appendActor(fopAc_ac_c* ac) { + dDemo_actor_c* demoActor = dComIfGp_demo_getActor(ac->mDemoActorId); + if (demoActor != NULL) + return demoActor; + + if (mNumActor >= ARRAY_SIZE(mpActors)) + return NULL; + + demoActor = new dDemo_actor_c(); + if (demoActor == NULL) + return NULL; + + mpActors[mNumActor++] = demoActor; + demoActor->setActor(ac); + ac->mDemoActorId = mNumActor; + return demoActor; } /* 8006A2F8-8006A31C .text getActor__14dDemo_object_cFUc */ -dDemo_actor_c* dDemo_object_c::getActor(u8) { - /* Nonmatching */ +dDemo_actor_c* dDemo_object_c::getActor(u8 no) { + if (no == 0 || no > ARRAY_SIZE(mpActors)) + return NULL; + return mpActors[no - 1]; } /* 8006A31C-8006A398 .text createCamera__14dDemo_object_cFv */ -void dDemo_object_c::createCamera() { - /* Nonmatching */ +dDemo_camera_c* dDemo_object_c::createCamera() { + if (mpActiveCamera != NULL) + return mpActiveCamera; + + mpActiveCamera = new dDemo_camera_c(); + return mpActiveCamera; } /* 8006A398-8006A3AC .text getActiveCamera__14dDemo_object_cFv */ -void dDemo_object_c::getActiveCamera() { - /* Nonmatching */ +dDemo_camera_c* dDemo_object_c::getActiveCamera() { + if (mpActiveCamera != NULL) + return mpActiveCamera; + return NULL; } /* 8006A3AC-8006A428 .text createAmbient__14dDemo_object_cFv */ -void dDemo_object_c::createAmbient() { - /* Nonmatching */ +dDemo_ambient_c* dDemo_object_c::createAmbient() { + if (mpAmbient != NULL) + return mpAmbient; + + mpAmbient = new dDemo_ambient_c(); + return mpAmbient; } /* 8006A428-8006A4C8 .text appendLight__14dDemo_object_cFv */ -void dDemo_object_c::appendLight() { - /* Nonmatching */ +dDemo_light_c* dDemo_object_c::appendLight() { + if (mNumLight >= ARRAY_SIZE(mpLight)) + return NULL; + + dDemo_light_c* demoLight = new dDemo_light_c(); + if (demoLight == NULL) + return NULL; + + mpLight[mNumLight++] = demoLight; + return demoLight; } /* 8006A4C8-8006A544 .text createFog__14dDemo_object_cFv */ -void dDemo_object_c::createFog() { - /* Nonmatching */ +dDemo_fog_c* dDemo_object_c::createFog() { + if (mpFog != NULL) + return mpFog; + + mpFog = new dDemo_fog_c(); + return mpFog; } /* 8006A544-8006A678 .text remove__14dDemo_object_cFv */ void dDemo_object_c::remove() { - /* Nonmatching */ + while (mNumActor) + delete mpActors[--mNumActor]; + + if (mpActiveCamera != NULL) { + delete mpActiveCamera; + mpActiveCamera = NULL; + } + + if (mpAmbient != NULL) { + delete mpAmbient; + mpAmbient = NULL; + } + + while (mNumLight) + delete mpLight[--mNumLight]; + + if (mpFog != NULL) { + delete mpFog; + mpFog = NULL; + } } -/* 8006A678-8006A6D8 .text __dt__11dDemo_fog_cFv */ -dDemo_fog_c::~dDemo_fog_c() {} - -/* 8006A6D8-8006A738 .text __dt__13dDemo_light_cFv */ -dDemo_light_c::~dDemo_light_c() {} - -/* 8006A738-8006A798 .text __dt__15dDemo_ambient_cFv */ -dDemo_ambient_c::~dDemo_ambient_c() {} - -/* 8006A798-8006A7F8 .text __dt__14dDemo_camera_cFv */ -dDemo_camera_c::~dDemo_camera_c() {} - /* 8006A7F8-8006A92C .text JSGFindObject__14dDemo_system_cCFPCcQ26JStage8TEObject */ -bool dDemo_system_c::JSGFindObject(const char*, JStage::TEObject) const { - /* Nonmatching */ +void* dDemo_system_c::JSGFindObject(const char* name, JStage::TEObject type) const { + if (mObject == NULL) + return NULL; + + if (type == JStage::TOBJ_ACTOR || type == JStage::TOBJ_ACTOR_UNK) { + fopAc_ac_c* ac = fopAcM_searchFromName((char*)name, 0, 0); + if (ac == NULL) { + if (type == JStage::TOBJ_ACTOR && strncmp(name, "d_act", 5) == 0) { + ac = (fopAc_ac_c*)fopAcM_fastCreate((char*)name, 0); + if (ac == NULL) + return NULL; + fopAcM_setStageLayer(ac); + } else { + return NULL; + } + } + return mObject->appendActor(ac); + } else if (type == JStage::TOBJ_CAMERA) { + return mObject->createCamera(); + } else if (type == JStage::TOBJ_AMBIENT) { + return mObject->createAmbient(); + } else if (type == JStage::TOBJ_LIGHT) { + return mObject->appendLight(); + } else if (type == JStage::TOBJ_FOG) { + return mObject->createFog(); + } else { + return NULL; + } } /* 8006A92C-8006ADA0 .text __ct__15dDemo_manager_cFv */ dDemo_manager_c::dDemo_manager_c() { /* Nonmatching */ + mCurFile = NULL; + mFrame = 0; + mMesgControl = new dMesg_tControl(); + JUT_ASSERT(0x5b6, mMesgControl != 0); + mSystem = new dDemo_system_c(); + JUT_ASSERT(0x5ba, mSystem != 0); + mControl = new JStudio::TControl(); + // TODO: finish this once we make progress on JStudio headers + // mFactory->appendCreateObj(mStage); + // mFactory->appendCreateObj(mAudio); + // mFactory->appendCreateObj(mParticle); + mSystem->setObject(&mDemoObj); + // mFactory->appendCreateObj(mMessage); + mMode = 0; } /* 8006ADA0-8006AEFC .text __dt__15dDemo_manager_cFv */ @@ -345,38 +523,3 @@ void dDemo_manager_c::remove() { void dDemo_manager_c::update() { /* Nonmatching */ } - -/* 8006B1B4-8006B240 .text JSGFindNodeID__13dDemo_actor_cCFPCc */ -s32 dDemo_actor_c::JSGFindNodeID(const char*) const { - /* Nonmatching */ -} - -/* 8006B240-8006B2DC .text JSGGetNodeTransformation__13dDemo_actor_cCFUlPA4_f */ -int dDemo_actor_c::JSGGetNodeTransformation(u32, f32(*)[4]) const { - /* Nonmatching */ -} - -/* 8006B2DC-8006B2E4 .text JSGGetAnimationFrameMax__13dDemo_actor_cCFv */ -f32 dDemo_actor_c::JSGGetAnimationFrameMax() const { - /* Nonmatching */ -} - -/* 8006B2E4-8006B2EC .text JSGGetTextureAnimationFrameMax__13dDemo_actor_cCFv */ -f32 dDemo_actor_c::JSGGetTextureAnimationFrameMax() const { - /* Nonmatching */ -} - -/* 8006B2EC-8006B308 .text JSGGetTranslation__13dDemo_actor_cCFP3Vec */ -void dDemo_actor_c::JSGGetTranslation(Vec*) const { - /* Nonmatching */ -} - -/* 8006B308-8006B324 .text JSGGetScaling__13dDemo_actor_cCFP3Vec */ -void dDemo_actor_c::JSGGetScaling(Vec*) const { - /* Nonmatching */ -} - -/* 8006B324-8006B39C .text JSGGetRotation__13dDemo_actor_cCFP3Vec */ -void dDemo_actor_c::JSGGetRotation(Vec*) const { - /* Nonmatching */ -}