diff --git a/config/assets.yml b/config/assets.yml index 560a15d2..a60b3d3f 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -10286,9 +10286,6 @@ config/rel.yml: mFM_rail_pal_11: addrs: [0x80F8C428, 0x80F8C448] type: pal16 - mFM_rail_pal_12: - addrs: [0x80F8C448, 0x80F8C468] - type: pal16 # ac_koinobori # NPC draw data assets diff --git a/include/ac_effectbg.h b/include/ac_effectbg.h index 4fd4cbc6..a4f24917 100644 --- a/include/ac_effectbg.h +++ b/include/ac_effectbg.h @@ -8,6 +8,18 @@ extern "C" { #endif +enum { + EffectBG_EFFECT_SHAKE, + EffectBG_EFFECT_CUT_LEFT, + EffectBG_EFFECT_CUT_RIGHT, + EffectBG_EFFECT_SHAKE_SMALL, + EffectBG_EFFECT_SHAKE_LARGE, + + EffectBG_EFFECT_NUM +}; + +typedef void (*EffectBG_MAKE_EFFECTBG_PROC)(GAME*, s16, s16, xyz_t*); + extern ACTOR_PROFILE Effectbg_Profile; #ifdef __cplusplus @@ -15,4 +27,3 @@ extern ACTOR_PROFILE Effectbg_Profile; #endif #endif - diff --git a/include/ac_htable.h b/include/ac_htable.h index 20c07ace..1e48db36 100644 --- a/include/ac_htable.h +++ b/include/ac_htable.h @@ -8,6 +8,14 @@ extern "C" { #endif +typedef mActor_name_t (*aHTBL_SEARCH_PICK_UP_ITEM_LAYER2_PROC)(GAME*); + +typedef struct htable_clip_s { + aHTBL_SEARCH_PICK_UP_ITEM_LAYER2_PROC search_pick_up_item_layer2_proc; + xyz_t pickup_pos; + s16 pickup_counter; +} aHTBL_Clip_c; + extern ACTOR_PROFILE Htable_Profile; #ifdef __cplusplus @@ -15,4 +23,3 @@ extern ACTOR_PROFILE Htable_Profile; #endif #endif - diff --git a/include/ac_my_room.h b/include/ac_my_room.h index 95de307d..b72ac650 100644 --- a/include/ac_my_room.h +++ b/include/ac_my_room.h @@ -296,6 +296,7 @@ extern u8 aMR_GetAlphaEdge(u16 ftr_name); extern int aMR_DrawDolphinMode(u16 ftr_name); extern Gfx* aMR_IconNo2Gfx1(int icon_no); extern Gfx* aMR_IconNo2Gfx2(int icon_no); +extern int aMR_RadioBgmNow(void); #ifdef __cplusplus } diff --git a/include/ac_npc.h b/include/ac_npc.h index f8c00288..3a6d7361 100644 --- a/include/ac_npc.h +++ b/include/ac_npc.h @@ -402,7 +402,7 @@ typedef struct npc_condition_s { typedef struct npc_uzai_s { int step; - u8 tool; + u8 counter; u8 flag; u8 cross; } aNPC_uzai_c; diff --git a/include/c_keyframe.h b/include/c_keyframe.h index 5ea08181..59a49ca7 100644 --- a/include/c_keyframe.h +++ b/include/c_keyframe.h @@ -472,19 +472,19 @@ extern void cKF_SkeletonInfo_R_AnimationMove_base(xyz_t* base, s_xyz* sbase, xyz /** * Calculates and applies transformation to world coordinates based on animation data. * - * @param calcx X-coordinate for calculation base. - * @param calcy Y-coordinate for calculation base. - * @param calcz Z-coordinate for calculation base. - * @param base Base position result. - * @param calcp Position calculation parameters. - * @param val Angle value for rotation. - * @param trans Transformation to apply. + * @param calc_pos Calculated position result. + * @param base_pos Base world position. + * @param trans_x X-coordinate for translation. + * @param trans_y Y-coordinate for translation. + * @param trans_z Z-coordinate for translation. + * @param angle_y Angle value for rotation. + * @param scale Scaling factor. * @param keyframe Skeleton info structure containing animation data. - * @param animation_flag Flags determining which transformations to apply. + * @param trans_flag Flags determining which transformations to apply. */ -extern void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(f32 calcx, f32 calcy, f32 calcz, xyz_t* base, - xyz_t* calcp, s16 val, xyz_t* trans, - cKF_SkeletonInfo_R_c* keyframe, int animation_flag); +extern void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(xyz_t* calc_pos, const xyz_t* base_pos, f32 trans_x, + f32 trans_y, f32 trans_z, s16 angle_y, const xyz_t* scale, + cKF_SkeletonInfo_R_c* keyframe, int trans_flag); #ifdef __cplusplus } diff --git a/include/m_clip.h b/include/m_clip.h index c308b0b8..1da06acd 100644 --- a/include/m_clip.h +++ b/include/m_clip.h @@ -25,6 +25,8 @@ #include "ac_quest_manager_clip.h" #include "ac_shop_goods_h.h" #include "ac_shop_design.h" +#include "ac_effectbg.h" +#include "ac_htable.h" #ifdef __cplusplus extern "C" { @@ -38,7 +40,7 @@ typedef struct clip_s { /* 0x020 */ int arrange_ftr_num; /* 0x024 */ void* _024; /* 0x028 */ void* misin_clip; - /* 0x02C */ void* _02C; + /* 0x02C */ aHTBL_Clip_c* htbl_clip; /* 0x030 */ void* _030; /* 0x034 */ void* _034; /* 0x038 */ void* _038; @@ -72,7 +74,7 @@ typedef struct clip_s { /* 0x0A8 */ void* _0A8; /* 0x0AC */ aGYO_Clip_c* gyo_clip; /* 0x0B0 */ aSG_Clip_c* shop_goods_clip; - /* 0x0B4 */ void* _0B4; + /* 0x0B4 */ EffectBG_MAKE_EFFECTBG_PROC make_effect_bg_proc; /* 0x0B8 */ aShopUmbrella_Clip_c* shop_umbrella_clip; /* 0x0BC */ aAR_Clip_c* arrange_room_clip; /* 0x0C0 */ void* _0C0; diff --git a/include/m_collision_bg.h b/include/m_collision_bg.h index e7097712..025eb60e 100644 --- a/include/m_collision_bg.h +++ b/include/m_collision_bg.h @@ -134,6 +134,13 @@ enum { mCoBG_AREA_NUM }; +enum { + mCoBG_BLOCK_BGCHECK_MODE_NORMAL, + mCoBG_BLOCK_BGCHECK_MODE_INTRO_DEMO, + + mCoBG_BLOCK_BGCHECK_MODE_NUM +}; + /* sizeof(mCoBG_CollisionData_c) == 4*/ typedef struct collision_bg_data_s { /* 1------- -------- -------- -------- */ u32 shape : 1; /* collision shape */ @@ -331,6 +338,11 @@ extern void mCoBG_BgCheckControll_RemoveDirectedUnitColumn(xyz_t* reverse_pos, A s16 check_type, int ut_x, int ut_z); extern xyz_t mCoBG_UniqueWallCheck(ACTOR* actorx, f32 range, f32 y_ofs); extern xyz_t mCoBG_ScopeWallCheck(ACTOR* actorx, const xyz_t* pos, f32 x, f32 z, f32 range, f32 y_ofs); +extern int mCoBG_ScrollCheck(xyz_t start_pos, xyz_t end_pos, f32 radius); +extern int mCoBG_GetBlockBgCheckMode(void); +extern void mCoBG_GroundCheckOnly(xyz_t* reverse_pos, ACTOR* actor, f32 check_range, f32 offset_y, s16 check_type); +extern f32 mCoBG_Wpos2BgUtCenterHeight_AddColumn(xyz_t pos); +extern f32 mCoBG_UtNum2UtCenterY_Keep(int ut_x, int ut_z); extern void mCoBG_InitMoveBgData(); extern void mCoBG_InitBlockBgCheckMode(); diff --git a/include/m_common_data.h b/include/m_common_data.h index 721a54af..091e746e 100644 --- a/include/m_common_data.h +++ b/include/m_common_data.h @@ -245,7 +245,7 @@ typedef struct common_data_s { /* 0x0285BE */ s8 player_actor_exists; /* 0x0285BF */ s8 complete_payment_type; /* 0x0285C0 */ s8 player_decoy_flag; - /* 0x0285C1 */ u8 _285C1; + /* 0x0285C1 */ s8 axe_damage; /* 0x0285C2 */ u8 make_npc2_actor; /* 0x0285C4 */ s16 event_id; /* 0x0285C6 */ u8 event_title_flags; @@ -308,7 +308,7 @@ typedef struct common_data_s { /* 0x02DB46 */ mCD_persistent_data_c travel_persistent_data; /* used for checking if travelling back to town */ /* 0x02DBA2 */ s16 island_weather; /* 0x02DBA4 */ s16 island_weather_intensity; - /* 0x02DBA6 */ s16 _2DBA6; + /* 0x02DBA6 */ s16 sunburn_time; /* 0x02DBA8 */ u8 memcard_slot; /* 0X02DBAC */ int my_room_message_control_flags; /* 0x02DBB0 */ s16 can_look_goki_count; diff --git a/include/m_field_info.h b/include/m_field_info.h index 582677aa..6717e39a 100644 --- a/include/m_field_info.h +++ b/include/m_field_info.h @@ -25,11 +25,14 @@ extern "C" { #define mFI_UT_WORLDSIZE_HALF_X_F (mFI_UT_WORLDSIZE_X_F / 2.0f) #define mFI_UT_WORLDSIZE_HALF_Z_F (mFI_UT_WORLDSIZE_X_F / 2.0f) -#define mFI_BK_WORLDSIZE_X (mFI_UT_WORLDSIZE_X * UT_X_NUM) -#define mFI_BK_WORLDSIZE_Z (mFI_UT_WORLDSIZE_Z * UT_Z_NUM) +#define mFI_BK_WORLDSIZE_BASE (mFI_UNIT_BASE_SIZE * UT_BASE_NUM) +#define mFI_BK_WORLDSIZE_BASE_F ((f32)mFI_BK_WORLDSIZE_BASE) -#define mFI_BK_WORLDSIZE_X_F (mFI_UT_WORLDSIZE_X_F * UT_X_NUM) -#define mFI_BK_WORLDSIZE_Z_F (mFI_UT_WORLDSIZE_Z_F * UT_Z_NUM) +#define mFI_BK_WORLDSIZE_X mFI_BK_WORLDSIZE_BASE +#define mFI_BK_WORLDSIZE_Z mFI_BK_WORLDSIZE_BASE + +#define mFI_BK_WORLDSIZE_X_F mFI_BK_WORLDSIZE_BASE_F +#define mFI_BK_WORLDSIZE_Z_F mFI_BK_WORLDSIZE_BASE_F #define mFI_POS2UT(pos) ((int)((pos) / mFI_UNIT_BASE_SIZE_F)) diff --git a/include/m_name_table.h b/include/m_name_table.h index 4d34127c..aa8305bf 100644 --- a/include/m_name_table.h +++ b/include/m_name_table.h @@ -212,6 +212,9 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define ITEM_IS_RSVCPORG(n) ((n) >= RSV_CPORIGINAL_FLD0_00 && (n) <= RSV_CPORIGINAL_FLD7_11) #define ITEM_IS_RSVGBAORG(n) ((n) >= RSV_GBAORIGINAL0 && (n) <= RSV_GBAORIGINAL7) +#define ITEM_IS_MYMANNIQUIN(n) ((n) >= FTR_CLOTH_MANNIQUIN_MY_ORIGINAL0 && (n) <= FTR_CLOTH_MYMANNIQUIN_END) +#define ITEM_IS_MYUMBRELLA(n) ((n) >= FTR_MYUMBRELLA_START && (n) <= FTR_MYUMBRELLA_END) + #define PAPER2TYPE(n) ((n) % PAPER_UNIQUE_NUM) #define PAPER2STACK(n) ((n) / PAPER_UNIQUE_NUM) @@ -281,12 +284,232 @@ extern int mNT_check_unknown(mActor_name_t item_no); ((item) == GOLD_TREE_BEES) \ ) +// @BUG - they check for money tree variants twice +#define IS_ITEM_COLLIDEABLE_TREE(item) \ + (((item) == TREE_S0) || \ + ((item) == TREE_APPLE_S0) || \ + ((item) == TREE_ORANGE_S0) || \ + ((item) == TREE_PEACH_S0) || \ + ((item) == TREE_PEAR_S0) || \ + ((item) == TREE_CHERRY_S0) || \ + ((item) == TREE_1000BELLS_S0) || \ + ((item) == TREE_10000BELLS_S0) || \ + ((item) == TREE_30000BELLS_S0) || \ + ((item) == TREE_1000BELLS_S0) || \ + ((item) == TREE_10000BELLS_S0) || \ + ((item) == TREE_30000BELLS_S0) || \ + ((item) == TREE_100BELLS_S0) || \ + ((item) == TREE_PALM_S0) || \ + ((item) == CEDAR_TREE_S0) || \ + ((item) == GOLD_TREE_S0) || \ + ((item) == TREE_S1) || \ + ((item) == TREE_APPLE_S1) || \ + ((item) == TREE_ORANGE_S1) || \ + ((item) == TREE_PEACH_S1) || \ + ((item) == TREE_PEAR_S1) || \ + ((item) == TREE_CHERRY_S1) || \ + ((item) == TREE_1000BELLS_S1) || \ + ((item) == TREE_10000BELLS_S1) || \ + ((item) == TREE_30000BELLS_S1) || \ + ((item) == TREE_1000BELLS_S1) || \ + ((item) == TREE_10000BELLS_S1) || \ + ((item) == TREE_30000BELLS_S1) || \ + ((item) == TREE_100BELLS_S1) || \ + ((item) == TREE_PALM_S1) || \ + ((item) == CEDAR_TREE_S1) || \ + ((item) == GOLD_TREE_S1) || \ + ((item) == TREE_S2) || \ + ((item) == TREE_APPLE_S2) || \ + ((item) == TREE_ORANGE_S2) || \ + ((item) == TREE_PEACH_S2) || \ + ((item) == TREE_PEAR_S2) || \ + ((item) == TREE_CHERRY_S2) || \ + ((item) == TREE_1000BELLS_S2) || \ + ((item) == TREE_10000BELLS_S2) || \ + ((item) == TREE_30000BELLS_S2) || \ + ((item) == TREE_1000BELLS_S2) || \ + ((item) == TREE_10000BELLS_S2) || \ + ((item) == TREE_30000BELLS_S2) || \ + ((item) == TREE_100BELLS_S2) || \ + ((item) == TREE_PALM_S2) || \ + ((item) == CEDAR_TREE_S2) || \ + ((item) == GOLD_TREE_S2) || \ + ((item) == TREE) || \ + ((item) == TREE_APPLE_FRUIT) || \ + ((item) == TREE_ORANGE_FRUIT) || \ + ((item) == TREE_PEACH_FRUIT) || \ + ((item) == TREE_PEAR_FRUIT) || \ + ((item) == TREE_CHERRY_FRUIT) || \ + ((item) == TREE_1000BELLS) || \ + ((item) == TREE_10000BELLS) || \ + ((item) == TREE_30000BELLS) || \ + ((item) == TREE_100BELLS) || \ + ((item) == TREE_PALM_FRUIT) || \ + ((item) == CEDAR_TREE) || \ + ((item) == GOLD_TREE) || \ + ((item) == GOLD_TREE_SHOVEL) || \ + ((item) == TREE_APPLE_NOFRUIT_0) || \ + ((item) == TREE_ORANGE_NOFRUIT_0) || \ + ((item) == TREE_PEACH_NOFRUIT_0) || \ + ((item) == TREE_PEAR_NOFRUIT_0) || \ + ((item) == TREE_CHERRY_NOFRUIT_0) || \ + ((item) == TREE_PALM_NOFRUIT_0) || \ + ((item) == TREE_APPLE_NOFRUIT_1) || \ + ((item) == TREE_ORANGE_NOFRUIT_1) || \ + ((item) == TREE_PEACH_NOFRUIT_1) || \ + ((item) == TREE_PEAR_NOFRUIT_1) || \ + ((item) == TREE_CHERRY_NOFRUIT_1) || \ + ((item) == TREE_PALM_NOFRUIT_1) || \ + ((item) == TREE_APPLE_NOFRUIT_2) || \ + ((item) == TREE_ORANGE_NOFRUIT_2) || \ + ((item) == TREE_PEACH_NOFRUIT_2) || \ + ((item) == TREE_PEAR_NOFRUIT_2) || \ + ((item) == TREE_CHERRY_NOFRUIT_2) || \ + ((item) == TREE_PALM_NOFRUIT_2) || \ + ((item) == TREE_BEES) || \ + ((item) == TREE_FTR) || \ + ((item) == TREE_LIGHTS) || \ + ((item) == TREE_PRESENT) || \ + ((item) == TREE_BELLS) || \ + ((item) == CEDAR_TREE_BELLS) || \ + ((item) == CEDAR_TREE_FTR) || \ + ((item) == CEDAR_TREE_BEES) || \ + ((item) == CEDAR_TREE_LIGHTS) || \ + ((item) == GOLD_TREE_BELLS) || \ + ((item) == GOLD_TREE_FTR) || \ + ((item) == GOLD_TREE_BEES) \ + ) + +#define IS_ITEM_XMAS_TREE(item) ((item) == TREE_LIGHTS || (item) == CEDAR_TREE_LIGHTS) +#define IS_ITEM_SMALL_TREE(item) ( \ + ((item) == TREE_S0) || \ + ((item) == TREE_APPLE_S0) || \ + ((item) == TREE_ORANGE_S0) || \ + ((item) == TREE_PEACH_S0) || \ + ((item) == TREE_PEAR_S0) || \ + ((item) == TREE_CHERRY_S0) || \ + ((item) == TREE_1000BELLS_S0) || \ + ((item) == TREE_10000BELLS_S0) || \ + ((item) == TREE_30000BELLS_S0) || \ + ((item) == TREE_1000BELLS_S0) || \ + ((item) == TREE_10000BELLS_S0) || \ + ((item) == TREE_30000BELLS_S0) || \ + ((item) == TREE_100BELLS_S0) || \ + ((item) == TREE_PALM_S0) || \ + ((item) == CEDAR_TREE_S0) || \ + ((item) == GOLD_TREE_S0) \ +) +#define IS_ITEM_MED_TREE(item) ( \ + ((item) == TREE_S1) || \ + ((item) == TREE_APPLE_S1) || \ + ((item) == TREE_ORANGE_S1) || \ + ((item) == TREE_PEACH_S1) || \ + ((item) == TREE_PEAR_S1) || \ + ((item) == TREE_CHERRY_S1) || \ + ((item) == TREE_1000BELLS_S1) || \ + ((item) == TREE_10000BELLS_S1) || \ + ((item) == TREE_30000BELLS_S1) || \ + ((item) == TREE_1000BELLS_S1) || \ + ((item) == TREE_10000BELLS_S1) || \ + ((item) == TREE_30000BELLS_S1) || \ + ((item) == TREE_100BELLS_S1) || \ + ((item) == TREE_PALM_S1) || \ + ((item) == CEDAR_TREE_S1) || \ + ((item) == GOLD_TREE_S1) \ +) +#define IS_ITEM_LARGE_TREE(item) ( \ + ((item) == TREE_S2) || \ + ((item) == TREE_APPLE_S2) || \ + ((item) == TREE_ORANGE_S2) || \ + ((item) == TREE_PEACH_S2) || \ + ((item) == TREE_PEAR_S2) || \ + ((item) == TREE_CHERRY_S2) || \ + ((item) == TREE_1000BELLS_S2) || \ + ((item) == TREE_10000BELLS_S2) || \ + ((item) == TREE_30000BELLS_S2) || \ + ((item) == TREE_1000BELLS_S2) || \ + ((item) == TREE_10000BELLS_S2) || \ + ((item) == TREE_30000BELLS_S2) || \ + ((item) == TREE_100BELLS_S2) || \ + ((item) == TREE_PALM_S2) || \ + ((item) == CEDAR_TREE_S2) || \ + ((item) == GOLD_TREE_S2) \ +) + +#define IS_ITEM_FULL_TREE(item) \ + (((item) == TREE) || \ + ((item) == TREE_APPLE_FRUIT) || \ + ((item) == TREE_ORANGE_FRUIT) || \ + ((item) == TREE_PEACH_FRUIT) || \ + ((item) == TREE_PEAR_FRUIT) || \ + ((item) == TREE_CHERRY_FRUIT) || \ + ((item) == TREE_1000BELLS) || \ + ((item) == TREE_10000BELLS) || \ + ((item) == TREE_30000BELLS) || \ + ((item) == TREE_100BELLS) || \ + ((item) == TREE_PALM_FRUIT) || \ + ((item) == CEDAR_TREE) || \ + ((item) == GOLD_TREE) || \ + ((item) == GOLD_TREE_SHOVEL) || \ + ((item) == TREE_APPLE_NOFRUIT_0) || \ + ((item) == TREE_ORANGE_NOFRUIT_0 ) || \ + ((item) == TREE_PEACH_NOFRUIT_0) || \ + ((item) == TREE_PEAR_NOFRUIT_0) || \ + ((item) == TREE_CHERRY_NOFRUIT_0) || \ + ((item) == TREE_PALM_NOFRUIT_0) || \ + ((item) == TREE_APPLE_NOFRUIT_1) || \ + ((item) == TREE_ORANGE_NOFRUIT_1 ) || \ + ((item) == TREE_PEACH_NOFRUIT_1) || \ + ((item) == TREE_PEAR_NOFRUIT_1) || \ + ((item) == TREE_CHERRY_NOFRUIT_1) || \ + ((item) == TREE_PALM_NOFRUIT_1) || \ + ((item) == TREE_APPLE_NOFRUIT_2) || \ + ((item) == TREE_ORANGE_NOFRUIT_2 ) || \ + ((item) == TREE_PEACH_NOFRUIT_2) || \ + ((item) == TREE_PEAR_NOFRUIT_2) || \ + ((item) == TREE_CHERRY_NOFRUIT_2) || \ + ((item) == TREE_PALM_NOFRUIT_2) || \ + ((item) == TREE_BEES) || \ + ((item) == TREE_FTR) || \ + ((item) == TREE_LIGHTS) || \ + ((item) == TREE_PRESENT) || \ + ((item) == TREE_BELLS) || \ + ((item) == CEDAR_TREE_BELLS) || \ + ((item) == CEDAR_TREE_FTR) || \ + ((item) == CEDAR_TREE_BEES) || \ + ((item) == CEDAR_TREE_LIGHTS) || \ + ((item) == GOLD_TREE_BELLS) || \ + ((item) == GOLD_TREE_FTR) || \ + ((item) == GOLD_TREE_BEES) \ + ) + +#define IS_ITEM_SHAKEABLE_TREE(item) (IS_ITEM_MED_TREE(item) || IS_ITEM_LARGE_TREE(item) || IS_ITEM_FULL_TREE(item)) + +#define IS_ITEM_BEE_TREE(item) ((item) == TREE_BEES || (item) == CEDAR_TREE_BEES || (item) == GOLD_TREE_BEES) + +#define IS_ITEM_STONE(item) ((item) >= ROCK_A && (item) <= ROCK_E) +#define IS_ITEM_STONE_TC(item) (((item) >= MONEY_ROCK_A && (item) <= MONEY_ROCK_E) || (item) == MONEY_FLOWER_SEED) /* TC is ten coin */ +#define IS_ITEM_ROCK(item) (((item) >= ROCK_A && (item) <= ROCK_E) || ((item) >= MONEY_ROCK_A && (item) <= MONEY_ROCK_E) || (item) == MONEY_FLOWER_SEED) + #define IS_ITEM_GRASS(item) ((item) >= GRASS_A && (item) <= GRASS_C) /* aka IS_ITEM_WEED */ #define IS_ITEM_HANIWA(item) ((item) >= HANIWA_START && (item) <= HANIWA_END) #define IS_ITEM_DIARY(item) ((item) >= ITM_DIARY_START && (item) <= (ITM_DIARY_END-1)) +#define IS_ITEM_AXE(item) ((item) == ITM_AXE || ((item) >= ITM_AXE_USE_1 && (item) <= ITM_AXE_USE_7)) +#define IS_ITEM_GOLDEN_TOOL(item) ((item) >= ITM_GOLDEN_NET && (item) <= ITM_GOLDEN_ROD) + +#define ITEM_IS_HOLE(item) ((item) >= HOLE_START && (item) <= HOLE_END) +#define ITEM_IS_BURIED_PITFALL_HOLE(item) ((item) >= BURIED_PITFALL_HOLE_START && (item) <= BURIED_PITFALL_HOLE_END) +#define ITEM_IS_BURIED_PITFALL_HOLE_RSV(item) ((item) >= BURIED_PITFALL_HOLE_RSV_START && (item) <= BURIED_PITFALL_HOLE_RSV_END) + +#define ITEM_IS_PLAYER_HOUSE(item) ((item) >= HOUSE0 && (item) < (HOUSE3 + 1)) +#define ITEM_IS_NPC_HOUSE(item) ((item) >= NPC_HOUSE_START && (item) < NPC_HOUSE_END) +#define ITEM_IS_ISLAND_NPC_HOUSE(item) ((item) >= COTTAGE_NPC && (item) < COTTAGE_NPC_END) + +#define ITEM_IS_SIGNBOARD(item) ((item) >= SIGNBOARD_START && (item) <= SIGNBOARD_END) + #define BG_CATEGORY 0 #define ENV_CATEGORY 8 @@ -334,33 +557,60 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define HOLE23 (HOLE_START + 23) #define HOLE24 (HOLE_START + 24) #define HOLE_END HOLE24 -#define BURIED_PITFALL_START 0x002A -#define BURIED_PITFALL00 (BURIED_PITFALL_START + 0) -#define BURIED_PITFALL01 (BURIED_PITFALL_START + 1) -#define BURIED_PITFALL02 (BURIED_PITFALL_START + 2) -#define BURIED_PITFALL03 (BURIED_PITFALL_START + 3) -#define BURIED_PITFALL04 (BURIED_PITFALL_START + 4) -#define BURIED_PITFALL05 (BURIED_PITFALL_START + 5) -#define BURIED_PITFALL06 (BURIED_PITFALL_START + 6) -#define BURIED_PITFALL07 (BURIED_PITFALL_START + 7) -#define BURIED_PITFALL08 (BURIED_PITFALL_START + 8) -#define BURIED_PITFALL09 (BURIED_PITFALL_START + 9) -#define BURIED_PITFALL10 (BURIED_PITFALL_START + 10) -#define BURIED_PITFALL11 (BURIED_PITFALL_START + 11) -#define BURIED_PITFALL12 (BURIED_PITFALL_START + 12) -#define BURIED_PITFALL13 (BURIED_PITFALL_START + 13) -#define BURIED_PITFALL14 (BURIED_PITFALL_START + 14) -#define BURIED_PITFALL15 (BURIED_PITFALL_START + 15) -#define BURIED_PITFALL16 (BURIED_PITFALL_START + 16) -#define BURIED_PITFALL17 (BURIED_PITFALL_START + 17) -#define BURIED_PITFALL18 (BURIED_PITFALL_START + 18) -#define BURIED_PITFALL19 (BURIED_PITFALL_START + 19) -#define BURIED_PITFALL20 (BURIED_PITFALL_START + 20) -#define BURIED_PITFALL21 (BURIED_PITFALL_START + 21) -#define BURIED_PITFALL22 (BURIED_PITFALL_START + 22) -#define BURIED_PITFALL23 (BURIED_PITFALL_START + 23) -#define BURIED_PITFALL24 (BURIED_PITFALL_START + 24) -#define BURIED_PITFALL_END BURIED_PITFALL24 +#define BURIED_PITFALL_HOLE_START 0x002A +#define BURIED_PITFALL_HOLE00 (BURIED_PITFALL_HOLE_START + 0) +#define BURIED_PITFALL_HOLE01 (BURIED_PITFALL_HOLE_START + 1) +#define BURIED_PITFALL_HOLE02 (BURIED_PITFALL_HOLE_START + 2) +#define BURIED_PITFALL_HOLE03 (BURIED_PITFALL_HOLE_START + 3) +#define BURIED_PITFALL_HOLE04 (BURIED_PITFALL_HOLE_START + 4) +#define BURIED_PITFALL_HOLE05 (BURIED_PITFALL_HOLE_START + 5) +#define BURIED_PITFALL_HOLE06 (BURIED_PITFALL_HOLE_START + 6) +#define BURIED_PITFALL_HOLE07 (BURIED_PITFALL_HOLE_START + 7) +#define BURIED_PITFALL_HOLE08 (BURIED_PITFALL_HOLE_START + 8) +#define BURIED_PITFALL_HOLE09 (BURIED_PITFALL_HOLE_START + 9) +#define BURIED_PITFALL_HOLE10 (BURIED_PITFALL_HOLE_START + 10) +#define BURIED_PITFALL_HOLE11 (BURIED_PITFALL_HOLE_START + 11) +#define BURIED_PITFALL_HOLE12 (BURIED_PITFALL_HOLE_START + 12) +#define BURIED_PITFALL_HOLE13 (BURIED_PITFALL_HOLE_START + 13) +#define BURIED_PITFALL_HOLE14 (BURIED_PITFALL_HOLE_START + 14) +#define BURIED_PITFALL_HOLE15 (BURIED_PITFALL_HOLE_START + 15) +#define BURIED_PITFALL_HOLE16 (BURIED_PITFALL_HOLE_START + 16) +#define BURIED_PITFALL_HOLE17 (BURIED_PITFALL_HOLE_START + 17) +#define BURIED_PITFALL_HOLE18 (BURIED_PITFALL_HOLE_START + 18) +#define BURIED_PITFALL_HOLE19 (BURIED_PITFALL_HOLE_START + 19) +#define BURIED_PITFALL_HOLE20 (BURIED_PITFALL_HOLE_START + 20) +#define BURIED_PITFALL_HOLE21 (BURIED_PITFALL_HOLE_START + 21) +#define BURIED_PITFALL_HOLE22 (BURIED_PITFALL_HOLE_START + 22) +#define BURIED_PITFALL_HOLE23 (BURIED_PITFALL_HOLE_START + 23) +#define BURIED_PITFALL_HOLE24 (BURIED_PITFALL_HOLE_START + 24) +#define BURIED_PITFALL_HOLE_END BURIED_PITFALL_HOLE24 +#define BURIED_PITFALL_HOLE_RSV_START 0x0043 +#define BURIED_PITFALL_HOLE_RSV00 (BURIED_PITFALL_HOLE_RSV_START + 0) +#define BURIED_PITFALL_HOLE_RSV01 (BURIED_PITFALL_HOLE_RSV_START + 1) +#define BURIED_PITFALL_HOLE_RSV02 (BURIED_PITFALL_HOLE_RSV_START + 2) +#define BURIED_PITFALL_HOLE_RSV03 (BURIED_PITFALL_HOLE_RSV_START + 3) +#define BURIED_PITFALL_HOLE_RSV04 (BURIED_PITFALL_HOLE_RSV_START + 4) +#define BURIED_PITFALL_HOLE_RSV05 (BURIED_PITFALL_HOLE_RSV_START + 5) +#define BURIED_PITFALL_HOLE_RSV06 (BURIED_PITFALL_HOLE_RSV_START + 6) +#define BURIED_PITFALL_HOLE_RSV07 (BURIED_PITFALL_HOLE_RSV_START + 7) +#define BURIED_PITFALL_HOLE_RSV08 (BURIED_PITFALL_HOLE_RSV_START + 8) +#define BURIED_PITFALL_HOLE_RSV09 (BURIED_PITFALL_HOLE_RSV_START + 9) +#define BURIED_PITFALL_HOLE_RSV10 (BURIED_PITFALL_HOLE_RSV_START + 10) +#define BURIED_PITFALL_HOLE_RSV11 (BURIED_PITFALL_HOLE_RSV_START + 11) +#define BURIED_PITFALL_HOLE_RSV12 (BURIED_PITFALL_HOLE_RSV_START + 12) +#define BURIED_PITFALL_HOLE_RSV13 (BURIED_PITFALL_HOLE_RSV_START + 13) +#define BURIED_PITFALL_HOLE_RSV14 (BURIED_PITFALL_HOLE_RSV_START + 14) +#define BURIED_PITFALL_HOLE_RSV15 (BURIED_PITFALL_HOLE_RSV_START + 15) +#define BURIED_PITFALL_HOLE_RSV16 (BURIED_PITFALL_HOLE_RSV_START + 16) +#define BURIED_PITFALL_HOLE_RSV17 (BURIED_PITFALL_HOLE_RSV_START + 17) +#define BURIED_PITFALL_HOLE_RSV18 (BURIED_PITFALL_HOLE_RSV_START + 18) +#define BURIED_PITFALL_HOLE_RSV19 (BURIED_PITFALL_HOLE_RSV_START + 19) +#define BURIED_PITFALL_HOLE_RSV20 (BURIED_PITFALL_HOLE_RSV_START + 20) +#define BURIED_PITFALL_HOLE_RSV21 (BURIED_PITFALL_HOLE_RSV_START + 21) +#define BURIED_PITFALL_HOLE_RSV22 (BURIED_PITFALL_HOLE_RSV_START + 22) +#define BURIED_PITFALL_HOLE_RSV23 (BURIED_PITFALL_HOLE_RSV_START + 23) +#define BURIED_PITFALL_HOLE_RSV24 (BURIED_PITFALL_HOLE_RSV_START + 24) +#define BURIED_PITFALL_HOLE_RSV_END BURIED_PITFALL_HOLE_RSV24 #define SHINE_SPOT 0x005C #define HOLE_SHINE 0x005D #define TREE_BEES 0x005E @@ -569,6 +819,7 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define SIGNBOARD5_PLR3 (SIGNBOARD4_PLR3 + 1) #define SIGNBOARD6_PLR3 (SIGNBOARD5_PLR3 + 1) #define SIGNBOARD7_PLR3 (SIGNBOARD6_PLR3 + 1) +#define SIGNBOARD_END (SIGNBOARD7_PLR3) #define FTR0_START 0x1000 #define FTR_CLASSIC_WARDROBE 0x1004 @@ -2269,6 +2520,7 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define BOAT (STRUCTURE_START + 79) #define COTTAGE_MY (STRUCTURE_START + 80) #define COTTAGE_NPC (STRUCTURE_START + 81) +#define COTTAGE_NPC_END (COTTAGE_NPC + 1) #define PORT_SIGN (STRUCTURE_START + 82) #define STRUCTURE_END (STRUCTURE_START + 83) diff --git a/include/m_player.h b/include/m_player.h index 7bfcebb7..b6ee9568 100644 --- a/include/m_player.h +++ b/include/m_player.h @@ -17,6 +17,14 @@ extern "C" { #define mPlayer_DEBT3 49800 /* Basement */ #define mPlayer_DEBT4 798000 /* Upper floor */ +/* These are in frames */ +#define mPlayer_SUNBURN_TIME_VILLAGE (15 * mTM_SECONDS_IN_MINUTE * FRAMES_PER_SECOND) +#define mPlayer_SUNBURN_TIME_ISLAND (5 * mTM_SECONDS_IN_MINUTE * FRAMES_PER_SECOND) + +#define mPlayer_SUNBURN_MAX_RANK 8 + +#define mPlayer_RADIO_EXCERCISE_COMMAND_RING_BUFFER_SIZE 8 + typedef struct player_actor_s PLAYER_ACTOR; #define mPlayer_FORCE_POSITION_ANGLE_NONE 0 @@ -31,6 +39,8 @@ typedef struct player_actor_s PLAYER_ACTOR; #define mPlayer_WALK_FLAG_SET_POS (1 << 1) #define mPlayer_WALK_FLAG_RESET_MORPH (1 << 2) +#define mPlayer_NET_CATCH_TABLE_COUNT 8 + enum { mPlayer_JOINT_ROOT, mPlayer_JOINT_BASE, @@ -66,7 +76,7 @@ enum { mPlayer_ADDRESSABLE_TRUE, mPlayer_ADDRESSABLE_FALSE_MOVEMENT, mPlayer_ADDRESSABLE_FALSE_TALKING, - mPlayer_ADDRESSABLE_FALSE_USING_TOOL, + mPlayer_ADDRESSABLE_FALSE_READY_NET, mPlayer_ADDRESSABLE_NUM }; @@ -215,6 +225,61 @@ enum { #define mPlayer_MAIN_INDEX_VALID(idx) ((idx) >= 0 && (idx) < mPlayer_INDEX_NUM) +enum { + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_1, + mPlayer_REQUEST_PRIORITY_2, + mPlayer_REQUEST_PRIORITY_3, + mPlayer_REQUEST_PRIORITY_4, + mPlayer_REQUEST_PRIORITY_5, + mPlayer_REQUEST_PRIORITY_6, + mPlayer_REQUEST_PRIORITY_7, + mPlayer_REQUEST_PRIORITY_8, + mPlayer_REQUEST_PRIORITY_9, + mPlayer_REQUEST_PRIORITY_10, + mPlayer_REQUEST_PRIORITY_11, + mPlayer_REQUEST_PRIORITY_12, + mPlayer_REQUEST_PRIORITY_13, + mPlayer_REQUEST_PRIORITY_14, + mPlayer_REQUEST_PRIORITY_15, + mPlayer_REQUEST_PRIORITY_16, + mPlayer_REQUEST_PRIORITY_17, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_22, + mPlayer_REQUEST_PRIORITY_23, + mPlayer_REQUEST_PRIORITY_24, + mPlayer_REQUEST_PRIORITY_25, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_27, + mPlayer_REQUEST_PRIORITY_28, + mPlayer_REQUEST_PRIORITY_29, + mPlayer_REQUEST_PRIORITY_30, + mPlayer_REQUEST_PRIORITY_31, + mPlayer_REQUEST_PRIORITY_32, + mPlayer_REQUEST_PRIORITY_33, + mPlayer_REQUEST_PRIORITY_34, + mPlayer_REQUEST_PRIORITY_35, + mPlayer_REQUEST_PRIORITY_36, + mPlayer_REQUEST_PRIORITY_37, + mPlayer_REQUEST_PRIORITY_38, + mPlayer_REQUEST_PRIORITY_39, + mPlayer_REQUEST_PRIORITY_40, + mPlayer_REQUEST_PRIORITY_41, + mPlayer_REQUEST_PRIORITY_42, + mPlayer_REQUEST_PRIORITY_43, + mPlayer_REQUEST_PRIORITY_44, + mPlayer_REQUEST_PRIORITY_45, + + mPlayer_REQUEST_PRIORITY_NUM +}; + +#define mPlayer_REQUEST_PRIORITY_NONE -1 + +#define mPlayer_REQUEST_PRIORITY_VALID(prio) ((prio) >= 0 && (prio) < mPlayer_REQUEST_PRIORITY_NUM) + enum { mPlayer_ANIM_WAIT1, mPlayer_ANIM_WALK1, @@ -377,6 +442,35 @@ enum { mPlayer_ANIM_NUM }; +enum { + mPlayer_ITEM_MAIN_NONE, + mPlayer_ITEM_MAIN_AXE_NORMAL, + mPlayer_ITEM_MAIN_NET_NORMAL, + mPlayer_ITEM_MAIN_NET_SWING, + mPlayer_ITEM_MAIN_NET_STOP, + mPlayer_ITEM_MAIN_TUMBLE, + mPlayer_ITEM_MAIN_TUBMLE_GETUP, + mPlayer_ITEM_MAIN_NET_PULL, + mPlayer_ITEM_MAIN_NET_PUTAWAY, + mPlayer_ITEM_MAIN_NET_COMPLETE_COLLECTION, + mPlayer_ITEM_MAIN_UMBRELLA_NORMAL, + mPlayer_ITEM_MAIN_ROD_NORMAL, + mPlayer_ITEM_MAIN_ROD_READY, + mPlayer_ITEM_MAIN_ROD_CAST, + mPlayer_ITEM_MAIN_ROD_AIR, + mPlayer_ITEM_MAIN_ROD_RELAX, + mPlayer_ITEM_MAIN_ROD_COLLECT, + mPlayer_ITEM_MAIN_ROD_VIB, + mPlayer_ITEM_MAIN_ROD_FLY, + mPlayer_ITEM_MAIN_ROD_PUTAWAY, + mPlayer_ITEM_MAIN_SCOOP_NORMAL, + mPlayer_ITEM_MAIN_BALLOON_NORMAL, + mPlayer_ITEM_MAIN_WINDMILL_NORMAL, + mPlayer_ITEM_MAIN_FAN_NORMAL, + + mPlayer_ITEM_MAIN_NUM, +}; + enum { mPlayer_ITEM_KIND_AXE, mPlayer_ITEM_KIND_AXE_USE_1, @@ -469,6 +563,8 @@ enum { mPlayer_ITEM_KIND_NUM /* Are there more? */ }; +#define mPlayer_ITEM_KIND_NONE -1 + #define mPlayer_ITEM_KIND_CHECK(kind, min, max) ((kind) >= (min) && (kind) < ((max) + 1)) #define mPlayer_ITEM_IS_AXE(kind) mPlayer_ITEM_KIND_CHECK(kind, mPlayer_ITEM_KIND_AXE, mPlayer_ITEM_KIND_GOLD_AXE) #define mPlayer_ITEM_IS_NET(kind) mPlayer_ITEM_KIND_CHECK(kind, mPlayer_ITEM_KIND_NET, mPlayer_ITEM_KIND_GOLD_NET) @@ -483,6 +579,9 @@ enum { mPlayer_ITEM_KIND_CHECK(kind, mPlayer_ITEM_KIND_YELLOW_PINWHEEL, mPlayer_ITEM_KIND_FANCY_PINWHEEL) #define mPlayer_ITEM_IS_FAN(kind) \ mPlayer_ITEM_KIND_CHECK(kind, mPlayer_ITEM_KIND_BLUEBELL_FAN, mPlayer_ITEM_KIND_LEAF_FAN) +#define mPlayer_ITEM_IS_NOT_TOOL(kind) \ + (mPlayer_ITEM_IS_UMBRELLA(kind) || mPlayer_ITEM_IS_BALLOON(kind) || mPlayer_ITEM_IS_WINDMILL(kind) || \ + mPlayer_ITEM_IS_FAN(kind)) #define mPlayer_ITEM_KIND_VALID(kind) ((kind) >= 0 && kind < mPlayer_ITEM_KIND_NUM) @@ -592,6 +691,59 @@ enum { mPlayer_DRAW_TYPE_NUM }; +enum { + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_WORLD_POS, + mPlayer_SHADOW_TYPE_ANIME_POS, + mPlayer_SHADOW_TYPE_NONE, + + mPlayer_SHADOW_TYPE_NUM +}; + +enum { + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_ENTER_BUILDING, + + mPlayer_STATUS_FOR_BEE_NUM +}; + +enum { + mPlayer_NET_CATCH_TYPE_INSECT, + mPlayer_NET_CATCH_TYPE_UNK1, + + mPlayer_NET_CATCH_TYPE_NUM +}; + +enum { + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_NONE, + + mPlayer_ABLE_ITEM_NUM +}; + +enum { + mPlayer_AXE_HIT_NONE, + mPlayer_AXE_HIT_REFLECT, + mPlayer_AXE_HIT_TREE, + + mPlayer_AXE_HIT_NUM +}; + +enum { + mPlayer_AXE_BREAK_FROM_SWING, + mPlayer_AXE_BREAK_FROM_REFLECT, + + mPlayer_AXE_BREAK_FROM_NUM +}; + +#define mPlayer_SETUP_TEXTURE_ANIMATION_NONE (0 << 0) +/* Where is (1 << 0)? */ +#define mPlayer_SETUP_TEXTURE_ANIMATION_EYE (1 << 1) +#define mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH (1 << 2) + typedef struct player_request_return_demo_s { int prev_main_index; f32 time; @@ -745,6 +897,10 @@ typedef struct player_request_stung_mosquito_s { u32 label; } mPlayer_request_stung_mosquito_c; +typedef struct player_request_notice_mosquito_s { + u32 label; +} mPlayer_request_notice_mosquito_c; + typedef struct player_request_switch_on_lighthouse_s { s16 angle_y; xyz_t pos; @@ -795,7 +951,7 @@ typedef struct player_request_wade_s { typedef struct player_request_wade_snowball_s { int dir; - xyz_t pos; + xyz_t snowball_dist; u32 label; } mPlayer_request_wade_snowball_c; @@ -927,7 +1083,7 @@ typedef struct player_request_reflect_scoop_s { typedef struct player_request_putin_scoop_s { xyz_t dig_pos; mActor_name_t item; - int _10; + int get_gold_scoop_flag; } mPlayer_request_putin_scoop_c; typedef struct player_request_putaway_scoop_s { @@ -1039,7 +1195,7 @@ typedef struct player_request_radio_exercise_s { typedef struct player_request_demo_geton_boat_wade_s { int dir; - f32 speed; // TODO: check this + f32 border_ofs; } mPlayer_request_demo_geton_boat_wade_c; typedef struct player_request_demo_getoff_boat_s { @@ -1116,6 +1272,7 @@ typedef union { mPlayer_request_shock_c shock; mPlayer_request_push_snowball_c push_snowball; mPlayer_request_stung_mosquito_c stung_mosquito; + mPlayer_request_notice_mosquito_c notice_mosquito; mPlayer_request_switch_on_lighthouse_c switch_on_lighthouse; mPlayer_request_demo_geton_boat_c demo_geton_boat; mPlayer_request_demo_getoff_boat_standup_c demo_getoff_boat_standup; @@ -1219,6 +1376,7 @@ typedef union { mPlayer_request_shock_c shock; mPlayer_request_push_snowball_c push_snowball; mPlayer_request_stung_mosquito_c stung_mosquito; + mPlayer_request_notice_mosquito_c notice_mosquito; mPlayer_request_switch_on_lighthouse_c switch_on_lighthouse; mPlayer_request_demo_geton_boat_c demo_geton_boat; mPlayer_request_demo_getoff_boat_standup_c demo_getoff_boat_standup; @@ -1305,6 +1463,10 @@ typedef struct player_main_wait_s { int radio_exercise_command; } mPlayer_main_wait_c; +typedef struct player_main_door_s { + u32 label; +} mPlayer_main_door_c; + typedef struct player_main_wade_s { int dir; xyz_t start_pos; @@ -1332,6 +1494,49 @@ typedef struct player_main_pickup_jump_s { int exchange_flag; } mPlayer_main_pickup_jump_c; +typedef struct player_main_swing_axe_s { + /* 0x00 */ xyz_t target_pos; + /* 0x0C */ mActor_name_t item; + /* 0x0E */ u16 axe_damage_no; + /* 0x10 */ int tree_ut_x; + /* 0x14 */ int tree_ut_z; + /* 0x18 */ int bee_flag; + /* 0x1C */ s16 bee_angle_y; + /* 0x20 */ int bee_counter; +} mPlayer_main_swing_axe_c; + +typedef struct player_main_reflect_axe_s { + xyz_t target_pos; + mActor_name_t item; + u16 axe_damage_no; + ACTOR* reflect_actor_p; +} mPlayer_main_reflect_axe_c; + +typedef struct player_main_broken_axe_s { + union { + mPlayer_main_swing_axe_c swing_axe; + mPlayer_main_reflect_axe_c reflect_axe; + } axe; + int break_type; /* mPlayer_AXE_BREAK_FROM_* */ + f32 _28; + int _2C; +} mPlayer_main_broken_axe_c; + +typedef struct player_main_dig_scoop_s { + xyz_t target_pos; + mActor_name_t item; +} mPlayer_main_dig_scoop_c; + +typedef struct player_main_fill_scoop_s { + xyz_t target_pos; +} mPlayer_main_fill_scoop_c; + +typedef struct player_main_reflect_scoop_s { + xyz_t target_pos; + mActor_name_t item; + ACTOR* reflect_actor_p; +} mPlayer_main_reflect_scoop_c; + typedef struct player_main_get_scoop_s { xyz_t target_pos; mActor_name_t item; @@ -1349,6 +1554,12 @@ typedef struct player_main_putaway_scoop_s { int submenu_flag; } mPlayer_main_putaway_scoop_c; +typedef struct player_main_putin_scoop_s { + xyz_t target_pos; + mActor_name_t item; + int get_gold_scoop_flag; // TODO: check this +} mPlayer_main_putin_scoop_c; + typedef struct player_main_wash_car_s { int anime_idx; int change_anime_idx; @@ -1360,6 +1571,51 @@ typedef struct player_main_wash_car_s { int effect_flag; } mPlayer_main_wash_car_c; +typedef struct player_main_swing_net_s { + f32 swing_timer; +} mPlayer_main_swing_net_c; + +typedef struct player_main_demo_wade_s { + int dir; + xyz_t start_pos; + xyz_t end_pos; + f32 timer; +} mPlayer_main_demo_wade_c; + +typedef struct player_main_shake_tree_s { + xyz_t target_pos; + mActor_name_t item; + int tree_ut_x; + int tree_ut_z; + int bee_flag; + s16 bee_angle_y; + int bee_spawn_timer; +} mPlayer_main_shake_tree_c; + +typedef struct player_main_stung_bee_s { + f32 timer; +} mPlayer_main_stung_bee_c; + +typedef struct player_main_push_snowball_s { + u32 label; +} mPlayer_main_push_snowball_c; + +typedef struct player_main_wade_snowball_s { + int dir; + xyz_t start_pos; + xyz_t end_pos; + f32 timer; + xyz_t snowball_dist; + u32 snowball_label; +} mPlayer_main_wade_snowball_c; + +typedef struct player_main_demo_geton_boat_wade_s { + int dir; + xyz_t start_pos; + xyz_t end_pos; + f32 timer; +} mPlayer_main_demo_geton_boat_wade_c; + typedef struct player_main_demo_geton_boat_sitdown_s { s16 angle_z; } mPlayer_main_demo_geton_boat_sitdown_c; @@ -1384,12 +1640,27 @@ typedef union { mPlayer_main_return_outdoor_c return_outdoor; mPlayer_main_return_outdoor2_c return_outdoor2; mPlayer_main_wait_c wait; + mPlayer_main_door_c door; mPlayer_main_wade_c wade; mPlayer_main_pickup_c pickup; mPlayer_main_pickup_jump_c pickup_jump; + mPlayer_main_swing_axe_c swing_axe; + mPlayer_main_reflect_axe_c reflect_axe; + mPlayer_main_broken_axe_c broken_axe; + mPlayer_main_swing_net_c swing_net; + mPlayer_main_dig_scoop_c dig_scoop; + mPlayer_main_fill_scoop_c fill_scoop; + mPlayer_main_reflect_scoop_c reflect_scoop; mPlayer_main_get_scoop_c get_scoop; mPlayer_main_putaway_scoop_c putaway_scoop; + mPlayer_main_putin_scoop_c putin_scoop; + mPlayer_main_demo_wade_c demo_wade; mPlayer_main_wash_car_c wash_car; + mPlayer_main_shake_tree_c shake_tree; + mPlayer_main_stung_bee_c stung_bee; + mPlayer_main_push_snowball_c push_snowball; + mPlayer_main_wade_snowball_c wade_snowball; + mPlayer_main_demo_geton_boat_wade_c demo_geton_boat_wade; mPlayer_main_demo_geton_boat_sitdown_c demo_geton_boat_sitdown; mPlayer_main_demo_getoff_boat_standup_c demo_getoff_boat_standup; mPlayer_main_uki_c uki; @@ -1412,6 +1683,10 @@ typedef struct controller_data_s { mActor_name_t equiped_item; } mPlayer_Controller_Data_c; +typedef struct player_eye_pattern_s { + s16 pattern; + s16 timer; +} mPlayer_eye_pattern_c; /* sizeof(struct player_actor_s) == 0x13A8 */ struct player_actor_s { @@ -1425,15 +1700,14 @@ struct player_actor_s { /* 0x0A88 */ s_xyz item_joint_data[8]; /* 0x0AB8 */ s_xyz item_morph_data[8]; /* 0x0AE8 */ Mtx item_work_mtx[2][4]; /* swapped between frames */ - /* 0x0CE8 */ s16 eye_pattern_normal; - /* 0x0CEA */ s16 eye_pattern_normal_timer; + /* 0x0CE8 */ mPlayer_eye_pattern_c eye_pattern_normal; /* 0x0CEC */ int blink_count; /* 0x0CF0 */ int eye_tex_idx; /* 0x0CF4 */ int mouth_tex_idx; /* 0x0CF8 */ int now_main_index; /* 0x0CFC */ int prev_main_index; /* 0x0D00 */ int changed_main_index; - /* 0x0D04 */ int item_main_index; + /* 0x0D04 */ int now_item_main_index; /* 0x0D08 */ int requested_main_index; /* 0x0D0C */ int requested_main_index_priority; /* 0x0D10 */ int requested_main_index_changed; @@ -1443,8 +1717,12 @@ struct player_actor_s { /* 0x0DA8 */ u8 _0DA8[0x0DB4 - 0x0DA8]; /* unused */ /* 0x0DB4 */ int animation0_idx; /* 0x0DB8 */ int animation1_idx; - /* 0x0DBC */ int _0DBC; - /* 0x0DC0 */ int _0DC0[9]; + /* 0x0DBC */ int part_table_idx; + /* 0x0DC0 */ int _0DC0; + /* 0x0DC4 */ int item_shape_addr[2]; + /* 0x0DCC */ int item_anim_addr[2]; + /* 0x0DD4 */ int item_shape_segaddr[2]; + /* 0x0DDC */ int item_anim_segaddr[2]; /* 0x0DE4 */ int item_shape_type[2]; /* 0x0DEC */ int item_animation_idx[2]; /* 0x0DF4 */ int item_bank_idx; @@ -1466,10 +1744,10 @@ struct player_actor_s { /* 0x0E70 */ u32 item_net_catch_label; /* 0x0E74 */ s8 item_net_catch_type; /* 0x0E75 */ s8 item_net_has_catch; - /* 0x0E78 */ u32 item_net_catch_label_request_table[8]; - /* 0x0E98 */ s8 item_net_catch_type_request_table[8]; - /* 0x0EA0 */ xyz_t item_net_catch_pos_request_table[8]; - /* 0x0F00 */ f32 item_net_catch_radius_request_table[8]; + /* 0x0E78 */ u32 item_net_catch_label_request_table[mPlayer_NET_CATCH_TABLE_COUNT]; + /* 0x0E98 */ s8 item_net_catch_type_request_table[mPlayer_NET_CATCH_TABLE_COUNT]; + /* 0x0EA0 */ xyz_t item_net_catch_pos_request_table[mPlayer_NET_CATCH_TABLE_COUNT]; + /* 0x0F00 */ f32 item_net_catch_radius_request_table[mPlayer_NET_CATCH_TABLE_COUNT]; /* 0x0F20 */ int item_net_catch_request_use_count; /* 0x0F24 */ u32 item_net_catch_label_request_force; /* 0x0F28 */ s8 item_net_catch_type_request_force; @@ -1477,7 +1755,7 @@ struct player_actor_s { /* 0x0F30 */ ACTOR* fishing_rod_actor_p; /* 0x0F34 */ xyz_t item_rod_top_pos; /* 0x0F40 */ xyz_t item_rod_virtual_top_pos; - /* 0x0F4C */ int update_item_rod_top_pos; + /* 0x0F4C */ int item_rod_top_pos_set; /* 0x0F50 */ s16 item_rod_angle_z; /* 0x0F54 */ ClObjTris_c item_axe_tris; /* 0x0F68 */ ClObjTrisElem_c item_axe_tris_elem_tbl[1]; @@ -1534,18 +1812,18 @@ struct player_actor_s { /* 0x11F9 */ s8 bgm_volume_mode; /* 0x11FC */ int crash_snowball_for_wade; /* 0x1200 */ xyz_t snowball_dist; - /* 0x120C */ int wade_request_flag; + /* 0x120C */ int request_wade_dir; /* 0x1210 */ u16 cancel_wade_timer; - /* 0x1214 */ int cancel_wade_flag; - /* 0x1218 */ f32 geton_boat_wade; - /* 0x121C */ u16 frame_timer; + /* 0x1214 */ int excute_cancel_wade; + /* 0x1218 */ f32 geton_boat_wade_border_start; + /* 0x121C */ u16 player_frame_counter; /* 0x121E */ s8 bee_chase_bgm_flag; /* 0x121F */ s8 status_for_bee; - /* 0x1220 */ void* angle_force_speak_label; + /* 0x1220 */ u32 able_force_speak_label; /* 0x1224 */ int player_sunburn_rankup; /* 0x1228 */ int player_sunburn_rankdown; - /* 0x122C */ s8 radio_exercise_command_ring_buffer[8]; - /* 0x1234 */ s8 radio_exercise_ring_buffer_cmd_num; + /* 0x122C */ s8 radio_exercise_command_ring_buffer[mPlayer_RADIO_EXCERCISE_COMMAND_RING_BUFFER_SIZE]; + /* 0x1234 */ s8 radio_exercise_ring_buffer_cmd_timer; /* 0x1238 */ int radio_exercise_command_ring_buffer_index; /* 0x123C */ int radio_exercise_continue_cmd_idx; /* 0x1240 */ f32 radio_exercise_cmd_timer; diff --git a/include/m_player_lib.h b/include/m_player_lib.h index 1dd97404..0e32ee73 100644 --- a/include/m_player_lib.h +++ b/include/m_player_lib.h @@ -106,6 +106,10 @@ extern int mPlib_request_main_demo_getoff_train_type1(GAME* game); extern int mPlib_check_player_actor_main_index_OutDoorMove2(GAME* game); extern int mPlib_Check_SetOrderSubmenu(void); extern void mPlib_Clear_change_data_from_submenu(void); +extern int mPlib_strength_request_main_wade_priority(GAME* game); +extern int mPlib_strength_request_main_demo_wade_priority(GAME* game); +extern int mPlib_strength_request_main_demo_geton_boat_wade_priority(GAME* game); +extern int mPlib_strength_request_main_wade_snowball_priority(GAME* game); extern mPlayer_change_data_from_submenu_c* mPlib_Get_change_data_from_submenu_p(); @@ -120,6 +124,10 @@ extern void mPlib_request_main_give_type1(GAME* game, mActor_name_t item, int mo #define GET_PLAYER_ACTOR_NOW() get_player_actor_withoutCheck((GAME_PLAY*)gamePT) #define GET_PLAYER_ACTOR_GAME(game) get_player_actor_withoutCheck((GAME_PLAY*)(game)) +#define GET_PLAYER_ACTOR_ACTOR(play) ((ACTOR*)GET_PLAYER_ACTOR(play)) +#define GET_PLAYER_ACTOR_NOW_ACTOR() ((ACTOR*)GET_PLAYER_ACTOR_NOW()) +#define GET_PLAYER_ACTOR_GAME_ACTOR(game) ((ACTOR*)GET_PLAYER_ACTOR_GAME(game)) + #ifdef __cplusplus } #endif diff --git a/include/m_submenu.h b/include/m_submenu.h index d67f0c88..9010a1c5 100644 --- a/include/m_submenu.h +++ b/include/m_submenu.h @@ -178,9 +178,9 @@ struct submenu_s { /* 0x162 */ u8 open_flag; // only set to 0 or 1, checked at least once in aQMgr_actor_move_talk_sub_hand_item_wait /* 0x163 */ u8 after_mode; /* relates to code which runs after the submenu process */ /* 0x164 */ u8 unk_164; // only set to 0 in mSM_move_LINKWait in AC - /* 0x165 */ u8 disable_start_btn_flag; /* when set to TRUE, the START button input will be ignored */ - /* 0x166 */ u8 disable_start_btn_timer; /* timer for when to disable the start button ignore flag */ - /* 0x168 */ xyz_t water_pos; /* calculated to the nearest water position to the player for releasing fish */ + /* 0x165 */ u8 start_refuse; /* when set to TRUE, the START button input will be ignored */ + /* 0x166 */ u8 start_refuse_timer; /* timer for when to disable the start button ignore flag */ + /* 0x168 */ xyz_t water_pos; /* calculated to the nearest water position to the player for releasing fish */ /* 0x174 */ Submenu_Item_c* item_p; /* pointer to a 'Submenu_Item_c' array, seemingly only points to Submenu::items */ /* 0x178 */ s16 item_num; /* number of items in the item array */ diff --git a/include/types.h b/include/types.h index 35aeebf8..5633403f 100644 --- a/include/types.h +++ b/include/types.h @@ -83,6 +83,8 @@ typedef u32 unknown; #define BUTTON_B 0x4000 #define BUTTON_A 0x8000 +#define FRAMES_PER_SECOND 60 + #define ARRAY_SIZE(arr, type) (sizeof(arr) / sizeof(type)) #define ARRAY_COUNT(arr) (int)(sizeof(arr) / sizeof(arr[0])) diff --git a/src/ac_br_shop_move.c_inc b/src/ac_br_shop_move.c_inc index 7aa57ac4..389e4f7d 100644 --- a/src/ac_br_shop_move.c_inc +++ b/src/ac_br_shop_move.c_inc @@ -16,7 +16,8 @@ static void change_FGUnit(ACTOR* actor, int type) { if (mSN_ClearSnowman(name) == 0) { int dug = FALSE; - if ((((*name >= BURIED_PITFALL_START) && (*name <= BURIED_PITFALL_END)) || (*name == SHINE_SPOT))) { + if ((((*name >= BURIED_PITFALL_HOLE_START) && (*name <= BURIED_PITFALL_HOLE_END)) || + (*name == SHINE_SPOT))) { dug = TRUE; } diff --git a/src/ac_buggy_move.c_inc b/src/ac_buggy_move.c_inc index 150d291e..0579b48e 100644 --- a/src/ac_buggy_move.c_inc +++ b/src/ac_buggy_move.c_inc @@ -34,7 +34,8 @@ static void change_FGUnit(STRUCTURE_ACTOR* buggy, int type) { if (mSN_ClearSnowman(unit_fg) == FALSE) { dug = FALSE; - if ((((*unit_fg >= BURIED_PITFALL_START) && (*unit_fg <= BURIED_PITFALL_END)) || (*unit_fg == SHINE_SPOT))) { + if ((((*unit_fg >= BURIED_PITFALL_HOLE_START) && (*unit_fg <= BURIED_PITFALL_HOLE_END)) || + (*unit_fg == SHINE_SPOT))) { dug = TRUE; } diff --git a/src/ac_kamakura_move.c_inc b/src/ac_kamakura_move.c_inc index c8fc9295..76cac6dc 100644 --- a/src/ac_kamakura_move.c_inc +++ b/src/ac_kamakura_move.c_inc @@ -31,7 +31,8 @@ static void change_FGUnit(STRUCTURE_ACTOR* kamakura, int type) { if (mSN_ClearSnowman(unit_fg) == FALSE) { dug = FALSE; - if ((((*unit_fg >= BURIED_PITFALL_START) && (*unit_fg <= BURIED_PITFALL_END)) || (*unit_fg == SHINE_SPOT))) { + if ((((*unit_fg >= BURIED_PITFALL_HOLE_START) && (*unit_fg <= BURIED_PITFALL_HOLE_END)) || + (*unit_fg == SHINE_SPOT))) { dug = TRUE; } @@ -171,14 +172,7 @@ static void aKKR_wait(STRUCTURE_ACTOR* kamakura, GAME_PLAY* play) { static void aKKR_setup_action(STRUCTURE_ACTOR* kamakura, int action) { static aSTR_MOVE_PROC process[] = { - &aKKR_wait, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + &aKKR_wait, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; kamakura->action_proc = process[action]; diff --git a/src/ac_npc_rcn_guide_schedule.c_inc b/src/ac_npc_rcn_guide_schedule.c_inc index c8abd00c..dcfd47e2 100644 --- a/src/ac_npc_rcn_guide_schedule.c_inc +++ b/src/ac_npc_rcn_guide_schedule.c_inc @@ -39,7 +39,7 @@ static void aNRG_take_with(NPC_RCN_GUIDE_ACTOR* rcn_guide, GAME_PLAY* play) { static void aNRG_decide_house_wait(NPC_RCN_GUIDE_ACTOR* rcn_guide, GAME_PLAY* play) { int next_think_idx = -1; - if (GET_PLAYER_ACTOR_NOW()->cancel_wade_flag) { + if (GET_PLAYER_ACTOR_NOW()->excute_cancel_wade) { /* Player is trying to leave the acre, so let them know they can't */ next_think_idx = aNRC_THINK_STOP_WADE; } else if (Common_Get(clip).demo_clip != NULL && Common_Get(clip).demo_clip->type == mDemo_CLIP_TYPE_INTRO_DEMO) { @@ -112,7 +112,7 @@ static void aNRG_exit(NPC_RCN_GUIDE_ACTOR* rcn_guide, GAME_PLAY* play) { intro_demo->rcn_guide_actor_p = NULL; Actor_delete(&rcn_guide->npc_class.actor_class); - play->submenu.disable_start_btn_flag = FALSE; + play->submenu.start_refuse = FALSE; } } } else { @@ -177,7 +177,7 @@ static void aNRG_approach_init(NPC_RCN_GUIDE_ACTOR* rcn_guide, GAME_PLAY* play) f32 z; /* Player cannot open the start menu */ - play->submenu.disable_start_btn_flag = TRUE; + play->submenu.start_refuse = TRUE; /* Make the player stand around waiting */ mPlib_request_main_demo_wait_type1(&play->game, 0, NULL); diff --git a/src/ac_tent.c b/src/ac_tent.c index 545219eb..bce9c0eb 100644 --- a/src/ac_tent.c +++ b/src/ac_tent.c @@ -76,7 +76,8 @@ static void aTnt_ChangeFg(ACTOR* actor, int type) { if (mSN_ClearSnowman(name) == 0) { int dug = FALSE; - if ((((*name >= BURIED_PITFALL_START) && (*name <= BURIED_PITFALL_END)) || (*name == SHINE_SPOT))) { + if ((((*name >= BURIED_PITFALL_HOLE_START) && (*name <= BURIED_PITFALL_HOLE_END)) || + (*name == SHINE_SPOT))) { dug = TRUE; } diff --git a/src/bg_item_common.c_inc b/src/bg_item_common.c_inc index c44d58c3..ba6bc6f5 100644 --- a/src/bg_item_common.c_inc +++ b/src/bg_item_common.c_inc @@ -624,7 +624,7 @@ static int bIT_common_bury_after(mActor_name_t fg_bury_item, mActor_name_t fg_ho int hole_no = mCoBG_GetHoleNumber(*bury_pos); if (hole_no != -1) { - *buried_item_p = BURIED_PITFALL_START + hole_no; + *buried_item_p = BURIED_PITFALL_HOLE_START + hole_no; } else { *buried_item_p = EMPTY_NO; } @@ -2907,7 +2907,7 @@ static int bIT_actor_pit_fall(mActor_name_t pit_fg_item, int ut_x, int ut_z, mAc mFI_UtNum2CenterWpos(&pos, ut_x, ut_z); pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(pos, -1.0f); - pitfall_fg_no = pit_fg_item - BURIED_PITFALL_START; + pitfall_fg_no = pit_fg_item - BURIED_PITFALL_HOLE_START; mFI_SetFG_common(pitfall_fg_no + 0x43, pos, FALSE); hole_fg_no = pitfall_fg_no + HOLE_START; bIT_actor_pit_entry(common->pit, 1, hole_fg_no, &pos, fg_item_in_pit); diff --git a/src/c_keyframe.c b/src/c_keyframe.c index a65391f5..e4f27dc5 100644 --- a/src/c_keyframe.c +++ b/src/c_keyframe.c @@ -893,7 +893,7 @@ extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, cKF_Skel s_xyz* applyjoint; if ((info1 == NULL) || (info2 == NULL) || (flag == NULL)) { - return 0; + return cKF_STATE_NONE; } joint = (F32_IS_ZERO(info1->morph_counter)) ? &info1->current_joint->x : &info1->target_joint->x; @@ -930,7 +930,7 @@ extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, cKF_Skel if (info1->morph_counter <= 0.0f) { info1->morph_counter = 0.0f; } - return 0; + return cKF_STATE_NONE; } cKF_SkeletonInfo_R_morphJoint(info1); info1->morph_counter += 0.5f; @@ -1210,25 +1210,25 @@ extern void cKF_SkeletonInfo_R_AnimationMove_base(xyz_t* base, s_xyz* sbase, xyz keyframe->fixed_counter = count; } -extern void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(f32 calcx, f32 calcy, f32 calcz, xyz_t* base, - xyz_t* calcp, s16 val, xyz_t* trans, - cKF_SkeletonInfo_R_c* keyframe, int animation_flag) { +extern void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(xyz_t* calc_pos, const xyz_t* base_pos, f32 trans_x, + f32 trans_y, f32 trans_z, s16 angle_y, const xyz_t* scale, + cKF_SkeletonInfo_R_c* keyframe, int trans_flag) { f32 sin, cos; f32 j_x, j_z; s_xyz* cur_joint = keyframe->current_joint; - if (animation_flag & cKF_ANIMATION_TRANS_XZ) { - j_x = cur_joint->x - calcx; - j_z = cur_joint->z - calcz; + if (trans_flag & cKF_ANIMATION_TRANS_XZ) { + j_x = cur_joint->x - trans_x; + j_z = cur_joint->z - trans_z; - sin = sin_s(val); - cos = cos_s(val); + sin = sin_s(angle_y); + cos = cos_s(angle_y); - base->x = calcp->x + trans->x * ((j_x * cos) + (j_z * sin)); - base->z = calcp->z + trans->z * ((-j_x * sin) + (j_z * cos)); + calc_pos->x = base_pos->x + scale->x * ((j_x * cos) + (j_z * sin)); + calc_pos->z = base_pos->z + scale->z * ((-j_x * sin) + (j_z * cos)); } - if (animation_flag & cKF_ANIMATION_TRANS_Y) { - base->y = calcp->y + trans->y * (cur_joint->y - calcy); + if (trans_flag & cKF_ANIMATION_TRANS_Y) { + calc_pos->y = base_pos->y + scale->y * (cur_joint->y - trans_y); } } diff --git a/src/m_banti.c b/src/m_banti.c index 0929813e..6c8df602 100644 --- a/src/m_banti.c +++ b/src/m_banti.c @@ -17,326 +17,327 @@ extern cKF_Skeleton_R_c cKF_bs_r_clk_hiniti; extern cKF_Skeleton_R_c cKF_bs_r_clk_jikan; extern void banti_ct() { - bzero(&banti, sizeof(Banti_c)); + bzero(&banti, sizeof(Banti_c)); - banti.addressable_type = 0; - banti.disabled = 0; - banti.timer = 0; - banti.alpha = 0.0f; - banti.disp_left = 0; - banti.move_left = 0; - banti.move_timer = 0.0f; + banti.addressable_type = 0; + banti.disabled = 0; + banti.timer = 0; + banti.alpha = 0.0f; + banti.disp_left = 0; + banti.move_left = 0; + banti.move_timer = 0.0f; - cKF_SkeletonInfo_R_ct(&banti.month_anim.keyframe, &cKF_bs_r_clk_hiniti, NULL, banti.month_anim.work, banti.month_anim.morph); - banti_animation_init_hiduke(&banti.month_anim); - banti.month_anim.keyframe.frame_control.speed = 0.0f; + cKF_SkeletonInfo_R_ct(&banti.month_anim.keyframe, &cKF_bs_r_clk_hiniti, NULL, banti.month_anim.work, + banti.month_anim.morph); + banti_animation_init_hiduke(&banti.month_anim); + banti.month_anim.keyframe.frame_control.speed = 0.0f; - cKF_SkeletonInfo_R_ct(&banti.day_anim.keyframe, &cKF_bs_r_clk_hiniti, NULL, banti.day_anim.work, banti.day_anim.morph); - banti_animation_init_hiduke(&banti.day_anim); - banti.day_anim.keyframe.frame_control.speed = 0.0f; + cKF_SkeletonInfo_R_ct(&banti.day_anim.keyframe, &cKF_bs_r_clk_hiniti, NULL, banti.day_anim.work, + banti.day_anim.morph); + banti_animation_init_hiduke(&banti.day_anim); + banti.day_anim.keyframe.frame_control.speed = 0.0f; - cKF_SkeletonInfo_R_ct(&banti.hour_upper_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.hour_upper_anim.work, banti.hour_upper_anim.morph); - banti_animation_init_jikan(&banti.hour_upper_anim); - banti.hour_upper_anim.keyframe.frame_control.speed = 0.0f; + cKF_SkeletonInfo_R_ct(&banti.hour_upper_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.hour_upper_anim.work, + banti.hour_upper_anim.morph); + banti_animation_init_jikan(&banti.hour_upper_anim); + banti.hour_upper_anim.keyframe.frame_control.speed = 0.0f; - cKF_SkeletonInfo_R_ct(&banti.hour_lower_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.hour_lower_anim.work, banti.hour_lower_anim.morph); - banti_animation_init_jikan(&banti.hour_lower_anim); - banti.hour_lower_anim.keyframe.frame_control.speed = 0.0f; + cKF_SkeletonInfo_R_ct(&banti.hour_lower_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.hour_lower_anim.work, + banti.hour_lower_anim.morph); + banti_animation_init_jikan(&banti.hour_lower_anim); + banti.hour_lower_anim.keyframe.frame_control.speed = 0.0f; - cKF_SkeletonInfo_R_ct(&banti.min_upper_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.min_upper_anim.work, banti.min_upper_anim.morph); - banti_animation_init_jikan(&banti.min_upper_anim); - banti.min_upper_anim.keyframe.frame_control.speed = 0.0f; + cKF_SkeletonInfo_R_ct(&banti.min_upper_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.min_upper_anim.work, + banti.min_upper_anim.morph); + banti_animation_init_jikan(&banti.min_upper_anim); + banti.min_upper_anim.keyframe.frame_control.speed = 0.0f; - cKF_SkeletonInfo_R_ct(&banti.min_lower_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.min_lower_anim.work, banti.min_lower_anim.morph); - banti_animation_init_jikan(&banti.min_lower_anim); - banti.min_lower_anim.keyframe.frame_control.speed = 0.0f; + cKF_SkeletonInfo_R_ct(&banti.min_lower_anim.keyframe, &cKF_bs_r_clk_jikan, NULL, banti.min_lower_anim.work, + banti.min_lower_anim.morph); + banti_animation_init_jikan(&banti.min_lower_anim); + banti.min_lower_anim.keyframe.frame_control.speed = 0.0f; - lbRTC_TimeCopy(&banti.next_time, Common_GetPointer(time.rtc_time)); - lbRTC_TimeCopy(&banti.displayed_time, Common_GetPointer(time.rtc_time)); + lbRTC_TimeCopy(&banti.next_time, Common_GetPointer(time.rtc_time)); + lbRTC_TimeCopy(&banti.displayed_time, Common_GetPointer(time.rtc_time)); } extern void banti_dt() { - cKF_SkeletonInfo_R_dt(&banti.month_anim.keyframe); - cKF_SkeletonInfo_R_dt(&banti.day_anim.keyframe); - cKF_SkeletonInfo_R_dt(&banti.hour_upper_anim.keyframe); - cKF_SkeletonInfo_R_dt(&banti.hour_lower_anim.keyframe); - cKF_SkeletonInfo_R_dt(&banti.min_upper_anim.keyframe); - cKF_SkeletonInfo_R_dt(&banti.min_lower_anim.keyframe); + cKF_SkeletonInfo_R_dt(&banti.month_anim.keyframe); + cKF_SkeletonInfo_R_dt(&banti.day_anim.keyframe); + cKF_SkeletonInfo_R_dt(&banti.hour_upper_anim.keyframe); + cKF_SkeletonInfo_R_dt(&banti.hour_lower_anim.keyframe); + cKF_SkeletonInfo_R_dt(&banti.min_upper_anim.keyframe); + cKF_SkeletonInfo_R_dt(&banti.min_lower_anim.keyframe); } static void banti_chk_disp_left(GAME_PLAY* play) { - xyz_t player_pos_screen; + xyz_t player_pos_screen; - Game_play_Projection_Trans(play, &get_player_actor_withoutCheck(play)->actor_class.world.position, &player_pos_screen); + Game_play_Projection_Trans(play, &get_player_actor_withoutCheck(play)->actor_class.world.position, + &player_pos_screen); - if (player_pos_screen.x >= 180.0f && player_pos_screen.y >= 150.0f) { - if (banti.move_left == FALSE) { - banti.move_left = TRUE; - banti.move_timer = 0.0f; + if (player_pos_screen.x >= 180.0f && player_pos_screen.y >= 150.0f) { + if (banti.move_left == FALSE) { + banti.move_left = TRUE; + banti.move_timer = 0.0f; + } + + banti.move_timer += 1.0f; + + if (banti.move_timer > 10.0f) { + banti.move_timer = 10.0f; + + if (banti.alpha < 0.01f) { + banti.disp_left = TRUE; + banti.disabled = FALSE; + } else if (banti.disp_left == FALSE) { + banti.disabled = TRUE; + } + } + } else { + if (banti.move_left == TRUE) { + banti.move_left = FALSE; + banti.move_timer = 0.0f; + } + + banti.move_timer += 1.0f; + + if (banti.move_timer > 10.0f) { + banti.move_timer = 10.0f; + + if (banti.alpha < 0.01f) { + banti.disp_left = FALSE; + banti.disabled = FALSE; + } else if (banti.disp_left == TRUE) { + banti.disabled = TRUE; + } + } } - - banti.move_timer += 1.0f; - - if (banti.move_timer > 10.0f) { - banti.move_timer = 10.0f; - - if (banti.alpha < 0.01f) { - banti.disp_left = TRUE; - banti.disabled = FALSE; - } - else if (banti.disp_left == FALSE) { - banti.disabled = TRUE; - } - } - } - else { - if (banti.move_left == TRUE) { - banti.move_left = FALSE; - banti.move_timer = 0.0f; - } - - banti.move_timer += 1.0f; - - if (banti.move_timer > 10.0f) { - banti.move_timer = 10.0f; - - if (banti.alpha < 0.01f) { - banti.disp_left = FALSE; - banti.disabled = FALSE; - } - else if (banti.disp_left == TRUE) { - banti.disabled = TRUE; - } - } - } } static f32 banti_calc_disp_alpha_rate(GAME_PLAY* play) { - if (mDemo_CheckDemo() || mEv_CheckTitleDemo() > 0 || banti.disabled) { - banti.addressable_type = mPlayer_ADDRESSABLE_FALSE_MOVEMENT; - add_calc(&banti.alpha, 0.0f, 1.0f - sqrtf(0.8), 0.1f, 0.005f); /* quickly fade out on demo screen or title or force disabled */ - } - else if (banti.addressable_type == mPlayer_ADDRESSABLE_TRUE && play->submenu.process_status == mSM_PROCESS_WAIT) { - add_calc(&banti.alpha, 1.0f, 1.0f - sqrtf(0.8), 0.0425f, 0.0005f); /* fade in */ - } - else { - add_calc(&banti.alpha, 0.0f, 1.0f - sqrtf(0.8), 0.0425f, 0.0005f); /* fade out */ - } + if (mDemo_CheckDemo() || mEv_CheckTitleDemo() > 0 || banti.disabled) { + banti.addressable_type = mPlayer_ADDRESSABLE_FALSE_MOVEMENT; + add_calc(&banti.alpha, 0.0f, 1.0f - sqrtf(0.8), 0.1f, + 0.005f); /* quickly fade out on demo screen or title or force disabled */ + } else if (banti.addressable_type == mPlayer_ADDRESSABLE_TRUE && play->submenu.process_status == mSM_PROCESS_WAIT) { + add_calc(&banti.alpha, 1.0f, 1.0f - sqrtf(0.8), 0.0425f, 0.0005f); /* fade in */ + } else { + add_calc(&banti.alpha, 0.0f, 1.0f - sqrtf(0.8), 0.0425f, 0.0005f); /* fade out */ + } } extern cKF_Animation_R_c cKF_ba_r_clk_hiniti; static void banti_animation_init_hiduke(Banti_anim_c* anim) { - cKF_SkeletonInfo_R_init(&anim->keyframe, anim->keyframe.skeleton, &cKF_ba_r_clk_hiniti, 1.0f, 15.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_STOP, NULL); + cKF_SkeletonInfo_R_init(&anim->keyframe, anim->keyframe.skeleton, &cKF_ba_r_clk_hiniti, 1.0f, 15.0f, 1.0f, 0.5f, + 0.0f, cKF_FRAMECONTROL_STOP, NULL); } extern cKF_Animation_R_c cKF_ba_r_clk_jikan; static void banti_animation_init_jikan(Banti_anim_c* anim) { - cKF_SkeletonInfo_R_init(&anim->keyframe, anim->keyframe.skeleton, &cKF_ba_r_clk_jikan, 1.0f, 15.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_STOP, NULL); + cKF_SkeletonInfo_R_init(&anim->keyframe, anim->keyframe.skeleton, &cKF_ba_r_clk_jikan, 1.0f, 15.0f, 1.0f, 0.5f, + 0.0f, cKF_FRAMECONTROL_STOP, NULL); } static void banti_anime_proc() { - if (cKF_SkeletonInfo_R_play(&banti.month_anim.keyframe) == cKF_STATE_STOPPED) { - banti.month_anim.keyframe.frame_control.current_frame = 1.0f; - banti.month_anim.keyframe.frame_control.speed = 0.0f; - banti.month_anim.state = banti_ANIM_STATE_STOPPED; - } + if (cKF_SkeletonInfo_R_play(&banti.month_anim.keyframe) == cKF_STATE_STOPPED) { + banti.month_anim.keyframe.frame_control.current_frame = 1.0f; + banti.month_anim.keyframe.frame_control.speed = 0.0f; + banti.month_anim.state = banti_ANIM_STATE_STOPPED; + } - if (cKF_SkeletonInfo_R_play(&banti.day_anim.keyframe) == cKF_STATE_STOPPED) { - banti.day_anim.keyframe.frame_control.current_frame = 1.0f; - banti.day_anim.keyframe.frame_control.speed = 0.0f; - banti.day_anim.state = banti_ANIM_STATE_STOPPED; - } + if (cKF_SkeletonInfo_R_play(&banti.day_anim.keyframe) == cKF_STATE_STOPPED) { + banti.day_anim.keyframe.frame_control.current_frame = 1.0f; + banti.day_anim.keyframe.frame_control.speed = 0.0f; + banti.day_anim.state = banti_ANIM_STATE_STOPPED; + } - if (cKF_SkeletonInfo_R_play(&banti.hour_upper_anim.keyframe) == cKF_STATE_STOPPED) { - banti.hour_upper_anim.keyframe.frame_control.current_frame = 1.0f; - banti.hour_upper_anim.keyframe.frame_control.speed = 0.0f; - banti.hour_upper_anim.state = banti_ANIM_STATE_STOPPED; - } + if (cKF_SkeletonInfo_R_play(&banti.hour_upper_anim.keyframe) == cKF_STATE_STOPPED) { + banti.hour_upper_anim.keyframe.frame_control.current_frame = 1.0f; + banti.hour_upper_anim.keyframe.frame_control.speed = 0.0f; + banti.hour_upper_anim.state = banti_ANIM_STATE_STOPPED; + } - if (cKF_SkeletonInfo_R_play(&banti.hour_lower_anim.keyframe) == cKF_STATE_STOPPED) { - banti.hour_lower_anim.keyframe.frame_control.current_frame = 1.0f; - banti.hour_lower_anim.keyframe.frame_control.speed = 0.0f; - banti.hour_lower_anim.state = banti_ANIM_STATE_STOPPED; - } + if (cKF_SkeletonInfo_R_play(&banti.hour_lower_anim.keyframe) == cKF_STATE_STOPPED) { + banti.hour_lower_anim.keyframe.frame_control.current_frame = 1.0f; + banti.hour_lower_anim.keyframe.frame_control.speed = 0.0f; + banti.hour_lower_anim.state = banti_ANIM_STATE_STOPPED; + } - if (cKF_SkeletonInfo_R_play(&banti.min_upper_anim.keyframe) == cKF_STATE_STOPPED) { - banti.min_upper_anim.keyframe.frame_control.current_frame = 1.0f; - banti.min_upper_anim.keyframe.frame_control.speed = 0.0f; - banti.min_upper_anim.state = banti_ANIM_STATE_STOPPED; - } + if (cKF_SkeletonInfo_R_play(&banti.min_upper_anim.keyframe) == cKF_STATE_STOPPED) { + banti.min_upper_anim.keyframe.frame_control.current_frame = 1.0f; + banti.min_upper_anim.keyframe.frame_control.speed = 0.0f; + banti.min_upper_anim.state = banti_ANIM_STATE_STOPPED; + } - if (cKF_SkeletonInfo_R_play(&banti.min_lower_anim.keyframe) == cKF_STATE_STOPPED) { - banti.min_lower_anim.keyframe.frame_control.current_frame = 1.0f; - banti.min_lower_anim.keyframe.frame_control.speed = 0.0f; - banti.min_lower_anim.state = banti_ANIM_STATE_STOPPED; - } + if (cKF_SkeletonInfo_R_play(&banti.min_lower_anim.keyframe) == cKF_STATE_STOPPED) { + banti.min_lower_anim.keyframe.frame_control.current_frame = 1.0f; + banti.min_lower_anim.keyframe.frame_control.speed = 0.0f; + banti.min_lower_anim.state = banti_ANIM_STATE_STOPPED; + } } static void banti_chk_anime_start() { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - u8 banti_hour; - u8 rtc_hour; - u8 banti_min; - u8 rtc_min; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + u8 banti_hour; + u8 rtc_hour; + u8 banti_min; + u8 rtc_min; - int work1; - int work0; - int disp0; - int disp1; + int work1; + int work0; + int disp0; + int disp1; - if (banti.month_anim.state == banti_ANIM_STATE_STOPPED && banti.displayed_time.month != Common_GetPointer(time.rtc_time)->month) { - banti_animation_init_hiduke(&banti.month_anim); - banti.month_anim.state = banti_ANIM_STATE_PLAYING; - } + if (banti.month_anim.state == banti_ANIM_STATE_STOPPED && + banti.displayed_time.month != Common_GetPointer(time.rtc_time)->month) { + banti_animation_init_hiduke(&banti.month_anim); + banti.month_anim.state = banti_ANIM_STATE_PLAYING; + } - if (banti.day_anim.state == banti_ANIM_STATE_STOPPED && banti.displayed_time.day != Common_GetPointer(time.rtc_time)->day) { - banti_animation_init_hiduke(&banti.day_anim); - banti.day_anim.state = banti_ANIM_STATE_PLAYING; - } + if (banti.day_anim.state == banti_ANIM_STATE_STOPPED && + banti.displayed_time.day != Common_GetPointer(time.rtc_time)->day) { + banti_animation_init_hiduke(&banti.day_anim); + banti.day_anim.state = banti_ANIM_STATE_PLAYING; + } - banti_hour = banti.displayed_time.hour; - if (banti_hour == 0 || banti_hour == 12) { - work0 = 12; - } - else if (banti_hour > 11) { - work0 = banti_hour - 12; - } - else { - work0 = banti_hour; - } + banti_hour = banti.displayed_time.hour; + if (banti_hour == 0 || banti_hour == 12) { + work0 = 12; + } else if (banti_hour > 11) { + work0 = banti_hour - 12; + } else { + work0 = banti_hour; + } - rtc_hour = Common_GetPointer(time.rtc_time)->hour; - if (rtc_hour == 0 || rtc_hour == 12) { - work1 = 12; - } - else if (rtc_hour > 11) { - work1 = rtc_hour - 12; - } - else { - work1 = rtc_hour; - } + rtc_hour = Common_GetPointer(time.rtc_time)->hour; + if (rtc_hour == 0 || rtc_hour == 12) { + work1 = 12; + } else if (rtc_hour > 11) { + work1 = rtc_hour - 12; + } else { + work1 = rtc_hour; + } - disp0 = work0 / 10; - disp1 = work1 / 10; - if (banti.hour_upper_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { - banti_animation_init_jikan(&banti.hour_upper_anim); - banti.hour_upper_anim.state = banti_ANIM_STATE_PLAYING; - } + disp0 = work0 / 10; + disp1 = work1 / 10; + if (banti.hour_upper_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { + banti_animation_init_jikan(&banti.hour_upper_anim); + banti.hour_upper_anim.state = banti_ANIM_STATE_PLAYING; + } - disp0 = work0 % 10; - disp1 = work1 % 10; - if (banti.hour_lower_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { - banti_animation_init_jikan(&banti.hour_lower_anim); - banti.hour_lower_anim.state = banti_ANIM_STATE_PLAYING; - } + disp0 = work0 % 10; + disp1 = work1 % 10; + if (banti.hour_lower_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { + banti_animation_init_jikan(&banti.hour_lower_anim); + banti.hour_lower_anim.state = banti_ANIM_STATE_PLAYING; + } - disp0 = banti.displayed_time.min / 10; - disp1 = Common_GetPointer(time.rtc_time)->min / 10; - if (banti.min_upper_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { - banti_animation_init_jikan(&banti.min_upper_anim); - banti.min_upper_anim.state = banti_ANIM_STATE_PLAYING; - } + disp0 = banti.displayed_time.min / 10; + disp1 = Common_GetPointer(time.rtc_time)->min / 10; + if (banti.min_upper_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { + banti_animation_init_jikan(&banti.min_upper_anim); + banti.min_upper_anim.state = banti_ANIM_STATE_PLAYING; + } - disp0 = banti.displayed_time.min % 10; - disp1 = Common_GetPointer(time.rtc_time)->min % 10; - if (banti.min_lower_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { - banti_animation_init_jikan(&banti.min_lower_anim); - banti.min_lower_anim.state = banti_ANIM_STATE_PLAYING; - } + disp0 = banti.displayed_time.min % 10; + disp1 = Common_GetPointer(time.rtc_time)->min % 10; + if (banti.min_lower_anim.state == banti_ANIM_STATE_STOPPED && disp0 != disp1) { + banti_animation_init_jikan(&banti.min_lower_anim); + banti.min_lower_anim.state = banti_ANIM_STATE_PLAYING; + } } static void banti_time_check() { - int pre_state; - int post_state; + int pre_state; + int post_state; - pre_state = banti.month_anim.state | banti.day_anim.state | banti.hour_upper_anim.state | banti.hour_lower_anim.state | banti.min_upper_anim.state | banti.min_lower_anim.state; + pre_state = banti.month_anim.state | banti.day_anim.state | banti.hour_upper_anim.state | + banti.hour_lower_anim.state | banti.min_upper_anim.state | banti.min_lower_anim.state; - if (pre_state == banti_ANIM_STATE_STOPPED) { - banti_chk_anime_start(); - } - - banti_anime_proc(); - - post_state = banti.month_anim.state | banti.day_anim.state | banti.hour_upper_anim.state | banti.hour_lower_anim.state | banti.min_upper_anim.state | banti.min_lower_anim.state; - - if (pre_state != post_state) { if (pre_state == banti_ANIM_STATE_STOPPED) { - lbRTC_TimeCopy(&banti.next_time, Common_GetPointer(time.rtc_time)); + banti_chk_anime_start(); } - else { - lbRTC_TimeCopy(&banti.displayed_time, &banti.next_time); + + banti_anime_proc(); + + post_state = banti.month_anim.state | banti.day_anim.state | banti.hour_upper_anim.state | + banti.hour_lower_anim.state | banti.min_upper_anim.state | banti.min_lower_anim.state; + + if (pre_state != post_state) { + if (pre_state == banti_ANIM_STATE_STOPPED) { + lbRTC_TimeCopy(&banti.next_time, Common_GetPointer(time.rtc_time)); + } else { + lbRTC_TimeCopy(&banti.displayed_time, &banti.next_time); + } } - } } extern void banti_move(GAME_PLAY* play) { - int addressable_type; - int update; + int addressable_type; + int update; - banti_chk_disp_left(play); + banti_chk_disp_left(play); - addressable_type = mPlib_Get_address_able_display(); + addressable_type = mPlib_Get_address_able_display(); - if (banti.addressable_type != addressable_type) { - update = FALSE; - banti.timer++; + if (banti.addressable_type != addressable_type) { + update = FALSE; + banti.timer++; - if (addressable_type == mPlayer_ADDRESSABLE_FALSE_USING_TOOL) { - if (banti.timer > 50) { - update = TRUE; - } - } - else if (banti.addressable_type != mPlayer_ADDRESSABLE_TRUE) { - if (banti.timer > 30 || addressable_type == mPlayer_ADDRESSABLE_FALSE_TALKING) { - update = TRUE; - } - } - else if (banti.timer > 50 || addressable_type == mPlayer_ADDRESSABLE_FALSE_TALKING) { - update = TRUE; + if (addressable_type == mPlayer_ADDRESSABLE_FALSE_READY_NET) { + if (banti.timer > 50) { + update = TRUE; + } + } else if (banti.addressable_type != mPlayer_ADDRESSABLE_TRUE) { + if (banti.timer > 30 || addressable_type == mPlayer_ADDRESSABLE_FALSE_TALKING) { + update = TRUE; + } + } else if (banti.timer > 50 || addressable_type == mPlayer_ADDRESSABLE_FALSE_TALKING) { + update = TRUE; + } + + if (update == TRUE) { + banti.timer = 0; + banti.addressable_type = addressable_type; + } + } else { + banti.timer = 0; } - if (update == TRUE) { - banti.timer = 0; - banti.addressable_type = addressable_type; - } - } - else { - banti.timer = 0; - } - - banti_calc_disp_alpha_rate(play); - banti_time_check(); + banti_calc_disp_alpha_rate(play); + banti_time_check(); } -static int banti_draw_before(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) { - Gfx** gfx_pp; - Mtx* mtx; - Banti_callback_c* callback_data = (Banti_callback_c*)arg; +static int banti_draw_before(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) { + Gfx** gfx_pp; + Mtx* mtx; + Banti_callback_c* callback_data = (Banti_callback_c*)arg; - gfx_pp = callback_data->gfx_pp; - mtx = callback_data->mtx; + gfx_pp = callback_data->gfx_pp; + mtx = callback_data->mtx; - Matrix_softcv3_mult(joint_pos, joint_rot); - if (*joint_shape != NULL) { - _Matrix_to_Mtx(mtx); + Matrix_softcv3_mult(joint_pos, joint_rot); + if (*joint_shape != NULL) { + _Matrix_to_Mtx(mtx); - gSPMatrix(gfx_pp[0]++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx_pp[0]++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (callback_data->state == banti_ANIM_STATE_STOPPED) { - if (joint_idx != 2) { - gSPDisplayList(gfx_pp[0]++, *joint_shape); - } - } - else { - gSPDisplayList(gfx_pp[0]++, *joint_shape); + if (callback_data->state == banti_ANIM_STATE_STOPPED) { + if (joint_idx != 2) { + gSPDisplayList(gfx_pp[0]++, *joint_shape); + } + } else { + gSPDisplayList(gfx_pp[0]++, *joint_shape); + } + + callback_data->mtx++; } - callback_data->mtx++; - } - - return 0; + return 0; } extern u8 clk_win_suuji1_TA_tex_txt[]; @@ -371,81 +372,57 @@ extern u8 clk_win_suuji29_TA_tex_txt[]; extern u8 clk_win_suuji30_TA_tex_txt[]; extern u8 clk_win_suuji31_TA_tex_txt[]; -static void banti_draw_hiduke_sub(Gfx** gfx_pp, GAME* game, Banti_anim_c* anim, int tex0_idx, int tex1_idx, int pos_idx) { - static u8* hiniti_tex_table[31] = { - clk_win_suuji1_TA_tex_txt, - clk_win_suuji2_TA_tex_txt, - clk_win_suuji3_TA_tex_txt, - clk_win_suuji4_TA_tex_txt, - clk_win_suuji5_TA_tex_txt, - clk_win_suuji6_TA_tex_txt, - clk_win_suuji7_TA_tex_txt, - clk_win_suuji8_TA_tex_txt, - clk_win_suuji9_TA_tex_txt, - clk_win_suuji10_TA_tex_txt, - clk_win_suuji11_TA_tex_txt, - clk_win_suuji12_TA_tex_txt, - clk_win_suuji13_TA_tex_txt, - clk_win_suuji14_TA_tex_txt, - clk_win_suuji15_TA_tex_txt, - clk_win_suuji16_TA_tex_txt, - clk_win_suuji17_TA_tex_txt, - clk_win_suuji18_TA_tex_txt, - clk_win_suuji19_TA_tex_txt, - clk_win_suuji20_TA_tex_txt, - clk_win_suuji21_TA_tex_txt, - clk_win_suuji22_TA_tex_txt, - clk_win_suuji23_TA_tex_txt, - clk_win_suuji24_TA_tex_txt, - clk_win_suuji25_TA_tex_txt, - clk_win_suuji26_TA_tex_txt, - clk_win_suuji27_TA_tex_txt, - clk_win_suuji28_TA_tex_txt, - clk_win_suuji29_TA_tex_txt, - clk_win_suuji30_TA_tex_txt, - clk_win_suuji31_TA_tex_txt - }; +static void banti_draw_hiduke_sub(Gfx** gfx_pp, GAME* game, Banti_anim_c* anim, int tex0_idx, int tex1_idx, + int pos_idx) { + static u8* hiniti_tex_table[31] = { + clk_win_suuji1_TA_tex_txt, clk_win_suuji2_TA_tex_txt, clk_win_suuji3_TA_tex_txt, clk_win_suuji4_TA_tex_txt, + clk_win_suuji5_TA_tex_txt, clk_win_suuji6_TA_tex_txt, clk_win_suuji7_TA_tex_txt, clk_win_suuji8_TA_tex_txt, + clk_win_suuji9_TA_tex_txt, clk_win_suuji10_TA_tex_txt, clk_win_suuji11_TA_tex_txt, clk_win_suuji12_TA_tex_txt, + clk_win_suuji13_TA_tex_txt, clk_win_suuji14_TA_tex_txt, clk_win_suuji15_TA_tex_txt, clk_win_suuji16_TA_tex_txt, + clk_win_suuji17_TA_tex_txt, clk_win_suuji18_TA_tex_txt, clk_win_suuji19_TA_tex_txt, clk_win_suuji20_TA_tex_txt, + clk_win_suuji21_TA_tex_txt, clk_win_suuji22_TA_tex_txt, clk_win_suuji23_TA_tex_txt, clk_win_suuji24_TA_tex_txt, + clk_win_suuji25_TA_tex_txt, clk_win_suuji26_TA_tex_txt, clk_win_suuji27_TA_tex_txt, clk_win_suuji28_TA_tex_txt, + clk_win_suuji29_TA_tex_txt, clk_win_suuji30_TA_tex_txt, clk_win_suuji31_TA_tex_txt + }; - static xyz_t set_pos_table[2] = { - { 64.0f, -70.0f, 0.0f }, - { 94.0f, -70.0f, 0.0f } - }; + static xyz_t set_pos_table[2] = { { 64.0f, -70.0f, 0.0f }, { 94.0f, -70.0f, 0.0f } }; - GRAPH* g = game->graph; - xyz_t* set_pos = &set_pos_table[pos_idx]; - Mtx* m; - int joint; - Banti_callback_c callback_data; + GRAPH* g = game->graph; + xyz_t* set_pos = &set_pos_table[pos_idx]; + Mtx* m; + int joint; + Banti_callback_c callback_data; - Matrix_push(); - Matrix_translate(set_pos->x, set_pos->y, set_pos->z, 1); + Matrix_push(); + Matrix_translate(set_pos->x, set_pos->y, set_pos->z, 1); - m = (Mtx*)GRAPH_ALLOC_TYPE(g, Mtx, anim->keyframe.skeleton->num_shown_joints); - callback_data.mtx = m; + m = (Mtx*)GRAPH_ALLOC_TYPE(g, Mtx, anim->keyframe.skeleton->num_shown_joints); + callback_data.mtx = m; - if (m != NULL) { - joint = 0; - callback_data.gfx_pp = gfx_pp; - callback_data.state = anim->state; + if (m != NULL) { + joint = 0; + callback_data.gfx_pp = gfx_pp; + callback_data.state = anim->state; - gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_8, hiniti_tex_table[tex0_idx]); - gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_9, hiniti_tex_table[tex1_idx]); + gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_8, hiniti_tex_table[tex0_idx]); + gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_9, hiniti_tex_table[tex1_idx]); + cKF_Si3_draw_SV_R_child(game, &anim->keyframe, &joint, &banti_draw_before, NULL, &callback_data, NULL); + } - cKF_Si3_draw_SV_R_child(game, &anim->keyframe, &joint, &banti_draw_before, NULL, &callback_data, NULL); - } - - Matrix_pull(); + Matrix_pull(); } static void banti_draw_hiduke(Gfx** gfx_pp, GAME_PLAY* play, int alpha) { - u8 a = alpha; + u8 a = alpha; - gDPSetPrimColor(gfx_pp[0]++, 0, a, 235, 255, 120, a); - gDPSetEnvColor(gfx_pp[0]++, 80, 40, 40, a); + gDPSetPrimColor(gfx_pp[0]++, 0, a, 235, 255, 120, a); + gDPSetEnvColor(gfx_pp[0]++, 80, 40, 40, a); - banti_draw_hiduke_sub(gfx_pp, (GAME*)play, &banti.month_anim, banti.displayed_time.month - 1, banti.next_time.month - 1, 0); - banti_draw_hiduke_sub(gfx_pp, (GAME*)play, &banti.day_anim, banti.displayed_time.day - 1, banti.next_time.day - 1, 1); + banti_draw_hiduke_sub(gfx_pp, (GAME*)play, &banti.month_anim, banti.displayed_time.month - 1, + banti.next_time.month - 1, 0); + banti_draw_hiduke_sub(gfx_pp, (GAME*)play, &banti.day_anim, banti.displayed_time.day - 1, banti.next_time.day - 1, + 1); } extern u8 clk_win_jikan0_TA_tex_txt[]; @@ -460,94 +437,82 @@ extern u8 clk_win_jikan8_TA_tex_txt[]; extern u8 clk_win_jikan9_TA_tex_txt[]; extern u8 clk_win_jikan_TA_tex_txt[]; -static void banti_draw_jikan_sub(Gfx** gfx_pp, GAME* game, Banti_anim_c* anim, int idx0, int idx1, int hide_zero, int pos_idx) { - static u8* jikan_tex_table[11] = { - clk_win_jikan0_TA_tex_txt, - clk_win_jikan1_TA_tex_txt, - clk_win_jikan2_TA_tex_txt, - clk_win_jikan3_TA_tex_txt, - clk_win_jikan4_TA_tex_txt, - clk_win_jikan5_TA_tex_txt, - clk_win_jikan6_TA_tex_txt, - clk_win_jikan7_TA_tex_txt, - clk_win_jikan8_TA_tex_txt, - clk_win_jikan9_TA_tex_txt, - clk_win_jikan_TA_tex_txt - }; +static void banti_draw_jikan_sub(Gfx** gfx_pp, GAME* game, Banti_anim_c* anim, int idx0, int idx1, int hide_zero, + int pos_idx) { + static u8* jikan_tex_table[11] = { clk_win_jikan0_TA_tex_txt, clk_win_jikan1_TA_tex_txt, clk_win_jikan2_TA_tex_txt, + clk_win_jikan3_TA_tex_txt, clk_win_jikan4_TA_tex_txt, clk_win_jikan5_TA_tex_txt, + clk_win_jikan6_TA_tex_txt, clk_win_jikan7_TA_tex_txt, clk_win_jikan8_TA_tex_txt, + clk_win_jikan9_TA_tex_txt, clk_win_jikan_TA_tex_txt }; - static xyz_t set_pos_table[4] = { - { 60.0f, -91.0f, 0.0f }, - { 76.0f, -91.0f, 0.0f }, - { 98.0f, -91.0f, 0.0f }, - { 113.0f, -91.0f, 0.0f } - }; + static xyz_t set_pos_table[4] = { + { 60.0f, -91.0f, 0.0f }, { 76.0f, -91.0f, 0.0f }, { 98.0f, -91.0f, 0.0f }, { 113.0f, -91.0f, 0.0f } + }; - GRAPH* g = game->graph; - xyz_t* set_pos = &set_pos_table[pos_idx]; - Mtx* m; - int joint; - Banti_callback_c callback_data; + GRAPH* g = game->graph; + xyz_t* set_pos = &set_pos_table[pos_idx]; + Mtx* m; + int joint; + Banti_callback_c callback_data; - Matrix_push(); - Matrix_translate(set_pos->x, set_pos->y, set_pos->z, 1); + Matrix_push(); + Matrix_translate(set_pos->x, set_pos->y, set_pos->z, 1); - if (hide_zero == TRUE) { - if (idx0 == 0) { - idx0 = 10; + if (hide_zero == TRUE) { + if (idx0 == 0) { + idx0 = 10; + } + + if (idx1 == 0) { + idx1 = 10; + } } - if (idx1 == 0) { - idx1 = 10; + m = (Mtx*)GRAPH_ALLOC_TYPE(g, Mtx, anim->keyframe.skeleton->num_shown_joints); + callback_data.mtx = m; + + if (m != NULL) { + joint = 0; + callback_data.gfx_pp = gfx_pp; + callback_data.state = anim->state; + + gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_8, jikan_tex_table[idx0]); + gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_9, jikan_tex_table[idx1]); + + cKF_Si3_draw_SV_R_child(game, &anim->keyframe, &joint, &banti_draw_before, NULL, &callback_data, NULL); } - } - m = (Mtx*)GRAPH_ALLOC_TYPE(g, Mtx, anim->keyframe.skeleton->num_shown_joints); - callback_data.mtx = m; - - if (m != NULL) { - joint = 0; - callback_data.gfx_pp = gfx_pp; - callback_data.state = anim->state; - - gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_8, jikan_tex_table[idx0]); - gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_9, jikan_tex_table[idx1]); - - - cKF_Si3_draw_SV_R_child(game, &anim->keyframe, &joint, &banti_draw_before, NULL, &callback_data, NULL); - } - - Matrix_pull(); + Matrix_pull(); } static void banti_draw_jikan(Gfx** gfx_pp, GAME_PLAY* play, int alpha) { - u8 a = alpha; - int now_hour; - int next_hour; + u8 a = alpha; + int now_hour; + int next_hour; - gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 255, a); - gDPSetEnvColor(gfx_pp[0]++, 60, 25, 10, a); + gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 255, a); + gDPSetEnvColor(gfx_pp[0]++, 60, 25, 10, a); - now_hour = banti.displayed_time.hour; - if (now_hour == 0 || now_hour == 12) { - now_hour = 12; - } - else if (now_hour > 11) { - now_hour -= 12; - } + now_hour = banti.displayed_time.hour; + if (now_hour == 0 || now_hour == 12) { + now_hour = 12; + } else if (now_hour > 11) { + now_hour -= 12; + } - next_hour = banti.next_time.hour; - if (next_hour == 0 || next_hour == 12) { - next_hour = 12; - } - else if (next_hour > 11) { - next_hour -= 12; - } + next_hour = banti.next_time.hour; + if (next_hour == 0 || next_hour == 12) { + next_hour = 12; + } else if (next_hour > 11) { + next_hour -= 12; + } - banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.hour_upper_anim, now_hour / 10, next_hour / 10, TRUE, 0); - banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.hour_lower_anim, now_hour % 10, next_hour % 10, FALSE, 1); + banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.hour_upper_anim, now_hour / 10, next_hour / 10, TRUE, 0); + banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.hour_lower_anim, now_hour % 10, next_hour % 10, FALSE, 1); - banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.min_upper_anim, banti.displayed_time.min / 10, banti.next_time.min / 10, FALSE, 2); - banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.min_lower_anim, banti.displayed_time.min % 10, banti.next_time.min % 10, FALSE, 3); + banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.min_upper_anim, banti.displayed_time.min / 10, + banti.next_time.min / 10, FALSE, 2); + banti_draw_jikan_sub(gfx_pp, (GAME*)play, &banti.min_lower_anim, banti.displayed_time.min % 10, + banti.next_time.min % 10, FALSE, 3); } extern u8 clk_win_pm_tex_rgb_ia8[]; @@ -569,124 +534,112 @@ extern Gfx clk_win_maru2T_model[]; extern Gfx clk_win_ampmT_model[]; extern void banti_draw(GAME_PLAY* play) { - static u8* week_tex_table[lbRTC_WEEK] = { - clk_win_sun_tex_rgb_ia8, - clk_win_mon_tex_rgb_ia8, - clk_win_tue_tex_rgb_ia8, - clk_win_wed_tex_rgb_ia8, - clk_win_thu_tex_rgb_ia8, - clk_win_fri_tex_rgb_ia8, - clk_win_sat_tex_rgb_ia8 - }; + static u8* week_tex_table[lbRTC_WEEK] = { clk_win_sun_tex_rgb_ia8, clk_win_mon_tex_rgb_ia8, clk_win_tue_tex_rgb_ia8, + clk_win_wed_tex_rgb_ia8, clk_win_thu_tex_rgb_ia8, clk_win_fri_tex_rgb_ia8, + clk_win_sat_tex_rgb_ia8 }; - if (mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELDTYPE_FG && mEv_CheckFirstIntro() != TRUE && banti.alpha > 0.01f) { - GRAPH* g = play->game.graph; - int poly_render = FALSE; - Mtx* m = (Mtx*)GRAPH_ALLOC_TYPE(g, Mtx, 1); + if (mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELDTYPE_FG && mEv_CheckFirstIntro() != TRUE && banti.alpha > 0.01f) { + GRAPH* g = play->game.graph; + int poly_render = FALSE; + Mtx* m = (Mtx*)GRAPH_ALLOC_TYPE(g, Mtx, 1); - /* TODO: submenu mode enums */ - if (play->submenu.process_status != mSM_PROCESS_WAIT && play->submenu.mode > 2) { - poly_render = TRUE; + /* TODO: submenu mode enums */ + if (play->submenu.process_status != mSM_PROCESS_WAIT && play->submenu.mode > 2) { + poly_render = TRUE; + } + + OPEN_DISP(g); + + if (m != NULL) { + mFont_CulcOrthoMatrix(m); + + if (poly_render == TRUE) { + gSPMatrix(NOW_POLY_OPA_DISP++, m, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + } else { + gSPMatrix(NOW_FONT_DISP++, m, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + } + } + + Matrix_scale(16.0f, 16.0f, 16.0f, 0); + + if (banti.disp_left == TRUE) { + Matrix_translate(-184.0f, 0.0f, 0.0f, 1); + } + + { + Gfx** gfx_pp; + u8* am_pm_tex = banti.displayed_time.hour < 12 ? clk_win_am_tex_rgb_ia8 : clk_win_pm_tex_rgb_ia8; + int alpha; + u8 a; + Gfx* gfx; + u32 rendermode0; + u32 rendermode1; + + if (poly_render == TRUE) { + gfx = NOW_POLY_OPA_DISP; + } else { + gfx = NOW_FONT_DISP; + } + + gfx_pp = &gfx; + + gSPMatrix(gfx_pp[0]++, _Matrix_to_Mtx_new(g), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + alpha = banti.alpha * 255.0f; + if (banti.alpha >= 0.4f) { + rendermode0 = G_RM_PASS; + rendermode1 = G_RM_XLU_SURF2; + } else { + rendermode0 = G_RM_PASS; + rendermode1 = G_RM_CLD_SURF2; + } + + gSPDisplayList(gfx_pp[0]++, clk_win_mode); + gDPSetRenderMode(gfx_pp[0]++, rendermode0, rendermode1); + + if (banti.displayed_time.weekday == lbRTC_SUNDAY) { + u8 a = alpha; + + gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 225, a); + gDPSetEnvColor(gfx_pp[0]++, 165, 30, 30, a); + } else { + u8 a = alpha; + + gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 225, a); + gDPSetEnvColor(gfx_pp[0]++, 80, 40, 0, a); + } + + gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_9, week_tex_table[banti.displayed_time.weekday]); + gSPDisplayList(gfx_pp[0]++, clk_win_youbiT_model); + + if ((Common_Get(time.rtc_time).sec & 1) == 1) { + u8 a = alpha; + + gDPSetPrimColor(gfx_pp[0]++, 0, a, 215, 120, 0, a); + gDPSetEnvColor(gfx_pp[0]++, 70, 50, 50, a); + gSPDisplayList(gfx_pp[0]++, clk_win_maru2T_model); + } + + a = alpha; + gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 120, a); + gDPSetEnvColor(gfx_pp[0]++, 70, 10, 10, a); + gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_A, am_pm_tex); + gSPDisplayList(gfx_pp[0]++, clk_win_ampmT_model); + + gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 0, a); + gDPSetEnvColor(gfx_pp[0]++, 70, 50, 50, a); + gSPDisplayList(gfx_pp[0]++, clk_win_maruT_model); + + banti_draw_hiduke(&gfx, play, alpha); + banti_draw_jikan(&gfx, play, alpha); + + if (poly_render == TRUE) { + SET_POLY_OPA_DISP(*gfx_pp); + } else { + SET_FONT_DISP(*gfx_pp); + } + } + + CLOSE_DISP(g); } - - OPEN_DISP(g); - - if (m != NULL) { - mFont_CulcOrthoMatrix(m); - - if (poly_render == TRUE) { - gSPMatrix(NOW_POLY_OPA_DISP++, m, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - } - else { - gSPMatrix(NOW_FONT_DISP++, m, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - } - - } - - Matrix_scale(16.0f, 16.0f, 16.0f, 0); - - if (banti.disp_left == TRUE) { - Matrix_translate(-184.0f, 0.0f, 0.0f, 1); - } - - { - Gfx** gfx_pp; - u8* am_pm_tex = banti.displayed_time.hour < 12 ? clk_win_am_tex_rgb_ia8 : clk_win_pm_tex_rgb_ia8; - int alpha; - u8 a; - Gfx* gfx; - u32 rendermode0; - u32 rendermode1; - - if (poly_render == TRUE) { - gfx = NOW_POLY_OPA_DISP; - } - else { - gfx = NOW_FONT_DISP; - } - - gfx_pp = &gfx; - - gSPMatrix(gfx_pp[0]++, _Matrix_to_Mtx_new(g), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - alpha = banti.alpha * 255.0f; - if (banti.alpha >= 0.4f) { - rendermode0 = G_RM_PASS; - rendermode1 = G_RM_XLU_SURF2; - } - else { - rendermode0 = G_RM_PASS; - rendermode1 = G_RM_CLD_SURF2; - } - - gSPDisplayList(gfx_pp[0]++, clk_win_mode); - gDPSetRenderMode(gfx_pp[0]++, rendermode0, rendermode1); - - if (banti.displayed_time.weekday == lbRTC_SUNDAY) { - u8 a = alpha; - - gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 225, a); - gDPSetEnvColor(gfx_pp[0]++, 165, 30, 30, a); - } - else { - u8 a = alpha; - - gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 225, a); - gDPSetEnvColor(gfx_pp[0]++, 80, 40, 0, a); - } - - gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_9, week_tex_table[banti.displayed_time.weekday]); - gSPDisplayList(gfx_pp[0]++, clk_win_youbiT_model); - - if ((Common_Get(time.rtc_time).sec & 1) == 1) { - u8 a = alpha; - - gDPSetPrimColor(gfx_pp[0]++, 0, a, 215, 120, 0, a); - gDPSetEnvColor(gfx_pp[0]++, 70, 50, 50, a); - gSPDisplayList(gfx_pp[0]++, clk_win_maru2T_model); - } - - a = alpha; - gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 120, a); - gDPSetEnvColor(gfx_pp[0]++, 70, 10, 10, a); - gSPSegment(gfx_pp[0]++, G_MWO_SEGMENT_A, am_pm_tex); - gSPDisplayList(gfx_pp[0]++, clk_win_ampmT_model); - - gDPSetPrimColor(gfx_pp[0]++, 0, a, 255, 255, 0, a); - gDPSetEnvColor(gfx_pp[0]++, 70, 50, 50, a); - gSPDisplayList(gfx_pp[0]++, clk_win_maruT_model); - - banti_draw_hiduke(&gfx, play, alpha); - banti_draw_jikan(&gfx, play, alpha); - - if (poly_render == TRUE) { - SET_POLY_OPA_DISP(*gfx_pp); - } - else { - SET_FONT_DISP(*gfx_pp); - } - } - - CLOSE_DISP(g); - } } diff --git a/src/m_field_info.c b/src/m_field_info.c index 769aac77..40c953d1 100644 --- a/src/m_field_info.c +++ b/src/m_field_info.c @@ -8,886 +8,844 @@ #include "libultra/libultra.h" #include "m_player_lib.h" -static mCoBG_Collision_u l_edge_ut = { - { - 0, - 31, - 31, - 31, - 31, - 31, - mCoBG_ATTRIBUTE_GRASS0 - } -}; +static mCoBG_Collision_u l_edge_ut = { { 0, 31, 31, 31, 31, 31, mCoBG_ATTRIBUTE_GRASS0 } }; typedef struct collision_keep_s { - int assumed_ut_x; - int assumed_ut_z; - int unk_C; + int assumed_ut_x; + int assumed_ut_z; + int unk_C; } mFI_col_keep_c; -static mFI_col_keep_c l_keepcld[mFI_NUM_COL_KEEP] = { - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 } -}; +static mFI_col_keep_c l_keepcld[mFI_NUM_COL_KEEP] = { { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, + { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, + { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 } }; extern void mFI_ClearFieldData() { - g_fdinfo = NULL; + g_fdinfo = NULL; } extern int mFI_CheckFieldData() { - int res = FALSE; + int res = FALSE; - if (g_fdinfo != NULL) { - res = TRUE; - } + if (g_fdinfo != NULL) { + res = TRUE; + } - return res; + return res; } extern mFM_block_info_c* mFI_GetBlockTopP() { - mFM_block_info_c* block_info = NULL; - if (g_fdinfo != NULL) { - block_info = g_fdinfo->block_info; - } + mFM_block_info_c* block_info = NULL; + if (g_fdinfo != NULL) { + block_info = g_fdinfo->block_info; + } - return block_info; + return block_info; } extern mActor_name_t mFI_GetFieldId() { - mActor_name_t field_id = 0; + mActor_name_t field_id = 0; - if (mFI_CheckFieldData() == TRUE) { - field_id = g_fdinfo->field_id; - } + if (mFI_CheckFieldData() == TRUE) { + field_id = g_fdinfo->field_id; + } - return field_id; + return field_id; } extern int mFI_CheckShopFieldName(mActor_name_t field_name) { - int res = FALSE; + int res = FALSE; - if (mFI_GET_TYPE(field_name) == mFI_FIELD_ROOM0) { - switch (field_name) { - case mFI_FIELD_ROOM_SHOP0: - case mFI_FIELD_ROOM_SHOP1: - case mFI_FIELD_ROOM_SHOP2: - case mFI_FIELD_ROOM_SHOP3_1: - case mFI_FIELD_ROOM_SHOP3_2: - res = TRUE; - break; + if (mFI_GET_TYPE(field_name) == mFI_FIELD_ROOM0) { + switch (field_name) { + case mFI_FIELD_ROOM_SHOP0: + case mFI_FIELD_ROOM_SHOP1: + case mFI_FIELD_ROOM_SHOP2: + case mFI_FIELD_ROOM_SHOP3_1: + case mFI_FIELD_ROOM_SHOP3_2: + res = TRUE; + break; + } } - } - return res; + return res; } extern int mFI_CheckShop() { - int res = FALSE; + int res = FALSE; - if (mFI_CheckFieldData() == TRUE) { - res = mFI_CheckShopFieldName(mFI_GetFieldId()); - } + if (mFI_CheckFieldData() == TRUE) { + res = mFI_CheckShopFieldName(mFI_GetFieldId()); + } - return res; + return res; } extern u8 mFI_GetBlockXMax() { - u8 size = 0; + u8 size = 0; - if (mFI_CheckFieldData() == TRUE) { - size = g_fdinfo->block_x_max; - } - - return size; + if (mFI_CheckFieldData() == TRUE) { + size = g_fdinfo->block_x_max; + } + + return size; } extern u8 mFI_GetBlockZMax() { - u8 size = 0; + u8 size = 0; - if (mFI_CheckFieldData() == TRUE) { - size = g_fdinfo->block_z_max; - } - - return size; + if (mFI_CheckFieldData() == TRUE) { + size = g_fdinfo->block_z_max; + } + + return size; } extern f32 mFI_GetBlockWidth() { - static f32 player_room_wd[4] = { - 240.0f, - 320.0f, - 400.0f, - 400.0f - }; + static f32 player_room_wd[4] = { 240.0f, 320.0f, 400.0f, 400.0f }; - mActor_name_t field_id = mFI_GetFieldId(); - mActor_name_t house_owner_name = Common_Get(house_owner_name); + mActor_name_t field_id = mFI_GetFieldId(); + mActor_name_t house_owner_name = Common_Get(house_owner_name); - switch (mFI_GET_TYPE(field_id)) { - case mFI_FIELD_ROOM0: - { - switch (field_id) { - case mFI_FIELD_ROOM_POLICE_BOX: - return 400.0f; - case mFI_FIELD_ROOM_SHOP0: - return 320.0f; - case mFI_FIELD_ROOM_SHOP1: - return 440.0f; - case mFI_FIELD_ROOM_SHOP2: - return 440.0f; - case mFI_FIELD_ROOM_SHOP3_1: - return 480.0f; - case mFI_FIELD_ROOM_SHOP3_2: - return 480.0f; - case mFI_FIELD_ROOM_MUSEUM_ENTRANCE: - return 320.0f; - case mFI_FIELD_ROOM_MUSEUM_FOSSIL: - return 640.0f; - case mFI_FIELD_ROOM_MUSEUM_PAINTING: - return 640.0f; - case mFI_FIELD_ROOM_MUSEUM_FISH: - return 560.0f; - case mFI_FIELD_ROOM_MUSEUM_INSECT: - return 560.0f; - case mFI_FIELD_ROOM_NEEDLEWORK: - return 400.0f; - case mFI_FIELD_ROOM_LIGHTHOUSE: - return 240.0f; - case mFI_FIELD_ROOM_TENT: - return 240.0f; - default: - return 320.0f; - } + switch (mFI_GET_TYPE(field_id)) { + case mFI_FIELD_ROOM0: { + switch (field_id) { + case mFI_FIELD_ROOM_POLICE_BOX: + return 400.0f; + case mFI_FIELD_ROOM_SHOP0: + return 320.0f; + case mFI_FIELD_ROOM_SHOP1: + return 440.0f; + case mFI_FIELD_ROOM_SHOP2: + return 440.0f; + case mFI_FIELD_ROOM_SHOP3_1: + return 480.0f; + case mFI_FIELD_ROOM_SHOP3_2: + return 480.0f; + case mFI_FIELD_ROOM_MUSEUM_ENTRANCE: + return 320.0f; + case mFI_FIELD_ROOM_MUSEUM_FOSSIL: + return 640.0f; + case mFI_FIELD_ROOM_MUSEUM_PAINTING: + return 640.0f; + case mFI_FIELD_ROOM_MUSEUM_FISH: + return 560.0f; + case mFI_FIELD_ROOM_MUSEUM_INSECT: + return 560.0f; + case mFI_FIELD_ROOM_NEEDLEWORK: + return 400.0f; + case mFI_FIELD_ROOM_LIGHTHOUSE: + return 240.0f; + case mFI_FIELD_ROOM_TENT: + return 240.0f; + default: + return 320.0f; + } + } + + case mFI_FIELD_NPCROOM0: { + return mFI_BK_WORLDSIZE_X_F / 2.0f; + } + + case mFI_FIELD_PLAYER0_ROOM: { + u8 size; + + if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { + return 400.0f; + } + + if (Save_Get(scene_no) == SCENE_MY_ROOM_LL2) { + return mFI_BK_WORLDSIZE_X_F / 2.0f; + } + + if (Save_Get(scene_no) >= SCENE_MY_ROOM_BASEMENT_S && Save_Get(scene_no) <= SCENE_MY_ROOM_BASEMENT_LL1) { + return 400.0f; + } + + size = Save_Get(homes[house_owner_name]).size_info.size; + if (size > 3) { + size = 3; + } + + return player_room_wd[size]; + } + + default: { + return mFI_BK_WORLDSIZE_X_F; + } } - - case mFI_FIELD_NPCROOM0: - { - return mFI_BK_WORLDSIZE_X_F / 2.0f; - } - - case mFI_FIELD_PLAYER0_ROOM: - { - u8 size; - - if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { - return 400.0f; - } - - if (Save_Get(scene_no) == SCENE_MY_ROOM_LL2) { - return mFI_BK_WORLDSIZE_X_F / 2.0f; - } - - if (Save_Get(scene_no) >= SCENE_MY_ROOM_BASEMENT_S && Save_Get(scene_no) <= SCENE_MY_ROOM_BASEMENT_LL1) { - return 400.0f; - } - - size = Save_Get(homes[house_owner_name]).size_info.size; - if (size > 3) { - size = 3; - } - - return player_room_wd[size]; - } - - default: - { - return mFI_BK_WORLDSIZE_X_F; - } - } } extern f32 mFI_GetBlockHeight() { - static f32 player_room_ht[4] = { - 280.0f, - 360.0f, - 440.0f, - 440.0f - }; + static f32 player_room_ht[4] = { 280.0f, 360.0f, 440.0f, 440.0f }; - mActor_name_t field_id = mFI_GetFieldId(); - mActor_name_t house_owner_name = Common_Get(house_owner_name); + mActor_name_t field_id = mFI_GetFieldId(); + mActor_name_t house_owner_name = Common_Get(house_owner_name); - switch (mFI_GET_TYPE(field_id)) { - case mFI_FIELD_ROOM0: - { - switch (field_id) { - case mFI_FIELD_ROOM_POLICE_BOX: - return 400.0f; - case mFI_FIELD_ROOM_SHOP0: - return 320.0f; - case mFI_FIELD_ROOM_SHOP1: - return 320.0f; - case mFI_FIELD_ROOM_SHOP2: - return 480.0f; - case mFI_FIELD_ROOM_SHOP3_1: - return 560.0f; - case mFI_FIELD_ROOM_SHOP3_2: - return 560.0f; - case mFI_FIELD_ROOM_MUSEUM_ENTRANCE: - return 640.0f; - case mFI_FIELD_ROOM_MUSEUM_FOSSIL: - return 640.0f; - case mFI_FIELD_ROOM_MUSEUM_PAINTING: - return 640.0f; - case mFI_FIELD_ROOM_MUSEUM_FISH: - return 640.0f; - case mFI_FIELD_ROOM_MUSEUM_INSECT: - return 640.0f; - case mFI_FIELD_ROOM_NEEDLEWORK: - return 320.0f; - case mFI_FIELD_ROOM_LIGHTHOUSE: - return 260.0f; - case mFI_FIELD_ROOM_TENT: - return 260.0f; - default: - return 320.0f; - } + switch (mFI_GET_TYPE(field_id)) { + case mFI_FIELD_ROOM0: { + switch (field_id) { + case mFI_FIELD_ROOM_POLICE_BOX: + return 400.0f; + case mFI_FIELD_ROOM_SHOP0: + return 320.0f; + case mFI_FIELD_ROOM_SHOP1: + return 320.0f; + case mFI_FIELD_ROOM_SHOP2: + return 480.0f; + case mFI_FIELD_ROOM_SHOP3_1: + return 560.0f; + case mFI_FIELD_ROOM_SHOP3_2: + return 560.0f; + case mFI_FIELD_ROOM_MUSEUM_ENTRANCE: + return 640.0f; + case mFI_FIELD_ROOM_MUSEUM_FOSSIL: + return 640.0f; + case mFI_FIELD_ROOM_MUSEUM_PAINTING: + return 640.0f; + case mFI_FIELD_ROOM_MUSEUM_FISH: + return 640.0f; + case mFI_FIELD_ROOM_MUSEUM_INSECT: + return 640.0f; + case mFI_FIELD_ROOM_NEEDLEWORK: + return 320.0f; + case mFI_FIELD_ROOM_LIGHTHOUSE: + return 260.0f; + case mFI_FIELD_ROOM_TENT: + return 260.0f; + default: + return 320.0f; + } + } + + case mFI_FIELD_NPCROOM0: { + return mFI_BK_WORLDSIZE_X_F / 2.0f; + } + + case mFI_FIELD_PLAYER0_ROOM: { + u8 size; + + if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { + return 440.0f; + } + + if (Save_Get(scene_no) == SCENE_MY_ROOM_LL2) { + return 360.0f; + } + + if (Save_Get(scene_no) >= SCENE_MY_ROOM_BASEMENT_S && Save_Get(scene_no) <= SCENE_MY_ROOM_BASEMENT_LL1) { + return 440.0f; + } + + size = Save_Get(homes[house_owner_name]).size_info.size; + if (size > 3) { + size = 3; + } + + return player_room_ht[size]; + } + + default: { + return mFI_BK_WORLDSIZE_X_F; + } } - - case mFI_FIELD_NPCROOM0: - { - return mFI_BK_WORLDSIZE_X_F / 2.0f; - } - - case mFI_FIELD_PLAYER0_ROOM: - { - u8 size; - - if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { - return 440.0f; - } - - if (Save_Get(scene_no) == SCENE_MY_ROOM_LL2) { - return 360.0f; - } - - if (Save_Get(scene_no) >= SCENE_MY_ROOM_BASEMENT_S && Save_Get(scene_no) <= SCENE_MY_ROOM_BASEMENT_LL1) { - return 440.0f; - } - - size = Save_Get(homes[house_owner_name]).size_info.size; - if (size > 3) { - size = 3; - } - - return player_room_ht[size]; - } - - default: - { - return mFI_BK_WORLDSIZE_X_F; - } - } } extern int mFI_GetBlockNum(int block_x, int block_z) { - int num = block_x + block_z * mFI_GetBlockXMax(); + int num = block_x + block_z * mFI_GetBlockXMax(); - return num; + return num; } static int mFI_GetUtNum(int ut_x, int ut_z) { - return ut_x + ut_z * UT_X_NUM; + return ut_x + ut_z * UT_X_NUM; } extern int mFI_BlockCheck(int block_x, int block_z) { - int num = mFI_GetBlockNum(block_x, block_z); + int num = mFI_GetBlockNum(block_x, block_z); - if (block_x < 0 || block_x >= mFI_GetBlockXMax() || block_z < 0 || block_z >= mFI_GetBlockZMax() || g_fdinfo->block_info[num].bg_info.bg_id.combination_type == 292) { - return FALSE; - } + if (block_x < 0 || block_x >= mFI_GetBlockXMax() || block_z < 0 || block_z >= mFI_GetBlockZMax() || + g_fdinfo->block_info[num].bg_info.bg_id.combination_type == 292) { + return FALSE; + } - return TRUE; + return TRUE; } extern int mFI_UtNumCheck(int ut_x, int ut_z, int bx_max, int bz_max) { - int res = TRUE; - int max_x = (bx_max * UT_X_NUM); - int max_z = (bz_max * UT_Z_NUM); + int res = TRUE; + int max_x = (bx_max * UT_X_NUM); + int max_z = (bz_max * UT_Z_NUM); - if (ut_x < 0 || ut_x >= max_x || ut_z < 0 || ut_z >= max_z) { - res = FALSE; - } + if (ut_x < 0 || ut_x >= max_x || ut_z < 0 || ut_z >= max_z) { + res = FALSE; + } - return res; + return res; } static int mFI_WposCheck(xyz_t wpos) { - int bx; - int bz; + int bx; + int bz; - return mFI_Wpos2BlockNum(&bx, &bz, wpos); + return mFI_Wpos2BlockNum(&bx, &bz, wpos); } extern int mFI_WposX2UtNumX(f32 wpos_x) { - return (int)(wpos_x / mFI_UT_WORLDSIZE_X_F); + return (int)(wpos_x / mFI_UT_WORLDSIZE_X_F); } extern int mFI_WposZ2UtNumZ(f32 wpos_z) { - return (int)(wpos_z / mFI_UT_WORLDSIZE_Z_F); + return (int)(wpos_z / mFI_UT_WORLDSIZE_Z_F); } extern int mFI_Wpos2UtNum(int* ut_x, int* ut_z, xyz_t wpos) { - *ut_x = (int)(wpos.x / mFI_UT_WORLDSIZE_X_F); - *ut_z = (int)(wpos.z / mFI_UT_WORLDSIZE_Z_F); + *ut_x = (int)(wpos.x / mFI_UT_WORLDSIZE_X_F); + *ut_z = (int)(wpos.z / mFI_UT_WORLDSIZE_Z_F); - if ( - wpos.x < 0.0f || wpos.x > (mFI_GetBlockXMax() * mFI_BK_WORLDSIZE_X_F) || - wpos.z < 0.0f || wpos.z > (mFI_GetBlockZMax() * mFI_BK_WORLDSIZE_Z_F) - ) { - return FALSE; - } + if (wpos.x < 0.0f || wpos.x > (mFI_GetBlockXMax() * mFI_BK_WORLDSIZE_X_F) || wpos.z < 0.0f || + wpos.z > (mFI_GetBlockZMax() * mFI_BK_WORLDSIZE_Z_F)) { + return FALSE; + } - return TRUE; + return TRUE; } extern int mFI_UtNum2CenterWpos(xyz_t* wpos, int ut_x, int ut_z) { - wpos->x = (f32)ut_x * mFI_UT_WORLDSIZE_X_F; - wpos->z = (f32)ut_z * mFI_UT_WORLDSIZE_Z_F; + wpos->x = (f32)ut_x * mFI_UT_WORLDSIZE_X_F; + wpos->z = (f32)ut_z * mFI_UT_WORLDSIZE_Z_F; - wpos->x += mFI_UT_WORLDSIZE_HALF_X_F; - wpos->z += mFI_UT_WORLDSIZE_HALF_Z_F; + wpos->x += mFI_UT_WORLDSIZE_HALF_X_F; + wpos->z += mFI_UT_WORLDSIZE_HALF_Z_F; - return mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()); + return mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()); } extern int mFI_Wpos2UtCenterWpos(xyz_t* wpos, xyz_t src_pos) { - f32 x = (int)(src_pos.x / mFI_UT_WORLDSIZE_X_F) * mFI_UT_WORLDSIZE_X; - f32 z = (int)(src_pos.z / mFI_UT_WORLDSIZE_Z_F) * mFI_UT_WORLDSIZE_Z; + f32 x = (int)(src_pos.x / mFI_UT_WORLDSIZE_X_F) * mFI_UT_WORLDSIZE_X; + f32 z = (int)(src_pos.z / mFI_UT_WORLDSIZE_Z_F) * mFI_UT_WORLDSIZE_Z; - wpos->x = x + mFI_UT_WORLDSIZE_HALF_Z_F; - wpos->y = src_pos.y; - wpos->z = z + mFI_UT_WORLDSIZE_HALF_Z_F; + wpos->x = x + mFI_UT_WORLDSIZE_HALF_Z_F; + wpos->y = src_pos.y; + wpos->z = z + mFI_UT_WORLDSIZE_HALF_Z_F; - return mFI_WposCheck(src_pos); + return mFI_WposCheck(src_pos); } extern int mFI_Wpos2UtNum_inBlock(int* ut_x, int* ut_z, xyz_t wpos) { - int res = FALSE; + int res = FALSE; - if ( - wpos.x >= 0.0f && wpos.x < ((f32)mFI_GetBlockXMax() * mFI_BK_WORLDSIZE_X_F) && - wpos.z >= 0.0f && wpos.z < ((f32)mFI_GetBlockZMax() * mFI_BK_WORLDSIZE_Z_F) - ) { + if (wpos.x >= 0.0f && wpos.x < ((f32)mFI_GetBlockXMax() * mFI_BK_WORLDSIZE_X_F) && wpos.z >= 0.0f && + wpos.z < ((f32)mFI_GetBlockZMax() * mFI_BK_WORLDSIZE_Z_F)) { + ut_x[0] = (int)(wpos.x / mFI_UT_WORLDSIZE_X_F); + ut_z[0] = (int)(wpos.z / mFI_UT_WORLDSIZE_Z_F); + + ut_x[0] &= 0xF; + ut_z[0] &= 0xF; + + res = TRUE; + } else { + ut_x[0] = 0; + ut_z[0] = 0; + } + + return res; +} + +extern int mFI_Wpos2BlockNum(int* bx, int* bz, xyz_t wpos) { + bx[0] = (int)(wpos.x / mFI_BK_WORLDSIZE_X_F); + bz[0] = (int)(wpos.z / mFI_BK_WORLDSIZE_Z_F); + + return mFI_BlockCheck(*bx, *bz); +} + +extern int mFI_Wpos2BkandUtNuminBlock(int* bx, int* bz, int* ut_x, int* ut_z, xyz_t wpos) { + bx[0] = (int)(wpos.x / mFI_BK_WORLDSIZE_X_F); + bz[0] = (int)(wpos.z / mFI_BK_WORLDSIZE_Z_F); ut_x[0] = (int)(wpos.x / mFI_UT_WORLDSIZE_X_F); ut_z[0] = (int)(wpos.z / mFI_UT_WORLDSIZE_Z_F); ut_x[0] &= 0xF; ut_z[0] &= 0xF; - res = TRUE; - } - else { - ut_x[0] = 0; - ut_z[0] = 0; - } - - return res; -} - -extern int mFI_Wpos2BlockNum(int* bx, int* bz, xyz_t wpos) { - bx[0] = (int)(wpos.x / mFI_BK_WORLDSIZE_X_F); - bz[0] = (int)(wpos.z / mFI_BK_WORLDSIZE_Z_F); - - return mFI_BlockCheck(*bx, *bz); -} - -extern int mFI_Wpos2BkandUtNuminBlock(int* bx, int* bz, int* ut_x, int* ut_z, xyz_t wpos) { - bx[0] = (int)(wpos.x / mFI_BK_WORLDSIZE_X_F); - bz[0] = (int)(wpos.z / mFI_BK_WORLDSIZE_Z_F); - ut_x[0] = (int)(wpos.x / mFI_UT_WORLDSIZE_X_F); - ut_z[0] = (int)(wpos.z / mFI_UT_WORLDSIZE_Z_F); - - ut_x[0] &= 0xF; - ut_z[0] &= 0xF; - - return mFI_BlockCheck(*bx, *bz); + return mFI_BlockCheck(*bx, *bz); } static int mFI_UtNum2BlockNum(int* bx, int* bz, int ut_x, int ut_z) { - if (ut_x < 0) { - ut_x -= (UT_X_NUM - 1); - } + if (ut_x < 0) { + ut_x -= (UT_X_NUM - 1); + } - if (ut_z < 0) { - ut_z -= (UT_Z_NUM - 1); - } + if (ut_z < 0) { + ut_z -= (UT_Z_NUM - 1); + } - bx[0] = ut_x / UT_X_NUM; - bz[0] = ut_z / UT_Z_NUM; + bx[0] = ut_x / UT_X_NUM; + bz[0] = ut_z / UT_Z_NUM; - return mFI_BlockCheck(bx[0], bz[0]); + return mFI_BlockCheck(bx[0], bz[0]); } static int mFI_GetUtNumInBK(int* bk_ut_x, int* bk_ut_z, int ut_x, int ut_z) { - int res = mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()); + int res = mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()); - if (res) { - bk_ut_x[0] = ut_x & 0xF; - bk_ut_z[0] = ut_z & 0xF; - } - else { - bk_ut_x[0] = 0; - bk_ut_z[0] = 0; - } + if (res) { + bk_ut_x[0] = ut_x & 0xF; + bk_ut_z[0] = ut_z & 0xF; + } else { + bk_ut_x[0] = 0; + bk_ut_z[0] = 0; + } - return res; + return res; } extern int mFI_WpostoLposInBK(xyz_t* lpos, xyz_t wpos) { - int bx; - int bz; - int res = mFI_Wpos2BlockNum(&bx, &bz, wpos); + int bx; + int bz; + int res = mFI_Wpos2BlockNum(&bx, &bz, wpos); - lpos->x = wpos.x - ((f32)bx * mFI_BK_WORLDSIZE_X_F); - lpos->y = wpos.y; - lpos->z = wpos.z - ((f32)bz * mFI_BK_WORLDSIZE_Z_F); - return res; + lpos->x = wpos.x - ((f32)bx * mFI_BK_WORLDSIZE_X_F); + lpos->y = wpos.y; + lpos->z = wpos.z - ((f32)bz * mFI_BK_WORLDSIZE_Z_F); + return res; } extern int mFI_LposInBKtoWpos(xyz_t* wpos, xyz_t lpos, int bx, int bz) { - wpos->x = lpos.x + (f32)(bx * mFI_BK_WORLDSIZE_X); - wpos->y = lpos.y; - wpos->z = lpos.z + (f32)(bz * mFI_BK_WORLDSIZE_Z); + wpos->x = lpos.x + (f32)(bx * mFI_BK_WORLDSIZE_X); + wpos->y = lpos.y; + wpos->z = lpos.z + (f32)(bz * mFI_BK_WORLDSIZE_Z); - return mFI_BlockCheck(bx, bz); + return mFI_BlockCheck(bx, bz); } extern int mFI_ScrollCheck(xyz_t wpos, u8 dir) { - int bx; - int bz; - - if (mFI_Wpos2BlockNum(&bx, &bz, wpos) == FALSE) { - return FALSE; - } + int bx; + int bz; - switch (dir) { - case mFI_MOVEDIR_RIGHT: - bx++; - break; - case mFI_MOVEDIR_LEFT: - bx--; - break; - case mFI_MOVEDIR_UP: - bz--; - break; - case mFI_MOVEDIR_DOWN: - bz++; - break; - default: - return FALSE; - } + if (mFI_Wpos2BlockNum(&bx, &bz, wpos) == FALSE) { + return FALSE; + } - return mFI_BlockCheck(bx, bz); + switch (dir) { + case mFI_MOVEDIR_RIGHT: + bx++; + break; + case mFI_MOVEDIR_LEFT: + bx--; + break; + case mFI_MOVEDIR_UP: + bz--; + break; + case mFI_MOVEDIR_DOWN: + bz++; + break; + default: + return FALSE; + } + + return mFI_BlockCheck(bx, bz); } extern int mFI_BkNum2WposXZ(f32* wpos_x, f32* wpos_z, int bx, int bz) { - int res = FALSE; + int res = FALSE; - wpos_x[0] = (f32)(bx * mFI_BK_WORLDSIZE_X); - wpos_z[0] = (f32)(bz * mFI_BK_WORLDSIZE_Z); + wpos_x[0] = (f32)(bx * mFI_BK_WORLDSIZE_X); + wpos_z[0] = (f32)(bz * mFI_BK_WORLDSIZE_Z); - if (mFI_CheckFieldData() == TRUE) { - res = mFI_BlockCheck(bx, bz); - } + if (mFI_CheckFieldData() == TRUE) { + res = mFI_BlockCheck(bx, bz); + } - return res; + return res; } extern void mFI_UtNum2PosXZInBk(f32* pos_x, f32* pos_z, int ut_x, int ut_z) { - pos_x[0] = (f32)(ut_x * mFI_UT_WORLDSIZE_X); - pos_z[0] = (f32)(ut_z * mFI_UT_WORLDSIZE_Z); + pos_x[0] = (f32)(ut_x * mFI_UT_WORLDSIZE_X); + pos_z[0] = (f32)(ut_z * mFI_UT_WORLDSIZE_Z); } extern void mFI_BkandUtNum2Wpos(xyz_t* wpos, int bx, int bz, int ut_x, int ut_z) { - f32 wpos_x; - f32 wpos_z; - f32 bpos_x; - f32 bpos_z; + f32 wpos_x; + f32 wpos_z; + f32 bpos_x; + f32 bpos_z; - mFI_BkNum2WposXZ(&wpos_x, &wpos_z, bx, bz); - mFI_UtNum2PosXZInBk(&bpos_x, &bpos_z, ut_x, ut_z); + mFI_BkNum2WposXZ(&wpos_x, &wpos_z, bx, bz); + mFI_UtNum2PosXZInBk(&bpos_x, &bpos_z, ut_x, ut_z); - wpos->x = wpos_x + bpos_x; - wpos->y = 0.0f; - wpos->z = wpos_z + bpos_z; + wpos->x = wpos_x + bpos_x; + wpos->y = 0.0f; + wpos->z = wpos_z + bpos_z; } extern void mFI_BkandUtNum2CenterWpos(xyz_t* wpos, int bx, int bz, int ut_x, int ut_z) { - mFI_BkandUtNum2Wpos(wpos, bx, bz, ut_x, ut_z); + mFI_BkandUtNum2Wpos(wpos, bx, bz, ut_x, ut_z); - wpos->x += mFI_UT_WORLDSIZE_HALF_X_F; - wpos->z += mFI_UT_WORLDSIZE_HALF_Z_F; + wpos->x += mFI_UT_WORLDSIZE_HALF_X_F; + wpos->z += mFI_UT_WORLDSIZE_HALF_Z_F; } extern mFM_field_draw_info_c* mFI_BGDisplayListTop() { - return g_fdinfo->bg_draw_info; + return g_fdinfo->bg_draw_info; } extern mFM_field_pal_c* mFI_GetFieldPal() { - return &g_fdinfo->field_palette; + return &g_fdinfo->field_palette; } extern int mFI_GetPlayerHouseFloorNo(int scene) { - int floor = -1; + int floor = -1; - switch (scene) { - case SCENE_MY_ROOM_S: - case SCENE_MY_ROOM_M: - case SCENE_MY_ROOM_L: - case SCENE_MY_ROOM_LL1: - case SCENE_COTTAGE_MY: - floor = 0; - break; + switch (scene) { + case SCENE_MY_ROOM_S: + case SCENE_MY_ROOM_M: + case SCENE_MY_ROOM_L: + case SCENE_MY_ROOM_LL1: + case SCENE_COTTAGE_MY: + floor = 0; + break; - case SCENE_MY_ROOM_LL2: - floor = 1; - break; + case SCENE_MY_ROOM_LL2: + floor = 1; + break; - case SCENE_MY_ROOM_BASEMENT_S: - case SCENE_MY_ROOM_BASEMENT_M: - case SCENE_MY_ROOM_BASEMENT_L: - case SCENE_MY_ROOM_BASEMENT_LL1: - floor = 2; - break; - } + case SCENE_MY_ROOM_BASEMENT_S: + case SCENE_MY_ROOM_BASEMENT_M: + case SCENE_MY_ROOM_BASEMENT_L: + case SCENE_MY_ROOM_BASEMENT_LL1: + floor = 2; + break; + } - return floor; + return floor; } extern int mFI_GetNowPlayerHouseFloorNo() { - return mFI_GetPlayerHouseFloorNo(Save_Get(scene_no)); + return mFI_GetPlayerHouseFloorNo(Save_Get(scene_no)); } typedef struct register_bg_info_s { - int dma_active; - int bg_num; - u32 unused_rom_start; - u32 unused_rom_size; + int dma_active; + int bg_num; + u32 unused_rom_start; + u32 unused_rom_size; } mFI_register_bg_info_c; static mFI_register_bg_info_c l_register_bg_info[mFM_VISIBLE_BLOCK_NUM]; static void mFI_ClearRegisterBgInfo(mFI_register_bg_info_c* bg_info) { - bg_info->dma_active = FALSE; - bg_info->bg_num = -1; - bg_info->unused_rom_start = 0; - bg_info->unused_rom_size = 0; + bg_info->dma_active = FALSE; + bg_info->bg_num = -1; + bg_info->unused_rom_start = 0; + bg_info->unused_rom_size = 0; } static void mFI_ClearRegisterBgInfoIdx(int idx) { - mFI_ClearRegisterBgInfo(&l_register_bg_info[idx]); + mFI_ClearRegisterBgInfo(&l_register_bg_info[idx]); } extern void mFI_InitRegisterBgInfo() { - int i; + int i; - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - mFI_ClearRegisterBgInfo(&l_register_bg_info[i]); - } + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + mFI_ClearRegisterBgInfo(&l_register_bg_info[i]); + } } static int mFI_CheckFreeRegisterBgInfo(mFI_register_bg_info_c* bg_info) { - int res = FALSE; + int res = FALSE; - if (bg_info->bg_num == -1) { - res = TRUE; - } + if (bg_info->bg_num == -1) { + res = TRUE; + } - return res; + return res; } static int mFI_GetFreeRegisterBgInfo() { - mFI_register_bg_info_c* bg_info = l_register_bg_info; - int res = -1; - int i; + mFI_register_bg_info_c* bg_info = l_register_bg_info; + int res = -1; + int i; - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - if (mFI_CheckFreeRegisterBgInfo(bg_info)) { - res = i; - break; + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + if (mFI_CheckFreeRegisterBgInfo(bg_info)) { + res = i; + break; + } + + bg_info++; } - - bg_info++; - } - return res; + return res; } static void mFI_SetRegisterBgInfo(int bg_num, u32 rom_start, u32 rom_size) { - mFI_register_bg_info_c* bg_info = l_register_bg_info + bg_num; + mFI_register_bg_info_c* bg_info = l_register_bg_info + bg_num; - bg_info->dma_active = TRUE; - bg_info->bg_num = bg_num; - bg_info->unused_rom_start = rom_start; - bg_info->unused_rom_size = rom_size; + bg_info->dma_active = TRUE; + bg_info->bg_num = bg_num; + bg_info->unused_rom_start = rom_start; + bg_info->unused_rom_size = rom_size; } static int mFI_CheckFinishBgDma(int bg_num) { - int res = FALSE; + int res = FALSE; - if (l_register_bg_info[bg_num].dma_active == FALSE && l_register_bg_info[bg_num].bg_num != -1) { - res = TRUE; - } + if (l_register_bg_info[bg_num].dma_active == FALSE && l_register_bg_info[bg_num].bg_num != -1) { + res = TRUE; + } - return res; + return res; } static void mFI_DmaBg_sub(mFI_register_bg_info_c* bg_info) { - g_fdinfo->bg_draw_info[bg_info->bg_num].dma_loaded = TRUE; + g_fdinfo->bg_draw_info[bg_info->bg_num].dma_loaded = TRUE; } static void mFI_DmaBg() { - mFI_register_bg_info_c* bg_info = l_register_bg_info; - int i; + mFI_register_bg_info_c* bg_info = l_register_bg_info; + int i; - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - if (bg_info->dma_active == TRUE) { - mFI_DmaBg_sub(bg_info); - mFI_BornItemON(); - Common_Set(remove_cut_tree_info_bitfield, Common_Get(remove_cut_tree_info_bitfield) | (1 << bg_info->bg_num)); - bg_info->dma_active = FALSE; - - break; + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + if (bg_info->dma_active == TRUE) { + mFI_DmaBg_sub(bg_info); + mFI_BornItemON(); + Common_Set(remove_cut_tree_info_bitfield, + Common_Get(remove_cut_tree_info_bitfield) | (1 << bg_info->bg_num)); + bg_info->dma_active = FALSE; + + break; + } + + bg_info++; } - - bg_info++; - } } extern int mFI_CheckBgDma(int bx, int bz) { - int res = FALSE; - int i; - - if (mFI_CheckFieldData() == TRUE) { - mFM_field_draw_info_c* draw_info = mFI_BGDisplayListTop(); + int res = FALSE; + int i; - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - if (draw_info->block_x == bx && draw_info->block_z == bz && draw_info->dma_loaded) { - res = TRUE; + if (mFI_CheckFieldData() == TRUE) { + mFM_field_draw_info_c* draw_info = mFI_BGDisplayListTop(); - break; - } - - draw_info++; + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + if (draw_info->block_x == bx && draw_info->block_z == bz && draw_info->dma_loaded) { + res = TRUE; + + break; + } + + draw_info++; + } } - } - return res; + return res; } extern f32 mFI_UtNum2BaseHeight(int ut_x, int ut_z) { - int bx; - int bz; - int num; + int bx; + int bz; + int num; - if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { - return 10000.0f; - } + if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { + return 10000.0f; + } - num = mFI_GetBlockNum(bx, bz); - return (f32)((int)g_fdinfo->block_info[num].bg_info.bg_id.height * (3 * mFI_UT_WORLDSIZE_X)); + num = mFI_GetBlockNum(bx, bz); + return (f32)((int)g_fdinfo->block_info[num].bg_info.bg_id.height * (3 * mFI_UT_WORLDSIZE_X)); } extern f32 mFI_BkNum2BaseHeight(int bx, int bz) { - int num; + int num; - if (mFI_BlockCheck(bx, bz) == FALSE) { - return 10000.0f; - } + if (mFI_BlockCheck(bx, bz) == FALSE) { + return 10000.0f; + } - num = mFI_GetBlockNum(bx, bz); - return (f32)((int)g_fdinfo->block_info[num].bg_info.bg_id.height * (3 * mFI_UT_WORLDSIZE_X)); + num = mFI_GetBlockNum(bx, bz); + return (f32)((int)g_fdinfo->block_info[num].bg_info.bg_id.height * (3 * mFI_UT_WORLDSIZE_X)); } extern u8 mFI_BkNum2BlockType(int bx, int bz) { - u8 type = 39; + u8 type = 39; - if (mFI_CheckFieldData() && bx >= 0 && bx < BLOCK_X_NUM && bz >= 0 && bz < BLOCK_Z_NUM) { - int idx = (bz * BLOCK_X_NUM) + bx; - - type = g_block_type_p[idx]; - } + if (mFI_CheckFieldData() && bx >= 0 && bx < BLOCK_X_NUM && bz >= 0 && bz < BLOCK_Z_NUM) { + int idx = (bz * BLOCK_X_NUM) + bx; - return type; + type = g_block_type_p[idx]; + } + + return type; } // 25% static int mFI_GetPuleTypeIdx(u8 type) { - u32 kind = mRF_Type2BlockInfo(type); - int idx = -1; + u32 kind = mRF_Type2BlockInfo(type); + int idx = -1; - if ((kind & mRF_BLOCKKIND_POOL) == mRF_BLOCKKIND_POOL) { - idx = type - 69; - } + if ((kind & mRF_BLOCKKIND_POOL) == mRF_BLOCKKIND_POOL) { + idx = type - 69; + } - return idx; + return idx; } extern int mFI_GetPuleIdx() { - int bx; - int bz; - u8 type; + int bx; + int bz; + u8 type; - mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_POOL); - type = mFI_BkNum2BlockType(bx, bz); - return mFI_GetPuleTypeIdx(type); + mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_POOL); + type = mFI_BkNum2BlockType(bx, bz); + return mFI_GetPuleTypeIdx(type); } extern u32 mFI_BkNum2BlockKind(int bx, int bz) { - u32 kind = mRF_BLOCKKIND_NONE; + u32 kind = mRF_BLOCKKIND_NONE; - if (mFI_CheckFieldData() && mFI_BlockCheck(bx, bz)) { - int num = mFI_GetBlockNum(bx, bz); + if (mFI_CheckFieldData() && mFI_BlockCheck(bx, bz)) { + int num = mFI_GetBlockNum(bx, bz); - kind = g_fdinfo->block_info[num].bg_info.block_kind; - } + kind = g_fdinfo->block_info[num].bg_info.block_kind; + } - return kind; + return kind; } extern int mFI_CheckBlockKind(int bx, int bz, u32 block_kind) { - int res = FALSE; - u32 kind = mFI_BkNum2BlockKind(bx, bz); + int res = FALSE; + u32 kind = mFI_BkNum2BlockKind(bx, bz); - kind &= block_kind; - if (block_kind == kind) { - res = TRUE; - } + kind &= block_kind; + if (block_kind == kind) { + res = TRUE; + } - return res; + return res; } extern int mFI_CheckBlockKind_OR(int bx, int bz, u32 block_kind_OR) { - int res = FALSE; - u32 kind = mFI_BkNum2BlockKind(bx, bz); - - kind &= block_kind_OR; - if (kind != mRF_BLOCKKIND_NONE) { - res = TRUE; - } + int res = FALSE; + u32 kind = mFI_BkNum2BlockKind(bx, bz); - return res; + kind &= block_kind_OR; + if (kind != mRF_BLOCKKIND_NONE) { + res = TRUE; + } + + return res; } extern int mFI_BlockKind2BkNum(int* bx, int* bz, u32 kind) { - u32* kind_p = (u32*)g_block_kind_p; - int res = FALSE; - int i; + u32* kind_p = (u32*)g_block_kind_p; + int res = FALSE; + int i; - bx[0] = 0; - bz[0] = 0; - - if (kind_p != NULL) { - for (i = 0; i < BLOCK_TOTAL_NUM; i++) { - u32 k = kind_p[0]; + bx[0] = 0; + bz[0] = 0; - k &= kind; - if (kind == k) { - bx[0] = i % BLOCK_X_NUM; - bz[0] = i / BLOCK_X_NUM; - res = TRUE; + if (kind_p != NULL) { + for (i = 0; i < BLOCK_TOTAL_NUM; i++) { + u32 k = kind_p[0]; - break; - } + k &= kind; + if (kind == k) { + bx[0] = i % BLOCK_X_NUM; + bz[0] = i / BLOCK_X_NUM; + res = TRUE; - kind_p++; + break; + } + + kind_p++; + } } - } - return res; + return res; } extern void mFI_GetSpecialBlockNum(int* block_pos, u32* kinds, int count) { - int i; + int i; - for (i = 0; i < count; i++) { - mFI_BlockKind2BkNum(block_pos + 0, block_pos + 1, kinds[0]); - kinds++; - block_pos += 2; - } + for (i = 0; i < count; i++) { + mFI_BlockKind2BkNum(block_pos + 0, block_pos + 1, kinds[0]); + kinds++; + block_pos += 2; + } } extern void mFI_GetIslandBlockNumX(int* island_x_blocks) { - u32* kind_p = (u32*)g_block_kind_p; - int found_num = 0; - int i; + u32* kind_p = (u32*)g_block_kind_p; + int found_num = 0; + int i; - if (island_x_blocks != NULL && kind_p != NULL) { - bzero(island_x_blocks, 2 * sizeof(int)); + if (island_x_blocks != NULL && kind_p != NULL) { + bzero(island_x_blocks, 2 * sizeof(int)); - kind_p += mISL_BLOCK_Z * BLOCK_X_NUM; - for (i = 0; i < BLOCK_X_NUM; i++) { - if ((kind_p[0] & mRF_BLOCKKIND_ISLAND) == mRF_BLOCKKIND_ISLAND) { - island_x_blocks[0] = i; - island_x_blocks++; - found_num++; - } + kind_p += mISL_BLOCK_Z * BLOCK_X_NUM; + for (i = 0; i < BLOCK_X_NUM; i++) { + if ((kind_p[0] & mRF_BLOCKKIND_ISLAND) == mRF_BLOCKKIND_ISLAND) { + island_x_blocks[0] = i; + island_x_blocks++; + found_num++; + } - if (found_num >= mISL_FG_BLOCK_X_NUM) { - break; - } + if (found_num >= mISL_FG_BLOCK_X_NUM) { + break; + } - kind_p++; + kind_p++; + } } - } } extern mCoBG_Collision_u* mFI_GetBkNum2ColTop(int bx, int bz) { - mCoBG_Collision_u* col = NULL; + mCoBG_Collision_u* col = NULL; - if (mFI_CheckFieldData() && mFI_BlockCheck(bx, bz)) { - int num = mFI_GetBlockNum(bx, bz); + if (mFI_CheckFieldData() && mFI_BlockCheck(bx, bz)) { + int num = mFI_GetBlockNum(bx, bz); - col = (mCoBG_Collision_u*)g_fdinfo->block_info[num].bg_info.collision; - } + col = (mCoBG_Collision_u*)g_fdinfo->block_info[num].bg_info.collision; + } - return col; + return col; } extern mCoBG_Collision_u* mFI_UtNum2UtCol(int ut_x, int ut_z) { - int b_ut_x; - int b_ut_z; - int bx; - int bz; + int b_ut_x; + int b_ut_z; + int bx; + int bz; - if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { - return &l_edge_ut; - } - else if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { - return &l_edge_ut; - } - else { - mFM_bg_info_c* bg_info; - mCoBG_Collision_u* col; - int num; - int idx; + if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { + return &l_edge_ut; + } else if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { + return &l_edge_ut; + } else { + mFM_bg_info_c* bg_info; + mCoBG_Collision_u* col; + int num; + int idx; - mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); - num = mFI_GetBlockNum(bx, bz); - idx = b_ut_z * UT_X_NUM + b_ut_x; - col = (mCoBG_Collision_u*)g_fdinfo->block_info[num].bg_info.collision; - col += idx; - return col; - } + mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); + num = mFI_GetBlockNum(bx, bz); + idx = b_ut_z * UT_X_NUM + b_ut_x; + col = (mCoBG_Collision_u*)g_fdinfo->block_info[num].bg_info.collision; + col += idx; + return col; + } } extern void mFI_ClearColKeep() { - int i; + int i; - for (i = 0; i < mFI_NUM_COL_KEEP; i++) { - l_keepcld[i].assumed_ut_x = 0xFF; - l_keepcld[i].assumed_ut_z = 0xFF; - l_keepcld[i].unk_C = 0; - } + for (i = 0; i < mFI_NUM_COL_KEEP; i++) { + l_keepcld[i].assumed_ut_x = 0xFF; + l_keepcld[i].assumed_ut_z = 0xFF; + l_keepcld[i].unk_C = 0; + } } /* @unused mFI_GetUtColGroup */ @@ -895,723 +853,699 @@ extern void mFI_ClearColKeep() { /* @unused mFI_UtNum2UtColKeep */ extern mCoBG_Collision_u* mFI_GetUnitCol(xyz_t wpos) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { - return &l_edge_ut; - } - else { - return mFI_UtNum2UtCol(ut_x, ut_z); - } + if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { + return &l_edge_ut; + } else { + return mFI_UtNum2UtCol(ut_x, ut_z); + } } extern u8 mFI_UtNum2UtKeepH(int ut_x, int ut_z) { - int b_ut_x; - int b_ut_z; - int bx; - int bz; + int b_ut_x; + int b_ut_z; + int bx; + int bz; - if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { - return mCoBG_HEIGHT_MAX; - } - else if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { - return mCoBG_HEIGHT_MAX; - } - else { - mFM_block_info_c* block; - u8* keep_p; - int num; - int idx; + if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { + return mCoBG_HEIGHT_MAX; + } else if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { + return mCoBG_HEIGHT_MAX; + } else { + mFM_block_info_c* block; + u8* keep_p; + int num; + int idx; - mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); - num = mFI_GetBlockNum(bx, bz); - keep_p = (u8*)g_fdinfo->block_info[num].bg_info.keep_h; - idx = b_ut_z * UT_Z_NUM + b_ut_x; - keep_p += b_ut_z * UT_Z_NUM + b_ut_x; - return keep_p[0]; - } + mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); + num = mFI_GetBlockNum(bx, bz); + keep_p = (u8*)g_fdinfo->block_info[num].bg_info.keep_h; + idx = b_ut_z * UT_Z_NUM + b_ut_x; + keep_p += b_ut_z * UT_Z_NUM + b_ut_x; + return keep_p[0]; + } } extern mFM_bg_sound_source_c* mFI_GetSoundSourcePBlockNum(int bx, int bz) { - mFM_bg_sound_source_c* ss = NULL; + mFM_bg_sound_source_c* ss = NULL; - if (mFI_BlockCheck(bx, bz)) { - int num = mFI_GetBlockNum(bx, bz); - ss = g_fdinfo->block_info[num].bg_info.sound_source; - } + if (mFI_BlockCheck(bx, bz)) { + int num = mFI_GetBlockNum(bx, bz); + ss = g_fdinfo->block_info[num].bg_info.sound_source; + } - return ss; + return ss; } extern Gfx* mFI_GetBGDisplayListRom(int bx, int bz) { - Gfx* gfx; - int num = mFI_GetBlockNum(bx, bz); + Gfx* gfx; + int num = mFI_GetBlockNum(bx, bz); - if (mFI_BlockCheck(bx, bz) == FALSE) { - gfx = NULL; - } - else { - gfx = g_fdinfo->block_info[num].bg_info.opaque_gfx; - } + if (mFI_BlockCheck(bx, bz) == FALSE) { + gfx = NULL; + } else { + gfx = g_fdinfo->block_info[num].bg_info.opaque_gfx; + } - return gfx; + return gfx; } extern Gfx* mFI_GetBGDisplayListRom_XLU(int bx, int bz) { - Gfx* gfx; - int num = mFI_GetBlockNum(bx, bz); + Gfx* gfx; + int num = mFI_GetBlockNum(bx, bz); - if (mFI_BlockCheck(bx, bz) == FALSE) { - gfx = NULL; - } - else { - gfx = g_fdinfo->block_info[num].bg_info.translucent_gfx; - } + if (mFI_BlockCheck(bx, bz) == FALSE) { + gfx = NULL; + } else { + gfx = g_fdinfo->block_info[num].bg_info.translucent_gfx; + } - return gfx; + return gfx; } extern EVW_ANIME_DATA* mFI_GetBGTexAnimInfo(s8* anim_num, int bx, int bz) { - EVW_ANIME_DATA* anime; - int num = mFI_GetBlockNum(bx, bz); + EVW_ANIME_DATA* anime; + int num = mFI_GetBlockNum(bx, bz); - if (mFI_BlockCheck(bx, bz) == FALSE) { - anime = NULL; - anim_num[0] = 0; - } - else { - anime = g_fdinfo->block_info[num].bg_info.animation; - anim_num[0] = g_fdinfo->block_info[num].bg_info.animation_count; - } + if (mFI_BlockCheck(bx, bz) == FALSE) { + anime = NULL; + anim_num[0] = 0; + } else { + anime = g_fdinfo->block_info[num].bg_info.animation; + anim_num[0] = g_fdinfo->block_info[num].bg_info.animation_count; + } - return anime; + return anime; } static int mFI_BGDispMatch(int* idx, int bx, int bz) { - int max = g_fdinfo->bg_num; - int res = FALSE; - int i; + int max = g_fdinfo->bg_num; + int res = FALSE; + int i; - for (i = 0; i < max; i++) { - idx[0] = i; - - if (g_fdinfo->bg_draw_info[i].block_x == bx && g_fdinfo->bg_draw_info[i].block_z == bz) { - res = TRUE; - break; + for (i = 0; i < max; i++) { + idx[0] = i; + + if (g_fdinfo->bg_draw_info[i].block_x == bx && g_fdinfo->bg_draw_info[i].block_z == bz) { + res = TRUE; + break; + } } - } - return res; + return res; } static int mFI_SearchNullDisp(int* idx) { - int res = FALSE; - int free_idx = mFI_GetFreeRegisterBgInfo(); + int res = FALSE; + int free_idx = mFI_GetFreeRegisterBgInfo(); - if (free_idx != -1) { - idx[0] = free_idx; - res = TRUE; - } - else { - idx[0] = g_fdinfo->bg_num; - } + if (free_idx != -1) { + idx[0] = free_idx; + res = TRUE; + } else { + idx[0] = g_fdinfo->bg_num; + } - return res; + return res; } static void mFI_BGDispMake(u8* disp_bitfield, int bx, int bz) { - int num = mFI_GetBlockNum(bx, bz); - int idx; - - if (mFI_BGDispMatch(&idx, bx, bz) == FALSE) { - if (mFI_SearchNullDisp(&idx)) { - mFI_SetRegisterBgInfo(idx, g_fdinfo->block_info[num].bg_info.rom_start_addr, g_fdinfo->block_info[num].bg_info.rom_size); - g_fdinfo->bg_draw_info[idx].block_x = bx; - g_fdinfo->bg_draw_info[idx].block_z = bz; - disp_bitfield[0] |= (1 << idx); + int num = mFI_GetBlockNum(bx, bz); + int idx; + + if (mFI_BGDispMatch(&idx, bx, bz) == FALSE) { + if (mFI_SearchNullDisp(&idx)) { + mFI_SetRegisterBgInfo(idx, g_fdinfo->block_info[num].bg_info.rom_start_addr, + g_fdinfo->block_info[num].bg_info.rom_size); + g_fdinfo->bg_draw_info[idx].block_x = bx; + g_fdinfo->bg_draw_info[idx].block_z = bz; + disp_bitfield[0] |= (1 << idx); + } + } else { + disp_bitfield[0] |= (1 << idx); } - } - else { - disp_bitfield[0] |= (1 << idx); - } } typedef struct block_area_info_s { - int initialized; - int _04; - f32 area[6]; + int initialized; + int _04; + f32 area[6]; } mFI_block_area_info_c; static mFI_block_area_info_c l_barea; extern void mFI_InitAreaInfo() { - static f32 area_table[6] = { - /* X position */ - 280.0f, /* x = [0, 6] */ - 360.0f, /* x = [7, 8] */ - 640.0f, /* x = [9, 15] */ + static f32 area_table[6] = { + /* X position */ + 280.0f, /* x = [0, 6] */ + 360.0f, /* x = [7, 8] */ + 640.0f, /* x = [9, 15] */ - /* Z position */ - 380.0f, /* z = [0, 9.5) */ - 400.0f, /* z = [9.5, 10)*/ - 640.0f /* z = [10, 15] */ - }; + /* Z position */ + 380.0f, /* z = [0, 9.5) */ + 400.0f, /* z = [9.5, 10)*/ + 640.0f /* z = [10, 15] */ + }; - int i; + int i; - l_barea.initialized = TRUE; - l_barea._04 = 0; + l_barea.initialized = TRUE; + l_barea._04 = 0; - for (i = 0; i < 6; i++) { - l_barea.area[i] = area_table[i]; - } + for (i = 0; i < 6; i++) { + l_barea.area[i] = area_table[i]; + } } static void mFI_WhereisInBlock(u8* pos_bitfield, xyz_t wpos) { - xyz_t lpos; - int i; + xyz_t lpos; + int i; - mFI_WpostoLposInBK(&lpos, wpos); + mFI_WpostoLposInBK(&lpos, wpos); - if (lpos.x >= 0.0f) { - for (i = 0; i < 3; i++) { - if (lpos.x < l_barea.area[i]) { - pos_bitfield[0] |= (1 << i); - break; - } + if (lpos.x >= 0.0f) { + for (i = 0; i < 3; i++) { + if (lpos.x < l_barea.area[i]) { + pos_bitfield[0] |= (1 << i); + break; + } + } } - } - if (lpos.z >= 0.0f) { - for (i = 3; i < 6; i++) { - if (lpos.z < l_barea.area[i]) { - pos_bitfield[0] |= (1 << i); - break; - } + if (lpos.z >= 0.0f) { + for (i = 3; i < 6; i++) { + if (lpos.z < l_barea.area[i]) { + pos_bitfield[0] |= (1 << i); + break; + } + } } - } } extern void mFI_BGDisplayListRefresh(xyz_t wpos) { - u8 disp_bitfield; - u8 where_bitfield; - int bx; - int bz; - int i; - int nearest_bx; - int nearest_bz; - int num; - int temp; + u8 disp_bitfield; + u8 where_bitfield; + int bx; + int bz; + int i; + int nearest_bx; + int nearest_bz; + int num; + int temp; - disp_bitfield = 0; - where_bitfield = 0; - Common_Set(remove_cut_tree_info_bitfield, 0); - if (mFI_Wpos2BlockNum(&bx, &bz, wpos)) { - num = mFI_GetBlockNum(bx, bz); + disp_bitfield = 0; + where_bitfield = 0; + Common_Set(remove_cut_tree_info_bitfield, 0); + if (mFI_Wpos2BlockNum(&bx, &bz, wpos)) { + num = mFI_GetBlockNum(bx, bz); - if (g_fdinfo->block_info[num].bg_info.bg_id.combination_type != 292) { - mFI_BGDispMake(&disp_bitfield, bx, bz); - } - } - - mFI_WhereisInBlock(&where_bitfield, wpos); - - /* Check if the acres to the immediate left or right should be displayed */ - nearest_bx = bx - 1; - if ((where_bitfield & 1) != 0 && mFI_BlockCheck(nearest_bx, bz)) { - mFI_BGDispMake(&disp_bitfield, nearest_bx, bz); - } - else { - nearest_bx = bx + 1; - if (((where_bitfield >> 2) & 1) != 0 && mFI_BlockCheck(nearest_bx, bz)) { - mFI_BGDispMake(&disp_bitfield, nearest_bx, bz); - } - } - - nearest_bz = bz - 1; - if (((where_bitfield >> 3) & 1) != 0 && mFI_BlockCheck(bx, nearest_bz)) { - mFI_BGDispMake(&disp_bitfield, bx, nearest_bz); /* display acre immediately above */ - - nearest_bx = bx - 1; - if ((where_bitfield & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { - mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre above and to the left */ - } - else { - nearest_bx = bx + 1; - if (((where_bitfield >> 2) & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { - mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre above and to the right */ - } - } - } - else { - nearest_bz = bz + 1; - - if (((where_bitfield >> 5) & 1) != 0 && mFI_BlockCheck(bx, nearest_bz)) { - mFI_BGDispMake(&disp_bitfield, bx, nearest_bz); /* display acre immediately below */ - - nearest_bx = bx - 1; - if ((where_bitfield & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { - mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre below and to the left */ - } - else { - nearest_bx = bx + 1; - if (((where_bitfield >> 2) & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { - mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre below and to the right */ + if (g_fdinfo->block_info[num].bg_info.bg_id.combination_type != 292) { + mFI_BGDispMake(&disp_bitfield, bx, bz); } - } } - } - - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - if (((disp_bitfield >> i) & 1) != 1) { - g_fdinfo->bg_draw_info[i].dma_loaded = FALSE; - g_fdinfo->bg_draw_info[i].block_x = 0xFF; - g_fdinfo->bg_draw_info[i].block_z = 0xFF; - mFI_ClearRegisterBgInfoIdx(i); + + mFI_WhereisInBlock(&where_bitfield, wpos); + + /* Check if the acres to the immediate left or right should be displayed */ + nearest_bx = bx - 1; + if ((where_bitfield & 1) != 0 && mFI_BlockCheck(nearest_bx, bz)) { + mFI_BGDispMake(&disp_bitfield, nearest_bx, bz); + } else { + nearest_bx = bx + 1; + if (((where_bitfield >> 2) & 1) != 0 && mFI_BlockCheck(nearest_bx, bz)) { + mFI_BGDispMake(&disp_bitfield, nearest_bx, bz); + } + } + + nearest_bz = bz - 1; + if (((where_bitfield >> 3) & 1) != 0 && mFI_BlockCheck(bx, nearest_bz)) { + mFI_BGDispMake(&disp_bitfield, bx, nearest_bz); /* display acre immediately above */ + + nearest_bx = bx - 1; + if ((where_bitfield & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { + mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre above and to the left */ + } else { + nearest_bx = bx + 1; + if (((where_bitfield >> 2) & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { + mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre above and to the right */ + } + } + } else { + nearest_bz = bz + 1; + + if (((where_bitfield >> 5) & 1) != 0 && mFI_BlockCheck(bx, nearest_bz)) { + mFI_BGDispMake(&disp_bitfield, bx, nearest_bz); /* display acre immediately below */ + + nearest_bx = bx - 1; + if ((where_bitfield & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { + mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre below and to the left */ + } else { + nearest_bx = bx + 1; + if (((where_bitfield >> 2) & 1) != 0 && mFI_BlockCheck(nearest_bx, nearest_bz)) { + mFI_BGDispMake(&disp_bitfield, nearest_bx, nearest_bz); /* display acre below and to the right */ + } + } + } + } + + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + if (((disp_bitfield >> i) & 1) != 1) { + g_fdinfo->bg_draw_info[i].dma_loaded = FALSE; + g_fdinfo->bg_draw_info[i].block_x = 0xFF; + g_fdinfo->bg_draw_info[i].block_z = 0xFF; + mFI_ClearRegisterBgInfoIdx(i); + } } - } } static u32 l_mfi_player_bk_kind; static void mFI_SetPlayerBlockKind(xyz_t wpos) { - u32* dst = &l_mfi_player_bk_kind; - int bx; - int bz; + u32* dst = &l_mfi_player_bk_kind; + int bx; + int bz; - dst[0] = mRF_BLOCKKIND_NONE; - - if (mFI_Wpos2BlockNum(&bx, &bz, wpos) == TRUE) { - dst[0] = mFI_BkNum2BlockKind(bx, bz); - } + dst[0] = mRF_BLOCKKIND_NONE; + + if (mFI_Wpos2BlockNum(&bx, &bz, wpos) == TRUE) { + dst[0] = mFI_BkNum2BlockKind(bx, bz); + } } extern int mFI_CheckInIsland() { - int res = FALSE; + int res = FALSE; - if ((l_mfi_player_bk_kind & mRF_BLOCKKIND_OCEAN) || Save_Get(scene_no) == SCENE_COTTAGE_MY || Save_Get(scene_no) == SCENE_COTTAGE_NPC) { - res = TRUE; - } + if ((l_mfi_player_bk_kind & mRF_BLOCKKIND_OCEAN) || Save_Get(scene_no) == SCENE_COTTAGE_MY || + Save_Get(scene_no) == SCENE_COTTAGE_NPC) { + res = TRUE; + } - return res; + return res; } extern int mFI_CheckInJustIslandOutdoor() { - if (Save_Get(scene_no) == SCENE_FG && (l_mfi_player_bk_kind & mRF_BLOCKKIND_ISLAND)) { - return TRUE; - } + if (Save_Get(scene_no) == SCENE_FG && (l_mfi_player_bk_kind & mRF_BLOCKKIND_ISLAND)) { + return TRUE; + } - return FALSE; + return FALSE; } extern u32 mFI_CheckPlayerBlockInfo() { - return l_mfi_player_bk_kind; + return l_mfi_player_bk_kind; } extern mActor_name_t* mFI_BkNumtoUtFGTop(int bx, int bz) { - mActor_name_t* fg_top = NULL; + mActor_name_t* fg_top = NULL; - if (mFI_CheckFieldData() && mFI_BlockCheck(bx, bz)) { - int num = mFI_GetBlockNum(bx, bz); + if (mFI_CheckFieldData() && mFI_BlockCheck(bx, bz)) { + int num = mFI_GetBlockNum(bx, bz); - fg_top = g_fdinfo->block_info[num].fg_info.items_p; - } + fg_top = g_fdinfo->block_info[num].fg_info.items_p; + } - return fg_top; + return fg_top; } extern mActor_name_t* mFI_BkNum2UtFGTop_layer(int bx, int bz, int layer) { - mActor_name_t* fg_layer_top = NULL; + mActor_name_t* fg_layer_top = NULL; - if (mFI_CheckFieldData() && g_fdinfo->fg2_p != NULL && bx == 0 && bz == 0) { - if (layer == 0) { - fg_layer_top = mFI_BkNumtoUtFGTop(bx, bz); + if (mFI_CheckFieldData() && g_fdinfo->fg2_p != NULL && bx == 0 && bz == 0) { + if (layer == 0) { + fg_layer_top = mFI_BkNumtoUtFGTop(bx, bz); + } else if (layer > 0 && layer < mHm_LAYER_NUM) { + fg_layer_top = g_fdinfo->fg2_p[layer - 1]; + } } - else if (layer > 0 && layer < mHm_LAYER_NUM) { - fg_layer_top = g_fdinfo->fg2_p[layer - 1]; - } - } - return fg_layer_top; + return fg_layer_top; } extern mActor_name_t* mFI_UtNum2UtFG(int ut_x, int ut_z) { - int bx; - int bz; + int bx; + int bz; - if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { - return NULL; - } - else if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { - return NULL; - } - else { - int b_ut_x; - int b_ut_z; - int num; - mActor_name_t* fg_p; + if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { + return NULL; + } else if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { + return NULL; + } else { + int b_ut_x; + int b_ut_z; + int num; + mActor_name_t* fg_p; - mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); - num = mFI_GetBlockNum(bx, bz); - fg_p = g_fdinfo->block_info[num].fg_info.items_p; + mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); + num = mFI_GetBlockNum(bx, bz); + fg_p = g_fdinfo->block_info[num].fg_info.items_p; - if (fg_p == NULL) { - return NULL; + if (fg_p == NULL) { + return NULL; + } else { + int idx = b_ut_z * UT_X_NUM + b_ut_x; + fg_p += idx; + return fg_p; + } } - else { - int idx = b_ut_z * UT_X_NUM + b_ut_x; - fg_p += idx; - return fg_p; - } - } } static mActor_name_t* mFI_UtNum2UtFG2(int ut_x, int ut_z) { - mActor_name_t* fg2 = NULL; - int bx; - int bz; - int b_ut_x; - int b_ut_z; + mActor_name_t* fg2 = NULL; + int bx; + int bz; + int b_ut_x; + int b_ut_z; - if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) && mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z)) { - mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); - fg2 = mFI_BkNum2UtFGTop_layer(bx, bz, 1); + if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) && + mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z)) { + mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); + fg2 = mFI_BkNum2UtFGTop_layer(bx, bz, 1); - if (fg2 != NULL) { - int idx = b_ut_z * UT_Z_NUM + b_ut_x; - fg2 += idx; + if (fg2 != NULL) { + int idx = b_ut_z * UT_Z_NUM + b_ut_x; + fg2 += idx; + } } - } - return fg2; + return fg2; } extern mActor_name_t* mFI_GetUnitFG(xyz_t wpos) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { - return NULL; - } - else { - return mFI_UtNum2UtFG(ut_x, ut_z); - } + if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { + return NULL; + } else { + return mFI_UtNum2UtFG(ut_x, ut_z); + } } extern mActor_name_t* mFI_GetUnitFG2(xyz_t wpos) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { - return NULL; - } - else { - return mFI_UtNum2UtFG2(ut_x, ut_z); - } + if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { + return NULL; + } else { + return mFI_UtNum2UtFG2(ut_x, ut_z); + } } extern int mFI_GetBlockUtNum2FG(mActor_name_t* item, int bx, int bz, int ut_x, int ut_z) { - int res = FALSE; + int res = FALSE; - if ( - mFI_BlockCheck(bx, bz) && - (ut_x >= 0 && ut_x < UT_X_NUM) && - (ut_z >= 0 && ut_z < UT_Z_NUM) - ) { - int num = mFI_GetBlockNum(bx, bz); - int ut_num = mFI_GetUtNum(ut_x, ut_z); + if (mFI_BlockCheck(bx, bz) && (ut_x >= 0 && ut_x < UT_X_NUM) && (ut_z >= 0 && ut_z < UT_Z_NUM)) { + int num = mFI_GetBlockNum(bx, bz); + int ut_num = mFI_GetUtNum(ut_x, ut_z); - res = TRUE; - item[0] = g_fdinfo->block_info[num].fg_info.items_p[ut_num]; - } - else { - item[0] = RSV_NO; - } + res = TRUE; + item[0] = g_fdinfo->block_info[num].fg_info.items_p[ut_num]; + } else { + item[0] = RSV_NO; + } - return res; + return res; } extern int mFI_BlockUtNumtoFGSet(mActor_name_t item, int bx, int bz, int ut_x, int ut_z) { - int res = FALSE; - mActor_name_t* fg_p = mFI_BkNumtoUtFGTop(bx, bz); + int res = FALSE; + mActor_name_t* fg_p = mFI_BkNumtoUtFGTop(bx, bz); - if ( - fg_p != NULL && - (ut_x >= 0 && ut_x < UT_X_NUM) && - (ut_z >= 0 && ut_z < UT_Z_NUM) - ) { - int ut_num = mFI_GetUtNum(ut_x, ut_z); - - res = TRUE; - fg_p[ut_num] = item; - } + if (fg_p != NULL && (ut_x >= 0 && ut_x < UT_X_NUM) && (ut_z >= 0 && ut_z < UT_Z_NUM)) { + int ut_num = mFI_GetUtNum(ut_x, ut_z); - return res; + res = TRUE; + fg_p[ut_num] = item; + } + + return res; } extern int mFI_UtNumtoFGSet_common(mActor_name_t item, int ut_x, int ut_z, int update) { - int bx; - int bz; - int b_ut_x; - int b_ut_z; - int block_num; - int ut_num; + int bx; + int bz; + int b_ut_x; + int b_ut_z; + int block_num; + int ut_num; - if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { - return FALSE; - } + if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == FALSE) { + return FALSE; + } - if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { - return FALSE; - } + if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == FALSE) { + return FALSE; + } - block_num = mFI_GetBlockNum(bx, bz); - if (g_fdinfo->block_info[block_num].fg_info.fg_id == 203) { - return FALSE; - } + block_num = mFI_GetBlockNum(bx, bz); + if (g_fdinfo->block_info[block_num].fg_info.fg_id == 203) { + return FALSE; + } - mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); - ut_num = mFI_GetUtNum(b_ut_x, b_ut_z); - g_fdinfo->block_info[block_num].fg_info.items_p[ut_num] = item; + mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); + ut_num = mFI_GetUtNum(b_ut_x, b_ut_z); + g_fdinfo->block_info[block_num].fg_info.items_p[ut_num] = item; - if (update) { - mFI_SetFGUpData(); - } + if (update) { + mFI_SetFGUpData(); + } - return TRUE; + return TRUE; } static int mFI_UtNum2FGSet_layer(mActor_name_t item, int ut_x, int ut_z, int layer) { - int bx; - int bz; - int b_ut_x; - int b_ut_z; - int num; - int res = FALSE; + int bx; + int bz; + int b_ut_x; + int b_ut_z; + int num; + int res = FALSE; - if ( - mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == TRUE && - mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == TRUE - ) { - mActor_name_t* fg_layer_p = mFI_BkNum2UtFGTop_layer(bx, bz, layer); + if (mFI_UtNumCheck(ut_x, ut_z, mFI_GetBlockXMax(), mFI_GetBlockZMax()) == TRUE && + mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == TRUE) { + mActor_name_t* fg_layer_p = mFI_BkNum2UtFGTop_layer(bx, bz, layer); - if (fg_layer_p != NULL) { - mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); - num = mFI_GetUtNum(b_ut_x, b_ut_z); - fg_layer_p[num] = item; - mFI_SetFGUpData(); - res = TRUE; + if (fg_layer_p != NULL) { + mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); + num = mFI_GetUtNum(b_ut_x, b_ut_z); + fg_layer_p[num] = item; + mFI_SetFGUpData(); + res = TRUE; + } } - } - return res; + return res; } extern int mFI_SetFG_common(mActor_name_t item, xyz_t wpos, int update) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { - return FALSE; - } + if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == FALSE) { + return FALSE; + } - return mFI_UtNumtoFGSet_common(item, ut_x, ut_z, update); + return mFI_UtNumtoFGSet_common(item, ut_x, ut_z, update); } extern int mFI_SetFG2(mActor_name_t item, xyz_t wpos) { - int ut_x; - int ut_z; - int res = FALSE; + int ut_x; + int ut_z; + int res = FALSE; - if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == TRUE) { - mFI_UtNum2FGSet_layer(item, ut_x, ut_z, 1); - res = TRUE; - } + if (mFI_Wpos2UtNum(&ut_x, &ut_z, wpos) == TRUE) { + mFI_UtNum2FGSet_layer(item, ut_x, ut_z, 1); + res = TRUE; + } - return res; + return res; } extern void mFI_InitItemTable(mFI_item_table_c* vis_block_info) { - mFI_block_tbl_c* block_table = vis_block_info->block_info_tbl; - int i; + mFI_block_tbl_c* block_table = vis_block_info->block_info_tbl; + int i; - vis_block_info->count = 0; - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - block_table->block_x = -1; - block_table->block_z = -1; - block_table->pos_x = 0.0f; - block_table->pos_z = 0.0f; - block_table->items = NULL; + vis_block_info->count = 0; + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + block_table->block_x = -1; + block_table->block_z = -1; + block_table->pos_x = 0.0f; + block_table->pos_z = 0.0f; + block_table->items = NULL; - /* @BUG - they forgot to increment the pointer */ - #ifdef BUGFIXES - block_table++; - #endif - } +/* @BUG - they forgot to increment the pointer */ +#ifdef BUGFIXES + block_table++; +#endif + } } static void mFI_SetOldItemTableIdx(int n, int idx) { - g_fdinfo->last_bg_idx[n] = idx; + g_fdinfo->last_bg_idx[n] = idx; } extern int mFI_GetOldItemTableIdx(int n) { - return g_fdinfo->last_bg_idx[n]; + return g_fdinfo->last_bg_idx[n]; } -static void mFI_MakeOldItemTableIdxTable(mFI_block_tbl_c* block_table, int count, int* block_x_tbl, int* block_z_tbl, int num) { - int i; - int j; +static void mFI_MakeOldItemTableIdxTable(mFI_block_tbl_c* block_table, int count, int* block_x_tbl, int* block_z_tbl, + int num) { + int i; + int j; - for (i = 0; i < count; i++) { - if ((int)block_table->block_x != -1 && (int)block_table->block_z != -1) { - int* bx_p = block_x_tbl; - int* bz_p = block_z_tbl; - - for (j = 0; j < num; j++) { - if (*bx_p == block_table->block_x && *bz_p == block_table->block_z) { - mFI_SetOldItemTableIdx(i, j); - break; + for (i = 0; i < count; i++) { + if ((int)block_table->block_x != -1 && (int)block_table->block_z != -1) { + int* bx_p = block_x_tbl; + int* bz_p = block_z_tbl; + + for (j = 0; j < num; j++) { + if (*bx_p == block_table->block_x && *bz_p == block_table->block_z) { + mFI_SetOldItemTableIdx(i, j); + break; + } + bx_p++; + bz_p++; + } + + if (j == num) { + mFI_SetOldItemTableIdx(i, -1); + } } - bx_p++; - bz_p++; - } - if (j == num) { - mFI_SetOldItemTableIdx(i, -1); - } + block_table++; } - - block_table++; - } } static void mFI_SetBlockTable(mFI_block_tbl_c* block_table, int bx, int bz) { - f32 x = 0.0f; - f32 z = 0.0f; - int num = mFI_GetBlockNum(bx, bz); + f32 x = 0.0f; + f32 z = 0.0f; + int num = mFI_GetBlockNum(bx, bz); - block_table->items = g_fdinfo->block_info[num].fg_info.items_p; - block_table->block_x = bx; - block_table->block_z = bz; + block_table->items = g_fdinfo->block_info[num].fg_info.items_p; + block_table->block_x = bx; + block_table->block_z = bz; - mFI_BkNum2WposXZ(&x, &z, bx, bz); - block_table->pos_x = x; - block_table->pos_z = z; + mFI_BkNum2WposXZ(&x, &z, bx, bz); + block_table->pos_x = x; + block_table->pos_z = z; } extern int mFI_GetItemTable_NoReset(mFI_item_table_c* item_table, xyz_t wpos) { - static int table_no[3] = { 0, 1, 1 }; - static int check_x[3] = { 0, 1, -1 }; + static int table_no[3] = { 0, 1, 1 }; + static int check_x[3] = { 0, 1, -1 }; - mFM_field_draw_info_c* bg_disp = mFI_BGDisplayListTop(); - int t_no; - u8 _num = 0; - u8 _bitfield = 0; - u8 clear_tree_cut_bitfield = 0; - int bx; - int bz; - int block_x_tbl[mFM_VISIBLE_BLOCK_NUM]; - int block_z_tbl[mFM_VISIBLE_BLOCK_NUM]; - int i; - int j; + mFM_field_draw_info_c* bg_disp = mFI_BGDisplayListTop(); + int t_no; + u8 _num = 0; + u8 _bitfield = 0; + u8 clear_tree_cut_bitfield = 0; + int bx; + int bz; + int block_x_tbl[mFM_VISIBLE_BLOCK_NUM]; + int block_z_tbl[mFM_VISIBLE_BLOCK_NUM]; + int i; + int j; - if (mFI_Wpos2BlockNum(&bx, &bz, wpos) == FALSE) { - return FALSE; - } + if (mFI_Wpos2BlockNum(&bx, &bz, wpos) == FALSE) { + return FALSE; + } - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - block_x_tbl[i] = item_table->block_info_tbl[i].block_x; - block_z_tbl[i] = item_table->block_info_tbl[i].block_z; - } + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + block_x_tbl[i] = item_table->block_info_tbl[i].block_x; + block_z_tbl[i] = item_table->block_info_tbl[i].block_z; + } - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - if (mFI_CheckFinishBgDma(i) == TRUE && bg_disp->block_z == bz) { - for (j = 0; j < 3; j++) { - int bx_near = bx + check_x[j]; - - t_no = table_no[j]; + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + if (mFI_CheckFinishBgDma(i) == TRUE && bg_disp->block_z == bz) { + for (j = 0; j < 3; j++) { + int bx_near = bx + check_x[j]; - if (bg_disp->block_x == bx_near) { - mFI_SetBlockTable(&item_table->block_info_tbl[t_no], bx_near, bz); - _num++; - _bitfield |= (1 << i); + t_no = table_no[j]; - if ((Common_Get(remove_cut_tree_info_bitfield) >> i) & 1) { - clear_tree_cut_bitfield |= (1 << t_no); - } + if (bg_disp->block_x == bx_near) { + mFI_SetBlockTable(&item_table->block_info_tbl[t_no], bx_near, bz); + _num++; + _bitfield |= (1 << i); - break; + if ((Common_Get(remove_cut_tree_info_bitfield) >> i) & 1) { + clear_tree_cut_bitfield |= (1 << t_no); + } + + break; + } + } } - } + + if (_num >= 2) { + break; + } + + bg_disp++; } - if (_num >= 2) { - break; + bg_disp = mFI_BGDisplayListTop(); + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + if (((_bitfield >> i) & 1) == 0 && mFI_CheckFinishBgDma(i) == TRUE && bg_disp->block_x != 0xFF && + bg_disp->block_z != 0xFF) { + mFI_SetBlockTable(&item_table->block_info_tbl[_num], bg_disp->block_x, bg_disp->block_z); + + if ((Common_Get(remove_cut_tree_info_bitfield) >> i) & 1) { + clear_tree_cut_bitfield |= (1 << _num); + } + + _num++; + } + + if (_num >= mFM_VISIBLE_BLOCK_NUM) { + break; + } + + bg_disp++; } - bg_disp++; - } + Common_Set(remove_cut_tree_info_bitfield, clear_tree_cut_bitfield); - bg_disp = mFI_BGDisplayListTop(); - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - if (((_bitfield >> i) & 1) == 0 && mFI_CheckFinishBgDma(i) == TRUE && bg_disp->block_x != 0xFF && bg_disp->block_z != 0xFF) { - mFI_SetBlockTable(&item_table->block_info_tbl[_num], bg_disp->block_x, bg_disp->block_z); - - if ((Common_Get(remove_cut_tree_info_bitfield) >> i) & 1) { - clear_tree_cut_bitfield |= (1 << _num); - } - - _num++; + /* Clear any unused entries */ + for (i = _num; i < mFM_VISIBLE_BLOCK_NUM; i++) { + item_table->block_info_tbl[i].block_x = 0xFF; + item_table->block_info_tbl[i].block_z = 0xFF; } - if (_num >= mFM_VISIBLE_BLOCK_NUM) { - break; - } + mFI_MakeOldItemTableIdxTable(item_table->block_info_tbl, _num, block_x_tbl, block_z_tbl, item_table->count); + item_table->count = _num; - bg_disp++; - } - - Common_Set(remove_cut_tree_info_bitfield, clear_tree_cut_bitfield); - - /* Clear any unused entries */ - for (i = _num; i < mFM_VISIBLE_BLOCK_NUM; i++) { - item_table->block_info_tbl[i].block_x = 0xFF; - item_table->block_info_tbl[i].block_z = 0xFF; - } - - mFI_MakeOldItemTableIdxTable(item_table->block_info_tbl, _num, block_x_tbl, block_z_tbl, item_table->count); - item_table->count = _num; - - return TRUE; + return TRUE; } extern int mFI_GetItemTable(mFI_item_table_c* item_table, xyz_t wpos, char* file, int line) { - g_fdinfo->update_fg = FALSE; - g_fdinfo->born_item = FALSE; - return mFI_GetItemTable_NoReset(item_table, wpos); + g_fdinfo->update_fg = FALSE; + g_fdinfo->born_item = FALSE; + return mFI_GetItemTable_NoReset(item_table, wpos); } extern int mFI_FGisUpDate() { - if (mFI_CheckFieldData()) { - return g_fdinfo->update_fg & 1; - } + if (mFI_CheckFieldData()) { + return g_fdinfo->update_fg & 1; + } - return FALSE; + return FALSE; } extern void mFI_SetFGUpData() { - if (mFI_CheckFieldData()) { - g_fdinfo->update_fg = TRUE; - } + if (mFI_CheckFieldData()) { + g_fdinfo->update_fg = TRUE; + } } /* 50% */ extern void mFI_BornItemON() { - if (mFI_CheckFieldData()) { - g_fdinfo->born_item = TRUE; - } + if (mFI_CheckFieldData()) { + g_fdinfo->born_item = TRUE; + } } /* @unused @fabricated */ @@ -1624,346 +1558,345 @@ extern MATCH_FORCESTRIP void mFI_BornItemOFF() { */ extern int mFI_ItemisBorn() { - return g_fdinfo->born_item & 1; + return g_fdinfo->born_item & 1; } extern int mFI_ActorisBorn() { - return g_fdinfo->born_actor & 1; + return g_fdinfo->born_actor & 1; } extern void mFI_SetBearActor(GAME_PLAY* play, xyz_t wpos, int set_flag) { - int bx; - int bz; + int bx; + int bz; - g_fdinfo->born_actor = TRUE; - mFI_Wpos2BlockNum(&bx, &bz, wpos); + g_fdinfo->born_actor = TRUE; + mFI_Wpos2BlockNum(&bx, &bz, wpos); - if (set_flag == FALSE) { - play->last_block_table.block_x = -1; - play->last_block_table.block_z = -1; - play->last_block_table.items = NULL; - } - else { - mem_copy((u8*)&play->last_block_table, (u8*)&play->block_table, sizeof(mFI_block_tbl_c)); - } + if (set_flag == FALSE) { + play->last_block_table.block_x = -1; + play->last_block_table.block_z = -1; + play->last_block_table.items = NULL; + } else { + mem_copy((u8*)&play->last_block_table, (u8*)&play->block_table, sizeof(mFI_block_tbl_c)); + } - mFI_SetBlockTable(&play->block_table, bx, bz); + mFI_SetBlockTable(&play->block_table, bx, bz); } extern int mFI_search_unit_around(xyz_t* wpos, mActor_name_t item) { - static f32 BI_chk_pos[9 * 2] = { - -40.0f, -40.0f, // x - 1, z - 1 (top-left) - -40.0f, 40.0f, // x - 1, z + 1 (bottom-left) - 40.0f, 40.0f, // x + 1, z + 1 (bottom-right) - 40.0f, -40.0f, // x + 1, z - 1 (top-right) - -40.0f, 0.0f, // x - 1, z (left) - 0.0f, 40.0f, // x, z + 1 (below) - 40.0f, 0.0f, // x + 1, z (right) - 0.0f, -40.0f, // x, z - 1 (above) - 0.0f, 0.0f // x, z (origin) - }; - xyz_t tpos; - mActor_name_t* item_p; - int i = 9; - int res = FALSE; - f32* around = BI_chk_pos; + static f32 BI_chk_pos[9 * 2] = { + -40.0f, -40.0f, // x - 1, z - 1 (top-left) + -40.0f, 40.0f, // x - 1, z + 1 (bottom-left) + 40.0f, 40.0f, // x + 1, z + 1 (bottom-right) + 40.0f, -40.0f, // x + 1, z - 1 (top-right) + -40.0f, 0.0f, // x - 1, z (left) + 0.0f, 40.0f, // x, z + 1 (below) + 40.0f, 0.0f, // x + 1, z (right) + 0.0f, -40.0f, // x, z - 1 (above) + 0.0f, 0.0f // x, z (origin) + }; + xyz_t tpos; + mActor_name_t* item_p; + int i = 9; + int res = FALSE; + f32* around = BI_chk_pos; - while (i != 0) { - i--; + while (i != 0) { + i--; - tpos.x = wpos->x + around[i * 2 + 0]; - tpos.z = wpos->z + around[i * 2 + 1]; + tpos.x = wpos->x + around[i * 2 + 0]; + tpos.z = wpos->z + around[i * 2 + 1]; - item_p = mFI_GetUnitFG(tpos); - if (item_p != NULL && item_p[0] == item) { - xyz_t_move(wpos, &tpos); - res = TRUE; - break; + item_p = mFI_GetUnitFG(tpos); + if (item_p != NULL && item_p[0] == item) { + xyz_t_move(wpos, &tpos); + res = TRUE; + break; + } } - } - return res; + return res; } /* @unused @frabricated */ extern MATCH_FORCESTRIP int mFI_search_unit_around2(xyz_t* wpos, mActor_name_t item) { - static f32 BI_chk_pos[9 * 2] = { - -40.0f, -40.0f, // x - 1, z - 1 (top-left) - -40.0f, 40.0f, // x - 1, z + 1 (bottom-left) - 40.0f, 40.0f, // x + 1, z + 1 (bottom-right) - 40.0f, -40.0f, // x + 1, z - 1 (top-right) - -40.0f, 0.0f, // x - 1, z (left) - 0.0f, 40.0f, // x, z + 1 (below) - 40.0f, 0.0f, // x + 1, z (right) - 0.0f, -40.0f, // x, z - 1 (above) - 0.0f, 0.0f // x, z (origin) - }; - xyz_t tpos; - mActor_name_t* item_p; - int i = 9; - int res = FALSE; - f32* around = BI_chk_pos; + static f32 BI_chk_pos[9 * 2] = { + -40.0f, -40.0f, // x - 1, z - 1 (top-left) + -40.0f, 40.0f, // x - 1, z + 1 (bottom-left) + 40.0f, 40.0f, // x + 1, z + 1 (bottom-right) + 40.0f, -40.0f, // x + 1, z - 1 (top-right) + -40.0f, 0.0f, // x - 1, z (left) + 0.0f, 40.0f, // x, z + 1 (below) + 40.0f, 0.0f, // x + 1, z (right) + 0.0f, -40.0f, // x, z - 1 (above) + 0.0f, 0.0f // x, z (origin) + }; + xyz_t tpos; + mActor_name_t* item_p; + int i = 9; + int res = FALSE; + f32* around = BI_chk_pos; - while (i != 0) { - i--; + while (i != 0) { + i--; - tpos.x = wpos->x + around[i * 2 + 0]; - tpos.z = wpos->z + around[i * 2 + 1]; + tpos.x = wpos->x + around[i * 2 + 0]; + tpos.z = wpos->z + around[i * 2 + 1]; - item_p = mFI_GetUnitFG2(tpos); - if (item_p != NULL && item_p[0] == item) { - xyz_t_move(wpos, &tpos); - res = TRUE; - break; + item_p = mFI_GetUnitFG2(tpos); + if (item_p != NULL && item_p[0] == item) { + xyz_t_move(wpos, &tpos); + res = TRUE; + break; + } } - } - return res; + return res; } extern int mFI_GetItemNumOnBlock(int bx, int bz, mActor_name_t min_item, mActor_name_t max_item) { - mActor_name_t* fg_p = mFI_BkNumtoUtFGTop(bx, bz); - int num = 0; - int i; - - if (fg_p != NULL) { - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (fg_p[0] >= min_item && fg_p[0] <= max_item) { - num++; - } - - fg_p++; - } - } - - return num; -} - -extern int mFI_GetItemNumOnBlockInField(int bx, int bz, mActor_name_t min_item, mActor_name_t max_item) { - mActor_name_t* fg_p = NULL; - int num = 0; - int i; - - if (bx > 0 && bx <= FG_BLOCK_X_NUM && bz > 0 && bz <= FG_BLOCK_Z_NUM) { - fg_p = Save_Get(fg)[bz - 1][bx - 1].items[0]; - } - - if (fg_p != NULL) { - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (fg_p[0] >= min_item && fg_p[0] <= max_item) { - num++; - } - - fg_p++; - } - } - - return num; -} - -extern int mFI_GetItemNumField_BCT(mActor_name_t min_item, mActor_name_t max_item) { - mFM_fg_c* fg = Save_Get(fg[0]); - mActor_name_t* items_p; - int num = 0; - int bz; - - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - int bx; - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - int i; - items_p = fg->items[0]; - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (items_p[0] >= min_item && items_p[0] <= max_item) { - num++; - } - - items_p++; - } - - fg++; - } - } - - return num; -} - -extern int mFI_GetItemNumField(mActor_name_t min_item, mActor_name_t max_item) { - int num = 0; - - /* @BUG - they forgot to actually call the mFI_CheckFieldData func */ - #ifndef BUGFIXES - if (mFI_CheckFieldData) { - #else - if (mFI_CheckFieldData()) { - #endif - int bx_max = mFI_GetBlockXMax(); - int bz_max = mFI_GetBlockZMax(); - - int bz; - int bx; - - for (bz = 0; bz < bz_max; bz++) { - for (bx = 0; bx < bx_max; bx++) { - num += mFI_GetItemNumOnBlock(bx, bz, min_item, max_item); - } - } - } - - return num; -} - -extern int mFI_GetItemNumInBlock(mActor_name_t item, mActor_name_t* fg_items) { - int num = 0; - int i; - - if (fg_items != NULL) { - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (fg_items[0] == item) { - num++; - } - - fg_items++; - } - } - - return num; -} - -extern int mFI_SearchFGInBlock(int* ut_x, int* ut_z, mActor_name_t item, int bx, int bz) { - mActor_name_t* fg_p = mFI_BkNumtoUtFGTop(bx, bz); - int res = FALSE; - - if (fg_p != NULL) { + mActor_name_t* fg_p = mFI_BkNumtoUtFGTop(bx, bz); + int num = 0; int i; - - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (fg_p[0] == item) { - ut_x[0] = i & 15; - ut_z[0] = i >> 4; - res = TRUE; - break; - } - - fg_p++; - } - } - - return res; -} - -extern int mFI_CheckFGExist(mActor_name_t* check_items, int check_item_num) { - mActor_name_t* check_p = check_items; - - if (mFI_CheckFieldData() == TRUE) { - int bx_max = mFI_GetBlockXMax(); - int bz_max = mFI_GetBlockZMax(); - mActor_name_t* fg_p; - - int bz; - - for (bz = 0; bz < bz_max; bz++) { - int bx; - for (bx = 0; bx < bx_max; bx++) { - fg_p = mFI_BkNumtoUtFGTop(bx, bz); - - if (fg_p != NULL) { - int ut; - for (ut = 0; ut < UT_TOTAL_NUM; ut++) { - int i; - check_items = check_p; - - for (i = 0; i < check_item_num; i++) { - if (check_items[0] == fg_p[0]) { - return TRUE; - } - - check_items++; + if (fg_p != NULL) { + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (fg_p[0] >= min_item && fg_p[0] <= max_item) { + num++; } fg_p++; - } } - } } - } - return FALSE; + return num; +} + +extern int mFI_GetItemNumOnBlockInField(int bx, int bz, mActor_name_t min_item, mActor_name_t max_item) { + mActor_name_t* fg_p = NULL; + int num = 0; + int i; + + if (bx > 0 && bx <= FG_BLOCK_X_NUM && bz > 0 && bz <= FG_BLOCK_Z_NUM) { + fg_p = Save_Get(fg)[bz - 1][bx - 1].items[0]; + } + + if (fg_p != NULL) { + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (fg_p[0] >= min_item && fg_p[0] <= max_item) { + num++; + } + + fg_p++; + } + } + + return num; +} + +extern int mFI_GetItemNumField_BCT(mActor_name_t min_item, mActor_name_t max_item) { + mFM_fg_c* fg = Save_Get(fg[0]); + mActor_name_t* items_p; + int num = 0; + int bz; + + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { + int bx; + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { + int i; + items_p = fg->items[0]; + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (items_p[0] >= min_item && items_p[0] <= max_item) { + num++; + } + + items_p++; + } + + fg++; + } + } + + return num; +} + +extern int mFI_GetItemNumField(mActor_name_t min_item, mActor_name_t max_item) { + int num = 0; + +/* @BUG - they forgot to actually call the mFI_CheckFieldData func */ +#ifndef BUGFIXES + if (mFI_CheckFieldData) { +#else + if (mFI_CheckFieldData()) { +#endif + int bx_max = mFI_GetBlockXMax(); + int bz_max = mFI_GetBlockZMax(); + + int bz; + int bx; + + for (bz = 0; bz < bz_max; bz++) { + for (bx = 0; bx < bx_max; bx++) { + num += mFI_GetItemNumOnBlock(bx, bz, min_item, max_item); + } + } + } + + return num; +} + +extern int mFI_GetItemNumInBlock(mActor_name_t item, mActor_name_t* fg_items) { + int num = 0; + int i; + + if (fg_items != NULL) { + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (fg_items[0] == item) { + num++; + } + + fg_items++; + } + } + + return num; +} + +extern int mFI_SearchFGInBlock(int* ut_x, int* ut_z, mActor_name_t item, int bx, int bz) { + mActor_name_t* fg_p = mFI_BkNumtoUtFGTop(bx, bz); + int res = FALSE; + + if (fg_p != NULL) { + int i; + + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (fg_p[0] == item) { + ut_x[0] = i & 15; + ut_z[0] = i >> 4; + res = TRUE; + + break; + } + + fg_p++; + } + } + + return res; +} + +extern int mFI_CheckFGExist(mActor_name_t* check_items, int check_item_num) { + mActor_name_t* check_p = check_items; + + if (mFI_CheckFieldData() == TRUE) { + int bx_max = mFI_GetBlockXMax(); + int bz_max = mFI_GetBlockZMax(); + mActor_name_t* fg_p; + + int bz; + + for (bz = 0; bz < bz_max; bz++) { + int bx; + for (bx = 0; bx < bx_max; bx++) { + fg_p = mFI_BkNumtoUtFGTop(bx, bz); + + if (fg_p != NULL) { + int ut; + for (ut = 0; ut < UT_TOTAL_NUM; ut++) { + int i; + check_items = check_p; + + for (i = 0; i < check_item_num; i++) { + if (check_items[0] == fg_p[0]) { + return TRUE; + } + + check_items++; + } + + fg_p++; + } + } + } + } + } + + return FALSE; } extern u8* mFI_GetHaniwaStepBlock(int bx, int bz) { - u8* haniwa_step_block_p = NULL; + u8* haniwa_step_block_p = NULL; - if (mFI_BlockCheck(bx, bz) == TRUE) { - int num = mFI_GetBlockNum(bx, bz); + if (mFI_BlockCheck(bx, bz) == TRUE) { + int num = mFI_GetBlockNum(bx, bz); - haniwa_step_block_p = g_fdinfo->block_info[num].fg_info.haniwa_step; - } + haniwa_step_block_p = g_fdinfo->block_info[num].fg_info.haniwa_step; + } - return haniwa_step_block_p; + return haniwa_step_block_p; } extern u16 mFI_GetMoveActorBitData(int bx, int bz) { - u16 move_actor_bit_data = 0; + u16 move_actor_bit_data = 0; - if (mFI_BlockCheck(bx, bz)) { - int num = mFI_GetBlockNum(bx, bz); - - move_actor_bit_data = g_fdinfo->block_info[num].fg_info.move_actor_bit_data; - } + if (mFI_BlockCheck(bx, bz)) { + int num = mFI_GetBlockNum(bx, bz); - return move_actor_bit_data; + move_actor_bit_data = g_fdinfo->block_info[num].fg_info.move_actor_bit_data; + } + + return move_actor_bit_data; } static void mFI_MakeMoveActorBitData(int bx, int bz, mFM_move_actor_c* move_actor) { - int num = mFI_GetBlockNum(bx, bz); - u16* move_actor_bit_data_p = &g_fdinfo->block_info[num].fg_info.move_actor_bit_data; - int i; + int num = mFI_GetBlockNum(bx, bz); + u16* move_actor_bit_data_p = &g_fdinfo->block_info[num].fg_info.move_actor_bit_data; + int i; - if (move_actor_bit_data_p != NULL) { - for (i = 0; i < mFM_MOVE_ACTOR_NUM; i++) { - if (move_actor->name_id == EMPTY_NO) { - break; - } + if (move_actor_bit_data_p != NULL) { + for (i = 0; i < mFM_MOVE_ACTOR_NUM; i++) { + if (move_actor->name_id == EMPTY_NO) { + break; + } - move_actor_bit_data_p[0] |= (1 << i); - move_actor++; + move_actor_bit_data_p[0] |= (1 << i); + move_actor++; + } } - } } extern void mFI_SetMoveActorBitData(int bx, int bz, u16 move_actor_bit_data) { - if (mFI_BlockCheck(bx, bz)) { - int num = mFI_GetBlockNum(bx, bz); + if (mFI_BlockCheck(bx, bz)) { + int num = mFI_GetBlockNum(bx, bz); - g_fdinfo->block_info[num].fg_info.move_actor_bit_data = move_actor_bit_data; - } + g_fdinfo->block_info[num].fg_info.move_actor_bit_data = move_actor_bit_data; + } } extern void mFI_SetMoveActorBitData_ON(s16 move_actor_idx, int bx, int bz) { - if (mFI_BlockCheck(bx, bz) && move_actor_idx >= 0 && move_actor_idx < mFM_MOVE_ACTOR_NUM) { - int num = mFI_GetBlockNum(bx, bz); - u16* move_actor_bit_data_p = &g_fdinfo->block_info[num].fg_info.move_actor_bit_data; - u16 data = move_actor_bit_data_p[0]; + if (mFI_BlockCheck(bx, bz) && move_actor_idx >= 0 && move_actor_idx < mFM_MOVE_ACTOR_NUM) { + int num = mFI_GetBlockNum(bx, bz); + u16* move_actor_bit_data_p = &g_fdinfo->block_info[num].fg_info.move_actor_bit_data; + u16 data = move_actor_bit_data_p[0]; - move_actor_bit_data_p[0] = data | (1 << move_actor_idx); - } + move_actor_bit_data_p[0] = data | (1 << move_actor_idx); + } } extern void mFI_SetMoveActorBitData_OFF(s16 move_actor_idx, int bx, int bz) { - if (mFI_BlockCheck(bx, bz) && move_actor_idx >= 0 && move_actor_idx < mFM_MOVE_ACTOR_NUM) { - int num = mFI_GetBlockNum(bx, bz); - u16* move_actor_bit_data_p = &g_fdinfo->block_info[num].fg_info.move_actor_bit_data; - u16 data = move_actor_bit_data_p[0]; + if (mFI_BlockCheck(bx, bz) && move_actor_idx >= 0 && move_actor_idx < mFM_MOVE_ACTOR_NUM) { + int num = mFI_GetBlockNum(bx, bz); + u16* move_actor_bit_data_p = &g_fdinfo->block_info[num].fg_info.move_actor_bit_data; + u16 data = move_actor_bit_data_p[0]; - move_actor_bit_data_p[0] = data & ~(1 << move_actor_idx); - } + move_actor_bit_data_p[0] = data & ~(1 << move_actor_idx); + } } extern void mFI_MyMoveActorBitData_ON(ACTOR* actor) { - if (actor != NULL) { - mFI_SetMoveActorBitData_ON(actor->move_actor_list_idx, actor->block_x, actor->block_z); - } + if (actor != NULL) { + mFI_SetMoveActorBitData_ON(actor->move_actor_list_idx, actor->block_x, actor->block_z); + } } /* @unused @fabricated */ @@ -1976,215 +1909,209 @@ extern MATCH_FORCESTRIP void mFI_MyMoveActorBitData_OFF(ACTOR* actor) { */ extern int mFI_GetMoveActorListIdx(mFM_move_actor_c* move_actor_list, int list_size, mActor_name_t actor_name) { - int idx = -1; - int i; + int idx = -1; + int i; - for (i = 0; i < list_size; i++) { - if (move_actor_list->name_id == actor_name) { - idx = i; - break; + for (i = 0; i < list_size; i++) { + if (move_actor_list->name_id == actor_name) { + idx = i; + break; + } + + move_actor_list++; } - move_actor_list++; - } - - return idx; + return idx; } -extern int mFI_RegistMoveActorList(mActor_name_t actor_name, int bx, int bz, int ut_x, int ut_z, int npc_info_idx, s16 arg) { - int num = mFI_GetBlockNum(bx, bz); - mFM_move_actor_c* move_actor_list = g_fdinfo->block_info[num].fg_info.move_actors; - int res = FALSE; +extern int mFI_RegistMoveActorList(mActor_name_t actor_name, int bx, int bz, int ut_x, int ut_z, int npc_info_idx, + s16 arg) { + int num = mFI_GetBlockNum(bx, bz); + mFM_move_actor_c* move_actor_list = g_fdinfo->block_info[num].fg_info.move_actors; + int res = FALSE; - if (move_actor_list != NULL) { - int idx = mFI_GetMoveActorListIdx(move_actor_list, mFM_MOVE_ACTOR_NUM, EMPTY_NO); + if (move_actor_list != NULL) { + int idx = mFI_GetMoveActorListIdx(move_actor_list, mFM_MOVE_ACTOR_NUM, EMPTY_NO); - if (idx != -1) { - move_actor_list[idx].name_id = actor_name; - move_actor_list[idx].ut_x = ut_x; - move_actor_list[idx].ut_z = ut_z; - move_actor_list[idx].npc_info_idx = npc_info_idx; - move_actor_list[idx].arg = arg; - mFI_SetMoveActorBitData_ON(idx, bx, bz); - res = TRUE; + if (idx != -1) { + move_actor_list[idx].name_id = actor_name; + move_actor_list[idx].ut_x = ut_x; + move_actor_list[idx].ut_z = ut_z; + move_actor_list[idx].npc_info_idx = npc_info_idx; + move_actor_list[idx].arg = arg; + mFI_SetMoveActorBitData_ON(idx, bx, bz); + res = TRUE; + } } - } - return res; + return res; } extern int mFI_UnregistMoveActorList(mActor_name_t actor_name, int bx, int bz) { - int num = mFI_GetBlockNum(bx, bz); - mFM_move_actor_c* move_actor_list = g_fdinfo->block_info[num].fg_info.move_actors; - int res = FALSE; + int num = mFI_GetBlockNum(bx, bz); + mFM_move_actor_c* move_actor_list = g_fdinfo->block_info[num].fg_info.move_actors; + int res = FALSE; - if (move_actor_list != NULL) { - int idx = mFI_GetMoveActorListIdx(move_actor_list, mFM_MOVE_ACTOR_NUM, actor_name); + if (move_actor_list != NULL) { + int idx = mFI_GetMoveActorListIdx(move_actor_list, mFM_MOVE_ACTOR_NUM, actor_name); - if (idx != -1) { - move_actor_list[idx].name_id = EMPTY_NO; - mFI_SetMoveActorBitData_OFF(idx, bx, bz); - res = TRUE; + if (idx != -1) { + move_actor_list[idx].name_id = EMPTY_NO; + mFI_SetMoveActorBitData_OFF(idx, bx, bz); + res = TRUE; + } } - } - return res; + return res; } extern int mFI_AddMoveActorList(mActor_name_t actor_name, int bx, int bz, int ut_x, int ut_z, s16 arg) { - int res = FALSE; + int res = FALSE; - if (ITEM_NAME_GET_TYPE(actor_name) == NAME_TYPE_ITEM2 && mFI_BlockCheck(bx, bz)) { - res = mFI_RegistMoveActorList(actor_name, bx, bz, ut_x, ut_z, -1, arg); - } + if (ITEM_NAME_GET_TYPE(actor_name) == NAME_TYPE_ITEM2 && mFI_BlockCheck(bx, bz)) { + res = mFI_RegistMoveActorList(actor_name, bx, bz, ut_x, ut_z, -1, arg); + } - return res; + return res; } extern mFM_move_actor_c* mFI_MoveActorListDma(int bx, int bz) { - static mFM_move_actor_c l_aclist[mFM_MOVE_ACTOR_NUM]; + static mFM_move_actor_c l_aclist[mFM_MOVE_ACTOR_NUM]; - mFM_move_actor_c* move_actor_list = NULL; - int num = mFI_GetBlockNum(bx, bz); + mFM_move_actor_c* move_actor_list = NULL; + int num = mFI_GetBlockNum(bx, bz); - if (mFI_BlockCheck(bx, bz)) { - move_actor_list = l_aclist; - bcopy(g_fdinfo->block_info[num].fg_info.move_actors, move_actor_list, mFM_MOVE_ACTOR_NUM * sizeof(mFM_move_actor_c)); - } + if (mFI_BlockCheck(bx, bz)) { + move_actor_list = l_aclist; + bcopy(g_fdinfo->block_info[num].fg_info.move_actors, move_actor_list, + mFM_MOVE_ACTOR_NUM * sizeof(mFM_move_actor_c)); + } - return move_actor_list; + return move_actor_list; } extern void mFI_InitMoveActorBitData() { - int bx_max = mFI_GetBlockXMax(); - int bz_max = mFI_GetBlockZMax(); - int bz; - - for (bz = 0; bz < bz_max; bz++) { - int bx; - - for (bx = 0; bx < bx_max; bx++) { - mFM_move_actor_c* move_actor_list = mFI_MoveActorListDma(bx, bz); + int bx_max = mFI_GetBlockXMax(); + int bz_max = mFI_GetBlockZMax(); + int bz; - if (move_actor_list != NULL) { - mFI_MakeMoveActorBitData(bx, bz, move_actor_list); - } + for (bz = 0; bz < bz_max; bz++) { + int bx; + + for (bx = 0; bx < bx_max; bx++) { + mFM_move_actor_c* move_actor_list = mFI_MoveActorListDma(bx, bz); + + if (move_actor_list != NULL) { + mFI_MakeMoveActorBitData(bx, bz, move_actor_list); + } + } } - } } static int l_player_wade; extern void mFI_SetPlayerWade(GAME_PLAY* play) { - PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); + PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); - if (player != NULL) { - if (mPlib_check_player_actor_main_index_AllWade(play) == TRUE) { - if (l_player_wade == mFI_WADE_NONE || l_player_wade == mFI_WADE_END) { - l_player_wade = mFI_WADE_START; - } - else { - l_player_wade = mFI_WADE_INPROGRESS; - } + if (player != NULL) { + if (mPlib_check_player_actor_main_index_AllWade(play) == TRUE) { + if (l_player_wade == mFI_WADE_NONE || l_player_wade == mFI_WADE_END) { + l_player_wade = mFI_WADE_START; + } else { + l_player_wade = mFI_WADE_INPROGRESS; + } + } else if (l_player_wade == mFI_WADE_INPROGRESS) { + l_player_wade = mFI_WADE_END; + } else { + l_player_wade = mFI_WADE_NONE; + } + } else { + l_player_wade = mFI_WADE_ERROR; } - else if (l_player_wade == mFI_WADE_INPROGRESS) { - l_player_wade = mFI_WADE_END; - } - else { - l_player_wade = mFI_WADE_NONE; - } - } - else { - l_player_wade = mFI_WADE_ERROR; - } } extern int mFI_CheckPlayerWade(int wade) { - int res = FALSE; + int res = FALSE; - if (wade == l_player_wade) { - res = TRUE; - } + if (wade == l_player_wade) { + res = TRUE; + } - return res; + return res; } extern int mFI_GetPlayerWade() { - return l_player_wade; + return l_player_wade; } extern int mFI_GetNextBlockNum(int* bx, int* bz) { - xyz_t end_pos = {0.0f, 0.0f, 0.0f}; - int res = FALSE; - int res2; + xyz_t end_pos = { 0.0f, 0.0f, 0.0f }; + int res = FALSE; + int res2; - if (Common_Get(player_actor_exists)) { - res = ((*GET_PLAYER_ACTOR_NOW()->Get_WadeEndPos_proc)(gamePT, &end_pos)); - } + if (Common_Get(player_actor_exists)) { + res = ((*GET_PLAYER_ACTOR_NOW()->Get_WadeEndPos_proc)(gamePT, &end_pos)); + } - res2 = mFI_Wpos2BlockNum(bx, bz, end_pos); - res2 &= res; - return res2; + res2 = mFI_Wpos2BlockNum(bx, bz, end_pos); + res2 &= res; + return res2; } extern u16* mFI_GetDepositP(int bx, int bz) { - u16* deposit_p = NULL; + u16* deposit_p = NULL; - if (mFI_CheckFieldData() == FALSE || mFI_GET_TYPE(mFI_GetFieldId()) != mFI_FIELD_FG) { - if (bx - 1 >= 0 && bx - 1 < FG_BLOCK_X_NUM && bz - 1 >= 0 && bz - 1 < FG_BLOCK_Z_NUM) { - deposit_p = Save_Get(deposit[(bx - 1) + (bz - 1) * FG_BLOCK_X_NUM]); + if (mFI_CheckFieldData() == FALSE || mFI_GET_TYPE(mFI_GetFieldId()) != mFI_FIELD_FG) { + if (bx - 1 >= 0 && bx - 1 < FG_BLOCK_X_NUM && bz - 1 >= 0 && bz - 1 < FG_BLOCK_Z_NUM) { + deposit_p = Save_Get(deposit[(bx - 1) + (bz - 1) * FG_BLOCK_X_NUM]); + } + } else if (mFI_BlockCheck(bx, bz) == TRUE) { + deposit_p = g_fdinfo->block_info[bx + bz * mFI_GetBlockXMax()].fg_info.deposit_p; } - } - else if (mFI_BlockCheck(bx, bz) == TRUE) { - deposit_p = g_fdinfo->block_info[bx + bz * mFI_GetBlockXMax()].fg_info.deposit_p; - } - return deposit_p; + return deposit_p; } extern void mFI_ClearDeposit(int bx, int bz) { - u16* deposit_p = mFI_GetDepositP(bx, bz); + u16* deposit_p = mFI_GetDepositP(bx, bz); - if (deposit_p != NULL) { - int i; + if (deposit_p != NULL) { + int i; - for (i = 0; i < UT_Z_NUM; i++) { - deposit_p[0] = 0; - deposit_p++; + for (i = 0; i < UT_Z_NUM; i++) { + deposit_p[0] = 0; + deposit_p++; + } } - } } static int mFI_LineDepositON(u16* deposit, int ut_x) { - deposit[0] |= (1 << ut_x); - return TRUE; + deposit[0] |= (1 << ut_x); + return TRUE; } static int mFI_LineDepositOFF(u16* deposit, int ut_x) { - deposit[0] &= ~(1 << ut_x); - return FALSE; + deposit[0] &= ~(1 << ut_x); + return FALSE; } extern int mFI_GetLineDeposit(u16* deposit, int ut_x) { - return (deposit[0] >> ut_x) & 1; + return (deposit[0] >> ut_x) & 1; } typedef int (*mFI_SET_DEPOSIT_PROC)(u16*, int); static int mFI_SetDeposit(u16* deposit, int ut_x, int ut_z, int type) { - static mFI_SET_DEPOSIT_PROC control_proc[mFI_DEPOSIT_NUM] = { - &mFI_LineDepositON, - &mFI_LineDepositOFF, - &mFI_GetLineDeposit - }; + static mFI_SET_DEPOSIT_PROC control_proc[mFI_DEPOSIT_NUM] = { &mFI_LineDepositON, &mFI_LineDepositOFF, + &mFI_GetLineDeposit }; - int res = FALSE; + int res = FALSE; - if (deposit != NULL && ut_x >= 0 && ut_x < UT_X_NUM && ut_z >= 0 && ut_z < UT_Z_NUM) { - res = (*control_proc[type])(deposit + ut_z, ut_x); - } + if (deposit != NULL && ut_x >= 0 && ut_x < UT_X_NUM && ut_z >= 0 && ut_z < UT_Z_NUM) { + res = (*control_proc[type])(deposit + ut_z, ut_x); + } - return res; + return res; } /* @unused, @fabricated */ @@ -2195,22 +2122,22 @@ extern MATCH_FORCESTRIP void mFI_BlockDepositON(u16* deposit_p, int ut_x, int ut */ extern void mFI_BlockDepositOFF(u16* deposit_p, int ut_x, int ut_z) { - mFI_SetDeposit(deposit_p, ut_x, ut_z, mFI_DEPOSIT_OFF); + mFI_SetDeposit(deposit_p, ut_x, ut_z, mFI_DEPOSIT_OFF); } extern int mFI_GetBlockDeposit(u16* deposit_p, int ut_x, int ut_z) { - return mFI_SetDeposit(deposit_p, ut_x, ut_z, mFI_DEPOSIT_GET); + return mFI_SetDeposit(deposit_p, ut_x, ut_z, mFI_DEPOSIT_GET); } static int mFI_BkUtNum2SetDeposit(int bx, int bz, int ut_x, int ut_z, int type) { - int res = FALSE; - u16* deposit_p = mFI_GetDepositP(bx, bz); + int res = FALSE; + u16* deposit_p = mFI_GetDepositP(bx, bz); - if (deposit_p != NULL) { - res = mFI_SetDeposit(deposit_p, ut_x, ut_z, type); - } + if (deposit_p != NULL) { + res = mFI_SetDeposit(deposit_p, ut_x, ut_z, type); + } - return res; + return res; } /* @unused @fabricated */ @@ -2221,7 +2148,7 @@ extern MATCH_FORCESTRIP void mFI_BkUtNum2DepositON(int bx, int bz, int ut_x, int */ extern void mFI_BkUtNum2DepositOFF(int bx, int bz, int ut_x, int ut_z) { - mFI_BkUtNum2SetDeposit(bx, bz, ut_x, ut_z, mFI_DEPOSIT_OFF); + mFI_BkUtNum2SetDeposit(bx, bz, ut_x, ut_z, mFI_DEPOSIT_OFF); } /* @unused @fabricated */ @@ -2232,1587 +2159,1353 @@ extern MATCH_FORCESTRIP int mFI_BkUtNum2DepositGet(int bx, int bz, int ut_x, int */ static int mFI_UtNum2SetDeposit(int ut_x, int ut_z, int type) { - int res = FALSE; - int bx; - int bz; - int b_ut_x; - int b_ut_z; + int res = FALSE; + int bx; + int bz; + int b_ut_x; + int b_ut_z; - if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == TRUE && mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z) == TRUE) { - res = mFI_BkUtNum2SetDeposit(bx, bz, b_ut_x, b_ut_z, type); - } + if (mFI_UtNum2BlockNum(&bx, &bz, ut_x, ut_z) == TRUE && mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z) == TRUE) { + res = mFI_BkUtNum2SetDeposit(bx, bz, b_ut_x, b_ut_z, type); + } - return res; + return res; } extern void mFI_UtNum2DepositON(int ut_x, int ut_z) { - mFI_UtNum2SetDeposit(ut_x, ut_z, mFI_DEPOSIT_ON); + mFI_UtNum2SetDeposit(ut_x, ut_z, mFI_DEPOSIT_ON); } extern void mFI_UtNum2DepositOFF(int ut_x, int ut_z) { - mFI_UtNum2SetDeposit(ut_x, ut_z, mFI_DEPOSIT_OFF); + mFI_UtNum2SetDeposit(ut_x, ut_z, mFI_DEPOSIT_OFF); } extern int mFI_UtNum2DepositGet(int ut_x, int ut_z) { - return mFI_UtNum2SetDeposit(ut_x, ut_z, mFI_DEPOSIT_GET); + return mFI_UtNum2SetDeposit(ut_x, ut_z, mFI_DEPOSIT_GET); } extern void mFI_Wpos2DepositON(xyz_t wpos) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); - mFI_UtNum2DepositON(ut_x, ut_z); + mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); + mFI_UtNum2DepositON(ut_x, ut_z); } extern void mFI_Wpos2DepositOFF(xyz_t wpos) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); - mFI_UtNum2DepositOFF(ut_x, ut_z); + mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); + mFI_UtNum2DepositOFF(ut_x, ut_z); } extern int mFI_Wpos2DepositGet(xyz_t wpos) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); - return mFI_UtNum2DepositGet(ut_x, ut_z); + mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); + return mFI_UtNum2DepositGet(ut_x, ut_z); } extern int mFI_CheckItemNoHole(mActor_name_t item) { - int res = FALSE; + int res = FALSE; - if (item >= HOLE_START && item <= HOLE_END || item == HOLE_SHINE) { - res = TRUE; - } + if (item >= HOLE_START && item <= HOLE_END || item == HOLE_SHINE) { + res = TRUE; + } - return res; + return res; } /* @unused extern int mFI_CheckCanDeposit(xyz_t wpos?) */ static int mFI_CheckNothing(mActor_name_t* item, xyz_t wpos) { - return FALSE; + return FALSE; } static int mFI_CheckDigHole(mActor_name_t* item, xyz_t wpos) { - int res = FALSE; + int res = FALSE; - if (mFI_CheckItemNoHole(*item) == TRUE && mFI_Wpos2DepositGet(wpos) == TRUE) { - res = TRUE; - } + if (mFI_CheckItemNoHole(*item) == TRUE && mFI_Wpos2DepositGet(wpos) == TRUE) { + res = TRUE; + } - return res; + return res; } static int mFI_CheckDigHoleFillin(mActor_name_t* item, xyz_t wpos) { - int res = FALSE; + int res = FALSE; - if (mFI_CheckItemNoHole(*item) == TRUE && mFI_Wpos2DepositGet(wpos) == FALSE) { - res = TRUE; - } + if (mFI_CheckItemNoHole(*item) == TRUE && mFI_Wpos2DepositGet(wpos) == FALSE) { + res = TRUE; + } - return res; + return res; } static int mFI_CheckDigNoItem(mActor_name_t* item, xyz_t wpos) { - int res = FALSE; + int res = FALSE; - if (*item == EMPTY_NO) { - res = TRUE; - } + if (*item == EMPTY_NO) { + res = TRUE; + } - return res; + return res; } static int mFI_CheckDigRemoveItem(mActor_name_t* item, xyz_t wpos) { - int res = FALSE; + int res = FALSE; - if ( - (*item >= FLOWER_LEAVES_PANSIES0 && *item <= FLOWER_TULIP2) || - (*item >= TREE_STUMP001 && *item <= TREE_STUMP004) || - (*item >= GRASS_A && *item <= GRASS_C) || - (*item == TREE_SAPLING) || - (*item == TREE_APPLE_SAPLING) || - (*item == TREE_ORANGE_SAPLING) || - (*item == TREE_PEACH_SAPLING) || - (*item == TREE_PEAR_SAPLING) || - (*item == TREE_CHERRY_SAPLING) || - (*item == TREE_1000BELLS_SAPLING) || - (*item == TREE_10000BELLS_SAPLING) || - (*item == TREE_30000BELLS_SAPLING) || - (*item == TREE_100BELLS_SAPLING) || - (*item == DEAD_SAPLING) || - (*item >= TREE_PALM_STUMP001 && *item <= TREE_PALM_STUMP004) || - (*item == TREE_PALM_SAPLING) || - (*item == DEAD_PALM_SAPLING) || - (*item >= CEDAR_TREE_STUMP001 && *item <= CEDAR_TREE_STUMP004) || - (*item == CEDAR_TREE_SAPLING) || - (*item == DEAD_CEDAR_SAPLING) || - (*item >= GOLD_TREE_STUMP001 && *item <= GOLD_TREE_STUMP004) || - (*item == GOLD_TREE_SAPLING) || - (*item == DEAD_GOLD_SAPLING) - ) { - res = TRUE; - } + if ((*item >= FLOWER_LEAVES_PANSIES0 && *item <= FLOWER_TULIP2) || + (*item >= TREE_STUMP001 && *item <= TREE_STUMP004) || (*item >= GRASS_A && *item <= GRASS_C) || + (*item == TREE_SAPLING) || (*item == TREE_APPLE_SAPLING) || (*item == TREE_ORANGE_SAPLING) || + (*item == TREE_PEACH_SAPLING) || (*item == TREE_PEAR_SAPLING) || (*item == TREE_CHERRY_SAPLING) || + (*item == TREE_1000BELLS_SAPLING) || (*item == TREE_10000BELLS_SAPLING) || (*item == TREE_30000BELLS_SAPLING) || + (*item == TREE_100BELLS_SAPLING) || (*item == DEAD_SAPLING) || + (*item >= TREE_PALM_STUMP001 && *item <= TREE_PALM_STUMP004) || (*item == TREE_PALM_SAPLING) || + (*item == DEAD_PALM_SAPLING) || (*item >= CEDAR_TREE_STUMP001 && *item <= CEDAR_TREE_STUMP004) || + (*item == CEDAR_TREE_SAPLING) || (*item == DEAD_CEDAR_SAPLING) || + (*item >= GOLD_TREE_STUMP001 && *item <= GOLD_TREE_STUMP004) || (*item == GOLD_TREE_SAPLING) || + (*item == DEAD_GOLD_SAPLING)) { + res = TRUE; + } - return res; + return res; } static int mFI_CheckDigGetItem(mActor_name_t* item, xyz_t wpos) { - int res = FALSE; - - if (mFI_Wpos2DepositGet(wpos) == TRUE) { - if (mFI_CheckItemNoHole(*item) == FALSE) { - res = TRUE; - } - } - else { - int valid = (*item >= BURIED_PITFALL_START && *item <= BURIED_PITFALL_END) || *item == SHINE_SPOT; + int res = FALSE; - if (valid == TRUE) { - item[0] = bg_item_fg_sub_dig2take_conv(*item); - res = TRUE; - } - } + if (mFI_Wpos2DepositGet(wpos) == TRUE) { + if (mFI_CheckItemNoHole(*item) == FALSE) { + res = TRUE; + } + } else { + int valid = (*item >= BURIED_PITFALL_HOLE_START && *item <= BURIED_PITFALL_HOLE_END) || *item == SHINE_SPOT; - return res; + if (valid == TRUE) { + item[0] = bg_item_fg_sub_dig2take_conv(*item); + res = TRUE; + } + } + + return res; } static int mFI_CheckDigDiffPosArea(xyz_t wpos0, xyz_t wpos1) { - int res = FALSE; + int res = FALSE; - if ( - (wpos0.x > wpos1.x + mFI_UT_WORLDSIZE_HALF_X_F) || - (wpos0.x < wpos1.x - mFI_UT_WORLDSIZE_HALF_X_F) || - (wpos0.z > wpos1.z + mFI_UT_WORLDSIZE_HALF_Z_F) || - (wpos0.z < wpos1.z - mFI_UT_WORLDSIZE_HALF_Z_F) - ) { - res = TRUE; - } + if ((wpos0.x > wpos1.x + mFI_UT_WORLDSIZE_HALF_X_F) || (wpos0.x < wpos1.x - mFI_UT_WORLDSIZE_HALF_X_F) || + (wpos0.z > wpos1.z + mFI_UT_WORLDSIZE_HALF_Z_F) || (wpos0.z < wpos1.z - mFI_UT_WORLDSIZE_HALF_Z_F)) { + res = TRUE; + } - return res; + return res; } typedef int (*mFI_DIG_CHECK_PROC)(mActor_name_t*, xyz_t); extern int mFI_GetDigStatus(mActor_name_t* item, xyz_t wpos, int golden_shovel) { - int status = mFI_DIGSTATUS_CANCEL; - mActor_name_t* dig_item_p = mFI_GetUnitFG(wpos); - item[0] = EMPTY_NO; + int status = mFI_DIGSTATUS_CANCEL; + mActor_name_t* dig_item_p = mFI_GetUnitFG(wpos); + item[0] = EMPTY_NO; - if (dig_item_p != NULL) { - item[0] = dig_item_p[0]; + if (dig_item_p != NULL) { + item[0] = dig_item_p[0]; - if (mCoBG_CheckHole(wpos) == TRUE) { - static mFI_DIG_CHECK_PROC dig_check[mFI_DIGSTATUS_NUM] = { - &mFI_CheckNothing, - &mFI_CheckDigHole, - &mFI_CheckDigHoleFillin, - &mFI_CheckDigNoItem, - &mFI_CheckDigRemoveItem, - &mFI_CheckDigGetItem - }; + if (mCoBG_CheckHole(wpos) == TRUE) { + static mFI_DIG_CHECK_PROC dig_check[mFI_DIGSTATUS_NUM] = { &mFI_CheckNothing, &mFI_CheckDigHole, + &mFI_CheckDigHoleFillin, &mFI_CheckDigNoItem, + &mFI_CheckDigRemoveItem, &mFI_CheckDigGetItem }; - static xyz_t old_pos = { 0.0f, 0.0f, 0.0f }; + static xyz_t old_pos = { 0.0f, 0.0f, 0.0f }; - int i; + int i; - for (i = 0; i < mFI_DIGSTATUS_NUM; i++) { - int res = (*dig_check[i])(item, wpos); + for (i = 0; i < mFI_DIGSTATUS_NUM; i++) { + int res = (*dig_check[i])(item, wpos); - if (res == TRUE) { - status = i; + if (res == TRUE) { + status = i; - if (i != mFI_DIGSTATUS_DIG) { - break; - } + if (i != mFI_DIGSTATUS_DIG) { + break; + } - if (golden_shovel == TRUE) { - + if (golden_shovel == TRUE) { - /* 10% chance of getting 100 bells with golden shovel */ - if (mFI_CheckDigDiffPosArea(wpos, old_pos) == TRUE && RANDOM(10) == 1) { - status = mFI_DIGSTATUS_GET_ITEM; - item[0] = ITM_MONEY_100; + /* 10% chance of getting 100 bells with golden shovel */ + if (mFI_CheckDigDiffPosArea(wpos, old_pos) == TRUE && RANDOM(10) == 1) { + status = mFI_DIGSTATUS_GET_ITEM; + item[0] = ITM_MONEY_100; + } + } + + old_pos = wpos; + break; + } } - } - - old_pos = wpos; - break; + } else if (mCoBG_CheckSkySwing(wpos) == TRUE) { + status = mFI_DIGSTATUS_MISS; } - } } - else if (mCoBG_CheckSkySwing(wpos) == TRUE) { - status = mFI_DIGSTATUS_MISS; - } - } - return status; + return status; } static void mFI_ClearHoleBlock_sub(mActor_name_t* fg_items_p) { - int i; + int i; - if (fg_items_p == NULL) { - return; - } - - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (*fg_items_p >= HOLE_START && *fg_items_p <= HOLE_END) { - fg_items_p[0] = EMPTY_NO; - } - else if (*fg_items_p == HOLE_SHINE) { - fg_items_p[0] = EMPTY_NO; + if (fg_items_p == NULL) { + return; } - fg_items_p++; - } + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (*fg_items_p >= HOLE_START && *fg_items_p <= HOLE_END) { + fg_items_p[0] = EMPTY_NO; + } else if (*fg_items_p == HOLE_SHINE) { + fg_items_p[0] = EMPTY_NO; + } + + fg_items_p++; + } } extern void mFI_ClearHoleBlock(int bx, int bz) { - mFI_ClearHoleBlock_sub(mFI_BkNumtoUtFGTop(bx, bz)); + mFI_ClearHoleBlock_sub(mFI_BkNumtoUtFGTop(bx, bz)); } extern void mFI_ClearBeecomb(int bx, int bz) { - mActor_name_t* fg_items_p = mFI_BkNumtoUtFGTop(bx, bz); - int i; - - if (fg_items_p != NULL) { - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (*fg_items_p == HONEYCOMB) { - fg_items_p[0] = EMPTY_NO; - } + mActor_name_t* fg_items_p = mFI_BkNumtoUtFGTop(bx, bz); + int i; - fg_items_p++; + if (fg_items_p != NULL) { + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (*fg_items_p == HONEYCOMB) { + fg_items_p[0] = EMPTY_NO; + } + + fg_items_p++; + } } - } } static void mFI_SetFGStructureKeep(mActor_name_t* item_p, mActor_name_t replace_item, int destroy_item) { - if (destroy_item == FALSE) { - mPB_keep_item(*item_p); - } + if (destroy_item == FALSE) { + mPB_keep_item(*item_p); + } - item_p[0] = replace_item; + item_p[0] = replace_item; } static mActor_name_t l_set_fg_table[3 * 3]; -static int mFI_SetStructure11( - mActor_name_t* fg_items_p, - mActor_name_t replace_item, - mActor_name_t fill_item, - int bx, - int bz, - int ut_x, - int ut_z, - int destroy_item -) { - fg_items_p += mFI_GetUtNum(ut_x, ut_z); - mFI_SetFGStructureKeep(fg_items_p, replace_item, destroy_item); - mFI_BkUtNum2DepositOFF(bx, bz, ut_x, ut_z); - mCoBG_Ut2SetDefaultOffset(ut_x + bx * UT_X_NUM, ut_z + bz * UT_Z_NUM); - return TRUE; +static int mFI_SetStructure11(mActor_name_t* fg_items_p, mActor_name_t replace_item, mActor_name_t fill_item, int bx, + int bz, int ut_x, int ut_z, int destroy_item) { + fg_items_p += mFI_GetUtNum(ut_x, ut_z); + mFI_SetFGStructureKeep(fg_items_p, replace_item, destroy_item); + mFI_BkUtNum2DepositOFF(bx, bz, ut_x, ut_z); + mCoBG_Ut2SetDefaultOffset(ut_x + bx * UT_X_NUM, ut_z + bz * UT_Z_NUM); + return TRUE; } -static int mFI_SetStructure21( - mActor_name_t* fg_items_p, - mActor_name_t replace_item, - mActor_name_t fill_item, - int bx, - int bz, - int ut_x, - int ut_z, - int destroy_item -) { - mActor_name_t* set_fg_table = l_set_fg_table; - int res = FALSE; +static int mFI_SetStructure21(mActor_name_t* fg_items_p, mActor_name_t replace_item, mActor_name_t fill_item, int bx, + int bz, int ut_x, int ut_z, int destroy_item) { + mActor_name_t* set_fg_table = l_set_fg_table; + int res = FALSE; - if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z >= 0 && ut_z < UT_Z_NUM - 1) { - int i; + if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z >= 0 && ut_z < UT_Z_NUM - 1) { + int i; - for (i = 0; i < 2; i++) { - set_fg_table[i] = fill_item; + for (i = 0; i < 2; i++) { + set_fg_table[i] = fill_item; + } + + set_fg_table[0] = replace_item; + for (i = 0; i < 2; i++) { + mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + i, ut_z, destroy_item); + set_fg_table++; + } + + res = TRUE; } - set_fg_table[0] = replace_item; - for (i = 0; i < 2; i++) { - mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + i, ut_z, destroy_item); - set_fg_table++; - } - - res = TRUE; - } - - return res; + return res; } -static int mFI_SetStructure22( - mActor_name_t* fg_items_p, - mActor_name_t replace_item, - mActor_name_t fill_item, - int bx, - int bz, - int ut_x, - int ut_z, - int destroy_item -) { - mActor_name_t* set_fg_table = l_set_fg_table; - int res = FALSE; +static int mFI_SetStructure22(mActor_name_t* fg_items_p, mActor_name_t replace_item, mActor_name_t fill_item, int bx, + int bz, int ut_x, int ut_z, int destroy_item) { + mActor_name_t* set_fg_table = l_set_fg_table; + int res = FALSE; - if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z >= 0 && ut_z < UT_Z_NUM - 1) { - int i; - int j; + if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z >= 0 && ut_z < UT_Z_NUM - 1) { + int i; + int j; - for (i = 0; i < 2 * 2; i++) { - set_fg_table[i] = fill_item; + for (i = 0; i < 2 * 2; i++) { + set_fg_table[i] = fill_item; + } + + set_fg_table[0] = replace_item; + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); + set_fg_table++; + } + } + + res = TRUE; } - set_fg_table[0] = replace_item; - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); - set_fg_table++; - } - } - - res = TRUE; - } - - return res; + return res; } -static int mFI_SetStructure23( - mActor_name_t* fg_items_p, - mActor_name_t replace_item, - mActor_name_t fill_item, - int bx, - int bz, - int ut_x, - int ut_z, - int destroy_item -) { - mActor_name_t* set_fg_table = l_set_fg_table; - int res = FALSE; +static int mFI_SetStructure23(mActor_name_t* fg_items_p, mActor_name_t replace_item, mActor_name_t fill_item, int bx, + int bz, int ut_x, int ut_z, int destroy_item) { + mActor_name_t* set_fg_table = l_set_fg_table; + int res = FALSE; - if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { - int i; - int j; + if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { + int i; + int j; - for (i = 0; i < 2 * 3; i++) { - set_fg_table[i] = fill_item; + for (i = 0; i < 2 * 3; i++) { + set_fg_table[i] = fill_item; + } + + set_fg_table[2] = replace_item; + for (i = -1; i < 2; i++) { + for (j = 0; j < 2; j++) { + mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); + set_fg_table++; + } + } + + res = TRUE; } - set_fg_table[2] = replace_item; - for (i = -1; i < 2; i++) { - for (j = 0; j < 2; j++) { - mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); - set_fg_table++; - } - } - - res = TRUE; - } - - return res; + return res; } -static int mFI_SetStructure32( - mActor_name_t* fg_items_p, - mActor_name_t replace_item, - mActor_name_t fill_item, - int bx, - int bz, - int ut_x, - int ut_z, - int destroy_item -) { - mActor_name_t* set_fg_table = l_set_fg_table; - int res = FALSE; +static int mFI_SetStructure32(mActor_name_t* fg_items_p, mActor_name_t replace_item, mActor_name_t fill_item, int bx, + int bz, int ut_x, int ut_z, int destroy_item) { + mActor_name_t* set_fg_table = l_set_fg_table; + int res = FALSE; - if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { - int i; - int j; + if (ut_x >= 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { + int i; + int j; - for (i = 0; i < 3 * 2; i++) { - set_fg_table[i] = fill_item; + for (i = 0; i < 3 * 2; i++) { + set_fg_table[i] = fill_item; + } + + set_fg_table[1] = replace_item; + for (i = 0; i < 2; i++) { + for (j = -1; j < 2; j++) { + mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); + set_fg_table++; + } + } + + res = TRUE; } - set_fg_table[1] = replace_item; - for (i = 0; i < 2; i++) { - for (j = -1; j < 2; j++) { - mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); - set_fg_table++; - } - } - - res = TRUE; - } - - return res; + return res; } -static int mFI_SetStructure33( - mActor_name_t* fg_items_p, - mActor_name_t replace_item, - mActor_name_t fill_item, - int bx, - int bz, - int ut_x, - int ut_z, - int destroy_item -) { - mActor_name_t* set_fg_table = l_set_fg_table; - int res = FALSE; +static int mFI_SetStructure33(mActor_name_t* fg_items_p, mActor_name_t replace_item, mActor_name_t fill_item, int bx, + int bz, int ut_x, int ut_z, int destroy_item) { + mActor_name_t* set_fg_table = l_set_fg_table; + int res = FALSE; - if (ut_x > 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { - int i; - int j; + if (ut_x > 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { + int i; + int j; - for (i = 0; i < 3 * 3; i++) { - set_fg_table[i] = fill_item; + for (i = 0; i < 3 * 3; i++) { + set_fg_table[i] = fill_item; + } + + set_fg_table[4] = replace_item; + for (i = -1; i < 2; i++) { + for (j = -1; j < 2; j++) { + mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); + set_fg_table++; + } + } + + res = TRUE; } - set_fg_table[4] = replace_item; - for (i = -1; i < 2; i++) { - for (j = -1; j < 2; j++) { - mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); - set_fg_table++; - } - } - - res = TRUE; - } - - return res; + return res; } -static int mFI_SetStructure33_main_back( - mActor_name_t* fg_items_p, - mActor_name_t replace_item, - mActor_name_t fill_item, - int bx, - int bz, - int ut_x, - int ut_z, - int destroy_item -) { - mActor_name_t* set_fg_table = l_set_fg_table; - int res = FALSE; +static int mFI_SetStructure33_main_back(mActor_name_t* fg_items_p, mActor_name_t replace_item, mActor_name_t fill_item, + int bx, int bz, int ut_x, int ut_z, int destroy_item) { + mActor_name_t* set_fg_table = l_set_fg_table; + int res = FALSE; - if (ut_x > 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { - int i; - int j; + if (ut_x > 0 && ut_x < UT_X_NUM - 1 && ut_z > 0 && ut_z < UT_Z_NUM - 1) { + int i; + int j; - for (i = 0; i < 3 * 3; i++) { - set_fg_table[i] = fill_item; + for (i = 0; i < 3 * 3; i++) { + set_fg_table[i] = fill_item; + } + + set_fg_table[1] = replace_item; + for (i = -1; i < 2; i++) { + for (j = -1; j < 2; j++) { + mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); + set_fg_table++; + } + } + + res = TRUE; } - set_fg_table[1] = replace_item; - for (i = -1; i < 2; i++) { - for (j = -1; j < 2; j++) { - mFI_SetStructure11(fg_items_p, *set_fg_table, fill_item, bx, bz, ut_x + j, ut_z + i, destroy_item); - set_fg_table++; - } - } - - res = TRUE; - } - - return res; + return res; } static u8 l_structure_set_type[STRUCTURE_END - STRUCTURE_START] = { - 0x0c, 0x0c, 0x0c, 0x0c, 0x05, 0x05, 0x05, 0x05, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0a, 0x0a, - 0x0a, 0x0a, 0x05, 0x05, 0x00, 0x06, 0x06, 0x05, - 0x05, 0x06, 0x05, 0x00, 0x06, 0x06, 0x00, 0x00, - 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x05, - 0x04, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c + 0x0c, 0x0c, 0x0c, 0x0c, 0x05, 0x05, 0x05, 0x05, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0c, 0x0a, 0x0a, 0x0a, 0x0a, 0x05, 0x05, 0x00, 0x06, 0x06, 0x05, 0x05, 0x06, 0x05, + 0x00, 0x06, 0x06, 0x00, 0x00, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x05, 0x05, 0x04, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c }; typedef int (*mFI_SET_STRUCTURE_PROC)(mActor_name_t*, mActor_name_t, mActor_name_t, int, int, int, int, int); extern int mFI_SetFGStructure_common(mActor_name_t structure_name, int bx, int bz, int ut_x, int ut_z, int set_type) { - static mFI_SET_STRUCTURE_PROC set_structure[12] = { - &mFI_SetStructure11, - &mFI_SetStructure21, - &mFI_SetStructure22, - &mFI_SetStructure23, - &mFI_SetStructure32, - &mFI_SetStructure33, - &mFI_SetStructure33_main_back, + static mFI_SET_STRUCTURE_PROC set_structure[12] = { + &mFI_SetStructure11, &mFI_SetStructure21, &mFI_SetStructure22, &mFI_SetStructure23, + &mFI_SetStructure32, &mFI_SetStructure33, &mFI_SetStructure33_main_back, - &mFI_SetStructure11, - &mFI_SetStructure22, - &mFI_SetStructure23, - &mFI_SetStructure33, - &mFI_SetStructure33_main_back - }; + &mFI_SetStructure11, &mFI_SetStructure22, &mFI_SetStructure23, &mFI_SetStructure33, + &mFI_SetStructure33_main_back + }; - static mActor_name_t fill_name_table[mFI_SET_STRUCTURE_NUM] = { RSV_NO, EMPTY_NO }; - static int keep_status_table[mFI_SET_STRUCTURE_NUM] = { FALSE, TRUE }; + static mActor_name_t fill_name_table[mFI_SET_STRUCTURE_NUM] = { RSV_NO, EMPTY_NO }; + static int keep_status_table[mFI_SET_STRUCTURE_NUM] = { FALSE, TRUE }; - mActor_name_t* fg_p = NULL; - int keep_status = keep_status_table[set_type]; - int res = FALSE; + mActor_name_t* fg_p = NULL; + int keep_status = keep_status_table[set_type]; + int res = FALSE; - if (mFI_CheckFieldData() == TRUE) { - if (mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELD_FG) { - if (mFI_BlockCheck(bx, bz) == TRUE && ITEM_NAME_GET_TYPE(structure_name) == NAME_TYPE_STRUCT) { - fg_p = mFI_BkNumtoUtFGTop(bx, bz); - } - } - else { - int fg_bx = bx - 1; - int fg_bz = bz - 1; + if (mFI_CheckFieldData() == TRUE) { + if (mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELD_FG) { + if (mFI_BlockCheck(bx, bz) == TRUE && ITEM_NAME_GET_TYPE(structure_name) == NAME_TYPE_STRUCT) { + fg_p = mFI_BkNumtoUtFGTop(bx, bz); + } + } else { + int fg_bx = bx - 1; + int fg_bz = bz - 1; - if (fg_bx >= 0 && fg_bx < FG_BLOCK_X_NUM && fg_bz >= 0 && fg_bz < FG_BLOCK_Z_NUM) { - fg_p = Save_Get(fg[fg_bz][fg_bx]).items[0]; - } - } - - if (fg_p != NULL) { - u8 structure_type = l_structure_set_type[(int)(structure_name - STRUCTURE_START)]; - - if (structure_type < 0xC) { - mActor_name_t fill_name = fill_name_table[set_type]; - - if (set_type == mFI_SET_STRUCTURE_REMOVE) { - if (structure_type >= 7) { - structure_name = mFM_GetReseveName(bx, bz); - } - else { - structure_name = fill_name; - } + if (fg_bx >= 0 && fg_bx < FG_BLOCK_X_NUM && fg_bz >= 0 && fg_bz < FG_BLOCK_Z_NUM) { + fg_p = Save_Get(fg[fg_bz][fg_bx]).items[0]; + } } - res = (*set_structure[structure_type])(fg_p, structure_name, fill_name, bx, bz, ut_x, ut_z, keep_status); + if (fg_p != NULL) { + u8 structure_type = l_structure_set_type[(int)(structure_name - STRUCTURE_START)]; - if (res == TRUE) { - mFI_SetFGUpData(); + if (structure_type < 0xC) { + mActor_name_t fill_name = fill_name_table[set_type]; + + if (set_type == mFI_SET_STRUCTURE_REMOVE) { + if (structure_type >= 7) { + structure_name = mFM_GetReseveName(bx, bz); + } else { + structure_name = fill_name; + } + } + + res = + (*set_structure[structure_type])(fg_p, structure_name, fill_name, bx, bz, ut_x, ut_z, keep_status); + + if (res == TRUE) { + mFI_SetFGUpData(); + } + } } - } } - } - return res; + return res; } -extern int mFI_CheckStructureArea(int ut_x, int ut_z, mActor_name_t structure_name, int structure_ut_x, int structure_ut_z) { - static s8 set_area_table[12][4] = { - { - 0, 0, - 0, 0 - }, - { - 0, 1, - 0, 0 - }, - { - 0, 1, - 0, 1 - }, - { - -1, 1, - 0, 1 - }, - { - -1, 1, - -1, 1 - }, - { - -1, 1, - -1, 1 - }, - { - 0, 0, - 0, 0 - }, +extern int mFI_CheckStructureArea(int ut_x, int ut_z, mActor_name_t structure_name, int structure_ut_x, + int structure_ut_z) { + static s8 set_area_table[12][4] = { { 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 0, 1 }, { -1, 1, 0, 1 }, + { -1, 1, -1, 1 }, { -1, 1, -1, 1 }, { 0, 0, 0, 0 }, - { - 0, 1, - 0, 1 - }, - { - -1, 1, - -1, 1 - }, - { - -1, 1, - -1, 1 - }, - { - 0, 0, - 0, 0 - }, - { - 0, 0, - 0, 0 + { 0, 1, 0, 1 }, { -1, 1, -1, 1 }, { -1, 1, -1, 1 }, { 0, 0, 0, 0 }, + { 0, 0, 0, 0 } }; + + int start_x = structure_ut_x; + int start_z = structure_ut_z; + u8 structure_type; + s8* set_area; + int end_x = structure_ut_x; + int end_z = structure_ut_z; + int z; + + if (ITEM_NAME_GET_TYPE(structure_name) == NAME_TYPE_STRUCT) { + structure_type = l_structure_set_type[(int)(structure_name - STRUCTURE_START)]; + + if (structure_type < 12) { + set_area = set_area_table[structure_type]; + + start_x += set_area[0]; + end_x += set_area[1]; + start_z += set_area[2]; + end_z += set_area[3]; + } } - }; - int start_x = structure_ut_x; - int start_z = structure_ut_z; - u8 structure_type; - s8* set_area; - int end_x = structure_ut_x; - int end_z = structure_ut_z; - int z; - - if (ITEM_NAME_GET_TYPE(structure_name) == NAME_TYPE_STRUCT) { - structure_type = l_structure_set_type[(int)(structure_name - STRUCTURE_START)]; - - if (structure_type < 12) { - set_area = set_area_table[structure_type]; - - start_x += set_area[0]; - end_x += set_area[1]; - start_z += set_area[2]; - end_z += set_area[3]; + for (z = start_z; z < end_z + 1; z++) { + int x; + for (x = start_x; x < end_x + 1; x++) { + if (ut_x == x && ut_z == z) { + return TRUE; + } + } } - } - for (z = start_z; z < end_z + 1; z++) { - int x; - for (x = start_x; x < end_x + 1; x++) { - if (ut_x == x && ut_z == z) { - return TRUE; - } - } - } - - return FALSE; + return FALSE; } -/* +/* * @BUG: The RNG call will only be in the range [0, 3], * meaning you can never get an orange unless your town's * fruit is peaches and you roll a 3 (peach). - * + * * Additionally, this function is "bad" because it gives a 50% chance * for the next fruit to be rolled if you have apples, pears, or cherries. * The other two fruits are 25% each. */ #ifndef BUGFIXES extern mActor_name_t mFI_GetOtherFruit() { - mActor_name_t other_fruit = ITM_FOOD_START | RANDOM(4); + mActor_name_t other_fruit = ITM_FOOD_START | RANDOM(4); - if (other_fruit == Save_Get(fruit)) { - other_fruit++; - } + if (other_fruit == Save_Get(fruit)) { + other_fruit++; + } - return other_fruit; + return other_fruit; } #else /* This implementation gives an equal 25% chance for all non-native fruit to be rolled */ extern mActor_name_t mFI_GetOtherFruit() { - mActor_name_t other_fruit = ITM_FOOD_START | RANDOM(4); + mActor_name_t other_fruit = ITM_FOOD_START | RANDOM(4); - /* simple fix is to add one if the random fruit is also greater than the town fruit */ - if (other_fruit >= Save_Get(fruit)) { - other_fruit++; - } + /* simple fix is to add one if the random fruit is also greater than the town fruit */ + if (other_fruit >= Save_Get(fruit)) { + other_fruit++; + } - return other_fruit; + return other_fruit; } #endif extern int mFI_CheckFGNpcOn(mActor_name_t item) { - int res = FALSE; + int res = FALSE; - if (item == EMPTY_NO) { - res = TRUE; - } - else { - switch (ITEM_NAME_GET_TYPE(item)) { - case NAME_TYPE_ITEM0: - { - if ( - (item == TREE_SAPLING) || - (item == TREE_APPLE_SAPLING) || - (item == TREE_ORANGE_SAPLING) || - (item == TREE_PEACH_SAPLING) || - (item == TREE_PEAR_SAPLING) || - (item == TREE_CHERRY_SAPLING) || - (item == TREE_1000BELLS_SAPLING) || - (item == TREE_10000BELLS_SAPLING) || - (item == TREE_30000BELLS_SAPLING) || - (item == TREE_100BELLS_SAPLING) || - (item == TREE_PALM_SAPLING) || - (item == CEDAR_TREE_SAPLING) || - (item == GOLD_TREE_SAPLING) || - (item >= FLOWER_LEAVES_PANSIES0 && item <= FLOWER_TULIP2) || - (item >= GRASS_A && item <= GRASS_C) - ){ - res = TRUE; - } - - break; - } - - case NAME_TYPE_FTR0: - case NAME_TYPE_ITEM1: - case NAME_TYPE_FTR1: - case NAME_TYPE_WARP: - case NAME_TYPE_ITEM2: - { + if (item == EMPTY_NO) { res = TRUE; - break; - } - } - } + } else { + switch (ITEM_NAME_GET_TYPE(item)) { + case NAME_TYPE_ITEM0: { + if ((item == TREE_SAPLING) || (item == TREE_APPLE_SAPLING) || (item == TREE_ORANGE_SAPLING) || + (item == TREE_PEACH_SAPLING) || (item == TREE_PEAR_SAPLING) || (item == TREE_CHERRY_SAPLING) || + (item == TREE_1000BELLS_SAPLING) || (item == TREE_10000BELLS_SAPLING) || + (item == TREE_30000BELLS_SAPLING) || (item == TREE_100BELLS_SAPLING) || + (item == TREE_PALM_SAPLING) || (item == CEDAR_TREE_SAPLING) || (item == GOLD_TREE_SAPLING) || + (item >= FLOWER_LEAVES_PANSIES0 && item <= FLOWER_TULIP2) || (item >= GRASS_A && item <= GRASS_C)) { + res = TRUE; + } - return res; + break; + } + + case NAME_TYPE_FTR0: + case NAME_TYPE_ITEM1: + case NAME_TYPE_FTR1: + case NAME_TYPE_WARP: + case NAME_TYPE_ITEM2: { + res = TRUE; + break; + } + } + } + + return res; } extern int mFI_CheckLapPolice(int bx, int bz, int ut_x, int ut_z) { - int p_bx; - int p_bz; - int p_ut_x; - int p_ut_z; + int p_bx; + int p_bz; + int p_ut_x; + int p_ut_z; - int res = FALSE; + int res = FALSE; - if (mFI_CheckFieldData() == TRUE && mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELD_FG) { - mFM_GetPolicePos(&p_bx, &p_bz, &p_ut_x, &p_ut_z); + if (mFI_CheckFieldData() == TRUE && mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELD_FG) { + mFM_GetPolicePos(&p_bx, &p_bz, &p_ut_x, &p_ut_z); - if (bx == p_bx && bz == p_bz && ut_x == p_ut_x && ut_z == p_ut_z) { - res = TRUE; + if (bx == p_bx && bz == p_bz && ut_x == p_ut_x && ut_z == p_ut_z) { + res = TRUE; + } } - } - return res; + return res; } extern int mFI_GetWaveUtinBlock(int* ut_x, int* ut_z, int bx, int bz) { - mCoBG_Collision_u* col_p; - mCoBG_Collision_u* col; - int num; - int sel; - int i; - int res; + mCoBG_Collision_u* col_p; + mCoBG_Collision_u* col; + int num; + int sel; + int i; + int res; - num = 0; - res = FALSE; - ut_x[0] = 0; - ut_z[0] = 0; - - col_p = mFI_GetBkNum2ColTop(bx, bz); - col = col_p; + num = 0; + res = FALSE; + ut_x[0] = 0; + ut_z[0] = 0; - if (col_p != NULL) { - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { - num++; - } + col_p = mFI_GetBkNum2ColTop(bx, bz); + col = col_p; - col_p++; - } + if (col_p != NULL) { + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { + num++; + } - if (num > 0) { - col_p = col; - sel = RANDOM(num); - - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { - if (sel <= 0) { - ut_x[0] = i & 0xF; - ut_z[0] = i >> 4; - res = TRUE; - - break; - } - else { - sel--; - } + col_p++; } - col_p++; - } - } - } + if (num > 0) { + col_p = col; + sel = RANDOM(num); - return res; + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { + if (sel <= 0) { + ut_x[0] = i & 0xF; + ut_z[0] = i >> 4; + res = TRUE; + + break; + } else { + sel--; + } + } + + col_p++; + } + } + } + + return res; } -extern int mFI_ClearBlockItemRandom_common(mActor_name_t item, int clear_num, mActor_name_t* fg_p, u16* deposit_p, int delete_buried) { - static u16 candidate[UT_Z_NUM]; - - u16* candidate_p = candidate; - mActor_name_t* fg_p2 = fg_p; - u16* deposit_p2 = deposit_p; - int num = 0; - int selected; - int cleared_num = 0; - int ut_z; - int ut_x; +extern int mFI_ClearBlockItemRandom_common(mActor_name_t item, int clear_num, mActor_name_t* fg_p, u16* deposit_p, + int delete_buried) { + static u16 candidate[UT_Z_NUM]; - if (clear_num > 0 && clear_num <= UT_TOTAL_NUM) { - if (fg_p != NULL) { - bzero(candidate, sizeof(candidate)); + u16* candidate_p = candidate; + mActor_name_t* fg_p2 = fg_p; + u16* deposit_p2 = deposit_p; + int num = 0; + int selected; + int cleared_num = 0; + int ut_z; + int ut_x; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - if (*fg_p == item && (delete_buried == TRUE || (deposit_p != NULL && mFI_GetLineDeposit(deposit_p, ut_x) == FALSE))) { - num++; - candidate_p[0] |= (1 << ut_x); - } + if (clear_num > 0 && clear_num <= UT_TOTAL_NUM) { + if (fg_p != NULL) { + bzero(candidate, sizeof(candidate)); - fg_p++; + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (*fg_p == item && (delete_buried == TRUE || + (deposit_p != NULL && mFI_GetLineDeposit(deposit_p, ut_x) == FALSE))) { + num++; + candidate_p[0] |= (1 << ut_x); + } + + fg_p++; + } + + deposit_p++; + candidate_p++; + } } - deposit_p++; - candidate_p++; - } + if (num > 0) { + if (num <= clear_num) { + fg_p = fg_p2; + deposit_p = deposit_p2; + candidate_p = candidate; + + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (((candidate_p[0] >> ut_x) & 1) == 1) { + fg_p[0] = EMPTY_NO; + + if (delete_buried == TRUE && deposit_p != NULL) { + mFI_LineDepositOFF(deposit_p, ut_x); + } + } + + fg_p++; + } + + deposit_p++; + candidate_p++; + } + + cleared_num = num; + } else { + while (clear_num != 0 && num != 0) { + fg_p = fg_p2; + deposit_p = deposit_p2; + candidate_p = candidate; + + selected = RANDOM(num); + + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (((candidate_p[0] >> ut_x) & 1) == 1) { + if (selected <= 0) { + fg_p[0] = EMPTY_NO; + + if (delete_buried == TRUE && deposit_p != NULL) { + mFI_LineDepositOFF(deposit_p, ut_x); + } + + ut_z = UT_Z_NUM; + num--; + break; + } else { + selected--; + } + } + + fg_p++; + } + + deposit_p++; + candidate_p++; + } + + cleared_num++; + clear_num--; + } + } + } } - if (num > 0) { - if (num <= clear_num) { - fg_p = fg_p2; - deposit_p = deposit_p2; - candidate_p = candidate; - - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - if (((candidate_p[0] >> ut_x) & 1) == 1) { - fg_p[0] = EMPTY_NO; - - if (delete_buried == TRUE && deposit_p != NULL) { - mFI_LineDepositOFF(deposit_p, ut_x); - } - } - - fg_p++; - } - - deposit_p++; - candidate_p++; - } - - cleared_num = num; - } - else { - while (clear_num != 0 && num != 0) { - fg_p = fg_p2; - deposit_p = deposit_p2; - candidate_p = candidate; - - selected = RANDOM(num); - - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - if (((candidate_p[0] >> ut_x) & 1) == 1) { - if (selected <= 0) { - fg_p[0] = EMPTY_NO; - - if (delete_buried == TRUE && deposit_p != NULL) { - mFI_LineDepositOFF(deposit_p, ut_x); - } - - ut_z = UT_Z_NUM; - num--; - break; - } - else { - selected--; - } - } - - fg_p++; - } - - deposit_p++; - candidate_p++; - } - - cleared_num++; - clear_num--; - } - } - } - } - - return cleared_num; + return cleared_num; } static int l_reserve_set_shell; extern void mFI_SetFirstSetShell() { - l_reserve_set_shell = mFI_SET_SHELL_NUM; + l_reserve_set_shell = mFI_SET_SHELL_NUM; } static int mFI_CheckSetShell() { - int res = FALSE; + int res = FALSE; - /* Refresh shells every 10th minute */ - if (Common_Get(time.rtc_time.min) % 10 == 0) { - res = TRUE; - } + /* Refresh shells every 10th minute */ + if (Common_Get(time.rtc_time.min) % 10 == 0) { + res = TRUE; + } - return res; + return res; } static int mFI_GetCanSetShellNum(u8* shell_num, int bx, int bz) { - mCoBG_Collision_u* col_p; - mActor_name_t* fg_p; - u16* deposit_p; - int valid_ut_num = 0; - int ut_z; - int ut_x; - - fg_p = mFI_BkNumtoUtFGTop(bx, bz); - col_p = mFI_GetBkNum2ColTop(bx, bz); - deposit_p = mFI_GetDepositP(bx, bz); + mCoBG_Collision_u* col_p; + mActor_name_t* fg_p; + u16* deposit_p; + int valid_ut_num = 0; + int ut_z; + int ut_x; - if (fg_p != NULL && col_p != NULL && deposit_p != NULL) { - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - if (*fg_p == EMPTY_NO && mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { - valid_ut_num++; - } - else if ( - ((*fg_p >= ITM_SHELL0 && *fg_p <= ITM_SHELL7) || *fg_p == ITM_FOOD_COCONUT) && - mFI_GetBlockDeposit(deposit_p, ut_x, ut_z) == FALSE - ) { - shell_num[0]++; - } + fg_p = mFI_BkNumtoUtFGTop(bx, bz); + col_p = mFI_GetBkNum2ColTop(bx, bz); + deposit_p = mFI_GetDepositP(bx, bz); - fg_p++; - col_p++; - } + if (fg_p != NULL && col_p != NULL && deposit_p != NULL) { + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (*fg_p == EMPTY_NO && mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { + valid_ut_num++; + } else if (((*fg_p >= ITM_SHELL0 && *fg_p <= ITM_SHELL7) || *fg_p == ITM_FOOD_COCONUT) && + mFI_GetBlockDeposit(deposit_p, ut_x, ut_z) == FALSE) { + shell_num[0]++; + } + + fg_p++; + col_p++; + } + } } - } - return valid_ut_num; + return valid_ut_num; } static u8 l_sandy_beach_bx[7] = { 1, 2, 3, 4, 5, mISL_BLOCK_X0, mISL_BLOCK_X1 }; static u8 l_sandy_beach_bz[7] = { 6, 6, 6, 6, 6, mISL_BLOCK_Z, mISL_BLOCK_Z }; -static void mFI_ResearchShell(u8* can_set_ut_num, u8* on_shell_num, int* total_set_num, int* total_blocks, xyz_t player_pos) { - int player_bx; - int player_bz; - int i; - - mFI_Wpos2BlockNum(&player_bx, &player_bz, player_pos); - for (i = 0; i < 7; i++) { - int bx = l_sandy_beach_bx[i]; - int bz = l_sandy_beach_bz[i]; - /* Don't refresh shells if the player is in the acre */ - if (bx != player_bx || bz != player_bz) { - u8 can_set_num; - - can_set_ut_num[0] = mFI_GetCanSetShellNum(on_shell_num, bx, bz); - can_set_num = *can_set_ut_num; - - if (can_set_num != 0) { - u8 on_num = *on_shell_num; - - if (on_shell_num[0] < mFI_MAX_SHELLS_PER_BLOCK) { - int add_shell_num = mFI_MAX_SHELLS_PER_BLOCK - on_num; - - if (add_shell_num > can_set_num) { - u8 add = add_shell_num - can_set_num; - - on_shell_num[0] = on_num + add; - total_set_num[0] += *can_set_ut_num; - } - else { - total_set_num[0] += add_shell_num; - } - - total_blocks[0]++; - } - else { - can_set_ut_num[0] = 0; - } - } - } - - can_set_ut_num++; - on_shell_num++; - } -} - -static void mFI_DivideShellSameSum(u8* can_set_ut_num, u8* shell_num_inblock, u8* on_shell_num, int* set_num, int* block_num) { - while (set_num[0] > 0 && block_num[0] > 0 && set_num[0] > block_num[0]) { +static void mFI_ResearchShell(u8* can_set_ut_num, u8* on_shell_num, int* total_set_num, int* total_blocks, + xyz_t player_pos) { + int player_bx; + int player_bz; int i; + mFI_Wpos2BlockNum(&player_bx, &player_bz, player_pos); for (i = 0; i < 7; i++) { - if (can_set_ut_num[0] != 0 && on_shell_num[0] < mFI_MAX_SHELLS_PER_BLOCK) { - shell_num_inblock[0]++; - on_shell_num[0]++; - set_num[0]--; + int bx = l_sandy_beach_bx[i]; + int bz = l_sandy_beach_bz[i]; + /* Don't refresh shells if the player is in the acre */ + if (bx != player_bx || bz != player_bz) { + u8 can_set_num; - if (on_shell_num[0] >= mFI_MAX_SHELLS_PER_BLOCK) { - block_num[0]--; + can_set_ut_num[0] = mFI_GetCanSetShellNum(on_shell_num, bx, bz); + can_set_num = *can_set_ut_num; + + if (can_set_num != 0) { + u8 on_num = *on_shell_num; + + if (on_shell_num[0] < mFI_MAX_SHELLS_PER_BLOCK) { + int add_shell_num = mFI_MAX_SHELLS_PER_BLOCK - on_num; + + if (add_shell_num > can_set_num) { + u8 add = add_shell_num - can_set_num; + + on_shell_num[0] = on_num + add; + total_set_num[0] += *can_set_ut_num; + } else { + total_set_num[0] += add_shell_num; + } + + total_blocks[0]++; + } else { + can_set_ut_num[0] = 0; + } + } } - } - shell_num_inblock++; - on_shell_num++; - can_set_ut_num++; + can_set_ut_num++; + on_shell_num++; } - - shell_num_inblock -= 7; - on_shell_num -= 7; - can_set_ut_num -= 7; - } } -static void mFI_DivideShellRandom(u8* can_set_ut_num, u8* shell_num_inblock, u8* on_shell_num, int set_num, int block_num) { - u8* can_set_ut_num_p = can_set_ut_num; - u8* shell_num_inblock_p = shell_num_inblock; - u8* on_shell_num_p = on_shell_num; +static void mFI_DivideShellSameSum(u8* can_set_ut_num, u8* shell_num_inblock, u8* on_shell_num, int* set_num, + int* block_num) { + while (set_num[0] > 0 && block_num[0] > 0 && set_num[0] > block_num[0]) { + int i; - while (block_num > 0 && set_num > 0) { - int selected_block; - int i; - - can_set_ut_num_p = can_set_ut_num; - shell_num_inblock_p = shell_num_inblock; - on_shell_num_p = on_shell_num; - selected_block = RANDOM(block_num); + for (i = 0; i < 7; i++) { + if (can_set_ut_num[0] != 0 && on_shell_num[0] < mFI_MAX_SHELLS_PER_BLOCK) { + shell_num_inblock[0]++; + on_shell_num[0]++; + set_num[0]--; - for (i = 0; i < 7; i++) { - if ((int)can_set_ut_num_p[0] > 0 && on_shell_num_p[0] < mFI_MAX_SHELLS_PER_BLOCK) { - if (selected_block <= 0) { - shell_num_inblock_p[0]++; - on_shell_num_p[0]++; + if (on_shell_num[0] >= mFI_MAX_SHELLS_PER_BLOCK) { + block_num[0]--; + } + } - if (on_shell_num_p[0] >= mFI_MAX_SHELLS_PER_BLOCK) { - block_num--; - } - - break; + shell_num_inblock++; + on_shell_num++; + can_set_ut_num++; } - else { - selected_block--; - } - } - can_set_ut_num_p++; - on_shell_num_p++; - shell_num_inblock_p++; + shell_num_inblock -= 7; + on_shell_num -= 7; + can_set_ut_num -= 7; } +} - set_num--; - } +static void mFI_DivideShellRandom(u8* can_set_ut_num, u8* shell_num_inblock, u8* on_shell_num, int set_num, + int block_num) { + u8* can_set_ut_num_p = can_set_ut_num; + u8* shell_num_inblock_p = shell_num_inblock; + u8* on_shell_num_p = on_shell_num; + + while (block_num > 0 && set_num > 0) { + int selected_block; + int i; + + can_set_ut_num_p = can_set_ut_num; + shell_num_inblock_p = shell_num_inblock; + on_shell_num_p = on_shell_num; + selected_block = RANDOM(block_num); + + for (i = 0; i < 7; i++) { + if ((int)can_set_ut_num_p[0] > 0 && on_shell_num_p[0] < mFI_MAX_SHELLS_PER_BLOCK) { + if (selected_block <= 0) { + shell_num_inblock_p[0]++; + on_shell_num_p[0]++; + + if (on_shell_num_p[0] >= mFI_MAX_SHELLS_PER_BLOCK) { + block_num--; + } + + break; + } else { + selected_block--; + } + } + + can_set_ut_num_p++; + on_shell_num_p++; + shell_num_inblock_p++; + } + + set_num--; + } } static void mFI_DivideShell(u8* can_set_ut_num, u8* shell_num_inblock, u8* on_shell_num, int set_num, int block_num) { - mFI_DivideShellSameSum(can_set_ut_num, shell_num_inblock, on_shell_num, &set_num, &block_num); // divide shells evenly amongst acres first - mFI_DivideShellRandom(can_set_ut_num, shell_num_inblock, on_shell_num, set_num, block_num); // randomly place remaining shells + mFI_DivideShellSameSum(can_set_ut_num, shell_num_inblock, on_shell_num, &set_num, + &block_num); // divide shells evenly amongst acres first + mFI_DivideShellRandom(can_set_ut_num, shell_num_inblock, on_shell_num, set_num, + block_num); // randomly place remaining shells } static mActor_name_t mFI_GetShell(int is_island) { - static mActor_name_t normal_shell[6] = { - ITM_SHELL0, // lion's paw - ITM_SHELL1, // wentletrap - ITM_SHELL2, // venus comb - ITM_SHELL3, // prceletta - ITM_SHELL4, // sand dollar - ITM_SHELL7 // coral - }; + static mActor_name_t normal_shell[6] = { + ITM_SHELL0, // lion's paw + ITM_SHELL1, // wentletrap + ITM_SHELL2, // venus comb + ITM_SHELL3, // prceletta + ITM_SHELL4, // sand dollar + ITM_SHELL7 // coral + }; - static mActor_name_t rare_shell[2] = { - ITM_SHELL6, // conch - ITM_SHELL5 // white scallop - }; + static mActor_name_t rare_shell[2] = { + ITM_SHELL6, // conch + ITM_SHELL5 // white scallop + }; - static mActor_name_t island_rare_shell[3] = { - ITM_SHELL6, // conch - ITM_SHELL5, // white scallop - ITM_FOOD_COCONUT - }; + static mActor_name_t island_rare_shell[3] = { ITM_SHELL6, // conch + ITM_SHELL5, // white scallop + ITM_FOOD_COCONUT }; - static mActor_name_t* shell_table[3] = { - normal_shell, - rare_shell, - island_rare_shell - }; + static mActor_name_t* shell_table[3] = { normal_shell, rare_shell, island_rare_shell }; - static f32 shell_max[3] = { - 6.0f, - 2.0f, - /* @BUG - this is supposed to be 3.0f, the devs messed up. Coconuts are supposed to wash up on the beach */ - #ifndef BUGFIXES - 2.0f - #else - 3.0f - #endif - }; + static f32 shell_max[3] = { 6.0f, 2.0f, +/* @BUG - this is supposed to be 3.0f, the devs messed up. Coconuts are supposed to wash up on the beach */ +#ifndef BUGFIXES + 2.0f +#else + 3.0f +#endif + }; - int table = 0; - int index; + int table = 0; + int index; - /* 25% chance for a rare shell */ - if (RANDOM(4) == 3) { - if (is_island == TRUE) { - table = 2; + /* 25% chance for a rare shell */ + if (RANDOM(4) == 3) { + if (is_island == TRUE) { + table = 2; + } else { + table = 1; + } } - else { - table = 1; - } - } - /* Return a random shell from the selected table */ - index = (int)RANDOM_F(shell_max[table]); - return shell_table[table][index]; + /* Return a random shell from the selected table */ + index = (int)RANDOM_F(shell_max[table]); + return shell_table[table][index]; } -static void mFI_SetShellBlock(mActor_name_t* fg_p, mCoBG_Collision_u* col_p, int shell_num, u8* can_set_ut_num, int is_island) { - mActor_name_t* fg = fg_p; - mCoBG_Collision_u* col = col_p; +static void mFI_SetShellBlock(mActor_name_t* fg_p, mCoBG_Collision_u* col_p, int shell_num, u8* can_set_ut_num, + int is_island) { + mActor_name_t* fg = fg_p; + mCoBG_Collision_u* col = col_p; - if (fg_p != NULL && col_p != NULL) { - while (shell_num != 0 && can_set_ut_num[0] != 0) { - int selected = RANDOM(can_set_ut_num[0]); - int i; - - fg_p = fg; - col_p = col; + if (fg_p != NULL && col_p != NULL) { + while (shell_num != 0 && can_set_ut_num[0] != 0) { + int selected = RANDOM(can_set_ut_num[0]); + int i; - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (fg_p[0] == EMPTY_NO && mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { - if (selected <= 0) { - fg_p[0] = mFI_GetShell(is_island); - shell_num--; - can_set_ut_num[0]--; - - break; - } - else { - selected--; - } + fg_p = fg; + col_p = col; + + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (fg_p[0] == EMPTY_NO && mCoBG_CheckWaveAttr(col_p->data.unit_attribute) == TRUE) { + if (selected <= 0) { + fg_p[0] = mFI_GetShell(is_island); + shell_num--; + can_set_ut_num[0]--; + + break; + } else { + selected--; + } + } + + fg_p++; + col_p++; + } + + if (i == UT_TOTAL_NUM) { + break; + } } - - fg_p++; - col_p++; - } - - if (i == UT_TOTAL_NUM) { - break; - } } - } } static void mFI_SetShellSandyBeachBlock(u8* can_set_ut_num, u8* shell_num_inblock) { - int bz; - int shell_num; - int bx; - int i; + int bz; + int shell_num; + int bx; + int i; - for (i = 0; i < 7; i++) { - if (can_set_ut_num[0] != 0) { - shell_num = shell_num_inblock[0]; + for (i = 0; i < 7; i++) { + if (can_set_ut_num[0] != 0) { + shell_num = shell_num_inblock[0]; - if (shell_num > 0) { - bx = l_sandy_beach_bx[i]; - bz = l_sandy_beach_bz[i]; + if (shell_num > 0) { + bx = l_sandy_beach_bx[i]; + bz = l_sandy_beach_bz[i]; - mFI_SetShellBlock(mFI_BkNumtoUtFGTop(bx, bz), mFI_GetBkNum2ColTop(bx, bz), shell_num, can_set_ut_num, bz == mISL_BLOCK_Z); - } + mFI_SetShellBlock(mFI_BkNumtoUtFGTop(bx, bz), mFI_GetBkNum2ColTop(bx, bz), shell_num, can_set_ut_num, + bz == mISL_BLOCK_Z); + } + } + + can_set_ut_num++; + shell_num_inblock++; } - - can_set_ut_num++; - shell_num_inblock++; - } } static void mFI_SetShellWave(int set_num, xyz_t player_pos) { - static u8 can_set_ut_num[7]; - static u8 shell_num_inblock[7]; - static u8 on_shell_num[7]; + static u8 can_set_ut_num[7]; + static u8 shell_num_inblock[7]; + static u8 on_shell_num[7]; - int total_blocks = 0; - int total_set_num = 0; + int total_blocks = 0; + int total_set_num = 0; - bzero(can_set_ut_num, sizeof(can_set_ut_num)); - bzero(shell_num_inblock, sizeof(shell_num_inblock)); - bzero(on_shell_num, sizeof(on_shell_num)); + bzero(can_set_ut_num, sizeof(can_set_ut_num)); + bzero(shell_num_inblock, sizeof(shell_num_inblock)); + bzero(on_shell_num, sizeof(on_shell_num)); - mFI_ResearchShell(can_set_ut_num, on_shell_num, &total_set_num, &total_blocks, player_pos); + mFI_ResearchShell(can_set_ut_num, on_shell_num, &total_set_num, &total_blocks, player_pos); - if (set_num > total_set_num) { - set_num = total_set_num; - } + if (set_num > total_set_num) { + set_num = total_set_num; + } - if (total_blocks > 0 && set_num > 0) { - mFI_DivideShell(can_set_ut_num, shell_num_inblock, on_shell_num, set_num, total_blocks); - mFI_SetShellSandyBeachBlock(can_set_ut_num, shell_num_inblock); - } + if (total_blocks > 0 && set_num > 0) { + mFI_DivideShell(can_set_ut_num, shell_num_inblock, on_shell_num, set_num, total_blocks); + mFI_SetShellSandyBeachBlock(can_set_ut_num, shell_num_inblock); + } } static void mFI_SetShell(xyz_t player_pos) { - static int set_flag; + static int set_flag; - if (mFI_CheckSetShell() == TRUE) { - if (set_flag == FALSE) { - set_flag = TRUE; - l_reserve_set_shell++; + if (mFI_CheckSetShell() == TRUE) { + if (set_flag == FALSE) { + set_flag = TRUE; + l_reserve_set_shell++; + } + } else { + set_flag = FALSE; } - } - else { - set_flag = FALSE; - } - if (mFI_CheckFieldData() == TRUE) { - mActor_name_t field_id = mFI_GetFieldId(); + if (mFI_CheckFieldData() == TRUE) { + mActor_name_t field_id = mFI_GetFieldId(); - if (Save_Get(scene_no) == SCENE_FG && mFI_GET_TYPE(field_id) == mFI_FIELD_FG && l_reserve_set_shell > 0) { - mFI_SetShellWave(l_reserve_set_shell, player_pos); - l_reserve_set_shell = 0; + if (Save_Get(scene_no) == SCENE_FG && mFI_GET_TYPE(field_id) == mFI_FIELD_FG && l_reserve_set_shell > 0) { + mFI_SetShellWave(l_reserve_set_shell, player_pos); + l_reserve_set_shell = 0; + } } - } } static int mFI_now_bg_num; extern void mFI_FieldMove(xyz_t player_pos) { - mFI_BGDisplayListRefresh(player_pos); - mFI_DmaBg(); - mFI_SetPlayerBlockKind(player_pos); - mFI_SetShell(player_pos); - mMsr_SetMushroom(player_pos); - mFRm_save_data_check(); + mFI_BGDisplayListRefresh(player_pos); + mFI_DmaBg(); + mFI_SetPlayerBlockKind(player_pos); + mFI_SetShell(player_pos); + mMsr_SetMushroom(player_pos); + mFRm_save_data_check(); - if (mFI_CheckFieldData() == TRUE) { - int bx; - int bz; + if (mFI_CheckFieldData() == TRUE) { + int bx; + int bz; - if (mFI_Wpos2BlockNum(&bx, &bz, player_pos) == TRUE) { - int num = mFI_GetBlockNum(bx, bz); - mFM_block_info_c* block_info = g_fdinfo->block_info + num; + if (mFI_Wpos2BlockNum(&bx, &bz, player_pos) == TRUE) { + int num = mFI_GetBlockNum(bx, bz); + mFM_block_info_c* block_info = g_fdinfo->block_info + num; - if (block_info != NULL) { - mFI_now_bg_num = block_info->bg_info.bg_id.combination_type; - } + if (block_info != NULL) { + mFI_now_bg_num = block_info->bg_info.bg_id.combination_type; + } + } } - } } extern void mFI_PrintNowBGNum(gfxprint_t* gfxprint) { - gfxprint_color(gfxprint, 200, 200, 250, 255); - gfxprint_locate8x8(gfxprint, 3, 7); - gfxprint_printf(gfxprint, "%d", mFI_now_bg_num); + gfxprint_color(gfxprint, 200, 200, 250, 255); + gfxprint_locate8x8(gfxprint, 3, 7); + gfxprint_printf(gfxprint, "%d", mFI_now_bg_num); } extern void mFI_PrintFgAttr(gfxprint_t* gfxprint) { - if (mFI_CheckFieldData() && gamePT != NULL) { - int ut_x; - int ut_z; - u32 attribute; + if (mFI_CheckFieldData() && gamePT != NULL) { + int ut_x; + int ut_z; + u32 attribute; - PLAYER_ACTOR* player = GET_PLAYER_ACTOR_NOW(); - mActor_name_t item = EMPTY_NO; - mActor_name_t* fg_item_p = mFI_GetUnitFG(player->actor_class.world.position); - int plant = mCoBG_CheckPlant(player->actor_class.world.position); + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_NOW(); + mActor_name_t item = EMPTY_NO; + mActor_name_t* fg_item_p = mFI_GetUnitFG(player->actor_class.world.position); + int plant = mCoBG_CheckPlant(player->actor_class.world.position); - if (fg_item_p != NULL) { - item = fg_item_p[0]; + if (fg_item_p != NULL) { + item = fg_item_p[0]; + } + + mFI_Wpos2UtNum_inBlock(&ut_x, &ut_z, player->actor_class.world.position); + attribute = mCoBG_Wpos2BgAttribute_Original(player->actor_class.world.position); + + gfxprint_color(gfxprint, 200, 200, 250, 255); + gfxprint_locate8x8(gfxprint, 3, 8); + gfxprint_printf(gfxprint, "%d,%d - %4x - %d - %d", ut_x, ut_z, item, attribute, plant); } - - mFI_Wpos2UtNum_inBlock(&ut_x, &ut_z, player->actor_class.world.position); - attribute = mCoBG_Wpos2BgAttribute_Original(player->actor_class.world.position); - - gfxprint_color(gfxprint, 200, 200, 250, 255); - gfxprint_locate8x8(gfxprint, 3, 8); - gfxprint_printf(gfxprint, "%d,%d - %4x - %d - %d", ut_x, ut_z, item, attribute, plant); - } } extern int mFI_SetOyasiroPos(s16* oyasiro_p) { - int bx; - int bz; + int bx; + int bz; - if (mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_SHRINE) == TRUE) { - int ut_x; - int ut_z; + if (mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_SHRINE) == TRUE) { + int ut_x; + int ut_z; - if ( - mFI_SearchFGInBlock(&ut_x, &ut_z, WISHING_WELL, bx, bz) == FALSE && - mFI_SearchFGInBlock(&ut_x, &ut_z, 0xF103, bx, bz) == FALSE - ) { - return FALSE; + if (mFI_SearchFGInBlock(&ut_x, &ut_z, WISHING_WELL, bx, bz) == FALSE && + mFI_SearchFGInBlock(&ut_x, &ut_z, 0xF103, bx, bz) == FALSE) { + return FALSE; + } else { + xyz_t pos; + + mFI_BkandUtNum2CenterWpos(&pos, bx, bz, ut_x, ut_z); + oyasiro_p[0] = (s16)pos.x; + oyasiro_p[1] = (s16)pos.z; // @BUG - maybe a bug? You'd think it'd be .y then .z + oyasiro_p[2] = (s16)pos.y; + + return TRUE; + } + } else { + return FALSE; } - else { - xyz_t pos; - - mFI_BkandUtNum2CenterWpos(&pos, bx, bz, ut_x, ut_z); - oyasiro_p[0] = (s16)pos.x; - oyasiro_p[1] = (s16)pos.z; // @BUG - maybe a bug? You'd think it'd be .y then .z - oyasiro_p[2] = (s16)pos.y; - - return TRUE; - } - } - else { - return FALSE; - } } static int mFI_CheckBlockSetTreasure(int* block, int bx, int bz) { - int i; + int i; - for (i = 0; i < 4; i++) { - if (bx == block[0] && bz == block[1]) { - return FALSE; + for (i = 0; i < 4; i++) { + if (bx == block[0] && bz == block[1]) { + return FALSE; + } + + block += 2; } - block += 2; - } - - return TRUE; + return TRUE; } extern int mFI_SetTreasure(int* selected_bx, int* selected_bz, mActor_name_t item) { - static int no_check_block_table[2 * 4] = { - 3, 1, /* train station */ - 3, 2, /* player house */ - 0, 0, /* wishing well/shrine (dynamic) */ - 0, 0 /* lake (dynamic) */ - }; + static int no_check_block_table[2 * 4] = { + 3, 1, /* train station */ + 3, 2, /* player house */ + 0, 0, /* wishing well/shrine (dynamic) */ + 0, 0 /* lake (dynamic) */ + }; - u8 depositable_num_block[FG_BLOCK_TOTAL_NUM]; - mFM_fg_c* fg_block; - mFM_fg_c* fg_block_p; - u8* depositable_num_p2; - u8* depositable_num_p; - u8 depositable_blocks; - int res; + u8 depositable_num_block[FG_BLOCK_TOTAL_NUM]; + mFM_fg_c* fg_block; + mFM_fg_c* fg_block_p; + u8* depositable_num_p2; + u8* depositable_num_p; + u8 depositable_blocks; + int res; - fg_block = Save_Get(fg[0]); - fg_block_p = fg_block; - depositable_num_p = depositable_num_block; - depositable_blocks = 0; - res = FALSE; + fg_block = Save_Get(fg[0]); + fg_block_p = fg_block; + depositable_num_p = depositable_num_block; + depositable_blocks = 0; + res = FALSE; - if (Save_Get(scene_no) == SCENE_FG) { - int bz; + if (Save_Get(scene_no) == SCENE_FG) { + int bz; - bzero(depositable_num_p, FG_BLOCK_TOTAL_NUM); - mFI_BlockKind2BkNum(&no_check_block_table[4], &no_check_block_table[5], mRF_BLOCKKIND_SHRINE); - mFI_BlockKind2BkNum(&no_check_block_table[6], &no_check_block_table[7], mRF_BLOCKKIND_POOL); + bzero(depositable_num_p, FG_BLOCK_TOTAL_NUM); + mFI_BlockKind2BkNum(&no_check_block_table[4], &no_check_block_table[5], mRF_BLOCKKIND_SHRINE); + mFI_BlockKind2BkNum(&no_check_block_table[6], &no_check_block_table[7], mRF_BLOCKKIND_POOL); - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - int bx; + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { + int bx; - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - if (mFI_CheckBlockSetTreasure(no_check_block_table, bx + 1, bz + 1) == TRUE) { - mCoBG_Collision_u* col_p = mFI_GetBkNum2ColTop(bx + 1, bz + 1); - - depositable_num_p[0] = mMsm_GetDepositAbleNum(fg_block_p->items[0], col_p); + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { + if (mFI_CheckBlockSetTreasure(no_check_block_table, bx + 1, bz + 1) == TRUE) { + mCoBG_Collision_u* col_p = mFI_GetBkNum2ColTop(bx + 1, bz + 1); - if (depositable_num_p[0] != 0) { - depositable_blocks++; - } + depositable_num_p[0] = mMsm_GetDepositAbleNum(fg_block_p->items[0], col_p); + + if (depositable_num_p[0] != 0) { + depositable_blocks++; + } + } + + depositable_num_p++; + fg_block_p++; + } } - depositable_num_p++; - fg_block_p++; - } - } + if (depositable_blocks != 0) { + u8* depositable_num_p; // removing this line fixes regalloc but causes regswaps + int selected_block; + int i; - if (depositable_blocks != 0) { - u8* depositable_num_p; // removing this line fixes regalloc but causes regswaps - int selected_block; - int i; - - depositable_num_p2 = depositable_num_block; - selected_block = RANDOM(depositable_blocks); - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - if (depositable_num_p2[0] != 0) { - if (selected_block <= 0) { - selected_bx[0] = (i % FG_BLOCK_X_NUM) + 1; - selected_bz[0] = (i / FG_BLOCK_X_NUM) + 1; - mMsm_DepositItemBlock(fg_block->items[0], item, selected_bx[0], selected_bz[0], Save_Get(deposit[i]), depositable_num_p2[0]); - res = TRUE; + depositable_num_p2 = depositable_num_block; + selected_block = RANDOM(depositable_blocks); + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + if (depositable_num_p2[0] != 0) { + if (selected_block <= 0) { + selected_bx[0] = (i % FG_BLOCK_X_NUM) + 1; + selected_bz[0] = (i / FG_BLOCK_X_NUM) + 1; + mMsm_DepositItemBlock(fg_block->items[0], item, selected_bx[0], selected_bz[0], + Save_Get(deposit[i]), depositable_num_p2[0]); + res = TRUE; - break; - } - else { - selected_block--; - } + break; + } else { + selected_block--; + } + } + + depositable_num_p2++; + fg_block++; + } } - - depositable_num_p2++; - fg_block++; - } } - } - return res; + return res; } static int l_mFI_climate; extern int mFI_GetClimate() { - switch (l_mFI_climate) { - case mFI_CLIMATE_2: - case mFI_CLIMATE_3: - case mFI_CLIMATE_4: - case mFI_CLIMATE_5: - return FALSE; - default: - return l_mFI_climate & 1; - } + switch (l_mFI_climate) { + case mFI_CLIMATE_2: + case mFI_CLIMATE_3: + case mFI_CLIMATE_4: + case mFI_CLIMATE_5: + return FALSE; + default: + return l_mFI_climate & 1; + } } extern void mFI_SetClimate(int climate) { - if (climate == mFI_CLIMATE_NUM) { - switch (l_mFI_climate) { - case mFI_CLIMATE_0: - l_mFI_climate = mFI_CLIMATE_2; - break; - case mFI_CLIMATE_ISLAND: - l_mFI_climate = mFI_CLIMATE_3; - break; + if (climate == mFI_CLIMATE_NUM) { + switch (l_mFI_climate) { + case mFI_CLIMATE_0: + l_mFI_climate = mFI_CLIMATE_2; + break; + case mFI_CLIMATE_ISLAND: + l_mFI_climate = mFI_CLIMATE_3; + break; + } + } else { + l_mFI_climate = climate; } - } - else { - l_mFI_climate = climate; - } } extern int mFI_CheckBeforeScenePerpetual() { - switch (l_mFI_climate) { - case mFI_CLIMATE_3: - case mFI_CLIMATE_5: - return TRUE; - default: - return FALSE; - } + switch (l_mFI_climate) { + case mFI_CLIMATE_3: + case mFI_CLIMATE_5: + return TRUE; + default: + return FALSE; + } } extern void mFI_ChangeClimate_ForEventNotice() { - switch (l_mFI_climate) { - case mFI_CLIMATE_2: - l_mFI_climate = mFI_CLIMATE_4; - break; - case mFI_CLIMATE_4: - l_mFI_climate = mFI_CLIMATE_0; - break; - case mFI_CLIMATE_3: - l_mFI_climate = mFI_CLIMATE_5; - break; - case mFI_CLIMATE_5: - l_mFI_climate = mFI_CLIMATE_ISLAND; - break; - } + switch (l_mFI_climate) { + case mFI_CLIMATE_2: + l_mFI_climate = mFI_CLIMATE_4; + break; + case mFI_CLIMATE_4: + l_mFI_climate = mFI_CLIMATE_0; + break; + case mFI_CLIMATE_3: + l_mFI_climate = mFI_CLIMATE_5; + break; + case mFI_CLIMATE_5: + l_mFI_climate = mFI_CLIMATE_ISLAND; + break; + } - mCoBG_InitBoatCollision(); + mCoBG_InitBoatCollision(); } extern void mFI_PullTanukiPathTrees() { - static u8 ut_table[6] = { - 0x07, 0x08, - 0x17, 0x18, - 0x27, 0x28 - }; + static u8 ut_table[6] = { 0x07, 0x08, 0x17, 0x18, 0x27, 0x28 }; - mActor_name_t* fg_p = Save_Get(fg[2][2]).items[0]; - int i; + mActor_name_t* fg_p = Save_Get(fg[2][2]).items[0]; + int i; - for (i = 0; i < 6; i++) { - int ut = ut_table[i]; - - if ( - (fg_p[ut] == TREE_S0) || - (fg_p[ut] == TREE_S1) || - (fg_p[ut] == TREE_S2) || - (fg_p[ut] == TREE) || - (fg_p[ut] == TREE_1000BELLS_S0) || - (fg_p[ut] == TREE_1000BELLS_S1) || - (fg_p[ut] == TREE_1000BELLS_S2) || - (fg_p[ut] == TREE_1000BELLS) || - (fg_p[ut] == TREE_10000BELLS_S0) || - (fg_p[ut] == TREE_10000BELLS_S1) || - (fg_p[ut] == TREE_10000BELLS_S2) || - (fg_p[ut] == TREE_10000BELLS) || - (fg_p[ut] == TREE_30000BELLS_S0) || - (fg_p[ut] == TREE_30000BELLS_S1) || - (fg_p[ut] == TREE_30000BELLS_S2) || - (fg_p[ut] == TREE_30000BELLS) || - (fg_p[ut] == TREE_100BELLS_S0) || - (fg_p[ut] == TREE_100BELLS_S1) || - (fg_p[ut] == TREE_100BELLS_S2) || - (fg_p[ut] == TREE_100BELLS) || - (fg_p[ut] == CEDAR_TREE_S0) || - (fg_p[ut] == CEDAR_TREE_S1) || - (fg_p[ut] == CEDAR_TREE_S2) || - (fg_p[ut] == CEDAR_TREE) || - (fg_p[ut] == GOLD_TREE_S0) || - (fg_p[ut] == GOLD_TREE_S1) || - (fg_p[ut] == GOLD_TREE_S2) || - (fg_p[ut] == GOLD_TREE) || - (fg_p[ut] == GOLD_TREE_SHOVEL) || - (fg_p[ut] == TREE_APPLE_S0) || - (fg_p[ut] == TREE_APPLE_S1) || - (fg_p[ut] == TREE_APPLE_S2) || - (fg_p[ut] == TREE_APPLE_NOFRUIT_0) || - (fg_p[ut] == TREE_APPLE_NOFRUIT_1) || - (fg_p[ut] == TREE_APPLE_NOFRUIT_2) || - (fg_p[ut] == TREE_APPLE_FRUIT) || - (fg_p[ut] == TREE_ORANGE_S0) || - (fg_p[ut] == TREE_ORANGE_S1) || - (fg_p[ut] == TREE_ORANGE_S2) || - (fg_p[ut] == TREE_ORANGE_NOFRUIT_0) || - (fg_p[ut] == TREE_ORANGE_NOFRUIT_1) || - (fg_p[ut] == TREE_ORANGE_NOFRUIT_2) || - (fg_p[ut] == TREE_ORANGE_FRUIT) || - (fg_p[ut] == TREE_PEACH_S0) || - (fg_p[ut] == TREE_PEACH_S1) || - (fg_p[ut] == TREE_PEACH_S2) || - (fg_p[ut] == TREE_PEACH_NOFRUIT_0) || - (fg_p[ut] == TREE_PEACH_NOFRUIT_1) || - (fg_p[ut] == TREE_PEACH_NOFRUIT_2) || - (fg_p[ut] == TREE_PEACH_FRUIT) || - (fg_p[ut] == TREE_PEAR_S0) || - (fg_p[ut] == TREE_PEAR_S1) || - (fg_p[ut] == TREE_PEAR_S2) || - (fg_p[ut] == TREE_PEAR_NOFRUIT_0) || - (fg_p[ut] == TREE_PEAR_NOFRUIT_1) || - (fg_p[ut] == TREE_PEAR_NOFRUIT_2) || - (fg_p[ut] == TREE_PEAR_FRUIT) || - (fg_p[ut] == TREE_CHERRY_S0) || - (fg_p[ut] == TREE_CHERRY_S1) || - (fg_p[ut] == TREE_CHERRY_S2) || - (fg_p[ut] == TREE_CHERRY_NOFRUIT_0) || - (fg_p[ut] == TREE_CHERRY_NOFRUIT_1) || - (fg_p[ut] == TREE_CHERRY_NOFRUIT_2) || - (fg_p[ut] == TREE_CHERRY_FRUIT) || - (fg_p[ut] == TREE_PALM_S0) || - (fg_p[ut] == TREE_PALM_S1) || - (fg_p[ut] == TREE_PALM_S2) || - (fg_p[ut] == TREE_PALM_NOFRUIT_0) || - (fg_p[ut] == TREE_PALM_NOFRUIT_1) || - (fg_p[ut] == TREE_PALM_NOFRUIT_2) || - (fg_p[ut] == TREE_PALM_FRUIT) || - (fg_p[ut] == TREE_BEES) || - (fg_p[ut] == TREE_FTR) || - (fg_p[ut] == TREE_LIGHTS) || - (fg_p[ut] == TREE_PRESENT) || - (fg_p[ut] == TREE_BELLS) || - (fg_p[ut] == CEDAR_TREE_BELLS) || - (fg_p[ut] == CEDAR_TREE_FTR) || - (fg_p[ut] == CEDAR_TREE_BEES) || - (fg_p[ut] == CEDAR_TREE_LIGHTS) || - (fg_p[ut] == GOLD_TREE_BELLS) || - (fg_p[ut] == GOLD_TREE_FTR) || - (fg_p[ut] == GOLD_TREE_BEES) - ) { - fg_p[ut] = EMPTY_NO; + for (i = 0; i < 6; i++) { + int ut = ut_table[i]; + + if ((fg_p[ut] == TREE_S0) || (fg_p[ut] == TREE_S1) || (fg_p[ut] == TREE_S2) || (fg_p[ut] == TREE) || + (fg_p[ut] == TREE_1000BELLS_S0) || (fg_p[ut] == TREE_1000BELLS_S1) || (fg_p[ut] == TREE_1000BELLS_S2) || + (fg_p[ut] == TREE_1000BELLS) || (fg_p[ut] == TREE_10000BELLS_S0) || (fg_p[ut] == TREE_10000BELLS_S1) || + (fg_p[ut] == TREE_10000BELLS_S2) || (fg_p[ut] == TREE_10000BELLS) || (fg_p[ut] == TREE_30000BELLS_S0) || + (fg_p[ut] == TREE_30000BELLS_S1) || (fg_p[ut] == TREE_30000BELLS_S2) || (fg_p[ut] == TREE_30000BELLS) || + (fg_p[ut] == TREE_100BELLS_S0) || (fg_p[ut] == TREE_100BELLS_S1) || (fg_p[ut] == TREE_100BELLS_S2) || + (fg_p[ut] == TREE_100BELLS) || (fg_p[ut] == CEDAR_TREE_S0) || (fg_p[ut] == CEDAR_TREE_S1) || + (fg_p[ut] == CEDAR_TREE_S2) || (fg_p[ut] == CEDAR_TREE) || (fg_p[ut] == GOLD_TREE_S0) || + (fg_p[ut] == GOLD_TREE_S1) || (fg_p[ut] == GOLD_TREE_S2) || (fg_p[ut] == GOLD_TREE) || + (fg_p[ut] == GOLD_TREE_SHOVEL) || (fg_p[ut] == TREE_APPLE_S0) || (fg_p[ut] == TREE_APPLE_S1) || + (fg_p[ut] == TREE_APPLE_S2) || (fg_p[ut] == TREE_APPLE_NOFRUIT_0) || (fg_p[ut] == TREE_APPLE_NOFRUIT_1) || + (fg_p[ut] == TREE_APPLE_NOFRUIT_2) || (fg_p[ut] == TREE_APPLE_FRUIT) || (fg_p[ut] == TREE_ORANGE_S0) || + (fg_p[ut] == TREE_ORANGE_S1) || (fg_p[ut] == TREE_ORANGE_S2) || (fg_p[ut] == TREE_ORANGE_NOFRUIT_0) || + (fg_p[ut] == TREE_ORANGE_NOFRUIT_1) || (fg_p[ut] == TREE_ORANGE_NOFRUIT_2) || + (fg_p[ut] == TREE_ORANGE_FRUIT) || (fg_p[ut] == TREE_PEACH_S0) || (fg_p[ut] == TREE_PEACH_S1) || + (fg_p[ut] == TREE_PEACH_S2) || (fg_p[ut] == TREE_PEACH_NOFRUIT_0) || (fg_p[ut] == TREE_PEACH_NOFRUIT_1) || + (fg_p[ut] == TREE_PEACH_NOFRUIT_2) || (fg_p[ut] == TREE_PEACH_FRUIT) || (fg_p[ut] == TREE_PEAR_S0) || + (fg_p[ut] == TREE_PEAR_S1) || (fg_p[ut] == TREE_PEAR_S2) || (fg_p[ut] == TREE_PEAR_NOFRUIT_0) || + (fg_p[ut] == TREE_PEAR_NOFRUIT_1) || (fg_p[ut] == TREE_PEAR_NOFRUIT_2) || (fg_p[ut] == TREE_PEAR_FRUIT) || + (fg_p[ut] == TREE_CHERRY_S0) || (fg_p[ut] == TREE_CHERRY_S1) || (fg_p[ut] == TREE_CHERRY_S2) || + (fg_p[ut] == TREE_CHERRY_NOFRUIT_0) || (fg_p[ut] == TREE_CHERRY_NOFRUIT_1) || + (fg_p[ut] == TREE_CHERRY_NOFRUIT_2) || (fg_p[ut] == TREE_CHERRY_FRUIT) || (fg_p[ut] == TREE_PALM_S0) || + (fg_p[ut] == TREE_PALM_S1) || (fg_p[ut] == TREE_PALM_S2) || (fg_p[ut] == TREE_PALM_NOFRUIT_0) || + (fg_p[ut] == TREE_PALM_NOFRUIT_1) || (fg_p[ut] == TREE_PALM_NOFRUIT_2) || (fg_p[ut] == TREE_PALM_FRUIT) || + (fg_p[ut] == TREE_BEES) || (fg_p[ut] == TREE_FTR) || (fg_p[ut] == TREE_LIGHTS) || + (fg_p[ut] == TREE_PRESENT) || (fg_p[ut] == TREE_BELLS) || (fg_p[ut] == CEDAR_TREE_BELLS) || + (fg_p[ut] == CEDAR_TREE_FTR) || (fg_p[ut] == CEDAR_TREE_BEES) || (fg_p[ut] == CEDAR_TREE_LIGHTS) || + (fg_p[ut] == GOLD_TREE_BELLS) || (fg_p[ut] == GOLD_TREE_FTR) || (fg_p[ut] == GOLD_TREE_BEES)) { + fg_p[ut] = EMPTY_NO; + } } - } } diff --git a/src/m_island.c b/src/m_island.c index 9d26a8c8..7385836e 100644 --- a/src/m_island.c +++ b/src/m_island.c @@ -738,7 +738,7 @@ static void mISL_toHole(mActor_name_t* fg, u16* deposit, int bx, int bz) { hole_no = 0; } - fg[0] = BURIED_PITFALL_START + hole_no; + fg[0] = BURIED_PITFALL_HOLE_START + hole_no; deposit[0] &= ~(1 << ut_x); } diff --git a/src/m_museum.c b/src/m_museum.c index 116bc243..5d8d10fd 100644 --- a/src/m_museum.c +++ b/src/m_museum.c @@ -450,7 +450,7 @@ extern void mMsm_DepositItemBlock(mActor_name_t* fg_items, mActor_name_t item, i int hole_num = mCoBG_BnumUnum2HoleNumber(block_x, block_z, ut_x, ut_z); if (hole_num != -1) { - *fg_items = BURIED_PITFALL_START + hole_num; + *fg_items = BURIED_PITFALL_HOLE_START + hole_num; } } diff --git a/src/m_name_table.c b/src/m_name_table.c index ec73b22d..3be2a062 100644 --- a/src/m_name_table.c +++ b/src/m_name_table.c @@ -315,7 +315,7 @@ extern mActor_name_t bg_item_fg_sub_dig2take_conv(mActor_name_t item) { mActor_name_t dig_item; dig_item = item; - if ((item >= BURIED_PITFALL_START) && (item <= BURIED_PITFALL_END)) { + if ((item >= BURIED_PITFALL_HOLE_START) && (item <= BURIED_PITFALL_HOLE_END)) { dig_item = ITM_PITFALL; } diff --git a/src/m_player.c b/src/m_player.c index 05c43db1..866e41e2 100644 --- a/src/m_player.c +++ b/src/m_player.c @@ -7,6 +7,10 @@ #include "sys_matrix.h" #include "ac_tools.h" #include "m_rcp.h" +#include "ac_my_room.h" +#include "ac_insect.h" +#include "ac_set_ovl_insect.h" +#include "m_house.h" /* Common */ #include "../src/m_player_controller.c_inc" @@ -197,18 +201,18 @@ static int Player_actor_request_main_demo_getoff_boat_standup_all(GAME*, const x static int Player_actor_request_main_demo_get_golden_item2_all(GAME*, int, int); static int Player_actor_request_main_demo_get_golden_axe_wait_all(GAME*, int); static int Player_actor_check_request_main_priority(GAME*, int); -static void* Player_actor_get_door_label(GAME*); +static u32 Player_actor_get_door_label(GAME*); static int Player_actor_Set_Item_net_catch_request_table(ACTOR*, GAME*, u32, s8, const xyz_t*, f32); static f32 Player_actor_Get_Item_net_catch_swing_timer(ACTOR*, GAME*); -static u8 Player_actor_Set_Item_net_catch_request_force(ACTOR*, GAME*, u32, s8); +static int Player_actor_Set_Item_net_catch_request_force(ACTOR*, GAME*, u32, s8); static void Player_actor_Set_force_position_angle(GAME*, const xyz_t*, const s_xyz*, u8); static u8 Player_actor_Get_force_position_angle(GAME*, xyz_t*, s_xyz*); static int Player_actor_Get_WadeEndPos(GAME*, xyz_t*); -static int Player_actor_Check_Label_main_push_snowball(GAME*, void*); +static int Player_actor_Check_Label_main_push_snowball(GAME*, u32); static int Player_actor_SetParam_for_push_snowball(GAME*, const xyz_t*, s16, f32); static int Player_actor_able_submenu_request_main_index(GAME*); static int Player_actor_check_able_change_camera_normal_index(ACTOR*); -static int Player_actor_Check_able_force_speak_label(GAME*, ACTOR*); +static int Player_actor_Check_able_force_speak_label(GAME*, u32); static int Player_actor_check_cancel_request_change_proc_index(int); static u32 Player_actor_Get_item_net_catch_label(ACTOR*); static int Player_actor_Change_item_net_catch_label(ACTOR*, u32, s8); @@ -225,18 +229,20 @@ static int Player_actor_Set_ScrollDemo_forWade_snowball(ACTOR*, int, const xyz_t static int Player_actor_Check_tree_shaken(ACTOR*, const xyz_t*); static int Player_actor_Check_tree_shaken_little(ACTOR*, const xyz_t*); static int Player_actor_Check_tree_shaken_big(ACTOR*, const xyz_t*); -static int Player_actor_Check_Label_main_wade_snowball(GAME*, void*); +static int Player_actor_Check_Label_main_wade_snowball(GAME*, u32); static int Player_actor_GetSnowballPos_forWadeSnowball(ACTOR*, xyz_t*); static int Player_actor_CheckCondition_forWadeSnowball(GAME*, const xyz_t*, s16); static mActor_name_t Player_actor_Get_itemNo_forWindow(ACTOR*); static int Player_actor_check_cancel_event_without_priority(GAME*); static int Player_actor_CheckScene_AbleSubmenu(void); -static int Player_actor_Check_stung_mosquito(GAME*, ACTOR*); +static int Player_actor_Check_stung_mosquito(GAME*, u32); static int Player_actor_request_main_walk_all(GAME*, xyz_t*, f32, int, int); static int Player_actor_request_main_run_all(GAME*, f32, int, int); static int Player_actor_request_main_dash_all(GAME*, f32, int, int); +static void Player_actor_Refuse_pickup_demo_ct(ACTOR*); + static void Player_actor_init_value(ACTOR* actorx, GAME* game) { PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; GAME_PLAY* play = (GAME_PLAY*)game; @@ -255,7 +261,7 @@ static void Player_actor_init_value(ACTOR* actorx, GAME* game) { actorx->world.position.z, 0, 0, 0, -1, -1, -1, EMPTY_NO, -1, -1, -1); player->animation0_idx = -1; player->animation1_idx = -1; - player->_0DBC = -1; + player->part_table_idx = -1; player->item_shape_type[0] = -1; player->item_shape_type[1] = -1; player->item_shape_type[2] = -1; diff --git a/src/m_player_common.c_inc b/src/m_player_common.c_inc index e69de29b..4bedc8b9 100644 --- a/src/m_player_common.c_inc +++ b/src/m_player_common.c_inc @@ -0,0 +1,8541 @@ +static int Player_actor_check_request_main_priority(GAME* game, int priority) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + return priority - player->requested_main_index_priority; +} + +static void Player_actor_request_main_index(GAME* game, int request_index, int priority) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + player->requested_main_index = request_index; + player->requested_main_index_priority = priority; + player->requested_main_index_changed = TRUE; +} + +static void Player_actor_Set_start_refuse(ACTOR* actorx, GAME* game) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int idx = player->now_main_index; + GAME_PLAY* play = (GAME_PLAY*)game; + + if (mPlayer_MAIN_INDEX_VALID(idx) != FALSE) { + if (data[idx]) { + play->submenu.start_refuse = FALSE; + } else { + play->submenu.start_refuse = TRUE; + } + } +} + +static void Player_actor_Set_address_able_display(ACTOR* actorx) { + // clang-format off + static const s8 data[] = { + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_READY_NET, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_TALKING, + }; + // clang-format on + + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int idx = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(idx) != FALSE) { + player->address_able_display = data[idx]; + } +} + +static f32 Player_actor_Get_DemoMoveSpeedF(void) { + return (f32)mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 7) * 0.01f; +} + +static void Player_actor_Set_force_shadow_position(ACTOR* actorx, xyz_t* pos) { + mActorShadow_SetForceShadowPos(actorx, pos); +} + +static void Player_actor_Set_force_shadow_position_fromAnimePosition(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0 = &player->keyframe0; + xyz_t* pos_p = &player->shadow_pos; + + cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(pos_p, &actorx->world.position, 0.0f, 1000.0f, 0.0f, + actorx->shape_info.rotation.y, &actorx->scale, kf0, + cKF_ANIMATION_TRANS_XZ | cKF_ANIMATION_TRANS_Y); + Player_actor_Set_force_shadow_position(actorx, pos_p); +} + +static void Player_actor_Set_force_shadow_position_fromWorldPosition(ACTOR* actorx) { + Player_actor_Set_force_shadow_position(actorx, &actorx->world.position); +} + +static void Player_actor_SetupShadow(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int idx = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(idx) != FALSE) { + // clang-format off + static const s8 data[] = { + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_WORLD_POS, + mPlayer_SHADOW_TYPE_ANIME_POS, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NONE, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + mPlayer_SHADOW_TYPE_NORMAL, + }; + // clang-format on + + switch (data[idx]) { + case mPlayer_SHADOW_TYPE_ANIME_POS: + actorx->shape_info.draw_shadow = TRUE; + Player_actor_Set_force_shadow_position_fromAnimePosition(actorx); + break; + case mPlayer_SHADOW_TYPE_WORLD_POS: + actorx->shape_info.draw_shadow = TRUE; + Player_actor_Set_force_shadow_position_fromWorldPosition(actorx); + break; + case mPlayer_SHADOW_TYPE_NONE: + actorx->shape_info.draw_shadow = FALSE; + break; + default: + actorx->shape_info.draw_shadow = TRUE; + mActorShadow_UnSetForceShadowPos(actorx); + break; + } + } +} + +static void Player_actor_SetupSpeedF(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int idx = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(idx) != FALSE) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + if (data[idx] == FALSE) { + actorx->speed = 0.0f; + } + } +} + +static int Player_actor_Get_SetupRequestMainIndexPriority(int main_index) { + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + mPlayer_REQUEST_PRIORITY_41, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_34, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_43, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_22, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_22, + mPlayer_REQUEST_PRIORITY_22, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_22, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_11, + mPlayer_REQUEST_PRIORITY_11, + mPlayer_REQUEST_PRIORITY_12, + mPlayer_REQUEST_PRIORITY_22, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_27, + mPlayer_REQUEST_PRIORITY_28, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_22, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_27, + mPlayer_REQUEST_PRIORITY_28, + mPlayer_REQUEST_PRIORITY_29, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_21, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_37, + mPlayer_REQUEST_PRIORITY_37, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_43, + mPlayer_REQUEST_PRIORITY_43, + mPlayer_REQUEST_PRIORITY_30, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_27, + mPlayer_REQUEST_PRIORITY_28, + mPlayer_REQUEST_PRIORITY_29, + mPlayer_REQUEST_PRIORITY_25, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_38, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_44, + mPlayer_REQUEST_PRIORITY_43, + mPlayer_REQUEST_PRIORITY_25, + mPlayer_REQUEST_PRIORITY_26, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_20, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_19, + mPlayer_REQUEST_PRIORITY_34, + mPlayer_REQUEST_PRIORITY_34, + mPlayer_REQUEST_PRIORITY_33, + }; + // clang-format on + + int priority = data[main_index]; + + if (mPlayer_REQUEST_PRIORITY_VALID(priority)) { + return priority; + } + } + + return mPlayer_REQUEST_PRIORITY_NONE; +} + +static void Player_actor_SetupRequestMainIndexPriority(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_index = player->now_main_index; + int priority = Player_actor_Get_SetupRequestMainIndexPriority(main_index); + + if (mPlayer_REQUEST_PRIORITY_VALID(priority)) { + player->requested_main_index_priority = priority; + } +} + +static void Player_actor_SettleRequestMainIndexPriority(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_index = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_36, + mPlayer_REQUEST_PRIORITY_36, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_44, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_18, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_0, + mPlayer_REQUEST_PRIORITY_NONE, + }; + // clang-format on + + int priority = data[main_index]; + + if (mPlayer_REQUEST_PRIORITY_VALID(priority) && player->settled_requested_main_index_priority == FALSE && + player->requested_main_index_changed == FALSE) { + int requested_main_index_priority = player->requested_main_index_priority; + + if (requested_main_index_priority == Player_actor_Get_SetupRequestMainIndexPriority(main_index)) { + player->requested_main_index_priority = priority; + player->settled_requested_main_index_priority = TRUE; + } + } + } +} + +static void Player_actor_set_eye_pattern(ACTOR* actorx, int idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->eye_tex_idx = idx; +} + +static void Player_actor_set_eye_pattern_normal(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + mPlayer_eye_pattern_c* eye_pattern_p = &player->eye_pattern_normal; + s16* timer_p = &eye_pattern_p->timer; + s16* pattern_p = &eye_pattern_p->pattern; + int* blink_count_p = &player->blink_count; + int idx; + static const s8 pattern_table[] = { 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 0, 0 }; + + idx = *timer_p; + if (idx == 0) { + idx = 0; + } else { + idx = --(*timer_p); + } + + if (idx == 0) { + if (*blink_count_p <= 0) { + *blink_count_p = get_random_timer(0, 3); + *timer_p = get_random_timer(60, 120); + } else { + *timer_p = 16; + (*blink_count_p)--; + } + } + + *pattern_p = *timer_p; + if (*pattern_p >= 16) { + *pattern_p = 0; + } + + Player_actor_set_eye_pattern(actorx, pattern_table[*pattern_p]); +} + +static u8* Player_actor_Get_eye_tex_p(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int idx = player->eye_tex_idx; + + return mPlib_Get_eye_tex_p(idx); +} + +static void Player_actor_set_mouth_pattern(ACTOR* actorx, int idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->mouth_tex_idx = idx; +} + +static u8* Player_actor_Get_mouth_tex_p(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int idx = player->mouth_tex_idx; + + return mPlib_Get_mouth_tex_p(idx); +} + +static void Player_actor_set_tex_anime_pattern(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int anim0_idx = player->animation0_idx; + u8* eye_tex_idx_p = mPlib_Get_PlayerEyeTexAnimation_p(anim0_idx); + u8* mouth_tex_idx_p = mPlib_Get_PlayerMouthTexAnimation_p(anim0_idx); + + if (eye_tex_idx_p != NULL || mouth_tex_idx_p != NULL) { + cKF_SkeletonInfo_R_c* kf_p = &player->keyframe0; + cKF_FrameControl_c* frame_control_p = &kf_p->frame_control; + f32 cur_frame = frame_control_p->current_frame; + f32 max_frame = frame_control_p->max_frames; + + if (1.0f <= cur_frame && cur_frame <= max_frame) { + int pattern = (int)(cur_frame - 1.0f); + + if (eye_tex_idx_p != NULL) { + Player_actor_set_eye_pattern(actorx, (int)eye_tex_idx_p[pattern]); + } + + if (mouth_tex_idx_p != NULL) { + Player_actor_set_mouth_pattern(actorx, (int)mouth_tex_idx_p[pattern]); + } + } + } +} + +static void Player_actor_SetupTextureAnimation(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_idx = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_idx) != FALSE) { + // clang-format off + static const s8 data[] = { + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_EYE | mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE, + mPlayer_SETUP_TEXTURE_ANIMATION_NONE + }; + // clang-format on + + int flags = data[main_idx]; + + if ((flags & mPlayer_SETUP_TEXTURE_ANIMATION_EYE)) { + Player_actor_set_eye_pattern(actorx, 0); + } + + if ((flags & mPlayer_SETUP_TEXTURE_ANIMATION_MOUTH)) { + Player_actor_set_mouth_pattern(actorx, 0); + } + } +} + +static void Player_actor_Set_now_item_main_index(ACTOR* actorx, int item_main_index) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int last_item_main_index = player->now_item_main_index; + + if (item_main_index >= 0 && item_main_index < mPlayer_ITEM_MAIN_NUM) { + player->now_item_main_index = item_main_index; + Player_actor_Item_Setup_main(actorx, item_main_index, last_item_main_index); + } +} + +static void Player_actor_SetupItem_common(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_idx = player->now_main_index; + int item_kind = Player_actor_Get_ItemKind(actorx, main_idx); + + if (item_kind < 0) { + Player_actor_LoadOrDestruct_Item(actorx, -1, -1, 0.0f, 0.0f, 1.0f, mPlayer_ITEM_IS_BALLOON(item_kind) == FALSE); + Player_actor_Set_now_item_main_index(actorx, mPlayer_ITEM_MAIN_NONE); + player->item_kind = item_kind; + } +} + +static void Player_actor_SetupItemScale(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + f32* item_scale_p = &player->item_scale; + + if (mPlib_get_player_actor_main_index(game) != mPlayer_INDEX_TAKEOUT_ITEM) { + *item_scale_p = 1.0f; + } +} + +static void Player_actor_SetupWeight(ACTOR* actorx) { + if (mEv_CheckTitleDemo() <= 0) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_idx = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_idx) != FALSE) { + // clang-format off + static const u8 data[] = { + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 255, + 50, + 255, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 254, + 254, + 254, + 254, + 254, + 254, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 254, + 254, + 254, + 254, + 254, + 254, + 254, + 50, + 50, + 254, + 255, + 50, + 50, + 50, + 50, + 255, + 50, + 255, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 255, + 255, + 255, + 255, + 50, + 50, + 50, + 50, + 50, + 50, + 255, + 50, + 255, + 50, + 50, + 50, + 50, + 50, + 50, + 50, + 255, + 255, + 255, + 255, + 255, + 255, + 50, + 50, + 50 + }; + // clang-format on + + u8 weight = data[main_idx]; + u8* weight_p = &actorx->status_data.weight; + + if (*weight_p != weight) { + *weight_p = weight; + } + } + } +} + +static int Player_actor_Get_status_for_bee(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + return player->status_for_bee; +} + +static void Player_actor_Set_status_for_bee(ACTOR* actorx, s8 v) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->status_for_bee = v; +} + +static void Player_actor_Setup_status_for_bee(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_idx = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_idx) != FALSE) { + // clang-format off + static const s8 data[] = { + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ENTER_BUILDING, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ATTACK, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_ENTER_BUILDING, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT, + mPlayer_STATUS_FOR_BEE_WAIT + }; + // clang-format on + + player->status_for_bee = data[main_idx]; + } +} + +static void Player_actor_setup_main_Base2(ACTOR* actorx, GAME* game, int main_index) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->prev_main_index = player->now_main_index; + player->now_main_index = main_index; + player->requested_main_index_changed = FALSE; + player->settled_requested_main_index_priority = FALSE; + + Player_actor_Set_start_refuse(actorx, game); + Player_actor_Set_address_able_display(actorx); + Player_actor_SetupShadow(actorx); + Player_actor_SetupSpeedF(actorx); + Player_actor_SetupRequestMainIndexPriority(actorx); + Player_actor_SetupTextureAnimation(actorx); + Player_actor_SetupItem_common(actorx); + Player_actor_SetupItemScale(actorx, game); + Player_actor_SetupWeight(actorx); + Player_actor_Setup_status_for_bee(actorx); +} + +static void Player_actor_setup_main_Base(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + Player_actor_setup_main_Base2(actorx, game, player->requested_main_index); +} + +/* Common Movement */ + +static void Player_actor_Movement_Base(ACTOR* actorx) { + Actor_position_moveF(actorx); +} + +static int Player_actor_Movement_Base_Braking_common(ACTOR* actorx, f32 brake_amount) { + f32 speed = actorx->speed; + + speed -= brake_amount; + if (speed < 0.0f) { + speed = 0.0f; + } + + actorx->speed = speed; + Player_actor_Movement_Base(actorx); + return speed == 0.0f; +} + +static int Player_actor_Movement_Base_Braking(ACTOR* actorx) { + return Player_actor_Movement_Base_Braking_common(actorx, 0.326525f); +} + +static void Player_actor_SetPlayerAngle_forUki(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ACTOR* uki_actor = player->fishing_rod_actor_p; + xyz_t* uki_pos_p = &uki_actor->world.position; + xyz_t* player_pos_p = &actorx->world.position; + f32 dx = uki_pos_p->x - player_pos_p->x; + f32 dz = uki_pos_p->z - player_pos_p->z; + + if (dx != 0.0f || dz != 0.0f) { + s16 target_angle_y = atans_table(dz, dx); + + add_calc_short_angle2(&actorx->shape_info.rotation.y, target_angle_y, 1.0f - sqrtf(0.5f), + DEG2SHORT_ANGLE2(13.73291015625f), DEG2SHORT_ANGLE2(0.274658203125f)); + actorx->world.angle.y = actorx->shape_info.rotation.y; + } +} + +static void Player_actor_Movement_Base_Stop(ACTOR* actorx, int use_position_speed_y) { + actorx->speed = 0.0f; + Actor_position_speed_set(actorx); + + if (use_position_speed_y == FALSE) { + actorx->position_speed.y = 0.0f; + } + + Actor_position_move(actorx); +} + +static int Player_actor_Search_exist_npc_inCircle_forWade(GAME* game, xyz_t* origin, f32 radius_sq) { + GAME_PLAY* play = (GAME_PLAY*)game; + Actor_info* actor_info_p = &play->actor_info; + Actor_list* actor_list_p = &actor_info_p->list[ACTOR_PART_NPC]; + ACTOR* actorx_p = actor_list_p->actor; + f32 origin_x = origin->x; + f32 origin_z = origin->z; + + for (actorx_p; actorx_p != NULL; actorx_p = actorx_p->next_actor) { + xyz_t* pos_p = &actorx_p->world.position; + f32 dx = pos_p->x - origin_x; + f32 dz = pos_p->z - origin_z; + + if (Math3DVecLengthSquare2D(dx, dz) < radius_sq) { + NPC_ACTOR* npc_actor_p = (NPC_ACTOR*)actorx_p; + + if (npc_actor_p->condition_info.hide_flg == FALSE) { + return TRUE; + } + } + } + + return FALSE; +} + +static int Player_actor_CheckAbleMoveWadeBG(GAME* game, const xyz_t* pos_p, int dir, int check_for_npc) { + xyz_t target_pos; + xyz_t local_border_pos = { 0.0f, 0.0f, 0.0f }; + xyz_t world_border_pos; + int bx; + int bz; + + mFI_Wpos2BlockNum(&bx, &bz, *pos_p); + mFI_LposInBKtoWpos(&world_border_pos, local_border_pos, bx, bz); + target_pos = *pos_p; + switch (dir) { + case mFI_MOVEDIR_RIGHT: + target_pos.x = world_border_pos.x + 18.0f + mFI_BK_WORLDSIZE_X_F; + break; + case mFI_MOVEDIR_LEFT: + target_pos.x = world_border_pos.x - 18.0f; + break; + case mFI_MOVEDIR_UP: + target_pos.z = world_border_pos.z - 18.0f; + break; + case mFI_MOVEDIR_DOWN: + target_pos.z = world_border_pos.z + 18.0f + mFI_BK_WORLDSIZE_Z_F; + break; + default: + return FALSE; + } + + if (check_for_npc == FALSE || Player_actor_Search_exist_npc_inCircle_forWade(game, &target_pos, 36.0f) == FALSE) { + return mCoBG_ScrollCheck(*pos_p, target_pos, 18.0f); + } + + return FALSE; +} + +static int Player_actor_CheckAbleMoveWadeBlock(GAME* game, const xyz_t* pos_p, s16 angle_y, f32 stick_range, + int angle_range, int npc_check_flag) { + f32 move_percentX = Player_actor_GetController_move_percentX(); + f32 move_percentY = Player_actor_GetController_move_percentY(); + xyz_t local_pos; + + mFI_WpostoLposInBK(&local_pos, *pos_p); + if (move_percentX > stick_range && + ((DEG2SHORT_ANGLE2(90.0f) - angle_range) < angle_y && angle_y < (DEG2SHORT_ANGLE2(90.0f) + angle_range)) && + mFI_ScrollCheck(*pos_p, mFI_MOVEDIR_RIGHT)) { + f32 border_x = (mFI_BK_WORLDSIZE_X_F - 18.0f); + + if (mCoBG_GetBlockBgCheckMode() == mCoBG_BLOCK_BGCHECK_MODE_INTRO_DEMO) { + border_x -= mFI_UNIT_BASE_SIZE_F; + } + + if (local_pos.x >= border_x) { + if (mPlib_Get_unable_wade() == FALSE) { + if (Player_actor_CheckAbleMoveWadeBG(game, pos_p, mFI_MOVEDIR_RIGHT, npc_check_flag)) { + return mFI_MOVEDIR_RIGHT; + } + } else { + return mFI_MOVEDIR_RIGHT; + } + } + + } else if (move_percentX < -stick_range && + (DEG2SHORT_ANGLE2(-90.0f) - angle_range < (int)angle_y && + (int)angle_y < DEG2SHORT_ANGLE2(-90.0f) + angle_range) && + mFI_ScrollCheck(*pos_p, mFI_MOVEDIR_LEFT)) { + f32 border_x = 18.0f; + + if (mCoBG_GetBlockBgCheckMode() == mCoBG_BLOCK_BGCHECK_MODE_INTRO_DEMO) { + border_x += mFI_UNIT_BASE_SIZE_F; + } + + if (local_pos.x <= border_x) { + if (mPlib_Get_unable_wade() == FALSE) { + if (Player_actor_CheckAbleMoveWadeBG(game, pos_p, mFI_MOVEDIR_LEFT, npc_check_flag)) { + return mFI_MOVEDIR_LEFT; + } + } else { + return mFI_MOVEDIR_LEFT; + } + } + } + + else if (move_percentY > stick_range && + ((DEG2SHORT_ANGLE2(180.0f) - angle_range) < (int)angle_y || + (int)angle_y < (DEG2SHORT_ANGLE2(-180.0f) + angle_range)) && + mFI_ScrollCheck(*pos_p, mFI_MOVEDIR_UP)) { + f32 border_z = 18.0f; + + if (mCoBG_GetBlockBgCheckMode() == mCoBG_BLOCK_BGCHECK_MODE_INTRO_DEMO) { + border_z += mFI_UNIT_BASE_SIZE_F; + } + + if (local_pos.z <= border_z) { + if (mPlib_Get_unable_wade() == FALSE) { + if (Player_actor_CheckAbleMoveWadeBG(game, pos_p, mFI_MOVEDIR_UP, npc_check_flag)) { + return mFI_MOVEDIR_UP; + } + } else { + return mFI_MOVEDIR_UP; + } + } + } + + else if (move_percentY < -stick_range && + ((-angle_range < (int)angle_y && (int)angle_y <= DEG2SHORT_ANGLE2(0.0f)) || + (int)angle_y >= DEG2SHORT_ANGLE2(0.0f) && (int)angle_y < angle_range) && + mFI_ScrollCheck(*pos_p, mFI_MOVEDIR_DOWN)) { + f32 border_z = (mFI_BK_WORLDSIZE_Z_F - 18.0f); + + if (mCoBG_GetBlockBgCheckMode() == mCoBG_BLOCK_BGCHECK_MODE_INTRO_DEMO) { + border_z -= mFI_UNIT_BASE_SIZE_F; + } + + if (local_pos.z >= border_z) { + if (mPlib_Get_unable_wade() == FALSE) { + if (Player_actor_CheckAbleMoveWadeBG(game, pos_p, mFI_MOVEDIR_DOWN, npc_check_flag)) { + return mFI_MOVEDIR_DOWN; + } + } else { + return mFI_MOVEDIR_DOWN; + } + } + } + + return mFI_MOVEDIR_NONE; +} + +static int Player_actor_CheckAbleMoveDemoWadeBlock(ACTOR* actorx) { + if (actorx->speed != 0.0f) { + xyz_t local_pos; + s16 angle_y = actorx->shape_info.rotation.y; + f32 dir_x = sin_s(angle_y); + f32 dir_z = cos_s(angle_y); + + mFI_WpostoLposInBK(&local_pos, actorx->world.position); + + if (dir_x > 0.0f && local_pos.x >= (mFI_BK_WORLDSIZE_X_F - 18.0f)) { + if (mFI_ScrollCheck(actorx->world.position, mFI_MOVEDIR_RIGHT)) { + return mFI_MOVEDIR_RIGHT; + } + } + + if (dir_x < 0.0f && local_pos.x <= (18.0f)) { + if (mFI_ScrollCheck(actorx->world.position, mFI_MOVEDIR_LEFT)) { + return mFI_MOVEDIR_LEFT; + } + } + + if (dir_z < 0.0f && local_pos.z <= (18.0f)) { + if (mFI_ScrollCheck(actorx->world.position, mFI_MOVEDIR_UP)) { + return mFI_MOVEDIR_UP; + } + } + + if (dir_z > 0.0f && local_pos.z >= (mFI_BK_WORLDSIZE_Z_F - 18.0f)) { + if (mFI_ScrollCheck(actorx->world.position, mFI_MOVEDIR_DOWN)) { + return mFI_MOVEDIR_DOWN; + } + } + } + + return mFI_MOVEDIR_NONE; +} + +static int Player_actor_CheckAbleMoveDemoWadeBoatBlock(ACTOR* actorx, s16 angle_y, f32 border_start) { + xyz_t local_pos; + f32 dir_z; + + dir_z = cos_s(angle_y); + mFI_WpostoLposInBK(&local_pos, actorx->world.position); + + if (dir_z < 0.0f && local_pos.z <= border_start) { + if (mFI_ScrollCheck(actorx->world.position, mFI_MOVEDIR_UP)) { + return mFI_MOVEDIR_UP; + } + } + + if (dir_z > 0.0f && local_pos.z >= (mFI_BK_WORLDSIZE_Z_F - border_start)) { + if (mFI_ScrollCheck(actorx->world.position, mFI_MOVEDIR_DOWN)) { + return mFI_MOVEDIR_DOWN; + } + } + + return mFI_MOVEDIR_NONE; +} + +static void Player_actor_CorrectWadeBlockBorder(ACTOR* actorx) { + mCoBG_UniqueWallCheck(actorx, 18.0f, 0.0f); +} + +/* Animation */ + +static void Player_actor_DMA_Animation(ACTOR* actorx, GAME* game, int anim0_idx, int anim1_idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (anim0_idx >= 0 && anim0_idx != player->animation0_idx) { + player->animation0_idx = anim0_idx; + } + + if (anim1_idx >= 0 && anim1_idx != player->animation1_idx) { + player->animation1_idx = anim1_idx; + } +} + +static void Player_actor_DMA_PartTable(ACTOR* actorx, int part_table_idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (part_table_idx != player->part_table_idx) { + player->part_table_idx = part_table_idx; + mPlib_DMA_player_Part_Table(player->part_table, part_table_idx); + } +} + +static int Player_actor_CulcAnimation_Base(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + s8* part_table = player->part_table; + + if (part_table == NULL) { + return cKF_STATE_NONE; + } + + return cKF_SkeletonInfo_R_combine_play(&player->keyframe0, &player->keyframe1, part_table); +} + +static int Player_actor_CulcAnimation_Base2(ACTOR* actorx, f32* last_anim0_current_frame_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p = &player->keyframe0; + cKF_FrameControl_c* fc0_p = &kf0_p->frame_control; + cKF_SkeletonInfo_R_c* kf1_p = &player->keyframe1; + cKF_FrameControl_c* fc1_p = &kf1_p->frame_control; + + *last_anim0_current_frame_p = fc0_p->current_frame; + if (Player_actor_CulcAnimation_Base(actorx) == cKF_STATE_STOPPED) { + if (fc0_p->speed == 0.0f) { + return TRUE; /* Animation has stopped */ + } + + fc0_p->speed = 0.0f; + fc1_p->speed = 0.0f; + } + + return FALSE; +} + +static int Player_actor_CulcAnimation_Base3(ACTOR* actorx, f32* last_anim0_current_frame_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p = &player->keyframe0; + cKF_FrameControl_c* fc0_p = &kf0_p->frame_control; + + *last_anim0_current_frame_p = fc0_p->current_frame; + if (Player_actor_CulcAnimation_Base(actorx) == cKF_STATE_STOPPED) { + return TRUE; + } + + return FALSE; +} + +static int Player_actor_CheckContinueAnimation(ACTOR* actorx, int anim0_idx, int anim1_idx, f32* anim0_frame_p, + f32* anim1_frame_p, f32* morph_counter_p, int part_table_idx, + int continue_flag) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int now_anim0_idx; + int now_anim1_idx; + f32 now_frame0; + f32 now_frame1; + + if (continue_flag == FALSE) { + return FALSE; + } + + if (player->keyframe0.morph_counter != 0.0f) { + return FALSE; + } + + if (*morph_counter_p >= 0.0f) { + return FALSE; + } + + now_anim0_idx = player->animation0_idx; + now_anim1_idx = player->animation1_idx; + if (anim0_idx != now_anim0_idx || anim1_idx != now_anim1_idx) { + return FALSE; + } + + now_frame0 = *anim0_frame_p; + now_frame1 = *anim1_frame_p; + if (now_frame0 != 1.0f || now_frame1 != 1.0f) { + return FALSE; + } + + if (anim0_idx == mPlayer_ANIM_WAIT1) { + if (part_table_idx == mPlayer_PART_TABLE_NORMAL && anim1_idx != mPlayer_ANIM_WAIT1) { + return FALSE; + } + } else { + return FALSE; + } + + *anim0_frame_p = player->keyframe0.frame_control.current_frame; + *anim1_frame_p = player->keyframe1.frame_control.current_frame; + *morph_counter_p = 0.0f; + return TRUE; +} + +static void Player_actor_InitAnimation_Base1(ACTOR* actorx, GAME* game, int anim0_idx, int anim1_idx, f32 anim0_frame, + f32 anim1_frame, f32 frame_speed, f32 morph_counter, int part_table_idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p; + cKF_SkeletonInfo_R_c* kf1_p; + + Player_actor_CheckContinueAnimation(actorx, anim0_idx, anim1_idx, &anim0_frame, &anim1_frame, &morph_counter, + part_table_idx, TRUE); + Player_actor_DMA_PartTable(actorx, part_table_idx); + Player_actor_DMA_Animation(actorx, game, anim0_idx, anim1_idx); + + kf0_p = &player->keyframe0; + kf1_p = &player->keyframe1; + + if (anim0_idx >= 0) { + cKF_SkeletonInfo_R_init_standard_repeat_setframeandspeedandmorph(kf0_p, mPlib_Get_Pointer_Animation(anim0_idx), + NULL, anim0_frame, frame_speed, morph_counter); + } else { + kf0_p->morph_counter = morph_counter; + } + + if (anim1_idx >= 0) { + cKF_SkeletonInfo_R_init_standard_repeat_setframeandspeedandmorph(kf1_p, mPlib_Get_Pointer_Animation(anim1_idx), + NULL, anim1_frame, frame_speed, morph_counter); + } else { + kf1_p->morph_counter = morph_counter; + } +} + +static void Player_actor_InitAnimation_Base2(ACTOR* actorx, GAME* game, int anim0_idx, int anim1_idx, f32 anim0_frame, + f32 anim1_frame, f32 frame_speed, f32 morph_counter, int mode, + int part_table_idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p; + cKF_SkeletonInfo_R_c* kf1_p; + + Player_actor_CheckContinueAnimation(actorx, anim0_idx, anim1_idx, &anim0_frame, &anim1_frame, &morph_counter, + part_table_idx, TRUE); + Player_actor_DMA_Animation(actorx, game, anim0_idx, anim1_idx); + Player_actor_DMA_PartTable(actorx, part_table_idx); + + kf0_p = &player->keyframe0; + kf1_p = &player->keyframe1; + + if (anim0_idx >= 0) { + cKF_SkeletonInfo_R_init_standard_setframeandspeedandmorphandmode( + kf0_p, mPlib_Get_Pointer_Animation(anim0_idx), NULL, anim0_frame, frame_speed, morph_counter, mode); + } else { + kf0_p->morph_counter = morph_counter; + } + + if (anim1_idx >= 0) { + cKF_SkeletonInfo_R_init_standard_setframeandspeedandmorphandmode( + kf1_p, mPlib_Get_Pointer_Animation(anim1_idx), NULL, anim1_frame, frame_speed, morph_counter, mode); + } else { + kf1_p->morph_counter = morph_counter; + } +} + +static void Player_actor_InitAnimation_Base3(ACTOR* actorx, GAME* game, int anim0_idx, int anim1_idx, f32 frame_speed, + f32 morph_counter, int mode, int part_table_idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p; + cKF_SkeletonInfo_R_c* kf1_p; + + Player_actor_DMA_Animation(actorx, game, anim0_idx, anim1_idx); + Player_actor_DMA_PartTable(actorx, part_table_idx); + + kf0_p = &player->keyframe0; + kf1_p = &player->keyframe1; + + /* @BUG - shouldn't this be checking anim0_idx ?? */ + if (anim1_idx >= 0) { + cKF_SkeletonInfo_R_init_reverse_setspeedandmorphandmode(kf0_p, mPlib_Get_Pointer_Animation(anim0_idx), NULL, + frame_speed, morph_counter, mode); + } else { + kf0_p->morph_counter = morph_counter; + } + + if (anim1_idx >= 0) { + cKF_SkeletonInfo_R_init_reverse_setspeedandmorphandmode(kf1_p, mPlib_Get_Pointer_Animation(anim1_idx), NULL, + frame_speed, morph_counter, mode); + } else { + kf1_p->morph_counter = morph_counter; + } +} + +/* Collision */ + +static void Player_actor_Get_player_move_position(ACTOR* actorx, xyz_t* pos_p) { + *pos_p = actorx->world.position; +} + +// clang-format off +static ClObjPipeData_c Player_actor_OcInfoData_forStand = { + { 0x39, 0x08, ClObj_TYPE_PIPE }, /* ClObjData_c */ + { 0x01 }, /* ClObjElemData_c */ + { { 20, 60, 0, { 0, 0, 0 } } }, /* ClObjPipeAttrData_c */ +}; +// clang-format on + +// clang-format off +static ClObjTrisElemData_c Player_actor_pclobj_tris_base_forItem[1] = { + { + { 0x00 }, /* ClObjElemData_c */ + { { { -70.0f, 176.0f, 0.0f }, { -70.0f, -4.0f, 0.0f }, { 0.0f, -4.0f, 30.0f } } }, /* ClObjTrisElemAttrData_c */ + }, +}; +// clang-format on + +// clang-format off +static ClObjTrisData_c Player_actor_pclobj_tris_data_forItem = { + { 0x30, 0x02, ClObj_TYPE_TRIS }, /* ClObjData_c */ + 1, /* num */ + Player_actor_pclobj_tris_base_forItem, /* data */ +}; +// clang-format on + +static void Player_actor_ct_forCorect(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ClObjPipe_c* col_pipe_p = &player->col_pipe; + ClObjTris_c* axe_tris_p = &player->item_axe_tris; + ClObjTris_c* net_tris_p = &player->item_net_tris; + + /* Collision Pipe */ + ClObjPipe_ct(game, col_pipe_p); + ClObjPipe_set5(game, col_pipe_p, actorx, &Player_actor_OcInfoData_forStand); + + /* Axe Collision */ + ClObjTris_ct(game, axe_tris_p); + ClObjTris_set5_nzm(game, axe_tris_p, actorx, &Player_actor_pclobj_tris_data_forItem, + player->item_axe_tris_elem_tbl); + + /* Net Collision */ + ClObjTris_ct(game, net_tris_p); + ClObjTris_set5_nzm(game, net_tris_p, actorx, &Player_actor_pclobj_tris_data_forItem, + player->item_net_tris_elem_tbl); +} + +static void Player_actor_dt_forCorect(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ClObjPipe_c* col_pipe_p = &player->col_pipe; + ClObjTris_c* axe_tris_p = &player->item_axe_tris; + ClObjTris_c* net_tris_p = &player->item_net_tris; + + ClObjPipe_dt(game, col_pipe_p); + ClObjTris_dt_nzf(game, axe_tris_p); + ClObjTris_dt_nzf(game, net_tris_p); +} + +static void Player_actor_Excute_Corect_forStand(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ClObjPipe_c* col_pipe_p = &player->col_pipe; + ClObj_c* col_obj_p = &col_pipe_p->collision_obj; + GAME_PLAY* play = (GAME_PLAY*)game; + CollisionCheck_c* col_check_p = &play->collision_check; + + CollisionCheck_Uty_ActorWorldPosSetPipeC(actorx, col_pipe_p); + CollisionCheck_setOC(game, col_check_p, col_obj_p); +} + +static void Player_actor_Excute_Corect_forBrake(ACTOR* actorx, GAME* game) { + f32 speed = actorx->speed; + u8* weight_p = &actorx->status_data.weight; + + if (speed != 0.0f) { + *weight_p = 50; + } else { + *weight_p = MASSTYPE_HEAVY; + } + + Player_actor_Excute_Corect_forStand(actorx, game); +} + +static void Player_actor_Excute_Corect_forOutdoor(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p = &player->keyframe0; + ClObjPipe_c* col_pipe_p = &player->col_pipe; + s_xyz* pipe_center_p = &col_pipe_p->attribute.pipe.center; + ClObj_c* col_obj_p = &col_pipe_p->collision_obj; + GAME_PLAY* play = (GAME_PLAY*)game; + CollisionCheck_c* col_check_p = &play->collision_check; + xyz_t world_pos; + + cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(&world_pos, &actorx->world.position, 0.0f, 1000.0f, 0.0f, + actorx->shape_info.rotation.y, &actorx->scale, kf0_p, + cKF_ANIMATION_TRANS_XZ); + + pipe_center_p->x = world_pos.x; + pipe_center_p->y = actorx->world.position.y; + pipe_center_p->z = world_pos.z; + + CollisionCheck_setOC(game, col_check_p, col_obj_p); +} + +static int Player_actor_Check_OBJtoLine_forItem_axe(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ClObjTris_c* axe_tris_p = &player->item_axe_tris; + + return axe_tris_p->collision_obj.collision_flags1 & (1 << 2); +} + +static int Player_actor_Check_OBJtoLine_forItem_net(ACTOR* actorx, ACTOR** hit_actor) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ClObjTris_c* net_tris_p = &player->item_net_tris; + + if ((net_tris_p->collision_obj.collision_flags1 & (1 << 2)) == 0) { + *hit_actor = NULL; + return FALSE; + } else { + *hit_actor = net_tris_p->collision_obj.collided_actor; + return TRUE; + } +} + +static void Player_actor_SetPosition_OBJtoLine_forItem(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ClObjTris_c* axe_tris_p = &player->item_axe_tris; + ClObjTris_c* net_tris_p = &player->item_net_tris; + + /* Process axe collision */ + { + xyz_t start_pos; + xyz_t right_pos; + xyz_t left_pos; + s16 angle_y = actorx->shape_info.rotation.y; + s16 right_angle_y = angle_y - DEG2SHORT_ANGLE2(8.0255126953125f); + s16 left_angle_y = angle_y + DEG2SHORT_ANGLE2(8.0255126953125f); + + Player_actor_Get_player_move_position(actorx, &start_pos); + start_pos.y += 31.0f; + + right_pos = start_pos; + right_pos.x += 35.0f * sin_s(right_angle_y); + right_pos.z += 35.0f * cos_s(right_angle_y); + + left_pos = start_pos; + left_pos.x += 35.0f * sin_s(left_angle_y); + left_pos.z += 35.0f * cos_s(left_angle_y); + + { + ClObjTrisElem_c* axe_tris_elem_p = axe_tris_p->elements; + ClObjTrisElemAttr_c* axe_tris_elem_attr_p = &axe_tris_elem_p->attribute; + xyz_t* vtx_tbl = axe_tris_elem_attr_p->tri.vtx; + + vtx_tbl[0] = start_pos; + vtx_tbl[1] = right_pos; + vtx_tbl[2] = left_pos; + } + } + + /* Process net collision */ + if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_SWING_NET) { + xyz_t* net_start_pos_p = &player->net_start_pos; + xyz_t* net_end_pos_p = &player->net_end_pos; + xyz_t net_top_pos = *net_end_pos_p; + + net_top_pos.y += 10.0f; + + { + ClObjTrisElem_c* net_tris_elem_p = net_tris_p->elements; + ClObjTrisElemAttr_c* net_tris_elem_attr_p = &net_tris_elem_p->attribute; + xyz_t* vtx_tbl = net_tris_elem_attr_p->tri.vtx; + + vtx_tbl[0] = *net_start_pos_p; + vtx_tbl[1] = *net_end_pos_p; + vtx_tbl[2] = net_top_pos; + } + } + + /* Update collision check */ + { + GAME_PLAY* play = (GAME_PLAY*)game; + CollisionCheck_c* col_check_p = &play->collision_check; + ClObj_c* axe_col_obj_p = &axe_tris_p->collision_obj; + ClObj_c* net_col_obj_p = &net_tris_p->collision_obj; + + CollisionCheck_setOCC(game, col_check_p, axe_col_obj_p); + CollisionCheck_setOCC(game, col_check_p, net_col_obj_p); + } +} + +static f32 Player_actor_Culc_over_speed_normalize_NoneZero(ACTOR* actorx, const xyz_t* pos_p) { + f32 over_speed_normalize; + xyz_t ground_norm; + + mCoBG_GetBgNorm_FromWpos(&ground_norm, *pos_p); + over_speed_normalize = 1.0f; + + if (ground_norm.x != 0.0f || ground_norm.z != 0.0f) { + xyz_t move_vec; + s16 angle_y = actorx->world.angle.y; + + move_vec.x = sin_s(angle_y); + move_vec.z = cos_s(angle_y); + + if (ground_norm.y != 0.0f) { + move_vec.y = (ground_norm.x * move_vec.x + ground_norm.z * move_vec.z) / -ground_norm.y; + + if (move_vec.y > 0.0f) { + over_speed_normalize = Math3DVecLengthSquare(&move_vec); + } + } + } + + if (over_speed_normalize == 0.0f) { + over_speed_normalize = 1.0f; + } + + return over_speed_normalize; +} + +static void Player_actor_set_eye_PositionAndAngle(ACTOR* actorx) { + Actor_world_to_eye(actorx, 33.0f); +} + +static void Player_actor_set_lean_angle(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p = &player->keyframe0; + f32 speed; + f32 lean_angle; + + speed = SQ(kf0_p->frame_control.speed) / 0.36f; + lean_angle = SQ(speed); + lean_angle = lean_angle * lean_angle * lean_angle * DEG2SHORT_ANGLE2(20.0f); + if (lean_angle > DEG2SHORT_ANGLE2(20.0f)) { + lean_angle = DEG2SHORT_ANGLE2(20.0f); + } + + add_calc_short_angle2(&actorx->shape_info.rotation.x, lean_angle, 1.0f - sqrtf(0.5f), DEG2SHORT_ANGLE2(10.0f), + DEG2SHORT_ANGLE2(0.0f)); +} + +static void Player_actor_recover_lean_angle(ACTOR* actorx) { + add_calc_short_angle2(&actorx->shape_info.rotation.x, DEG2SHORT_ANGLE2(0.0f), 1.0f - sqrtf(0.5f), + DEG2SHORT_ANGLE2(10.0f), DEG2SHORT_ANGLE2(0.0f)); +} + +static const s16 Player_actor_wall_angle[] = { + DEG2SHORT_ANGLE2(-180.0f), + DEG2SHORT_ANGLE2(-90.0f), + DEG2SHORT_ANGLE2(0.0f), + DEG2SHORT_ANGLE2(90.0f), +}; + +static s16 Player_actor_Get_Angle_fromIndex(int idx) { + if (idx >= 0 && idx < aMR_CONTACT_DIR_NUM) { + return Player_actor_wall_angle[idx]; + } + + return DEG2SHORT_ANGLE2(0.0f); +} + +static s16 Player_actor_Get_Angle_fromDirection(int direction) { + static const s16 angle[] = { + DEG2SHORT_ANGLE2(90.0f), + DEG2SHORT_ANGLE2(-90.0f), + DEG2SHORT_ANGLE2(-180.0f), + DEG2SHORT_ANGLE2(0.0f), + }; + + if (direction > mFI_MOVEDIR_NONE && direction < mFI_MOVEDIR_NUM) { + return angle[direction - mFI_MOVEDIR_RIGHT]; + } + + return DEG2SHORT_ANGLE2(0.0f); +} + +static int Player_actor_Get_Direction_fromAngle(s16 angle) { + switch (angle) { + case DEG2SHORT_ANGLE2(90.0f): + return mFI_MOVEDIR_RIGHT; + case DEG2SHORT_ANGLE2(-90.0f): + return mFI_MOVEDIR_LEFT; + case DEG2SHORT_ANGLE2(-180.0f): + return mFI_MOVEDIR_UP; + case DEG2SHORT_ANGLE2(0.0f): + return mFI_MOVEDIR_DOWN; + default: + return mFI_MOVEDIR_NONE; + } +} + +static int Player_actor_Get_Index_fromAngle(s16 angle) { + int i; + + for (i = 0; i < aMR_CONTACT_DIR_NUM; i++) { + if (angle == Player_actor_wall_angle[i]) { + return i; + } + } + + return aMR_CONTACT_DIR_BACK; +} + +static int Player_actor_RecieveDemoOrder_EffectOrder(void) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 0); + + if (order > 0) { + mDemo_Set_OrderValue(mDemo_ORDER_PLAYER, 0, 0); + } + + return order; +} + +static s16 Player_actor_Get_ControllerAngle(GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + int angle = DEG2SHORT_ANGLE2(270.0f) + (s16)Player_actor_GetController_move_angle() + (s16)getCamera2AngleY(play); + + return angle; +} + +static int Player_actor_Get_DiffWorldAngleToControllerAngle(ACTOR* actorx) { + s16 angle_y = actorx->world.angle.y; + s16 controller_y = DEG2SHORT_ANGLE2(90.0f) + Player_actor_GetController_move_angle(); + int diff_y = (s16)(angle_y - controller_y); + + diff_y = diff_y < 0 ? -diff_y : diff_y; + + return diff_y; +} + +static void Player_actor_putin(int slot, mActor_name_t item) { + if (slot >= 0) { + mPr_SetPossessionItem(Now_Private, slot, item, mPr_ITEM_COND_NORMAL); + } +} + +static void Player_actor_putin_item(int slot, mActor_name_t item, xyz_t* pos_p) { + Player_actor_putin(slot, item); + + if (pos_p != NULL) { + mFI_SetFG_common(EMPTY_NO, *pos_p, TRUE); + } +} + +static void Player_actor_putin_item_layer2(int slot, mActor_name_t item, xyz_t* pos_p) { + Player_actor_putin(slot, item); + + if (pos_p != NULL) { + mFI_SetFG2(EMPTY_NO, *pos_p); + } +} + +static void Player_actor_putin_furniture(GAME* game, int slot, mActor_name_t item) { + if (!ITEM_IS_MYMANNIQUIN(item) && !ITEM_IS_MYUMBRELLA(item)) { + Player_actor_putin(slot, item); + } + + if (Common_Get(clip).my_room_clip != NULL) { + Common_Get(clip).my_room_clip->ftr2itemBag_proc(game); + } +} + +static int Player_actor_Check_AnimationFrame_PerfectEqual(ACTOR* actorx, f32 frame) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p = &player->keyframe0; + cKF_FrameControl_c* fc_p = &kf0_p->frame_control; + f32 cur_frame = fc_p->current_frame; + + return cur_frame == frame; +} + +static int Player_actor_Check_AnimationFrame_Common(f32 cur_frame, f32 frame_speed, f32 end_frame, f32 target_frame) { + f32 last_frame = cur_frame - frame_speed; + + if (frame_speed > 0.0f) { + if (last_frame < 1.0f) { + if (((end_frame + last_frame) - 1.0f < target_frame && target_frame <= end_frame) || + (1.0f <= target_frame && target_frame <= cur_frame)) { + return TRUE; + } + } else { + if (last_frame < target_frame && target_frame <= cur_frame) { + return TRUE; + } + } + } else if (frame_speed < 0.0f) { + if (last_frame > end_frame) { + if (((end_frame - last_frame) + 1.0f < target_frame && target_frame <= cur_frame) || + (1.0f <= target_frame && target_frame <= cur_frame)) { + return TRUE; + } + } else { + if (cur_frame <= target_frame && target_frame < last_frame) { + return TRUE; + } + } + } else { + if (cur_frame == target_frame) { + return TRUE; + } + } + + return FALSE; +} + +static int Player_actor_Check_AnimationFrame(cKF_FrameControl_c* fc_p, f32 target_frame) { + f32 frame_speed = fc_p->speed; + f32 cur_frame = fc_p->current_frame; + f32 end_frame = fc_p->end_frame; + + return Player_actor_Check_AnimationFrame_Common(cur_frame, frame_speed, end_frame, target_frame); +} + +static int Player_actor_Check_TradingItemMode(u8 mode) { + if (Common_Get(clip).handOverItem_clip->request_mode == mode) { + return TRUE; + } + + return FALSE; +} + +static void Player_actor_CHange_TradingItemMode(ACTOR* actorx, u8 mode) { + Common_Get(clip).handOverItem_clip->chg_request_mode_proc(actorx, mode); +} + +static void Player_actor_Set_item_matrix_set(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->item_matrix_set = TRUE; +} + +static void Player_actor_Unset_item_matrix_set(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->item_matrix_set = FALSE; +} + +static void Player_actor_Change_ItemParent(ACTOR* actor) { + ACTOR* item_actor = Common_Get(clip).handOverItem_clip->chg_master_proc(actor); + + if (item_actor != NULL) { + Common_Get(clip).handOverItem_clip->chg_request_mode_proc(actor, aHOI_REQUEST_GET_PULL); + } +} + +static int Player_actor_Check_ItemParent(ACTOR* actor) { + return Common_Get(clip).handOverItem_clip->master_actor == actor; +} + +static void Player_actor_Birth_TradingItem(ACTOR* actor, mActor_name_t item, int mode, int present_flag) { + if (Common_Get(clip).handOverItem_clip != NULL) { + ACTOR* item_actor = Common_Get(clip).handOverItem_clip->birth_proc(item, mode, present_flag, actor); + + if (item_actor != NULL) { + Player_actor_CHange_TradingItemMode(actor, aHOI_REQUEST_TRANSFER); + } + } +} + +static void Player_actor_ItemBank_ct(ACTOR* actorx, GAME* game) { + // stubbed +} + +static int Player_actor_Change_ItemBank(ACTOR* actorx, int item_idx, int anim_idx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int last_bank = player->item_bank_idx; + int cur_bank_idx = last_bank ^ 1; + int last_item_idx = player->item_shape_type[cur_bank_idx]; + int res = FALSE; + + player->item_bank_idx = cur_bank_idx; + + if (item_idx >= 0) { + if (item_idx != last_item_idx) { + player->item_shape_type[cur_bank_idx] = item_idx; + } + } else { + player->item_shape_type[cur_bank_idx] = -1; + player->item_shape_segaddr[cur_bank_idx] = 0; + } + + if (anim_idx >= 0) { + if (anim_idx != player->item_animation_idx[cur_bank_idx]) { + player->item_animation_idx[cur_bank_idx] = anim_idx; + } + + if (player->item_animation_idx[cur_bank_idx] == player->item_animation_idx[cur_bank_idx ^ 1]) { + res = TRUE; + } + } else { + player->item_anim_addr[cur_bank_idx] = 0; + player->item_anim_segaddr[cur_bank_idx] = 0; + player->item_animation_idx[cur_bank_idx] = -1; + } + + return res; +} + +static void Player_actor_Set_OldAngle(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + s_xyz* world_angle_p = &actorx->world.angle; + s_xyz* shape_rot_p = &actorx->shape_info.rotation; + s_xyz* old_world_angle_p = &player->old_world_angle; + s_xyz* old_shape_angle_p = &player->old_shape_angle; + + player->world_angle_delta.x = (s16)(world_angle_p->x - old_world_angle_p->x); + player->world_angle_delta.y = (s16)(world_angle_p->y - old_world_angle_p->y); + player->world_angle_delta.z = (s16)(world_angle_p->z - old_world_angle_p->z); + + player->shape_angle_delta.x = (s16)(shape_rot_p->x - old_shape_angle_p->x); + player->shape_angle_delta.y = (s16)(shape_rot_p->y - old_shape_angle_p->y); + player->shape_angle_delta.z = (s16)(shape_rot_p->z - old_shape_angle_p->z); + + *old_world_angle_p = *world_angle_p; + *old_shape_angle_p = *shape_rot_p; +} + +static void Player_actor_Reset_Item_net_catch_request_table(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->item_net_catch_request_use_count = 0; + player->item_net_catch_label_request_force = 0; +} + +static int Player_actor_Set_Item_net_catch_request_table(ACTOR* actorx, GAME* game, u32 label, s8 type, + const xyz_t* pos_p, f32 radius) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_SWING_NET) { + int catch_num = player->item_net_catch_request_use_count; + + if ((catch_num >= 0 && catch_num < mPlayer_NET_CATCH_TABLE_COUNT) && + (type >= 0 && type < mPlayer_NET_CATCH_TYPE_NUM) && pos_p != NULL && 0.0f <= radius) { + player->item_net_catch_label_request_table[catch_num] = label; + player->item_net_catch_type_request_table[catch_num] = type; + player->item_net_catch_pos_request_table[catch_num] = *pos_p; + player->item_net_catch_radius_request_table[catch_num] = radius; + player->item_net_catch_request_use_count = catch_num + 1; + return TRUE; + } + } + + return FALSE; +} + +static int Player_actor_Set_Item_net_catch_request_force(ACTOR* actorx, GAME* game, u32 label, s8 type) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_SWING_NET && + player->item_net_catch_label_request_force == 0) { + player->item_net_catch_label_request_force = label; + player->item_net_catch_type_request_force = type; + return TRUE; + } + + return FALSE; +} + +static f32 Player_actor_Get_Item_net_catch_swing_timer(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_SWING_NET) { + return player->main_data.swing_net.swing_timer; + } + + return 0.0f; +} + +static void Player_actor_DisappearShadow_fromAnimationFrame(ACTOR* actorx, f32 start_frame, f32 end_frame) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + f32 cur_frame = player->keyframe0.frame_control.current_frame; + + if (cur_frame < start_frame) { + return; + } + + if (cur_frame < end_frame) { + f32 p = 1.0f - ((cur_frame - start_frame) - 1.0f) / ((end_frame - start_frame) - 1.0f); + + if (p < 0.0f) { + p = 0.0f; + } else if (p > 1.0f) { + p = 1.0f; + } + + actorx->shape_info.shadow_size_change_rate = p; + actorx->shape_info.shadow_alpha_change_rate = p; + } else { + actorx->shape_info.shadow_size_change_rate = 0.0f; + actorx->shape_info.shadow_alpha_change_rate = 0.0f; + actorx->shape_info.draw_shadow = FALSE; + } +} + +static void Player_actor_AppearShadow_fromAnimationFrame(ACTOR* actorx, f32 appear_start_frame, f32 appear_end_frame) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + f32 cur_frame = player->keyframe0.frame_control.current_frame; + f32 end_frame = player->keyframe0.frame_control.end_frame; + + if (cur_frame > end_frame - appear_end_frame) { + actorx->shape_info.shadow_size_change_rate = 1.0f; + actorx->shape_info.shadow_alpha_change_rate = 1.0f; + } else if (cur_frame > (end_frame - appear_start_frame) - appear_end_frame) { + f32 p = 1.0f - ((end_frame - cur_frame) - appear_end_frame) / (appear_start_frame - 1.0f); + + if (p < 0.0f) { + p = 0.0f; + } else if (p > 1.0f) { + p = 1.0f; + } + + actorx->shape_info.shadow_size_change_rate = p; + actorx->shape_info.shadow_alpha_change_rate = p; + } else { + actorx->shape_info.shadow_size_change_rate = 0.0f; + actorx->shape_info.shadow_alpha_change_rate = 0.0f; + actorx->shape_info.draw_shadow = TRUE; + } +} + +static u32 Player_actor_get_door_label(GAME* game) { + if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_DOOR) { + return GET_PLAYER_ACTOR_GAME(game)->main_data.door.label; + } + + return 0; +} + +static void Player_actor_BGcheck_common_type1(ACTOR* actorx) { + mCoBG_BgCheckControll(NULL, actorx, 18.0f, 0.0f, TRUE, FALSE, 1); + Player_actor_CorrectWadeBlockBorder(actorx); +} + +static void Player_actor_BGcheck_common_type2(ACTOR* actorx) { + mCoBG_BgCheckControll(NULL, actorx, 18.0f, 0.0f, TRUE, FALSE, 1); +} + +static void Player_actor_BGcheck_common_type3(ACTOR* actorx) { + mCoBG_GroundCheckOnly(NULL, actorx, 18.0f, 0.0f, 0); +} + +static void Player_actor_Set_force_position_angle(GAME* game, const xyz_t* pos_p, const s_xyz* angle_p, u8 flags) { + if (flags != mPlayer_FORCE_POSITION_ANGLE_NONE) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + if (pos_p != NULL) { + if ((flags & mPlayer_FORCE_POSITION_ANGLE_POSX)) { + player->force_position.x = pos_p->x; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_POSY)) { + player->force_position.y = pos_p->y; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_POSZ)) { + player->force_position.z = pos_p->z; + } + } + + if (angle_p != NULL) { + if ((flags & mPlayer_FORCE_POSITION_ANGLE_ROTX)) { + player->force_angle.x = angle_p->x; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_ROTY)) { + player->force_angle.y = angle_p->y; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_ROTZ)) { + player->force_angle.z = angle_p->z; + } + } + + player->force_position_angle_flag |= flags; + } +} + +static void Player_actor_Reset_force_position_angle(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->force_position_angle_flag = mPlayer_FORCE_POSITION_ANGLE_NONE; +} + +static u8 Player_actor_Get_force_position_angle(GAME* game, xyz_t* pos_p, s_xyz* angle_p) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + u8 flags = player->force_position_angle_flag; + + if (flags != mPlayer_FORCE_POSITION_ANGLE_NONE) { + if (pos_p != NULL) { + if ((flags & mPlayer_FORCE_POSITION_ANGLE_POSX)) { + pos_p->x = player->force_position.x; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_POSY)) { + pos_p->y = player->force_position.y; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_POSZ)) { + pos_p->z = player->force_position.z; + } + } + + if (angle_p != NULL) { + if ((flags & mPlayer_FORCE_POSITION_ANGLE_ROTX)) { + angle_p->x = player->force_angle.x; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_ROTY)) { + angle_p->y = player->force_angle.y; + } + + if ((flags & mPlayer_FORCE_POSITION_ANGLE_ROTZ)) { + angle_p->z = player->force_angle.z; + } + } + } + + return flags; +} + +static void Player_actor_Reinput_force_position_angle(ACTOR* actorx, GAME* game) { + Player_actor_Get_force_position_angle(game, &actorx->world.position, &actorx->world.angle); + Player_actor_Get_force_position_angle(game, NULL, &actorx->shape_info.rotation); + Player_actor_Reset_force_position_angle(actorx); +} + +static int Player_actor_Get_DemoOrder(void) { + return mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 1); +} + +static void Player_actor_Set_DemoOrder(u16 value) { + mDemo_Set_OrderValue(mDemo_ORDER_PLAYER, 1, value); +} + +static void Player_actor_Get_DemoPosition(xyz_t* pos_p) { + f32 x = (s16)mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 2); + f32 y = (s16)mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 3); + f32 z = (s16)mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 4); + + pos_p->x = x; + pos_p->y = y; + pos_p->z = z; +} + +static int Player_actor_Get_DemoChangeAngleY(void) { + return mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 5); +} + +static void Player_actor_Set_DemoChangeAngleY(u16 value) { + mDemo_Set_OrderValue(mDemo_ORDER_PLAYER, 5, value); +} + +static s16 Player_actor_Get_DemoAngleY(void) { + return (s16)mDemo_Get_OrderValue(mDemo_ORDER_PLAYER, 6); +} + +static int Player_actor_CheckScene_AbleOutItem(int scene_no) { + // clang-format off + static const s8 data[] = { + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + if (!(scene_no >= 0 && scene_no < SCENE_NUM)) { + return FALSE; + } + + return data[scene_no]; +} + +static int Player_actor_CheckPlayer_AbleOutItem(int main_index) { + if (mPlayer_MAIN_INDEX_VALID(main_index) == FALSE) { + return mPlayer_ABLE_ITEM_CAN_USE_ALL; + } else { + // clang-format off + static const s8 data[] = { + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_RESTRICTED, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + }; + // clang-format on + + return data[main_index]; + } +} + +static int Player_actor_CheckPlayer_AbleLoadItem(int main_index) { + if (mPlayer_MAIN_INDEX_VALID(main_index) == FALSE) { + return mPlayer_ABLE_ITEM_CAN_USE_ALL; + } else { + // clang-format off + static const s8 data[] = { + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_NONE, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_ALL, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA, + }; + // clang-format on + + return data[main_index]; + } +} + +static int Player_actor_Check_is_demo_mode(int main_index) { + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + }; + // clang-format on + + return data[main_index]; + } + + return FALSE; +} + +static int Player_actor_Check_axe_after(ACTOR* actorx, xyz_t* target_pos_p, mActor_name_t* fg_p, + ACTOR** reflect_actor_pp) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + *fg_p = EMPTY_NO; + *reflect_actor_pp = NULL; + + if (Player_actor_Check_OBJtoLine_forItem_axe(actorx)) { + ClObjTris_c* axe_tris_p = &player->item_axe_tris; + ClObjTrisElem_c* axe_tris_elem_p = axe_tris_p->elements; + ClObjTrisElemAttr_c* axe_tris_elem_attr_p = &axe_tris_elem_p->attribute; + xyz_t* cross_p = &axe_tris_elem_attr_p->t; + ACTOR* reflect_actor = axe_tris_p->collision_obj.collided_actor; + + *target_pos_p = *cross_p; + *reflect_actor_pp = reflect_actor; + + if (reflect_actor != NULL) { + if (reflect_actor->id == mAc_PROFILE_BALL) { + if (reflect_actor->speed == 0.0f) { + return mPlayer_AXE_HIT_REFLECT; + } + } else { + return mPlayer_AXE_HIT_REFLECT; + } + } else { + return mPlayer_AXE_HIT_REFLECT; + } + } + + { + xyz_t* unit_center_p; + s16 player_angle_y = actorx->shape_info.rotation.y; + xyz_t player_move_pos; + int player_pos_x; + int player_pos_z; + xyz_t unit_center_pos[8]; + xyz_t unit_pos[8]; + int unit_exist_table[8]; + int unit_center_angle_table[8]; + f32 unit_center_dist_table[8]; + int unit_count; + int i; + int right_idx = -1; + int left_idx = -1; + int up_idx = -1; + int down_idx = -1; + f32 x; + f32 z; + + Player_actor_Get_player_move_position(actorx, &player_move_pos); + player_pos_x = (int)(player_move_pos.x / mFI_UT_WORLDSIZE_X_F); + player_pos_z = (int)(player_move_pos.z / mFI_UT_WORLDSIZE_Z_F); + + x = player_pos_x * mFI_UT_WORLDSIZE_X_F; + z = player_pos_z * mFI_UT_WORLDSIZE_Z_F; + + if (x == player_move_pos.x && z == player_move_pos.z) { + return 0; + } else if (x == player_move_pos.x) { + unit_count = 4; + unit_pos[0].x = unit_pos[2].x = player_move_pos.x + mFI_UT_WORLDSIZE_HALF_X_F; + unit_pos[1].x = unit_pos[3].x = player_move_pos.x - mFI_UT_WORLDSIZE_HALF_X_F; + unit_pos[0].z = unit_pos[1].z = player_move_pos.z - mFI_UT_WORLDSIZE_Z_F; + unit_pos[2].z = unit_pos[3].z = player_move_pos.z + mFI_UT_WORLDSIZE_Z_F; + } else if (z == player_move_pos.z) { + unit_count = 4; + unit_pos[0].x = unit_pos[2].x = player_move_pos.x + mFI_UT_WORLDSIZE_X_F; + unit_pos[1].x = unit_pos[3].x = player_move_pos.x - mFI_UT_WORLDSIZE_X_F; + unit_pos[0].z = unit_pos[1].z = player_move_pos.z - mFI_UT_WORLDSIZE_HALF_Z_F; + unit_pos[2].z = unit_pos[3].z = player_move_pos.z + mFI_UT_WORLDSIZE_HALF_Z_F; + } else { + right_idx = 3; + left_idx = 4; + up_idx = 1; + down_idx = 6; + unit_count = 8; + + unit_pos[6].x = player_move_pos.x; + unit_pos[1].x = player_move_pos.x; + unit_pos[4].z = player_move_pos.z; + unit_pos[0].x = unit_pos[3].x = unit_pos[5].x = player_move_pos.x - mFI_UT_WORLDSIZE_X_F; + unit_pos[2].x = unit_pos[4].x = unit_pos[7].x = player_move_pos.x + mFI_UT_WORLDSIZE_X_F; + unit_pos[0].z = unit_pos[1].z = unit_pos[2].z = player_move_pos.z - mFI_UT_WORLDSIZE_Z_F; + unit_pos[3].z = player_move_pos.z; + unit_pos[5].z = unit_pos[6].z = unit_pos[7].z = player_move_pos.z + mFI_UT_WORLDSIZE_Z_F; + } + + for (i = 0; i < unit_count; i++) { + unit_center_p = &unit_center_pos[i]; + unit_exist_table[i] = mFI_Wpos2UtCenterWpos(unit_center_p, unit_pos[i]); + if (unit_exist_table[i] != FALSE) { + f32 dx = unit_center_p->x - player_move_pos.x; + f32 dz = unit_center_p->z - player_move_pos.z; + f32 dist_center = Math3DVecLength2D(dx, dz); + int angle_center = atans_table(dz, dx) - player_angle_y; + int abs_angle_center = ABS(angle_center); + + if (abs_angle_center > DEG2SHORT_ANGLE2(180.0f)) { + abs_angle_center = DEG2SHORT_ANGLE2(360.0f) - abs_angle_center; + } + + unit_center_angle_table[i] = abs_angle_center; + unit_center_dist_table[i] = dist_center; + } + } + + { + int tree_exist_table[8] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }; + mActor_name_t tree_fg_table[8]; + mActor_name_t* unit_fg_p; + + for (i = 0; i < unit_count; i++) { + if (unit_exist_table[i] != FALSE) { + unit_center_p = &unit_center_pos[i]; + unit_fg_p = mFI_GetUnitFG(*unit_center_p); + + if (unit_fg_p != NULL) { + mActor_name_t item = *unit_fg_p; + + if (IS_ITEM_COLLIDEABLE_TREE(item) != FALSE || IS_ITEM_ROCK(item) != FALSE) { + f32 diff_y = mCoBG_GetBgY_OnlyCenter_FromWpos2(*unit_center_p, 0.0f) - player_move_pos.y; + f32 abs_diff_y = ABS(diff_y); + + if (abs_diff_y < (mFI_UNIT_BASE_SIZE_F * 0.5f)) { + tree_fg_table[i] = item; + tree_exist_table[i] = TRUE; + } + } + } + } + } + + for (i = 0; i < unit_count; i++) { + if (tree_exist_table[i] != FALSE) { + if (unit_center_dist_table[i] > (mFI_UNIT_BASE_SIZE_F * 1.5f)) { + tree_exist_table[i] = FALSE; + } + } + } + + for (i = 0; i < unit_count; i++) { + if (tree_exist_table[i] != FALSE) { + if (unit_center_angle_table[i] > DEG2SHORT_ANGLE2(75.0f)) { + tree_exist_table[i] = FALSE; + } + } + } + + { + int selected_idx = -1; + int min_angle_y = DEG2SHORT_ANGLE2(360.0f); + + if (right_idx >= 0 && tree_exist_table[right_idx] != FALSE && + min_angle_y > unit_center_angle_table[right_idx]) { + min_angle_y = unit_center_angle_table[right_idx]; + selected_idx = right_idx; + } + + if (left_idx >= 0 && tree_exist_table[left_idx] != FALSE && + min_angle_y > unit_center_angle_table[left_idx]) { + min_angle_y = unit_center_angle_table[left_idx]; + selected_idx = left_idx; + } + + if (up_idx >= 0 && tree_exist_table[up_idx] != FALSE && min_angle_y > unit_center_angle_table[up_idx]) { + min_angle_y = unit_center_angle_table[up_idx]; + selected_idx = up_idx; + } + + if (down_idx >= 0 && tree_exist_table[down_idx] != FALSE && + min_angle_y > unit_center_angle_table[down_idx]) { + min_angle_y = unit_center_angle_table[down_idx]; + selected_idx = down_idx; + } + + if (selected_idx >= 0) { + mActor_name_t item = tree_fg_table[selected_idx]; + + target_pos_p->x = unit_center_pos[selected_idx].x; + target_pos_p->y = player_move_pos.y; + target_pos_p->z = unit_center_pos[selected_idx].z; + *fg_p = item; + + if (IS_ITEM_COLLIDEABLE_TREE(item) != FALSE) { + return mPlayer_AXE_HIT_TREE; /* Hit item was a tree */ + } else { + return mPlayer_AXE_HIT_REFLECT; /* Hit item was a rock, reflect it */ + } + } else { + int selected_idx = -1; + int min_angle_y = DEG2SHORT_ANGLE2(360.0f); + + for (i = 0; i < unit_count; i++) { + if (tree_exist_table[i] != FALSE && min_angle_y > unit_center_angle_table[i]) { + min_angle_y = unit_center_angle_table[i]; + selected_idx = i; + } + } + + if (selected_idx >= 0) { + mActor_name_t item = tree_fg_table[selected_idx]; + + target_pos_p->x = unit_center_pos[selected_idx].x; + target_pos_p->y = player_move_pos.y; + target_pos_p->z = unit_center_pos[selected_idx].z; + *fg_p = item; + + if (IS_ITEM_COLLIDEABLE_TREE(item) != FALSE) { + return mPlayer_AXE_HIT_TREE; /* Hit item was a tree */ + } else { + return mPlayer_AXE_HIT_REFLECT; /* Hit item was a rock, reflect it */ + } + } else { + int exist_table[8] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }; + + for (i = 0; i < unit_count; i++) { + if (unit_exist_table[i] != FALSE) { + if (unit_center_dist_table[i] < (mFI_UNIT_BASE_SIZE_F * 1.5f)) { + exist_table[i] = TRUE; + } + } + } + + for (i = 0; i < unit_count; i++) { + if (exist_table[i] != FALSE) { + if (unit_center_angle_table[i] > DEG2SHORT_ANGLE2(75.0f)) { + exist_table[i] = FALSE; + } + } + } + + { + int selected_idx = -1; + int min_angle_y = DEG2SHORT_ANGLE2(360.0f); + + for (i = 0; i < unit_count; i++) { + if (exist_table[i] != FALSE && min_angle_y > unit_center_angle_table[i]) { + min_angle_y = unit_center_angle_table[i]; + selected_idx = i; + } + } + + if (selected_idx >= 0) { + f32 bg_y = mCoBG_Wpos2BgUtCenterHeight_AddColumn(unit_center_pos[selected_idx]); + f32 diff_y = bg_y - player_move_pos.y; + + if (diff_y >= 31.0f) { + target_pos_p->x = unit_center_pos[selected_idx].x; + target_pos_p->y = player_move_pos.y; + target_pos_p->z = unit_center_pos[selected_idx].z; + *reflect_actor_pp = NULL; + return mPlayer_AXE_HIT_REFLECT; + } + } + } + } + } + } + } + } + + return mPlayer_AXE_HIT_NONE; +} + +static mActor_name_t Player_actor_GetitemNo_forDamageAxe(mActor_name_t itemNo, int reflected) { + if (mEv_CheckTitleDemo() > 0) { + return itemNo; + } + + if (IS_ITEM_AXE(itemNo) != FALSE) { + if (IS_ITEM_GOLDEN_TOOL(itemNo) == FALSE) { + // clang-format off + static mActor_name_t data[] = { + ITM_AXE_USE_1, + ITM_AXE_USE_2, + ITM_AXE_USE_3, + ITM_AXE_USE_4, + ITM_AXE_USE_5, + ITM_AXE_USE_6, + ITM_AXE_USE_7, + EMPTY_NO, + }; + // clang-format on + + int prev_damage; + int axe_damage; + int damage_idx; + + switch (itemNo) { + case ITM_AXE: + damage_idx = 0; + break; + case ITM_AXE_USE_1: + damage_idx = 1; + break; + case ITM_AXE_USE_2: + damage_idx = 2; + break; + case ITM_AXE_USE_3: + damage_idx = 3; + break; + case ITM_AXE_USE_4: + damage_idx = 4; + break; + case ITM_AXE_USE_5: + damage_idx = 5; + break; + case ITM_AXE_USE_6: + damage_idx = 6; + break; + case ITM_AXE_USE_7: + damage_idx = 7; + break; + default: + return itemNo; + } + + if (damage_idx < 0 || damage_idx >= 8) { + damage_idx = 7; + } + + prev_damage = Common_Get(axe_damage); + if (reflected) { + axe_damage = prev_damage + 3; + } else { + axe_damage = prev_damage + 1; + } + + Common_Set(axe_damage, axe_damage); + + switch (axe_damage >= 9) { + default: + return data[damage_idx]; + case FALSE: + return itemNo; + } + } + } + + return itemNo; +} + +static int Player_actor_CheckAndRequest_main_axe_all(GAME* game, int prio) { + xyz_t target_pos; + mActor_name_t item; + ACTOR* reflect_actor_p; + + if (Player_actor_CheckController_forAxe(game)) { + int result = + Player_actor_Check_axe_after(GET_PLAYER_ACTOR_GAME_ACTOR(game), &target_pos, &item, &reflect_actor_p); + + if (result == mPlayer_AXE_HIT_TREE) { + int tree_ut_x; + int tree_ut_z; + + if (mFI_Wpos2UtNum(&tree_ut_x, &tree_ut_z, target_pos)) { + mActor_name_t damage_itemNo = + Player_actor_GetitemNo_forDamageAxe(Player_actor_Get_ItemNoSubmenu(), FALSE); + + if (damage_itemNo == EMPTY_NO) { + return Player_actor_request_main_broken_axe_type_swing(game, &target_pos, item, tree_ut_x, + tree_ut_z, prio); + } else { + return Player_actor_request_main_swing_axe_all(game, &target_pos, item, damage_itemNo, tree_ut_x, + tree_ut_z, prio); + } + } + + return FALSE; + } else if (result == mPlayer_AXE_HIT_REFLECT) { + mActor_name_t damage_itemNo = Player_actor_GetitemNo_forDamageAxe(Player_actor_Get_ItemNoSubmenu(), TRUE); + + if (damage_itemNo == EMPTY_NO) { + return Player_actor_request_main_broken_axe_type_reflect(game, &target_pos, item, reflect_actor_p, + prio); + } else { + return Player_actor_request_main_reflect_axe_all(game, &target_pos, item, damage_itemNo, + reflect_actor_p, prio); + } + } else { + return Player_actor_request_main_air_axe_all(game, prio); + } + } + + return FALSE; +} + +static int Player_actor_CheckAbleSpeed_forItem(GAME* game) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + switch (player->now_main_index) { + case mPlayer_INDEX_WALK: + case mPlayer_INDEX_RUN: + case mPlayer_INDEX_DASH: + if (player->keyframe0.frame_control.speed >= 0.5f) { + return FALSE; + } + break; + } + + return TRUE; +} + +static int Player_actor_CheckAndRequest_main_umbrella_all(GAME* game, int prio) { + if (Player_actor_CheckController_forUmbrella(game) && Player_actor_CheckAbleSpeed_forItem(game)) { + return Player_actor_request_main_rotate_umbrella_all(game, prio); + } + + return FALSE; +} + +static int Player_actor_CheckAndRequest_main_fan_all(GAME* game, int check_trigger, int param_2, int prio) { + if (Player_actor_CheckController_forFan(game, check_trigger) && Player_actor_CheckAbleSpeed_forItem(game)) { + return Player_actor_request_main_swing_fan_all(game, param_2, prio); + } + + return FALSE; +} + +static void Player_actor_SetEffectStart_axe_common(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (Player_actor_Check_AnimationFrame(&player->keyframe0.frame_control, 12.0f)) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_SWING_AXE, actorx->world.position, 2, actorx->shape_info.rotation.y, game, + RSV_NO, actorx->bg_collision_check.result.unit_attribute, 1); + } +} + +static int Player_actor_Get_WadeEndPos(GAME* game, xyz_t* end_pos_p) { + if (end_pos_p != NULL) { + if (Common_Get(player_actor_exists)) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_WADE) { + *end_pos_p = player->main_data.wade.end_pos; + return TRUE; + } else if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_DEMO_WADE) { + *end_pos_p = player->main_data.demo_wade.end_pos; + return TRUE; + } else if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_WADE_SNOWBALL) { + *end_pos_p = player->main_data.wade_snowball.end_pos; + return TRUE; + } else if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_DEMO_GETON_BOAT_WADE) { + *end_pos_p = player->main_data.demo_geton_boat_wade.end_pos; + return TRUE; + } + + *end_pos_p = GET_PLAYER_ACTOR_GAME_ACTOR(game)->world.position; + } else { + *end_pos_p = ZeroVec; + } + } + + return FALSE; +} + +static void Player_actor_Init_ScrollDemo_forWade(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + Player_actor_request_main_wade_all(gamePT, player->request_wade_dir, mPlayer_REQUEST_PRIORITY_2); + mPlib_strength_request_main_wade_priority(gamePT); +} + +static void Player_actor_Init_ScrollDemo_forDemo_wade(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + Player_actor_request_main_demo_wade_all(gamePT, player->request_wade_dir, mPlayer_REQUEST_PRIORITY_19); + mPlib_strength_request_main_demo_wade_priority(gamePT); +} + +static void Player_actor_Init_ScrollDemo_forDemo_geton_boat_wade(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + Player_actor_request_main_demo_geton_boat_wade_all( + gamePT, player->request_wade_dir, player->geton_boat_wade_border_start, mPlayer_REQUEST_PRIORITY_19); + mPlib_strength_request_main_demo_geton_boat_wade_priority(gamePT); +} + +static void Player_actor_Init_ScrollDemo_forWade_snowball(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + Player_actor_request_main_wade_snowball_all(gamePT, player->request_wade_dir, &player->snowball_dist, + mPlayer_REQUEST_PRIORITY_2); + mPlib_strength_request_main_wade_snowball_priority(gamePT); +} + +static int Player_actor_Set_ScrollDemo_forWade(ACTOR* actorx, GAME* game, int npc_check_flag) { + xyz_t* player_pos_p = &actorx->world.position; + s16 player_angle_y = actorx->shape_info.rotation.y; + int dir = Player_actor_CheckAbleMoveWadeBlock(game, player_pos_p, player_angle_y, 0.65f, DEG2SHORT_ANGLE2(40.0f), + npc_check_flag); + + if (dir != mFI_MOVEDIR_NONE) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (mPlib_Get_unable_wade() == FALSE) { + player->request_wade_dir = dir; + mDemo_Request(mDemo_TYPE_SCROLL, actorx, &Player_actor_Init_ScrollDemo_forWade); + return TRUE; + } + + player->cancel_wade_timer = player->player_frame_counter; + player->excute_cancel_wade = TRUE; + } + + return FALSE; +} + +static int Player_actor_Set_ScrollDemo_forDemo_wade(ACTOR* actorx) { + int dir = Player_actor_CheckAbleMoveDemoWadeBlock(actorx); + + if (dir != mFI_MOVEDIR_NONE) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->request_wade_dir = dir; + mDemo_Request(mDemo_TYPE_SCROLL2, actorx, &Player_actor_Init_ScrollDemo_forDemo_wade); + return TRUE; + } + + return FALSE; +} + +static int Player_actor_Set_ScrollDemo_forDemo_geton_boat_wade(ACTOR* actorx, s16 angle_y, f32 border_start) { + int dir = Player_actor_CheckAbleMoveDemoWadeBoatBlock(actorx, angle_y, border_start); + + if (dir != mFI_MOVEDIR_NONE) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->request_wade_dir = dir; + player->geton_boat_wade_border_start = border_start; + mDemo_Request(mDemo_TYPE_SCROLL3, actorx, &Player_actor_Init_ScrollDemo_forDemo_geton_boat_wade); + return TRUE; + } + + return FALSE; +} + +static int Player_actor_Set_ScrollDemo_forWade_snowball(ACTOR* actorx, int request_dir, const xyz_t* snowball_dist) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (mPlib_Get_unable_wade() == FALSE) { + player->request_wade_dir = request_dir; + player->snowball_dist = *snowball_dist; + mDemo_Request(mDemo_TYPE_SCROLL, actorx, &Player_actor_Init_ScrollDemo_forWade_snowball); + return TRUE; + } else { + player->cancel_wade_timer = player->player_frame_counter; + player->excute_cancel_wade = TRUE; + } + + return FALSE; +} + +static void Player_actor_SetForMark_for_settle_main(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_index = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE) { + // clang-format off + static const s8 value[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + if (value[main_index] != FALSE) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_FOOTPRINT, player->left_foot_pos, 2, player->left_foot_angle.y, game, + RSV_NO, actorx->bg_collision_check.result.unit_attribute, 0); + + eEC_CLIP->effect_make_proc(eEC_EFFECT_FOOTPRINT, player->right_foot_pos, 2, player->right_foot_angle.y, + game, RSV_NO, actorx->bg_collision_check.result.unit_attribute, 0); + } + } +} + +static void Player_actor_SetupItem_Base0(ACTOR* actorx, int anim1_idx, int item_anim_idx, f32 item_anim_speed, + f32 item_morph_speed, f32 start_frame, int* anim1_idx_p, + int* part_table_idx_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int item_kind = Player_actor_Get_ItemKind(actorx, player->requested_main_index); + + Player_actor_LoadOrDestruct_Item(actorx, item_kind, item_anim_idx, item_anim_speed, item_morph_speed, start_frame, + mPlayer_ITEM_IS_BALLOON(item_kind) == FALSE); + + if (item_kind >= 0) { + *anim1_idx_p = mPlib_Get_BasicPlayerAnimeIndex_fromItemKind(item_kind); + } else { + *anim1_idx_p = anim1_idx; + } + + Player_actor_Set_now_item_main_index(actorx, Player_actor_Get_BasicItemMainIndex_fromItemKind(item_kind)); + player->item_kind = item_kind; + *part_table_idx_p = mPlib_Get_BasicPartTableIndex_fromAnimeIndex(*anim1_idx_p); +} + +static int Player_actor_SetupItem_Base_windmill(ACTOR* actorx, int requested_item_kind, int current_item_kind, + int anim1_idx, int* anim1_idx_p, int* part_table_idx_p) { + if (mPlayer_ITEM_IS_WINDMILL(requested_item_kind) != FALSE) { + if (requested_item_kind != current_item_kind) { + Player_actor_SetupItem_Base0(actorx, anim1_idx, + mPlib_Get_BasicItemAnimeIndex_fromItemKind(requested_item_kind), 0.0f, 0.0f, + 1.0f, anim1_idx_p, part_table_idx_p); + } else { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_FrameControl_c* item_fc = &player->item_keyframe.frame_control; + + Player_actor_SetupItem_Base0(actorx, anim1_idx, + mPlib_Get_BasicItemAnimeIndex_fromItemKind(requested_item_kind), + item_fc->speed, 0.0f, item_fc->current_frame, anim1_idx_p, part_table_idx_p); + } + + return TRUE; + } + + return FALSE; +} + +static void Player_actor_SetupItem_Base1(ACTOR* actorx, int anim1_idx, f32 item_morph_speed, int* anim1_idx_p, + int* part_table_idx_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int item_kind = Player_actor_Get_ItemKind(actorx, player->requested_main_index); + + if (Player_actor_SetupItem_Base_windmill(actorx, item_kind, player->item_kind, anim1_idx, anim1_idx_p, + part_table_idx_p) == FALSE) { + int item_anime_idx = mPlib_Get_BasicItemAnimeIndex_fromItemKind(item_kind); + + Player_actor_SetupItem_Base0(actorx, anim1_idx, item_anime_idx, 0.5f, item_morph_speed, -1.0f, anim1_idx_p, + part_table_idx_p); + } +} + +static void Player_actor_SetupItem_Base2(ACTOR* actorx, int item_kind, int anim_idx, int item_main_index, + f32 morph_speed, f32 start_frame, int mode) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int request_item_kind = Player_actor_Get_ItemKind(actorx, player->requested_main_index); + + if (item_kind == request_item_kind && Player_actor_Check_ItemAnimationToItemKind(item_kind, anim_idx) != FALSE) { + Player_actor_LoadOrDestruct_Item(actorx, item_kind, anim_idx, 0.5f, morph_speed, start_frame, mode); + Player_actor_Set_now_item_main_index(actorx, item_main_index); + player->item_kind = item_kind; + } +} + +static void Player_actor_SetupItem_Base3(ACTOR* actorx, int anim1_idx, f32 morph_speed, int* anim1_idx_p, + int* part_table_idx_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int item_kind = Player_actor_Get_ItemKind(actorx, player->requested_main_index); + + if (Player_actor_SetupItem_Base_windmill(actorx, item_kind, player->item_kind, anim1_idx, anim1_idx_p, + part_table_idx_p) == FALSE) { + if (mPlayer_ITEM_IS_ROD(item_kind) == FALSE) { + int item_anime_idx = mPlib_Get_BasicItemAnimeIndex_fromItemKind(item_kind); + + Player_actor_SetupItem_Base0(actorx, anim1_idx, item_anime_idx, 0.5f, morph_speed, -1.0f, anim1_idx_p, + part_table_idx_p); + } else { + Player_actor_SetupItem_Base0(actorx, anim1_idx, mPlayer_ITEM_DATA_ROD_MOVE, 0.5f, morph_speed, -1.0f, + anim1_idx_p, part_table_idx_p); + } + } +} + +static void Player_actor_Get_ItemRodTopInitPos(ACTOR* actorx, xyz_t* pos_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->item_rod_top_pos_set != FALSE) { + *pos_p = player->item_rod_top_pos; + } else { + xyz_t pos = actorx->world.position; + s_xyz* player_rot_p = &actorx->shape_info.rotation; + + pos.x += 25.5456f; + pos.y += 271.9735f; + pos.z -= 21.69f; + + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateZ(player_rot_p->z, 1); + Matrix_RotateX(player_rot_p->x, 1); + Matrix_RotateY(player_rot_p->y, 1); + Matrix_Position(&pos, pos_p); + Matrix_pull(); + } +} + +static void Player_actor_Get_ItemRodVirtualTopPos(ACTOR* actorx, xyz_t* pos_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->item_rod_top_pos_set != FALSE) { + *pos_p = player->item_rod_virtual_top_pos; + } else { + Player_actor_Get_ItemRodTopInitPos(actorx, pos_p); + } +} + +static int Player_actor_check_cancel_request_change_proc_index(int requested_main_index) { + if (mPlib_check_player_warp_forEvent() != FALSE && mPlayer_MAIN_INDEX_VALID(requested_main_index) != FALSE) { + // clang-format off + static const s8 value[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + return value[requested_main_index]; + } + + return FALSE; +} + +static int Player_actor_able_request_main_index_for_reset(int request_main_index) { + if (mPlayer_MAIN_INDEX_VALID(request_main_index) != FALSE) { + // clang-format off + static const s8 value[] = { + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + return value[request_main_index]; + } + + return FALSE; +} + +static int Player_actor_check_able_request_main_index_for_reset(int request_main_index) { + if (Common_Get(reset_flag) && Now_Private->reset_count == 2 && + Player_actor_able_request_main_index_for_reset(request_main_index) != FALSE) { + if (Common_Get(reset_type) != 3) { + Common_Set(reset_type, 3); + } + + return TRUE; + } + + return FALSE; +} + +static int Player_actor_check_request_main_able(GAME* game, int request_main_index, int priority) { + if (Player_actor_check_cancel_request_change_proc_index(request_main_index) == FALSE && + Player_actor_check_able_request_main_index_for_reset(request_main_index) == FALSE && + Player_actor_check_request_main_priority(game, priority) > 0) { + return TRUE; + } + + return FALSE; +} + +static int Player_actor_cancel_request_change_proc_index(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->requested_main_index_changed != FALSE && + Player_actor_check_cancel_request_change_proc_index(player->requested_main_index) != FALSE) { + player->requested_main_index_priority = mPlayer_REQUEST_PRIORITY_NONE; + player->requested_main_index_changed = FALSE; + return TRUE; + } + + return FALSE; +} + +static int Player_actor_Check_scoop_after(GAME* game, xyz_t* target_pos_p, mActor_name_t* fg_p, + ACTOR** reflect_actor_pp, int gold_shovel) { + return mPlib_Check_scoop_after(game, target_pos_p, fg_p, reflect_actor_pp, gold_shovel); +} + +static int Player_actor_Search_STONE_TC(ACTOR* actorx, xyz_t* target_pos_p) { + mActor_name_t* fg_p = mFI_GetUnitFG(*target_pos_p); + + if (fg_p != NULL && IS_ITEM_STONE_TC(*fg_p) != FALSE && Common_Get(clip).bg_item_clip != NULL && + Common_Get(clip).bg_item_clip->ten_coin_entry_ex_proc != NULL) { + Common_Get(clip).bg_item_clip->ten_coin_entry_ex_proc(target_pos_p, actorx->shape_info.rotation.y); + return TRUE; + } + + return FALSE; +} + +static int Player_actor_CheckAndRequest_main_scoop_all(GAME* game, int priority) { + if (Player_actor_CheckController_forScoop(game) != FALSE) { + xyz_t target_pos; + mActor_name_t item; + ACTOR* reflect_actor_p; + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + int gold_shovel = player->item_kind == mPlayer_ITEM_KIND_GOLD_SHOVEL; + int scoop_request_index = + Player_actor_Check_scoop_after(game, &target_pos, &item, &reflect_actor_p, gold_shovel); + + if (scoop_request_index == mPlayer_INDEX_DIG_SCOOP) { + if (Player_actor_request_main_dig_scoop_all(game, &target_pos, item, priority)) { + return TRUE; + } + } else if (scoop_request_index == mPlayer_INDEX_FILL_SCOOP) { + if (Player_actor_request_main_fill_scoop_all(game, &target_pos, priority)) { + return TRUE; + } + } else if (scoop_request_index == mPlayer_INDEX_REFLECT_SCOOP) { + if (Player_actor_request_main_reflect_scoop_all(game, &target_pos, item, reflect_actor_p, priority)) { + return TRUE; + } + } else if (scoop_request_index == mPlayer_INDEX_AIR_SCOOP) { + if (Player_actor_request_main_air_scoop_all(game, priority)) { + return TRUE; + } + } else if (scoop_request_index == mPlayer_INDEX_GET_SCOOP) { + if (Player_actor_request_main_get_scoop_all(game, &target_pos, item, priority)) { + return TRUE; + } + } + } + + return FALSE; +} + +static void Player_actor_cancel_request_change_proc_index_by_A_btn(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->a_btn_triggers_submenu != FALSE) { + int request_main_index = player->requested_main_index; + + if (mPlayer_MAIN_INDEX_VALID(request_main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + if (data[request_main_index] != FALSE) { + player->requested_main_index_priority = mPlayer_REQUEST_PRIORITY_NONE; + player->requested_main_index_changed = FALSE; + } + } + + player->a_btn_triggers_submenu = FALSE; + } +} + +static u32 Player_actor_Get_item_net_catch_label(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + switch (player->now_main_index) { + case mPlayer_INDEX_SWING_NET: + case mPlayer_INDEX_PULL_NET: + case mPlayer_INDEX_NOTICE_NET: + case mPlayer_INDEX_PUTAWAY_NET: + return player->item_net_catch_label; + default: + return 0; + } +} + +static int Player_actor_Change_item_net_catch_label(ACTOR* actorx, u32 label, s8 insect_type) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + aINS_INSECT_ACTOR* insect_actor = (aINS_INSECT_ACTOR*)label; + + if (player->item_net_has_catch == FALSE) { + switch (player->now_main_index) { + case mPlayer_INDEX_SWING_NET: + case mPlayer_INDEX_PULL_NET: + case mPlayer_INDEX_NOTICE_NET: + case mPlayer_INDEX_PUTAWAY_NET: + player->item_net_catch_label = label; + player->item_net_catch_type = insect_type; + if (insect_type == 0 && insect_actor != NULL) { + player->item_net_catch_insect_idx = insect_actor->type; + } else if (insect_actor != NULL) { + if (insect_actor->tools_actor.actor_class.id == mAc_PROFILE_BEE) { + player->item_net_catch_insect_idx = aSOI_INSECT_TYPE_BEE; + } else { + player->item_net_catch_insect_idx = aSOI_INSECT_TYPE_ANT; + } + } else { + player->item_net_catch_insect_idx = aSOI_INSECT_TYPE_INVALID; + } + + return TRUE; + } + } + + return FALSE; +} + +static int Player_actor_Check_StopNet(ACTOR* actorx, xyz_t* net_pos_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->changed_main_index != FALSE) { + switch (player->now_main_index) { + case mPlayer_INDEX_PULL_NET: + case mPlayer_INDEX_STOP_NET: + if (net_pos_p != NULL) { + *net_pos_p = player->net_pos; + } + + return TRUE; + } + } + + return FALSE; +} + +static int Player_actor_Check_HitAxe(ACTOR* actorx, xyz_t* axe_pos_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + mPlayer_main_swing_axe_c* swing_axe_p = NULL; + mPlayer_main_reflect_axe_c* reflect_axe_p = NULL; + xyz_t* pos_p; + + switch (player->now_main_index) { + case mPlayer_INDEX_SWING_AXE: + swing_axe_p = &player->main_data.swing_axe; + break; + case mPlayer_INDEX_REFLECT_AXE: + reflect_axe_p = &player->main_data.reflect_axe; + break; + case mPlayer_INDEX_BROKEN_AXE: { + mPlayer_main_broken_axe_c* broken_axe_p = &player->main_data.broken_axe; + + if (broken_axe_p->break_type != mPlayer_AXE_BREAK_FROM_SWING) { + reflect_axe_p = &broken_axe_p->axe.reflect_axe; + } else { + swing_axe_p = &broken_axe_p->axe.swing_axe; + } + break; + } + default: + return FALSE; + } + + if (swing_axe_p != NULL) { + pos_p = &swing_axe_p->target_pos; + } else { + pos_p = &reflect_axe_p->target_pos; + } + + if (pos_p != NULL && Player_actor_Check_AnimationFrame(&player->keyframe0.frame_control, 15.0f) != FALSE) { + if (axe_pos_p != NULL) { + *axe_pos_p = *pos_p; + } + + return TRUE; + } + + return FALSE; +} + +static int Player_actor_Check_VibUnit_OneFrame(ACTOR* actorx, const xyz_t* check_pos_p) { + xyz_t target_pos; + + if (Player_actor_Check_HitAxe(actorx, &target_pos)) { + int check_bx; + int check_bz; + int target_bx; + int target_bz; + + if (mFI_Wpos2BlockNum(&check_bx, &check_bz, *check_pos_p) == FALSE) { + return FALSE; + } + + if (mFI_Wpos2BlockNum(&target_bx, &target_bz, target_pos) == FALSE) { + return FALSE; + } + + if (check_bx == target_bx && check_bz == target_bz) { + return TRUE; + } + } + + return FALSE; +} + +static int Player_actor_Check_HitScoop(ACTOR* actorx, xyz_t* scoop_pos_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + xyz_t* target_pos_p = NULL; + f32 check_frame = 0.0f; + + switch (player->now_main_index) { + case mPlayer_INDEX_DIG_SCOOP: + target_pos_p = &player->main_data.dig_scoop.target_pos; + check_frame = 20.0f; + break; + case mPlayer_INDEX_REFLECT_SCOOP: + target_pos_p = &player->main_data.reflect_scoop.target_pos; + check_frame = 20.0f; + break; + case mPlayer_INDEX_GET_SCOOP: + target_pos_p = &player->main_data.get_scoop.target_pos; + check_frame = 20.0f; + break; + case mPlayer_INDEX_FILL_SCOOP: + target_pos_p = &player->main_data.fill_scoop.target_pos; + check_frame = 40.0f; + break; + case mPlayer_INDEX_PUTIN_SCOOP: + target_pos_p = &player->main_data.putin_scoop.target_pos; + check_frame = 47.0f; + break; + } + + if (target_pos_p != NULL && Player_actor_Check_AnimationFrame(&player->keyframe0.frame_control, check_frame)) { + if (scoop_pos_p != NULL) { + *scoop_pos_p = *target_pos_p; + } + + return TRUE; + } + + return FALSE; +} + +static int Player_actor_Check_DigScoop(ACTOR* actorx, xyz_t* scoop_pos_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + xyz_t* target_pos_p = NULL; + + switch (player->now_main_index) { + case mPlayer_INDEX_DIG_SCOOP: + target_pos_p = &player->main_data.dig_scoop.target_pos; + break; + case mPlayer_INDEX_REFLECT_SCOOP: + target_pos_p = &player->main_data.reflect_scoop.target_pos; + break; + case mPlayer_INDEX_GET_SCOOP: + target_pos_p = &player->main_data.get_scoop.target_pos; + break; + case mPlayer_INDEX_FILL_SCOOP: + target_pos_p = &player->main_data.fill_scoop.target_pos; + break; + case mPlayer_INDEX_PUTIN_SCOOP: + target_pos_p = &player->main_data.putin_scoop.target_pos; + break; + } + + if (target_pos_p != NULL) { + if (scoop_pos_p != NULL) { + *scoop_pos_p = *target_pos_p; + } + + return TRUE; + } + + return FALSE; +} + +static void Player_actor_request_camera2_main_simple_fishing(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + ACTOR* uki_actor = player->fishing_rod_actor_p; + GAME_PLAY* play = (GAME_PLAY*)game; + + if (uki_actor != NULL) { + Camera2_change_priority(play, 0); + Camera2_request_main_simple_fishing(play, &actorx->eye.position, &uki_actor->world.position, 5); + } +} + +static void Player_actor_request_camera2_main_simple_return(ACTOR* actorx, GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + + Camera2_change_priority(play, 0); + Camera2_request_main_simple_fishing_return(play, &actorx->eye.position, 5); +} + +static void Player_actor_request_camera2_main_normal(GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + + Camera2_change_priority(play, 0); + Camera2_request_main_normal(play, 0, 5); +} + +static void Player_actor_request_camera2_change_priority(GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + + Camera2_change_priority(play, 0); +} + +static int Player_actor_SearchPosition_npc_forStand(GAME* game, const xyz_t* pos_p) { + if (pos_p != NULL) { + GAME_PLAY* play = (GAME_PLAY*)game; + Actor_info* actor_info = &play->actor_info; + Actor_list* actor_list = &actor_info->list[ACTOR_PART_NPC]; + ACTOR* actor = actor_list->actor; + f32 x = pos_p->x; + f32 z = pos_p->z; + f32 sq_rad = SQ(30.0f); + + for (actor; actor != NULL; actor = actor->next_actor) { + f32 dx = actor->world.position.x - x; + f32 dz = actor->world.position.z - z; + + if (Math3DVecLengthSquare2D(dx, dz) < sq_rad) { + NPC_ACTOR* npc_actor = (NPC_ACTOR*)actor; + + if (npc_actor->condition_info.hide_flg == FALSE) { + return TRUE; + } + } + } + } + + return FALSE; +} + +static void Player_actor_SetEffect_forTakeout_item(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + s8 item_kind = player->item_kind; + + if (mPlayer_ITEM_IS_AXE(item_kind) != FALSE) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_KIGAE_LIGHT, actorx->world.position, 2, actorx->shape_info.rotation.y, + game, RSV_NO, 1, 0); + } else if (mPlayer_ITEM_IS_SHOVEL(item_kind) != FALSE) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_KIGAE_LIGHT, actorx->world.position, 2, actorx->shape_info.rotation.y, + game, RSV_NO, 2, 0); + } +} + +static int Player_actor_check_request_change_item(GAME* game) { + ACTOR* actorx = GET_PLAYER_ACTOR_GAME_ACTOR(game); + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + s8 item_kind = player->item_kind; + s8 requested_item_kind = Player_actor_Get_ItemKind(actorx, player->now_main_index); + int idx; + + if (item_kind != requested_item_kind) { + switch (player->now_main_index) { + case mPlayer_INDEX_WAIT: + case mPlayer_INDEX_WALK: + case mPlayer_INDEX_RUN: + case mPlayer_INDEX_DASH: + return player->now_main_index; + } + } + + return -1; +} + +static int Player_actor_check_item_is_fish(mActor_name_t item) { +/* @BUG - these macros should be swapped */ +#ifndef BUGFIXES + if (ITEM_NAME_GET_CAT(item) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_TYPE(item) == ITEM1_CAT_FISH) { + return TRUE; + } +#else + if (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_CAT(item) == ITEM1_CAT_FISH) { + return TRUE; + } +#endif + + return FALSE; +} + +static int Player_actor_Check_CommonFootMark_AnimeFrame_fromAnimeIndex(f32 cur_frame, f32 speed, f32 end_frame, + int anim_idx, const s16** data_table_p, + const u8* len_table_p) { + if (anim_idx >= 0 && anim_idx < mPlayer_ANIM_NUM) { + const s16* data_p = data_table_p[anim_idx]; + + if (data_p != NULL) { + const int len = len_table_p[anim_idx]; + int i; + + for (i = 0; i < len; i++) { + const f32 frame = *data_p; + + /* Negative frames signal end */ + if (frame < 0.0f) { + return FALSE; + } + + if (Player_actor_Check_AnimationFrame_Common(cur_frame, speed, end_frame, frame)) { + return TRUE; + } + + data_p++; + } + } + } + + return FALSE; +} + +static int Player_actor_Check_RightFootMark_AnimeFrame_fromAnimeIndex(f32 cur_frame, f32 speed, f32 end_frame, + int anime_index) { + static const s16 right_data_wait1[] = { -1 }; + static const s16 right_data_walk1[] = { 9 }; + static const s16 right_data_axe1[] = { -1 }; + static const s16 right_data_run1[] = { 9 }; + static const s16 right_data_push1[] = { 23 }; + static const s16 right_data_pull1[] = { 11, 24 }; + static const s16 right_data_hold_wait1[] = { -1 }; + static const s16 right_data_pickup1[] = { -1 }; + static const s16 right_data_Lturn1[] = { -1 }; + static const s16 right_data_Rturn1[] = { -1 }; + static const s16 right_data_get1[] = { -1 }; + static const s16 right_data_get_change1[] = { 26 }; + static const s16 right_data_get_putaway1[] = { -1 }; + static const s16 right_data_open1[] = { -1 }; + static const s16 right_data_putaway1[] = { -1 }; + static const s16 right_data_trans_wait1[] = { -1 }; + static const s16 right_data_transfer1[] = { -1 }; + static const s16 right_data_umb_open1[] = { -1 }; + static const s16 right_data_umbrella1[] = { -1 }; + static const s16 right_data_dash1[] = { 9 }; + static const s16 right_data_run_slip1[] = { -1 }; + static const s16 right_data_get_pull1[] = { -1 }; + static const s16 right_data_get_m1[] = { -1 }; + static const s16 right_data_kamae_move_m1[] = { 9 }; + static const s16 right_data_kamae_wait_m1[] = { -1 }; + static const s16 right_data_kokeru_a1[] = { -1 }; + static const s16 right_data_kokeru_getup_a1[] = { -1 }; + static const s16 right_data_kokeru_getup_n1[] = { -1 }; + static const s16 right_data_kokeru_n1[] = { -1 }; + static const s16 right_data_net1[] = { -1 }; + static const s16 right_data_net_swing1[] = { 10 }; + static const s16 right_data_axe_swing1[] = { 5, 23 }; + static const s16 right_data_kamae_slip_m1[] = { -1 }; + static const s16 right_data_kokeru1[] = { -1 }; + static const s16 right_data_kokeru_getup1[] = { -1 }; + static const s16 right_data_sitdown1[] = { -1 }; + static const s16 right_data_sitdown_wait1[] = { -1 }; + static const s16 right_data_standup1[] = { -1 }; + static const s16 right_data_putaway_m1[] = { -1 }; + static const s16 right_data_bed_wait1[] = { -1 }; + static const s16 right_data_inbed_L1[] = { -1 }; + static const s16 right_data_inbed_R1[] = { -1 }; + static const s16 right_data_intrain1[] = { 8, 28, 50, 71, 88, 111 }; + static const s16 right_data_kagu_open_d1[] = { 12 }; + static const s16 right_data_kagu_open_h1[] = { -1 }; + static const s16 right_data_kagu_open_k1[] = { -1 }; + static const s16 right_data_negaeri_L1[] = { -1 }; + static const s16 right_data_negaeri_R1[] = { -1 }; + static const s16 right_data_outbed_L1[] = { -1 }; + static const s16 right_data_outbed_R1[] = { -1 }; + static const s16 right_data_outtrain1[] = { 21 }; + static const s16 right_data_kagu_close_d1[] = { 16 }; + static const s16 right_data_kagu_close_h1[] = { 6 }; + static const s16 right_data_kagu_close_k1[] = { 6 }; + static const s16 right_data_kagu_wait_d1[] = { -1 }; + static const s16 right_data_kagu_wait_h1[] = { -1 }; + static const s16 right_data_kagu_wait_k1[] = { -1 }; + static const s16 right_data_go_out_o1[] = { -1 }; + static const s16 right_data_go_out_s1[] = { -1 }; + static const s16 right_data_into_s1[] = { -1 }; + static const s16 right_data_axe_hane1[] = { 5, 24, 37 }; + static const s16 right_data_axe_suka1[] = { 5, 40 }; + static const s16 right_data_hold_wait_h1[] = { -1 }; + static const s16 right_data_hold_wait_o1[] = { -1 }; + static const s16 right_data_get_t1[] = { -1 }; + static const s16 right_data_get_t2[] = { 31 }; + static const s16 right_data_putaway_t1[] = { 17 }; + static const s16 right_data_sao1[] = { -1 }; + static const s16 right_data_sao_swing1[] = { -1 }; + static const s16 right_data_turi_hiki1[] = { -1 }; + static const s16 right_data_turi_wait1[] = { -1 }; + static const s16 right_data_not_get_t1[] = { -1 }; + static const s16 right_data_menu_catch1[] = { -1 }; + static const s16 right_data_menu_change1[] = { -1 }; + static const s16 right_data_umb_close1[] = { 13, 27 }; + static const s16 right_data_not_sao_swing1[] = { -1 }; + static const s16 right_data_intrain_wait1[] = { -1 }; + static const s16 right_data_clear_table1[] = { -1 }; + static const s16 right_data_dig1[] = { 13, 41 }; + static const s16 right_data_fill_up1[] = { 14, 41, 51 }; + static const s16 right_data_not_dig1[] = { 13, 29 }; + static const s16 right_data_clear_table_l1[] = { -1 }; + static const s16 right_data_pickup_l1[] = { -1 }; + static const s16 right_data_scoop1[] = { -1 }; + static const s16 right_data_confirm1[] = { 10, 22 }; + static const s16 right_data_dig_suka1[] = { 15, 41 }; + static const s16 right_data_get_d1[] = { 13, 43, 51 }; + static const s16 right_data_putaway_d1[] = { 12 }; + static const s16 right_data_dig_kabu1[] = { 33, 61 }; + static const s16 right_data_fill_up_i1[] = { 21, 48, 58 }; + static const s16 right_data_send_mail1[] = { -1 }; + static const s16 right_data_get_f1[] = { -1 }; + static const s16 right_data_get_pull_f1[] = { -1 }; + static const s16 right_data_get_putaway_f1[] = { -1 }; + static const s16 right_data_trans_wait_f1[] = { -1 }; + static const s16 right_data_transfer_f1[] = { -1 }; + static const s16 right_data_shake1[] = { -1 }; + static const s16 right_data_tired1[] = { -1 }; + static const s16 right_data_wash1[] = { -1 }; + static const s16 right_data_wash2[] = { -1 }; + static const s16 right_data_wash3[] = { -1 }; + static const s16 right_data_wash4[] = { -1 }; + static const s16 right_data_wash5[] = { -1 }; + static const s16 right_data_fukubiki1[] = { -1 }; + static const s16 right_data_omairi1[] = { -1 }; + static const s16 right_data_saisen1[] = { -1 }; + static const s16 right_data_return_mail1[] = { -1 }; + static const s16 right_data_return_mail2[] = { -1 }; + static const s16 right_data_return_mail3[] = { -1 }; + static const s16 right_data_eat1[] = { -1 }; + static const s16 right_data_gaaan1[] = { -1 }; + static const s16 right_data_gaaan2[] = { -1 }; + static const s16 right_data_deru1[] = { -1 }; + static const s16 right_data_guratuku1[] = { -1 }; + static const s16 right_data_mogaku1[] = { -1 }; + static const s16 right_data_otiru1[] = { -1 }; + static const s16 right_data_zassou1[] = { -1 }; + static const s16 right_data_knock1[] = { -1 }; + static const s16 right_data_biku1[] = { -1 }; + static const s16 right_data_hati1[] = { -1 }; + static const s16 right_data_hati2[] = { -1 }; + static const s16 right_data_hati3[] = { -1 }; + static const s16 right_data_push_yuki1[] = { 9 }; + static const s16 right_data_deru2[] = { -1 }; + static const s16 right_data_otiru2[] = { -1 }; + static const s16 right_data_itazura1[] = { -1 }; + static const s16 right_data_umb_rot1[] = { -1 }; + static const s16 right_data_pickup_wait1[] = { -1 }; + static const s16 right_data_yatta1[] = { -1 }; + static const s16 right_data_yatta2[] = { -1 }; + static const s16 right_data_yatta3[] = { -1 }; + static const s16 right_data_kaze1[] = { -1 }; + static const s16 right_data_mosquito1[] = { -1 }; + static const s16 right_data_mosquito2[] = { -1 }; + static const s16 right_data_ride1[] = { 9 }; + static const s16 right_data_ride2[] = { -1 }; + static const s16 right_data_ridewait[] = { -1 }; + static const s16 right_data_getoff1[] = { -1 }; + static const s16 right_data_getoff2[] = { -1 }; + static const s16 right_data_utiwa_wait1[] = { -1 }; + static const s16 right_data_utiwa_d1[] = { -1 }; + static const s16 right_data_axe_break1[] = { 5, 24, 37 }; + static const s16 right_data_axe_breakwait1[] = { -1 }; + static const s16 right_data_light_on1[] = { -1 }; + static const s16 right_data_taisou1[] = { -1 }; + static const s16 right_data_taisou2_1[] = { -1 }; + static const s16 right_data_taisou2_2[] = { -1 }; + static const s16 right_data_taisou3[] = { -1 }; + static const s16 right_data_taisou4_1[] = { -1 }; + static const s16 right_data_taisou4_2[] = { -1 }; + static const s16 right_data_taisou5_1[] = { -1 }; + static const s16 right_data_taisou5_2[] = { -1 }; + static const s16 right_data_taisou6_1[] = { -1 }; + static const s16 right_data_taisou6_2[] = { -1 }; + static const s16 right_data_taisou7_1[] = { -1 }; + static const s16 right_data_taisou7_2[] = { -1 }; + static const s16 right_data_omairi_us1[] = { -1 }; + + static const s16* data_p_table[] = { + right_data_wait1, + right_data_walk1, + right_data_axe1, + right_data_run1, + right_data_push1, + right_data_pull1, + right_data_hold_wait1, + right_data_pickup1, + right_data_Lturn1, + right_data_Rturn1, + right_data_get1, + right_data_get_change1, + right_data_get_putaway1, + right_data_open1, + right_data_putaway1, + right_data_trans_wait1, + right_data_transfer1, + right_data_umb_open1, + right_data_umbrella1, + right_data_dash1, + right_data_run_slip1, + right_data_get_pull1, + right_data_get_m1, + right_data_kamae_move_m1, + right_data_kamae_wait_m1, + right_data_kokeru_a1, + right_data_kokeru_getup_a1, + right_data_kokeru_getup_n1, + right_data_kokeru_n1, + right_data_net1, + right_data_net_swing1, + right_data_axe_swing1, + right_data_kamae_slip_m1, + right_data_kokeru1, + right_data_kokeru_getup1, + right_data_sitdown1, + right_data_sitdown_wait1, + right_data_standup1, + right_data_putaway_m1, + right_data_bed_wait1, + right_data_inbed_L1, + right_data_inbed_R1, + right_data_intrain1, + right_data_kagu_open_d1, + right_data_kagu_open_h1, + right_data_kagu_open_k1, + right_data_negaeri_L1, + right_data_negaeri_R1, + right_data_outbed_L1, + right_data_outbed_R1, + right_data_outtrain1, + right_data_kagu_close_d1, + right_data_kagu_close_h1, + right_data_kagu_close_k1, + right_data_kagu_wait_d1, + right_data_kagu_wait_h1, + right_data_kagu_wait_k1, + right_data_go_out_o1, + right_data_go_out_s1, + right_data_into_s1, + right_data_axe_hane1, + right_data_axe_suka1, + right_data_hold_wait_h1, + right_data_hold_wait_o1, + right_data_get_t1, + right_data_get_t2, + right_data_putaway_t1, + right_data_sao1, + right_data_sao_swing1, + right_data_turi_hiki1, + right_data_turi_wait1, + right_data_not_get_t1, + right_data_menu_catch1, + right_data_menu_change1, + right_data_umb_close1, + right_data_not_sao_swing1, + right_data_intrain_wait1, + right_data_clear_table1, + right_data_dig1, + right_data_fill_up1, + right_data_not_dig1, + right_data_clear_table_l1, + right_data_pickup_l1, + right_data_scoop1, + right_data_confirm1, + right_data_dig_suka1, + right_data_get_d1, + right_data_putaway_d1, + right_data_dig_kabu1, + right_data_fill_up_i1, + right_data_send_mail1, + right_data_get_f1, + right_data_get_pull_f1, + right_data_get_putaway_f1, + right_data_trans_wait_f1, + right_data_transfer_f1, + right_data_shake1, + right_data_tired1, + right_data_wash1, + right_data_wash2, + right_data_wash3, + right_data_wash4, + right_data_wash5, + right_data_fukubiki1, + right_data_omairi1, + right_data_saisen1, + right_data_return_mail1, + right_data_return_mail2, + right_data_return_mail3, + right_data_eat1, + right_data_gaaan1, + right_data_gaaan2, + right_data_deru1, + right_data_guratuku1, + right_data_mogaku1, + right_data_otiru1, + right_data_zassou1, + right_data_knock1, + right_data_biku1, + right_data_hati1, + right_data_hati2, + right_data_hati3, + right_data_push_yuki1, + right_data_deru2, + right_data_otiru2, + right_data_itazura1, + right_data_umb_rot1, + right_data_pickup_wait1, + right_data_yatta1, + right_data_yatta2, + right_data_yatta3, + right_data_kaze1, + right_data_mosquito1, + right_data_mosquito2, + right_data_ride1, + right_data_ride2, + right_data_ridewait, + right_data_getoff1, + right_data_getoff2, + right_data_utiwa_wait1, + right_data_utiwa_d1, + right_data_axe_break1, + right_data_axe_breakwait1, + right_data_light_on1, + right_data_taisou1, + right_data_taisou2_1, + right_data_taisou2_2, + right_data_taisou3, + right_data_taisou4_1, + right_data_taisou4_2, + right_data_taisou5_1, + right_data_taisou5_2, + right_data_taisou6_1, + right_data_taisou6_2, + right_data_taisou7_1, + right_data_taisou7_2, + right_data_omairi_us1, + }; + + // clang-format off + static const u8 size_table[] = { + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 6, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 2, + 3, + 2, + 1, + 1, + 1, + 2, + 2, + 3, + 1, + 2, + 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + }; + // clang-format on + + return Player_actor_Check_CommonFootMark_AnimeFrame_fromAnimeIndex(cur_frame, speed, end_frame, anime_index, + data_p_table, size_table); +} + +static int Player_actor_Check_LeftFootMark_AnimeFrame_fromAnimeIndex(f32 cur_frame, f32 speed, f32 end_frame, + int anime_index) { + static const s16 left_data_wait1[] = { -1 }; + static const s16 left_data_walk1[] = { 1 }; + static const s16 left_data_axe1[] = { -1 }; + static const s16 left_data_run1[] = { 1 }; + static const s16 left_data_push1[] = { 15 }; + static const s16 left_data_pull1[] = { 6, 17 }; + static const s16 left_data_hold_wait1[] = { -1 }; + static const s16 left_data_pickup1[] = { 9, 20 }; + static const s16 left_data_Lturn1[] = { -1 }; + static const s16 left_data_Rturn1[] = { -1 }; + static const s16 left_data_get1[] = { -1 }; + static const s16 left_data_get_change1[] = { 26 }; + static const s16 left_data_get_putaway1[] = { -1 }; + static const s16 left_data_open1[] = { -1 }; + static const s16 left_data_putaway1[] = { -1 }; + static const s16 left_data_trans_wait1[] = { -1 }; + static const s16 left_data_transfer1[] = { -1 }; + static const s16 left_data_umb_open1[] = { -1 }; + static const s16 left_data_umbrella1[] = { -1 }; + static const s16 left_data_dash1[] = { 1 }; + static const s16 left_data_run_slip1[] = { -1 }; + static const s16 left_data_get_pull1[] = { -1 }; + static const s16 left_data_get_m1[] = { 25, 43 }; + static const s16 left_data_kamae_move_m1[] = { 6 }; + static const s16 left_data_kamae_wait_m1[] = { -1 }; + static const s16 left_data_kokeru_a1[] = { -1 }; + static const s16 left_data_kokeru_getup_a1[] = { -1 }; + static const s16 left_data_kokeru_getup_n1[] = { -1 }; + static const s16 left_data_kokeru_n1[] = { -1 }; + static const s16 left_data_net1[] = { -1 }; + static const s16 left_data_net_swing1[] = { 7 }; + static const s16 left_data_axe_swing1[] = { 13, 29 }; + static const s16 left_data_kamae_slip_m1[] = { -1 }; + static const s16 left_data_kokeru1[] = { -1 }; + static const s16 left_data_kokeru_getup1[] = { -1 }; + static const s16 left_data_sitdown1[] = { -1 }; + static const s16 left_data_sitdown_wait1[] = { -1 }; + static const s16 left_data_standup1[] = { -1 }; + static const s16 left_data_putaway_m1[] = { -1 }; + static const s16 left_data_bed_wait1[] = { -1 }; + static const s16 left_data_inbed_L1[] = { -1 }; + static const s16 left_data_inbed_R1[] = { -1 }; + static const s16 left_data_intrain1[] = { 19, 40, 61, 82, 101 }; + static const s16 left_data_kagu_open_d1[] = { 6 }; + static const s16 left_data_kagu_open_h1[] = { 7 }; + static const s16 left_data_kagu_open_k1[] = { 7 }; + static const s16 left_data_negaeri_L1[] = { -1 }; + static const s16 left_data_negaeri_R1[] = { -1 }; + static const s16 left_data_outbed_L1[] = { -1 }; + static const s16 left_data_outbed_R1[] = { -1 }; + static const s16 left_data_outtrain1[] = { 5, 21 }; + static const s16 left_data_kagu_close_d1[] = { -1 }; + static const s16 left_data_kagu_close_h1[] = { -1 }; + static const s16 left_data_kagu_close_k1[] = { -1 }; + static const s16 left_data_kagu_wait_d1[] = { -1 }; + static const s16 left_data_kagu_wait_h1[] = { -1 }; + static const s16 left_data_kagu_wait_k1[] = { -1 }; + static const s16 left_data_go_out_o1[] = { -1 }; + static const s16 left_data_go_out_s1[] = { -1 }; + static const s16 left_data_into_s1[] = { -1 }; + static const s16 left_data_axe_hane1[] = { 12, 33 }; + static const s16 left_data_axe_suka1[] = { 14 }; + static const s16 left_data_hold_wait_h1[] = { -1 }; + static const s16 left_data_hold_wait_o1[] = { -1 }; + static const s16 left_data_get_t1[] = { 23 }; + static const s16 left_data_get_t2[] = { 21 }; + static const s16 left_data_putaway_t1[] = { 10 }; + static const s16 left_data_sao1[] = { -1 }; + static const s16 left_data_sao_swing1[] = { 18 }; + static const s16 left_data_turi_hiki1[] = { -1 }; + static const s16 left_data_turi_wait1[] = { -1 }; + static const s16 left_data_not_get_t1[] = { 27 }; + static const s16 left_data_menu_catch1[] = { -1 }; + static const s16 left_data_menu_change1[] = { -1 }; + static const s16 left_data_umb_close1[] = { 9, 33 }; + static const s16 left_data_not_sao_swing1[] = { 21 }; + static const s16 left_data_intrain_wait1[] = { -1 }; + static const s16 left_data_clear_table1[] = { -1 }; + static const s16 left_data_dig1[] = { 10, 25 }; + static const s16 left_data_fill_up1[] = { 10, 23, 48 }; + static const s16 left_data_not_dig1[] = { 10, 17, 35 }; + static const s16 left_data_clear_table_l1[] = { -1 }; + static const s16 left_data_pickup_l1[] = { -1 }; + static const s16 left_data_scoop1[] = { -1 }; + static const s16 left_data_confirm1[] = { 15 }; + static const s16 left_data_dig_suka1[] = { 10, 38 }; + static const s16 left_data_get_d1[] = { 10, 27, 51 }; + static const s16 left_data_putaway_d1[] = { 16 }; + static const s16 left_data_dig_kabu1[] = { 30, 45 }; + static const s16 left_data_fill_up_i1[] = { 17, 30, 55 }; + static const s16 left_data_send_mail1[] = { -1 }; + static const s16 left_data_get_f1[] = { -1 }; + static const s16 left_data_get_pull_f1[] = { -1 }; + static const s16 left_data_get_putaway_f1[] = { -1 }; + static const s16 left_data_trans_wait_f1[] = { -1 }; + static const s16 left_data_transfer_f1[] = { -1 }; + static const s16 left_data_shake1[] = { -1 }; + static const s16 left_data_tired1[] = { -1 }; + static const s16 left_data_wash1[] = { -1 }; + static const s16 left_data_wash2[] = { -1 }; + static const s16 left_data_wash3[] = { -1 }; + static const s16 left_data_wash4[] = { -1 }; + static const s16 left_data_wash5[] = { -1 }; + static const s16 left_data_fukubiki1[] = { -1 }; + static const s16 left_data_omairi1[] = { -1 }; + static const s16 left_data_saisen1[] = { -1 }; + static const s16 left_data_return_mail1[] = { -1 }; + static const s16 left_data_return_mail2[] = { -1 }; + static const s16 left_data_return_mail3[] = { -1 }; + static const s16 left_data_eat1[] = { -1 }; + static const s16 left_data_gaaan1[] = { -1 }; + static const s16 left_data_gaaan2[] = { -1 }; + static const s16 left_data_deru1[] = { -1 }; + static const s16 left_data_guratuku1[] = { -1 }; + static const s16 left_data_mogaku1[] = { -1 }; + static const s16 left_data_otiru1[] = { -1 }; + static const s16 left_data_zassou1[] = { -1 }; + static const s16 left_data_knock1[] = { -1 }; + static const s16 left_data_biku1[] = { -1 }; + static const s16 left_data_hati1[] = { -1 }; + static const s16 left_data_hati2[] = { -1 }; + static const s16 left_data_hati3[] = { -1 }; + static const s16 left_data_push_yuki1[] = { 1 }; + static const s16 left_data_deru2[] = { -1 }; + static const s16 left_data_otiru2[] = { -1 }; + static const s16 left_data_itazura1[] = { -1 }; + static const s16 left_data_umb_rot1[] = { -1 }; + static const s16 left_data_pickup_wait1[] = { -1 }; + static const s16 left_data_yatta1[] = { -1 }; + static const s16 left_data_yatta2[] = { -1 }; + static const s16 left_data_yatta3[] = { -1 }; + static const s16 left_data_kaze1[] = { -1 }; + static const s16 left_data_mosquito1[] = { -1 }; + static const s16 left_data_mosquito2[] = { -1 }; + static const s16 left_data_ride1[] = { -1 }; + static const s16 left_data_ride2[] = { -1 }; + static const s16 left_data_ridewait[] = { -1 }; + static const s16 left_data_getoff1[] = { -1 }; + static const s16 left_data_getoff2[] = { -1 }; + static const s16 left_data_utiwa_wait1[] = { -1 }; + static const s16 left_data_utiwa_d1[] = { -1 }; + static const s16 left_data_axe_break1[] = { 12, 33 }; + static const s16 left_data_axe_breakwait1[] = { -1 }; + static const s16 left_data_light_on1[] = { -1 }; + static const s16 left_data_taisou1[] = { -1 }; + static const s16 left_data_taisou2_1[] = { -1 }; + static const s16 left_data_taisou2_2[] = { -1 }; + static const s16 left_data_taisou3[] = { -1 }; + static const s16 left_data_taisou4_1[] = { -1 }; + static const s16 left_data_taisou4_2[] = { -1 }; + static const s16 left_data_taisou5_1[] = { -1 }; + static const s16 left_data_taisou5_2[] = { -1 }; + static const s16 left_data_taisou6_1[] = { -1 }; + static const s16 left_data_taisou6_2[] = { -1 }; + static const s16 left_data_taisou7_1[] = { -1 }; + static const s16 left_data_taisou7_2[] = { -1 }; + static const s16 left_data_omairi_us1[] = { -1 }; + + static const s16* data_p_table[] = { + left_data_wait1, + left_data_walk1, + left_data_axe1, + left_data_run1, + left_data_push1, + left_data_pull1, + left_data_hold_wait1, + left_data_pickup1, + left_data_Lturn1, + left_data_Rturn1, + left_data_get1, + left_data_get_change1, + left_data_get_putaway1, + left_data_open1, + left_data_putaway1, + left_data_trans_wait1, + left_data_transfer1, + left_data_umb_open1, + left_data_umbrella1, + left_data_dash1, + left_data_run_slip1, + left_data_get_pull1, + left_data_get_m1, + left_data_kamae_move_m1, + left_data_kamae_wait_m1, + left_data_kokeru_a1, + left_data_kokeru_getup_a1, + left_data_kokeru_getup_n1, + left_data_kokeru_n1, + left_data_net1, + left_data_net_swing1, + left_data_axe_swing1, + left_data_kamae_slip_m1, + left_data_kokeru1, + left_data_kokeru_getup1, + left_data_sitdown1, + left_data_sitdown_wait1, + left_data_standup1, + left_data_putaway_m1, + left_data_bed_wait1, + left_data_inbed_L1, + left_data_inbed_R1, + left_data_intrain1, + left_data_kagu_open_d1, + left_data_kagu_open_h1, + left_data_kagu_open_k1, + left_data_negaeri_L1, + left_data_negaeri_R1, + left_data_outbed_L1, + left_data_outbed_R1, + left_data_outtrain1, + left_data_kagu_close_d1, + left_data_kagu_close_h1, + left_data_kagu_close_k1, + left_data_kagu_wait_d1, + left_data_kagu_wait_h1, + left_data_kagu_wait_k1, + left_data_go_out_o1, + left_data_go_out_s1, + left_data_into_s1, + left_data_axe_hane1, + left_data_axe_suka1, + left_data_hold_wait_h1, + left_data_hold_wait_o1, + left_data_get_t1, + left_data_get_t2, + left_data_putaway_t1, + left_data_sao1, + left_data_sao_swing1, + left_data_turi_hiki1, + left_data_turi_wait1, + left_data_not_get_t1, + left_data_menu_catch1, + left_data_menu_change1, + left_data_umb_close1, + left_data_not_sao_swing1, + left_data_intrain_wait1, + left_data_clear_table1, + left_data_dig1, + left_data_fill_up1, + left_data_not_dig1, + left_data_clear_table_l1, + left_data_pickup_l1, + left_data_scoop1, + left_data_confirm1, + left_data_dig_suka1, + left_data_get_d1, + left_data_putaway_d1, + left_data_dig_kabu1, + left_data_fill_up_i1, + left_data_send_mail1, + left_data_get_f1, + left_data_get_pull_f1, + left_data_get_putaway_f1, + left_data_trans_wait_f1, + left_data_transfer_f1, + left_data_shake1, + left_data_tired1, + left_data_wash1, + left_data_wash2, + left_data_wash3, + left_data_wash4, + left_data_wash5, + left_data_fukubiki1, + left_data_omairi1, + left_data_saisen1, + left_data_return_mail1, + left_data_return_mail2, + left_data_return_mail3, + left_data_eat1, + left_data_gaaan1, + left_data_gaaan2, + left_data_deru1, + left_data_guratuku1, + left_data_mogaku1, + left_data_otiru1, + left_data_zassou1, + left_data_knock1, + left_data_biku1, + left_data_hati1, + left_data_hati2, + left_data_hati3, + left_data_push_yuki1, + left_data_deru2, + left_data_otiru2, + left_data_itazura1, + left_data_umb_rot1, + left_data_pickup_wait1, + left_data_yatta1, + left_data_yatta2, + left_data_yatta3, + left_data_kaze1, + left_data_mosquito1, + left_data_mosquito2, + left_data_ride1, + left_data_ride2, + left_data_ridewait, + left_data_getoff1, + left_data_getoff2, + left_data_utiwa_wait1, + left_data_utiwa_d1, + left_data_axe_break1, + left_data_axe_breakwait1, + left_data_light_on1, + left_data_taisou1, + left_data_taisou2_1, + left_data_taisou2_2, + left_data_taisou3, + left_data_taisou4_1, + left_data_taisou4_2, + left_data_taisou5_1, + left_data_taisou5_2, + left_data_taisou6_1, + left_data_taisou6_2, + left_data_taisou7_1, + left_data_taisou7_2, + left_data_omairi_us1, + }; + + // clang-format off + static const u8 size_table[] = { + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 5, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 2, + 3, + 3, + 1, + 1, + 1, + 1, + 2, + 3, + 1, + 2, + 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1. + }; + // clang-format on + + return Player_actor_Check_CommonFootMark_AnimeFrame_fromAnimeIndex(cur_frame, speed, end_frame, anime_index, + data_p_table, size_table); +} + +static int Player_actor_Set_FootMark_MarkOnly(ACTOR* actorx, GAME* game, int disable_footprint) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + cKF_SkeletonInfo_R_c* kf0_p = &player->keyframe0; + cKF_FrameControl_c* fc0_p = &kf0_p->frame_control; + f32 cur_frame = fc0_p->current_frame; + f32 speed = fc0_p->speed; + f32 end_frame = fc0_p->end_frame; + int anime_index = player->animation0_idx; + int res = FALSE; + + if (Player_actor_Check_RightFootMark_AnimeFrame_fromAnimeIndex(cur_frame, speed, end_frame, anime_index)) { + if (disable_footprint == FALSE) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_FOOTPRINT, player->right_foot_pos, 2, player->right_foot_angle.y, + game, RSV_NO, actorx->bg_collision_check.result.unit_attribute, 0); + } + + res = TRUE; + } + + if (Player_actor_Check_LeftFootMark_AnimeFrame_fromAnimeIndex(cur_frame, speed, end_frame, anime_index)) { + if (disable_footprint == FALSE) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_FOOTPRINT, player->left_foot_pos, 2, player->left_foot_angle.y, game, + RSV_NO, actorx->bg_collision_check.result.unit_attribute, 0); + } + + res = TRUE; + } + + return res; +} + +static int Player_actor_CheckAble_FootMark_Sound(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int anime_index = player->animation0_idx; + + if (anime_index >= 0 && anime_index < mPlayer_ANIM_NUM) { + // clang-format off + static const u8 data[] = { + FALSE, + TRUE, + FALSE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + return data[anime_index]; + } + + return FALSE; +} + +static void Player_actor_Set_FootMark_Base1(ACTOR* actorx, GAME* game, int disable_effect, int disable_sound) { + int footprint_res = Player_actor_Set_FootMark_MarkOnly(actorx, game, disable_effect); + + if (disable_sound == FALSE && Player_actor_CheckAble_FootMark_Sound(actorx) && footprint_res) { + Player_actor_sound_FootStep2(actorx); + } +} + +static void Player_actor_Set_FootMark_Base2(ACTOR* actorx, GAME* game, int disable_effect, int type) { + if (Player_actor_Set_FootMark_MarkOnly(actorx, game, disable_effect) && + Player_actor_CheckAble_FootMark_Sound(actorx)) { + Player_actor_sound_FootStep1(actorx, type); + } +} + +static int Player_actor_Check_RotateOctagon(GAME* game) { + if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_ROTATE_OCTAGON) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + if (player->keyframe0.frame_control.current_frame >= 9.0f) { + return TRUE; + } + } + + return FALSE; +} + +static void Player_actor_Reset_unable_hand_item_in_demo(ACTOR* actorx, int main_index) { + if (Player_actor_Check_is_demo_mode(main_index) == FALSE) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->unable_hand_item_in_demo = FALSE; + } +} + +static void Player_actor_Reset_able_hand_all_item_in_demo(ACTOR* actorx, int main_index) { + if (Player_actor_Check_is_demo_mode(main_index) == FALSE) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->able_hand_all_item_in_demo = FALSE; + } +} + +static void Player_actor_Set_EffectBgTree(GAME* game, mActor_name_t item, s16 bg_ef_type, int ut_x, int ut_z) { + xyz_t pos; + + if (mFI_UtNum2CenterWpos(&pos, ut_x, ut_z)) { + s16 variant; + pos.y = mCoBG_UtNum2UtCenterY_Keep(ut_x, ut_z); + + if (IS_ITEM_XMAS_TREE(item) != FALSE) { + if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { + variant = 12; + } else { + variant = 3; + } + } else if (IS_ITEM_SMALL_TREE(item) != FALSE) { + if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { + variant = 4; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { + variant = 8; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { + variant = 13; + } else { + variant = -1; + } + } else if (IS_ITEM_MED_TREE(item) != FALSE) { + if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { + variant = 5; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { + variant = 9; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { + variant = 14; + } else { + variant = 0; + } + } else if (IS_ITEM_LARGE_TREE(item) != FALSE) { + if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { + variant = 6; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { + variant = 10; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { + variant = 15; + } else { + variant = 1; + } + } else { + if (FGTreeType_check(item) == mNT_TREE_TYPE_PALM) { + variant = 7; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_CEDAR) { + variant = 11; + } else if (FGTreeType_check(item) == mNT_TREE_TYPE_GOLD) { + variant = 16; + } else { + variant = 2; + } + } + + if (Common_Get(clip).make_effect_bg_proc != NULL) { + Common_Get(clip).make_effect_bg_proc(game, bg_ef_type, variant, &pos); + } + } +} + +static mActor_name_t Player_actor_Get_shake_tree_position_and_itemNo(ACTOR* actorx, xyz_t* pos_p) { + xyz_t* player_pos_p = &actorx->world.position; + xyz_t center_pos; + + if (mFI_Wpos2UtCenterWpos(¢er_pos, *player_pos_p)) { + static const f32 add_X[] = { + -mFI_UT_WORLDSIZE_X_F, 0.0f, mFI_UT_WORLDSIZE_X_F, -mFI_UT_WORLDSIZE_X_F, mFI_UT_WORLDSIZE_X_F, + -mFI_UT_WORLDSIZE_X_F, 0.0f, mFI_UT_WORLDSIZE_X_F, + }; + static const f32 add_Z[] = { + -mFI_UT_WORLDSIZE_Z_F, -mFI_UT_WORLDSIZE_Z_F, -mFI_UT_WORLDSIZE_Z_F, 0.0f, 0.0f, + mFI_UT_WORLDSIZE_Z_F, mFI_UT_WORLDSIZE_Z_F, mFI_UT_WORLDSIZE_Z_F, + }; + mActor_name_t unit_item[8]; + xyz_t unit_pos[8]; + int select_index = -1; + int i; + + for (i = 0; i < 8; i++) { + unit_pos[i].x = center_pos.x + add_X[i]; + unit_pos[i].z = center_pos.z + add_Z[i]; + } + + for (i = 0; i < 8; i++) { + mActor_name_t* fg_p = mFI_GetUnitFG(unit_pos[i]); + + if (fg_p != NULL) { + if (IS_ITEM_COLLIDEABLE_TREE(*fg_p) == FALSE) { + unit_item[i] = EMPTY_NO; + } else { + unit_item[i] = *fg_p; + } + } else { + unit_item[i] = EMPTY_NO; + } + } + + for (i = 0; i < 8; i++) { + if (unit_item[i] != EMPTY_NO) { + f32 dy; + + unit_pos[i].y = mCoBG_GetBgY_OnlyCenter_FromWpos2(unit_pos[i], 0.0f); + dy = ABS(unit_pos[i].y - player_pos_p->y); + + if (dy > 10.0f) { + unit_item[i] = EMPTY_NO; + } + } + } + + for (i = 0; i < 8; i++) { + if (unit_item[i] != EMPTY_NO) { + f32 dist_sq = Math3DLengthSquare2D(unit_pos[i].x, unit_pos[i].z, player_pos_p->x, player_pos_p->z); + + if (dist_sq >= SQ(mFI_UNIT_BASE_SIZE_F)) { + unit_item[i] = EMPTY_NO; + } + } + } + + { + int min_angle = DEG2SHORT_ANGLE2(45.0f); + int player_angle_y = actorx->shape_info.rotation.y; + + for (i = 0; i < 8; i++) { + if (unit_item[i] != EMPTY_NO) { + f32 dx = unit_pos[i].x - player_pos_p->x; + f32 dz = unit_pos[i].z - player_pos_p->z; + int angle = (s16)(atans_table(dz, dx) - player_angle_y); + int abs_angle = ABS(angle); + + if (abs_angle < min_angle) { + select_index = i; + min_angle = abs_angle; + } + } + } + } + + if (select_index >= 0 && select_index < 8) { + *pos_p = unit_pos[select_index]; + return unit_item[select_index]; + } + } + + *pos_p = *player_pos_p; + return EMPTY_NO; +} + +static mActor_name_t Player_actor_check_fg_little_shake_tree(ACTOR* actorx, int* ut_x_p, int* ut_z_p, xyz_t* pos_p) { + mActor_name_t item = Player_actor_Get_shake_tree_position_and_itemNo(actorx, pos_p); + + if (item != EMPTY_NO && mFI_Wpos2UtNum(ut_x_p, ut_z_p, *pos_p)) { + return item; + } + + *ut_x_p = -1; + *ut_z_p = -1; + return EMPTY_NO; +} + +static int Player_actor_Check_able_shake_tree_table(ACTOR* actorx, int tree_ut_x, int tree_ut_z, int little_flag, + f32 time) { + if (tree_ut_x < 0 || tree_ut_z < 0) { + return FALSE; + } else { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + f32* shake_timer_p = player->shake_tree_timer; + int* shake_ut_x_p = player->shake_tree_ut_x; + int* shake_ut_z_p = player->shake_tree_ut_z; + int i; + + for (i = 0; i < 3; i++) { + if (tree_ut_x == *shake_ut_x_p && tree_ut_z == *shake_ut_z_p) { + if (little_flag != FALSE) { + return FALSE; + } + + if (*shake_timer_p > time) { + return FALSE; + } + } + + shake_timer_p++; + shake_ut_x_p++; + shake_ut_z_p++; + } + } + + return TRUE; +} + +static int Player_actor_Set_shake_tree_table(ACTOR* actorx, GAME* game, mActor_name_t item, int tree_ut_x, + int tree_ut_z, int little_flag) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (Player_actor_Check_able_shake_tree_table(actorx, tree_ut_x, tree_ut_z, little_flag, 0.0f) == FALSE) { + return FALSE; + } else { + f32* shake_timer_p = player->shake_tree_timer; + int* shake_ut_x_p = player->shake_tree_ut_x; + int* shake_ut_z_p = player->shake_tree_ut_z; + int* shake_tree_little_p = player->shake_tree_little; + int i; + + if (little_flag == FALSE) { + for (i = 0; i < 3; i++) { +/* @BUG - *shake_ut_z_p is missing an = sign */ +#ifndef BUGFIXES + if ((*shake_ut_x_p == tree_ut_x) && (*shake_ut_z_p = tree_ut_z)) { +#else + if ((*shake_ut_x_p == tree_ut_x) && (*shake_ut_z_p == tree_ut_z)) { +#endif + Player_actor_Set_EffectBgTree(game, item, EffectBG_EFFECT_SHAKE_LARGE, tree_ut_x, tree_ut_z); + *shake_timer_p = 84.0f; + *shake_tree_little_p = FALSE; + return TRUE; + } + + shake_timer_p++; + shake_ut_x_p++; + shake_ut_z_p++; + shake_tree_little_p++; + } + + shake_timer_p = player->shake_tree_timer; + shake_ut_x_p = player->shake_tree_ut_x; + shake_ut_z_p = player->shake_tree_ut_z; + shake_tree_little_p = player->shake_tree_little; + } + + { + s16 bg_ef_type; + int i; + + for (i = 0; i < 3; i++) { + if (*shake_ut_x_p < 0 || *shake_ut_z_p < 0) { + bg_ef_type = little_flag ? EffectBG_EFFECT_SHAKE_SMALL : EffectBG_EFFECT_SHAKE_LARGE; + *shake_ut_x_p = tree_ut_x; + *shake_ut_z_p = tree_ut_z; + + if (little_flag) { + *shake_timer_p = 16.0f; + } else { + *shake_timer_p = 84.0f; + } + + *shake_tree_little_p = little_flag; + Player_actor_Set_EffectBgTree(game, item, bg_ef_type, tree_ut_x, tree_ut_z); + return TRUE; + } + + shake_timer_p++; + shake_ut_x_p++; + shake_ut_z_p++; + shake_tree_little_p++; + } + } + } + + return FALSE; +} + +static void Player_actor_check_little_shake_tree(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_index = player->now_main_index; + int tree_ut_x = -1; + int tree_ut_z = -1; + + switch (main_index) { + default: { + xyz_t pos; + mActor_name_t item; + + item = Player_actor_check_fg_little_shake_tree(actorx, &tree_ut_x, &tree_ut_z, &pos); + if (item != EMPTY_NO && Player_actor_Set_shake_tree_table(actorx, game, item, tree_ut_x, tree_ut_z, TRUE)) { + if (IS_ITEM_SHAKEABLE_TREE(item) != FALSE) { + Player_actor_sound_tree_touch(&pos); + } + } + break; + } + case mPlayer_INDEX_SHAKE_TREE: + tree_ut_x = player->main_data.shake_tree.tree_ut_x; + tree_ut_z = player->main_data.shake_tree.tree_ut_z; + break; + } + + { + f32* shake_timer_p = player->shake_tree_timer; + int* shake_ut_x_p = player->shake_tree_ut_x; + int* shake_ut_z_p = player->shake_tree_ut_z; + int shake_ut_x; + int shake_ut_z; + int i; + + for (i = 0; i < 3; i++) { + if (*shake_timer_p <= 0.0f) { + shake_ut_x = *shake_ut_x_p; + shake_ut_z = *shake_ut_z_p; + + if ((shake_ut_x >= 0 || shake_ut_z >= 0) && (shake_ut_x != tree_ut_x || shake_ut_z != tree_ut_z)) { + *shake_ut_x_p = -1; + *shake_ut_z_p = -1; + } + } + + shake_timer_p++; + shake_ut_x_p++; + shake_ut_z_p++; + } + } +} + +static void Player_actor_check_shake_tree_timer(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + f32* shake_timer_p = player->shake_tree_timer; + int i; + + for (i = 0; i < 3; i++) { + if (*shake_timer_p > 0.0f) { + *shake_timer_p -= 1.0f; + if (*shake_timer_p < 0.0f) { + *shake_timer_p = 0.0f; + } + } + + shake_timer_p++; + } +} + +static int Player_actor_CheckAndRequest_main_shake_tree_all(GAME* game) { + if (Player_actor_CheckController_forShake_tree(game)) { + ACTOR* actorx = GET_PLAYER_ACTOR_GAME_ACTOR(game); + xyz_t pos; + mActor_name_t item; + + item = Player_actor_Get_shake_tree_position_and_itemNo(actorx, &pos); + if (item != EMPTY_NO) { + int tree_ut_x; + int tree_ut_z; + + if (mFI_Wpos2UtNum(&tree_ut_x, &tree_ut_z, pos) && + Player_actor_Check_able_shake_tree_table(actorx, tree_ut_x, tree_ut_z, FALSE, 16.0f)) { + return Player_actor_request_main_shake_tree_all(game, &pos, item, tree_ut_x, tree_ut_z, + mPlayer_REQUEST_PRIORITY_5); + } + } + } + + return FALSE; +} + +static int Player_actor_Get_tree_shaken_table_index(ACTOR* actorx, const xyz_t* pos_p) { + int tree_ut_x; + int tree_ut_z; + + if (mFI_Wpos2UtNum(&tree_ut_x, &tree_ut_z, *pos_p)) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + f32* shake_timer_p = player->shake_tree_timer; + int* shake_ut_x_p = player->shake_tree_ut_x; + int* shake_ut_z_p = player->shake_tree_ut_z; + int i; + + for (i = 0; i < 3; i++) { + if (*shake_timer_p > 0.0f && *shake_ut_x_p == tree_ut_x && *shake_ut_z_p == tree_ut_z) { + return i; + } + + shake_timer_p++; + shake_ut_x_p++; + shake_ut_z_p++; + } + } + + return -1; +} + +static int Player_actor_Check_tree_shaken_little(ACTOR* actorx, const xyz_t* pos_p) { + int idx = Player_actor_Get_tree_shaken_table_index(actorx, pos_p); + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (idx >= 0 && idx < 3 && player->shake_tree_little[idx] != FALSE) { + return TRUE; + } else { + xyz_t scoop_pos; + + if (Player_actor_Check_HitScoop(actorx, &scoop_pos)) { + xyz_t ut_center_pos; + + if (mFI_Wpos2UtCenterWpos(&ut_center_pos, *pos_p)) { + if (scoop_pos.x == ut_center_pos.x && scoop_pos.z == ut_center_pos.z) { + return TRUE; + } + } + } + } + + return FALSE; +} + +static int Player_actor_Check_tree_shaken_big(ACTOR* actorx, const xyz_t* pos_p) { + int idx = Player_actor_Get_tree_shaken_table_index(actorx, pos_p); + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (idx >= 0 && idx < 3 && player->shake_tree_little[idx] == FALSE) { + return TRUE; + } else { + xyz_t axe_pos; + + if (Player_actor_Check_HitAxe(actorx, &axe_pos)) { + xyz_t ut_center_pos; + + if (mFI_Wpos2UtCenterWpos(&ut_center_pos, *pos_p)) { + if (axe_pos.x == ut_center_pos.x && axe_pos.z == ut_center_pos.z) { + return TRUE; + } + } + } + } + + return FALSE; +} + +static int Player_actor_Check_tree_shaken(ACTOR* actorx, const xyz_t* pos_p) { + if (Player_actor_Check_tree_shaken_little(actorx, pos_p) || Player_actor_Check_tree_shaken_big(actorx, pos_p)) { + return TRUE; + } + + return FALSE; +} + +static void Player_actor_reset_pitfall(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->pitfall_flag) { + if (Common_Get(clip).bg_item_clip != NULL && Common_Get(clip).bg_item_clip->pit_fall_stop_proc != NULL) { + xyz_t* pitfall_pos_p = &player->pitfall_pos; + mActor_name_t* fg_p = mFI_GetUnitFG(*pitfall_pos_p); + + if (fg_p != NULL) { + mActor_name_t item = *fg_p; + + if (ITEM_IS_BURIED_PITFALL_HOLE_RSV(item)) { + int ut_x; + int ut_z; + + if (mFI_Wpos2UtNum(&ut_x, &ut_z, *pitfall_pos_p)) { + Common_Get(clip).bg_item_clip->pit_fall_stop_proc(item, ut_x, ut_z, EMPTY_NO); + } + } + } + } + + player->pitfall_flag = FALSE; + } +} + +static void Player_actor_check_pitfall(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + Player_actor_reset_pitfall(actorx); + if (Common_Get(clip).bg_item_clip != NULL && Common_Get(clip).bg_item_clip->pit_fall_proc != NULL) { + int main_index = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + if (data[main_index] != FALSE) { + xyz_t* player_pos_p = &actorx->world.position; + xyz_t pitfall_check_pos; + + if (mFI_Wpos2UtCenterWpos(&pitfall_check_pos, *player_pos_p)) { + f32 dist = Math3DLengthSquare2D(pitfall_check_pos.x, pitfall_check_pos.y, player_pos_p->x, + player_pos_p->y); + + if (dist <= SQ(19.0f)) { + mActor_name_t* fg_p = mFI_GetUnitFG(pitfall_check_pos); + + if (fg_p != NULL) { + mActor_name_t item = *fg_p; + + if (ITEM_IS_BURIED_PITFALL_HOLE(item)) { + pitfall_check_pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(pitfall_check_pos, 0.0f); + if (Player_actor_request_main_ready_pitfall_all(game, &pitfall_check_pos, + mPlayer_REQUEST_PRIORITY_26)) { + int ut_x; + int ut_z; + + if (mFI_Wpos2UtNum(&ut_x, &ut_z, pitfall_check_pos)) { + Common_Get(clip).bg_item_clip->pit_fall_proc(item, ut_x, ut_z, EMPTY_NO); + player->pitfall_pos = pitfall_check_pos; + player->pitfall_flag = TRUE; + } + } + } + } + } + } + } + } + } +} + +static int Player_actor_Check_end_stung_bee(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->now_main_index == mPlayer_INDEX_STUNG_BEE) { + if (player->main_data.stung_bee.timer <= 162.0f) { + return FALSE; + } + } + + return TRUE; +} + +static int Player_actor_Check_BirthBee_common(ACTOR* actorx, mActor_name_t item, int tree_ut_x, int tree_ut_z, + s16* angle_y_p) { + if (Common_Get(clip).bg_item_clip != NULL && Common_Get(clip).bg_item_clip->item_tree_fruit_drop_proc != NULL) { + if (tree_ut_x >= 0 && tree_ut_z >= 0) { + if (IS_ITEM_BEE_TREE(item)) { + xyz_t item_drop_pos; + + Common_Get(clip).bg_item_clip->item_tree_fruit_drop_proc(item, tree_ut_x, tree_ut_z, &item_drop_pos); + if (item_drop_pos.x >= 0.0f && item_drop_pos.z >= 0.0f) { + if (angle_y_p != NULL) { + f32 dx = item_drop_pos.x - actorx->world.position.x; + f32 dz = item_drop_pos.z - actorx->world.position.z; + + if (dx != 0.0f || dz != 0.0f) { + *angle_y_p = atans_table(dz, dx); + } else { + *angle_y_p = actorx->shape_info.rotation.y; + } + } + + return TRUE; + } + } + } + } + + return FALSE; +} + +static void Player_actor_set_ripple(ACTOR* actorx, GAME* game) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (eEC_CLIP != NULL) { + f32* ripple_timer_p = &player->ripple_timer; + + *ripple_timer_p += 1.0f; + if (*ripple_timer_p >= 8.0f) { + s16 attr = actorx->bg_collision_check.result.unit_attribute; + + if (player->ripple_foot_idx != 0) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_WAIT_ASIMOTO, player->right_foot_pos, 2, + player->right_foot_angle.y, game, RSV_NO, attr, 0); + player->ripple_foot_idx = 0; + } else { + eEC_CLIP->effect_make_proc(eEC_EFFECT_WAIT_ASIMOTO, player->left_foot_pos, 2, player->left_foot_angle.y, + game, RSV_NO, attr, 0); + player->ripple_foot_idx = 1; + } + + *ripple_timer_p = 0.0f; + } + } +} + +static int Player_actor_Check_NecessaryDoorKnock(ACTOR* actorx) { + mActor_name_t item = actorx->npc_id; + + if (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_STRUCT) { + if (ITEM_IS_PLAYER_HOUSE(item)) { + + if (mEv_CheckFirstIntro()) { + return TRUE; + } else { + int arrange_idx = item - HOUSE0; + + if (mLd_PlayerManKindCheck() == FALSE) { + if (arrange_idx != mHS_get_arrange_idx(Common_Get(player_no))) { + return TRUE; + } + } else { + return TRUE; + } + } + } else if (ITEM_IS_NPC_HOUSE(item) || ITEM_IS_ISLAND_NPC_HOUSE(item)) { + return TRUE; + } + } + + return FALSE; +} + +static int Player_actor_CheckAndRequest_KnockDoor(ACTOR* actorx, GAME* game, int main_index) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (main_index == mPlayer_INDEX_DOOR) { + mPlayer_request_door_c* req_door_data_p = &player->requested_main_index_data.door; + ACTOR* door_actor = (ACTOR*)req_door_data_p->label; + + if (door_actor != NULL && Player_actor_Check_NecessaryDoorKnock(door_actor)) { + if (Player_actor_request_main_knock_door(game, &req_door_data_p->player_pos, req_door_data_p->angle_y, + mPlayer_REQUEST_PRIORITY_38)) { + return mPlayer_INDEX_KNOCK_DOOR; + } + } + } + + return main_index; +} + +static int Player_actor_CheckAndRequest_ItemInOut(ACTOR* actorx, GAME* game, int main_index) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + s8 able_hand_all_item_in_demo = player->able_hand_all_item_in_demo; + s8 item_kind = Player_actor_Get_ItemKind_fromScene(); + + if (item_kind >= 0 && able_hand_all_item_in_demo == FALSE) { + int request_main_index = player->requested_main_index; + int now_main_index = player->now_main_index; + int request_able_out_item = Player_actor_CheckPlayer_AbleOutItem(request_main_index); + int main_able_out_item = Player_actor_CheckPlayer_AbleOutItem(now_main_index); + + if (request_able_out_item == mPlayer_ABLE_ITEM_NONE || main_able_out_item == mPlayer_ABLE_ITEM_NONE) { + return main_index; + } + + if (mPlayer_ITEM_IS_NOT_TOOL(item_kind) == FALSE) { + if ((request_able_out_item == mPlayer_ABLE_ITEM_RESTRICTED || + request_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA) && + main_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_ALL) { + if (Player_actor_request_main_putin_item(game, mPlayer_REQUEST_PRIORITY_37)) { + return mPlayer_INDEX_PUTIN_ITEM; + } + } else if ((request_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_ALL) && + (main_able_out_item == mPlayer_ABLE_ITEM_RESTRICTED || + main_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA)) { + if (Player_actor_request_main_takeout_item(game, mPlayer_REQUEST_PRIORITY_37)) { + return mPlayer_INDEX_TAKEOUT_ITEM; + } + } + } else { + if (mPlayer_ITEM_IS_NOT_TOOL(item_kind) != FALSE) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); // we already have the player???? + int umbrella_flag = FALSE; + + if (request_main_index == mPlayer_INDEX_TALK) { + umbrella_flag = player->requested_main_index_data.talk.umbrella_flag; + } else if (request_main_index == mPlayer_INDEX_DEMO_WAIT) { + umbrella_flag = player->requested_main_index_data.demo_wait.umbrella_flag; + } + + if (umbrella_flag != FALSE && Player_actor_request_main_putin_item(game, mPlayer_REQUEST_PRIORITY_37)) { + return mPlayer_INDEX_PUTIN_ITEM; + } + } + + { + int in_demo_mode = Player_actor_Check_is_demo_mode(now_main_index); + int will_be_in_demo_mode = Player_actor_Check_is_demo_mode(request_main_index); + s8 unable_hand_item_in_demo = player->unable_hand_item_in_demo; + + if (in_demo_mode && !will_be_in_demo_mode && unable_hand_item_in_demo && + Player_actor_request_main_takeout_item(game, mPlayer_REQUEST_PRIORITY_37)) { + return mPlayer_INDEX_TAKEOUT_ITEM; + } else if (request_able_out_item == mPlayer_ABLE_ITEM_RESTRICTED && + (main_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_ALL || + main_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA)) { + if (Player_actor_request_main_putin_item(game, mPlayer_REQUEST_PRIORITY_37)) { + return mPlayer_INDEX_PUTIN_ITEM; + } + } else if ((request_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_ALL || + request_able_out_item == mPlayer_ABLE_ITEM_CAN_USE_UMBRELLA) && + main_able_out_item == mPlayer_ABLE_ITEM_RESTRICTED) { + if (Player_actor_request_main_takeout_item(game, mPlayer_REQUEST_PRIORITY_37)) { + return mPlayer_INDEX_TAKEOUT_ITEM; + } + } + } + } + } + + return main_index; +} + +static void Player_actor_Set_bgm_volume(ACTOR* actorx, int main_index) { + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE && mEv_CheckTitleDemo() <= 0) { + // clang-format off + static const s8 data[] = { + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS, + mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS, + mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS, + mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS, + mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS, + mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_FISHING, + mPlayer_BGM_VOLUME_MODE_FISHING, + mPlayer_BGM_VOLUME_MODE_FISHING, + mPlayer_BGM_VOLUME_MODE_FISHING, + mPlayer_BGM_VOLUME_MODE_FISHING, + mPlayer_BGM_VOLUME_MODE_FISHING, + mPlayer_BGM_VOLUME_MODE_FISHING, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + mPlayer_BGM_VOLUME_MODE_NORMAL, + }; + // clang-format on + + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + s8 last_bgm_volume_mode = player->bgm_volume_mode; + s8 next_bgm_volume_mode = data[main_index]; + + if (last_bgm_volume_mode != next_bgm_volume_mode) { + if (next_bgm_volume_mode == mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS) { + mBGMPsComp_volume_collect_insects_start(); + } else if (next_bgm_volume_mode == mPlayer_BGM_VOLUME_MODE_FISHING) { + mBGMPsComp_volume_fishing_start(); + } + + if (last_bgm_volume_mode == mPlayer_BGM_VOLUME_MODE_COLLECT_INSECTS) { + mBGMPsComp_volume_collect_insects_end(); + } else if (last_bgm_volume_mode == mPlayer_BGM_VOLUME_MODE_FISHING) { + mBGMPsComp_volume_fishing_end(); + } + + player->bgm_volume_mode = next_bgm_volume_mode; + } + } +} + +static int Player_actor_Check_Label_main_push_snowball(GAME* game, u32 label) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + if (player->now_main_index == mPlayer_INDEX_PUSH_SNOWBALL && player->main_data.push_snowball.label == label) { + return TRUE; + } + + return FALSE; +} + +static int Player_actor_Check_Label_main_wade_snowball(GAME* game, u32 label) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + if (player->now_main_index == mPlayer_INDEX_WADE_SNOWBALL && + player->main_data.wade_snowball.snowball_label == label) { + return TRUE; + } + + return FALSE; +} + +static int Player_actor_SetParam_for_push_snowball(GAME* game, const xyz_t* pos_p, s16 angle_y, f32 anim_speed) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + + if (player->now_main_index == mPlayer_INDEX_PUSH_SNOWBALL) { + ACTOR* actorx = GET_PLAYER_ACTOR_GAME_ACTOR(gamePT); + + actorx->world.position = *pos_p; + actorx->shape_info.rotation.y = angle_y; + actorx->world.angle.y = angle_y; + player->keyframe0.frame_control.speed = anim_speed; + player->keyframe1.frame_control.speed = anim_speed; + return TRUE; + } + + return FALSE; +} + +static int Player_actor_GetSnowballPos_forWadeSnowball(ACTOR* actorx, xyz_t* pos_p) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->now_main_index == mPlayer_INDEX_WADE_SNOWBALL) { + xyz_t* snowball_dist_p = &player->main_data.wade_snowball.snowball_dist; + + pos_p->x = actorx->world.position.x + snowball_dist_p->x; + pos_p->y = actorx->world.position.y + snowball_dist_p->y; + pos_p->z = actorx->world.position.z + snowball_dist_p->z; + } + + return FALSE; +} + +static int Player_actor_CheckCondition_forWadeSnowball(GAME* game, const xyz_t* pos_p, s16 angle_y) { + return Player_actor_CheckAbleMoveWadeBlock(game, pos_p, angle_y, 0.65f, DEG2SHORT_ANGLE2(5.0f), + mEv_CheckTitleDemo() <= 0); +} + +static void Player_actor_Culc_player_frame_counter(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->player_frame_counter++; +} + +static void Player_actor_Reset_excute_cancel_wade(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->excute_cancel_wade) { + if (mPlib_Get_unable_wade()) { + int dFrame = player->player_frame_counter - player->cancel_wade_timer; + + if (dFrame < 0) { + dFrame = 0xFFFF - dFrame; + } + + if (dFrame > 0) { + player->excute_cancel_wade = FALSE; + } + } else { + player->excute_cancel_wade = FALSE; + } + } +} + +static void Player_actor_Culc_wade_end_pos(const xyz_t* src_pos_p, xyz_t* wade_end_pos_p, int direction, + f32 border_adjust) { + int bx; + int bz; + + *wade_end_pos_p = *src_pos_p; + if (mFI_Wpos2BlockNum(&bx, &bz, *src_pos_p)) { + xyz_t wpos; + xyz_t lpos = { 0.0f, 0.0f, 0.0f }; + + mFI_LposInBKtoWpos(&wpos, lpos, bx, bz); + switch (direction) { + case mFI_MOVEDIR_RIGHT: + case mFI_MOVEDIR_LEFT: { + f32 z_up = (wpos.z + border_adjust); + f32 z_down = (wpos.z - border_adjust) + mFI_BK_WORLDSIZE_Z_F; + + if (wade_end_pos_p->z < z_up) { + wade_end_pos_p->z = z_up; + } else if (wade_end_pos_p->z > z_down) { + wade_end_pos_p->z = z_down; + } + break; + } + + case mFI_MOVEDIR_UP: + default: { + f32 x_left = (wpos.x + border_adjust); + f32 x_right = (wpos.x - border_adjust) + mFI_BK_WORLDSIZE_X_F; + + if (wade_end_pos_p->x < x_left) { + wade_end_pos_p->x = x_left; + } else if (wade_end_pos_p->x > x_right) { + wade_end_pos_p->x = x_right; + } + break; + } + } + + switch (direction) { + case mFI_MOVEDIR_RIGHT: + wade_end_pos_p->x = (wpos.x + border_adjust) + mFI_BK_WORLDSIZE_X_F; + break; + case mFI_MOVEDIR_LEFT: + wade_end_pos_p->x = (wpos.x - border_adjust); + break; + case mFI_MOVEDIR_UP: + wade_end_pos_p->z = (wpos.z - border_adjust); + break; + default: + wade_end_pos_p->z = (wpos.z + border_adjust) + mFI_BK_WORLDSIZE_Z_F; + break; + } + } +} + +static void Player_actor_Get_PickupHandPosition(ACTOR* actorx, xyz_t* pos_p, f32 dist) { + s16 angle_y = actorx->shape_info.rotation.y; + f32 x = dist * sin_s(angle_y); + f32 z = dist * cos_s(angle_y); + + *pos_p = actorx->world.position; + pos_p->x += x; + pos_p->z += z; +} + +static void Player_actor_Get_ItemDisplayPos(xyz_t* item_pos_p, xyz_t* center_pos_p) { + if (Common_Get(clip).bg_item_clip != NULL && Common_Get(clip).bg_item_clip->rand_pos_get_proc != NULL) { + const xyz_t pos = *center_pos_p; + + Common_Get(clip).bg_item_clip->rand_pos_get_proc(item_pos_p, &pos); + } else { + *item_pos_p = *center_pos_p; + } +} + +static int Player_actor_CheckItemPosition_forPickup(const xyz_t* pos_p, f32 max_dist_sq, f32 max_dist_y, + xyz_t* target_pos_p, xyz_t* item_pos_p) { + mFI_Wpos2UtCenterWpos(target_pos_p, *pos_p); + if (Common_Get(field_type) != mFI_FIELDTYPE2_FG) { + target_pos_p->y = mCoBG_GetBgY_OnlyCenter_FromWpos2(*target_pos_p, 0.0f); + } else { + target_pos_p->y = mCoBG_GetBgY_OnlyCenter_FromWpos2(*target_pos_p, -1.0f); + } + + Player_actor_Get_ItemDisplayPos(item_pos_p, target_pos_p); + + target_pos_p->y = mCoBG_GetBgY_OnlyCenter_FromWpos2(*target_pos_p, 0.0f); + if (Math3DLengthSquare2D(item_pos_p->x, item_pos_p->z, pos_p->x, pos_p->z) <= max_dist_sq) { + f32 dy = target_pos_p->y - pos_p->y; + + if (ABS(dy) <= max_dist_y) { + return TRUE; + } + } + + return FALSE; +} + +static mActor_name_t* Player_actor_CheckItem_fromPosition(const xyz_t* pos_p, f32 max_dist_sq, f32 max_dist_y, + xyz_t* target_pos_p, xyz_t* item_pos_p) { + if (mFI_Wpos2DepositGet(*pos_p) == FALSE) { + mActor_name_t* fg_p = mFI_GetUnitFG(*pos_p); + + if (fg_p != NULL) { + if (IS_ITEM_GRASS(*fg_p) != FALSE) { + if (Player_actor_CheckItemPosition_forPickup(pos_p, max_dist_sq, max_dist_y, target_pos_p, + item_pos_p)) { + return fg_p; + } + } else { + int field_type = Common_Get(field_type); + + switch (ITEM_NAME_GET_TYPE(*fg_p)) { + case NAME_TYPE_FTR0: + case NAME_TYPE_FTR1: + if (field_type != mFI_FIELDTYPE2_FG) { + break; + } + /* Fallthrough */ + case NAME_TYPE_ITEM1: + if (Player_actor_CheckItemPosition_forPickup(pos_p, max_dist_sq, max_dist_y, target_pos_p, + item_pos_p)) { + return fg_p; + } + break; + default: + if (ITEM_IS_SIGNBOARD(*fg_p) != FALSE) { + if (Player_actor_CheckItemPosition_forPickup(pos_p, max_dist_sq, max_dist_y, target_pos_p, + item_pos_p)) { + return fg_p; + } + } + break; + } + } + } + } + + return NULL; +} + +static mActor_name_t* Player_actor_Search_putin_item(ACTOR* actorx, xyz_t* target_pos_p, xyz_t* item_pos_p) { + xyz_t pos; + mActor_name_t* fg_p; + + /* Check for signboards first */ + Player_actor_Get_PickupHandPosition(actorx, &pos, 35.0f); + fg_p = Player_actor_CheckItem_fromPosition(&pos, SQ(15.0f), 15.0f, target_pos_p, item_pos_p); + if (fg_p != NULL && ITEM_IS_SIGNBOARD(*fg_p) != FALSE) { + return fg_p; + } + + /* Now look for regular items */ + Player_actor_Get_PickupHandPosition(actorx, &pos, 20.0f); + fg_p = Player_actor_CheckItem_fromPosition(&pos, SQ(15.0f), 15.0f, target_pos_p, item_pos_p); + if (fg_p != NULL) { + return fg_p; + } + + /* Search even closer */ + Player_actor_Get_PickupHandPosition(actorx, &pos, 10.0f); + fg_p = Player_actor_CheckItem_fromPosition(&pos, SQ(15.0f), 15.0f, target_pos_p, item_pos_p); + return fg_p; +} + +static int Player_actor_check_putin_item(ACTOR* actorx, mActor_name_t* item_p, xyz_t* target_pos_p, xyz_t* item_pos_p) { + mActor_name_t* fg_p = Player_actor_Search_putin_item(actorx, target_pos_p, item_pos_p); + + if (fg_p != NULL) { + *item_p = *fg_p; + return TRUE; + } else { + *item_p = EMPTY_NO; + return FALSE; + } +} + +static mActor_name_t Player_actor_Get_itemNo_forWindow(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int main_index = player->now_main_index; + + if (main_index == mPlayer_INDEX_WAIT) { + mActor_name_t itemNo = EMPTY_NO; + xyz_t item_pos; + xyz_t target_pos; + + if (Player_actor_check_putin_item(actorx, &itemNo, &target_pos, &item_pos)) { + if (IS_ITEM_GRASS(itemNo) == FALSE) { + return itemNo; + } + } + } + + return EMPTY_NO; +} + +static int Player_actor_able_submenu_request_main_index(GAME* game) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + int res; + + if (player->requested_main_index_changed) { + int request_main_index = player->requested_main_index; + + if (mPlayer_MAIN_INDEX_VALID(request_main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + request_main_index = data[request_main_index]; + return request_main_index; + } + } else { + return TRUE; + } + + return FALSE; +} + +static void Player_actor_Request_main_refuse_pickup_all(GAME* game, int refuse_pickup_knife_fork) { + ACTOR* actorx = GET_PLAYER_ACTOR_GAME_ACTOR(game); + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->refuse_pickup_knife_fork_flag = refuse_pickup_knife_fork; + mDemo_Request(mDemo_TYPE_REPORT, actorx, &Player_actor_Refuse_pickup_demo_ct); +} + +static int Player_actor_CheckAndRequest_main_pickup_all(GAME* game) { + int field_type = Common_Get(field_type); + + if ((field_type == mFI_FIELDTYPE2_FG || field_type == mFI_FIELDTYPE2_PLAYER_ROOM) && + Player_actor_CheckController_forPickup(game) && + Player_actor_check_request_main_priority(game, mPlayer_REQUEST_PRIORITY_8) > 0 && + Player_actor_check_cancel_request_change_proc_index(mPlayer_INDEX_PICKUP) == FALSE) { + int can_exchange = field_type == mFI_FIELDTYPE2_FG; + + if (mEv_CheckTitleDemo() <= 0) { + /* Check for picking up items in your house */ + if (Common_Get(clip).my_room_clip != NULL) { + mActor_name_t item = Common_Get(clip).my_room_clip->search_pickup_ftr_proc(game); + int item_slot = mPlib_Get_space_putin_item_forTICKET(&item); + + if (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1) { + xyz_t item_pos; + + Common_Get(clip).my_room_clip->leaf_start_pos_proc(&item_pos); + if (item_slot >= 0 || ITEM_IS_MYMANNIQUIN(item) || ITEM_IS_MYUMBRELLA(item) || can_exchange) { + if (Player_actor_request_main_pickup_jump(game, item_slot, item, &item_pos, FALSE, FALSE)) { + return TRUE; + } + } else { + Player_actor_Request_main_refuse_pickup_all(game, FALSE); + } + } else if (item != EMPTY_NO) { + xyz_t ftr_pos; + + Common_Get(clip).my_room_clip->leaf_start_pos_proc(&ftr_pos); + if (Common_Get(clip).my_room_clip->pickup_ftr_layer_proc() == mCoBG_LAYER1) { + if (item_slot >= 0 || ITEM_IS_MYMANNIQUIN(item) || ITEM_IS_MYUMBRELLA(item) || can_exchange) { + if (Player_actor_request_main_pickup_jump( + game, item_slot, mRmTp_FtrItemNo2Item1ItemNo(item, TRUE), &ftr_pos, TRUE, FALSE)) { + return TRUE; + } + } else { + Player_actor_Request_main_refuse_pickup_all(game, FALSE); + } + } else { + if (item_slot >= 0 || ITEM_IS_MYMANNIQUIN(item) || ITEM_IS_MYUMBRELLA(item) || can_exchange) { + if (Player_actor_request_main_pickup_furniture( + game, item_slot, mRmTp_FtrItemNo2Item1ItemNo(item, TRUE), &ftr_pos)) { + return TRUE; + } + } else { + Player_actor_Request_main_refuse_pickup_all(game, FALSE); + } + } + } + } + + /* Check for knife & fork */ + if (Common_Get(clip).htbl_clip != NULL) { + mActor_name_t htbl_item = Common_Get(clip).htbl_clip->search_pick_up_item_layer2_proc(game); + + if (htbl_item == ITM_KNIFE_AND_FORK) { + int item_slot = mPr_GetPossessionItemIdxWithCond(Now_Private, EMPTY_NO, mPr_ITEM_COND_NORMAL); + + if (item_slot >= 0) { + xyz_t pickup_pos = Common_Get(clip).htbl_clip->pickup_pos; + + if (Player_actor_request_main_pickup_jump(game, item_slot, htbl_item, &pickup_pos, FALSE, + TRUE)) { + return TRUE; + } + } else { + Player_actor_Request_main_refuse_pickup_all(game, TRUE); + } + } + } + } + + /* Check for outdoor items */ + { + ACTOR* actorx = GET_PLAYER_ACTOR_GAME_ACTOR(game); + mActor_name_t item; + xyz_t item_pos; + xyz_t target_pos; + + if (Player_actor_check_putin_item(actorx, &item, &target_pos, &item_pos)) { + int slot_idx = mPlib_Get_space_putin_item_forTICKET(&item); + + if (IS_ITEM_GRASS(item) != FALSE) { + if (Player_actor_request_main_remove_grass(game, &target_pos, &item_pos)) { + return TRUE; + } + } else { + mActor_name_t changed_item = ITEM_IS_SIGNBOARD(item) ? ITM_SIGNBOARD : item; + int item_is_signboard = item != changed_item; + + if (mEv_CheckTitleDemo() > 0) { + if (Player_actor_request_main_pickup(game, changed_item, &target_pos, &item_pos, -1, + item_is_signboard)) { + return TRUE; + } + } else { + if (slot_idx >= 0 || can_exchange) { + if (Player_actor_request_main_pickup(game, changed_item, &target_pos, &item_pos, slot_idx, + item_is_signboard)) { + return TRUE; + } + } else { + Player_actor_Request_main_refuse_pickup_all(game, FALSE); + } + } + } + } + } + } + + return FALSE; +} + +static int Player_actor_CheckScene_AbleSubmenu(void) { + int scene_no = Save_Get(scene_no); + + if (!(scene_no >= 0 && scene_no < SCENE_NUM)) { + return FALSE; + } else { + // clang-format off + static const s8 data[] = { + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + }; + // clang-format on + + return data[scene_no]; + } +} + +/* Why does this function even exist? It returns FALSE for every player state. */ +static int Player_actor_check_cancel_event_without_priority(GAME* game) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + int main_index = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + return data[main_index]; + } + + return FALSE; +} + +static int Player_actor_Check_able_force_speak_label(GAME* game, u32 label) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + u32 able_force_speak_label = player->able_force_speak_label; + + if (able_force_speak_label == 0) { + return TRUE; + } + + if (able_force_speak_label == label) { + return TRUE; + } + + return FALSE; +} + +static void Player_actor_Reset_able_force_speak_label(ACTOR* actorx, int main_index) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (Player_actor_Check_is_demo_mode(main_index) == FALSE) { + player->able_force_speak_label = 0; + } +} + +static int Player_actor_CheckAndSet_UZAI_forNpc(ACTOR* actorx) { + if (actorx != NULL && actorx->part == ACTOR_PART_NPC) { + NPC_ACTOR* npc_actor = (NPC_ACTOR*)actorx; + Animal_c* animal = npc_actor->npc_info.animal; + + if (animal != NULL && + mNpc_GetAnimalMemoryIdx(&Now_Private->player_ID, animal->memories, ANIMAL_MEMORY_NUM) != -1) { + if (ITEM_NAME_GET_TYPE(actorx->npc_id) == NAME_TYPE_NPC && + (npc_actor->condition_info.demo_flg & aNPC_COND_DEMO_SKIP_UZAI_CHECK) == 0) { + npc_actor->uzai.counter++; + npc_actor->uzai.flag = TRUE; + } + } + + return TRUE; + } + + return FALSE; +} + +static int Player_actor_Check_stung_mosquito(GAME* game, u32 label) { + int main_index = GET_PLAYER_ACTOR_GAME(game)->now_main_index; + + switch (main_index) { + case mPlayer_INDEX_STUNG_MOSQUITO: { + u32 stung_label = GET_PLAYER_ACTOR_GAME(game)->requested_main_index_data.stung_mosquito.label; + + if (stung_label == label) { + return TRUE; + } + break; + } + case mPlayer_INDEX_NOTICE_MOSQUITO: { + u32 notice_label = GET_PLAYER_ACTOR_GAME(game)->requested_main_index_data.notice_mosquito.label; + + if (notice_label == label) { + return TRUE; + } + break; + } + } + + return FALSE; +} + +static void Player_actor_Reset_bee_chase(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + Common_Set(player_bee_chase_flag, FALSE); + if (player->bee_chase_bgm_flag) { + player->bee_chase_bgm_flag = FALSE; + mBGMPsComp_delete_ps_happening(BGM_BEE_CHASE, 0); + } +} + +static void Player_actor_Check_player_sunburn_ChangeDay(ACTOR* actorx) { + if (mEv_CheckTitleDemo() <= 0) { + mActor_name_t field_id = mFI_GetFieldId(); + + if (mFI_GET_TYPE(field_id) == mFI_FIELD_FG) { + mPr_sunburn_c* sunburn = &Now_Private->sunburn; + + if (sunburn->rank > 0) { + lbRTC_ymd_c now_ymd; + int days; + + mTM_set_renew_time(&now_ymd, Common_GetPointer(time.rtc_time)); + days = lbRTC_GetIntervalDays2(&sunburn->last_changed_date, &now_ymd); + if (days < 0) { + sunburn->last_changed_date = now_ymd; + } + } + } + } +} + +static void Player_actor_Check_player_sunburn_rankdown_interval(ACTOR* actorx) { + if (mEv_CheckTitleDemo() <= 0) { + mActor_name_t field_id = mFI_GetFieldId(); + + if (mFI_GET_TYPE(field_id) == mFI_FIELD_FG) { + mPr_sunburn_c* sunburn = &Now_Private->sunburn; + + if (sunburn->rank > 0) { + int rankdown_days = sunburn->rankdown_days; + + if (rankdown_days > 0) { + lbRTC_ymd_c now_ymd; + int days; + + mTM_set_renew_time(&now_ymd, Common_GetPointer(time.rtc_time)); + days = lbRTC_GetIntervalDays2(&sunburn->last_changed_date, &now_ymd); + if (days > 0) { + if (rankdown_days >= 2) { + lbRTC_time_c add_time = { 0, 0, 0, 1, 0, 0, 0 }; // @BUG - should be 'static' + lbRTC_time_c last_changed_time; + + mTM_ymd_2_time(&last_changed_time, &sunburn->last_changed_date); + lbRTC_Add_Date(&last_changed_time, &add_time); + mTM_set_renew_time(&sunburn->last_changed_date, &last_changed_time); + } + + if (days == 1) { + rankdown_days -= 1; + } else { + rankdown_days -= 2; + } + + if (rankdown_days < 0) { + rankdown_days = 0; + } + + sunburn->rankdown_days = rankdown_days; + } + } + } + } + } +} + +static void Player_actor_Check_player_sunburn_rankdown(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (mEv_CheckTitleDemo() <= 0) { + mActor_name_t field_id = mFI_GetFieldId(); + + if (mFI_GET_TYPE(field_id) == mFI_FIELD_FG) { + mPr_sunburn_c* sunburn = &Now_Private->sunburn; + + if (sunburn->rank > 0 && player->player_sunburn_rankdown == FALSE) { + lbRTC_ymd_c now_ymd; + int days; + int diff_days; + + mTM_set_renew_time(&now_ymd, Common_GetPointer(time.rtc_time)); + days = lbRTC_GetIntervalDays2(&sunburn->last_changed_date, &now_ymd); + diff_days = days - sunburn->rankdown_days; + if (diff_days > 0) { + player->player_sunburn_rankdown = TRUE; + } + } + } + } +} + +static void Player_actor_Check_player_sunburn_rankup(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->player_sunburn_rankup == FALSE && mEv_CheckTitleDemo() <= 0) { + mActor_name_t field_id = mFI_GetFieldId(); + + if (mFI_GET_TYPE(field_id) == mFI_FIELD_FG) { + if (mEv_CheckFirstIntro() == FALSE && mEnv_NowWeather() == mEnv_WEATHER_CLEAR) { + int item_kind = mPlib_Check_now_handin_item_kind(); + + /* Player can use umbrellas to prevent sunburn */ + if (mPlayer_ITEM_IS_UMBRELLA(item_kind) == FALSE) { + lbRTC_time_c* time_p = Common_GetPointer(time.rtc_time); + int hour = time_p->hour; + + if (!(hour >= 10 && hour < 17)) { + return; + } + + if (mFI_CheckInIsland() == FALSE) { + int month = time_p->month; + int day = time_p->day; + + /* Sunburn will occur in town between July 16th and September 15th */ + if (month != lbRTC_AUGUST) { + if (month == lbRTC_JULY) { + if (day < 16) { + return; + } + } else if (month == lbRTC_SEPTEMBER) { + if (day > 15) { + return; + } + } else { + return; + } + } + + { + mPr_sunburn_c* sunburn = &Now_Private->sunburn; + + if (sunburn->rank > 0 && sunburn->rankdown_days >= 2) { + return; + } + } + } + + if (player->player_sunburn_rankdown == FALSE) { + int last_sunburn_time = Common_Get(sunburn_time); + int max_sunburn_time = mFI_CheckInIsland() == FALSE ? (s16)mPlayer_SUNBURN_TIME_VILLAGE + : mPlayer_SUNBURN_TIME_ISLAND; + if (last_sunburn_time >= max_sunburn_time) { + player->player_sunburn_rankup = TRUE; + } + + Common_Set(sunburn_time, last_sunburn_time + 1); + } + } + } + } + } +} + +static int Player_actor_Set_player_sunburn_rankdown(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->player_sunburn_rankdown != FALSE) { + mPr_sunburn_c* sunburn = &Now_Private->sunburn; + lbRTC_ymd_c now_date; + int days; + int diff_days; + + mTM_set_renew_time(&now_date, Common_GetPointer(time.rtc_time)); + days = lbRTC_GetIntervalDays2(&sunburn->last_changed_date, &now_date); + diff_days = days - sunburn->rankdown_days; + + if (diff_days > 0) { + int i; + + for (i = 0; i < diff_days; i++) { + sunburn->rank--; + + if (sunburn->rank < 0) { + sunburn->rank = 0; + break; + } + } + + sunburn->last_changed_date = now_date; + return TRUE; + } + + player->player_sunburn_rankdown = FALSE; /* @BUG? - shouldn't this be set to false in the above case too? */ + } + + return FALSE; +} + +static int Player_actor_Set_player_sunburn_rankup(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->player_sunburn_rankup != FALSE) { + mPr_sunburn_c* sunburn = &Now_Private->sunburn; + lbRTC_ymd_c now_date; + + mTM_set_renew_time(&now_date, Common_GetPointer(time.rtc_time)); + sunburn->rank++; + if (sunburn->rank >= (mPlayer_SUNBURN_MAX_RANK + 1)) { + sunburn->rank = mPlayer_SUNBURN_MAX_RANK; + } + + sunburn->last_changed_date = now_date; + sunburn->rankdown_days = 2; + Common_Set(sunburn_time, 0); + player->player_sunburn_rankup = FALSE; + return TRUE; + } + + return FALSE; +} + +static void Player_actor_Check_player_sunburn_for_dt(ACTOR* actorx) { + Player_actor_Check_player_sunburn_ChangeDay(actorx); + Player_actor_Check_player_sunburn_rankdown_interval(actorx); + Player_actor_Check_player_sunburn_rankdown(actorx); + Player_actor_Set_player_sunburn_rankup(actorx); + Player_actor_Set_player_sunburn_rankdown(actorx); +} + +static void Player_actor_Check_player_sunburn_for_main(ACTOR* actorx) { + Player_actor_Check_player_sunburn_ChangeDay(actorx); + Player_actor_Check_player_sunburn_rankdown_interval(actorx); + Player_actor_Check_player_sunburn_rankdown(actorx); + Player_actor_Check_player_sunburn_rankup(actorx); +} + +static void Player_actor_Check_player_sunburn_for_ct(ACTOR* actorx) { + Player_actor_Check_player_sunburn_ChangeDay(actorx); + Player_actor_Check_player_sunburn_rankdown_interval(actorx); + Player_actor_Check_player_sunburn_rankdown(actorx); + Player_actor_Set_player_sunburn_rankdown(actorx); +} + +static void Player_actor_Check_player_change_color_for_main(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (player->change_color_request) { + player->change_color_request = FALSE; + if (player->change_color_flag) { + player->change_color_timer += 1.0f; + if (player->change_color_timer >= 79.68f) { + player->change_color_timer = 0.0f; + } + } else { + player->change_color_flag = TRUE; + player->change_color_timer = 0.0f; + } + } else { + if (player->change_color_flag) { + player->change_color_flag = FALSE; + } + } +} + +static int Player_actor_Check_InBlockRadioExercise(ACTOR* actorx) { + if (mEv_check_status(mEv_EVENT_MORNING_AEROBICS, mEv_STATUS_RUN) || + mEv_check_status(mEv_EVENT_SPORTS_FAIR_AEROBICS, mEv_STATUS_RUN)) { + int bx; + int bz; + + if (mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_SHRINE)) { + int player_bx; + int player_bz; + + if (mFI_Wpos2BlockNum(&player_bx, &player_bz, actorx->world.position)) { + if (player_bx == bx && player_bz == bz) { + return TRUE; + } + } + } + } else { + /* Check if the aerobics radio is playing in the house */ + int field_type = Common_Get(field_type); + + if (field_type != mFI_FIELDTYPE2_FG && aMR_RadioBgmNow()) { + return TRUE; + } + } + + return FALSE; +} + +static int Player_actor_Check_AbleRadioExercise(ACTOR* actorx) { + /* Player must be in the same block as aerobics radio, or in a house room with one playing */ + if (Player_actor_Check_InBlockRadioExercise(actorx) == FALSE) { + return FALSE; + } + + /* Player must not be holding any item */ + if (mPlib_Check_now_handin_item() != FALSE) { + return FALSE; + } + + return TRUE; +} + +static int Player_actor_Get_RadioExerciseCommandRingBufferIndex(int base_idx, int ofs) { + base_idx += ofs; + if (base_idx >= mPlayer_RADIO_EXCERCISE_COMMAND_RING_BUFFER_SIZE) { + return base_idx - mPlayer_RADIO_EXCERCISE_COMMAND_RING_BUFFER_SIZE; + } else { + return base_idx; + } +} + +static s8 Player_actor_Get_RadioExerciseCommand(int base_idx, s8* command_ring_buffer_p, int ofs) { + int idx = Player_actor_Get_RadioExerciseCommandRingBufferIndex(base_idx, ofs); + + /* @BUG - this should probably be || idx >= mPlayer_RADIO_EXCERCISE_COMMAND_RING_BUFFER_SIZE */ + if (idx < 0 && idx < mPlayer_RADIO_EXCERCISE_COMMAND_RING_BUFFER_SIZE) { + idx = 0; + } + + return command_ring_buffer_p[idx]; +} + +static void Player_actor_Set_RadioExerciseCommandRingBuffer(ACTOR* actorx, s8 command) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int* buffer_idx_p = &player->radio_exercise_command_ring_buffer_index; + s8* ring_buffer_p = player->radio_exercise_command_ring_buffer; + s8* ring_buf_timer_p = &player->radio_exercise_ring_buffer_cmd_timer; + int now_buffer_idx = *buffer_idx_p; + + if (command >= 0) { + int cmd = Player_actor_Get_RadioExerciseCommand(0, ring_buffer_p, now_buffer_idx); + + if (cmd == command && !(*ring_buf_timer_p >= 50.0f)) { + (*ring_buf_timer_p)++; + return; + } + } + { + int new_buffer_idx = Player_actor_Get_RadioExerciseCommandRingBufferIndex(7, now_buffer_idx); + + *buffer_idx_p = new_buffer_idx; + ring_buffer_p[Player_actor_Get_RadioExerciseCommandRingBufferIndex(0, new_buffer_idx)] = command; + *ring_buf_timer_p = 0; + } +} + +static void Player_actor_Set_RadioExerciseCommand(ACTOR* actorx, GAME* game, int skip_input_flag) { + int command = -1; + + if (skip_input_flag == FALSE && Player_actor_Check_AbleRadioExercise(actorx)) { + command = Player_actor_CheckController_forRadio_exercise(game); + } + + Player_actor_Set_RadioExerciseCommandRingBuffer(actorx, command); +} + +static int Player_actor_Check_radio_exercise_command(ACTOR* actorx, int continue_idx, f32* timer_p) { + static s8 Player_actor_radio_exercise_command_key_data_type1[] = { 6, 0, 3 }; + static s8 Player_actor_radio_exercise_command_key_data_type2_1[] = { 1, 4, 3, 5, 2 }; + static s8 Player_actor_radio_exercise_command_key_data_type2_2[] = { 2, 5, 3, 4, 1 }; + static s8 Player_actor_radio_exercise_command_key_data_type3[] = { 3, 0, 3 }; + static s8 Player_actor_radio_exercise_command_key_data_type4_1_1[] = { 5, 0, 5 }; + static s8 Player_actor_radio_exercise_command_key_data_type4_1_2[] = { 7, 0, 5 }; + static s8 Player_actor_radio_exercise_command_key_data_type4_2_1[] = { 4, 0, 4 }; + static s8 Player_actor_radio_exercise_command_key_data_type4_2_2[] = { 8, 0, 4 }; + static s8 Player_actor_radio_exercise_command_key_data_type5_1_1[] = { 2, 0, 2 }; + static s8 Player_actor_radio_exercise_command_key_data_type5_1_2[] = { 1, 0, 2 }; + static s8 Player_actor_radio_exercise_command_key_data_type5_2_1[] = { 1, 0, 1 }; + static s8 Player_actor_radio_exercise_command_key_data_type5_2_2[] = { 2, 0, 1 }; + static s8 Player_actor_radio_exercise_command_key_data_type6_1_1[] = { 8, 0, 8 }; + static s8 Player_actor_radio_exercise_command_key_data_type6_1_2[] = { 4, 0, 8 }; + static s8 Player_actor_radio_exercise_command_key_data_type6_2_1[] = { 7, 0, 7 }; + static s8 Player_actor_radio_exercise_command_key_data_type6_2_2[] = { 5, 0, 7 }; + static s8 Player_actor_radio_exercise_command_key_data_type7_1[] = { 6, 8, 2, 5, 3, 4, 1, 7 }; + static s8 Player_actor_radio_exercise_command_key_data_type7_2[] = { 6, 7, 1, 4, 3, 5, 2, 8 }; + + // clang-format off + static s8* command_key_p_data[] = { + Player_actor_radio_exercise_command_key_data_type1, + Player_actor_radio_exercise_command_key_data_type2_1, + Player_actor_radio_exercise_command_key_data_type2_2, + Player_actor_radio_exercise_command_key_data_type3, + Player_actor_radio_exercise_command_key_data_type4_1_1, + Player_actor_radio_exercise_command_key_data_type4_1_2, + Player_actor_radio_exercise_command_key_data_type4_2_1, + Player_actor_radio_exercise_command_key_data_type4_2_2, + Player_actor_radio_exercise_command_key_data_type5_1_1, + Player_actor_radio_exercise_command_key_data_type5_1_2, + Player_actor_radio_exercise_command_key_data_type5_2_1, + Player_actor_radio_exercise_command_key_data_type5_2_2, + Player_actor_radio_exercise_command_key_data_type6_1_1, + Player_actor_radio_exercise_command_key_data_type6_1_2, + Player_actor_radio_exercise_command_key_data_type6_2_1, + Player_actor_radio_exercise_command_key_data_type6_2_2, + Player_actor_radio_exercise_command_key_data_type7_1, + Player_actor_radio_exercise_command_key_data_type7_2, + }; + // clang-format on + + // clang-format off + static int total_command_key_element_data[] = { + 3, + 5, + 5, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 8, + 8, + }; + // clang-format on + + // clang-format off + static s8 continue_command_data[] = { + -1, + 17, + 16, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + }; + // clang-format on + + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + int continue_command; + s8* ring_buffer_p = player->radio_exercise_command_ring_buffer; + int ring_buffer_idx = player->radio_exercise_command_ring_buffer_index; + s8** key_data_table = command_key_p_data; + int* len_table = total_command_key_element_data; + int i; + + if (continue_idx >= 0) { + continue_command = continue_command_data[continue_idx]; + } else { + continue_command = -1; + } + + *timer_p = 0.0f; + for (i = 0; i < ARRAY_COUNT(command_key_p_data); i++) { + s8* data_p = &(*key_data_table)[(*len_table) - 1]; + + if (continue_command < 0 || i == continue_command) { + int j = 0; + int n = (*len_table) - 1; + + while (n >= 0) { + s8 cmd = Player_actor_Get_RadioExerciseCommand(j, ring_buffer_p, ring_buffer_idx); + + if (cmd != *data_p || cmd < 0) { + break; + } + + data_p--; + j++; + n--; + } + + if (n < 0) { + if (continue_command_data[i] >= 0) { + *timer_p = 6.0f; + } + + return i; + } + } + + len_table++; + key_data_table++; + } + + return -1; +} + +static int Player_actor_CheckAndRequest_main_radio_exercise_all(GAME* game, int skip_request_flag) { + ACTOR* actorx = GET_PLAYER_ACTOR_GAME_ACTOR(game); + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (Player_actor_Check_AbleRadioExercise(actorx) == FALSE) { + return FALSE; + } else { + int cmd_idx; + f32 timer; + + player->radio_exercise_cmd_timer -= 1.0f; + if (player->radio_exercise_cmd_timer < 0.0f) { + player->radio_exercise_cmd_timer = 0.0f; + } + + cmd_idx = Player_actor_Check_radio_exercise_command(actorx, player->radio_exercise_continue_cmd_idx, &timer); + if (cmd_idx >= 0) { + if (player->radio_exercise_continue_cmd_idx >= 0) { + if (player->radio_exercise_cmd_timer > 0.0f) { + player->radio_exercise_continue_cmd_idx = cmd_idx; + player->radio_exercise_cmd_timer = timer; + } + } else { + player->radio_exercise_continue_cmd_idx = cmd_idx; + player->radio_exercise_cmd_timer = timer; + } + } + + if (skip_request_flag == FALSE && player->radio_exercise_continue_cmd_idx >= 0) { + if (player->radio_exercise_cmd_timer <= 0.0f) { + if (Player_actor_request_main_radio_exercise_all(game, player->radio_exercise_continue_cmd_idx, 0.0f, + mPlayer_REQUEST_PRIORITY_4)) { + return TRUE; + } + } + } + } + + return FALSE; +} + +static void Player_actor_Set_old_sound_frame_counter(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->old_sound_frame_counter = sAdo_GetSoundFrameCounter(); +} + +static int Player_actor_check_able_change_camera_normal_index(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + if (Player_actor_Check_AbleRadioExercise(actorx)) { + return FALSE; + } + + if (mEv_CheckTitleDemo() <= 0 && mPlib_Check_scene_able_change_camera_pos()) { + int main_index = player->now_main_index; + + if (mPlayer_MAIN_INDEX_VALID(main_index) != FALSE) { + // clang-format off + static const s8 data[] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + }; + // clang-format on + + return data[main_index]; + } + } + + return FALSE; +} + +static void Player_actor_Set_Indoor_Camera_Index(ACTOR* actorx, GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + Camera2* camera = &play->camera; + + if (Player_actor_check_able_change_camera_normal_index(actorx)) { + int dist_add_idx = camera->indoor_distance_addition_idx; + int dir_add_idx = camera->indoor_direction_addition_idx; + + if (chkTrigger(BUTTON_CUP)) { + if ((dist_add_idx - 1) >= 0) { + camera->indoor_distance_addition_idx = dist_add_idx - 1; + Player_actor_sound_camera_move1(); + } + } else if (chkTrigger(BUTTON_CDOWN)) { + if ((dist_add_idx + 1) < 3) { + camera->indoor_distance_addition_idx = dist_add_idx + 1; + Player_actor_sound_camera_move2(); + } + } + + if (chkTrigger(BUTTON_CLEFT)) { + if ((dir_add_idx - 1) >= 0) { + camera->indoor_direction_addition_idx = dir_add_idx - 1; + Player_actor_sound_camera_move1(); + } + } else if (chkTrigger(BUTTON_CRIGHT)) { + if ((dir_add_idx + 1) < 3) { + camera->indoor_direction_addition_idx = dir_add_idx + 1; + Player_actor_sound_camera_move1(); + } + } + } +} diff --git a/src/m_submenu.c b/src/m_submenu.c index 1cb8bc59..4aac8803 100644 --- a/src/m_submenu.c +++ b/src/m_submenu.c @@ -8,720 +8,656 @@ #include "m_quest.h" #include "libultra/libultra.h" -static mSM_dlftbl_c SubmenuArea_dlftbl[mSM_DLF_NUM] = { - { NULL, 0, 0, 0, 0, 0, "submenu_ovl" }, - { NULL, 0, 0, 0, 0, 0, "player_actor" } -}; +static mSM_dlftbl_c SubmenuArea_dlftbl[mSM_DLF_NUM] = { { NULL, 0, 0, 0, 0, 0, "submenu_ovl" }, + { NULL, 0, 0, 0, 0, 0, "player_actor" } }; static mSM_dlftbl_c* SubmenuArea_visit = NULL; static void* SubmenuArea_allocp = NULL; extern int mSM_COLLECT_INSECT_GET(int idx) { - u32 ftr_idx = (0x2F2 << 2) + (idx << 2); - return (Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] & (1 << ((ftr_idx >> 2) & 0x1F))) != 0; + u32 ftr_idx = (0x2F2 << 2) + (idx << 2); + return (Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] & + (1 << ((ftr_idx >> 2) & 0x1F))) != 0; } extern void mSM_COLLECT_INSECT_SET(int idx) { - u32 ftr_idx = (0x2F2 << 2) + (idx << 2); - Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] |= (1 << ((ftr_idx >> 2) & 0x1F)); + u32 ftr_idx = (0x2F2 << 2) + (idx << 2); + Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] |= (1 << ((ftr_idx >> 2) & 0x1F)); } static int mSM_CHECK_ALL_INSECT_GET_SUB() { - int i; - int n = 0; + int i; + int n = 0; - for (i = 0; i < INSECT_ONLY_NUM; i++) { - if (mSM_COLLECT_INSECT_GET(i) != FALSE) { - n++; + for (i = 0; i < INSECT_ONLY_NUM; i++) { + if (mSM_COLLECT_INSECT_GET(i) != FALSE) { + n++; + } } - } - return n; + return n; } extern int mSM_CHECK_ALL_INSECT_GET() { - if (mSM_CHECK_ALL_INSECT_GET_SUB() == INSECT_ONLY_NUM) { - return TRUE; - } + if (mSM_CHECK_ALL_INSECT_GET_SUB() == INSECT_ONLY_NUM) { + return TRUE; + } - return FALSE; + return FALSE; } extern int mSM_CHECK_LAST_INSECT_GET(int idx) { - int res = FALSE; + int res = FALSE; - if (mSM_CHECK_ALL_INSECT_GET_SUB() == (INSECT_ONLY_NUM - 1) && mSM_COLLECT_INSECT_GET(idx) == FALSE) { - res = TRUE; - } + if (mSM_CHECK_ALL_INSECT_GET_SUB() == (INSECT_ONLY_NUM - 1) && mSM_COLLECT_INSECT_GET(idx) == FALSE) { + res = TRUE; + } - return res; + return res; } extern int mSM_COLLECT_FISH_GET(int idx) { - u32 ftr_idx = (0x31A << 2) + (idx << 2); - return (Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] & (1 << ((ftr_idx >> 2) & 0x1F))) != 0; + u32 ftr_idx = (0x31A << 2) + (idx << 2); + return (Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] & + (1 << ((ftr_idx >> 2) & 0x1F))) != 0; } extern void mSM_COLLECT_FISH_SET(int idx) { - u32 ftr_idx = (0x31A << 2) + (idx << 2); - Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] |= (1 << ((ftr_idx >> 2) & 0x1F)); + u32 ftr_idx = (0x31A << 2) + (idx << 2); + Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 2 >> 5] |= (1 << ((ftr_idx >> 2) & 0x1F)); } static int mSM_CHECK_ALL_FISH_GET_SUB() { - int i; - int n = 0; + int i; + int n = 0; - for (i = 0; i < FISH_NUM; i++) { - if (mSM_COLLECT_FISH_GET(i) != FALSE) { - n++; + for (i = 0; i < FISH_NUM; i++) { + if (mSM_COLLECT_FISH_GET(i) != FALSE) { + n++; + } } - } - return n; + return n; } extern int mSM_CHECK_ALL_FISH_GET() { - if (mSM_CHECK_ALL_FISH_GET_SUB() == FISH_NUM) { - return TRUE; - } + if (mSM_CHECK_ALL_FISH_GET_SUB() == FISH_NUM) { + return TRUE; + } - return FALSE; + return FALSE; } extern int mSM_CHECK_LAST_FISH_GET(int idx) { - int res = FALSE; + int res = FALSE; - if (mSM_CHECK_ALL_FISH_GET_SUB() == (FISH_NUM - 1) && mSM_COLLECT_FISH_GET(idx) == FALSE) { - res = TRUE; - } + if (mSM_CHECK_ALL_FISH_GET_SUB() == (FISH_NUM - 1) && mSM_COLLECT_FISH_GET(idx) == FALSE) { + res = TRUE; + } - return res; + return res; } extern int SubmenuArea_IsPlayer() { - return SubmenuArea_visit == &SubmenuArea_dlftbl[mSM_DLF_PLAYER_ACTOR]; + return SubmenuArea_visit == &SubmenuArea_dlftbl[mSM_DLF_PLAYER_ACTOR]; } static void mSM_load_player_anime(GAME_PLAY* play) { - // stubbed + // stubbed } static void SubmenuArea_DoLink(mSM_dlftbl_c* dlftbl, Submenu* submenu, int dlf_idx) { - dlftbl->_00 = SubmenuArea_allocp; - dlftbl->_14 = 0; - SubmenuArea_visit = dlftbl; - submenu->overlay_address = dlftbl->_00; - submenu->next_overlay_address = dlftbl->_00; + dlftbl->_00 = SubmenuArea_allocp; + dlftbl->_14 = 0; + SubmenuArea_visit = dlftbl; + submenu->overlay_address = dlftbl->_00; + submenu->next_overlay_address = dlftbl->_00; } static void SubmenuArea_DoUnlink(mSM_dlftbl_c* dlftbl, Submenu* submenu) { - if (dlftbl->_00 != NULL) { - submenu->overlay_address = dlftbl->_00; - submenu->next_overlay_address = dlftbl->_00; - dlftbl->_14 = 0; - dlftbl->_00 = NULL; - SubmenuArea_visit = NULL; - } + if (dlftbl->_00 != NULL) { + submenu->overlay_address = dlftbl->_00; + submenu->next_overlay_address = dlftbl->_00; + dlftbl->_14 = 0; + dlftbl->_00 = NULL; + SubmenuArea_visit = NULL; + } } static int mSM_ovlptr_dllcnv_sub(void* proc, mSM_dlftbl_c* dlftbl, Submenu* submenu, int dlf_idx) { - if (dlf_idx == mSM_DLF_SUBMENU_OVL || dlf_idx == mSM_DLF_PLAYER_ACTOR) { - SubmenuArea_DoLink(dlftbl, submenu, dlf_idx); - return TRUE; - } + if (dlf_idx == mSM_DLF_SUBMENU_OVL || dlf_idx == mSM_DLF_PLAYER_ACTOR) { + SubmenuArea_DoLink(dlftbl, submenu, dlf_idx); + return TRUE; + } - return FALSE; + return FALSE; } extern void* mSM_ovlptr_dllcnv(void* proc, Submenu* submenu, int dlf_idx) { - if (SubmenuArea_visit != NULL) { - return; // ?? - } - else if (mSM_ovlptr_dllcnv_sub(proc, SubmenuArea_dlftbl, submenu, dlf_idx) == FALSE) { - return NULL; - } + if (SubmenuArea_visit != NULL) { + return; // ?? + } else if (mSM_ovlptr_dllcnv_sub(proc, SubmenuArea_dlftbl, submenu, dlf_idx) == FALSE) { + return NULL; + } - return proc; + return proc; } extern void mSM_submenu_ovlptr_init(GAME_PLAY* play) { - SubmenuArea_allocp = (void*)1; - SubmenuArea_visit = NULL; + SubmenuArea_allocp = (void*)1; + SubmenuArea_visit = NULL; } extern void mSM_submenu_ovlptr_cleanup(Submenu* submenu) { - if (SubmenuArea_visit != NULL) { - SubmenuArea_DoUnlink(SubmenuArea_visit, submenu); - SubmenuArea_visit = NULL; - } + if (SubmenuArea_visit != NULL) { + SubmenuArea_DoUnlink(SubmenuArea_visit, submenu); + SubmenuArea_visit = NULL; + } - SubmenuArea_allocp = NULL; + SubmenuArea_allocp = NULL; } extern void load_player(Submenu* submenu) { - mSM_dlftbl_c* dlftbl = &SubmenuArea_dlftbl[mSM_DLF_PLAYER_ACTOR]; + mSM_dlftbl_c* dlftbl = &SubmenuArea_dlftbl[mSM_DLF_PLAYER_ACTOR]; - if (SubmenuArea_visit != dlftbl) { - if (SubmenuArea_visit != NULL) { - SubmenuArea_DoUnlink(SubmenuArea_visit, submenu); + if (SubmenuArea_visit != dlftbl) { + if (SubmenuArea_visit != NULL) { + SubmenuArea_DoUnlink(SubmenuArea_visit, submenu); + } + + SubmenuArea_DoLink(dlftbl, submenu, mSM_DLF_PLAYER_ACTOR); } - - SubmenuArea_DoLink(dlftbl, submenu, mSM_DLF_PLAYER_ACTOR); - } } extern void mSM_submenu_ct(Submenu* submenu) { - bzero(submenu, sizeof(Submenu)); - submenu->process_status = mSM_PROCESS_WAIT; - submenu->wait_timer = 0; + bzero(submenu, sizeof(Submenu)); + submenu->process_status = mSM_PROCESS_WAIT; + submenu->wait_timer = 0; - if (Common_Get(submenu_disabled) == TRUE) { - submenu->disable_start_btn_flag = TRUE; - Common_Set(submenu_disabled, FALSE); - } + if (Common_Get(submenu_disabled) == TRUE) { + submenu->start_refuse = TRUE; + Common_Set(submenu_disabled, FALSE); + } - submenu->move_proc = (SUBMENU_PROC)&none_proc1; - submenu->draw_proc = (SUBMENU_GAME_PROC)&none_proc1; + submenu->move_proc = (SUBMENU_PROC)&none_proc1; + submenu->draw_proc = (SUBMENU_GAME_PROC)&none_proc1; } extern void mSM_submenu_dt(Submenu* submenu) { - // stubbed + // stubbed } extern void mSM_open_submenu(Submenu* submenu, int type, int arg0, int arg1) { - mSM_open_submenu_new2(submenu, type, arg0, arg1, NULL, 0); + mSM_open_submenu_new2(submenu, type, arg0, arg1, NULL, 0); } extern void mSM_open_submenu_new(Submenu* submenu, int type, int arg0, int arg1, void* arg2) { - mSM_open_submenu_new2(submenu, type, arg0, arg1, arg2, 0); + mSM_open_submenu_new2(submenu, type, arg0, arg1, arg2, 0); } extern void mSM_open_submenu_new2(Submenu* submenu, int type, int arg0, int arg1, void* arg2, int arg3) { - submenu->menu_type = type; - submenu->param0 = arg0; - submenu->param1 = arg1; - submenu->param2 = arg2; - submenu->param3 = arg3; + submenu->menu_type = type; + submenu->param0 = arg0; + submenu->param1 = arg1; + submenu->param2 = arg2; + submenu->param3 = arg3; } static void mSM_Reset_player_btn_type1(GAME_PLAY* play) { - PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); - if (player != NULL) { - player->a_btn_pressed = FALSE; - player->a_btn_triggers_submenu = TRUE; - } + if (player != NULL) { + player->a_btn_pressed = FALSE; + player->a_btn_triggers_submenu = TRUE; + } } static void mSM_Reset_player_btn_type2(GAME_PLAY* play) { - PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); - if (player != NULL) { - player->a_btn_triggers_submenu = TRUE; - } + if (player != NULL) { + player->a_btn_triggers_submenu = TRUE; + } } static int mSM_check_open_map_new(GAME_PLAY* play) { - PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); - int open_map = FALSE; - int bx; - int bz; + PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + int open_map = FALSE; + int bx; + int bz; - if (chkTrigger(mSM_MAP_BUTTON) && Common_Get(map_flag) == TRUE) { - open_map = TRUE; - } + if (chkTrigger(mSM_MAP_BUTTON) && Common_Get(map_flag) == TRUE) { + open_map = TRUE; + } - if (open_map == FALSE) { - return FALSE; - } + if (open_map == FALSE) { + return FALSE; + } - if (player == NULL) { - return FALSE; - } + if (player == NULL) { + return FALSE; + } - if (Save_Get(scene_no) == SCENE_COTTAGE_MY || Save_Get(scene_no) == SCENE_COTTAGE_NPC) { - return FALSE; - } + if (Save_Get(scene_no) == SCENE_COTTAGE_MY || Save_Get(scene_no) == SCENE_COTTAGE_NPC) { + return FALSE; + } - mFI_Wpos2BlockNum(&bx, &bz, player->actor_class.world.position); - return mFI_CheckBlockKind_OR(bx, bz, mRF_BLOCKKIND_OCEAN) == FALSE; + mFI_Wpos2BlockNum(&bx, &bz, player->actor_class.world.position); + return mFI_CheckBlockKind_OR(bx, bz, mRF_BLOCKKIND_OCEAN) == FALSE; } extern void mSM_submenu_ctrl(GAME_PLAY* play) { - Submenu* submenu = &play->submenu; - int open_inventory; + Submenu* submenu = &play->submenu; + int open_inventory; - if (submenu->process_status != mSM_PROCESS_WAIT) { - return; - } - - if (play->fb_fade_type != 0) { - return; - } - - if (play->fb_wipe_mode != 0) { - return; - } - - open_inventory = FALSE; - if (chkTrigger(mSM_INV_BUTTON_0) || chkTrigger(mSM_INV_BUTTON_1)) { - open_inventory = TRUE; - } - - if ( - ( - (open_inventory && Common_Get(reset_flag) == FALSE) || - (mSM_check_open_map_new(play) == TRUE && Common_Get(reset_flag) == FALSE) - ) && - submenu->disable_start_btn_flag == FALSE && submenu->disable_start_btn_timer == 0 && - mPlib_able_submenu_type1((GAME*)play) && mEv_CheckFirstIntro() == FALSE - ) { - if (open_inventory) { - mSM_open_submenu(submenu, mSM_OVL_INVENTORY, 0, 0); - } - else { - mSM_open_submenu(submenu, mSM_OVL_MAP, 1, 0); + if (submenu->process_status != mSM_PROCESS_WAIT) { + return; } - mSM_Reset_player_btn_type2(play); - } - else { - PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + if (play->fb_fade_type != 0) { + return; + } - if ( - player != NULL && player->a_btn_pressed == TRUE && - Common_Get(reset_flag) == FALSE && submenu->disable_start_btn_flag == FALSE && - submenu->disable_start_btn_timer == 0 && mPlib_able_submenu_type1((GAME*)play) - ) { - s16 y_dir = player->actor_class.shape_info.rotation.y; - int dir; - - y_dir -= -0x8000; - dir = ABS(y_dir); + if (play->fb_wipe_mode != 0) { + return; + } - if (dir < DEG2SHORT_ANGLE(45.0f)) { - switch (player->item_in_front) { - case MESSAGE_BOARD1: - case MESSAGE_BOARD0: - mSM_open_submenu(submenu, mSM_OVL_NOTICE, 0, 0); - mSM_Reset_player_btn_type1(play); - break; - case MAP_BOARD1: - case MAP_BOARD0: - mSM_open_submenu(submenu, mSM_OVL_MAP, 0, 0); - mSM_Reset_player_btn_type1(play); - break; + open_inventory = FALSE; + if (chkTrigger(mSM_INV_BUTTON_0) || chkTrigger(mSM_INV_BUTTON_1)) { + open_inventory = TRUE; + } + + if (((open_inventory && Common_Get(reset_flag) == FALSE) || + (mSM_check_open_map_new(play) == TRUE && Common_Get(reset_flag) == FALSE)) && + submenu->start_refuse == FALSE && submenu->start_refuse_timer == 0 && mPlib_able_submenu_type1((GAME*)play) && + mEv_CheckFirstIntro() == FALSE) { + if (open_inventory) { + mSM_open_submenu(submenu, mSM_OVL_INVENTORY, 0, 0); + } else { + mSM_open_submenu(submenu, mSM_OVL_MAP, 1, 0); } - } - } - } - if (submenu->menu_type != mSM_OVL_NONE) { - submenu->process_status = mSM_PROCESS_PREWAIT; - submenu->mode = 1; - SetGameFrame(1); - } + mSM_Reset_player_btn_type2(play); + } else { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); + + if (player != NULL && player->a_btn_pressed == TRUE && Common_Get(reset_flag) == FALSE && + submenu->start_refuse == FALSE && submenu->start_refuse_timer == 0 && + mPlib_able_submenu_type1((GAME*)play)) { + s16 y_dir = player->actor_class.shape_info.rotation.y; + int dir; + + y_dir -= -0x8000; + dir = ABS(y_dir); + + if (dir < DEG2SHORT_ANGLE(45.0f)) { + switch (player->item_in_front) { + case MESSAGE_BOARD1: + case MESSAGE_BOARD0: + mSM_open_submenu(submenu, mSM_OVL_NOTICE, 0, 0); + mSM_Reset_player_btn_type1(play); + break; + case MAP_BOARD1: + case MAP_BOARD0: + mSM_open_submenu(submenu, mSM_OVL_MAP, 0, 0); + mSM_Reset_player_btn_type1(play); + break; + } + } + } + } + + if (submenu->menu_type != mSM_OVL_NONE) { + submenu->process_status = mSM_PROCESS_PREWAIT; + submenu->mode = 1; + SetGameFrame(1); + } } static void mSM_move_Wait(Submenu* submenu) { - if (submenu->wait_timer != 0) { - submenu->wait_timer--; - } + if (submenu->wait_timer != 0) { + submenu->wait_timer--; + } - if (submenu->disable_start_btn_timer != 0) { - submenu->disable_start_btn_timer--; - } + if (submenu->start_refuse_timer != 0) { + submenu->start_refuse_timer--; + } } static void mSM_move_PREWait(Submenu* submenu) { - if (submenu->mode >= 3) { - submenu->process_status = mSM_PROCESS_LINKWAIT; - } + if (submenu->mode >= 3) { + submenu->process_status = mSM_PROCESS_LINKWAIT; + } } static void mSM_move_LINKWait(Submenu* submenu) { - Submenu_Item_c* item; - mSM_dlftbl_c* dlftbl = &SubmenuArea_dlftbl[mSM_DLF_SUBMENU_OVL]; - int i; + Submenu_Item_c* item; + mSM_dlftbl_c* dlftbl = &SubmenuArea_dlftbl[mSM_DLF_SUBMENU_OVL]; + int i; - if (SubmenuArea_visit != dlftbl) { - if (SubmenuArea_visit != NULL) { - SubmenuArea_DoUnlink(SubmenuArea_visit, submenu); + if (SubmenuArea_visit != dlftbl) { + if (SubmenuArea_visit != NULL) { + SubmenuArea_DoUnlink(SubmenuArea_visit, submenu); + } + + SubmenuArea_DoLink(dlftbl, submenu, mSM_DLF_SUBMENU_OVL); + submenu->move_proc = (SUBMENU_PROC)mSM_ovlptr_dllcnv(&mSM_menu_ovl_init, submenu, mSM_DLF_SUBMENU_OVL); + submenu->draw_proc = (SUBMENU_GAME_PROC)&none_proc1; + submenu->process_status = mSM_PROCESS_PLAY; + submenu->open_flag = TRUE; + submenu->after_mode = 7; + submenu->unk_164 = 0; + mMl_clear_mail(&submenu->mail); + submenu->item_p = &submenu->items[0]; + submenu->item_num = mPr_POCKETS_SLOT_COUNT; + + item = submenu->item_p; + for (i = 0; i < submenu->item_num; i++) { + item->item = EMPTY_NO; + item->slot_no = mPr_POCKETS_SLOT_COUNT; + item++; + } + + if (submenu->mode != 4) { + if ((submenu->menu_type == mSM_OVL_LEDIT && submenu->param0 == 0) || + Common_Get(now_private)->gender == mPr_SEX_MALE) { + sAdo_SpecChange(5); + } else { + sAdo_SpecChange(6); + } + + sAdo_SetVoiceMode(0); + } } - - SubmenuArea_DoLink(dlftbl, submenu, mSM_DLF_SUBMENU_OVL); - submenu->move_proc = (SUBMENU_PROC)mSM_ovlptr_dllcnv(&mSM_menu_ovl_init, submenu, mSM_DLF_SUBMENU_OVL); - submenu->draw_proc = (SUBMENU_GAME_PROC)&none_proc1; - submenu->process_status = mSM_PROCESS_PLAY; - submenu->open_flag = TRUE; - submenu->after_mode = 7; - submenu->unk_164 = 0; - mMl_clear_mail(&submenu->mail); - submenu->item_p = &submenu->items[0]; - submenu->item_num = mPr_POCKETS_SLOT_COUNT; - - item = submenu->item_p; - for (i = 0; i < submenu->item_num; i++) { - item->item = EMPTY_NO; - item->slot_no = mPr_POCKETS_SLOT_COUNT; - item++; - } - - if (submenu->mode != 4) { - if ( - (submenu->menu_type == mSM_OVL_LEDIT && submenu->param0 == 0) || - Common_Get(now_private)->gender == mPr_SEX_MALE - ) { - sAdo_SpecChange(5); - } - else { - sAdo_SpecChange(6); - } - - sAdo_SetVoiceMode(0); - } - } } static void mSM_move_Play(Submenu* submenu) { - (*submenu->move_proc)(submenu); + (*submenu->move_proc)(submenu); } static void mSM_move_End(Submenu* submenu) { - mSM_dlftbl_c* dlftbl = &SubmenuArea_dlftbl[mSM_DLF_SUBMENU_OVL]; - GAME_PLAY* play = (GAME_PLAY*)gamePT; + mSM_dlftbl_c* dlftbl = &SubmenuArea_dlftbl[mSM_DLF_SUBMENU_OVL]; + GAME_PLAY* play = (GAME_PLAY*)gamePT; - (*submenu->move_proc)(submenu); - submenu->process_status = mSM_PROCESS_WAIT; - submenu->menu_type = mSM_OVL_NONE; - submenu->wait_timer = 2; - submenu->open_flag = FALSE; - SetGameFrame(1); + (*submenu->move_proc)(submenu); + submenu->process_status = mSM_PROCESS_WAIT; + submenu->menu_type = mSM_OVL_NONE; + submenu->wait_timer = 2; + submenu->open_flag = FALSE; + SetGameFrame(1); - if (submenu->mode != 4) { - mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); - submenu->mode = 0; - mSc_dmacopy_all_exchange_bank(&play->object_exchange); - SubmenuArea_DoUnlink(dlftbl, submenu); - load_player(submenu); - mSM_load_player_anime(play); - submenu->disable_start_btn_timer = 1; + if (submenu->mode != 4) { + mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); + submenu->mode = 0; + mSc_dmacopy_all_exchange_bank(&play->object_exchange); + SubmenuArea_DoUnlink(dlftbl, submenu); + load_player(submenu); + mSM_load_player_anime(play); + submenu->start_refuse_timer = 1; - if (submenu->after_mode == 12) { - mPlib_request_main_demo_wait_from_submenu((ACTOR*)submenu->overlay->menu_info[mSM_OVL_MSCORE].data2); + if (submenu->after_mode == 12) { + mPlib_request_main_demo_wait_from_submenu((ACTOR*)submenu->overlay->menu_info[mSM_OVL_MSCORE].data2); + } + + if (mMsg_Check_main_hide(msg_win) == FALSE && mMsg_Check_not_series_main_wait(msg_win)) { + mMsg_sound_spec_change_voice(msg_win); + } } - - if (mMsg_Check_main_hide(msg_win) == FALSE && mMsg_Check_not_series_main_wait(msg_win)) { - mMsg_sound_spec_change_voice(msg_win); - } - } } extern void mSM_submenu_move(Submenu* submenu) { - static SUBMENU_PROC move_proc[mSM_PROCESS_NUM] = { - &mSM_move_Wait, - &mSM_move_PREWait, - &mSM_move_LINKWait, - &mSM_move_Play, - &mSM_move_End - }; + static SUBMENU_PROC move_proc[mSM_PROCESS_NUM] = { &mSM_move_Wait, &mSM_move_PREWait, &mSM_move_LINKWait, + &mSM_move_Play, &mSM_move_End }; - (*move_proc[submenu->process_status])(submenu); + (*move_proc[submenu->process_status])(submenu); } extern void mSM_submenu_draw(Submenu* submenu, GAME* game) { - if ( - submenu->mode >= 3 && - submenu->process_status == mSM_PROCESS_PLAY && - SubmenuArea_visit == &SubmenuArea_dlftbl[mSM_DLF_SUBMENU_OVL] - ) { - (*submenu->draw_proc)(submenu, game); - } + if (submenu->mode >= 3 && submenu->process_status == mSM_PROCESS_PLAY && + SubmenuArea_visit == &SubmenuArea_dlftbl[mSM_DLF_SUBMENU_OVL]) { + (*submenu->draw_proc)(submenu, game); + } } static int mSM_check_item_for_furniture(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; - int cat = ITEM_NAME_GET_CAT(item); - int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; + int cat = ITEM_NAME_GET_CAT(item); + int res = FALSE; - if ( - item != EMPTY_NO && - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && - cat != ITEM1_CAT_FISH && - cat != ITEM1_CAT_KABU && - cat != ITEM1_CAT_INSECT && - item != ITM_KNIFE_AND_FORK && - !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) - ) { - res = TRUE; - } + if (item != EMPTY_NO && mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && cat != ITEM1_CAT_FISH && cat != ITEM1_CAT_KABU && + cat != ITEM1_CAT_INSECT && item != ITM_KNIFE_AND_FORK && + !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12)) { + res = TRUE; + } - return res; + return res; } static int mSM_check_item_for_quest(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; - int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; + int res = FALSE; - if ( - item != EMPTY_NO && - !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && - item != ITM_KNIFE_AND_FORK && - !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4) - ) { - res = TRUE; - } + if (item != EMPTY_NO && !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && + item != ITM_KNIFE_AND_FORK && !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4)) { + res = TRUE; + } - return res; + return res; } static int mSM_check_item_for_sell(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; - int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; + int res = FALSE; - if ( - item != EMPTY_NO && - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - (ITEM_NAME_GET_TYPE(item) != NAME_TYPE_ITEM1 || ITEM_NAME_GET_CAT(item) != ITEM1_CAT_MONEY) && - !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && - item != ITM_KNIFE_AND_FORK && - !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4) - ) { - res = TRUE; - } + if (item != EMPTY_NO && mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + (ITEM_NAME_GET_TYPE(item) != NAME_TYPE_ITEM1 || ITEM_NAME_GET_CAT(item) != ITEM1_CAT_MONEY) && + !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && item != ITM_KNIFE_AND_FORK && + !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4)) { + res = TRUE; + } - return res; + return res; } static int mSM_check_item_for_give(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; - int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; + int res = FALSE; - if ( - item != EMPTY_NO && - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && - item != ITM_KNIFE_AND_FORK && - !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4) - ) { - res = TRUE; - } + if (item != EMPTY_NO && mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && item != ITM_KNIFE_AND_FORK && + !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4)) { + res = TRUE; + } - return res; + return res; } static int mSM_check_item_for_take(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; - int cat = ITEM_NAME_GET_CAT(item); - int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; + int cat = ITEM_NAME_GET_CAT(item); + int res = FALSE; - if ( - item != EMPTY_NO && - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && - item != ITM_KNIFE_AND_FORK && - !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4) && - ( - param_2 == 0 || - ( - ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && - ((cat == ITEM1_CAT_FISH && param_2 == 1) || - (cat == ITEM1_CAT_INSECT && param_2 == 2)) - ) - ) - ) { - res = TRUE; - } + if (item != EMPTY_NO && mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && item != ITM_KNIFE_AND_FORK && + !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4) && + (param_2 == 0 || (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && + ((cat == ITEM1_CAT_FISH && param_2 == 1) || (cat == ITEM1_CAT_INSECT && param_2 == 2))))) { + res = TRUE; + } - return res; + return res; } static int mSM_check_item_for_minidisk(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; - if ( - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && - ITEM_NAME_GET_CAT(item) == ITEM1_CAT_MINIDISK - ) { - return TRUE; - } + if (mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_CAT(item) == ITEM1_CAT_MINIDISK) { + return TRUE; + } - return FALSE; + return FALSE; } static int mSM_check_item_for_shrine(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - if ( - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_QUEST && - mQst_CheckLimitbyPossessionIdx(slot_no) - ) { - return TRUE; - } + Private_c* priv = Common_Get(now_private); + if (mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_QUEST && + mQst_CheckLimitbyPossessionIdx(slot_no)) { + return TRUE; + } - return FALSE; + return FALSE; } static int mSM_check_item_for_entrust(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; - int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; + int res = FALSE; - if ( - item == EMPTY_NO || - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - (ITEM_NAME_GET_TYPE(item) != NAME_TYPE_ITEM1 || ITEM_NAME_GET_CAT(item) != ITEM1_CAT_MONEY) && - !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && - item != ITM_KNIFE_AND_FORK && - !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4) - ) { - res = TRUE; - } + if (item == EMPTY_NO || + mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + (ITEM_NAME_GET_TYPE(item) != NAME_TYPE_ITEM1 || ITEM_NAME_GET_CAT(item) != ITEM1_CAT_MONEY) && + !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) && item != ITM_KNIFE_AND_FORK && + !(item >= ITM_SPIRIT0 && item <= ITM_SPIRIT4)) { + res = TRUE; + } - return res; + return res; } static int mSM_check_item_for_exchange(int slot_no, int exchange_id) { - int res = FALSE; - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; + int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; - if ( - item != EMPTY_NO && mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - item != ITM_SIGNBOARD && item != ITM_KNIFE_AND_FORK && !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) - ) { - if ( - (ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_CAT(item) == ITEM1_CAT_FISH) && - (ITEM_NAME_GET_TYPE(exchange_id) != NAME_TYPE_ITEM1 || ITEM_NAME_GET_CAT(exchange_id) != ITEM1_CAT_FISH) - ) { - PLAYER_ACTOR* player = GET_PLAYER_ACTOR_NOW(); - xyz_t water_pos; + if (item != EMPTY_NO && mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + item != ITM_SIGNBOARD && item != ITM_KNIFE_AND_FORK && + !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12)) { + if ((ITEM_NAME_GET_TYPE(item) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_CAT(item) == ITEM1_CAT_FISH) && + (ITEM_NAME_GET_TYPE(exchange_id) != NAME_TYPE_ITEM1 || ITEM_NAME_GET_CAT(exchange_id) != ITEM1_CAT_FISH)) { + PLAYER_ACTOR* player = GET_PLAYER_ACTOR_NOW(); + xyz_t water_pos; - if (mCoBG_SearchWaterLimitDistN(&water_pos, player->actor_class.world.position, player->actor_class.shape_info.rotation.y, 120.0f, 12) == FALSE) { - return FALSE; - } + if (mCoBG_SearchWaterLimitDistN(&water_pos, player->actor_class.world.position, + player->actor_class.shape_info.rotation.y, 120.0f, 12) == FALSE) { + return FALSE; + } - xyz_t_move(&((GAME_PLAY*)gamePT)->submenu.water_pos, &water_pos); + xyz_t_move(&((GAME_PLAY*)gamePT)->submenu.water_pos, &water_pos); + } + + res = TRUE; } - res = TRUE; - } - - return res; + return res; } static int mSM_check_item_for_curator(int slot_no, int param_2) { - Private_c* priv = Common_Get(now_private); - mActor_name_t item = priv->inventory.pockets[slot_no]; - int res = FALSE; + Private_c* priv = Common_Get(now_private); + mActor_name_t item = priv->inventory.pockets[slot_no]; + int res = FALSE; - if ( - item != EMPTY_NO && - mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && - item != ITM_KNIFE_AND_FORK && - !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12) - ) { - res = TRUE; - } + if (item != EMPTY_NO && mPr_GET_ITEM_COND(priv->inventory.item_conditions, slot_no) == mPr_ITEM_COND_NORMAL && + item != ITM_KNIFE_AND_FORK && !(item >= ITM_EXCERCISE_CARD00 && item <= ITM_EXCERCISE_CARD12)) { + res = TRUE; + } - return res; + return res; } typedef int (*mSM_INVENTORY_CHECK_PROC)(int, int); extern int mSM_check_open_inventory_itemlist(int type, int param_2) { - static mSM_INVENTORY_CHECK_PROC check_process[mSM_IV_OPEN_NUM] = { - NULL, - NULL, - &mSM_check_item_for_entrust, - NULL, - &mSM_check_item_for_quest, - &mSM_check_item_for_sell, - &mSM_check_item_for_give, - NULL, - &mSM_check_item_for_take, - &mSM_check_item_for_furniture, - &mSM_check_item_for_minidisk, - &mSM_check_item_for_shrine, - NULL, - &mSM_check_item_for_exchange, - NULL, - &mSM_check_item_for_curator, - NULL - }; + static mSM_INVENTORY_CHECK_PROC check_process[mSM_IV_OPEN_NUM] = { NULL, + NULL, + &mSM_check_item_for_entrust, + NULL, + &mSM_check_item_for_quest, + &mSM_check_item_for_sell, + &mSM_check_item_for_give, + NULL, + &mSM_check_item_for_take, + &mSM_check_item_for_furniture, + &mSM_check_item_for_minidisk, + &mSM_check_item_for_shrine, + NULL, + &mSM_check_item_for_exchange, + NULL, + &mSM_check_item_for_curator, + NULL }; - mSM_INVENTORY_CHECK_PROC check_proc = check_process[type]; - int i; - int res = 0; + mSM_INVENTORY_CHECK_PROC check_proc = check_process[type]; + int i; + int res = 0; - if (check_proc == NULL) { - return 0xFFFF; /* all slots are valid */ - } - - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if ((*check_proc)(i, param_2) != FALSE) { - res |= (1 << i); // slot is valid + if (check_proc == NULL) { + return 0xFFFF; /* all slots are valid */ } - } - return res; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if ((*check_proc)(i, param_2) != FALSE) { + res |= (1 << i); // slot is valid + } + } + + return res; } static char* mSM_Object_Exchange_keep_new(GAME_PLAY* play, s16 bank_id, size_t size) { - Object_Exchange_c* exchange = &play->object_exchange; - Object_Bank_c* bank = &exchange->banks[exchange->bank_idx]; + Object_Exchange_c* exchange = &play->object_exchange; + Object_Bank_c* bank = &exchange->banks[exchange->bank_idx]; - bank->bank_id = bank_id; - bank->dma_start = exchange->next_bank_ram_address; - bank->ram_start = exchange->next_bank_ram_address; - bank->size = size; + bank->bank_id = bank_id; + bank->dma_start = exchange->next_bank_ram_address; + bank->ram_start = exchange->next_bank_ram_address; + bank->size = size; - if (exchange->bank_idx < mSc_OBJECT_BANK_NUM - 1) { - exchange->next_bank_ram_address = (char*)ALIGN_NEXT((u32)(exchange->next_bank_ram_address + size), 16); - exchange->bank_idx++; - } + if (exchange->bank_idx < mSc_OBJECT_BANK_NUM - 1) { + exchange->next_bank_ram_address = (char*)ALIGN_NEXT((u32)(exchange->next_bank_ram_address + size), 16); + exchange->bank_idx++; + } - return bank->dma_start; + return bank->dma_start; } static void mSM_Object_Exchange_keep_new_MenuTexAndPallet(GAME_PLAY* play, int idx) { - char* tex_p = mSM_Object_Exchange_keep_new(play, ACTOR_OBJ_BANK_14, (32*32)/2); - char* pal_p = mSM_Object_Exchange_keep_new(play, ACTOR_OBJ_BANK_15, 16 * sizeof(u16)); + char* tex_p = mSM_Object_Exchange_keep_new(play, ACTOR_OBJ_BANK_14, (32 * 32) / 2); + char* pal_p = mSM_Object_Exchange_keep_new(play, ACTOR_OBJ_BANK_15, 16 * sizeof(u16)); - play->submenu_ground_tex[idx] = tex_p; - play->submenu_ground_pallet[idx] = pal_p; - mPlib_Load_PlayerTexAndPallet(tex_p, pal_p, Common_Get(now_private)->backgound_texture - ITM_CLOTH_START); + play->submenu_ground_tex[idx] = tex_p; + play->submenu_ground_pallet[idx] = pal_p; + mPlib_Load_PlayerTexAndPallet(tex_p, pal_p, Common_Get(now_private)->backgound_texture - ITM_CLOTH_START); } extern void mSM_Object_Exchange_keep_new_Menu(GAME_PLAY* play) { - play->submenu_ground_idx = 0; - mSM_Object_Exchange_keep_new_MenuTexAndPallet(play, 0); - mSM_Object_Exchange_keep_new_MenuTexAndPallet(play, 1); + play->submenu_ground_idx = 0; + mSM_Object_Exchange_keep_new_MenuTexAndPallet(play, 0); + mSM_Object_Exchange_keep_new_MenuTexAndPallet(play, 1); } extern u8* mSM_Get_ground_tex_p(GAME_PLAY* play) { - int idx = play->submenu_ground_idx; + int idx = play->submenu_ground_idx; - if (idx < 0) { - return NULL; - } + if (idx < 0) { + return NULL; + } - return (u8*)play->submenu_ground_tex[idx]; + return (u8*)play->submenu_ground_tex[idx]; } extern u16* mSM_Get_ground_pallet_p(GAME_PLAY* play) { - int idx = play->submenu_ground_idx; + int idx = play->submenu_ground_idx; - if (idx < 0) { - return NULL; - } + if (idx < 0) { + return NULL; + } - return (u16*)play->submenu_ground_pallet[idx]; + return (u16*)play->submenu_ground_pallet[idx]; }