diff --git a/include/JSystem/JStage/JSGCamera.h b/include/JSystem/JStage/JSGCamera.h index 55b7287de..336d2c476 100644 --- a/include/JSystem/JStage/JSGCamera.h +++ b/include/JSystem/JStage/JSGCamera.h @@ -4,7 +4,7 @@ #include "JSystem/JStage/JSGObject.h" namespace JStage { - struct TECameraProjection {}; + enum TECameraProjection {}; struct TECameraView {}; diff --git a/include/JSystem/JStudio/JStudio/jstudio-control.h b/include/JSystem/JStudio/JStudio/jstudio-control.h index 2bb666301..234e2e665 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-control.h +++ b/include/JSystem/JStudio/JStudio/jstudio-control.h @@ -116,15 +116,24 @@ class TControl : public stb::TControl { return transformedPosDir; } } - void transformOnGet_transform(const TTransform_position_direction& posDir, TTransform_position_direction* transformedPosDir) const { - transformOnGet_transformTranslation(posDir.mPosition, &transformedPosDir->mPosition); - transformOnGet_transformDirection(posDir.mDirection, &transformedPosDir->mDirection); + void transformOnGet_transform(const TTransform_position& rSrc, TTransform_position* pDst) const { + transformOnGet_transformTranslation(rSrc.mPosition, &pDst->mPosition); } - void transformOnGet_transformTranslation(const Vec& pos, Vec* transformedPos) const { - MTXMultVec(transformOnGet_getMatrix(), &pos, transformedPos); + void transformOnSet_transform(const TTransform_position& rSrc, TTransform_position* pDst) const { + transformOnSet_transformTranslation(rSrc.mPosition, &pDst->mPosition); } - void transformOnGet_transformDirection(const Vec& dir, Vec* transformedDir) const { - MTXMultVecSR(transformOnGet_getMatrix(), &dir, transformedDir); + void transformOnGet_transform(const TTransform_position_direction& rSrc, TTransform_position_direction* pDst) const { + transformOnGet_transformTranslation(rSrc.mPosition, &pDst->mPosition); + transformOnGet_transformDirection(rSrc.mDirection, &pDst->mDirection); + } + void transformOnGet_transformTranslation(const Vec& rSrc, Vec* pDst) const { + MTXMultVec(transformOnGet_getMatrix(), &rSrc, pDst); + } + void transformOnSet_transformTranslation(const Vec& rSrc, Vec* pDst) const { + MTXMultVec(transformOnSet_getMatrix(), &rSrc, pDst); + } + void transformOnGet_transformDirection(const Vec& rSrc, Vec* pDst) const { + MTXMultVecSR(transformOnGet_getMatrix(), &rSrc, pDst); } // TODO @@ -134,22 +143,19 @@ class TControl : public stb::TControl { void stb_getObjectContainer() const {} void stb_referObjectContainer() {} void stb_removeObject(TObject*) {} - void transformOnGet_transform(const TTransform_position&, TTransform_position*) const {} - void transformOnGet_transform(const TTransform_translation_rotation&, TTransform_translation_rotation*) const {} - void transformOnGet_transformRotation(const Vec&, Vec*) const {} - void transformOnGet_transform_ifEnabled(const TTransform_translation_rotation&, TTransform_translation_rotation*) const {} - void transformOnSet_transform(const TTransform_position&, TTransform_position*) const {} - void transformOnSet_transform(const TTransform_position_direction&, TTransform_position_direction*) const {} - void transformOnSet_transform(const TTransform_translation_rotation&, TTransform_translation_rotation*) const {} - void transformOnSet_transform(CMtxP, MtxP) const {} - void transformOnSet_transformDirection(const Vec&, Vec*) const {} - void transformOnSet_transformDirection_ifEnabled(const Vec&, Vec*) const {} - void transformOnSet_transformRotation(const Vec&, Vec*) const {} - void transformOnSet_transformTranslation(const Vec&, Vec*) const {} - void transformOnSet_transformTranslation_ifEnabled(const Vec&, Vec*) const {} - void transformOnSet_transform_ifEnabled(const TTransform_position_direction&, TTransform_position_direction*) const {} - void transformOnSet_transform_ifEnabled(const TTransform_translation_rotation&, TTransform_translation_rotation*) const {} - void transformOnSet_transform_ifEnabled(CMtxP, MtxP) const {} + void transformOnGet_transform(const TTransform_translation_rotation& rSrc, TTransform_translation_rotation* pDst) const {} + void transformOnGet_transformRotation(const Vec& rSrc, Vec* pDst) const {} + void transformOnGet_transform_ifEnabled(const TTransform_translation_rotation& rSrc, TTransform_translation_rotation* pDst) const {} + void transformOnSet_transform(const TTransform_position_direction& rSrc, TTransform_position_direction* pDst) const {} + void transformOnSet_transform(const TTransform_translation_rotation& rSrc, TTransform_translation_rotation* pDst) const {} + void transformOnSet_transform(CMtxP pSrc, MtxP pDst) const {} + void transformOnSet_transformDirection(const Vec& rSrc, Vec* pDst) const {} + void transformOnSet_transformDirection_ifEnabled(const Vec& rSrc, Vec* pDst) const {} + void transformOnSet_transformRotation(const Vec& rSrc, Vec* pDst) const {} + void transformOnSet_transformTranslation_ifEnabled(const Vec& rSrc, Vec* pDst) const {} + void transformOnSet_transform_ifEnabled(const TTransform_position_direction& rSrc, TTransform_position_direction* pDst) const {} + void transformOnSet_transform_ifEnabled(const TTransform_translation_rotation& rSrc, TTransform_translation_rotation* pDst) const {} + void transformOnSet_transform_ifEnabled(CMtxP pSrc, MtxP pDst) const {} /* 0x58 */ f64 mSecondPerFrame; /* 0x60 */ fvb::TControl fvb_Control; diff --git a/include/JSystem/JStudio/JStudio/jstudio-object.h b/include/JSystem/JStudio/JStudio/jstudio-object.h index e1628271d..45b111c03 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-object.h +++ b/include/JSystem/JStudio/JStudio/jstudio-object.h @@ -302,14 +302,13 @@ struct TAdaptor_camera : public TAdaptor { /* 0x10 */ TVariableValue mValue[11]; - static u8 const sauVariableValue_3_POSITION_XYZ[12]; - static u8 const sauVariableValue_3_TARGET_POSITION_XYZ[12]; + static u32 const sauVariableValue_3_POSITION_XYZ[3]; + static u32 const sauVariableValue_3_TARGET_POSITION_XYZ[3]; static u8 sauVariableValue_2_DISTANCE_NEAR_FAR[8]; }; struct TObject_camera : public TObject { - TObject_camera(JStudio::stb::data::TParse_TBlock_object const&, - JStudio::TAdaptor_camera*); + TObject_camera(JStudio::stb::data::TParse_TBlock_object const&, JStudio::TAdaptor_camera*); virtual ~TObject_camera(); virtual void do_paragraph(u32, void const*, u32); diff --git a/include/JSystem/JStudio/JStudio_JStage/control.h b/include/JSystem/JStudio/JStudio_JStage/control.h index 2503c555b..8c020773a 100644 --- a/include/JSystem/JStudio/JStudio_JStage/control.h +++ b/include/JSystem/JStudio/JStudio_JStage/control.h @@ -136,6 +136,8 @@ struct TAdaptor_ambientLight : public JStudio::TAdaptor_ambientLight { }; // Size: 0x64 struct TAdaptor_camera : public JStudio::TAdaptor_camera { + typedef TVariableValueOutput_object_ TVVOutput; + TAdaptor_camera(JStage::TSystem const*, JStage::TCamera*); virtual ~TAdaptor_camera(); virtual void adaptor_do_prepare(const JStudio::TObject*); @@ -147,14 +149,12 @@ struct TAdaptor_camera : public JStudio::TAdaptor_camera { virtual void adaptor_do_PARENT_NODE(JStudio::data::TEOperationData, void const*, u32); virtual void adaptor_do_PARENT_ENABLE(JStudio::data::TEOperationData, void const*, u32); - void setJSG_position_(JStudio::TControl const*); - void getJSG_position_(JStudio::TControl const*); - void setJSG_targetPosition_(JStudio::TControl const*); - void getJSG_targetPosition_(JStudio::TControl const*); - - static u8 saoVVOutput_[160 + 4 /* padding */]; + static const TVVOutput saoVVOutput_[5]; - /* 0xE8 */ u8 field_0xE8[0xF8 - 0xE8]; + /* 0xE8 */ const JStage::TSystem* mSystem; + /* 0xEC */ JStage::TCamera* mObject; + /* 0xF0 */ JStage::TObject* mF0; + /* 0xF4 */ u32 mF4; }; // Size: 0xF8 struct TAdaptor_fog : public JStudio::TAdaptor_fog { diff --git a/src/JSystem/JAudio/JASSeqParser.cpp b/src/JSystem/JAudio/JASSeqParser.cpp index 4ce0e25ee..54b49cde9 100644 --- a/src/JSystem/JAudio/JASSeqParser.cpp +++ b/src/JSystem/JAudio/JASSeqParser.cpp @@ -637,13 +637,13 @@ int JASystem::TSeqParser::cmdPrintf(TTrack* track, u32* args) { break; } - switch (buf[i]) { - case 'n': - buf[i] = '\r'; - continue; - default: - continue; - } + switch (buf[i]) { + case 'n': + buf[i] = '\r'; + continue; + default: + continue; + } } if (buf[i] != '%') { diff --git a/src/JSystem/JMessage/resource.cpp b/src/JSystem/JMessage/resource.cpp index bc4176aa1..8008e9adf 100644 --- a/src/JSystem/JMessage/resource.cpp +++ b/src/JSystem/JMessage/resource.cpp @@ -16,11 +16,11 @@ JMessage::TResourceContainer::TResourceContainer() { /* 8029FD04-8029FD90 .text Get_groupID__Q28JMessage18TResourceContainerFUs */ JMessage::TResource* JMessage::TResourceContainer::Get_groupID(u16 groupID) { - /* Nonmatching */ - for (iterator iter = begin(); iter != end(); iter++) { - TResource* res = &(*iter); + JGadget::TContainerEnumerator enumerator(this); + while (enumerator) { + const TResource* res = &(*enumerator); if (res->mInfo.get_groupID() == groupID) - return res; + return (TResource*)res; } return NULL; } diff --git a/src/JSystem/JStudio/JStudio_JStage/object-actor.cpp b/src/JSystem/JStudio/JStudio_JStage/object-actor.cpp index c238ed030..e254ae1f2 100644 --- a/src/JSystem/JStudio/JStudio_JStage/object-actor.cpp +++ b/src/JSystem/JStudio/JStudio_JStage/object-actor.cpp @@ -49,6 +49,7 @@ void TAdaptor_actor::adaptor_do_begin(const JStudio::TObject* object) { mObject->JSGGetRotation(&sp2C[1]); mObject->JSGGetScaling(&sp08); Vec* r29; + // TODO: inline if (!pControl->transformOnGet_isEnabled()) { r29 = sp2C; } else { diff --git a/src/JSystem/JStudio/JStudio_JStage/object-camera.cpp b/src/JSystem/JStudio/JStudio_JStage/object-camera.cpp index d230d60a1..9b967f526 100644 --- a/src/JSystem/JStudio/JStudio_JStage/object-camera.cpp +++ b/src/JSystem/JStudio/JStudio_JStage/object-camera.cpp @@ -6,52 +6,147 @@ #include "JSystem/JStudio/JStudio_JStage/object-camera.h" #include "dolphin/types.h" +namespace JStudio_JStage { + +const TAdaptor_camera::TVVOutput TAdaptor_camera::saoVVOutput_[5] = { + TVVOutput(7, &JStage::TCamera::JSGSetViewRoll, &JStage::TCamera::JSGGetViewRoll), + TVVOutput(6, &JStage::TCamera::JSGSetProjectionFovy, &JStage::TCamera::JSGGetProjectionFovy), + TVVOutput(8, &JStage::TCamera::JSGSetProjectionNear, &JStage::TCamera::JSGGetProjectionNear), + TVVOutput(9, &JStage::TCamera::JSGSetProjectionFar, &JStage::TCamera::JSGGetProjectionFar), + TVVOutput(-1, NULL, NULL), +}; + /* 80277354-802773E8 .text __ct__Q214JStudio_JStage15TAdaptor_cameraFPCQ26JStage7TSystemPQ26JStage7TCamera */ -JStudio_JStage::TAdaptor_camera::TAdaptor_camera(const JStage::TSystem*, JStage::TCamera*) { - /* Nonmatching */ +TAdaptor_camera::TAdaptor_camera(const JStage::TSystem* system, JStage::TCamera* camera) + : mSystem(system) + , mObject(camera) +{ } /* 802773E8-80277460 .text __dt__Q214JStudio_JStage15TAdaptor_cameraFv */ -JStudio_JStage::TAdaptor_camera::~TAdaptor_camera() { - /* Nonmatching */ +TAdaptor_camera::~TAdaptor_camera() { + adaptor_do_end(NULL); } /* 80277460-802774A8 .text adaptor_do_prepare__Q214JStudio_JStage15TAdaptor_cameraFPCQ27JStudio7TObject */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_prepare(const JStudio::TObject*) { - /* Nonmatching */ +void TAdaptor_camera::adaptor_do_prepare(const JStudio::TObject* object) { + for (const TVVOutput* output = saoVVOutput_; output->mValueIndex != -1; output++) { + mVariableValues[output->mValueIndex].setOutput(output); + } } +namespace { + struct TTransformed_ { + JStudio::TControl::TTransform_position mCurrent; + JStudio::TControl::TTransform_position mTarget; + }; + + inline const TTransformed_* transformOnGet_transform_ifEnabled_(const JStudio::TControl* pControl, const TTransformed_& rSrc, TTransformed_* pDst) { + if (!pControl->transformOnGet_isEnabled()) { + return &rSrc; + } else { + pControl->transformOnGet_transform(rSrc.mCurrent, &pDst->mCurrent); + pControl->transformOnGet_transform(rSrc.mTarget, &pDst->mTarget); + // Fixes codegen, but breaks regalloc: + // CMtxP temp = pControl->mTransformOnGet_Matrix; + // MTXMultVec(temp, &rSrc.mCurrent.mPosition, &pDst->mCurrent.mPosition); + // MTXMultVec(temp, &rSrc.mTarget.mPosition, &pDst->mTarget.mPosition); + return pDst; + } + } + inline const TTransformed_* transformOnSet_transform_ifEnabled_(const JStudio::TControl* pControl, const TTransformed_& rSrc, TTransformed_* pDst) { + if (!pControl->transformOnSet_isEnabled()) { + return &rSrc; + } else { + pControl->transformOnSet_transform(rSrc.mCurrent, &pDst->mCurrent); + pControl->transformOnSet_transform(rSrc.mTarget, &pDst->mTarget); + // Fixes codegen, but breaks regalloc: + // CMtxP temp = pControl->mTransformOnSet_Matrix; + // MTXMultVec(temp, &rSrc.mCurrent.mPosition, &pDst->mCurrent.mPosition); + // MTXMultVec(temp, &rSrc.mTarget.mPosition, &pDst->mTarget.mPosition); + return pDst; + } + } +}; + /* 802774A8-80277600 .text adaptor_do_begin__Q214JStudio_JStage15TAdaptor_cameraFPCQ27JStudio7TObject */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_begin(const JStudio::TObject*) { +void TAdaptor_camera::adaptor_do_begin(const JStudio::TObject* object) { /* Nonmatching */ + mObject->JSGFEnableFlag(1); + + const JStudio::TControl* pControl = (JStudio::TControl*)object->getControl(); + TTransformed_ sp20; + TTransformed_ sp08; + const TTransformed_* r29; + mObject->JSGGetViewPosition(&sp20.mCurrent.mPosition); + mObject->JSGGetViewTargetPosition(&sp20.mTarget.mPosition); + r29 = (TTransformed_*)transformOnGet_transform_ifEnabled_(pControl, sp20, &sp08); + adaptor_setVariableValue_Vec(sauVariableValue_3_POSITION_XYZ, r29->mCurrent.mPosition); + adaptor_setVariableValue_Vec(sauVariableValue_3_TARGET_POSITION_XYZ, r29->mTarget.mPosition); + for (const TVVOutput* output = saoVVOutput_; output->mValueIndex != -1; output++) { + mVariableValues[output->mValueIndex].setValue_immediate((mObject->*(output->mGetter))()); + } } /* 80277600-80277654 .text adaptor_do_end__Q214JStudio_JStage15TAdaptor_cameraFPCQ27JStudio7TObject */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_end(const JStudio::TObject*) { - /* Nonmatching */ +void TAdaptor_camera::adaptor_do_end(const JStudio::TObject* object) { + mObject->JSGFDisableFlag(1); } /* 80277654-8027771C .text adaptor_do_update__Q214JStudio_JStage15TAdaptor_cameraFPCQ27JStudio7TObjectUl */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_update(const JStudio::TObject*, u32) { +void TAdaptor_camera::adaptor_do_update(const JStudio::TObject* object, u32 p2) { /* Nonmatching */ + const JStudio::TControl* pControl = (JStudio::TControl*)object->getControl(); + TTransformed_ sp20; + TTransformed_ sp08; + adaptor_getVariableValue_Vec(&sp20.mCurrent.mPosition, sauVariableValue_3_POSITION_XYZ); + adaptor_getVariableValue_Vec(&sp20.mTarget.mPosition, sauVariableValue_3_TARGET_POSITION_XYZ); + const TTransformed_* r31 = transformOnSet_transform_ifEnabled_(pControl, sp20, &sp08); + mObject->JSGSetViewPosition(r31->mCurrent.mPosition); + mObject->JSGSetViewTargetPosition(r31->mTarget.mPosition); } /* 8027771C-80277750 .text adaptor_do_data__Q214JStudio_JStage15TAdaptor_cameraFPCQ27JStudio7TObjectPCvUlPCvUl */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_data(const JStudio::TObject*, const void*, u32, const void*, u32) { - /* Nonmatching */ +void TAdaptor_camera::adaptor_do_data(const JStudio::TObject* object, const void* p2, u32 p3, const void* p4, u32 p5) { + TAdaptor_object_::adaptor_data_(mObject, p2, p3, p4, p5); } /* 80277750-802777A4 .text adaptor_do_PARENT__Q214JStudio_JStage15TAdaptor_cameraFQ37JStudio4data15TEOperationDataPCvUl */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_PARENT(JStudio::data::TEOperationData, const void*, u32) { - /* Nonmatching */ +void TAdaptor_camera::adaptor_do_PARENT(JStudio::data::TEOperationData operation, const void* p2, u32 p3) { + switch (operation) { + case JStudio::data::TEOD_Unknown_18: + mF0 = (JStage::TObject*)mSystem->JSGFindObject((const char*)p2, JStage::TOBJ_ACTOR_UNK); + break; + } } /* 802777A4-80277814 .text adaptor_do_PARENT_NODE__Q214JStudio_JStage15TAdaptor_cameraFQ37JStudio4data15TEOperationDataPCvUl */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_PARENT_NODE(JStudio::data::TEOperationData, const void*, u32) { - /* Nonmatching */ +void TAdaptor_camera::adaptor_do_PARENT_NODE(JStudio::data::TEOperationData operation, const void* p2, u32 p3) { + switch (operation) { + case JStudio::data::TEOD_Unknown_18: + if (mF0) { + mF4 = mF0->JSGFindNodeID((const char*)p2); + } + break; + case JStudio::data::TEOD_Unknown_19: + mF4 = *(u32*)p2; + break; + } } /* 80277814-80277870 .text adaptor_do_PARENT_ENABLE__Q214JStudio_JStage15TAdaptor_cameraFQ37JStudio4data15TEOperationDataPCvUl */ -void JStudio_JStage::TAdaptor_camera::adaptor_do_PARENT_ENABLE(JStudio::data::TEOperationData, const void*, u32) { - /* Nonmatching */ +void TAdaptor_camera::adaptor_do_PARENT_ENABLE(JStudio::data::TEOperationData operation, const void* p2, u32 p3) { + switch (operation) { + case JStudio::data::TEOD_Unknown_02: + JStage::TObject* parent = NULL; + u32 idx = -1; + if (*(u32*)p2 != 0) { + parent = mF0; + idx = mF4; + } + mObject->JSGSetParent(parent, idx); + break; + } } + +} // namespace JStudio_JStage