From 0b1cb89d695b07ceef78fd17f10c8e026dfbf0c9 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Fri, 13 Feb 2026 15:08:10 -0800 Subject: [PATCH] d_demo debug (#3098) --- config/ShieldD/symbols.txt | 4 +- include/JSystem/JGadget/binary.h | 2 + include/JSystem/JGadget/linklist.h | 7 +- .../JSystem/JStudio/JStudio/jstudio-control.h | 3 +- .../JSystem/JStudio/JStudio_JAudio2/control.h | 1 + .../JSystem/JStudio/JStudio_JStage/control.h | 2 +- include/d/d_demo.h | 221 +++++++++--------- .../MSL/MSL_C/MSL_Common/Include/float.h | 2 +- src/d/d_demo.cpp | 196 ++++++++++------ 9 files changed, 258 insertions(+), 180 deletions(-) diff --git a/config/ShieldD/symbols.txt b/config/ShieldD/symbols.txt index e3317917a1..d7a19ab42f 100644 --- a/config/ShieldD/symbols.txt +++ b/config/ShieldD/symbols.txt @@ -35488,7 +35488,9 @@ __vt__Q27JStudio16TAdaptor_message = .data:0x80676850; // type:object size:0x24 @128962 = .data:0x806768B0; // type:object size:0x10 scope:local data:string hash:0xACCEA443 @128963 = .data:0x806768C0; // type:object size:0xC scope:local hash:0xACCEA442 @128964 = .data:0x806768D0; // type:object size:0x10 scope:local data:string hash:0xACCEA445 -lbl_806768E0 = .data:0x806768E0; // type:object size:0x28 +lbl_806768E0 = .data:0x806768E0; // type:object size:0x9 scope:local data:string +lbl_806768EC = .data:0x806768EC; // type:object size:0xE scope:local data:string +lbl_806768FC = .data:0x806768FC; // type:object size:0x9 scope:local data:string @STRING@JSGFindNodeID__13dDemo_actor_cCFPCc@1 = .data:0x80676908; // type:object size:0x9 scope:local data:string hash:0xDB057BAF dhash:0x59AD5DB6 @STRING@JSGFindNodeID__13dDemo_actor_cCFPCc@0 = .data:0x80676914; // type:object size:0xC scope:local data:string hash:0xDB057BAE dhash:0x59AD5DB6 @STRING@JSGFindNodeID__13dDemo_actor_cCFPCc = .data:0x80676920; // type:object size:0x9 scope:local data:string hash:0x99B503DE dhash:0x855EB0BA diff --git a/include/JSystem/JGadget/binary.h b/include/JSystem/JGadget/binary.h index 34aa9c0a5d..f395076c07 100644 --- a/include/JSystem/JGadget/binary.h +++ b/include/JSystem/JGadget/binary.h @@ -100,6 +100,8 @@ struct TValueIterator TValueIterator(const void* begin) { mBegin = reinterpret_cast(begin); + bool unused = false; + (void)&unused; } const void* get() const { return mBegin; } diff --git a/include/JSystem/JGadget/linklist.h b/include/JSystem/JGadget/linklist.h index f886a2880e..ca8dbc637e 100644 --- a/include/JSystem/JGadget/linklist.h +++ b/include/JSystem/JGadget/linklist.h @@ -14,7 +14,12 @@ struct TLinkListNode { pPrev_ = NULL; } - ~TLinkListNode() {} + ~TLinkListNode() { +#if DEBUG + JGADGET_ASSERTWARN(77, pNext_==NULL); + JGADGET_ASSERTWARN(78, pPrev_==NULL); +#endif + } TLinkListNode* getNext() const { return pNext_; } TLinkListNode* getPrev() const { return pPrev_; } diff --git a/include/JSystem/JStudio/JStudio/jstudio-control.h b/include/JSystem/JStudio/JStudio/jstudio-control.h index a41df62dd3..3dd1bdb285 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-control.h +++ b/include/JSystem/JStudio/JStudio/jstudio-control.h @@ -79,9 +79,10 @@ public: transformOnGet_enable(param_0); } - void transform_setOrigin_TxyzRy(const Vec& xyz, f32 rotY) { + bool transform_setOrigin_TxyzRy(const Vec& xyz, f32 rotY) { transformOnSet_setOrigin_TxyzRy(xyz, rotY); transformOnGet_setOrigin_TxyzRy(xyz, rotY); + return true; } void transform_setOrigin(const Vec& xyz, f32 rotY) { diff --git a/include/JSystem/JStudio/JStudio_JAudio2/control.h b/include/JSystem/JStudio/JStudio_JAudio2/control.h index 371aaf437f..effefaef18 100644 --- a/include/JSystem/JStudio/JStudio_JAudio2/control.h +++ b/include/JSystem/JStudio/JStudio_JAudio2/control.h @@ -27,6 +27,7 @@ struct TCreateObject : public JStudio::TCreateObject { JAISoundStarter* get_pJAISoundStarter_() { return pJAISoundStarter_; } const JStage::TSystem* get_pJSGSystem_() { return pJSGSystem_; } bool isPermit_onExit_notEnd() { return mPermit_onExit_notEnd; } + void setPermit_onExit_notEnd(bool value) { mPermit_onExit_notEnd = value; } /* 0x0C */ JAISoundStarter* pJAISoundStarter_; /* 0x10 */ const JStage::TSystem* pJSGSystem_; diff --git a/include/JSystem/JStudio/JStudio_JStage/control.h b/include/JSystem/JStudio/JStudio_JStage/control.h index 1b41039866..40cbaaeefe 100644 --- a/include/JSystem/JStudio/JStudio_JStage/control.h +++ b/include/JSystem/JStudio/JStudio_JStage/control.h @@ -2,11 +2,11 @@ #define JSTUDIO_JSTAGE_CONTROL_H #include "JSystem/JGadget/pointer.h" +#include "JSystem/JStage/JSGLight.h" #include "JSystem/JStage/JSGActor.h" #include "JSystem/JStage/JSGAmbientLight.h" #include "JSystem/JStage/JSGCamera.h" #include "JSystem/JStage/JSGFog.h" -#include "JSystem/JStage/JSGLight.h" #include "JSystem/JStage/JSGSystem.h" #include "JSystem/JStudio/JStudio/jstudio-object.h" #include "JSystem/JStudio/JStudio/jstudio-math.h" diff --git a/include/d/d_demo.h b/include/d/d_demo.h index bbcb5d72b6..73c6f24e42 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -3,9 +3,9 @@ #include "m_Do/m_Do_ext.h" #include "m_Do/m_Do_mtx.h" +#include "JSystem/JStudio/JStudio_JStage/object.h" #include "JSystem/JStudio/JStudio_JAudio2/control.h" #include "JSystem/JStudio/JStudio_JParticle/object-particle.h" -#include "JSystem/JStudio/JStudio_JStage/object.h" #include "SSystem/SComponent/c_sxyz.h" #include "SSystem/SComponent/c_xyz.h" #include "Z2AudioLib/Z2SoundStarter.h" @@ -27,12 +27,16 @@ public: ~dDemo_object_c(); JStage::TObject* appendActor(fopAc_ac_c*); dDemo_actor_c* getActor(u8); - JStage::TObject* createCamera(); + dDemo_camera_c* createCamera(); + dDemo_camera_c* createEditorCamera(); dDemo_camera_c* getActiveCamera(); JStage::TObject* createAmbient(); JStage::TObject* appendLight(); JStage::TObject* createFog(); void remove(); + void removeEditorCamera(); + + dDemo_camera_c* getCamera() { return mpCamera; } /* 0x00 */ u8 mActorNum; /* 0x01 */ u8 mLightNum; @@ -41,6 +45,9 @@ public: /* 0x88 */ dDemo_ambient_c* mpAmbient; /* 0x8C */ dDemo_light_c* mpLights[8]; /* 0xAC */ dDemo_fog_c* mpFog; +#if DEBUG + /* 0xB0 */ dDemo_camera_c* mpEditorCamera; +#endif }; // TODO: made up, figure out what this is @@ -85,15 +92,15 @@ public: void setActor(fopAc_ac_c*); f32 getPrm_Morf(); int getDemoIDData(int* o_arg0, int* o_arg1, int* o_arg2, u16* o_resID, u8*); - + virtual ~dDemo_actor_c(); virtual void JSGSetData(u32, void const*, u32); virtual s32 JSGFindNodeID(char const* param_0) const { - JUT_ASSERT(0, mModel != NULL); + JUT_ASSERT(115, mModel != NULL); return mModel->getModelData()->getJointName()->getIndex(param_0); } virtual bool JSGGetNodeTransformation(u32 param_0, Mtx param_1) const { - JUT_ASSERT(0, mModel != NULL); + JUT_ASSERT(120, mModel != NULL); cMtx_copy(mModel->getAnmMtx((u16)param_0), param_1); return true; } @@ -113,10 +120,14 @@ public: return mTexAnmFrameMax; } virtual void JSGGetTranslation(Vec* o_trans) const { - *o_trans = mTrans; + o_trans->x = mTrans.x; + o_trans->y = mTrans.y; + o_trans->z = mTrans.z; } virtual void JSGGetScaling(Vec* o_scale) const { - *o_scale = mScale; + o_scale->x = mScale.x; + o_scale->y = mScale.y; + o_scale->z = mScale.z; } virtual void JSGGetRotation(Vec* param_0) const { param_0->x = S2DEG(mRotate.x); @@ -163,96 +174,6 @@ private: /* 0x68 */ u32 mBrkId; }; -class dDemo_system_c : public JStage::TSystem { -public: - dDemo_system_c() { mpObject = NULL; } - - virtual int JSGFindObject(JStage::TObject**, char const*, - JStage::TEObject) const; - virtual ~dDemo_system_c(); - - void setObject(dDemo_object_c* i_object) { mpObject = i_object; } - -private: - /* 0x4 */ dDemo_object_c* mpObject; -}; - -class dDemo_particle_c : public JStudio_JParticle::TCreateObject { -public: - dDemo_particle_c(JPAEmitterManager* p_emitMgr, const JStage::TSystem* p_system) - : JStudio_JParticle::TCreateObject(p_emitMgr, p_system) {} - - virtual ~dDemo_particle_c(); - virtual JPABaseEmitter* emitter_create(u32); -}; - -class dDemo_light_c : public JStage::TLight { -public: - enum Enable_e { - ENABLE_LIGHT_TYPE_e = (1 << 0), - ENABLE_POSITION_e = (1 << 1), - ENABLE_COLOR_e = (1 << 2), - ENABLE_DIST_ATTEN_e = (1 << 3), - ENABLE_ANGLE_ATTEN_e = (1 << 4), - ENABLE_DIRECTION_e = (1 << 5), - }; - - dDemo_light_c() { - mFlags = 0; - } - - virtual void JSGSetLightType(JStage::TELight); - virtual void JSGSetPosition(Vec const&); - virtual void JSGSetColor(GXColor); - virtual void JSGSetDistanceAttenuation(f32, f32, GXDistAttnFn); - virtual void JSGSetAngleAttenuation(f32, GXSpotFn); - virtual void JSGSetDirection(Vec const&); - virtual ~dDemo_light_c(); - - void onEnable(u8 flag) { mFlags |= flag; } - -private: - /* 0x04 */ u8 mFlags; - /* 0x08 */ JStage::TELight mLightType; - /* 0x0C */ GXDistAttnFn mDistAttenFn; - /* 0x10 */ GXSpotFn mSpotFn; - /* 0x14 */ cXyz mPosition; - /* 0x20 */ GXColor mColor; - /* 0x24 */ f32 field_0x24; - /* 0x28 */ f32 field_0x28; - /* 0x2C */ f32 field_0x2c; - /* 0x30 */ cXyz mDirection; -}; - -class dDemo_fog_c : public JStage::TFog { -public: - enum Enable_e { - ENABLE_FOG_FN_e = (1 << 0), - ENABLE_START_Z_e = (1 << 1), - ENABLE_END_Z_e = (1 << 2), - ENABLE_COLOR_e = (1 << 3), - }; - - dDemo_fog_c() { - mFlags = 0; - } - - virtual void JSGSetFogFunction(GXFogType); - virtual void JSGSetStartZ(f32); - virtual void JSGSetEndZ(f32); - virtual void JSGSetColor(GXColor); - virtual ~dDemo_fog_c(); - - void onEnable(u8 flag) { mFlags |= flag; } - -private: - /* 0x04 */ u8 mFlags; - /* 0x05 */ u8 mFogType; - /* 0x08 */ f32 mStartZ; - /* 0x0C */ f32 mEndZ; - /* 0x10 */ GXColor mColor; -}; - class dDemo_camera_c : public JStage::TCamera { public: enum Enable_e { @@ -266,9 +187,7 @@ public: ENABLE_VIEW_ROLL_e = (1 << 7), }; - dDemo_camera_c() { - mFlags = 0; - } + dDemo_camera_c() : mFlags(0) {} virtual f32 JSGGetProjectionNear() const; virtual void JSGSetProjectionNear(f32); @@ -329,15 +248,95 @@ private: /* 0x05 */ GXColor mColor; }; -namespace { -class jstudio_tCreateObject_message : public JStudio::TCreateObject { +class dDemo_light_c : public JStage::TLight { public: - jstudio_tCreateObject_message() {} + enum Enable_e { + ENABLE_LIGHT_TYPE_e = (1 << 0), + ENABLE_POSITION_e = (1 << 1), + ENABLE_COLOR_e = (1 << 2), + ENABLE_DIST_ATTEN_e = (1 << 3), + ENABLE_ANGLE_ATTEN_e = (1 << 4), + ENABLE_DIRECTION_e = (1 << 5), + }; - virtual ~jstudio_tCreateObject_message(); - virtual bool create(JStudio::TObject**, const JStudio::stb::data::TParse_TBlock_object&); + dDemo_light_c() : mFlags(0) {} + + virtual void JSGSetLightType(JStage::TELight); + virtual void JSGSetPosition(Vec const&); + virtual void JSGSetColor(GXColor); + virtual void JSGSetDistanceAttenuation(f32, f32, GXDistAttnFn); + virtual void JSGSetAngleAttenuation(f32, GXSpotFn); + virtual void JSGSetDirection(Vec const&); + virtual ~dDemo_light_c(); + + void onEnable(u8 flag) { mFlags |= flag; } + +private: + /* 0x04 */ u8 mFlags; + /* 0x08 */ JStage::TELight mLightType; + /* 0x0C */ GXDistAttnFn mDistAttenFn; + /* 0x10 */ GXSpotFn mSpotFn; + /* 0x14 */ cXyz mPosition; + /* 0x20 */ GXColor mColor; + /* 0x24 */ f32 field_0x24; + /* 0x28 */ f32 field_0x28; + /* 0x2C */ f32 field_0x2c; + /* 0x30 */ cXyz mDirection; }; +class dDemo_fog_c : public JStage::TFog { +public: + enum Enable_e { + ENABLE_FOG_FN_e = (1 << 0), + ENABLE_START_Z_e = (1 << 1), + ENABLE_END_Z_e = (1 << 2), + ENABLE_COLOR_e = (1 << 3), + }; + + dDemo_fog_c() { + mFlags = 0; + } + + virtual void JSGSetFogFunction(GXFogType); + virtual void JSGSetStartZ(f32); + virtual void JSGSetEndZ(f32); + virtual void JSGSetColor(GXColor); + virtual ~dDemo_fog_c(); + + void onEnable(u8 flag) { mFlags |= flag; } + +private: + /* 0x04 */ u8 mFlags; + /* 0x05 */ s8 mFogType; + /* 0x08 */ f32 mStartZ; + /* 0x0C */ f32 mEndZ; + /* 0x10 */ GXColor mColor; +}; + +class dDemo_system_c : public JStage::TSystem { +public: + dDemo_system_c() { mpObject = NULL; } + + virtual int JSGFindObject(JStage::TObject**, char const*, + JStage::TEObject) const; + virtual ~dDemo_system_c(); + + void setObject(dDemo_object_c* i_object) { mpObject = i_object; } + +private: + /* 0x4 */ dDemo_object_c* mpObject; +}; + +class dDemo_particle_c : public JStudio_JParticle::TCreateObject { +public: + dDemo_particle_c(JPAEmitterManager* p_emitMgr, const JStage::TSystem* p_system) + : JStudio_JParticle::TCreateObject(p_emitMgr, p_system) {} + + virtual ~dDemo_particle_c(); + virtual JPABaseEmitter* emitter_create(u32); +}; + +namespace { class jstudio_tAdaptor_message : public JStudio::TAdaptor_message { public: typedef JStudio::TObject_message ObjectType; @@ -348,6 +347,14 @@ public: virtual void adaptor_do_MESSAGE(JStudio::data::TEOperationData, const void*, u32); }; +class jstudio_tCreateObject_message : public JStudio::TCreateObject { +public: + jstudio_tCreateObject_message() {} + + virtual ~jstudio_tCreateObject_message(); + virtual bool create(JStudio::TObject**, const JStudio::stb::data::TParse_TBlock_object&); +}; + }; // namespace int dDemo_setDemoData(fopAc_ac_c*, u8, mDoExt_McaMorf*, char const*, int, u16*, u32, s8); @@ -373,12 +380,12 @@ public: static s32 getMode() { return m_mode; } static u32 getFrame() { return m_frame; } static JStudio::stb::TControl* getControl() { return m_control; } - static bool isStatus(u32 status) { return m_status & status; } + static u32 isStatus(u32 status) { return m_status & status; } static void onStatus(u32 status) { m_status |= status; } static void offStatus(u32 status) { m_status &= ~status; } static void setBranchData(const u8* p_data) { m_branchData = p_data; } static s16 getBranchId() { return m_branchId; } - static s16 getBranchNum() { return m_branchNum; } + static u16 getBranchNum() { return m_branchNum; } static jmessage_tControl* getMesgControl() { return m_mesgControl; } static void setBranchNum(u16 num) { diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h index 1a294cbb1c..426828a97c 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h @@ -99,7 +99,7 @@ int __fpclassifyl(long double __value); #define FLT_MAX_EXP 128 #define FLT_MAX_10_EXP 38 -#if DEBUG +#if !PLATFORM_GCN #define FLT_MAX 3.4028235e38f #define FLT_EPSILON 1.1920929e-7f #else diff --git a/src/d/d_demo.cpp b/src/d/d_demo.cpp index 2a7c74f40b..023f1fcbdc 100644 --- a/src/d/d_demo.cpp +++ b/src/d/d_demo.cpp @@ -1,6 +1,7 @@ #include "d/dolzel.h" // IWYU pragma: keep #include "d/d_demo.h" +#include "d/d_debug_viewer.h" #include "d/d_msg_class.h" #include "d/d_msg_object.h" #include "f_op/f_op_camera_mng.h" @@ -192,6 +193,9 @@ u16 dDemo_c::m_branchType; const u8* dDemo_c::m_branchData; +#if DEBUG +u16 dDemo_c::m_branchNum = 0; +#endif int dDemo_actor_c::getDemoIDData(int* o_arg0, int* o_arg1, int* o_arg2, u16* o_resID, u8* param_4) { @@ -223,10 +227,6 @@ int dDemo_actor_c::getDemoIDData(int* o_arg0, int* o_arg1, int* o_arg2, u16* o_r return 1; } -#if DEBUG -u16 dDemo_c::m_branchNum = 0; -#endif - static void* dDemo_getJaiPointer(char const* arcName, u32 anmID, int param_2, u16* param_3) { if (param_2 <= 0 || param_3 == NULL) { return NULL; @@ -274,12 +274,15 @@ int dDemo_setDemoData(fopAc_ac_c* i_actor, u8 i_flags, mDoExt_McaMorf* i_morf, c demo_actor->setModel(i_morf->getModel()); + u32 anmID; + void* ptr; + const char* a_name; + J3DAnmTransform* i_key; + f32 prmMorf; if (flags & dDemo_actor_c::ENABLE_ANM_e) { - u32 anmID = demo_actor->getAnmId(); - void* ptr; + anmID = demo_actor->getAnmId(); if (anmID != demo_actor->getOldAnmId()) { - const char* a_name; if (anmID & 0x10000) { a_name = dStage_roomControl_c::getDemoArcName(); JUT_ASSERT(0x267, a_name != NULL); @@ -289,19 +292,20 @@ int dDemo_setDemoData(fopAc_ac_c* i_actor, u8 i_flags, mDoExt_McaMorf* i_morf, c demo_actor->setOldAnmId(anmID); - J3DAnmTransform* i_key = (J3DAnmTransform*)dComIfG_getObjectIDRes(a_name, anmID & 0xffff); - JUT_ASSERT(272, i_key != NULL); + i_key = (J3DAnmTransform*)dComIfG_getObjectIDRes(a_name, anmID & 0xffff); + JUT_ASSERT(626, i_key != NULL); ptr = dDemo_getJaiPointer(a_name, anmID & 0xffff, param_4, param_5); - f32 prmMorf = demo_actor->getPrm_Morf(); + prmMorf = demo_actor->getPrm_Morf(); i_morf->setAnm(i_key, -1, prmMorf, 1.0f, 0.0f, -1.0f, ptr); demo_actor->setAnmFrameMax(i_morf->getEndFrame()); } } + f32 anm_frame; if (flags & dDemo_actor_c::ENABLE_ANM_FRAME_e) { - f32 anm_frame = demo_actor->getAnmFrame(); + anm_frame = demo_actor->getAnmFrame(); if (anm_frame > 1.0f) { anm_frame -= 1.0f; @@ -392,7 +396,9 @@ void dDemo_actor_c::JSGSetTranslation(Vec const& i_trans) { } void dDemo_actor_c::JSGSetScaling(Vec const& i_scale) { - mScale = i_scale; + mScale.x = i_scale.x; + mScale.y = i_scale.y; + mScale.z = i_scale.z; onEnable(ENABLE_SCALE_e); } @@ -435,21 +441,22 @@ void dDemo_actor_c::JSGSetTextureAnimationFrame(f32 i_frame) { } static view_class* getView() { - if (dComIfGp_getWindowNum() == 0) { + if (!dComIfGp_getWindowNum()) { return NULL; } - int camID = dComIfGp_getWindow(0)->getCameraID(); + dDlst_window_c* window = dComIfGp_getWindow(0); + int camID = window->getCameraID(); return dComIfGp_getCamera(camID); } f32 dDemo_camera_c::JSGGetProjectionNear() const { view_class* view = getView(); - + if (view == NULL) { return 0.0f; } - + return view->near; } @@ -460,11 +467,11 @@ void dDemo_camera_c::JSGSetProjectionNear(f32 i_projNear) { f32 dDemo_camera_c::JSGGetProjectionFar() const { view_class* view = getView(); - + if (view == NULL) { return 1.0f; } - + return view->far; } @@ -475,11 +482,11 @@ void dDemo_camera_c::JSGSetProjectionFar(f32 i_projFar) { f32 dDemo_camera_c::JSGGetProjectionFovy() const { view_class* view = getView(); - + if (view == NULL) { return 60.0f; } - + return view->fovy; } @@ -490,11 +497,11 @@ void dDemo_camera_c::JSGSetProjectionFovy(f32 i_projFovy) { f32 dDemo_camera_c::JSGGetProjectionAspect() const { view_class* view = getView(); - + if (view == NULL) { - return 1.3571428f; + return mDoGph_gInf_c::getAspect(); } - + return view->aspect; } @@ -505,7 +512,7 @@ void dDemo_camera_c::JSGSetProjectionAspect(f32 i_aspect) { void dDemo_camera_c::JSGGetViewPosition(Vec* o_position) const { view_class* view = getView(); - + if (view == NULL) { o_position->x = 0.0f; o_position->y = 0.0f; @@ -516,13 +523,15 @@ void dDemo_camera_c::JSGGetViewPosition(Vec* o_position) const { } void dDemo_camera_c::JSGSetViewPosition(Vec const& i_position) { - mViewPos = i_position; + mViewPos.x = i_position.x; + mViewPos.y = i_position.y; + mViewPos.z = i_position.z; onEnable(ENABLE_VIEW_POS_e); } void dDemo_camera_c::JSGGetViewUpVector(Vec* o_upVec) const { view_class* view = getView(); - + if (view == NULL) { o_upVec->x = 0.0f; o_upVec->y = 1.0f; @@ -533,13 +542,15 @@ void dDemo_camera_c::JSGGetViewUpVector(Vec* o_upVec) const { } void dDemo_camera_c::JSGSetViewUpVector(Vec const& i_upVec) { - mViewUpVector = i_upVec; + mViewUpVector.x = i_upVec.x; + mViewUpVector.y = i_upVec.y; + mViewUpVector.z = i_upVec.z; onEnable(ENABLE_VIEW_UP_VEC_e); } void dDemo_camera_c::JSGGetViewTargetPosition(Vec* o_targetPos) const { view_class* view = getView(); - + if (view == NULL) { o_targetPos->x = 0.0f; o_targetPos->y = 0.0f; @@ -550,7 +561,9 @@ void dDemo_camera_c::JSGGetViewTargetPosition(Vec* o_targetPos) const { } void dDemo_camera_c::JSGSetViewTargetPosition(Vec const& i_targetPos) { - mViewTargetVector = i_targetPos; + mViewTargetVector.x = i_targetPos.x; + mViewTargetVector.y = i_targetPos.y; + mViewTargetVector.z = i_targetPos.z; onEnable(ENABLE_VIEW_TARG_POS_e); } @@ -580,7 +593,9 @@ void dDemo_light_c::JSGSetLightType(JStage::TELight i_lightType) { } void dDemo_light_c::JSGSetPosition(Vec const& i_pos) { - mPosition = i_pos; + mPosition.x = i_pos.x; + mPosition.y = i_pos.y; + mPosition.z = i_pos.z; onEnable(ENABLE_POSITION_e); } @@ -603,7 +618,9 @@ void dDemo_light_c::JSGSetAngleAttenuation(f32 param_0, GXSpotFn i_spotFn) { } void dDemo_light_c::JSGSetDirection(Vec const& i_direction) { - mDirection = i_direction; + mDirection.x = i_direction.x; + mDirection.y = i_direction.y; + mDirection.z = i_direction.z; onEnable(ENABLE_DIRECTION_e); } @@ -631,12 +648,18 @@ dDemo_object_c::dDemo_object_c() { mActorNum = 0; mLightNum = 0; mpCamera = NULL; +#if DEBUG + mpEditorCamera = NULL; +#endif mpAmbient = NULL; mpFog = NULL; } dDemo_object_c::~dDemo_object_c() { remove(); +#if DEBUG + removeEditorCamera(); +#endif } JStage::TObject* dDemo_object_c::appendActor(fopAc_ac_c* p_actor) { @@ -659,9 +682,7 @@ JStage::TObject* dDemo_object_c::appendActor(fopAc_ac_c* p_actor) { return NULL; } - u8 curActorNum = mActorNum; - mActorNum++; - mpActors[curActorNum] = demoActor; + mpActors[mActorNum++] = demoActor; demoActor->setActor(p_actor); p_actor->demoActorID = mActorNum; @@ -680,7 +701,7 @@ dDemo_actor_c* dDemo_object_c::getActor(u8 actorId) { return mpActors[actorId - 1]; } -JStage::TObject* dDemo_object_c::createCamera() { +dDemo_camera_c* dDemo_object_c::createCamera() { if (mpCamera != NULL) { // "2 demo cameras!!\n" OS_REPORT("デモカメラが2つも!!\n"); @@ -691,9 +712,21 @@ JStage::TObject* dDemo_object_c::createCamera() { return mpCamera; } +#if DEBUG +dDemo_camera_c* dDemo_object_c::createEditorCamera() { + if (mpEditorCamera) { + OSReport("エディターカメラが2つも!!\n"); + return mpEditorCamera; + } + + mpEditorCamera = new dDemo_camera_c(); + return mpEditorCamera; +} +#endif + dDemo_camera_c* dDemo_object_c::getActiveCamera() { - if (mpCamera != NULL) { - return mpCamera; + if (getCamera() != NULL) { + return getCamera(); } return NULL; @@ -724,9 +757,7 @@ JStage::TObject* dDemo_object_c::appendLight() { return NULL; } - u8 curLightNum = mLightNum; - mLightNum++; - mpLights[curLightNum] = demoLight; + mpLights[mLightNum++] = demoLight; return demoLight; } @@ -767,6 +798,15 @@ void dDemo_object_c::remove() { } } +#if DEBUG +void dDemo_object_c::removeEditorCamera() { + if (mpEditorCamera) { + delete mpEditorCamera; + mpEditorCamera = NULL; + } +} +#endif + dDemo_fog_c::~dDemo_fog_c() {} dDemo_light_c::~dDemo_light_c() {} @@ -782,6 +822,9 @@ int dDemo_system_c::JSGFindObject(JStage::TObject** p_TObj, char const* actorNam } if (objType == JStage::OBJECT_ACTOR || objType == JStage::OBJECT_UNDEFINED) { + if (DEBUG && dComIfGp_event_getMode() == 0) { + g_dComIfG_gameInfo.play.getEvent()->setDebugStb(true); + } fopAc_ac_c* actor = fopAcM_searchFromName(actorName, 0, 0); if (actor == NULL) { @@ -806,7 +849,11 @@ int dDemo_system_c::JSGFindObject(JStage::TObject** p_TObj, char const* actorNam *p_TObj = mpObject->appendActor(actor); } else if (objType == JStage::OBJECT_CAMERA) { - *p_TObj = mpObject->createCamera(); + if (DEBUG && !strcmp(actorName, "EditCam")) { + *p_TObj = mpObject->createEditorCamera(); + } else { + *p_TObj = mpObject->createCamera(); + } } else if (objType == JStage::OBJECT_AMBIENT) { *p_TObj = mpObject->createAmbient(); } else if (objType == JStage::OBJECT_LIGHT) { @@ -815,41 +862,46 @@ int dDemo_system_c::JSGFindObject(JStage::TObject** p_TObj, char const* actorNam *p_TObj = mpObject->createFog(); } else { // "Strange Demo Object type!! Type<%d>\n" - OS_REPORT("へんなデモオブジェクトタイプです!! タイプ<%d>\n"); + OS_REPORT("へんなデモオブジェクトタイプです!! タイプ<%d>\n", objType); JUT_ASSERT(1755, FALSE); } - return *p_TObj == NULL ? TRUE : FALSE; + if (*p_TObj == NULL) { + return true; + } else { + return false; + } } void dDemo_c::create() { m_system = new dDemo_system_c(); - JUT_ASSERT(0, m_system != NULL); + JUT_ASSERT(1774, m_system != NULL); m_control = new JStudio::TControl(); - JUT_ASSERT(0, m_control != NULL); + JUT_ASSERT(1776, m_control != NULL); m_mesgControl = new jmessage_tControl(); - JUT_ASSERT(0, m_mesgControl != NULL); + JUT_ASSERT(1778, m_mesgControl != NULL); m_stage = new JStudio_JStage::TCreateObject(m_system); - JUT_ASSERT(0, m_stage != NULL); + JUT_ASSERT(1781, m_stage != NULL); - m_audio = new JStudio_JAudio2::TCreateObject(Z2GetSoundStarter(), m_system); - JUT_ASSERT(0, m_audio != NULL); - m_audio->mPermit_onExit_notEnd = true; + JStudio_JAudio2::TCreateObject* p_audio = new JStudio_JAudio2::TCreateObject(Z2GetSoundStarter(), m_system); + m_audio = p_audio; + JUT_ASSERT(1787, m_audio != NULL); + p_audio->setPermit_onExit_notEnd(true); m_particle = new dDemo_particle_c(dPa_control_c::getEmitterManager(), m_system); - JUT_ASSERT(0, m_particle != NULL); + JUT_ASSERT(1794, m_particle != NULL); m_message = new jstudio_tCreateObject_message(); - JUT_ASSERT(0, m_message != NULL); + JUT_ASSERT(1797, m_message != NULL); m_factory = new JStudio::TFactory(); - JUT_ASSERT(0, m_factory != NULL); + JUT_ASSERT(1800, m_factory != NULL); m_object = new dDemo_object_c(); - JUT_ASSERT(0, m_object != NULL); + JUT_ASSERT(1802, m_object != NULL); m_control->setSecondPerFrame(1.0f / 30.0f); m_control->setFactory(m_factory); @@ -866,7 +918,7 @@ void dDemo_c::create() { void dDemo_c::remove() { end(); - + if (m_object != NULL) { delete m_object; m_object = NULL; @@ -918,7 +970,7 @@ dDemo_system_c::~dDemo_system_c() {} jmessage_tControl::~jmessage_tControl() {} int dDemo_c::start(u8 const* p_data, cXyz* p_translation, f32 rotationY) { - JUT_ASSERT(0, m_system != NULL); + JUT_ASSERT(1886, m_system != NULL); m_control->reset(); JStudio::TParse parser(m_control); @@ -936,7 +988,7 @@ int dDemo_c::start(u8 const* p_data, cXyz* p_translation, f32 rotationY) { m_control->forward(0); m_translation = p_translation; - if (p_translation != NULL) { + if (m_translation != NULL) { static cXyz l_translation; l_translation = *m_translation; m_translation = &l_translation; @@ -954,8 +1006,12 @@ int dDemo_c::start(u8 const* p_data, cXyz* p_translation, f32 rotationY) { return 1; } +static void dummyString2() { + DEAD_STRING("デモデータ再読み込みエラー!!\n"); +} + void dDemo_c::end() { - JUT_ASSERT(0, m_system != NULL); + JUT_ASSERT(1956, m_system != NULL); m_control->destroyObject_all(); m_object->remove(); @@ -964,18 +1020,18 @@ void dDemo_c::end() { } void dDemo_c::branch() { - JUT_ASSERT(0, m_system != NULL); + JUT_ASSERT(1995, m_system != NULL); m_control->destroyObject_all(); const u8* branchData = m_branchData; m_branchData = NULL; int rt = start(branchData, m_translation, m_rotationY); - JUT_ASSERT(0, rt); + JUT_ASSERT(2007, rt); } int dDemo_c::update() { - JUT_ASSERT(0, m_system != NULL); + JUT_ASSERT(2064, m_system != NULL); if (m_data == NULL) { if (m_branchData == NULL) { @@ -1008,7 +1064,7 @@ int dDemo_c::update() { } if (dComIfGs_staffroll_next_go_check() != 0) { - dScnKy_env_light_c* env_light = &g_env_light; + dScnKy_env_light_c* env_light = dKy_getEnvlight(); if (dComIfGs_staffroll_next_go_check() > 10) { env_light->staffroll_next_timer = 0; @@ -1021,12 +1077,20 @@ int dDemo_c::update() { } } +#if DEBUG + dDbVw_Report(480, 30, "Frame %d", m_frame); + dDbVw_Report(480, 40, "NoMSg %d", m_frameNoMsg); +#endif + return 1; } void dDemo_c::setBranchType(u16 type) { m_branchType = type; m_branchId = -1; +#if DEBUG + m_branchNum = 0; +#endif } void dDemo_c::setBranchId(u16 param_0, s16 branchId) { @@ -1046,14 +1110,10 @@ void dDemo_c::reset() { JPABaseEmitter* dDemo_particle_c::emitter_create(u32 i_id) { cXyz pos(0.0f, 0.0f, 0.0f); - return dComIfGp_particle_set(i_id, &pos, NULL, NULL, 0xFF, NULL, - dComIfGp_roomControl_getStayNo(), NULL, NULL, NULL); + JPABaseEmitter* emitter = dComIfGp_particle_set(i_id, &pos, NULL, NULL, 0xFF, NULL, dComIfGp_roomControl_getStayNo(), NULL, NULL, NULL); + return emitter; } dDemo_particle_c::~dDemo_particle_c() {} dDemo_camera_c::~dDemo_camera_c() {} - -static void dummyString2() { - DEAD_STRING("デモデータ再読み込みエラー!!\n"); -}