diff --git a/configure.py b/configure.py index e00799a89..7822c14be 100644 --- a/configure.py +++ b/configure.py @@ -526,7 +526,7 @@ config.libs = [ Object(Matching, "SSystem/SComponent/c_bg_s_gnd_chk.cpp"), Object(Matching, "SSystem/SComponent/c_bg_s_lin_chk.cpp"), Object(NonMatching, "SSystem/SComponent/c_bg_w.cpp"), - Object(NonMatching, "SSystem/SComponent/c_m2d.cpp"), + Object(Matching, "SSystem/SComponent/c_m2d.cpp"), Object(NonMatching, "SSystem/SComponent/c_m2d_g_box.cpp"), Object(NonMatching, "SSystem/SComponent/c_m3d.cpp"), Object(Matching, "SSystem/SComponent/c_m3d_g_aab.cpp"), diff --git a/include/JSystem/JUtility/JUTAssert.h b/include/JSystem/JUtility/JUTAssert.h index d1f509e7d..e54d47440 100644 --- a/include/JSystem/JUtility/JUTAssert.h +++ b/include/JSystem/JUtility/JUTAssert.h @@ -10,6 +10,14 @@ OSPanic(__FILE__, LINE, "Halt"); \ } +// Some asserts on floats have the wrong codegen with JUT_ASSERT's (COND) == 0 check. +// Using !(COND) instead fixes them. +#define JUT_ASSERT_FLOAT(LINE, COND) \ + if (!(COND)) { \ + JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND); \ + OSPanic(__FILE__, LINE, "Halt"); \ + } + #define JUT_PANIC(LINE) \ JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, "0"); \ OSPanic(__FILE__, LINE, "Halt"); diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index 1150df6ef..ef248f18d 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -326,6 +326,7 @@ private: /* 0x14 */ u8 mWeight; /* 0x15 */ u8 field_0x15; /* 0x16 */ u8 mDmg; + /* 0x18 */ /* vtable */ public: cCcD_Stts() {} diff --git a/src/SSystem/SComponent/c_m2d.cpp b/src/SSystem/SComponent/c_m2d.cpp index f3fe3a907..2009fd56e 100644 --- a/src/SSystem/SComponent/c_m2d.cpp +++ b/src/SSystem/SComponent/c_m2d.cpp @@ -17,7 +17,7 @@ void cM2d_CrossCirLin(cM2dGCir& circle, f32 x0, f32 y0, f32 x1, f32 y1, f32* pDs f32 c = (fVar1 * fVar1 + fVar15 * fVar15) - (circle.GetR() * circle.GetR()); f32 t; - JUT_ASSERT(0x47, c < 0.0f); + JUT_ASSERT_FLOAT(0x47, c < 0.0f); if (cM3d_IsZero(dVar13)) { if (!cM3d_IsZero(dVar14)) { @@ -48,7 +48,7 @@ void cM2d_CrossCirLin(cM2dGCir& circle, f32 x0, f32 y0, f32 x1, f32 y1, f32* pDs *pDstX = x0; *pDstY = y0; } else { - JUT_ASSERT(0x89, t >= 0.0f); + JUT_ASSERT_FLOAT(0x89, t >= 0.0f); *pDstX = x0 + (t * x1); *pDstY = y0 + (t * y1); } diff --git a/src/d/d_bg_s_acch.cpp b/src/d/d_bg_s_acch.cpp index b805379d7..b08d56b38 100644 --- a/src/d/d_bg_s_acch.cpp +++ b/src/d/d_bg_s_acch.cpp @@ -208,17 +208,8 @@ void dBgS_Acch::CrrPos(dBgS& i_bgs) { SetWaterIn(); } - // JUT_ASSERT's (COND) == 0 check screws up the codegen here. Using !(COND) instead fixes it. - // JUT_ASSERT(718, m_wtr.GetHeight() >= ground.y); - // JUT_ASSERT(719, m_wtr.GetHeight() <= top); - if (!(m_wtr.GetHeight() >= ground.y)) { - JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, 718, "m_wtr.GetHeight() >= ground.y"); - OSPanic(__FILE__, 718, "Halt"); - } - if (!(m_wtr.GetHeight() <= top)) { - JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, 719, "m_wtr.GetHeight() <= top"); - OSPanic(__FILE__, 719, "Halt"); - } + JUT_ASSERT_FLOAT(718, m_wtr.GetHeight() >= ground.y); + JUT_ASSERT_FLOAT(719, m_wtr.GetHeight() <= top); } } }