From 2301aa94bf0659323b3aa7aa72677129c72ac2f3 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Sat, 2 Dec 2023 01:09:24 -0800 Subject: [PATCH 1/5] fix functions not returning a value --- src/d/actor/d_a_bomb3.inc | 2 +- src/d/d_lib.cpp | 2 +- src/f_op/f_op_msg_mng.cpp | 2 +- src/m_Do/m_Do_ext.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/d/actor/d_a_bomb3.inc b/src/d/actor/d_a_bomb3.inc index 8d77c6c89..d35c814dd 100644 --- a/src/d/actor/d_a_bomb3.inc +++ b/src/d/actor/d_a_bomb3.inc @@ -1273,7 +1273,7 @@ BOOL daBomb_c::createHeap() { } static BOOL daBomb_createHeap(fopAc_ac_c* i_this) { - static_cast(i_this)->createHeap(); + return static_cast(i_this)->createHeap(); } int daBomb_c::create() { diff --git a/src/d/d_lib.cpp b/src/d/d_lib.cpp index 5d3952767..13aca7f9b 100644 --- a/src/d/d_lib.cpp +++ b/src/d/d_lib.cpp @@ -218,7 +218,7 @@ u32 dLib_setFirstMsg(u16 eventBit, u32 firstMsgID, u32 secondMsgID) { /* 80057F30-80057F78 .text dLib_checkPlayerInCircle__F4cXyzff */ bool dLib_checkPlayerInCircle(cXyz center, f32 radius, f32 halfHeight) { fopAc_ac_c* link = dComIfGp_getLinkPlayer(); - dLib_checkActorInCircle(center, link, radius, halfHeight); + return dLib_checkActorInCircle(center, link, radius, halfHeight); } /* 80057F78-80058098 .text dLib_checkActorInCircle__F4cXyzP10fopAc_ac_cff */ diff --git a/src/f_op/f_op_msg_mng.cpp b/src/f_op/f_op_msg_mng.cpp index 229054803..944c37f3b 100644 --- a/src/f_op/f_op_msg_mng.cpp +++ b/src/f_op/f_op_msg_mng.cpp @@ -62,7 +62,7 @@ s32 fopMsgM_setStageLayer(void* proc) { scene_class* stageProc = fopScnM_SearchByID(g_dComIfG_gameInfo.play.getRoomControl()->mProcID); JUT_ASSERT(0x189, stageProc != 0); u32 layer = fpcM_LayerID(stageProc); - fpcM_ChangeLayerID(proc, layer); + return fpcM_ChangeLayerID(proc, layer); } /* 8002AED4-8002AEF4 .text fopMsgM_SearchByID__FUi */ diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index 51e087642..3615de74c 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -169,7 +169,7 @@ void mDoExt_bpkAnm::entry(J3DMaterialTable* i_matTable, f32 i_frame) { /* 8000E32C-8000E358 .text init__13mDoExt_btpAnmFP12J3DModelDataP16J3DAnmTexPatterniifssbi */ int mDoExt_btpAnm::init(J3DModelData* i_modelData, J3DAnmTexPattern* i_btp, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { - init(&i_modelData->getMaterialTable(), i_btp, i_anmPlay, i_attribute, i_rate, i_startF, i_endF, i_modify, i_entry); + return init(&i_modelData->getMaterialTable(), i_btp, i_anmPlay, i_attribute, i_rate, i_startF, i_endF, i_modify, i_entry); } /* 8000E358-8000E37C .text entry__13mDoExt_btpAnmFP12J3DModelDatas */ @@ -221,7 +221,7 @@ void mDoExt_btpAnm::entry(J3DMaterialTable* i_matTable, s16 i_frame) { /* 8000E6CC-8000E6F8 .text init__13mDoExt_btkAnmFP12J3DModelDataP19J3DAnmTextureSRTKeyiifssbi */ int mDoExt_btkAnm::init(J3DModelData* i_modelData, J3DAnmTextureSRTKey* i_btk, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { - init(&i_modelData->getMaterialTable(), i_btk, i_anmPlay, i_attribute, i_rate, i_startF, i_endF, i_modify, i_entry); + return init(&i_modelData->getMaterialTable(), i_btk, i_anmPlay, i_attribute, i_rate, i_startF, i_endF, i_modify, i_entry); } /* 8000E6F8-8000E71C .text entry__13mDoExt_btkAnmFP12J3DModelDataf */ From 7215995e94317a59926424906db656f600a37b81 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Mon, 18 Dec 2023 18:33:23 -0800 Subject: [PATCH 2/5] avoid name collisions --- src/d/d_flower.cpp | 2 +- src/d/d_grass.cpp | 2 +- src/d/d_kankyo.cpp | 4 ++-- src/d/d_kyeff.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d/d_flower.cpp b/src/d/d_flower.cpp index 1af6d530f..7aab25379 100644 --- a/src/d/d_flower.cpp +++ b/src/d/d_flower.cpp @@ -67,7 +67,7 @@ void dFlower_packet_c::calc() { } /* 800C0A88-800C0D38 .text checkGroundY__FR4cXyz */ -void checkGroundY(cXyz&) { +static void checkGroundY(cXyz&) { /* Nonmatching */ } diff --git a/src/d/d_grass.cpp b/src/d/d_grass.cpp index ba8673e28..56782abdf 100644 --- a/src/d/d_grass.cpp +++ b/src/d/d_grass.cpp @@ -72,7 +72,7 @@ void dGrass_packet_c::calc() { } /* 80078008-800782B8 .text checkGroundY__FR4cXyz */ -void checkGroundY(cXyz&) { +static void checkGroundY(cXyz&) { /* Nonmatching */ } diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index 2c0fa18b6..e9bbc8604 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -106,7 +106,7 @@ s16 u8_data_ratio_set(u8 param_0, u8 param_1, f32 param_2) { } /* 8018F894-8018F8E4 .text s16_data_ratio_set__Fssf */ -s16 s16_data_ratio_set(s16 param_0, s16 param_1, f32 param_2) { +static s16 s16_data_ratio_set(s16 param_0, s16 param_1, f32 param_2) { return param_0 + (s16)(param_2 * (param_1 - param_0)); } @@ -147,7 +147,7 @@ f32 float_kankyo_color_ratio_set(f32 param_0, f32 param_1, f32 param_2, f32 para } /* 8018FAE0-8018FB14 .text get_parcent__Ffff */ -f32 get_parcent(f32 param_0, f32 param_1, f32 param_2) { +static f32 get_parcent(f32 param_0, f32 param_1, f32 param_2) { f32 temp_f1; f32 temp_f2; f32 temp_f4 = param_0 - param_1; diff --git a/src/d/d_kyeff.cpp b/src/d/d_kyeff.cpp index fe1c742be..0c86175be 100644 --- a/src/d/d_kyeff.cpp +++ b/src/d/d_kyeff.cpp @@ -26,7 +26,7 @@ BOOL dKyeff_Draw(dKyeff_c* i_this) { } /* 80198008-8019803C .text get_parcent__Ffff */ -f32 get_parcent(f32 param_0, f32 param_1, f32 param_2) { +static f32 get_parcent(f32 param_0, f32 param_1, f32 param_2) { f32 temp_f1; f32 temp_f2; f32 temp_f4 = param_0 - param_1; @@ -41,7 +41,7 @@ f32 get_parcent(f32 param_0, f32 param_1, f32 param_2) { } /* 8019803C-8019808C .text s16_data_ratio_set__Fssf */ -s16 s16_data_ratio_set(s16 param_0, s16 param_1, f32 param_2) { +static s16 s16_data_ratio_set(s16 param_0, s16 param_1, f32 param_2) { return param_0 + (s16)(param_2 * (param_1 - param_0)); } From ed346cbb09df6cf6ca06f6b92a45865a52605881 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Wed, 20 Dec 2023 19:29:58 -0800 Subject: [PATCH 3/5] PSMTX -> MTX --- src/JSystem/JParticle/JPADraw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JSystem/JParticle/JPADraw.cpp b/src/JSystem/JParticle/JPADraw.cpp index b808441cd..5b589d294 100644 --- a/src/JSystem/JParticle/JPADraw.cpp +++ b/src/JSystem/JParticle/JPADraw.cpp @@ -646,7 +646,7 @@ void JPADraw::setParticleClipBoard() { switch (dc.pbsp->getType()) { case JPABaseShape::JPAType_Billboard: case JPABaseShape::JPAType_DirBillboard: - PSMTXIdentity(cb.mDrawMtx); + MTXIdentity(cb.mDrawMtx); break; case JPABaseShape::JPAType_YBillboard: loadYBBMtx(cb.mDrawMtxPtr); @@ -732,7 +732,7 @@ void JPADraw::setChildClipBoard() { switch (dc.pssp->getType()) { case JPABaseShape::JPAType_Billboard: case JPABaseShape::JPAType_DirBillboard: - PSMTXIdentity(cb.mDrawMtx); + MTXIdentity(cb.mDrawMtx); break; case JPABaseShape::JPAType_YBillboard: loadYBBMtx(cb.mDrawMtxPtr); From 2aab59afe7212e4a01f08cfa579800c70dce4a0e Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Fri, 29 Dec 2023 20:44:55 -0800 Subject: [PATCH 4/5] JGeometry.h: reorder for better compiler compatibility --- include/JSystem/JGeometry.h | 48 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index b1fb48ace..212334cda 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -7,6 +7,29 @@ namespace JGeometry { +template +struct TUtil { + static inline f32 epsilon() { return 3.81469727e-06f; } + + static inline f32 sqrt(f32 mag) { + if (mag <= 0.0f) { + return mag; + } else { + f32 root = __frsqrte(mag); + return 0.5f * root * (3.0f - mag * (root * root)) * mag; + } + } + + static inline f32 inv_sqrt(f32 mag) { + if (mag <= 0.0f) { + return mag; + } else { + f32 root = __frsqrte(mag); + return 0.5f * root * (3.0f - mag * (root * root)); + } + } +}; + template struct TVec3 { T x; @@ -358,31 +381,6 @@ struct TBox2 : TBox > { void set(f32 x0, f32 y0, f32 x1, f32 y1) { i.set(x0, y0); f.set(x1, y1); } }; -template -struct TUtil { - static inline f32 epsilon() { - return 3.81469727e-06f; - } - - static inline f32 sqrt(f32 mag) { - if (mag <= 0.0f) { - return mag; - } else { - f32 root = __frsqrte(mag); - return 0.5f * root * (3.0f - mag * (root * root)) * mag; - } - } - - static inline f32 inv_sqrt(f32 mag) { - if (mag <= 0.0f) { - return mag; - } else { - f32 root = __frsqrte(mag); - return 0.5f * root * (3.0f - mag * (root * root)); - } - } -}; - // clang-format on } // namespace JGeometry From 69591674785e0dfca3fcad6b4ad453fbbd793815 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Sat, 30 Dec 2023 00:01:26 -0800 Subject: [PATCH 5/5] time macro --- include/JSystem/JUtility/JUTProcBar.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/JSystem/JUtility/JUTProcBar.h b/include/JSystem/JUtility/JUTProcBar.h index 2d17e65a2..d066edc04 100644 --- a/include/JSystem/JUtility/JUTProcBar.h +++ b/include/JSystem/JUtility/JUTProcBar.h @@ -26,7 +26,7 @@ public: } void end() { - mCost = ((OSGetTick() - mTick) * 8) / ((*(u32*)0x800000F8 / 4) / 125000); + mCost = OSTicksToMicroseconds(OSGetTick() - mTick); if (mCost == 0) { mCost = 1; }