From f33923dc5614da2460af998088ea8274bc2b9aca Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Sat, 14 Mar 2026 22:29:53 +0100 Subject: [PATCH 1/4] Fixes #82 --- libs/JSystem/src/JUtility/JUTFader.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/JSystem/src/JUtility/JUTFader.cpp b/libs/JSystem/src/JUtility/JUTFader.cpp index 35bcb09d87..754979115c 100644 --- a/libs/JSystem/src/JUtility/JUTFader.cpp +++ b/libs/JSystem/src/JUtility/JUTFader.cpp @@ -25,12 +25,18 @@ void JUTFader::control() { if (mStatus == 1) { return; } - + switch (mStatus) { case 0: mColor.a = 0xFF; break; case 2: + #if AVOID_UB + if (field_0x8 == 0) { + mStatus = 1; + break; + } + #endif mColor.a = 0xFF - ((++field_0xa * 0xFF) / field_0x8); if (field_0xa >= field_0x8) { @@ -39,6 +45,12 @@ void JUTFader::control() { break; case 3: + #if AVOID_UB + if (field_0x8 == 0) { + mStatus = 0; + break; + } + #endif mColor.a = ((++field_0xa * 0xFF) / field_0x8); if (field_0xa >= field_0x8) { From 08e0af1493044ee88c6a25658a1b70dc40952cda Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Sat, 14 Mar 2026 22:33:58 +0100 Subject: [PATCH 2/4] Fixes #74 --- include/d/actor/d_a_npc_cd.h | 26 +++++++++++++------------- include/d/actor/d_a_passer_mng.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/d/actor/d_a_npc_cd.h b/include/d/actor/d_a_npc_cd.h index 2e86c867c6..3f942a5988 100644 --- a/include/d/actor/d_a_npc_cd.h +++ b/include/d/actor/d_a_npc_cd.h @@ -58,8 +58,8 @@ struct daNpcCd_HIO_Jnt_c : public JORReflexible { void genMessage(JORMContext*); #endif - /* 0x04 */ Vec jntT; - /* 0x10 */ SVec jntR; + /* 0x04 */ BE(Vec) jntT; + /* 0x10 */ struct { BE(s16) x, y, z; } jntR; }; struct daNpcCd_HIO_Child_c : public JORReflexible { @@ -71,17 +71,17 @@ struct daNpcCd_HIO_Child_c : public JORReflexible { #endif /* 0x004 */ daNpcCd_HIO_Jnt_c field_0x4[12]; - /* 0x124 */ s16 field_0x124[0x0C]; - /* 0x13C */ f32 mObjScale; - /* 0x140 */ s16 mAtn; - /* 0x144 */ f32 mAnmPlaySpeed; - /* 0x148 */ f32 mWalkAnmPlaySpeed; - /* 0x14C */ f32 mMaxSpeed; - /* 0x150 */ f32 mWalkMaxSpeed; - /* 0x154 */ f32 mCylH; - /* 0x158 */ f32 mCylR; - /* 0x15C */ f32 mChkWallH; - /* 0x160 */ f32 mChkWallR; + /* 0x124 */ BE(s16) field_0x124[0x0C]; + /* 0x13C */ BE(f32) mObjScale; + /* 0x140 */ BE(s16) mAtn; + /* 0x144 */ BE(f32) mAnmPlaySpeed; + /* 0x148 */ BE(f32) mWalkAnmPlaySpeed; + /* 0x14C */ BE(f32) mMaxSpeed; + /* 0x150 */ BE(f32) mWalkMaxSpeed; + /* 0x154 */ BE(f32) mCylH; + /* 0x158 */ BE(f32) mCylR; + /* 0x15C */ BE(f32) mChkWallH; + /* 0x160 */ BE(f32) mChkWallR; }; STATIC_ASSERT(sizeof(daNpcCd_HIO_Child_c) == 0x164); diff --git a/include/d/actor/d_a_passer_mng.h b/include/d/actor/d_a_passer_mng.h index 7a628ebead..a6a048fefd 100644 --- a/include/d/actor/d_a_passer_mng.h +++ b/include/d/actor/d_a_passer_mng.h @@ -253,7 +253,7 @@ public: struct Group { u8 field_0x00; - int field_0x04[0]; + BE(int) field_0x04[0]; }; static Group* mGroupTbl[4]; From eafc00383cc26131a66848e8e660aac93f52395f Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Sat, 14 Mar 2026 22:35:31 +0100 Subject: [PATCH 3/4] Fixes crash when entering the very first house --- src/d/actor/d_a_mirror.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d/actor/d_a_mirror.cpp b/src/d/actor/d_a_mirror.cpp index b66a095d5c..5468d70f87 100644 --- a/src/d/actor/d_a_mirror.cpp +++ b/src/d/actor/d_a_mirror.cpp @@ -208,6 +208,9 @@ void dMirror_packet_c::modelDraw(J3DModel* i_model, Mtx param_1) { color.a = kankyo->bg_amb_col[0].a; J3DModelData* modelData = i_model->getModelData(); +#if TARGET_PC + j3dSys.setTexture(modelData->getTexture()); +#endif u16 materialNum = modelData->getMaterialNum(); for (u16 i = 0; i < materialNum; i++) { J3DMatPacket* matPacket = i_model->getMatPacket(i); From a791288d953a93368ee44ff28a8cd062cd91b2f1 Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Sun, 15 Mar 2026 20:48:43 +0100 Subject: [PATCH 4/4] Fixes #80 ? --- include/d/d_com_inf_game.h | 20 ++++++++++++++++++++ include/d/d_save.h | 24 ++++++++++++++++++++++++ src/d/d_com_inf_game.cpp | 4 ++++ src/d/d_save.cpp | 20 ++++++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 5f578dd658..73aad5ae51 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -1084,7 +1084,11 @@ s32 dComIfGs_isDungeonItemWarp(int i_stageNo); void dComIfGs_BossLife_public_Set(s8); s8 dComIfGs_sense_type_change_Get(); void dComIfGs_sense_type_change_Set(s8); +#if TARGET_PC +cXyz dComIfGs_getWarpPlayerPos(); +#else cXyz& dComIfGs_getWarpPlayerPos(); +#endif const char* dComIfGs_getWarpStageName(); s16 dComIfGs_getWarpPlayerAngleY(); s8 dComIfGs_getWarpRoomNo(); @@ -1174,7 +1178,11 @@ void dComIfGs_setWarpItemData(char const* stage, cXyz pos, s16 angle, s8 roomNo, u8 param_5); void dComIfGs_setLastWarpMarkItemData(const char* stage, cXyz pos, s16 angle, s8 roomNo, u8, u8); const char* dComIfGs_getWarpStageName(); +#if TARGET_PC +cXyz dComIfGs_getWarpPlayerPos(); +#else cXyz& dComIfGs_getWarpPlayerPos(); +#endif s16 dComIfGs_getWarpPlayerAngleY(); s8 dComIfGs_getWarpRoomNo(); u8 dComIfGs_getWarpMarkFlag(); @@ -1420,7 +1428,11 @@ inline BOOL dComIfGs_isTransformLV(int i_no) { return g_dComIfG_gameInfo.info.getPlayer().getPlayerStatusB().isTransformLV(i_no); } +#if TARGET_PC +inline cXyz dComIfGs_getHorseRestartPos() { +#else inline cXyz& dComIfGs_getHorseRestartPos() { +#endif return g_dComIfG_gameInfo.info.getPlayer().getHorsePlace().getPos(); } @@ -1441,7 +1453,11 @@ inline void dComIfGs_setHorseRestart(const char* i_stageName, cXyz& i_pos, s16 i g_dComIfG_gameInfo.info.getPlayer().getHorsePlace().set(i_stageName, i_pos, i_angle, i_roomNo); } +#if TARGET_PC +inline cXyz dComIfGs_getPlayerFieldLastStayPos() { +#else inline cXyz& dComIfGs_getPlayerFieldLastStayPos() { +#endif return g_dComIfG_gameInfo.info.getPlayer().getPlayerFieldLastStayInfo().getPos(); } @@ -1483,7 +1499,11 @@ inline void dComIfGs_setPlayerFieldLastStayInfo(const char* i_stage, cXyz& i_pos i_point, i_region); } +#if TARGET_PC +inline cXyz dComIfGs_getLastWarpMarkPlayerPos() { +#else inline cXyz& dComIfGs_getLastWarpMarkPlayerPos() { +#endif return g_dComIfG_gameInfo.info.getPlayer().getPlayerLastMarkInfo().getPos(); } diff --git a/include/d/d_save.h b/include/d/d_save.h index 4b21e6673e..0228f25f29 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -219,13 +219,21 @@ public: void init(); void set(const char* i_name, const cXyz& i_pos, s16 i_angle, s8 i_roomNo); +#if TARGET_PC + cXyz getPos() { return cXyz(mPos); } +#else cXyz& getPos() { return mPos; } +#endif s16 getAngleY() const { return mAngleY; } const char* getStageName() const { return mName; } s8 getRoomNo() const { return mRoomNo; } private: +#if TARGET_PC + /* 0x00 */ BE(Vec) mPos; +#else /* 0x00 */ cXyz mPos; +#endif /* 0x0C */ BE(s16) mAngleY; /* 0x0E */ char mName[8]; /* 0x16 */ u8 mSpawnId; @@ -257,7 +265,11 @@ public: void onRegionBit(int i_region); void set(const char* i_name, const cXyz& i_pos, s16 i_angle, s8 i_spawn, u8 i_regionNo); +#if TARGET_PC + cXyz getPos() { return cXyz(mPos); } +#else cXyz& getPos() { return mPos; } +#endif s16 getAngleY() { return mAngleY; } char* getName() { return mName; } u8 getRegionNo() const { return mRegionNo; } @@ -267,7 +279,11 @@ public: private: +#if TARGET_PC + /* 0x00 */ BE(Vec) mPos; +#else /* 0x00 */ cXyz mPos; +#endif /* 0x0C */ BE(s16) mAngleY; /* 0x0E */ char mName[8]; /* 0x16 */ s8 mLastSpawnId; @@ -284,7 +300,11 @@ public: void init(); void setWarpItemData(const char* i_name, const cXyz& i_pos, s16 i_angle, s8 i_roomNo, u8, u8); +#if TARGET_PC + cXyz getPos() { return cXyz(mPos); } +#else cXyz& getPos() { return mPos; } +#endif s16 getAngleY() const { return mAngleY; } const char* getName() { return mName; } s8 getRoomNo() const { return mRoomNo; } @@ -293,7 +313,11 @@ public: void resetWarpAcceptStage() { mWarpAcceptStage = -1; } private: +#if TARGET_PC + /* 0x00 */ BE(Vec) mPos; +#else /* 0x00 */ cXyz mPos; +#endif /* 0x0C */ BE(s16) mAngleY; /* 0x0E */ char mName[8]; /* 0x16 */ u8 mSpawnId; diff --git a/src/d/d_com_inf_game.cpp b/src/d/d_com_inf_game.cpp index 4e0f8da165..8da33212cf 100644 --- a/src/d/d_com_inf_game.cpp +++ b/src/d/d_com_inf_game.cpp @@ -2660,7 +2660,11 @@ const char* dComIfGs_getWarpStageName() { return dComIfGs_getLastWarpMarkStageName(); } +#if TARGET_PC +cXyz dComIfGs_getWarpPlayerPos() { +#else cXyz& dComIfGs_getWarpPlayerPos() { +#endif return dComIfGs_getLastWarpMarkPlayerPos(); } diff --git a/src/d/d_save.cpp b/src/d/d_save.cpp index 52daf21404..868dc7cfca 100644 --- a/src/d/d_save.cpp +++ b/src/d/d_save.cpp @@ -197,7 +197,11 @@ BOOL dSv_player_status_b_c::isTransformLV(int i_no) const { void dSv_horse_place_c::init() { strcpy(mName, ""); +#if TARGET_PC + mPos = BE(0.0f, 0.0f, 0.0f); +#else mPos.set(0.0f, 0.0f, 0.0f); +#endif mAngleY = 0; mSpawnId = 0; mRoomNo = 0; @@ -228,7 +232,11 @@ void dSv_player_return_place_c::set(const char* i_name, s8 i_roomNo, u8 i_status void dSv_player_field_last_stay_info_c::init() { strcpy(mName, ""); +#if TARGET_PC + mPos = BE(0.0f, 0.0f, 0.0f); +#else mPos.set(0.0f, 0.0f, 0.0f); +#endif mAngleY = 0; mLastSpawnId = 0; mRegionNo = 1; @@ -244,7 +252,11 @@ void dSv_player_field_last_stay_info_c::set(const char* i_name, const cXyz& i_po s8 i_spawn, u8 i_regionNo) { JUT_ASSERT(468, strlen(i_name) <= 7); strcpy(mName, i_name); +#if TARGET_PC + mPos = i_pos; +#else mPos.set(i_pos); +#endif mAngleY = i_angle; mLastSpawnId = i_spawn; mRegionNo = i_regionNo; @@ -269,7 +281,11 @@ BOOL dSv_player_field_last_stay_info_c::isRegionBit(int i_region) const { void dSv_player_last_mark_info_c::init() { strcpy(mName, ""); +#if TARGET_PC + mPos = BE(0.0f, 0.0f, 0.0f); +#else mPos.set(0.0f, 0.0f, 0.0f); +#endif mAngleY = 0; mRoomNo = 0; mSpawnId = 0; @@ -283,7 +299,11 @@ void dSv_player_last_mark_info_c::init() { void dSv_player_last_mark_info_c::setWarpItemData(const char* i_name, const cXyz& i_pos, s16 i_angle, s8 i_roomNo, u8 unk_4, u8 unk_5) { strcpy(mName, i_name); +#if TARGET_PC + mPos = i_pos; +#else mPos.set(i_pos); +#endif mAngleY = i_angle; mRoomNo = i_roomNo;