diff --git a/configure.py b/configure.py index e44e9e7a..253ed955 100644 --- a/configure.py +++ b/configure.py @@ -951,7 +951,7 @@ config.libs = [ Object(Matching, "actor/ac_douzou.c"), Object(Matching, "actor/ac_dummy.c"), Object(Matching, "actor/ac_dump.c"), - Object(NonMatching, "actor/ac_effectbg.c"), + Object(Matching, "actor/ac_effectbg.c"), Object(NonMatching, "actor/ac_event_manager.c"), Object(Matching, "actor/ac_fallS.c"), Object(Matching, "actor/ac_fallSESW.c"), diff --git a/include/ac_effectbg.h b/include/ac_effectbg.h index a4f24917..8cacca04 100644 --- a/include/ac_effectbg.h +++ b/include/ac_effectbg.h @@ -3,11 +3,16 @@ #include "types.h" #include "m_actor.h" +#include "c_keyframe.h" #ifdef __cplusplus extern "C" { #endif +#define EffectBg_ENTRY_NUM 3 +#define EffectBg_JOINT_NUM 4 +#define EffectBg_JOINT_ALL 6 + enum { EffectBG_EFFECT_SHAKE, EffectBG_EFFECT_CUT_LEFT, @@ -15,11 +20,72 @@ enum { EffectBG_EFFECT_SHAKE_SMALL, EffectBG_EFFECT_SHAKE_LARGE, - EffectBG_EFFECT_NUM + EffectBG_EFFECT_NUM, + + EffectBG_EFFECT_CUT_RIGHT_PALM = EffectBG_EFFECT_NUM, + EffectBG_EFFECT_CUT_RIGHT_CEDAR, + EffectBG_EFFECT_CUT_RIGHT_GOLD +}; + +enum { + EffectBG_VARIANT_TREE_SMALL = -1, + EffectBG_VARIANT_TREE_MED, + EffectBG_VARIANT_TREE_LARGE, + EffectBG_VARIANT_TREE_FULL, + + EffectBG_VARIANT_NUM, + EffectBG_VARIANT_TREE_XMAS = EffectBG_VARIANT_NUM, + EffectBG_VARIANT_PALM_SMALL, + EffectBG_VARIANT_PALM_MED, + EffectBG_VARIANT_PALM_LARGE, + EffectBG_VARIANT_PALM_FULL, + EffectBG_VARIANT_CEDAR_SMALL, + EffectBG_VARIANT_CEDAR_MED, + EffectBG_VARIANT_CEDAR_LARGE, + EffectBG_VARIANT_CEDAR_FULL, + EffectBG_VARIANT_CEDAR_XMAS, + EffectBG_VARIANT_GOLD_SMALL, + EffectBG_VARIANT_GOLD_MED, + EffectBG_VARIANT_GOLD_LARGE, + EffectBG_VARIANT_GOLD_FULL, + + EffectBG_VARIANT_ALL }; typedef void (*EffectBG_MAKE_EFFECTBG_PROC)(GAME*, s16, s16, xyz_t*); +typedef struct effectbg_entry_s { + cKF_SkeletonInfo_R_c keyframe; + Mtx mtx[2][EffectBg_JOINT_ALL]; + xyz_t base_pos; + xyz_t effect_pos; + s_xyz work[EffectBg_JOINT_NUM]; + s_xyz morph[EffectBg_JOINT_NUM]; + s16 timer; + s16 timer_max; + s16 type; + s16 variant; + s16 add_angle; + s16 leaf_angle; + u8 status; + int block_ux; + int block_uz; +} EffectBg_c; + +typedef struct effectbg_actor_s EFFECTBG_ACTOR; + +struct effectbg_actor_s { + ACTOR actor_class; + int _174; + EffectBg_c effect[EffectBg_ENTRY_NUM]; + int _CE8; + u16* tree_pal; + u16* palm_pal; + u16* palm_pal2; + u16* gold_pal; + int _CFC; +}; + extern ACTOR_PROFILE Effectbg_Profile; #ifdef __cplusplus diff --git a/include/audio_defs.h b/include/audio_defs.h index 8806f218..d9cc8d2a 100644 --- a/include/audio_defs.h +++ b/include/audio_defs.h @@ -83,6 +83,14 @@ typedef enum audio_sound_effects { NA_SE_5E = 0x5E, NA_SE_5F = 0x5F, NA_SE_60 = 0x60, + NA_SE_61 = 0x61, + + NA_SE_63 = 0x63, + NA_SE_64 = 0x64, + NA_SE_65 = 0x65, + NA_SE_66 = 0x66, + NA_SE_67 = 0x67, + NA_SE_68 = 0x68, NA_SE_GASAGOSO = 0x69, NA_SE_6A = 0x6A, @@ -102,6 +110,7 @@ typedef enum audio_sound_effects { NA_SE_KA_BUZZ = 0xCF, + NA_SE_108 = 0x108, NA_SE_ROD_STROKE = 0x109, NA_SE_ROD_BACK, NA_SE_10B, diff --git a/include/sys_matrix.h b/include/sys_matrix.h index 50b234f6..77fd30c2 100644 --- a/include/sys_matrix.h +++ b/include/sys_matrix.h @@ -33,8 +33,8 @@ extern Mtx* _Matrix_to_Mtx(Mtx* dest); extern Mtx* _Matrix_to_Mtx_new(GRAPH* graph); extern void Matrix_Position(xyz_t* old_pos, xyz_t* new_pos); extern void Matrix_Position_Zero(xyz_t* screen_pos); -extern void Matrix_Position_VecX(xyz_t* screen_pos, f32 x); -extern void Matrix_Position_VecZ(xyz_t* screen_pos, f32 x); +extern void Matrix_Position_VecX(f32 x, xyz_t* screen_pos); +extern void Matrix_Position_VecZ(f32 z, xyz_t* screen_pos); extern void Matrix_copy_MtxF(MtxF* dest, MtxF* src); extern void Matrix_MtxtoMtxF(Mtx* src, MtxF* dest); extern void Matrix_reverse(MtxF* m); diff --git a/src/actor/ac_effectbg.c b/src/actor/ac_effectbg.c new file mode 100644 index 00000000..db80bed0 --- /dev/null +++ b/src/actor/ac_effectbg.c @@ -0,0 +1,1165 @@ +#include "ac_effectbg.h" + +#include "m_name_table.h" +#include "m_field_info.h" +#include "m_common_data.h" +#include "m_debug.h" +#include "sys_matrix.h" +#include "m_rcp.h" + +#define EffectBg_STATUS_ACTIVE (1 << 0) +#define EffectBg_STATUS_1 (1 << 1) +#define EffectBg_STATUS_XMAS (1 << 2) +#define EffectBg_STATUS_PALM (1 << 3) +#define EffectBg_STATUS_CEDAR (1 << 4) +#define EffectBg_STATUS_GOLD (1 << 5) +#define EffectBg_STATUS_6 (1 << 6) +#define EffectBg_STATUS_7 (1 << 7) + +#define EffectBG_IS_SHAKE(t) \ + ((t) == EffectBG_EFFECT_SHAKE || (t) == EffectBG_EFFECT_SHAKE_SMALL || (t) == EffectBG_EFFECT_SHAKE_LARGE) + +// tree, cherry +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree3_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree3_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree3_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree3_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree3_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree3_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree4_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree4_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree4_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree4_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree4_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree4_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree5_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree5_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_f_tree5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree5_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree5_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree5_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_f_tree5_shakeL; + +// tree, summer +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree3_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree3_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree3_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree3_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree3_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree3_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree4_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree4_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree4_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree4_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree4_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree4_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree5_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree5_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_tree5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree5_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree5_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree5_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_tree5_shakeL; + +// tree, winter +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_tree3_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_tree3_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_tree3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree3_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree3_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree3_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree3_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_tree4_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_tree4_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_tree4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree4_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree4_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree4_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_w_tree4_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_x_tree5_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_x_tree5_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_x_tree5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_x_tree5_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_x_tree5_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_x_tree5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_x_tree5_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_x_tree5_shakeL; + +// palm, summer +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm3_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm3_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm3_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm3_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm3_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm3_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm4_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm4_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm4_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm4_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm4_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm4_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm5_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm5_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_palm5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm5_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm5_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm5_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_palm5_shakeL; + +// palm, winter +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm3_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm3_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm3_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm3_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm3_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm3_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm4_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm4_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm4_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm4_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm4_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm4_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm5_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm5_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_palm5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm5_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm5_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm5_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_w_palm5_shakeL; + +// cedar, summer +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar3_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar3_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar3_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar3_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar3_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar3_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar4_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar4_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar4_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar4_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar4_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar4_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar5_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar5_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_s_cedar5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar5_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar5_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar5_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_s_cedar5_shakeL; + +// cedar, winter +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_cedar3_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_cedar3_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_cedar3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar3_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar3_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar3_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar3_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar3_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_cedar4_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_cedar4_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_w_cedar4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar4_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar4_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar4_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar4_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_w_cedar4_shakeL; + +extern cKF_Skeleton_R_c cKF_bs_r_ef_x_cedar5_shake; +extern cKF_Skeleton_R_c cKF_bs_r_ef_x_cedar5_cutR; +extern cKF_Skeleton_R_c cKF_bs_r_ef_x_cedar5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_x_cedar5_shake; +extern cKF_Animation_R_c cKF_ba_r_ef_x_cedar5_cutR; +extern cKF_Animation_R_c cKF_ba_r_ef_x_cedar5_cutL; +extern cKF_Animation_R_c cKF_ba_r_ef_x_cedar5_shakeS; +extern cKF_Animation_R_c cKF_ba_r_ef_x_cedar5_shakeL; + +static cKF_Skeleton_R_c* cherry_tree_model_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_bs_r_ef_f_tree3_shake, + &cKF_bs_r_ef_f_tree3_cutR, + &cKF_bs_r_ef_f_tree3_cutL, + &cKF_bs_r_ef_f_tree3_shake, + &cKF_bs_r_ef_f_tree3_shake, + }, + { + &cKF_bs_r_ef_f_tree4_shake, + &cKF_bs_r_ef_f_tree4_cutR, + &cKF_bs_r_ef_f_tree4_cutL, + &cKF_bs_r_ef_f_tree4_shake, + &cKF_bs_r_ef_f_tree4_shake, + }, + { + &cKF_bs_r_ef_f_tree5_shake, + &cKF_bs_r_ef_f_tree5_cutR, + &cKF_bs_r_ef_f_tree5_cutL, + &cKF_bs_r_ef_f_tree5_shake, + &cKF_bs_r_ef_f_tree5_shake, + }, +}; + +static cKF_Animation_R_c* cherry_tree_anime_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_ba_r_ef_f_tree3_shake, + &cKF_ba_r_ef_f_tree3_cutR, + &cKF_ba_r_ef_f_tree3_cutL, + &cKF_ba_r_ef_f_tree3_shakeS, + &cKF_ba_r_ef_f_tree3_shakeL, + }, + { + &cKF_ba_r_ef_f_tree4_shake, + &cKF_ba_r_ef_f_tree4_cutR, + &cKF_ba_r_ef_f_tree4_cutL, + &cKF_ba_r_ef_f_tree4_shakeS, + &cKF_ba_r_ef_f_tree4_shakeL, + }, + { + &cKF_ba_r_ef_f_tree5_shake, + &cKF_ba_r_ef_f_tree5_cutR, + &cKF_ba_r_ef_f_tree5_cutL, + &cKF_ba_r_ef_f_tree5_shakeS, + &cKF_ba_r_ef_f_tree5_shakeL, + }, +}; + +static cKF_Skeleton_R_c* summer_tree_model_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_bs_r_ef_s_tree3_shake, + &cKF_bs_r_ef_s_tree3_cutR, + &cKF_bs_r_ef_s_tree3_cutL, + &cKF_bs_r_ef_s_tree3_shake, + &cKF_bs_r_ef_s_tree3_shake, + }, + { + &cKF_bs_r_ef_s_tree4_shake, + &cKF_bs_r_ef_s_tree4_cutR, + &cKF_bs_r_ef_s_tree4_cutL, + &cKF_bs_r_ef_s_tree4_shake, + &cKF_bs_r_ef_s_tree4_shake, + }, + { + &cKF_bs_r_ef_s_tree5_shake, + &cKF_bs_r_ef_s_tree5_cutR, + &cKF_bs_r_ef_s_tree5_cutL, + &cKF_bs_r_ef_s_tree5_shake, + &cKF_bs_r_ef_s_tree5_shake, + }, +}; + +static cKF_Animation_R_c* summer_tree_anime_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_ba_r_ef_s_tree3_shake, + &cKF_ba_r_ef_s_tree3_cutR, + &cKF_ba_r_ef_s_tree3_cutL, + &cKF_ba_r_ef_s_tree3_shakeS, + &cKF_ba_r_ef_s_tree3_shakeL, + }, + { + &cKF_ba_r_ef_s_tree4_shake, + &cKF_ba_r_ef_s_tree4_cutR, + &cKF_ba_r_ef_s_tree4_cutL, + &cKF_ba_r_ef_s_tree4_shakeS, + &cKF_ba_r_ef_s_tree4_shakeL, + }, + { + &cKF_ba_r_ef_s_tree5_shake, + &cKF_ba_r_ef_s_tree5_cutR, + &cKF_ba_r_ef_s_tree5_cutL, + &cKF_ba_r_ef_s_tree5_shakeS, + &cKF_ba_r_ef_s_tree5_shakeL, + }, +}; + +static cKF_Skeleton_R_c* winter_tree_model_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_bs_r_ef_w_tree3_shake, + &cKF_bs_r_ef_w_tree3_cutR, + &cKF_bs_r_ef_w_tree3_cutL, + &cKF_bs_r_ef_w_tree3_shake, + &cKF_bs_r_ef_w_tree3_shake, + }, + { + &cKF_bs_r_ef_w_tree4_shake, + &cKF_bs_r_ef_w_tree4_cutR, + &cKF_bs_r_ef_w_tree4_cutL, + &cKF_bs_r_ef_w_tree4_shake, + &cKF_bs_r_ef_w_tree4_shake, + }, + { + &cKF_bs_r_ef_x_tree5_shake, + &cKF_bs_r_ef_x_tree5_cutR, + &cKF_bs_r_ef_x_tree5_cutL, + &cKF_bs_r_ef_x_tree5_shake, + &cKF_bs_r_ef_x_tree5_shake, + }, +}; + +static cKF_Animation_R_c* winter_tree_anime_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_ba_r_ef_w_tree3_shake, + &cKF_ba_r_ef_w_tree3_cutR, + &cKF_ba_r_ef_w_tree3_cutL, + &cKF_ba_r_ef_w_tree3_shakeS, + &cKF_ba_r_ef_w_tree3_shakeL, + }, + { + &cKF_ba_r_ef_w_tree4_shake, + &cKF_ba_r_ef_w_tree4_cutR, + &cKF_ba_r_ef_w_tree4_cutL, + &cKF_ba_r_ef_w_tree4_shakeS, + &cKF_ba_r_ef_w_tree4_shakeL, + }, + { + &cKF_ba_r_ef_x_tree5_shake, + &cKF_ba_r_ef_x_tree5_cutR, + &cKF_ba_r_ef_x_tree5_cutL, + &cKF_ba_r_ef_x_tree5_shakeS, + &cKF_ba_r_ef_x_tree5_shakeL, + }, +}; + +static cKF_Skeleton_R_c* summer_palm_model_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_bs_r_ef_s_palm3_shake, + &cKF_bs_r_ef_s_palm3_cutR, + &cKF_bs_r_ef_s_palm3_cutL, + &cKF_bs_r_ef_s_palm3_shake, + &cKF_bs_r_ef_s_palm3_shake, + }, + { + &cKF_bs_r_ef_s_palm4_shake, + &cKF_bs_r_ef_s_palm4_cutR, + &cKF_bs_r_ef_s_palm4_cutL, + &cKF_bs_r_ef_s_palm4_shake, + &cKF_bs_r_ef_s_palm4_shake, + }, + { + &cKF_bs_r_ef_s_palm5_shake, + &cKF_bs_r_ef_s_palm5_cutR, + &cKF_bs_r_ef_s_palm5_cutL, + &cKF_bs_r_ef_s_palm5_shake, + &cKF_bs_r_ef_s_palm5_shake, + }, +}; + +static cKF_Animation_R_c* summer_palm_anime_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_ba_r_ef_s_palm3_shake, + &cKF_ba_r_ef_s_palm3_cutR, + &cKF_ba_r_ef_s_palm3_cutL, + &cKF_ba_r_ef_s_palm3_shakeS, + &cKF_ba_r_ef_s_palm3_shakeL, + }, + { + &cKF_ba_r_ef_s_palm4_shake, + &cKF_ba_r_ef_s_palm4_cutR, + &cKF_ba_r_ef_s_palm4_cutL, + &cKF_ba_r_ef_s_palm4_shakeS, + &cKF_ba_r_ef_s_palm4_shakeL, + }, + { + &cKF_ba_r_ef_s_palm5_shake, + &cKF_ba_r_ef_s_palm5_cutR, + &cKF_ba_r_ef_s_palm5_cutL, + &cKF_ba_r_ef_s_palm5_shakeS, + &cKF_ba_r_ef_s_palm5_shakeL, + }, +}; + +static cKF_Skeleton_R_c* winter_palm_model_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_bs_r_ef_w_palm3_shake, + &cKF_bs_r_ef_w_palm3_cutR, + &cKF_bs_r_ef_w_palm3_cutL, + &cKF_bs_r_ef_w_palm3_shake, + &cKF_bs_r_ef_w_palm3_shake, + }, + { + &cKF_bs_r_ef_w_palm4_shake, + &cKF_bs_r_ef_w_palm4_cutR, + &cKF_bs_r_ef_w_palm4_cutL, + &cKF_bs_r_ef_w_palm4_shake, + &cKF_bs_r_ef_w_palm4_shake, + }, + { + &cKF_bs_r_ef_w_palm5_shake, + &cKF_bs_r_ef_w_palm5_cutR, + &cKF_bs_r_ef_w_palm5_cutL, + &cKF_bs_r_ef_w_palm5_shake, + &cKF_bs_r_ef_w_palm5_shake, + }, +}; + +static cKF_Animation_R_c* winter_palm_anime_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_ba_r_ef_w_palm3_shake, + &cKF_ba_r_ef_w_palm3_cutR, + &cKF_ba_r_ef_w_palm3_cutL, + &cKF_ba_r_ef_w_palm3_shakeS, + &cKF_ba_r_ef_w_palm3_shakeL, + }, + { + &cKF_ba_r_ef_w_palm4_shake, + &cKF_ba_r_ef_w_palm4_cutR, + &cKF_ba_r_ef_w_palm4_cutL, + &cKF_ba_r_ef_w_palm4_shakeS, + &cKF_ba_r_ef_w_palm4_shakeL, + }, + { + &cKF_ba_r_ef_w_palm5_shake, + &cKF_ba_r_ef_w_palm5_cutR, + &cKF_ba_r_ef_w_palm5_cutL, + &cKF_ba_r_ef_w_palm5_shakeS, + &cKF_ba_r_ef_w_palm5_shakeL, + }, +}; + +static cKF_Skeleton_R_c* summer_cedar_model_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_bs_r_ef_s_cedar3_shake, + &cKF_bs_r_ef_s_cedar3_cutR, + &cKF_bs_r_ef_s_cedar3_cutL, + &cKF_bs_r_ef_s_cedar3_shake, + &cKF_bs_r_ef_s_cedar3_shake, + }, + { + &cKF_bs_r_ef_s_cedar4_shake, + &cKF_bs_r_ef_s_cedar4_cutR, + &cKF_bs_r_ef_s_cedar4_cutL, + &cKF_bs_r_ef_s_cedar4_shake, + &cKF_bs_r_ef_s_cedar4_shake, + }, + { + &cKF_bs_r_ef_s_cedar5_shake, + &cKF_bs_r_ef_s_cedar5_cutR, + &cKF_bs_r_ef_s_cedar5_cutL, + &cKF_bs_r_ef_s_cedar5_shake, + &cKF_bs_r_ef_s_cedar5_shake, + }, +}; + +static cKF_Animation_R_c* summer_cedar_anime_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_ba_r_ef_s_cedar3_shake, + &cKF_ba_r_ef_s_cedar3_cutR, + &cKF_ba_r_ef_s_cedar3_cutL, + &cKF_ba_r_ef_s_cedar3_shakeS, + &cKF_ba_r_ef_s_cedar3_shakeL, + }, + { + &cKF_ba_r_ef_s_cedar4_shake, + &cKF_ba_r_ef_s_cedar4_cutR, + &cKF_ba_r_ef_s_cedar4_cutL, + &cKF_ba_r_ef_s_cedar4_shakeS, + &cKF_ba_r_ef_s_cedar4_shakeL, + }, + { + &cKF_ba_r_ef_s_cedar5_shake, + &cKF_ba_r_ef_s_cedar5_cutR, + &cKF_ba_r_ef_s_cedar5_cutL, + &cKF_ba_r_ef_s_cedar5_shakeS, + &cKF_ba_r_ef_s_cedar5_shakeL, + }, +}; + +static cKF_Skeleton_R_c* winter_cedar_model_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_bs_r_ef_w_cedar3_shake, + &cKF_bs_r_ef_w_cedar3_cutR, + &cKF_bs_r_ef_w_cedar3_cutL, + &cKF_bs_r_ef_w_cedar3_shake, + &cKF_bs_r_ef_w_cedar3_shake, + }, + { + &cKF_bs_r_ef_w_cedar4_shake, + &cKF_bs_r_ef_w_cedar4_cutR, + &cKF_bs_r_ef_w_cedar4_cutL, + &cKF_bs_r_ef_w_cedar4_shake, + &cKF_bs_r_ef_w_cedar4_shake, + }, + { + &cKF_bs_r_ef_x_cedar5_shake, + &cKF_bs_r_ef_x_cedar5_cutR, + &cKF_bs_r_ef_x_cedar5_cutL, + &cKF_bs_r_ef_x_cedar5_shake, + &cKF_bs_r_ef_x_cedar5_shake, + }, +}; + +static cKF_Animation_R_c* winter_cedar_anime_tbl[][EffectBG_EFFECT_NUM] = { + { + &cKF_ba_r_ef_w_cedar3_shake, + &cKF_ba_r_ef_w_cedar3_cutR, + &cKF_ba_r_ef_w_cedar3_cutL, + &cKF_ba_r_ef_w_cedar3_shakeS, + &cKF_ba_r_ef_w_cedar3_shakeL, + }, + { + &cKF_ba_r_ef_w_cedar4_shake, + &cKF_ba_r_ef_w_cedar4_cutR, + &cKF_ba_r_ef_w_cedar4_cutL, + &cKF_ba_r_ef_w_cedar4_shakeS, + &cKF_ba_r_ef_w_cedar4_shakeL, + }, + { + &cKF_ba_r_ef_x_cedar5_shake, + &cKF_ba_r_ef_x_cedar5_cutR, + &cKF_ba_r_ef_x_cedar5_cutL, + &cKF_ba_r_ef_x_cedar5_shakeS, + &cKF_ba_r_ef_x_cedar5_shakeL, + }, +}; + +static void Effectbg_actor_ct(ACTOR* actorx, GAME* game); +static void Effectbg_actor_dt(ACTOR* actorx, GAME* game); +static void Effectbg_actor_move(ACTOR* actorx, GAME* game); +static void Effectbg_actor_draw(ACTOR* actorx, GAME* game); + +// clang-format off +ACTOR_PROFILE Effectbg_Profile = { + mAc_PROFILE_EFFECTBG, + ACTOR_PART_EFFECT, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_KEEP, + sizeof(EFFECTBG_ACTOR), + &Effectbg_actor_ct, + &Effectbg_actor_dt, + &Effectbg_actor_move, + &Effectbg_actor_draw, + NULL, +}; +// clang-format on + +static void Make_EffectBG(GAME* game, s16 type, s16 variant, xyz_t* pos); + +static void EffectBG_object_dt(EffectBg_c* efbg, GAME* game); + +static EffectBg_c* efbg_start_p = NULL; + +static void Effectbg_actor_ct(ACTOR* actorx, GAME* game) { + EFFECTBG_ACTOR* effect_actor = (EFFECTBG_ACTOR*)actorx; + mFM_field_pal_c* field_pal = mFI_GetFieldPal(); + EffectBg_c* efbg; + int i; + + if (field_pal != NULL) { + effect_actor->tree_pal = field_pal->cedar_tree_pal; + effect_actor->palm_pal = field_pal->palm_tree_pal; + effect_actor->palm_pal2 = field_pal->palm_tree_pal; + effect_actor->gold_pal = field_pal->golden_tree_pal; + } + + efbg_start_p = effect_actor->effect; + efbg = effect_actor->effect; + for (i = 0; i < EffectBg_ENTRY_NUM; i++) { + EffectBG_object_dt(efbg, game); + efbg++; + } + + CLIP(make_effect_bg_proc) = &Make_EffectBG; +} + +static void Effectbg_actor_dt(ACTOR* actorx, GAME* game) { + // nothing +} + +static int EfbgBgitemTreeCheck(xyz_t pos) { + mActor_name_t* fg_p = mFI_GetUnitFG(pos); + mActor_name_t item; + int stump; + int tree; + + if (fg_p != NULL) { + item = *fg_p; + } else { + return FALSE; + } + + stump = IS_ITEM_TREE_STUMP(item); + tree = IS_ITEM_COLLIDEABLE_TREE(item); + return (stump | tree) ? TRUE : FALSE; +} + +static void EffectBG_Make_Leafs(EffectBg_c* efbg, GAME* game, xyz_t pos, s16 count, s16 type) { + xyz_t effect_pos; + u32 season = Common_Get(time).season; + s16 bush_happa_type; + s16 bush_yuki_type; + + if (EffectBG_IS_SHAKE(type)) { + bush_yuki_type = 1; + + if (Common_Get(time).term_idx == mTM_TERM_4) { + bush_happa_type = 6; + } else { + bush_happa_type = 4; + } + } else if (type == EffectBG_EFFECT_CUT_RIGHT) { + bush_yuki_type = 0; + + if (Common_Get(time).term_idx == mTM_TERM_4) { + bush_happa_type = 6; + } else { + bush_happa_type = 4; + } + } else if (type == EffectBG_EFFECT_CUT_RIGHT_PALM) { + bush_yuki_type = 0; + bush_happa_type = 0x2000 | 4; + } else if (type == EffectBG_EFFECT_CUT_RIGHT_CEDAR) { + bush_yuki_type = 0; + bush_happa_type = 0x4000 | 4; + } else if (type == EffectBG_EFFECT_CUT_RIGHT_GOLD) { + bush_yuki_type = 0; + + if (Common_Get(time).term_idx == mTM_TERM_4) { + bush_happa_type = 0x4000 | 0x2000 | 6; + } else { + bush_happa_type = 0x4000 | 0x2000 | 4; + } + } else { + if (Common_Get(time).term_idx == 4) { + bush_happa_type = 7; + } else { + bush_happa_type = 5; + } + + bush_yuki_type = 0; + } + + if ((efbg->status & EffectBg_STATUS_GOLD) != 0 || efbg->variant == EffectBG_VARIANT_GOLD_SMALL) { + bush_happa_type |= 0x4000 | 0x2000; + } else if ((efbg->status & EffectBg_STATUS_PALM) != 0 || efbg->variant == EffectBG_VARIANT_PALM_SMALL) { + bush_happa_type |= 0x2000; + } else if ((efbg->status & EffectBg_STATUS_CEDAR) != 0 || efbg->variant == EffectBG_VARIANT_CEDAR_SMALL) { + bush_happa_type |= 0x4000; + } + + while (count-- != 0) { + effect_pos = pos; + + if (type != EffectBG_EFFECT_CUT_RIGHT && type != EffectBG_EFFECT_CUT_RIGHT_PALM && + type != EffectBG_EFFECT_CUT_RIGHT_CEDAR && type != EffectBG_EFFECT_CUT_RIGHT_GOLD) { + if ((efbg->status & EffectBg_STATUS_CEDAR) != 0 && efbg->variant == EffectBG_VARIANT_TREE_MED) { + effect_pos.x += RANDOM2_F(30.0f); + effect_pos.y += RANDOM2_F(30.0f); + effect_pos.z += RANDOM2_F(30.0f); + } else { + effect_pos.x += RANDOM2_F(40.0f); + effect_pos.y += RANDOM2_F(40.0f); + effect_pos.z += RANDOM2_F(40.0f); + } + } else { + effect_pos.y += 60.0f; + } + + if (type != 3) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_BUSH_HAPPA, effect_pos, 2, 0, game, RSV_NO, 0, bush_happa_type); + } + + if (season == mTM_SEASON_WINTER) { + effect_pos = pos; + + if ((efbg->status & EffectBg_STATUS_CEDAR) != 0 && efbg->variant == EffectBG_VARIANT_TREE_MED) { + effect_pos.x += RANDOM2_F(30.0f); + effect_pos.y += RANDOM2_F(30.0f); + effect_pos.z += RANDOM2_F(30.0f); + } else { + effect_pos.x += RANDOM2_F(40.0f); + effect_pos.y += RANDOM2_F(40.0f); + effect_pos.z += RANDOM2_F(40.0f); + } + + eEC_CLIP->effect_make_proc(eEC_EFFECT_BUSH_YUKI, effect_pos, 2, 0, game, RSV_NO, 0, bush_yuki_type); + } + } +} + +static void EffectBG_object_ct(EffectBg_c* efbg, GAME* game, s16 type, s16 variant) { + cKF_Skeleton_R_c* skeleton; + cKF_Animation_R_c* animation; + u32 season = Common_Get(time).season; + + if (variant == EffectBG_VARIANT_TREE_XMAS || variant == EffectBG_VARIANT_CEDAR_XMAS) { + variant -= 1; // convert to the full size + efbg->status |= EffectBg_STATUS_XMAS; + } + + // convert to the equivalent 'normal tree' type + if (variant >= EffectBG_VARIANT_GOLD_SMALL) { + variant -= (EffectBG_VARIANT_GOLD_SMALL - EffectBG_VARIANT_TREE_SMALL); + efbg->status |= EffectBg_STATUS_GOLD; + } else if (variant >= EffectBG_VARIANT_CEDAR_SMALL) { + variant -= (EffectBG_VARIANT_CEDAR_SMALL - EffectBG_VARIANT_TREE_SMALL); + efbg->status |= EffectBg_STATUS_CEDAR; + } else if (variant >= EffectBG_VARIANT_PALM_SMALL) { + variant -= (EffectBG_VARIANT_PALM_SMALL - EffectBG_VARIANT_TREE_SMALL); + efbg->status |= EffectBg_STATUS_PALM; + } + + if ((efbg->status & EffectBg_STATUS_CEDAR) != 0) { + if (season == mTM_SEASON_WINTER) { + skeleton = winter_cedar_model_tbl[variant][type]; + animation = winter_cedar_anime_tbl[variant][type]; + } else { + skeleton = summer_cedar_model_tbl[variant][type]; + animation = summer_cedar_anime_tbl[variant][type]; + } + } else if ((efbg->status & EffectBg_STATUS_PALM) != 0) { + if (season == mTM_SEASON_WINTER) { + skeleton = winter_palm_model_tbl[variant][type]; + animation = winter_palm_anime_tbl[variant][type]; + } else { + skeleton = summer_palm_model_tbl[variant][type]; + animation = summer_palm_anime_tbl[variant][type]; + } + } else { + if (season == mTM_SEASON_WINTER) { + skeleton = winter_tree_model_tbl[variant][type]; + animation = winter_tree_anime_tbl[variant][type]; + } else if (Common_Get(time).term_idx == mTM_TERM_4) { + skeleton = cherry_tree_model_tbl[variant][type]; + animation = cherry_tree_anime_tbl[variant][type]; + } else { + skeleton = summer_tree_model_tbl[variant][type]; + animation = summer_tree_anime_tbl[variant][type]; + } + } + + cKF_SkeletonInfo_R_ct(&efbg->keyframe, skeleton, animation, efbg->work, efbg->morph); + cKF_SkeletonInfo_R_init_standard_stop(&efbg->keyframe, animation, NULL); + cKF_SkeletonInfo_R_play(&efbg->keyframe); + efbg->keyframe.frame_control.speed = 0.5f; + + efbg->status |= EffectBg_STATUS_ACTIVE; + efbg->type = type; + efbg->variant = variant; + if (type == EffectBG_EFFECT_SHAKE_SMALL) { + efbg->timer_max = 18; + efbg->base_pos.y += 1.0f; + } else if (type == EffectBG_EFFECT_SHAKE_LARGE) { + efbg->timer_max = 82; + efbg->base_pos.y += 1.0f; + } else if (type == EffectBG_EFFECT_SHAKE) { + efbg->timer_max = 22; + efbg->base_pos.y += 1.0f; + } else { + efbg->base_pos.y += 2.0f; + + switch (variant) { + case EffectBG_VARIANT_TREE_MED: + sAdo_OngenTrgStart(NA_SE_63, &efbg->base_pos); + break; + case EffectBG_VARIANT_TREE_LARGE: + sAdo_OngenTrgStart(NA_SE_65, &efbg->base_pos); + break; + case EffectBG_VARIANT_TREE_FULL: + sAdo_OngenTrgStart(NA_SE_67, &efbg->base_pos); + break; + } + + efbg->timer_max = 98; + } + + if ((efbg->status & EffectBg_STATUS_PALM) != 0 && efbg->variant == EffectBG_VARIANT_TREE_FULL) { + efbg->base_pos.y += (f32)(int)GETREG(TAKREG, 50) * 0.1f; + efbg->base_pos.z += -2.0f + (f32)(int)GETREG(TAKREG, 51) * 0.1f; + } else if ((efbg->status & EffectBg_STATUS_CEDAR) != 0) { + efbg->base_pos.y += 0.5f; + efbg->base_pos.z += 0.5f; + } + + if (Common_Get(time).term_idx == mTM_TERM_16 || Common_Get(time).term_idx == mTM_TERM_15) { + mFI_Wpos2UtNum_inBlock(&efbg->block_ux, &efbg->block_uz, efbg->base_pos); + } else { + efbg->block_ux = 0; + efbg->block_uz = 0; + } + + efbg->timer = 0; +} + +static void EffectBG_object_dt(EffectBg_c* efbg, GAME* game) { + efbg->status = 0; +} + +static void EffectBG_object_move(EffectBg_c* efbg, GAME* game) { + xyz_t check_pos = efbg->effect_pos; + f32 ground_y; + + if (efbg->type == EffectBG_EFFECT_CUT_RIGHT) { + check_pos.x -= 21.0f; + } else if (efbg->type == EffectBG_EFFECT_CUT_LEFT) { + check_pos.x += 21.0f; + } + + ground_y = mCoBG_GetBgY_AngleS_FromWpos(NULL, check_pos, 0.0f); + if ((efbg->status & 0x02) == 0 && !EffectBG_IS_SHAKE(efbg->type) && efbg->effect_pos.y < ground_y) { + if (!EfbgBgitemTreeCheck(check_pos)) { + s16 count; + + switch (efbg->variant) { + case EffectBG_VARIANT_TREE_MED: + count = 5; + break; + case EffectBG_VARIANT_TREE_LARGE: + count = 7; + break; + case EffectBG_VARIANT_TREE_FULL: + count = 9; + break; + default: + count = 5; + break; + } + + EffectBG_Make_Leafs(efbg, game, efbg->effect_pos, count, 1); + efbg->leaf_angle = 0x2BC; + sAdo_OngenTrgStart(NA_SE_108, &efbg->base_pos); + efbg->status |= 0x02; + } + } + + if ((efbg->status & 0x02) == 0) { + cKF_SkeletonInfo_R_play(&efbg->keyframe); + } else { + efbg->add_angle += 0xDAC; + add_calc_short_angle2(&efbg->leaf_angle, 0, 1.0f - sqrtf(1.0f - (1.0f - sqrtf(0.9f))), 125, 0); + } + + if (efbg->timer == 70 && (efbg->type == EffectBG_EFFECT_CUT_RIGHT || efbg->type == EffectBG_EFFECT_CUT_LEFT) && + (efbg->status & 0x02) == 0) { + s16 count; + + switch (efbg->variant) { + case EffectBG_VARIANT_TREE_MED: + count = 5; + break; + case EffectBG_VARIANT_TREE_LARGE: + count = 7; + break; + case EffectBG_VARIANT_TREE_FULL: + count = 9; + break; + default: + count = 5; + break; + } + + EffectBG_Make_Leafs(efbg, game, efbg->effect_pos, count, 1); + sAdo_OngenTrgStart(NA_SE_108, &efbg->base_pos); + } else if (efbg->timer == 2 && efbg->type != EffectBG_EFFECT_SHAKE_SMALL && + efbg->type != EffectBG_EFFECT_SHAKE_LARGE) { + EffectBG_Make_Leafs(efbg, game, efbg->effect_pos, 3, 0); + } else if ((efbg->timer & 0xF) == 0 && efbg->timer != 0 && efbg->timer < 70 && + efbg->type != EffectBG_EFFECT_SHAKE_SMALL && efbg->type != EffectBG_EFFECT_SHAKE_LARGE) { + EffectBG_Make_Leafs(efbg, game, efbg->effect_pos, 1, 0); + } else if ((efbg->timer & 0xF) == 0 && efbg->type == EffectBG_EFFECT_SHAKE_SMALL) { + EffectBG_Make_Leafs(efbg, game, efbg->effect_pos, 1, 3); + } else if ((efbg->timer & 0xF) == 0 && efbg->timer != 0 && efbg->type == EffectBG_EFFECT_SHAKE_LARGE) { + EffectBG_Make_Leafs(efbg, game, efbg->effect_pos, 1, 4); + } + + if (efbg->timer >= efbg->timer_max) { + EffectBG_object_dt(efbg, game); + } + + efbg->timer++; +} + +static void Effectbg_actor_move(ACTOR* actorx, GAME* game) { + EffectBg_c* efbg = efbg_start_p; + int i; + + for (i = 0; i < EffectBg_ENTRY_NUM; i++, efbg++) { + if ((efbg->status & EffectBg_STATUS_ACTIVE) != 0) { + EffectBG_object_move(efbg, game); + } + } +} + +static int EffectBG_object_before_display(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + EffectBg_c* efbg = (EffectBg_c*)arg; + + if (joint_idx == 3) { + joint_rot->y += (int)((f32)efbg->leaf_angle * sin_s(efbg->add_angle)); + joint_rot->z += (int)((f32)efbg->leaf_angle * cos_s(efbg->add_angle)); + } + + if (efbg->variant == EffectBG_VARIANT_TREE_FULL && Common_Get(time).season == mTM_SEASON_WINTER && + ((!EffectBG_IS_SHAKE(efbg->type) && joint_idx == 4) || (EffectBG_IS_SHAKE(efbg->type) && joint_idx == 2))) { + if ((Common_Get(time).term_idx != mTM_TERM_16 && Common_Get(time).term_idx != mTM_TERM_15) || + ((efbg->status & EffectBg_STATUS_XMAS) == 0)) { + *joint_shape = NULL; + } else { + GAME_PLAY* play = (GAME_PLAY*)game; + int type = ((play->game_frame & ~0x1F) + efbg->block_ux + efbg->block_uz) % 3; + + OPEN_DISP(game->graph); + if (type == 0) { + gDPSetPrimColor(NEXT_POLY_OPA_DISP, 0, 255, 255, 255, 100, 1); + } else if (type == 1) { + gDPSetPrimColor(NEXT_POLY_OPA_DISP, 0, 255, 100, 255, 255, 1); + } else { + gDPSetPrimColor(NEXT_POLY_OPA_DISP, 0, 255, 255, 100, 255, 1); + } + + CLOSE_DISP(game->graph); + } + } + + return TRUE; +} + +static int EffectBG_object_before_display_xlu(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, + Gfx** joint_shape, u8* joint_flags, void* arg, s_xyz* joint_rot, + xyz_t* joint_pos) { + EffectBg_c* efbg = (EffectBg_c*)arg; + + if (joint_idx == 3) { + joint_rot->y += (int)((f32)efbg->leaf_angle * sin_s(efbg->add_angle)); + joint_rot->z += (int)((f32)efbg->leaf_angle * cos_s(efbg->add_angle)); + } + + if (efbg->variant == EffectBG_VARIANT_TREE_FULL && Common_Get(time).season == mTM_SEASON_WINTER && + ((!EffectBG_IS_SHAKE(efbg->type) && joint_idx == 4) || (EffectBG_IS_SHAKE(efbg->type) && joint_idx == 2))) { + if ((Common_Get(time).term_idx != mTM_TERM_16 && Common_Get(time).term_idx != mTM_TERM_15) || + ((efbg->status & EffectBg_STATUS_XMAS) == 0)) { + *joint_shape = NULL; + } else { + GAME_PLAY* play = (GAME_PLAY*)game; + int type = ((play->game_frame & ~0x1F) + efbg->block_ux + efbg->block_uz) % 3; + f32 remain = efbg->timer_max - efbg->timer; + f32 divisor = efbg->timer_max - 70; + u8 alpha = (u8)(255.0f * (remain / divisor)); + + OPEN_DISP(game->graph); + if (type == 0) { + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, alpha, 255, 255, 100, 0); + } else if (type == 1) { + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, alpha, 100, 255, 255, 0); + } else { + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, alpha, 255, 100, 255, 0); + } + + CLOSE_DISP(game->graph); + } + } + + *joint_flags = TRUE; + return TRUE; +} + +static int EffectBG_object_after_display(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + EffectBg_c* efbg = (EffectBg_c*)arg; + + if ((joint_idx == 3 && !EffectBG_IS_SHAKE(efbg->type)) || (joint_idx == 0 && EffectBG_IS_SHAKE(efbg->type))) { + f32 x; + + if ((efbg->status & EffectBg_STATUS_CEDAR) != 0) { + x = GETREG(TAKREG, 41) + 1000.0f; + } else { + x = 2000.0f; + } + + Matrix_Position_VecX(x, &efbg->effect_pos); + } + + return FALSE; +} + +static void EffectBG_object_draw(EffectBg_c* efbg, GAME* game) { + Mtx* mtx; + + _texture_z_light_fog_prim(game->graph); + _texture_z_light_fog_prim_xlu(game->graph); + + if (game->frame_counter & 1) { + mtx = efbg->mtx[0]; + } else { + mtx = efbg->mtx[1]; + } + + OPEN_DISP(game->graph); + + Matrix_translate(efbg->base_pos.x, efbg->base_pos.y, efbg->base_pos.z, 0); + Matrix_scale(0.01f, 0.01f, 0.01f, 1); + + if (efbg->timer < 70) { + gDPSetRenderMode(NEXT_POLY_OPA_DISP, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); + gDPSetPrimColor(NEXT_POLY_OPA_DISP, 0, 255, 255, 255, 255, 1); + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + cKF_Si3_draw_R_SV(game, &efbg->keyframe, mtx, &EffectBG_object_before_display, &EffectBG_object_after_display, + efbg); + } else { + gDPSetRenderMode(NEXT_POLY_XLU_DISP, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + + if (efbg->type == EffectBG_EFFECT_CUT_RIGHT || efbg->type == EffectBG_EFFECT_CUT_LEFT) { + f32 remain = efbg->timer_max - efbg->timer; + f32 divisor = efbg->timer_max - 70; + u8 alpha = (u8)(255.0f * (remain / divisor)); + + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, alpha, 255, 255, 255, 0); + } else { + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, 255, 255, 255, 255, 1); + } + + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + cKF_Si3_draw_R_SV(game, &efbg->keyframe, mtx, &EffectBG_object_before_display_xlu, + &EffectBG_object_after_display, efbg); + } + + CLOSE_DISP(game->graph); +} + +static void Effectbg_actor_draw(ACTOR* actorx, GAME* game) { + EFFECTBG_ACTOR* effectbg_actor = (EFFECTBG_ACTOR*)actorx; + EffectBg_c* efbg; + int i; + + OPEN_DISP(game->graph); + + gSPSegment(NEXT_POLY_OPA_DISP, ANIME_1_TXT_SEG, effectbg_actor->tree_pal); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, effectbg_actor->tree_pal); + gSPSegment(NEXT_POLY_OPA_DISP, ANIME_2_TXT_SEG, effectbg_actor->palm_pal); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_2_TXT_SEG, effectbg_actor->palm_pal); + + efbg = efbg_start_p; + + gDPSetTextureAdjustMode(NEXT_POLY_OPA_DISP, G_TA_DOLPHIN); + gDPSetTextureAdjustMode(NEXT_POLY_XLU_DISP, G_TA_DOLPHIN); + for (i = 0; i < EffectBg_ENTRY_NUM; i++, efbg++) { + if ((efbg->status & EffectBg_STATUS_ACTIVE) != 0) { + if ((efbg->status & EffectBg_STATUS_PALM) != 0) { + gSPSegment(NEXT_POLY_OPA_DISP, ANIME_2_TXT_SEG, effectbg_actor->palm_pal); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_2_TXT_SEG, effectbg_actor->palm_pal); + } else if ((efbg->status & EffectBg_STATUS_CEDAR) != 0) { + // There must be a misunderstanding for the various palettes, why else would it load this, unless it's a + // mistake + gSPSegment(NEXT_POLY_OPA_DISP, ANIME_1_TXT_SEG, effectbg_actor->palm_pal2); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, effectbg_actor->palm_pal2); + } else if ((efbg->status & EffectBg_STATUS_GOLD) != 0) { + gSPSegment(NEXT_POLY_OPA_DISP, ANIME_1_TXT_SEG, effectbg_actor->gold_pal); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, effectbg_actor->gold_pal); + } else { + gSPSegment(NEXT_POLY_OPA_DISP, ANIME_1_TXT_SEG, effectbg_actor->tree_pal); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, effectbg_actor->tree_pal); + } + + EffectBG_object_draw(efbg, game); + } + } + + gDPSetTextureAdjustMode(NEXT_POLY_OPA_DISP, G_TA_N64); + gDPSetTextureAdjustMode(NEXT_POLY_XLU_DISP, G_TA_N64); + + CLOSE_DISP(game->graph); +} + +static void Make_EffectBG(GAME* game, s16 type, s16 variant, xyz_t* pos) { + EffectBg_c* efbg = efbg_start_p; + s16 timer_max = 0; + int idx = 0; + int i; + + if (variant == EffectBG_VARIANT_TREE_SMALL || variant == EffectBG_VARIANT_PALM_SMALL || + variant == EffectBG_VARIANT_CEDAR_SMALL || variant == EffectBG_VARIANT_GOLD_SMALL) { + xyz_t small_pos = *pos; + s16 arg; + + if (type == EffectBG_EFFECT_CUT_RIGHT || type == EffectBG_EFFECT_CUT_LEFT) { + if (variant == EffectBG_VARIANT_TREE_SMALL) { + EffectBG_Make_Leafs(efbg, game, small_pos, 4, EffectBG_EFFECT_CUT_RIGHT); + } else if (variant == EffectBG_VARIANT_PALM_SMALL) { + EffectBG_Make_Leafs(efbg, game, small_pos, 4, 5); + } else if (variant == EffectBG_VARIANT_CEDAR_SMALL) { + EffectBG_Make_Leafs(efbg, game, small_pos, 4, 6); + } else if (variant == EffectBG_VARIANT_GOLD_SMALL) { + EffectBG_Make_Leafs(efbg, game, small_pos, 4, 7); + } + + sAdo_OngenTrgStart(NA_SE_61, &small_pos); + } + + if (variant == EffectBG_VARIANT_PALM_SMALL) { + small_pos.y += 19.0f + (f32)(int)GETREG(TAKREG, 50) * 0.1f; + small_pos.z += -2.0f + (f32)(int)GETREG(TAKREG, 51) * 0.1f; + arg = 1; + } else if (variant == EffectBG_VARIANT_CEDAR_SMALL) { + small_pos.y += 0.5f + (f32)(int)GETREG(TAKREG, 50) * 0.1f; + small_pos.z += -2.0f + (f32)(int)GETREG(TAKREG, 51) * 0.1f; + arg = 2; + } else if (variant == EffectBG_VARIANT_GOLD_SMALL) { + small_pos.y += 26.8f + (f32)(int)GETREG(TAKREG, 50) * 0.1f; + arg = 3; + } else { + small_pos.y += 26.8f; + arg = 0; + } + + eEC_CLIP->effect_make_proc(eEC_EFFECT_YOUNG_TREE, small_pos, 2, 0, game, RSV_NO, type, arg); + } else { + efbg = efbg_start_p; + for (i = 0; i < EffectBg_ENTRY_NUM; i++) { + if ((efbg->status & EffectBg_STATUS_ACTIVE) == 0) { + efbg->base_pos = efbg->effect_pos = *pos; + efbg->effect_pos.y += 90.0f; + EffectBG_object_ct(efbg, game, type, variant); + return; + } + + if (efbg->timer >= timer_max) { + timer_max = efbg->timer; + idx = i; + } + + efbg++; + } + + efbg_start_p[idx].base_pos = *pos; + EffectBG_object_ct(&efbg_start_p[idx], game, type, variant); + } +} diff --git a/src/game/m_inventory_ovl.c b/src/game/m_inventory_ovl.c index 01735f72..760d45f2 100644 --- a/src/game/m_inventory_ovl.c +++ b/src/game/m_inventory_ovl.c @@ -742,7 +742,7 @@ static void mIV_pl_shape_item_draw_rod(Submenu* submenu, GAME* game) { if (mtx != NULL) { xyz_t pos; - Matrix_Position_VecZ(&pos, 1500.0f); + Matrix_Position_VecZ(1500.0f, &pos); cKF_Si3_draw_R_SV(game, item_kf, mtx, NULL, NULL, NULL); Matrix_put(&submenu->overlay->inventory_ovl->item_mtx); Matrix_translate(0.0f, 0.0f, 1500.0f, 1); diff --git a/src/game/m_player_common.c_inc b/src/game/m_player_common.c_inc index 3c78bcb4..fc82545c 100644 --- a/src/game/m_player_common.c_inc +++ b/src/game/m_player_common.c_inc @@ -6045,49 +6045,49 @@ static void Player_actor_Set_EffectBgTree(GAME* game, mActor_name_t item, s16 bg if (IS_ITEM_XMAS_TREE(item) != FALSE) { if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { - variant = 12; + variant = EffectBG_VARIANT_CEDAR_XMAS; } else { - variant = 3; + variant = EffectBG_VARIANT_TREE_XMAS; } } else if (IS_ITEM_SMALL_TREE(item) != FALSE) { if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { - variant = 4; + variant = EffectBG_VARIANT_PALM_SMALL; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { - variant = 8; + variant = EffectBG_VARIANT_CEDAR_SMALL; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { - variant = 13; + variant = EffectBG_VARIANT_GOLD_SMALL; } else { - variant = -1; + variant = EffectBG_VARIANT_TREE_SMALL; } } else if (IS_ITEM_MED_TREE(item) != FALSE) { if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { - variant = 5; + variant = EffectBG_VARIANT_PALM_MED; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { - variant = 9; + variant = EffectBG_VARIANT_CEDAR_MED; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { - variant = 14; + variant = EffectBG_VARIANT_GOLD_MED; } else { - variant = 0; + variant = EffectBG_VARIANT_TREE_MED; } } else if (IS_ITEM_LARGE_TREE(item) != FALSE) { if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { - variant = 6; + variant = EffectBG_VARIANT_PALM_LARGE; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { - variant = 10; + variant = EffectBG_VARIANT_CEDAR_LARGE; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { - variant = 15; + variant = EffectBG_VARIANT_GOLD_LARGE; } else { - variant = 1; + variant = EffectBG_VARIANT_TREE_LARGE; } } else { if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { - variant = 7; + variant = EffectBG_VARIANT_PALM_FULL; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { - variant = 11; + variant = EffectBG_VARIANT_CEDAR_FULL; } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { - variant = 16; + variant = EffectBG_VARIANT_GOLD_FULL; } else { - variant = 2; + variant = EffectBG_VARIANT_TREE_FULL; } } diff --git a/src/game/m_player_draw.c_inc b/src/game/m_player_draw.c_inc index 3b1167c7..1fea1c66 100644 --- a/src/game/m_player_draw.c_inc +++ b/src/game/m_player_draw.c_inc @@ -92,7 +92,7 @@ static void Player_actor_draw_After_Larm2(ACTOR* actorx, GAME* game, cKF_Skeleto player->item_matrix_set = FALSE; } - Matrix_Position_VecX(&player->left_hand_pos, 1100.0f); + Matrix_Position_VecX(1100.0f, &player->left_hand_pos); Matrix_get(&player->left_hand_mtx); } diff --git a/src/game/m_player_item_axe.c_inc b/src/game/m_player_item_axe.c_inc index 197de9be..a97ae156 100644 --- a/src/game/m_player_item_axe.c_inc +++ b/src/game/m_player_item_axe.c_inc @@ -7,7 +7,7 @@ static void Player_actor_Item_draw_axe(ACTOR* actor, GAME* game) { int shape_type; Matrix_push(); - Matrix_Position_VecZ(&player->axe_pos, 1500.0f); + Matrix_Position_VecZ(1500.0f, &player->axe_pos); Matrix_pull(); shape_type = player->item_shape_type[player->item_bank_idx]; diff --git a/src/game/m_player_item_net.c_inc b/src/game/m_player_item_net.c_inc index 6bae78f9..8a91d428 100644 --- a/src/game/m_player_item_net.c_inc +++ b/src/game/m_player_item_net.c_inc @@ -241,11 +241,11 @@ static void Player_actor_Item_draw_net(ACTOR* actor, GAME* game) { Matrix_push(); Matrix_rotateXYZ(0, 3000, 0, 1); - Matrix_Position_VecZ(&player->net_start_pos, -2400.0f); - Matrix_Position_VecZ(&player->net_end_pos, 5500.0f); - Matrix_Position_VecZ(&player->net_pos, 4000.0f); - Matrix_Position_VecZ(&player->net_top_col_pos, 4000.0f); - Matrix_Position_VecZ(&player->net_bot_col_pos, 4000.0f); + Matrix_Position_VecZ(-2400.0f, &player->net_start_pos); + Matrix_Position_VecZ(5500.0f, &player->net_end_pos); + Matrix_Position_VecZ(4000.0f, &player->net_pos); + Matrix_Position_VecZ(4000.0f, &player->net_top_col_pos); + Matrix_Position_VecZ(4000.0f, &player->net_bot_col_pos); Matrix_pull(); cKF_Si3_draw_R_SV(&play->game, &player->item_keyframe, player->item_work_mtx[game->frame_counter % 2], NULL, Player_actor_Item_draw_net_After, &player->actor_class); diff --git a/src/game/m_player_item_rod.c_inc b/src/game/m_player_item_rod.c_inc index 64d85bdf..7a2d66f5 100644 --- a/src/game/m_player_item_rod.c_inc +++ b/src/game/m_player_item_rod.c_inc @@ -331,7 +331,7 @@ static int Player_actor_Item_main_rod_putaway(ACTOR* actor, GAME* game) { static void Player_actor_Item_draw_net_After_main4_sao(ACTOR* actor) { PLAYER_ACTOR* player = (PLAYER_ACTOR*)actor; - Matrix_Position_VecX(&player->item_rod_top_pos, 1050.0f); + Matrix_Position_VecX(1050.0f, &player->item_rod_top_pos); } typedef void (*mPlayer_item_rod_draw_proc)(void* arg, GAME* game, cKF_SkeletonInfo_R_c* keyframe, Gfx** joint_shape, @@ -365,7 +365,7 @@ static void Player_actor_Item_draw_rod(ACTOR* actor, GAME* game) { graph = play->game.graph; keyf = &player->item_keyframe; - Matrix_Position_VecZ(&player->item_rod_virtual_top_pos, 6000.0f); + Matrix_Position_VecZ(6000.0f, &player->item_rod_virtual_top_pos); Matrix_push(); Matrix_RotateZ(player->item_rod_angle_z, 1); diff --git a/src/game/m_player_item_scoop.c_inc b/src/game/m_player_item_scoop.c_inc index 3fddf37a..7d6e3553 100644 --- a/src/game/m_player_item_scoop.c_inc +++ b/src/game/m_player_item_scoop.c_inc @@ -7,7 +7,7 @@ static void Player_actor_Item_draw_scoop(ACTOR* actor, GAME* game) { int type; Matrix_push(); - Matrix_Position_VecZ(&player->scoop_pos, 2200.0f); + Matrix_Position_VecZ(2200.0f, &player->scoop_pos); Matrix_pull(); type = player->item_shape_type[player->item_bank_idx]; diff --git a/src/game/m_player_main_reflect_scoop.c_inc b/src/game/m_player_main_reflect_scoop.c_inc index 6f05b91e..59831afe 100644 --- a/src/game/m_player_main_reflect_scoop.c_inc +++ b/src/game/m_player_main_reflect_scoop.c_inc @@ -82,7 +82,7 @@ static void Player_actor_SetEffectHit_Reflect_scoop(ACTOR* actor, GAME* game) { int ut_z; if (mFI_Wpos2UtNum(&ut_x, &ut_z, *pos)) { - Player_actor_Set_EffectBgTree(game, item, 3, ut_x, ut_z); + Player_actor_Set_EffectBgTree(game, item, EffectBG_EFFECT_SHAKE_SMALL, ut_x, ut_z); } attr = 7; diff --git a/src/system/sys_matrix.c b/src/system/sys_matrix.c index e10d7785..1027773f 100644 --- a/src/system/sys_matrix.c +++ b/src/system/sys_matrix.c @@ -6,65 +6,68 @@ #include "MSL_C/w_math.h" #include "libforest/gbi_extensions.h" +// clang-format off Mtx Mtx_clear = gdSPDefMtx( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); +// clang-format on +// clang-format off MtxF MtxF_clear = { { {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}, } }; +// clang-format on static MtxF* Matrix_stack = NULL; static MtxF* Matrix_now = NULL; - -void new_Matrix(GAME* game){ - Matrix_now = THA_alloc16(&game->tha, 0x500); - Matrix_stack = Matrix_now; +void new_Matrix(GAME* game) { + Matrix_now = THA_alloc16(&game->tha, 0x500); + Matrix_stack = Matrix_now; } -void Matrix_push(){ + +void Matrix_push() { Matrix_copy_MtxF(Matrix_now + 1, Matrix_now); Matrix_now++; } -void Matrix_pull(){ +void Matrix_pull() { Matrix_now--; } -void Matrix_get(MtxF* dest){ +void Matrix_get(MtxF* dest) { Matrix_copy_MtxF(dest, Matrix_now); } -void Matrix_put(MtxF* src){ +void Matrix_put(MtxF* src) { Matrix_copy_MtxF(Matrix_now, src); } -MtxF* get_Matrix_now(void){ +MtxF* get_Matrix_now(void) { return (Matrix_now); } -void Matrix_mult(MtxF* m, u8 mode){ +void Matrix_mult(MtxF* m, u8 mode) { MtxF* curm = get_Matrix_now(); - if(mode == 1){ + if (mode == 1) { Skin_Matrix_MulMatrix(curm, m, curm); - } - else{ + } else { Matrix_copy_MtxF(Matrix_now, m); } } -void Matrix_translate(f32 x, f32 y, f32 z, u8 mode){ +void Matrix_translate(f32 x, f32 y, f32 z, u8 mode) { MtxF* curm = Matrix_now; f32 tx, ty; - if(mode == 1){ + if (mode == 1) { tx = curm->xx; ty = curm->xy; curm->xw += tx * x + ty * y + curm->xz * z; @@ -77,16 +80,15 @@ void Matrix_translate(f32 x, f32 y, f32 z, u8 mode){ tx = curm->wx; ty = curm->wy; curm->ww += tx * x + ty * y + curm->wz * z; - } - else{ - Skin_Matrix_SetTranslate(curm, x, y , z); + } else { + Skin_Matrix_SetTranslate(curm, x, y, z); } } -void Matrix_scale(f32 x, f32 y, f32 z, u8 mode){ +void Matrix_scale(f32 x, f32 y, f32 z, u8 mode) { MtxF* curm = Matrix_now; - if(mode == 1){ + if (mode == 1) { curm->xx *= x; curm->yx *= x; curm->zx *= x; @@ -99,20 +101,19 @@ void Matrix_scale(f32 x, f32 y, f32 z, u8 mode){ curm->wx *= x; curm->wy *= y; curm->wz *= z; - } - else{ + } else { Skin_Matrix_SetScale(curm, x, y, z); } } -void Matrix_RotateX(s16 x, int mode){ +void Matrix_RotateX(s16 x, int mode) { MtxF* curm; f32 sin; f32 cos; f32 fp, st2; - if(mode == 1){ - if(x != 0){ + if (mode == 1) { + if (x != 0) { curm = Matrix_now; sin = sin_s(x); @@ -120,22 +121,22 @@ void Matrix_RotateX(s16 x, int mode){ fp = curm->xy; st2 = curm->xz; - curm->xy = (fp * cos)+ (st2 * sin); + curm->xy = (fp * cos) + (st2 * sin); curm->xz = -(fp * sin) + (st2 * cos); fp = curm->yy; st2 = curm->yz; - curm->yy = (fp * cos)+ (st2 * sin); + curm->yy = (fp * cos) + (st2 * sin); curm->yz = -(fp * sin) + (st2 * cos); - + fp = curm->zy; st2 = curm->zz; - curm->zy = (fp * cos)+ (st2 * sin); + curm->zy = (fp * cos) + (st2 * sin); curm->zz = -(fp * sin) + (st2 * cos); fp = curm->wy; st2 = curm->wz; - curm->wy = (fp * cos)+ (st2 * sin); + curm->wy = (fp * cos) + (st2 * sin); curm->wz = -(fp * sin) + (st2 * cos); } } else { @@ -144,7 +145,7 @@ void Matrix_RotateX(s16 x, int mode){ if (x != 0) { sin = sin_s(x); cos = cos_s(x); - + } else { sin = 0.0f; cos = 1.0f; @@ -168,13 +169,13 @@ void Matrix_RotateX(s16 x, int mode){ } } -void Matrix_RotateY(s16 y, int mode){ +void Matrix_RotateY(s16 y, int mode) { MtxF* curm; f32 sin; f32 cos; f32 fp, st2; - if(mode == 1){ + if (mode == 1) { if (y != 0) { curm = Matrix_now; @@ -207,8 +208,7 @@ void Matrix_RotateY(s16 y, int mode){ if (y != 0) { sin = sin_s(y); cos = cos_s(y); - - + } else { sin = 0.0f; cos = 1.0f; @@ -239,31 +239,31 @@ void Matrix_RotateZ(s16 z, int mode) { f32 cos; f32 fp, st2; - if(mode == 1){ + if (mode == 1) { if (z != 0) { curm = Matrix_now; sin = sin_s(z); cos = cos_s(z); - + fp = curm->xx; st2 = curm->xy; - curm->xx = (fp * cos)+ (st2 * sin); + curm->xx = (fp * cos) + (st2 * sin); curm->xy = -(fp * sin) + (st2 * cos); fp = curm->yx; st2 = curm->yy; - curm->yx = (fp * cos)+ (st2 * sin); + curm->yx = (fp * cos) + (st2 * sin); curm->yy = -(fp * sin) + (st2 * cos); fp = curm->zx; st2 = curm->zy; - curm->zx = (fp * cos)+ (st2 * sin); + curm->zx = (fp * cos) + (st2 * sin); curm->zy = -(fp * sin) + (st2 * cos); fp = curm->wx; st2 = curm->wy; - curm->wx = (fp * cos)+ (st2 * sin); + curm->wx = (fp * cos) + (st2 * sin); curm->wy = -(fp * sin) + (st2 * cos); } } else { @@ -272,7 +272,7 @@ void Matrix_RotateZ(s16 z, int mode) { if (z != 0) { sin = sin_s(z); cos = cos_s(z); - + } else { sin = 0.0f; cos = 1.0f; @@ -297,34 +297,34 @@ void Matrix_RotateZ(s16 z, int mode) { } } -void Matrix_rotateXYZ(s16 x, s16 y, s16 z, int mode){ +void Matrix_rotateXYZ(s16 x, s16 y, s16 z, int mode) { MtxF* curm = Matrix_now; f32 sin; f32 cos; f32 fp, st2; - if(mode == 1){ + if (mode == 1) { sin = sin_s(z); cos = cos_s(z); fp = curm->xx; st2 = curm->xy; - curm->xx = (fp * cos)+ (st2 * sin); + curm->xx = (fp * cos) + (st2 * sin); curm->xy = -(fp * sin) + (st2 * cos); fp = curm->yx; st2 = curm->yy; - curm->yx = (fp * cos)+ (st2 * sin); + curm->yx = (fp * cos) + (st2 * sin); curm->yy = -(fp * sin) + (st2 * cos); fp = curm->zx; st2 = curm->zy; - curm->zx = (fp * cos)+ (st2 * sin); + curm->zx = (fp * cos) + (st2 * sin); curm->zy = -(fp * sin) + (st2 * cos); fp = curm->wx; st2 = curm->wy; - curm->wx = (fp * cos)+ (st2 * sin); + curm->wx = (fp * cos) + (st2 * sin); curm->wy = -(fp * sin) + (st2 * cos); if (y != 0) { @@ -338,17 +338,17 @@ void Matrix_rotateXYZ(s16 x, s16 y, s16 z, int mode){ fp = curm->yx; st2 = curm->yz; - curm->yx = (fp * cos)- (st2 * sin); + curm->yx = (fp * cos) - (st2 * sin); curm->yz = (fp * sin) + (st2 * cos); fp = curm->zx; st2 = curm->zz; - curm->zx = (fp * cos)- (st2 * sin); + curm->zx = (fp * cos) - (st2 * sin); curm->zz = (fp * sin) + (st2 * cos); fp = curm->wx; st2 = curm->wz; - curm->wx = (fp * cos)- (st2 * sin); + curm->wx = (fp * cos) - (st2 * sin); curm->wz = (fp * sin) + (st2 * cos); } @@ -358,22 +358,22 @@ void Matrix_rotateXYZ(s16 x, s16 y, s16 z, int mode){ fp = curm->xy; st2 = curm->xz; - curm->xy = (fp * cos)+ (st2 * sin); + curm->xy = (fp * cos) + (st2 * sin); curm->xz = -(fp * sin) + (st2 * cos); fp = curm->yy; st2 = curm->yz; - curm->yy = (fp * cos)+ (st2 * sin); + curm->yy = (fp * cos) + (st2 * sin); curm->yz = -(fp * sin) + (st2 * cos); fp = curm->zy; st2 = curm->zz; - curm->zy = (fp * cos)+ (st2 * sin); + curm->zy = (fp * cos) + (st2 * sin); curm->zz = -(fp * sin) + (st2 * cos); fp = curm->wy; st2 = curm->wz; - curm->wy = (fp * cos)+ (st2 * sin); + curm->wy = (fp * cos) + (st2 * sin); curm->wz = -(fp * sin) + (st2 * cos); } } else { @@ -391,21 +391,21 @@ void Matrix_softcv3_mult(xyz_t* pos, s_xyz* rot) { fp = curm->xx; st2 = curm->xy; - + curm->xw = curm->xw + (fp * pos->x + st2 * pos->y + curm->xz * pos->z); - curm->xx = (fp * cos) + (st2 * sin); - curm->xy = -(fp * sin) + (st2 * cos); + curm->xx = (fp * cos) + (st2 * sin); + curm->xy = -(fp * sin) + (st2 * cos); fp = curm->yx; st2 = curm->yy; - + curm->yw = curm->yw + (fp * pos->x + st2 * pos->y + curm->yz * pos->z); curm->yx = (fp * cos) + (st2 * sin); curm->yy = -(fp * sin) + (st2 * cos); fp = curm->zx; st2 = curm->zy; - + curm->zw = curm->zw + (curm->zx * pos->x + curm->zy * pos->y + curm->zz * pos->z); curm->zx = (fp * cos) + (st2 * sin); curm->zy = -(fp * sin) + (st2 * cos); @@ -416,53 +416,51 @@ void Matrix_softcv3_mult(xyz_t* pos, s_xyz* rot) { curm->wx = (fp * cos) + (st2 * sin); curm->wy = -(fp * sin) + (st2 * cos); - if(rot->y != 0){ - + if (rot->y != 0) { + sin = sin_s(rot->y); cos = cos_s(rot->y); - + fp = curm->xx; st2 = curm->xz; curm->xx = (fp * cos) - (st2 * sin); curm->xz = (fp * sin) + (st2 * cos); - + fp = curm->yx; st2 = curm->yz; curm->yx = (fp * cos) - (st2 * sin); curm->yz = (fp * sin) + (st2 * cos); - + fp = curm->zx; st2 = curm->zz; curm->zx = (fp * cos) - (st2 * sin); curm->zz = (fp * sin) + (st2 * cos); - - + fp = curm->wx; st2 = curm->wz; curm->wx = (fp * cos) - (st2 * sin); curm->wz = (fp * sin) + (st2 * cos); } - - if(rot->x != 0){ + if (rot->x != 0) { sin = sin_s(rot->x); - cos = cos_s(rot->x); - + cos = cos_s(rot->x); + fp = curm->xy; st2 = curm->xz; curm->xy = (fp * cos) + (st2 * sin); curm->xz = -(fp * sin) + (st2 * cos); - + fp = curm->yy; st2 = curm->yz; curm->yy = (fp * cos) + (st2 * sin); curm->yz = -(fp * sin) + (st2 * cos); - + fp = curm->zy; st2 = curm->zz; curm->zy = (fp * cos) + (st2 * sin); curm->zz = -(fp * sin) + (st2 * cos); - + fp = curm->wy; st2 = curm->wz; curm->wy = (fp * cos) + (st2 * sin); @@ -470,12 +468,11 @@ void Matrix_softcv3_mult(xyz_t* pos, s_xyz* rot) { } } -void Matrix_softcv3_load(s_xyz* src, f32 x, f32 y, f32 z){ +void Matrix_softcv3_load(s_xyz* src, f32 x, f32 y, f32 z) { MtxF* curm = Matrix_now; f32 sin, cos; f32 ss, sc; - sin = sin_s(src->y); cos = cos_s(src->y); @@ -489,51 +486,48 @@ void Matrix_softcv3_load(s_xyz* src, f32 x, f32 y, f32 z){ curm->wx = 0.0f; curm->ww = 1.0f; - if(src->x != 0){ - ss = sin_s(src->x); - sc = cos_s(src->x); + if (src->x != 0) { + ss = sin_s(src->x); + sc = cos_s(src->x); - - curm->zz = cos * sc; - curm->zy = cos * ss; + curm->zz = cos * sc; + curm->zy = cos * ss; - curm->xz = sin * sc; - curm->xy = sin * ss; - - curm->yz = -ss; - curm->yy = sc; + curm->xz = sin * sc; + curm->xy = sin * ss; + + curm->yz = -ss; + curm->yy = sc; + } else { + curm->zz = cos; + curm->xz = sin; + curm->yz = 0.0f; + curm->zy = 0.0f; + curm->xy = 0.0f; + curm->yy = 1.0f; } - else{ - curm->zz = cos; - curm->xz = sin; - curm->yz = 0.0f; - curm->zy = 0.0f; - curm->xy = 0.0f; - curm->yy = 1.0f; - } - if(src->z != 0){ + if (src->z != 0) { sin = sin_s(src->z); cos = cos_s(src->z); ss = curm->xy; sc = curm->xx; - + curm->xx = (sc * cos) + (ss * sin); curm->xy = -(sc * sin) + (ss * cos); ss = curm->zy; sc = curm->zx; - + curm->zx = (sc * cos) + (ss * sin); curm->zy = -(sc * sin) + (ss * cos); ss = curm->yy; curm->yx = curm->yy * sin; curm->yy = ss * cos; + } else { + curm->yx = 0.0f; } - else{ - curm->yx = 0.0f; -} } Mtx* _MtxF_to_Mtx(MtxF* src, Mtx* dest) { @@ -611,20 +605,19 @@ Mtx* _Matrix_to_Mtx(Mtx* dest) { return _MtxF_to_Mtx(Matrix_now, dest); } -Mtx* _Matrix_to_Mtx_new(GRAPH* graph){ +Mtx* _Matrix_to_Mtx_new(GRAPH* graph) { return _Matrix_to_Mtx(GRAPH_ALLOC(graph, sizeof(Mtx))); - } -void Matrix_Position(xyz_t* old_pos, xyz_t* new_pos){ +void Matrix_Position(xyz_t* old_pos, xyz_t* new_pos) { MtxF* curm = Matrix_now; - + new_pos->x = (curm->xx * old_pos->x) + (curm->xy * old_pos->y) + (curm->xz * old_pos->z) + curm->xw; new_pos->y = (curm->yx * old_pos->x) + (curm->yy * old_pos->y) + (curm->yz * old_pos->z) + curm->yw; new_pos->z = (curm->zx * old_pos->x) + (curm->zy * old_pos->y) + (curm->zz * old_pos->z) + curm->zw; } -void Matrix_Position_Zero(xyz_t* v){ +void Matrix_Position_Zero(xyz_t* v) { MtxF* curm = Matrix_now; v->x = curm->xw; @@ -632,23 +625,21 @@ void Matrix_Position_Zero(xyz_t* v){ v->z = curm->zw; } -void Matrix_Position_VecX(xyz_t* v, f32 x){ - MtxF* curm = Matrix_now; +void Matrix_Position_VecX(f32 x, xyz_t* v) { + MtxF* curm = Matrix_now; v->x = curm->xw + (curm->xx * x); v->y = curm->yw + (curm->yx * x); v->z = curm->zw + (curm->zx * x); - } -void Matrix_Position_VecZ(xyz_t* v, f32 z){ - MtxF* curm = Matrix_now; +void Matrix_Position_VecZ(f32 z, xyz_t* v) { + MtxF* curm = Matrix_now; v->x = curm->xw + (curm->xz * z); v->y = curm->yw + (curm->yz * z); v->z = curm->zw + (curm->zz * z); } - void Matrix_copy_MtxF(MtxF* dest, MtxF* src) { dest->xx = src->xx; dest->yx = src->yx; @@ -706,7 +697,7 @@ void Matrix_reverse(MtxF* curm) { curm->yz = fp; } -void Matrix_to_rotate_new(MtxF* curm, s_xyz* vec, int flag){ +void Matrix_to_rotate_new(MtxF* curm, s_xyz* vec, int flag) { f32 temp; f32 temp2; f32 temp3; @@ -728,10 +719,10 @@ void Matrix_to_rotate_new(MtxF* curm, s_xyz* vec, int flag){ vec->z = (fatan2(curm->yx, curm->yy) * 10430.3779297f); } else { temp = curm->xx; - + temp2 = curm->yx; temp *= temp; - temp += curm->zx * curm->zx; + temp += curm->zx * curm->zx; temp += (temp2 * temp2); /* temp = xx^2+zx^2+yx^2 == 1 for a rotation matrix */ temp = temp2 / sqrtf(temp); @@ -739,7 +730,7 @@ void Matrix_to_rotate_new(MtxF* curm, s_xyz* vec, int flag){ temp2 = curm->xy; temp3 = curm->yy; temp2 *= temp2; - temp2 += curm->zy * curm->zy; + temp2 += curm->zy * curm->zy; temp2 += (temp3 * temp3); /* temp2 = xy^2+zy^2+yy^2 == 1 for a rotation matrix */ temp2 = temp3 / sqrtf(temp2); @@ -772,10 +763,10 @@ void Matrix_to_rotate2_new(MtxF* curm, s_xyz* v, int flag) { v->x = (fatan2(curm->zy, curm->zz) * 10430.3779297f); } else { temp = curm->xy; - + temp2 = curm->zy; temp *= temp; - temp += curm->yy * curm->yy; + temp += curm->yy * curm->yy; temp += (temp2 * temp2); /* temp = zx^2+yy^2+zy^2 == 1 for a rotation matrix */ temp = temp2 / sqrtf(temp); @@ -783,7 +774,7 @@ void Matrix_to_rotate2_new(MtxF* curm, s_xyz* v, int flag) { temp2 = curm->xz; temp3 = curm->zz; temp2 *= temp2; - temp2 += curm->yz * curm->yz; + temp2 += curm->yz * curm->yz; temp2 += (temp3 * temp3); /* temp2 = xz^2+yz^2+zz^2 == 1 for a rotation matrix */ temp2 = temp3 / sqrtf(temp2); @@ -856,7 +847,7 @@ void Matrix_RotateVector(s16 angle, xyz_t* axis, u8 mode) { temp2 = axis->z * ((1.0f - cos) * axis->y); temp3 = axis->x * sin; - curm->zy = temp2 + temp3 ; + curm->zy = temp2 + temp3; curm->yz = temp2 - temp3; curm->wx = 0.0f; @@ -887,8 +878,8 @@ void Matrix_RotateVector(s16 angle, xyz_t* axis, u8 mode) { } } -void suMtxMakeTS(Mtx *mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, f32 translateZ) { - struct { +void suMtxMakeTS(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, f32 translateZ) { + struct { s16 intPart[4][4]; u16 fracPart[4][4]; }* mu = (void*)mtx; @@ -926,13 +917,13 @@ void suMtxMakeTS(Mtx *mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f mu->intPart[3][2] = ((u32)fp >> 16) & 0xFFFF; mu->intPart[3][3] = 1; mtx->m[3][3] = (u32)fp << 16; - } // S(RxRyRz)T where S is a scale matrix, Rx/Ry/Rz are rotations about the x/y/z axes, and T is a translation -void suMtxMakeSRT(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, f32 translateY, f32 translateZ) { +void suMtxMakeSRT(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, + f32 translateY, f32 translateZ) { int fp; - struct { + struct { s16 intPart[4][4]; u16 fracPart[4][4]; }* mu = (void*)mtx; @@ -944,51 +935,51 @@ void suMtxMakeSRT(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 ro f32 cosZ = cos_s(rotZ); fp = cosY * cosZ * scaleX * 0x10000; - mu->intPart[0][0] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[0][0] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[0][0] = fp & 0xFFFF; fp = cosY * sinZ * scaleX * 0x10000; - mu->intPart[0][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[0][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[0][1] = fp & 0xFFFF; - + fp = -sinY * scaleX * 0x10000; - mu->intPart[0][2] = ((u32) fp >> 0x10) & 0xFFFF; - mu->fracPart[0][2] = fp & 0xFFFF; + mu->intPart[0][2] = ((u32)fp >> 0x10) & 0xFFFF; + mu->fracPart[0][2] = fp & 0xFFFF; fp = ((sinX * sinY * cosZ) - (cosX * sinZ)) * scaleY * 0x10000; - mu->intPart[1][0] = ((u32) fp >> 0x10) & 0xFFFF; - mu->fracPart[1][0] = fp & 0xFFFF; + mu->intPart[1][0] = ((u32)fp >> 0x10) & 0xFFFF; + mu->fracPart[1][0] = fp & 0xFFFF; fp = ((sinX * sinY * sinZ) + (cosX * cosZ)) * scaleY * 0x10000; - mu->intPart[1][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[1][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[1][1] = fp & 0xFFFF; fp = sinX * cosY * scaleY * 0x10000; - mu->intPart[1][2] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[1][2] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[1][2] = fp & 0xFFFF; fp = ((cosX * sinY * cosZ) + (sinX * sinZ)) * scaleZ * 0x10000; - mu->intPart[2][0] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[2][0] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[2][0] = fp & 0xFFFF; fp = ((cosX * sinY * sinZ) - (sinX * cosZ)) * scaleZ * 0x10000; - mu->intPart[2][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[2][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[2][1] = fp & 0xFFFF; fp = cosX * cosY * scaleZ * 0x10000; - mu->intPart[2][2] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[2][2] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[2][2] = fp & 0xFFFF; fp = translateX * 0x10000; - mu->intPart[3][0] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[3][0] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[3][0] = fp & 0xFFFF; fp = translateY * 0x10000; - mu->intPart[3][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[3][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[3][1] = fp & 0xFFFF; fp = translateZ * 0x10000; - mu->intPart[3][2] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[3][2] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[3][2] = fp & 0xFFFF; mu->intPart[0][3] = mu->intPart[1][3] = mu->intPart[2][3] = 0; @@ -998,7 +989,8 @@ void suMtxMakeSRT(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 ro } // S(RzRxRy)T where S is a scale matrix, Rx/Ry/Rz are rotations, and T is a translation -void suMtxMakeSRT_ZXY(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, f32 translateY, f32 translateZ) { +void suMtxMakeSRT_ZXY(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s16 rotY, s16 rotZ, f32 translateX, + f32 translateY, f32 translateZ) { int fp; struct { s16 intPart[4][4]; @@ -1012,51 +1004,51 @@ void suMtxMakeSRT_ZXY(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s1 f32 cosZ = cos_s(rotZ); // likely sp+38 fp = ((cosY * cosZ) + (sinX * sinY * sinZ)) * scaleX * 0x10000; - mu->intPart[0][0] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[0][0] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[0][0] = fp & 0xFFFF; fp = cosX * sinZ * scaleX * 0x10000; - mu->intPart[0][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[0][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[0][1] = fp & 0xFFFF; - fp = ( - (sinY * cosZ) + (sinX * cosY * sinZ) ) * scaleX * 0x10000; - mu->intPart[0][2] = ((u32) fp >> 0x10) & 0xFFFF; + fp = (-(sinY * cosZ) + (sinX * cosY * sinZ)) * scaleX * 0x10000; + mu->intPart[0][2] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[0][2] = fp & 0xFFFF; - fp = (- (cosY * sinZ) + (sinX * sinY * cosZ) ) * scaleY * 0x10000; - mu->intPart[1][0] = ((u32) fp >> 0x10) & 0xFFFF; + fp = (-(cosY * sinZ) + (sinX * sinY * cosZ)) * scaleY * 0x10000; + mu->intPart[1][0] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[1][0] = fp & 0xFFFF; fp = cosX * cosZ * scaleY * 0x10000; - mu->intPart[1][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[1][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[1][1] = fp & 0xFFFF; fp = ((sinY * sinZ) + (sinX * cosY * cosZ)) * scaleY * 0x10000; - mu->intPart[1][2] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[1][2] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[1][2] = fp & 0xFFFF; fp = cosX * sinY * scaleZ * 0x10000; - mu->intPart[2][0] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[2][0] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[2][0] = fp & 0xFFFF; fp = -sinX * scaleZ * 0x10000; - mu->intPart[2][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[2][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[2][1] = fp & 0xFFFF; fp = cosX * cosY * scaleZ * 0x10000; - mu->intPart[2][2] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[2][2] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[2][2] = fp & 0xFFFF; fp = translateX * 0x10000; - mu->intPart[3][0] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[3][0] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[3][0] = fp & 0xFFFF; fp = translateY * 0x10000; - mu->intPart[3][1] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[3][1] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[3][1] = fp & 0xFFFF; fp = translateZ * 0x10000; - mu->intPart[3][2] = ((u32) fp >> 0x10) & 0xFFFF; + mu->intPart[3][2] = ((u32)fp >> 0x10) & 0xFFFF; mu->fracPart[3][2] = fp & 0xFFFF; mu->intPart[0][3] = mu->intPart[1][3] = mu->intPart[2][3] = 0; @@ -1064,4 +1056,3 @@ void suMtxMakeSRT_ZXY(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s16 rotX, s1 mu->intPart[3][3] = 1; mu->fracPart[3][3] = 0; } -