diff options
| -rw-r--r-- | mm/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h | 7 | ||||
| -rw-r--r-- | mm/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/mm/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h b/mm/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h index ce7cf95fb..eaf7000fd 100644 --- a/mm/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h +++ b/mm/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h @@ -4,7 +4,12 @@ #include "global.h" #define BG_KIN2_PICTURE_SKULLTULA_COLLECTED(thisx) (((thisx)->params >> 5) & 1) -#define BG_KIN2_PICTURE_GET_3FC(thisx) ((u8)(((thisx & 0x3FC)) >> 2)) +// #region 2S2H [Port] The original calculation is ((u8)(((thisx & 0x3FC)) >> 2)), but this results in values well +// over 100. This value is ultimately used to left shift 1 to get the treasure flag. Bit shifts greater than the bit +// width are undefined behavior. On N64, this likely truncates to a value below 32. The correction below matches other +// uses of the Skulltula Token chest flag (see ENSI_GET_CHEST_FLAG and inline uses in z_tg_sw.c): +#define BG_KIN2_PICTURE_GET_3FC(thisx) ((u8)(((thisx & 0xFC)) >> 2)) +// #endregion #define BG_KIN2_PICTURE_SKULLTULA_SPAWN_PARAM(thisx) ((((thisx)->params & 0x1F) << 2) | 0xFF03) struct BgKin2Picture; diff --git a/mm/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h b/mm/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h index 6afe50e1a..02682ddd6 100644 --- a/mm/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h +++ b/mm/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h @@ -7,7 +7,12 @@ struct ObjMakekinsuta; #define OBJMAKEKINSUTA_GET_1F(thisx) (((thisx)->params >> 8) & 0x1F) #define OBJMAKEKINSUTA_GETS_3(params) ((params & 3) & 0xFF) -#define OBJMAKEKINSUTA_GETS_3FC(params) (((params & 0x3FC) >> 2) & 0xFF) +// #region 2S2H [Port] The original calculation is (((params & 0x3FC) >> 2) & 0xFF), but this results in values well +// over 100. This value is ultimately used to left shift 1 to get the treasure flag. Bit shifts greater than the bit +// width are undefined behavior. On N64, this likely truncates to a value below 32. The correction below matches other +// uses of the Skulltula Token chest flag (see ENSI_GET_CHEST_FLAG and inline uses in z_tg_sw.c): +#define OBJMAKEKINSUTA_GETS_3FC(params) (((params & 0xFC) >> 2) & 0xFF) +// #endregion #define OBJMAKEKINSUTA_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) typedef struct ObjMakekinsuta { |
