diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 43837485..6f9ec3c1 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -459,6 +459,11 @@ ac_my_indoor.c: .text: [0x8046EE38, 0x80470288] .rodata: [0x80644A88, 0x80644A98] .data: [0x806870F0, 0x806873E8] +ac_my_room.c: + .text: [0x80470288, 0x80482D9C] + .rodata: [0x80644A98, 0x80644C28] + .data: [0x806873E8, 0x8068A378] + .bss: [0x812FBEB0, 0x812FC5E0] ac_psnowman.c: .text: [0x80484098, 0x80484694] .rodata: [0x80644C30, 0x80644C60] diff --git a/include/MSL_C/math.h b/include/MSL_C/math.h index 01e4da80..3fc61d26 100644 --- a/include/MSL_C/math.h +++ b/include/MSL_C/math.h @@ -13,6 +13,7 @@ extern "C" { #define SQRT2 (1.4142135623730950488016887242097) #define F_SQRT2 ((f32)SQRT2) +#define F_SQRT2_DIV2 (0.707106f) #define SQRTF(f) (__frsqrte(f)) diff --git a/include/ac_furniture.h b/include/ac_furniture.h index 9716da25..3e27ccaa 100644 --- a/include/ac_furniture.h +++ b/include/ac_furniture.h @@ -66,6 +66,7 @@ enum { }; enum { + aFTR_INTERACTION_NONE = 0, aFTR_INTERACTION_STORAGE_DRAWERS = 1, // dressers aFTR_INTERACTION_STORAGE_WARDROBE = 2, // double doors aFTR_INTERACTION_STORAGE_CLOSET = 4, // single door @@ -122,6 +123,21 @@ enum { aFTR_CONTACT_ACTION_NUM }; +enum { + aFTR_CONTACT_ACTION_TYPE_CHAIR1, + aFTR_CONTACT_ACTION_TYPE_CHAIR4, + aFTR_CONTACT_ACTION_TYPE_SOFA, + aFTR_CONTACT_ACTION_TYPE_BED_SINGLE, + aFTR_CONTACT_ACTION_TYPE_BED_DOUBLE, + + aFTR_CONTACT_ACTION_TYPE_NUM +}; + +#define aFTR_CHK_CONTACT_ACTION(cnt, action) (((cnt) >> (aFTR_CONTACT_ACTION_TYPE_##action)) & 1) +#define aFTR_CHK_CHAIR(cnt) \ + (aFTR_CHK_CONTACT_ACTION(cnt, CHAIR1) || aFTR_CHK_CONTACT_ACTION(cnt, CHAIR4) || aFTR_CHK_CONTACT_ACTION(cnt, SOFA)) +#define aFTR_CHK_BED(cnt) (aFTR_CHK_CONTACT_ACTION(cnt, BED_SINGLE) || aFTR_CHK_CONTACT_ACTION(cnt, BED_DOUBLE)) + enum { aFTR_SET_TYPE_NORMAL, /* Can't be placed on top and is not a table (layer0) */ aFTR_SET_TYPE_SURFACE, /* Is a surface (layer0) */ @@ -130,6 +146,14 @@ enum { aFTR_SET_TYPE_NUM }; +enum { + aFTR_KANKYO_MAP_NONE, + aFTR_KANKYO_MAP_OPA, + aFTR_KANKYO_MAP_XLU, + + aFTR_KANKYO_MAP_NUM +}; + typedef void (*aFTR_FTR_CT_PROC)(FTR_ACTOR*, u8*); typedef void (*aFTR_FTR_MOVE_PROC)(FTR_ACTOR*, ACTOR*, GAME*, u8*); typedef void (*aFTR_FTR_DRAW_PROC)(FTR_ACTOR*, ACTOR*, GAME*, u8*); @@ -190,10 +214,10 @@ struct furniture_actor_s { xyz_t position; xyz_t last_position; xyz_t target_position; - int target_distance; /* distance to target position */ - f32 player_distance; /* distance to the player */ - f32 angle_y; /* current Y angle */ - f32 angle_y_target; /* goal Y angle */ + int target_direction; /* direction to target position */ + f32 player_distance; /* distance to the player */ + f32 angle_y; /* current Y angle */ + f32 angle_y_target; /* goal Y angle */ s16 state; u8 shape_type; /* current size & shape (rotation) */ u8 original_shape_type; /* original size & shape (rotation) */ diff --git a/include/ac_my_room.h b/include/ac_my_room.h index 9c602d63..95de307d 100644 --- a/include/ac_my_room.h +++ b/include/ac_my_room.h @@ -149,7 +149,7 @@ typedef struct room_pickup_s { int picking_up_flag; s16 layer; s16 dust_effect_timer; - u16 icon; + s16 icon; } aMR_pickup_info_c; typedef struct room_rsv_ftr_s { @@ -291,6 +291,11 @@ extern FTR_ACTOR* aMR_GetParentFactor(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor extern s16 aMR_GetParentAngleOffset(FTR_ACTOR* ftr_actor, ACTOR* my_room_actorx); extern void aMR_SetSurprise(ACTOR* my_room_actor, s16 rot); extern void aMR_RadioCommonMove(FTR_ACTOR* ftr_actor, ACTOR* my_room_actorx); +extern void aMR_SaveWaltzTempo2(void); +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); #ifdef __cplusplus } diff --git a/include/audio.h b/include/audio.h index 99b2f5bc..f71359ae 100644 --- a/include/audio.h +++ b/include/audio.h @@ -58,7 +58,7 @@ extern void sAdo_OngenTrgStart(u16 id, const xyz_t* pos); extern void sAdo_SetOutMode(u8 mode); extern void sAdo_SetVoiceMode(u8 mode); -extern void sAdo_FloorTrgStart(u16 id, const xyz_t* pos); +extern void sAdo_FloorTrgStart(u8 id, const xyz_t* pos); extern void sAdo_RhythmStart(u32 id, s8 type, s8 wait); extern void sAdo_RhythmStop(u32 id); diff --git a/include/audio_defs.h b/include/audio_defs.h index e3553a44..b912a55c 100644 --- a/include/audio_defs.h +++ b/include/audio_defs.h @@ -60,6 +60,9 @@ typedef enum audio_sound_effects { NA_SE_TOOL_BROKEN2, NA_SE_TOOL_BROKEN3, + NA_SE_STONECOIN_ROLL = 0x7D, + NA_SE_STONECOIN_DRAG = 0x7E, + NA_SE_ROD_STROKE = 0x109, NA_SE_ROD_BACK, @@ -86,6 +89,7 @@ typedef enum audio_sound_effects { NA_SE_166 = 0x166, NA_SE_UCHIWA = 0x167, + NA_SE_LAWNMOWER = 0x177, NA_SE_SCOOP_SHIGEMI = 0x401, @@ -98,6 +102,8 @@ typedef enum audio_sound_effects { NA_SE_BED_NEGAERI, NA_SE_BED_OUT, + NA_SE_ROTATE = 0x41A, + NA_SE_SOFT_CHAIR_SIT = 0x41F, NA_SE_HARD_CHAIR_SIT, NA_SE_BUBU_CHAIR_SIT, diff --git a/include/jaudio_NES/game64.h b/include/jaudio_NES/game64.h index e75e8474..ed32bfef 100644 --- a/include/jaudio_NES/game64.h +++ b/include/jaudio_NES/game64.h @@ -29,7 +29,7 @@ extern void Na_OngenPos(u32, u8, u16, f32); extern void Na_OngenTrgStart(u16, u16, f32); extern void Na_SetOutMode(u8); extern void Na_SetVoiceMode(u8); -extern void Na_FloorTrgStart(u16, u16, f32); +extern void Na_FloorTrgStart(u8, u16, f32); extern void Na_Pause(u8); extern void Na_RhythmPos(u32, u8, u16, f32); extern void Na_SpecChange(int); diff --git a/include/m_actor.h b/include/m_actor.h index 8a4d1bd2..c7a193de 100644 --- a/include/m_actor.h +++ b/include/m_actor.h @@ -1187,16 +1187,9 @@ extern void Actor_get_overlay_area(ACTOR_DLFTBL* dlftbl, int unused, size_t allo extern void Actor_init_actor_class(ACTOR* actor, ACTOR_PROFILE* profile, ACTOR_DLFTBL* dlftbl, GAME_PLAY* play, int bank_idx, f32 x, f32 y, f32 z, s16 rot_x, s16 rot_y, s16 rot_z, s8 block_x, s8 block_z, s16 move_actor_list_idx, mActor_name_t name_id, s16 arg); -#ifndef MUST_MATCH extern ACTOR* Actor_info_make_actor(Actor_info* actor_info, GAME* game, s16 profile_no, f32 x, f32 y, f32 z, s16 rot_x, s16 rot_y, s16 rot_z, s8 block_x, s8 block_z, s16 move_actor_list_idx, mActor_name_t name_id, s16 arg, s8 npc_info_idx, int data_bank_idx); -#else -extern asm ACTOR* Actor_info_make_actor(Actor_info* actor_info, GAME* game, s16 profile_no, f32 x, f32 y, f32 z, - s16 rot_x, s16 rot_y, s16 rot_z, s8 block_x, s8 block_z, - s16 move_actor_list_idx, mActor_name_t name_id, s16 arg, s8 npc_info_idx, - int data_bank_idx); -#endif extern ACTOR* Actor_info_make_child_actor(Actor_info* actor_info, ACTOR* parent_actor, GAME* game, s16 profile, f32 x, f32 y, f32 z, s16 rot_x, s16 rot_y, s16 rot_z, s16 move_actor_list_idx, mActor_name_t name_id, s16 arg, int data_bank_idx); diff --git a/include/m_field_info.h b/include/m_field_info.h index e5455788..9b646568 100644 --- a/include/m_field_info.h +++ b/include/m_field_info.h @@ -15,8 +15,8 @@ extern "C" { #define mFI_UNIT_BASE_SIZE 40 #define mFI_UNIT_BASE_SIZE_F ((f32)mFI_UNIT_BASE_SIZE) -#define mFI_UT_WORLDSIZE_X 40 -#define mFI_UT_WORLDSIZE_Z 40 +#define mFI_UT_WORLDSIZE_X mFI_UNIT_BASE_SIZE +#define mFI_UT_WORLDSIZE_Z mFI_UNIT_BASE_SIZE #define mFI_UT_WORLDSIZE_X_F ((f32)mFI_UT_WORLDSIZE_X) #define mFI_UT_WORLDSIZE_Z_F ((f32)mFI_UT_WORLDSIZE_Z) @@ -30,6 +30,8 @@ extern "C" { #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_POS2UT(pos) ((int)((pos) / mFI_UNIT_BASE_SIZE_F)) + #define mFI_ROW_TO_CHARSTR(row) ((row) + 'A') #define mFI_COL_TO_CHARSTR(col) ((col) + '0') @@ -39,24 +41,24 @@ extern "C" { #define mFI_MAX_SHELLS_PER_BLOCK 4 enum field_type { - mFI_FIELDTYPE_FG, - mFI_FIELDTYPE_1, - mFI_FIELDTYPE_2, - mFI_FIELDTYPE_ROOM, - mFI_FIELDTYPE_NPC_ROOM, - mFI_FIELDTYPE_DEMO, - mFI_FIELDTYPE_PLAYER_ROOM, + mFI_FIELDTYPE_FG, + mFI_FIELDTYPE_1, + mFI_FIELDTYPE_2, + mFI_FIELDTYPE_ROOM, + mFI_FIELDTYPE_NPC_ROOM, + mFI_FIELDTYPE_DEMO, + mFI_FIELDTYPE_PLAYER_ROOM, - mFI_FIELDTYPE_NUM + mFI_FIELDTYPE_NUM }; enum field_type2 { - mFI_FIELDTYPE2_FG, - mFI_FIELDTYPE2_PLAYER_ROOM, - mFI_FIELDTYPE2_NPC_ROOM, - mFI_FIELDTYPE2_ROOM, + mFI_FIELDTYPE2_FG, + mFI_FIELDTYPE2_PLAYER_ROOM, + mFI_FIELDTYPE2_NPC_ROOM, + mFI_FIELDTYPE2_ROOM, - mFI_FIELDTYPE2_NUM + mFI_FIELDTYPE2_NUM }; #define mFI_TO_FIELD_ID(type, index) (((type) << 12) | (index)) @@ -64,134 +66,126 @@ enum field_type2 { #define mFI_TYPE(type) ((type) << 12) enum field_room { - /* TODO: others */ - mFI_FIELD_FG = mFI_TO_FIELD_ID(mFI_FIELDTYPE_FG, 0), + /* TODO: others */ + mFI_FIELD_FG = mFI_TO_FIELD_ID(mFI_FIELDTYPE_FG, 0), - mFI_FIELD_ROOM0 = mFI_TO_FIELD_ID(mFI_FIELDTYPE_ROOM, 0), - mFI_FIELD_ROOM_SHOP0, /* 0x3001 */ - mFI_FIELD_ROOM_BROKER_SHOP, /* 0x3002 */ - mFI_FIELD_ROOM_POST_OFFICE, /* 0x3003 */ - mFI_FIELD_ROOM_POLICE_BOX, /* 0x3004 */ - mFI_FIELD_ROOM_BUGGY, /* 0x3005 */ - mFI_FIELD_ROOM_SHOP1, /* 0x3006 */ - mFI_FIELD_ROOM_SHOP2, /* 0x3007 */ - mFI_FIELD_ROOM_SHOP3_1, /* 0x3008 */ - mFI_FIELD_ROOM_SHOP3_2, /* 0x3009 */ - mFI_FIELD_ROOM_KAMAKURA, /* 0x300A */ - mFI_FIELD_ROOM_MUSEUM_ENTRANCE, /* 0x300B */ - mFI_FIELD_ROOM_MUSEUM_PAINTING, /* 0x300C */ - mFI_FIELD_ROOM_MUSEUM_FOSSIL, /* 0x300D */ - mFI_FIELD_ROOM_MUSEUM_INSECT, /* 0x300E */ - mFI_FIELD_ROOM_MUSEUM_FISH, /* 0x300F */ - mFI_FIELD_ROOM_NEEDLEWORK, /* 0x3010 */ - mFI_FIELD_ROOM_LIGHTHOUSE, /* 0x3011 */ - mFI_FIELD_ROOM_TENT, /* 0x3012 */ + mFI_FIELD_ROOM0 = mFI_TO_FIELD_ID(mFI_FIELDTYPE_ROOM, 0), + mFI_FIELD_ROOM_SHOP0, /* 0x3001 */ + mFI_FIELD_ROOM_BROKER_SHOP, /* 0x3002 */ + mFI_FIELD_ROOM_POST_OFFICE, /* 0x3003 */ + mFI_FIELD_ROOM_POLICE_BOX, /* 0x3004 */ + mFI_FIELD_ROOM_BUGGY, /* 0x3005 */ + mFI_FIELD_ROOM_SHOP1, /* 0x3006 */ + mFI_FIELD_ROOM_SHOP2, /* 0x3007 */ + mFI_FIELD_ROOM_SHOP3_1, /* 0x3008 */ + mFI_FIELD_ROOM_SHOP3_2, /* 0x3009 */ + mFI_FIELD_ROOM_KAMAKURA, /* 0x300A */ + mFI_FIELD_ROOM_MUSEUM_ENTRANCE, /* 0x300B */ + mFI_FIELD_ROOM_MUSEUM_PAINTING, /* 0x300C */ + mFI_FIELD_ROOM_MUSEUM_FOSSIL, /* 0x300D */ + mFI_FIELD_ROOM_MUSEUM_INSECT, /* 0x300E */ + mFI_FIELD_ROOM_MUSEUM_FISH, /* 0x300F */ + mFI_FIELD_ROOM_NEEDLEWORK, /* 0x3010 */ + mFI_FIELD_ROOM_LIGHTHOUSE, /* 0x3011 */ + mFI_FIELD_ROOM_TENT, /* 0x3012 */ - mFI_FIELD_NPCROOM0 = mFI_TO_FIELD_ID(mFI_FIELDTYPE_NPC_ROOM, 0), - mFI_FIELD_NPCROOM_FIELD_TOOL_INSIDE, + mFI_FIELD_NPCROOM0 = mFI_TO_FIELD_ID(mFI_FIELDTYPE_NPC_ROOM, 0), + mFI_FIELD_NPCROOM_FIELD_TOOL_INSIDE, - mFI_FIELD_DEMO_STARTDEMO = mFI_TO_FIELD_ID(mFI_FIELDTYPE_DEMO, 0), - mFI_FIELD_DEMO_STARTDEMO2, - mFI_FIELD_DEMO_PLAYERSELECT, - mFI_FIELD_DEMO_STARTDEMO3, + mFI_FIELD_DEMO_STARTDEMO = mFI_TO_FIELD_ID(mFI_FIELDTYPE_DEMO, 0), + mFI_FIELD_DEMO_STARTDEMO2, + mFI_FIELD_DEMO_PLAYERSELECT, + mFI_FIELD_DEMO_STARTDEMO3, - mFI_FIELD_PLAYER0_ROOM = mFI_TO_FIELD_ID(mFI_FIELDTYPE_PLAYER_ROOM, 0), - mFI_FIELD_PLAYER1_ROOM, - mFI_FIELD_PLAYER2_ROOM, - mFI_FIELD_PLAYER3_ROOM, + mFI_FIELD_PLAYER0_ROOM = mFI_TO_FIELD_ID(mFI_FIELDTYPE_PLAYER_ROOM, 0), + mFI_FIELD_PLAYER1_ROOM, + mFI_FIELD_PLAYER2_ROOM, + mFI_FIELD_PLAYER3_ROOM, - /* TODO: others */ + /* TODO: others */ }; -#define mFI_GET_PLAYER_ROOM_NO(field_id) (((field_id)-mFI_FIELD_PLAYER0_ROOM) & 3) -#define mFI_IS_PLAYER_ROOM(field_id) \ - ((field_id) == mFI_FIELD_PLAYER0_ROOM || (field_id) == mFI_FIELD_PLAYER1_ROOM || \ - (field_id) == mFI_FIELD_PLAYER2_ROOM || (field_id) == mFI_FIELD_PLAYER3_ROOM) +#define mFI_GET_PLAYER_ROOM_NO(field_id) (((field_id) - mFI_FIELD_PLAYER0_ROOM) & 3) +#define mFI_IS_PLAYER_ROOM(field_id) \ + ((field_id) == mFI_FIELD_PLAYER0_ROOM || (field_id) == mFI_FIELD_PLAYER1_ROOM || \ + (field_id) == mFI_FIELD_PLAYER2_ROOM || (field_id) == mFI_FIELD_PLAYER3_ROOM) /* "wade" between acres (acre transition) */ enum player_wade_state { - mFI_WADE_NONE, - mFI_WADE_START, - mFI_WADE_INPROGRESS, - mFI_WADE_END, - mFI_WADE_ERROR, + mFI_WADE_NONE, + mFI_WADE_START, + mFI_WADE_INPROGRESS, + mFI_WADE_END, + mFI_WADE_ERROR, - mFI_WADE_NUM + mFI_WADE_NUM }; enum { - mFI_DEPOSIT_ON, - mFI_DEPOSIT_OFF, - mFI_DEPOSIT_GET, + mFI_DEPOSIT_ON, + mFI_DEPOSIT_OFF, + mFI_DEPOSIT_GET, - mFI_DEPOSIT_NUM + mFI_DEPOSIT_NUM }; enum { - mFI_MOVEDIR_NONE, - mFI_MOVEDIR_RIGHT, - mFI_MOVEDIR_LEFT, - mFI_MOVEDIR_UP, - mFI_MOVEDIR_DOWN, + mFI_MOVEDIR_NONE, + mFI_MOVEDIR_RIGHT, + mFI_MOVEDIR_LEFT, + mFI_MOVEDIR_UP, + mFI_MOVEDIR_DOWN, - mFI_MOVEDIR_NUM + mFI_MOVEDIR_NUM }; /* Not sure about these other than the island one */ +enum { mFI_CLIMATE_0, mFI_CLIMATE_ISLAND, mFI_CLIMATE_2, mFI_CLIMATE_3, mFI_CLIMATE_4, mFI_CLIMATE_5, mFI_CLIMATE_NUM }; + enum { - mFI_CLIMATE_0, - mFI_CLIMATE_ISLAND, - mFI_CLIMATE_2, - mFI_CLIMATE_3, - mFI_CLIMATE_4, - mFI_CLIMATE_5, - mFI_CLIMATE_NUM + mFI_DIGSTATUS_MISS, + mFI_DIGSTATUS_CANCEL, + mFI_DIGSTATUS_FILLIN, + mFI_DIGSTATUS_DIG, + mFI_DIGSTATUS_PUT_ITEM, + mFI_DIGSTATUS_GET_ITEM, + + mFI_DIGSTATUS_NUM }; enum { - mFI_DIGSTATUS_MISS, - mFI_DIGSTATUS_CANCEL, - mFI_DIGSTATUS_FILLIN, - mFI_DIGSTATUS_DIG, - mFI_DIGSTATUS_PUT_ITEM, - mFI_DIGSTATUS_GET_ITEM, - - mFI_DIGSTATUS_NUM -}; + mFI_SET_STRUCTURE_SET, + mFI_SET_STRUCTURE_REMOVE, -enum { - mFI_SET_STRUCTURE_SET, - mFI_SET_STRUCTURE_REMOVE, - - mFI_SET_STRUCTURE_NUM + mFI_SET_STRUCTURE_NUM }; /* sizeof(mFI_unit_c) == 0x14 */ typedef struct location_info_s { - /* 0x00 */ int block_x; - /* 0x04 */ int block_z; - /* 0x08 */ int unit_x; - /* 0x0C */ int unit_z; - /* 0x10 */ mActor_name_t* block_data; + /* 0x00 */ int block_x; + /* 0x04 */ int block_z; + /* 0x08 */ int unit_x; + /* 0x0C */ int unit_z; + /* 0x10 */ mActor_name_t* block_data; } mFI_unit_c; typedef struct block_table_s { - s8 block_x; - s8 block_z; + s8 block_x; + s8 block_z; - f32 pos_x; - f32 pos_z; + f32 pos_x; + f32 pos_z; - mActor_name_t* items; + mActor_name_t* items; } mFI_block_tbl_c; typedef struct visible_block_item_info_s { - int count; - mFI_block_tbl_c block_info_tbl[mFM_VISIBLE_BLOCK_NUM]; + int count; + mFI_block_tbl_c block_info_tbl[mFM_VISIBLE_BLOCK_NUM]; } mFI_item_table_c; enum { - mFI_SOUND_SOURCE_POND = 3, // TODO: might not be correct name + mFI_SOUND_SOURCE_POND = 3, // TODO: might not be correct name }; extern void mFI_ClearFieldData(); @@ -269,7 +263,7 @@ extern int mFI_GetItemTable(mFI_item_table_c* item_table, xyz_t wpos, char* file extern int mFI_FGisUpDate(); extern void mFI_SetFGUpData(); extern void mFI_BornItemON(); -//extern MATCH_FORCESTRIP void mFI_BornItemOFF(); +// extern MATCH_FORCESTRIP void mFI_BornItemOFF(); extern int mFI_ItemisBorn(); extern int mFI_ActorisBorn(); extern void mFI_SetBearActor(GAME_PLAY* play, xyz_t wpos, int set_flag); @@ -288,9 +282,10 @@ extern void mFI_SetMoveActorBitData(int bx, int bz, u16 move_actor_bit_data); extern void mFI_SetMoveActorBitData_ON(s16 move_actor_idx, int bx, int bz); extern void mFI_SetMoveActorBitData_OFF(s16 move_actor_idx, int bx, int bz); extern void mFI_MyMoveActorBitData_ON(ACTOR* actor); -//extern MATCH_FORCESTRIP void mFI_MyMoveActorBitData_OFF(ACTOR* actor); +// 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); -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); +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); extern int mFI_UnregistMoveActorList(mActor_name_t actor_name, int bx, int bz); extern int mFI_AddMoveActorList(mActor_name_t actor_name, int bx, int bz, int ut_x, int ut_z, s16 arg); extern mFM_move_actor_c* mFI_MoveActorListDma(int bx, int bz); @@ -302,12 +297,12 @@ extern int mFI_GetNextBlockNum(int* bx, int* bz); extern u16* mFI_GetDepositP(int bx, int bz); extern void mFI_ClearDeposit(int bx, int bz); extern int mFI_GetLineDeposit(u16* deposit, int ut_x); -//extern MATCH_FORCESTRIP void mFI_BlockDepositON(u16* deposit_p, int ut_x, int ut_z); +// extern MATCH_FORCESTRIP void mFI_BlockDepositON(u16* deposit_p, int ut_x, int ut_z); extern void mFI_BlockDepositOFF(u16* deposit_p, int ut_x, int ut_z); extern int mFI_GetBlockDeposit(u16* deposit_p, int ut_x, int ut_z); -//extern MATCH_FORCESTRIP void mFI_BkUtNum2DepositON(int bx, int bz, int ut_x, int ut_z); +// extern MATCH_FORCESTRIP void mFI_BkUtNum2DepositON(int bx, int bz, int ut_x, int ut_z); extern void mFI_BkUtNum2DepositOFF(int bx, int bz, int ut_x, int ut_z); -//extern MATCH_FORCESTRIP int mFI_BkUtNum2DepositGet(int bx, int bz, int ut_x, int ut_z); +// extern MATCH_FORCESTRIP int mFI_BkUtNum2DepositGet(int bx, int bz, int ut_x, int ut_z); extern void mFI_UtNum2DepositON(int ut_x, int ut_z); extern void mFI_UtNum2DepositOFF(int ut_x, int ut_z); extern int mFI_UtNum2DepositGet(int ut_x, int ut_z); @@ -320,12 +315,14 @@ extern int mFI_GetDigStatus(mActor_name_t* item, xyz_t wpos, int golden_shovel); extern void mFI_ClearHoleBlock(int bx, int bz); extern void mFI_ClearBeecomb(int bx, int bz); extern int mFI_SetFGStructure_common(mActor_name_t structure_name, int bx, int bz, int ut_x, int ut_z, int set_type); -extern int mFI_CheckStructureArea(int ut_x, int ut_z, mActor_name_t structure_name, int structure_ut_x, int structure_ut_z); +extern int mFI_CheckStructureArea(int ut_x, int ut_z, mActor_name_t structure_name, int structure_ut_x, + int structure_ut_z); extern mActor_name_t mFI_GetOtherFruit(); extern int mFI_CheckFGNpcOn(mActor_name_t item); extern int mFI_CheckLapPolice(int bx, int bz, int ut_x, int ut_z); extern int mFI_GetWaveUtinBlock(int* ut_x, int* ut_z, int bx, int bz); -extern int mFI_ClearBlockItemRandom_common(mActor_name_t item, int clear_num, mActor_name_t* fg_p, u16* deposit_p, int delete_buried); +extern int mFI_ClearBlockItemRandom_common(mActor_name_t item, int clear_num, mActor_name_t* fg_p, u16* deposit_p, + int delete_buried); extern void mFI_SetFirstSetShell(); extern void mFI_FieldMove(xyz_t player_pos); extern void mFI_PrintNowBGNum(gfxprint_t* gfxprint); diff --git a/include/m_name_table.h b/include/m_name_table.h index ff03aee2..7fa61d47 100644 --- a/include/m_name_table.h +++ b/include/m_name_table.h @@ -2253,6 +2253,7 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define ETC_START 0x8000 #define ETC_AIRPLANE ETC_START #define ETC_BALL (ETC_START + 1) +#define ETC_MY_ROOM (ETC_START + 2) #define ETC_MBG (ETC_START + 3) #define ETC_BOXTRICK (ETC_START + 4) #define ETC_BOXMANAGER (ETC_START + 5) diff --git a/include/m_player.h b/include/m_player.h index 978144e5..21d4ee79 100644 --- a/include/m_player.h +++ b/include/m_player.h @@ -5,6 +5,7 @@ #include "m_actor.h" #include "m_lib.h" #include "c_keyframe.h" +#include "libultra/ultratypes.h" #ifdef __cplusplus extern "C" { @@ -22,314 +23,331 @@ typedef struct player_actor_s PLAYER_ACTOR; #define mPlayer_FORCE_POSITION_ANGLE_ROTZ (1 << 6) enum { - mPlayer_ADDRESSABLE_TRUE, - mPlayer_ADDRESSABLE_FALSE_MOVEMENT, - mPlayer_ADDRESSABLE_FALSE_TALKING, - mPlayer_ADDRESSABLE_FALSE_USING_TOOL, + mPlayer_ADDRESSABLE_TRUE, + mPlayer_ADDRESSABLE_FALSE_MOVEMENT, + mPlayer_ADDRESSABLE_FALSE_TALKING, + mPlayer_ADDRESSABLE_FALSE_USING_TOOL, - mPlayer_ADDRESSABLE_NUM + mPlayer_ADDRESSABLE_NUM }; enum { - mPlayer_INDEX_DMA, - mPlayer_INDEX_INTRO, - mPlayer_INDEX_REFUSE, - mPlayer_INDEX_REFUSE_PICKUP, - mPlayer_INDEX_RETURN_DEMO, - mPlayer_INDEX_RETURN_OUTDOOR, - mPlayer_INDEX_RETURN_OUTDOOR2, - mPlayer_INDEX_WAIT, - mPlayer_INDEX_WALK, - mPlayer_INDEX_RUN, - mPlayer_INDEX_DASH, - mPlayer_INDEX_TUMBLE, - mPlayer_INDEX_TUMBLE_GETUP, - mPlayer_INDEX_TURN_DASH, - mPlayer_INDEX_FALL, - mPlayer_INDEX_WADE, - mPlayer_INDEX_DOOR, - mPlayer_INDEX_OUTDOOR, - mPlayer_INDEX_INVADE, - mPlayer_INDEX_HOLD, - mPlayer_INDEX_PUSH, - mPlayer_INDEX_PULL, - mPlayer_INDEX_ROTATE_FURNITURE, - mPlayer_INDEX_OPEN_FURNITURE, - mPlayer_INDEX_WAIT_OPEN_FURNITURE, - mPlayer_INDEX_CLOSE_FURNITURE, - mPlayer_INDEX_LIE_BED, - mPlayer_INDEX_WAIT_BED, - mPlayer_INDEX_ROLL_BED, - mPlayer_INDEX_STANDUP_BED, - mPlayer_INDEX_PICKUP, - mPlayer_INDEX_PICKUP_JUMP, - mPlayer_INDEX_PICKUP_FURNITURE, - mPlayer_INDEX_PICKUP_EXCHANGE, - mPlayer_INDEX_SITDOWN, - mPlayer_INDEX_SITDOWN_WAIT, - mPlayer_INDEX_STANDUP, - mPlayer_INDEX_SWING_AXE, - mPlayer_INDEX_AIR_AXE, - mPlayer_INDEX_REFLECT_AXE, - mPlayer_INDEX_BROKEN_AXE, - mPlayer_INDEX_SLIP_NET, - mPlayer_INDEX_READY_NET, - mPlayer_INDEX_READY_WALK_NET, - mPlayer_INDEX_SWING_NET, - mPlayer_INDEX_PULL_NET, - mPlayer_INDEX_STOP_NET, - mPlayer_INDEX_NOTICE_NET, - mPlayer_INDEX_PUTAWAY_NET, - mPlayer_INDEX_READY_ROD, - mPlayer_INDEX_CAST_ROD, - mPlayer_INDEX_AIR_ROD, - mPlayer_INDEX_RELAX_ROD, - mPlayer_INDEX_COLLECT_ROD, - mPlayer_INDEX_VIB_ROD, - mPlayer_INDEX_FLY_ROD, - mPlayer_INDEX_NOTICE_ROD, - mPlayer_INDEX_PUTAWAY_ROD, - mPlayer_INDEX_DIG_SCOOP, - mPlayer_INDEX_FILL_SCOOP, - mPlayer_INDEX_REFLECT_SCOOP, - mPlayer_INDEX_AIR_SCOOP, - mPlayer_INDEX_GET_SCOOP, - mPlayer_INDEX_PUTAWAY_SCOOP, - mPlayer_INDEX_PUTIN_SCOOP, - mPlayer_INDEX_TALK, - mPlayer_INDEX_RECIEVE_WAIT, - mPlayer_INDEX_RECIEVE_STRETCH, - mPlayer_INDEX_RECIEVE, - mPlayer_INDEX_RECIEVE_PUTAWAY, - mPlayer_INDEX_GIVE, - mPlayer_INDEX_GIVE_WAIT, - mPlayer_INDEX_TAKEOUT_ITEM, - mPlayer_INDEX_PUTIN_ITEM, - mPlayer_INDEX_DEMO_WAIT, - mPlayer_INDEX_DEMO_WALK, - mPlayer_INDEX_DEMO_GETON_TRAIN, - mPlayer_INDEX_DEMO_GETON_TRAIN_WAIT, - mPlayer_INDEX_DEMO_GETOFF_TRAIN, - mPlayer_INDEX_DEMO_STANDING_TRAIN, - mPlayer_INDEX_DEMO_WADE, - mPlayer_INDEX_HIDE, - mPlayer_INDEX_GROUNDHOG, - mPlayer_INDEX_RELEASE_CREATURE, - mPlayer_INDEX_WASH_CAR, - mPlayer_INDEX_TIRED, - mPlayer_INDEX_ROTATE_OCTAGON, - mPlayer_INDEX_THROW_MONEY, - mPlayer_INDEX_PRAY, - mPlayer_INDEX_SHAKE_TREE, - mPlayer_INDEX_MAIL_JUMP, - mPlayer_INDEX_MAIL_LAND, - mPlayer_INDEX_READY_PITFALL, - mPlayer_INDEX_FALL_PITFALL, - mPlayer_INDEX_STRUGGLE_PITFALL, - mPlayer_INDEX_CLIMBUP_PITFALL, - mPlayer_INDEX_STUNG_BEE, - mPlayer_INDEX_NOTICE_BEE, - mPlayer_INDEX_REMOVE_GRASS, - mPlayer_INDEX_SHOCK, - mPlayer_INDEX_KNOCK_DOOR, - mPlayer_INDEX_CHANGE_CLOTH, - mPlayer_INDEX_PUSH_SNOWBALL, - mPlayer_INDEX_ROTATE_UMBRELLA, - mPlayer_INDEX_WADE_SNOWBALL, - mPlayer_INDEX_COMPLETE_PAYMENT, - mPlayer_INDEX_FAIL_EMU, - mPlayer_INDEX_STUNG_MOSQUITO, - mPlayer_INDEX_NOTICE_MOSQUITO, - mPlayer_INDEX_SWING_FAN, - mPlayer_INDEX_SWITCH_ON_LIGHTHOUSE, - mPlayer_INDEX_RADIO_EXERCISE, - mPlayer_INDEX_DEMO_GETON_BOAT, - mPlayer_INDEX_DEMO_GETON_BOAT_SITDOWN, - mPlayer_INDEX_DEMO_GETON_BOAT_WAIT, - mPlayer_INDEX_DEMO_GETON_BOAT_WADE, - mPlayer_INDEX_DEMO_GETOFF_BOAT_STANDUP, - mPlayer_INDEX_DEMO_GETOFF_BOAT, - mPlayer_INDEX_DEMO_GET_GOLDEN_ITEM, - mPlayer_INDEX_DEMO_GET_GOLDEN_ITEM2, - mPlayer_INDEX_DEMO_GET_GOLDEN_AXE_WAIT + mPlayer_INDEX_DMA, + mPlayer_INDEX_INTRO, + mPlayer_INDEX_REFUSE, + mPlayer_INDEX_REFUSE_PICKUP, + mPlayer_INDEX_RETURN_DEMO, + mPlayer_INDEX_RETURN_OUTDOOR, + mPlayer_INDEX_RETURN_OUTDOOR2, + mPlayer_INDEX_WAIT, + mPlayer_INDEX_WALK, + mPlayer_INDEX_RUN, + mPlayer_INDEX_DASH, + mPlayer_INDEX_TUMBLE, + mPlayer_INDEX_TUMBLE_GETUP, + mPlayer_INDEX_TURN_DASH, + mPlayer_INDEX_FALL, + mPlayer_INDEX_WADE, + mPlayer_INDEX_DOOR, + mPlayer_INDEX_OUTDOOR, + mPlayer_INDEX_INVADE, + mPlayer_INDEX_HOLD, + mPlayer_INDEX_PUSH, + mPlayer_INDEX_PULL, + mPlayer_INDEX_ROTATE_FURNITURE, + mPlayer_INDEX_OPEN_FURNITURE, + mPlayer_INDEX_WAIT_OPEN_FURNITURE, + mPlayer_INDEX_CLOSE_FURNITURE, + mPlayer_INDEX_LIE_BED, + mPlayer_INDEX_WAIT_BED, + mPlayer_INDEX_ROLL_BED, + mPlayer_INDEX_STANDUP_BED, + mPlayer_INDEX_PICKUP, + mPlayer_INDEX_PICKUP_JUMP, + mPlayer_INDEX_PICKUP_FURNITURE, + mPlayer_INDEX_PICKUP_EXCHANGE, + mPlayer_INDEX_SITDOWN, + mPlayer_INDEX_SITDOWN_WAIT, + mPlayer_INDEX_STANDUP, + mPlayer_INDEX_SWING_AXE, + mPlayer_INDEX_AIR_AXE, + mPlayer_INDEX_REFLECT_AXE, + mPlayer_INDEX_BROKEN_AXE, + mPlayer_INDEX_SLIP_NET, + mPlayer_INDEX_READY_NET, + mPlayer_INDEX_READY_WALK_NET, + mPlayer_INDEX_SWING_NET, + mPlayer_INDEX_PULL_NET, + mPlayer_INDEX_STOP_NET, + mPlayer_INDEX_NOTICE_NET, + mPlayer_INDEX_PUTAWAY_NET, + mPlayer_INDEX_READY_ROD, + mPlayer_INDEX_CAST_ROD, + mPlayer_INDEX_AIR_ROD, + mPlayer_INDEX_RELAX_ROD, + mPlayer_INDEX_COLLECT_ROD, + mPlayer_INDEX_VIB_ROD, + mPlayer_INDEX_FLY_ROD, + mPlayer_INDEX_NOTICE_ROD, + mPlayer_INDEX_PUTAWAY_ROD, + mPlayer_INDEX_DIG_SCOOP, + mPlayer_INDEX_FILL_SCOOP, + mPlayer_INDEX_REFLECT_SCOOP, + mPlayer_INDEX_AIR_SCOOP, + mPlayer_INDEX_GET_SCOOP, + mPlayer_INDEX_PUTAWAY_SCOOP, + mPlayer_INDEX_PUTIN_SCOOP, + mPlayer_INDEX_TALK, + mPlayer_INDEX_RECIEVE_WAIT, + mPlayer_INDEX_RECIEVE_STRETCH, + mPlayer_INDEX_RECIEVE, + mPlayer_INDEX_RECIEVE_PUTAWAY, + mPlayer_INDEX_GIVE, + mPlayer_INDEX_GIVE_WAIT, + mPlayer_INDEX_TAKEOUT_ITEM, + mPlayer_INDEX_PUTIN_ITEM, + mPlayer_INDEX_DEMO_WAIT, + mPlayer_INDEX_DEMO_WALK, + mPlayer_INDEX_DEMO_GETON_TRAIN, + mPlayer_INDEX_DEMO_GETON_TRAIN_WAIT, + mPlayer_INDEX_DEMO_GETOFF_TRAIN, + mPlayer_INDEX_DEMO_STANDING_TRAIN, + mPlayer_INDEX_DEMO_WADE, + mPlayer_INDEX_HIDE, + mPlayer_INDEX_GROUNDHOG, + mPlayer_INDEX_RELEASE_CREATURE, + mPlayer_INDEX_WASH_CAR, + mPlayer_INDEX_TIRED, + mPlayer_INDEX_ROTATE_OCTAGON, + mPlayer_INDEX_THROW_MONEY, + mPlayer_INDEX_PRAY, + mPlayer_INDEX_SHAKE_TREE, + mPlayer_INDEX_MAIL_JUMP, + mPlayer_INDEX_MAIL_LAND, + mPlayer_INDEX_READY_PITFALL, + mPlayer_INDEX_FALL_PITFALL, + mPlayer_INDEX_STRUGGLE_PITFALL, + mPlayer_INDEX_CLIMBUP_PITFALL, + mPlayer_INDEX_STUNG_BEE, + mPlayer_INDEX_NOTICE_BEE, + mPlayer_INDEX_REMOVE_GRASS, + mPlayer_INDEX_SHOCK, + mPlayer_INDEX_KNOCK_DOOR, + mPlayer_INDEX_CHANGE_CLOTH, + mPlayer_INDEX_PUSH_SNOWBALL, + mPlayer_INDEX_ROTATE_UMBRELLA, + mPlayer_INDEX_WADE_SNOWBALL, + mPlayer_INDEX_COMPLETE_PAYMENT, + mPlayer_INDEX_FAIL_EMU, + mPlayer_INDEX_STUNG_MOSQUITO, + mPlayer_INDEX_NOTICE_MOSQUITO, + mPlayer_INDEX_SWING_FAN, + mPlayer_INDEX_SWITCH_ON_LIGHTHOUSE, + mPlayer_INDEX_RADIO_EXERCISE, + mPlayer_INDEX_DEMO_GETON_BOAT, + mPlayer_INDEX_DEMO_GETON_BOAT_SITDOWN, + mPlayer_INDEX_DEMO_GETON_BOAT_WAIT, + mPlayer_INDEX_DEMO_GETON_BOAT_WADE, + mPlayer_INDEX_DEMO_GETOFF_BOAT_STANDUP, + mPlayer_INDEX_DEMO_GETOFF_BOAT, + mPlayer_INDEX_DEMO_GET_GOLDEN_ITEM, + mPlayer_INDEX_DEMO_GET_GOLDEN_ITEM2, + mPlayer_INDEX_DEMO_GET_GOLDEN_AXE_WAIT }; enum { - mPlayer_CREATURE_INSECT, - mPlayer_CREATURE_GYOEI, - mPlayer_CREATURE_BALLOON, + mPlayer_CREATURE_INSECT, + mPlayer_CREATURE_GYOEI, + mPlayer_CREATURE_BALLOON, - mPlayer_CREATURE_NUM + mPlayer_CREATURE_NUM +}; + +enum { + mPlayer_BED_ACTION_NONE, + mPlayer_BED_ACTION_ROLL, + mPlayer_BED_ACTION_OUT, + + mPlayer_BED_ACTION_NUM }; typedef struct player_request_give_from_submenu_s { - xyz_t unused; // assumed based on size - mActor_name_t item; - int mode_after; // player mode after the action finishes - int present_flag; // set if the item is wrapped as presnet - int counter_flag; // set when the item slides across a counter + xyz_t unused; // assumed based on size + mActor_name_t item; + int mode_after; // player mode after the action finishes + int present_flag; // set if the item is wrapped as presnet + int counter_flag; // set when the item slides across a counter } mPlayer_request_give_from_submenu_c; typedef struct player_request_putin_scoop_from_submenu_s { - xyz_t wpos; - mActor_name_t item; - int got_gold_scoop; + xyz_t wpos; + mActor_name_t item; + int got_gold_scoop; } mPlayer_request_putin_scoop_from_submenu_data_c; typedef struct { - int type; - int got_gold_scoop; - s16 angle_y; - s16 item; + int type; + int got_gold_scoop; + s16 angle_y; + s16 item; } mPlayer_request_release_creature_gyoei_from_submenu_c; typedef struct { - int type; - int got_gold_scoop; - xyz_t wpos; - int insect_type; + int type; + int got_gold_scoop; + xyz_t wpos; + int insect_type; } mPlayer_request_release_creature_insect_from_submenu_c; typedef struct { - int type; - int got_gold_scoop; - int balloon_shape_type; + int type; + int got_gold_scoop; + int balloon_shape_type; } mPlayer_request_release_creature_balloon_from_submenu_c; typedef struct { - int _0; - ACTOR* speak_actor; + int _0; + ACTOR* speak_actor; } mPlayer_request_demo_wait_from_submenu_c; typedef struct { - int direct; - s16 angle; - xyz_t wpos; - int ftr_name; + int direct; + s16 angle; + xyz_t wpos; + int ftr_name; } mPlayer_request_lie_bed_c; typedef union { - mPlayer_request_give_from_submenu_c give_from_submenu; - mPlayer_request_putin_scoop_from_submenu_data_c putin_scoop_from_submenu; - mPlayer_request_release_creature_gyoei_from_submenu_c release_creature_gyoei_from_submenu; - mPlayer_request_release_creature_insect_from_submenu_c release_creature_insect_from_submenu; - mPlayer_request_release_creature_balloon_from_submenu_c release_creature_balloon_from_submenu; - mPlayer_request_demo_wait_from_submenu_c demo_wait_from_submenu; - mPlayer_request_lie_bed_c lie_bed; - /* TODO: others */ - u8 force_size[72]; // TEMP + mPlayer_request_give_from_submenu_c give_from_submenu; + mPlayer_request_putin_scoop_from_submenu_data_c putin_scoop_from_submenu; + mPlayer_request_release_creature_gyoei_from_submenu_c release_creature_gyoei_from_submenu; + mPlayer_request_release_creature_insect_from_submenu_c release_creature_insect_from_submenu; + mPlayer_request_release_creature_balloon_from_submenu_c release_creature_balloon_from_submenu; + mPlayer_request_demo_wait_from_submenu_c demo_wait_from_submenu; + mPlayer_request_lie_bed_c lie_bed; + /* TODO: others */ + u8 force_size[72]; // TEMP } mPlayer_request_main_data; typedef struct { - int requested_main_index; - int requested_index_pending; - mPlayer_request_main_data request_main_data; + int requested_main_index; + int requested_index_pending; + mPlayer_request_main_data request_main_data; } mPlayer_change_data_from_submenu_c; /* sizeof(struct player_actor_s) == 0x13A8 */ struct player_actor_s { - /* 0x0000 */ ACTOR actor_class; - /* 0x0174 */ cKF_SkeletonInfo_R_c keyframe0; - /* 0x01E4 */ cKF_SkeletonInfo_R_c keyframe1; - /* 0x0252 */ s_xyz joint_data[27]; - /* 0x02F4 */ s_xyz morph_data[27]; - /* 0x0398 */ Mtx work_mtx[2][13]; /* swapped between frames */ - /* 0x0A18 */ cKF_SkeletonInfo_R_c item_keyframe; /* for item animations */ - /* 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; - /* 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; - /* 0x0D08 */ int requested_main_index; - /* 0x0D0C */ int requested_main_index_priority; - /* 0x0D10 */ int requested_main_index_changed; - /* 0x0D14 */ int settled_requested_main_index_priority; - /* 0x0D18 */ u8 main_index_data[72]; // TODO: Union of many types... - /* 0x0D60 */ u8 requested_main_index_data[72]; // TODO: Union of many types... - /* 0x0DA8 */ u8 _0DA8[0x1270 - 0x0DA8]; /* TODO: finish */ - /* 0x1270 */ int (*request_main_invade_all_proc)(GAME*, int); - /* 0x1274 */ int (*request_main_refuse_all_proc)(GAME*, int); - /* 0x1278 */ int (*request_main_return_demo_all_proc)(GAME*, int, f32, int); - /* 0x127C */ int (*request_main_wait_all_proc)(GAME*, f32, int, int); - /* 0x1280 */ int (*request_main_talk_all_proc)(GAME*, ACTOR*, int, f32, int, int); - /* 0x1284 */ int (*request_main_hold_all_proc)(GAME*, int, int, const xyz_t*, f32, int, int); - /* 0x1288 */ int (*request_main_recieve_wait_all_proc)(GAME*, ACTOR*, int, int, mActor_name_t, int, int); - /* 0x128C */ int (*request_main_give_all_proc)(GAME*, ACTOR*, int, int, mActor_name_t, int, int, int, int); - /* 0x1290 */ int (*request_main_sitdown_all_proc)(GAME*, int, const xyz_t*, int, int); - /* 0x1294 */ int (*request_main_close_furniture_all_proc)(GAME*, int); - /* 0x1298 */ int (*request_main_lie_bed_all_proc)(GAME*, int, const xyz_t*, int, int, int); - /* 0x129C */ int (*request_main_hide_all_proc)(GAME*, int); - /* 0x12A0 */ int (*request_main_groundhog_proc)(GAME*, int); - /* 0x12A4 */ int (*request_main_door_all_proc)(GAME*, const xyz_t*, s16, int, void*, int); - /* 0x12A8 */ int (*request_main_outdoor_all_proc)(GAME*, int, int, int); - /* 0x12AC */ int (*request_main_wash_car_all_proc)(GAME*, const xyz_t*, const xyz_t*, s16, ACTOR*, int); - /* 0x12B0 */ int (*request_main_rotate_octagon_all_proc)(GAME*, ACTOR*, int, int, const xyz_t*, s16, int); - /* 0x12B4 */ int (*request_main_throw_money_all_proc)(GAME*, const xyz_t*, s16, int); - /* 0x12B8 */ int (*request_main_pray_all_proc)(GAME*, const xyz_t*, s16, int); - /* 0x12BC */ int (*request_main_mail_jump_all_proc)(GAME*, const xyz_t*, s16, int); - /* 0x12C0 */ int (*request_main_demo_wait_all_proc)(GAME*, int, void*, int); - /* 0x12C4 */ int (*request_main_demo_walk_all_proc)(GAME*, f32, f32, f32, int, int); - /* 0x12C8 */ int (*request_main_demo_geton_train_all_proc)(GAME*, const xyz_t*, s16, int); - /* 0x12CC */ int (*request_main_demo_getoff_train_all_proc)(GAME*, const xyz_t*, s16, int); - /* 0x12D0 */ int (*request_main_demo_standing_train_all_proc)(GAME*, int); - /* 0x12D4 */ int (*request_main_stung_bee_all_proc)(GAME*, int); - /* 0x12D8 */ int (*request_main_shock_all_proc)(GAME*, f32, s16, s8, int, int); - /* 0x12DC */ int (*request_main_change_cloth_forNPC_proc)(GAME*, mActor_name_t, int); - /* 0x12E0 */ int (*request_main_push_snowball_all_proc)(GAME*, void*, int, int); - /* 0x12E4 */ int (*request_main_stung_mosquito_all_proc)(GAME*, int, int); - /* 0x12E8 */ int (*request_main_switch_on_lighthouse_all_proc)(GAME*, const xyz_t*, int, int); - /* 0x12EC */ int (*request_main_demo_geton_boat_all_proc)(GAME*, const xyz_t*, s16, int); - /* 0x12F0 */ int (*request_main_demo_getoff_boat_standup_all_proc)(GAME*, const xyz_t*, s16, int); - /* 0x12F4 */ int (*request_main_demo_get_golden_item2_all_proc)(GAME*, int, int); - /* 0x12F8 */ int (*request_main_demo_get_golden_axe_wait_all_proc)(GAME*, int); - /* 0x12FC */ int (*check_request_main_priority_proc)(GAME*, int); - /* 0x1300 */ void* (*get_door_label_proc)(GAME*); - /* 0x1304 */ int (*Set_Item_net_catch_request_table_proc)(ACTOR*, GAME*, u32, s8, const xyz_t*, f32); - /* 0x1308 */ f32 (*Get_Item_net_catch_swing_timer_proc)(ACTOR*, GAME*); - /* 0x130C */ u8 (*Set_Item_net_catch_request_force_proc)(ACTOR*, GAME*, u32, s8); - /* 0x1310 */ void (*Set_force_position_angle_proc)(GAME*, const xyz_t*, const s_xyz*, u8); - /* 0x1314 */ u8 (*Get_force_position_angle_proc)(GAME*, xyz_t*, s_xyz*); - /* 0x1318 */ int (*Get_WadeEndPos_proc)(GAME*, xyz_t*); - /* 0x131C */ int (*Check_Label_main_push_snowball_proc)(GAME*, void*); - /* 0x1320 */ int (*SetParam_for_push_snowball_proc)(GAME*, const xyz_t*, s16, f32); - /* 0x1324 */ int (*able_submenu_request_main_index_proc)(GAME*); - /* 0x1328 */ int (*check_able_change_camera_normal_index_proc)(ACTOR*); - /* 0x132C */ int (*Check_able_force_speak_label_proc)(GAME*, ACTOR*); - /* 0x1330 */ int (*check_cancel_request_change_proc_index_proc)(int); - /* 0x1334 */ u32 (*Get_item_net_catch_label_proc)(ACTOR*); - /* 0x1338 */ int (*Change_item_net_catch_label_proc)(ACTOR*, u32, s8); - /* 0x133C */ int (*Check_StopNet_proc)(ACTOR*, xyz_t*); - /* 0x1340 */ int (*Check_HitAxe_proc)(ACTOR*, xyz_t*); - /* 0x1344 */ int (*Check_VibUnit_OneFrame_proc)(ACTOR*, const xyz_t*); - /* 0x1348 */ int (*Check_HitScoop_proc)(ACTOR*, xyz_t*); - /* 0x134C */ int (*Check_DigScoop_proc)(ACTOR*, xyz_t*); - /* 0x1350 */ int (*check_request_change_item_proc)(GAME*); - /* 0x1354 */ int (*Check_RotateOctagon_proc)(GAME*); - /* 0x1358 */ int (*Check_end_stung_bee_proc)(ACTOR*); - /* 0x135C */ int (*Get_status_for_bee_proc)(ACTOR*); - /* 0x1360 */ int (*Set_ScrollDemo_forWade_snowball_proc)(ACTOR*, int, const xyz_t*); - /* 0x1364 */ int (*Check_tree_shaken_proc)(ACTOR*, const xyz_t*); - /* 0x1368 */ int (*Check_tree_shaken_little_proc)(ACTOR*, const xyz_t*); - /* 0x136C */ int (*Check_tree_shaken_big_proc)(ACTOR*, const xyz_t*); - /* 0x1370 */ int (*Check_Label_main_wade_snowball_proc)(GAME*, void*); - /* 0x1374 */ int (*GetSnowballPos_forWadeSnowball_proc)(ACTOR*, xyz_t*); - /* 0x1378 */ int (*CheckCondition_forWadeSnowball_proc)(GAME*, const xyz_t*, s16); - /* 0x137C */ mActor_name_t (*Get_itemNo_forWindow_proc)(ACTOR*); - /* 0x1380 */ int (*check_cancel_event_without_priority_proc)(GAME*); - /* 0x1384 */ int (*CheckScene_AbleSubmenu_proc)(); - /* 0x1388 */ int (*Check_stung_mosquito_proc)(GAME*, ACTOR*); - /* 0x138C */ int a_btn_pressed; - /* 0x1390 */ int a_btn_triggers_submenu; - /* 0x1394 */ mActor_name_t item_in_front; /* item directly in front of the player */ - /* 0x1398 */ xyz_t foward_ut_pos; /* wpos of unit in front of player */ - /* 0x13A4 */ s8 update_scene_bg_mode; + /* 0x0000 */ ACTOR actor_class; + /* 0x0174 */ cKF_SkeletonInfo_R_c keyframe0; + /* 0x01E4 */ cKF_SkeletonInfo_R_c keyframe1; + /* 0x0252 */ s_xyz joint_data[27]; + /* 0x02F4 */ s_xyz morph_data[27]; + /* 0x0398 */ Mtx work_mtx[2][13]; /* swapped between frames */ + /* 0x0A18 */ cKF_SkeletonInfo_R_c item_keyframe; /* for item animations */ + /* 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; + /* 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; + /* 0x0D08 */ int requested_main_index; + /* 0x0D0C */ int requested_main_index_priority; + /* 0x0D10 */ int requested_main_index_changed; + /* 0x0D14 */ int settled_requested_main_index_priority; + /* 0x0D18 */ u8 main_index_data[72]; // TODO: Union of many types... + /* 0x0D60 */ u8 requested_main_index_data[72]; // TODO: Union of many types... + /* 0x0DA8 */ u8 _0DA8[0x1010 - 0x0DA8]; /* TODO: finish */ + /* 0x1010 */ ClObjPipe_c col_pipe; + /* 0x102C */ xyz_t head_pos; + /* 0x1038 */ xyz_t feel_pos; + /* 0x1044 */ xyz_t right_hand_pos; + /* 0x1050 */ xyz_t right_hand_move; + /* 0x105C */ xyz_t left_hand_pos; + /* 0x1068 */ MtxF right_hand_mtx; + /* 0x10A8 */ MtxF left_hand_mtx; + /* 0x10E8 */ u8 _10E8[0x1270 - 0x10E8]; + /* 0x1270 */ int (*request_main_invade_all_proc)(GAME*, int); + /* 0x1274 */ int (*request_main_refuse_all_proc)(GAME*, int); + /* 0x1278 */ int (*request_main_return_demo_all_proc)(GAME*, int, f32, int); + /* 0x127C */ int (*request_main_wait_all_proc)(GAME*, f32, int, int); + /* 0x1280 */ int (*request_main_talk_all_proc)(GAME*, ACTOR*, int, f32, int, int); + /* 0x1284 */ int (*request_main_hold_all_proc)(GAME*, int, int, const xyz_t*, f32, int, int); + /* 0x1288 */ int (*request_main_recieve_wait_all_proc)(GAME*, ACTOR*, int, int, mActor_name_t, int, int); + /* 0x128C */ int (*request_main_give_all_proc)(GAME*, ACTOR*, int, int, mActor_name_t, int, int, int, int); + /* 0x1290 */ int (*request_main_sitdown_all_proc)(GAME*, int, const xyz_t*, int, int); + /* 0x1294 */ int (*request_main_close_furniture_all_proc)(GAME*, int); + /* 0x1298 */ int (*request_main_lie_bed_all_proc)(GAME*, int, const xyz_t*, int, int, int); + /* 0x129C */ int (*request_main_hide_all_proc)(GAME*, int); + /* 0x12A0 */ int (*request_main_groundhog_proc)(GAME*, int); + /* 0x12A4 */ int (*request_main_door_all_proc)(GAME*, const xyz_t*, s16, int, void*, int); + /* 0x12A8 */ int (*request_main_outdoor_all_proc)(GAME*, int, int, int); + /* 0x12AC */ int (*request_main_wash_car_all_proc)(GAME*, const xyz_t*, const xyz_t*, s16, ACTOR*, int); + /* 0x12B0 */ int (*request_main_rotate_octagon_all_proc)(GAME*, ACTOR*, int, int, const xyz_t*, s16, int); + /* 0x12B4 */ int (*request_main_throw_money_all_proc)(GAME*, const xyz_t*, s16, int); + /* 0x12B8 */ int (*request_main_pray_all_proc)(GAME*, const xyz_t*, s16, int); + /* 0x12BC */ int (*request_main_mail_jump_all_proc)(GAME*, const xyz_t*, s16, int); + /* 0x12C0 */ int (*request_main_demo_wait_all_proc)(GAME*, int, void*, int); + /* 0x12C4 */ int (*request_main_demo_walk_all_proc)(GAME*, f32, f32, f32, int, int); + /* 0x12C8 */ int (*request_main_demo_geton_train_all_proc)(GAME*, const xyz_t*, s16, int); + /* 0x12CC */ int (*request_main_demo_getoff_train_all_proc)(GAME*, const xyz_t*, s16, int); + /* 0x12D0 */ int (*request_main_demo_standing_train_all_proc)(GAME*, int); + /* 0x12D4 */ int (*request_main_stung_bee_all_proc)(GAME*, int); + /* 0x12D8 */ int (*request_main_shock_all_proc)(GAME*, f32, s16, s8, int, int); + /* 0x12DC */ int (*request_main_change_cloth_forNPC_proc)(GAME*, mActor_name_t, int); + /* 0x12E0 */ int (*request_main_push_snowball_all_proc)(GAME*, void*, int, int); + /* 0x12E4 */ int (*request_main_stung_mosquito_all_proc)(GAME*, int, int); + /* 0x12E8 */ int (*request_main_switch_on_lighthouse_all_proc)(GAME*, const xyz_t*, int, int); + /* 0x12EC */ int (*request_main_demo_geton_boat_all_proc)(GAME*, const xyz_t*, s16, int); + /* 0x12F0 */ int (*request_main_demo_getoff_boat_standup_all_proc)(GAME*, const xyz_t*, s16, int); + /* 0x12F4 */ int (*request_main_demo_get_golden_item2_all_proc)(GAME*, int, int); + /* 0x12F8 */ int (*request_main_demo_get_golden_axe_wait_all_proc)(GAME*, int); + /* 0x12FC */ int (*check_request_main_priority_proc)(GAME*, int); + /* 0x1300 */ void* (*get_door_label_proc)(GAME*); + /* 0x1304 */ int (*Set_Item_net_catch_request_table_proc)(ACTOR*, GAME*, u32, s8, const xyz_t*, f32); + /* 0x1308 */ f32 (*Get_Item_net_catch_swing_timer_proc)(ACTOR*, GAME*); + /* 0x130C */ u8 (*Set_Item_net_catch_request_force_proc)(ACTOR*, GAME*, u32, s8); + /* 0x1310 */ void (*Set_force_position_angle_proc)(GAME*, const xyz_t*, const s_xyz*, u8); + /* 0x1314 */ u8 (*Get_force_position_angle_proc)(GAME*, xyz_t*, s_xyz*); + /* 0x1318 */ int (*Get_WadeEndPos_proc)(GAME*, xyz_t*); + /* 0x131C */ int (*Check_Label_main_push_snowball_proc)(GAME*, void*); + /* 0x1320 */ int (*SetParam_for_push_snowball_proc)(GAME*, const xyz_t*, s16, f32); + /* 0x1324 */ int (*able_submenu_request_main_index_proc)(GAME*); + /* 0x1328 */ int (*check_able_change_camera_normal_index_proc)(ACTOR*); + /* 0x132C */ int (*Check_able_force_speak_label_proc)(GAME*, ACTOR*); + /* 0x1330 */ int (*check_cancel_request_change_proc_index_proc)(int); + /* 0x1334 */ u32 (*Get_item_net_catch_label_proc)(ACTOR*); + /* 0x1338 */ int (*Change_item_net_catch_label_proc)(ACTOR*, u32, s8); + /* 0x133C */ int (*Check_StopNet_proc)(ACTOR*, xyz_t*); + /* 0x1340 */ int (*Check_HitAxe_proc)(ACTOR*, xyz_t*); + /* 0x1344 */ int (*Check_VibUnit_OneFrame_proc)(ACTOR*, const xyz_t*); + /* 0x1348 */ int (*Check_HitScoop_proc)(ACTOR*, xyz_t*); + /* 0x134C */ int (*Check_DigScoop_proc)(ACTOR*, xyz_t*); + /* 0x1350 */ int (*check_request_change_item_proc)(GAME*); + /* 0x1354 */ int (*Check_RotateOctagon_proc)(GAME*); + /* 0x1358 */ int (*Check_end_stung_bee_proc)(ACTOR*); + /* 0x135C */ int (*Get_status_for_bee_proc)(ACTOR*); + /* 0x1360 */ int (*Set_ScrollDemo_forWade_snowball_proc)(ACTOR*, int, const xyz_t*); + /* 0x1364 */ int (*Check_tree_shaken_proc)(ACTOR*, const xyz_t*); + /* 0x1368 */ int (*Check_tree_shaken_little_proc)(ACTOR*, const xyz_t*); + /* 0x136C */ int (*Check_tree_shaken_big_proc)(ACTOR*, const xyz_t*); + /* 0x1370 */ int (*Check_Label_main_wade_snowball_proc)(GAME*, void*); + /* 0x1374 */ int (*GetSnowballPos_forWadeSnowball_proc)(ACTOR*, xyz_t*); + /* 0x1378 */ int (*CheckCondition_forWadeSnowball_proc)(GAME*, const xyz_t*, s16); + /* 0x137C */ mActor_name_t (*Get_itemNo_forWindow_proc)(ACTOR*); + /* 0x1380 */ int (*check_cancel_event_without_priority_proc)(GAME*); + /* 0x1384 */ int (*CheckScene_AbleSubmenu_proc)(); + /* 0x1388 */ int (*Check_stung_mosquito_proc)(GAME*, ACTOR*); + /* 0x138C */ int a_btn_pressed; + /* 0x1390 */ int a_btn_triggers_submenu; + /* 0x1394 */ mActor_name_t item_in_front; /* item directly in front of the player */ + /* 0x1398 */ xyz_t foward_ut_pos; /* wpos of unit in front of player */ + /* 0x13A4 */ s8 update_scene_bg_mode; }; void Player_actor_ct(ACTOR*, GAME*); diff --git a/include/m_player_lib.h b/include/m_player_lib.h index 9052d5ad..55b7fda8 100644 --- a/include/m_player_lib.h +++ b/include/m_player_lib.h @@ -67,6 +67,9 @@ extern int mPlib_request_main_close_furniture_type1(GAME* game); extern int mPlib_request_main_shock_type1(GAME* game, f32 time, s16 angle_y, int axe_swing); extern int mPlib_request_main_hold_type1(GAME* game, int ftr_no, int player_direct, const xyz_t* player_pos); extern int mPlib_check_player_warp_forEvent(void); +extern int mPlib_check_player_actor_main_index_Furniture_Move(GAME* game); +extern int mPlib_request_main_sitdown_type1(GAME* game, int direct, const xyz_t* pos, int ftr_no); +extern int mPlib_request_main_lie_bed_type1(GAME* game, int direct, const xyz_t* pos, int head_direct, int ftr_no); extern mPlayer_change_data_from_submenu_c* mPlib_Get_change_data_from_submenu_p(); diff --git a/src/ac_my_room.c b/src/ac_my_room.c index 4fe3a109..b9e98172 100644 --- a/src/ac_my_room.c +++ b/src/ac_my_room.c @@ -17,6 +17,7 @@ #include "m_debug.h" #include "m_mark_room.h" #include "sys_matrix.h" +#include "m_rcp.h" enum { aMR_ICON_LEAF, @@ -110,6 +111,27 @@ enum { aMR_MSG_STATE_NUM }; +static void My_Room_Actor_ct(ACTOR*, GAME*); +static void My_Room_Actor_dt(ACTOR*, GAME*); +static void My_Room_Actor_move(ACTOR*, GAME*); +static void My_Room_Actor_draw(ACTOR*, GAME*); + +// clang-format off +ACTOR_PROFILE My_Room_Profile = { + mAc_PROFILE_MY_ROOM, + ACTOR_PART_BG, + ACTOR_STATE_CAN_MOVE_IN_DEMO_SCENES | ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + ETC_MY_ROOM, + ACTOR_OBJ_BANK_KEEP, + sizeof(MY_ROOM_ACTOR), + &My_Room_Actor_ct, + &My_Room_Actor_dt, + &My_Room_Actor_move, + &My_Room_Actor_draw, + NULL +}; +// clang-format on + #include "../src/ac_furniture_data.c_inc" #include "../src/ac_my_room_data.c_inc" @@ -146,10 +168,48 @@ static int aMR_SetFurniture2FG(FTR_ACTOR* ftr_actor, xyz_t pos, int on_flag); static int aMR_FtrIdx2ChangeFtrSwitch(ACTOR* actorx, int ftr_id); static aFTR_PROFILE* aMR_GetFurnitureProfile(u16 ftr_no); static mActor_name_t* aMR_GetLayerTopFg(s16 layer); - -#include "../src/ac_my_room_msg_ctrl.c_inc" -#include "../src/ac_my_room_goki.c_inc" -#include "../src/ac_my_room_melody.c_inc" +static void aMR_TidyItemInFurniture(FTR_ACTOR* ftr_actor); +static int aMR_GetItemCountInFurniture(FTR_ACTOR* ftr_actor); +static int aMR_ItemPutInFurniture(FTR_ACTOR* ftr_actor, mActor_name_t item); +static void aMR_AllMDSwitchOff(void); +static void aMR_OneMDSwitchOn_TheOtherSwitchOff(FTR_ACTOR* ftr_actor); +static void aMR_ReserveBgm(ACTOR* actorx, int bgm_no, FTR_ACTOR* ftr_actor, s16 timer); +static void aMR_SetMDFtrDemoData(MY_ROOM_ACTOR* my_room, FTR_ACTOR* ftr_actor, aMR_contact_info_c* contact_info); +static int aMR_CheckHikidashi(FTR_ACTOR* ftr_actor, PLAYER_ACTOR* player, aMR_contact_info_c* contact_info); +static int aMR_JudgeDemoStart(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, GAME* game, + PLAYER_ACTOR* player); +static void aMR_PlacePushFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, f32* point, + PLAYER_ACTOR* player, GAME* game); +static void aMR_PlacePullFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game); +static void aMR_PlaceKurukuruFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game); +static void aMR_SitDownFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game); +static void aMR_JudgeGoToBed(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game); +static void aMR_SetMelodyData(u8* melody_data); +static void aMR_GokiInfoCt(ACTOR* actorx, GAME* game); +static void aMR_GokiInfoDt(void); +static void aMR_CheckFtrAndGoki(ACTOR* actorx, FTR_ACTOR* ftr_actor, GAME* game); +static void aMR_MakeGokiburi(xyz_t* pos, GAME* game, s16 arg); +static void aMR_RequestPlayerBikkuri(ACTOR* actorx, GAME* game); +static void aMR_GetFtrShape4Position(xyz_t* p0, xyz_t* p1, xyz_t* p2, xyz_t* p3, FTR_ACTOR* ftr_actor); +static u8 aMR_JudgeStickFull(int direct, GAME* game); +static int aMR_JudgeFurnitureMove(u8 type, int ut); +static int aMR_RequestItemToFitFurniture(ACTOR* actorx, FTR_ACTOR* ftr_actor); +static void aMR_SetPullMoveAnime(FTR_ACTOR* ftr_actor, GAME* game, MY_ROOM_ACTOR* my_room, + aMR_contact_info_c* contact_info); +static int aMR_PullDirect2PushDirect(int pull_direct); +static void aMR_SetPushMoveAnime(FTR_ACTOR* ftr_actor, GAME* game, MY_ROOM_ACTOR* my_room, + aMR_contact_info_c* contact_info); +static void aMR_MoveShapeCenter(FTR_ACTOR* ftr_actor); +static void aMR_RotateY(f32* xz, f32 amount); +static int aMR_3DStickNuetral(void); +static void aMR_SetNicePos(xyz_t* nice_pos, xyz_t player_pos, f32* col_start_xz, f32* col_end_xz, + aMR_contact_info_c* contact_info, int type); +static int aMR_GetPlayerDirect(const f32* normal_xz); +static int aMR_Get3dDirectStatus(int direct); static aFTR_PROFILE* aMR_GetFurnitureProfile(u16 ftr_no) { if (ftr_no < FTR_NUM) { @@ -237,7 +297,7 @@ static int aMR_ItemNo2IconNo(mActor_name_t item_no) { return aMR_ICON_LEAF; } -static Gfx* aMR_IconNo2Gfx1(int icon_no) { +extern Gfx* aMR_IconNo2Gfx1(int icon_no) { aMR_icon_display_data_c* icon; if (icon_no < 0) { @@ -249,7 +309,7 @@ static Gfx* aMR_IconNo2Gfx1(int icon_no) { return aMR_icon_display_data[icon_no].mat_gfx; } -static Gfx* aMR_IconNo2Gfx2(int icon_no) { +extern Gfx* aMR_IconNo2Gfx2(int icon_no) { if (icon_no < 0) { icon_no = 0; } else if (icon_no >= aMR_ICON_NUM) { @@ -1402,6 +1462,8 @@ static int aMR_GetSceneFurnitureMax(void) { return 3; } +#include "../src/ac_my_room_msg_ctrl.c_inc" + static void aMR_SecureFurnitureRam(ACTOR* actorx) { l_aMR_work.ftr_actor_list = (FTR_ACTOR*)zelda_malloc(l_aMR_work.list_size * sizeof(FTR_ACTOR)); l_aMR_work.used_list = (u8*)zelda_malloc(l_aMR_work.list_size * sizeof(u8)); @@ -1719,8 +1781,6 @@ static void aMR_SetMDIslandNPC(void) { } } -static void aMR_GokiInfoCt(ACTOR* actorx, GAME* game); - static void My_Room_Actor_ct(ACTOR* actorx, GAME* game) { MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; GAME_PLAY* play = (GAME_PLAY*)game; @@ -1878,6 +1938,8 @@ static int aMR_PickupFtrLayer(void) { return mCoBG_LAYER0; } +#include "../src/ac_my_room_goki.c_inc" + static void aMR_LeafStartPos(xyz_t* pos) { static xyz_t leaf_start0 = { 0.0f, 0.0f, 0.0f }; @@ -1958,7 +2020,9 @@ static void My_Room_Actor_dt(ACTOR* actorx, GAME* game) { } } +#include "../src/ac_my_room_melody.c_inc" #include "../src/ac_my_room_move.c_inc" +#include "../src/ac_my_room_draw.c_inc" static void aMR_RedmaFtrBank(void) { int i; diff --git a/src/ac_my_room_action.c_inc b/src/ac_my_room_action.c_inc new file mode 100644 index 00000000..74bd687f --- /dev/null +++ b/src/ac_my_room_action.c_inc @@ -0,0 +1,1379 @@ +static f32 aMR_PointDist2(xyz_t* pos0, xyz_t* pos1) { + f32 dX = pos0->x - pos1->x; + f32 dZ = pos0->z - pos1->z; + + return dX * dX + dZ * dZ; +} + +static int aMR_GokiburiPos_Common(xyz_t* pos, FTR_ACTOR* ftr_actor, PLAYER_ACTOR* player, int flag) { + static xyz_t init_pos = { 0.0f, 0.0f, 0.0f }; + f32 dist_tbl[4]; + int idx_tbl[4] = { -1, -1, -1, -1 }; + int sorted_tbl[4]; + int idx_tbl_idx = 0; + + if (ftr_actor->original_shape_type == aFTR_SHAPE_TYPEA) { + *pos = ftr_actor->position; + return TRUE; + } else { + xyz_t shape_pos_tbl[4]; + int i; + int j; + f32 x; + f32 y; + f32 z; + int sel; + int chk; + + *pos = init_pos; + aMR_GetFtrShape4Position(&shape_pos_tbl[0], &shape_pos_tbl[1], &shape_pos_tbl[2], &shape_pos_tbl[3], ftr_actor); + for (i = 0; i < 4; i++) { + dist_tbl[i] = aMR_PointDist2(&shape_pos_tbl[i], &player->actor_class.world.position); + } + + for (j = 0; j < 4; j++) { + f32 dist = 1000000.0f; + + for (i = 0; i < 4; i++) { + if (dist_tbl[i] < dist && idx_tbl[i] == -1) { + dist = dist_tbl[i]; + idx_tbl_idx = i; + } + } + + idx_tbl[idx_tbl_idx] = j; + } + + for (j = 0; j < 4; j++) { + for (i = 0; i < 4; i++) { + if (j == idx_tbl[i]) { + sorted_tbl[j] = i; + break; + } + } + } + + sel = (sorted_tbl[0] + 1) & 3; + chk = sorted_tbl[1]; + if (sel != chk) { + x = (shape_pos_tbl[sorted_tbl[0]].x + shape_pos_tbl[sel].x) * 0.5f; + y = shape_pos_tbl[sorted_tbl[0]].y; + z = (shape_pos_tbl[sorted_tbl[0]].z + shape_pos_tbl[sel].z) * 0.5f; + } else { + sel = (sorted_tbl[0] - 1) & 3; + if (sel != chk) { + x = (shape_pos_tbl[sorted_tbl[0]].x + shape_pos_tbl[sel].x) * 0.5f; + y = shape_pos_tbl[sorted_tbl[0]].y; + z = (shape_pos_tbl[sorted_tbl[0]].z + shape_pos_tbl[sel].z) * 0.5f; + } else { + return FALSE; + } + } + + if (flag == 1) { + sel = (sorted_tbl[0] + 2) & 3; + pos->x = (x + shape_pos_tbl[sel].x) * 0.5f; + pos->y = y; + pos->z = (z + shape_pos_tbl[sel].z) * 0.5f; + } else { + pos->x = (x + shape_pos_tbl[chk].x) * 0.5f; + pos->y = y; + pos->z = (z + shape_pos_tbl[chk].z) * 0.5f; + } + } + + return TRUE; +} + +static int aMR_GokiburiPos_Rotate(xyz_t* pos, FTR_ACTOR* ftr_actor, PLAYER_ACTOR* player) { + /* 1x1 and 2x2 furniture don't expose newly empty spots when rotating, so ignore them */ + if (ftr_actor->original_shape_type == aFTR_SHAPE_TYPEA || ftr_actor->original_shape_type == aFTR_SHAPE_TYPEC) { + return FALSE; + } + + return aMR_GokiburiPos_Common(pos, ftr_actor, player, TRUE); +} + +static int aMR_GokiburiPos_Pull(xyz_t* pos, FTR_ACTOR* ftr_actor, PLAYER_ACTOR* player) { + return aMR_GokiburiPos_Common(pos, ftr_actor, player, TRUE); +} + +static int aMR_GokiburiPos_Push(xyz_t* pos, FTR_ACTOR* ftr_actor, PLAYER_ACTOR* player) { + return aMR_GokiburiPos_Common(pos, ftr_actor, player, FALSE); +} + +static int aMR_FtrColCheck(xyz_t pos, f32 radius) { + mActor_name_t* fg_p = aMR_GetLayerTopFg(mCoBG_LAYER0); + + if (fg_p != NULL) { + int i; + + for (i = 0; i < aMR_CONTACT_DIR_NUM; i++) { + xyz_t chk_pos; + int ut_x; + int ut_z; + int ut; + + switch (i) { + case aMR_CONTACT_DIR_BACK: + chk_pos.x = pos.x; + chk_pos.z = pos.z - radius; + break; + case aMR_CONTACT_DIR_RIGHT: + chk_pos.x = pos.x - radius; + chk_pos.z = pos.z; + break; + case aMR_CONTACT_DIR_FRONT: + chk_pos.x = pos.x; + chk_pos.z = pos.z + radius; + break; + case aMR_CONTACT_DIR_LEFT: + chk_pos.x = pos.x + radius; + chk_pos.z = pos.z; + break; + } + + ut_x = (int)(chk_pos.x / mFI_UT_WORLDSIZE_X_F); + ut_z = (int)(chk_pos.z / mFI_UT_WORLDSIZE_Z_F); + ut = ut_x + ut_z * UT_X_NUM; + + if (ITEM_IS_FTR(fg_p[ut]) || fg_p[ut] == RSV_FE1F) { + mActor_name_t item_no; + int ftrID; + + if (aMR_UnitNum2FtrItemNoFtrID(&item_no, &ftrID, ut_x, ut_z, mCoBG_LAYER0)) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[ftrID]; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + if (profile != NULL && aFTR_CHECK_INTERACTION(profile->interaction_type, + aFTR_INTERACTION_TYPE_NO_COLLISION) == FALSE) { + return TRUE; + } + } + } else if (fg_p[ut] == RSV_WALL_NO) { + return TRUE; /* House walls always have collision */ + } + } + + return FALSE; + } + + /* If we don't have any fg info then always collide */ + return TRUE; +} + +static void aMR_SetBubu(PLAYER_ACTOR* player, MY_ROOM_ACTOR* my_room, GAME* game, s16* bubu_p) { + if (eEC_CLIP != NULL) { + eEC_CLIP->effect_make_proc(eEC_EFFECT_BUBU, player->actor_class.world.position, 2, 0, game, RSV_NO, 0, 0); + } + + my_room->pull_timer = 0; + my_room->push_timer = 0; + + if (bubu_p != NULL) { + *bubu_p = TRUE; + } +} + +static int aMR_ConvertDirectLevel(int direct) { + static s16 direct_conv_data[] = { + mFI_MOVEDIR_UP, /* aMR_DIRECT_UP */ + mFI_MOVEDIR_LEFT, /* aMR_DIRECT_LEFT */ + mFI_MOVEDIR_DOWN, /* aMR_DIRECT_DOWN */ + mFI_MOVEDIR_RIGHT /* aMR_DIRECT_RIGHT */ + }; + + if (direct >= 0 && direct <= aMR_DIRECT_RIGHT) { + return direct_conv_data[direct]; + } + + return -1; +} + +static void aMR_SetMoveSE(FTR_ACTOR* ftr_actor) { + aMR_contact_info_c* contact_layer; + int floor_idx; + + switch (ftr_actor->name) { + case 0x406: /* stone coin */ + contact_layer = aMR_GetContactInfoLayer1(); + + if (ftr_actor->state == aFTR_STATE_WAIT_PUSH || ftr_actor->state == aFTR_STATE_WAIT_PUSH2 || + ftr_actor->state == aFTR_STATE_WAIT_PUSH3 || ftr_actor->state == aFTR_STATE_PUSH || + ftr_actor->state == aFTR_STATE_WAIT_PULL || ftr_actor->state == aFTR_STATE_WAIT_PULL2 || + ftr_actor->state == aFTR_STATE_PULL) { + if (contact_layer != NULL) { + switch (contact_layer->contact_direction) { + case aMR_CONTACT_DIR_RIGHT: + case aMR_CONTACT_DIR_LEFT: + sAdo_OngenTrgStart(NA_SE_STONECOIN_ROLL, &ftr_actor->position); + break; + default: + sAdo_OngenTrgStart(NA_SE_STONECOIN_DRAG, &ftr_actor->position); + break; + } + } + } + break; + case 0x4E8: /* lawn mower */ + floor_idx = Common_Get(floor_idx); + + if (floor_idx == FLOOR_NPC026 || floor_idx == FLOOR_NPC048) { + contact_layer = aMR_GetContactInfoLayer1(); + + if (ftr_actor->state == aFTR_STATE_WAIT_PUSH || ftr_actor->state == aFTR_STATE_WAIT_PUSH2 || + ftr_actor->state == aFTR_STATE_WAIT_PUSH3 || ftr_actor->state == aFTR_STATE_PUSH) { + if (contact_layer != NULL) { + switch (contact_layer->contact_direction) { + case aMR_CONTACT_DIR_BACK: + sAdo_OngenTrgStart(NA_SE_LAWNMOWER, &ftr_actor->position); + break; + } + } + } + } else { + sAdo_FloorTrgStart(Common_Get(floor_idx), &ftr_actor->position); + } + break; + default: + sAdo_FloorTrgStart(Common_Get(floor_idx), &ftr_actor->position); + break; + } +} + +static void aMR_SetRotateSE(FTR_ACTOR* ftr_actor) { + if (mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELD_PLAYER0_ROOM) { + sAdo_OngenTrgStart(NA_SE_ROTATE, &ftr_actor->position); + } +} + +static void aMR_GetPullSlip(xyz_t* pos, xyz_t target_pos, int ut_x, int ut_z, int direct) { + *pos = target_pos; + + switch (direct) { + case aMR_DIRECT_UP: + case aMR_DIRECT_DOWN: + pos->x = (f32)ut_x * mFI_UT_WORLDSIZE_X_F + mFI_UT_WORLDSIZE_HALF_X_F; + break; + default: + pos->z = (f32)ut_z * mFI_UT_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F; + break; + } +} + +enum { + aMR_SLIDE_PULL_JUDGE_TYPE0, + aMR_SLIDE_PULL_JUDGE_TYPE1, + aMR_SLIDE_PULL_JUDGE_NUM, +}; + +static int aMR_CheckSlidePullJudgeType(aMR_contact_info_c* contact_info, aFTR_PROFILE* profile) { + if (profile->shape == aFTR_SHAPE_TYPEC) { + return aMR_SLIDE_PULL_JUDGE_TYPE1; + } + + if (profile->shape <= aFTR_SHAPE_TYPEB_0) { + if (contact_info->contact_direction == aMR_CONTACT_DIR_FRONT || + contact_info->contact_direction == aMR_CONTACT_DIR_BACK) { + return aMR_SLIDE_PULL_JUDGE_TYPE1; + } + } + + return aMR_SLIDE_PULL_JUDGE_TYPE0; +} + +static int aMR_CheckPullPlayerObstacle2(xyz_t* pull0, xyz_t* pull1, aMR_contact_info_c* contact_info, + PLAYER_ACTOR* player, xyz_t move_ofs) { + if (contact_info->contact_flag && contact_info->contact_side == aMR_DIRECT_DOWN && + l_aMR_work.used_list[contact_info->ftrID] == TRUE) { + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(l_aMR_work.ftr_actor_list[contact_info->ftrID].name); + + if (profile != NULL) { + mActor_name_t* fg_p = aMR_GetLayerTopFg(mCoBG_LAYER0); + xyz_t player_pos = player->actor_class.world.position; + int direct = contact_info->direction; + xyz_t target_player_pos; + int ut_x; + int ut_z; + + target_player_pos.x = player_pos.x + move_ofs.x; + target_player_pos.y = player_pos.y + move_ofs.y; + target_player_pos.z = player_pos.z + move_ofs.z; + + ut_x = (int)(target_player_pos.x / mFI_UT_WORLDSIZE_X_F); + ut_z = (int)(target_player_pos.z / mFI_UT_WORLDSIZE_Z_F); + + *pull0 = target_player_pos; + *pull1 = target_player_pos; + + if (aMR_CheckSlidePullJudgeType(contact_info, profile) && fg_p != NULL) { + if (aMR_FtrColCheck(target_player_pos, 18.0f)) { + if (!aMR_FtrColCheck(target_player_pos, 0.5f)) { + aMR_GetPullSlip(pull1, target_player_pos, ut_x, ut_z, direct); + return FALSE; + } else { + return TRUE; + } + } else { + return FALSE; + } + } else { + return FALSE; + } + } else { + return TRUE; + } + } + + return TRUE; +} + +static int aMR_CheckPullPlayerObstacle(xyz_t* pull0, xyz_t* pull1, PLAYER_ACTOR* player, xyz_t move_ofs, int direct) { + mActor_name_t* fg_p = aMR_GetLayerTopFg(mCoBG_LAYER0); + + if (fg_p != NULL) { + int ut_x = (int)(player->actor_class.world.position.x / mFI_UT_WORLDSIZE_X_F); + int ut_z = (int)(player->actor_class.world.position.z / mFI_UT_WORLDSIZE_Z_F); + + if (aMR_Direct2PlussUnit(&ut_x, &ut_z, direct)) { + int ut = ut_x + ut_z * UT_X_NUM; + mActor_name_t item_no; + int ftrID; + + if (fg_p[ut] == RSV_WALL_NO || fg_p[ut] == RSV_FE1C || ITEM_NAME_GET_TYPE(fg_p[ut]) == NAME_TYPE_WARP) { + return TRUE; + } + + aMR_UnitNum2FtrItemNoFtrID(&item_no, &ftrID, ut_x, ut_z, mCoBG_LAYER0); + if ((ITEM_IS_FTR(item_no) || item_no == RSV_FE1F) && ftrID >= 0 && ftrID < l_aMR_work.list_size) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[ftrID]; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + if (profile != NULL && + aFTR_CHECK_INTERACTION(profile->interaction_type, aFTR_INTERACTION_TYPE_NO_COLLISION) == FALSE) { + return TRUE; + } + } + } + + pull0->x = player->actor_class.world.position.x + move_ofs.x; + pull0->y = player->actor_class.world.position.y + move_ofs.y; + pull0->z = player->actor_class.world.position.z + move_ofs.z; + + pull1->x = pull0->x; + pull1->y = pull0->y; + pull1->z = pull0->z; + + return FALSE; + } + + return TRUE; +} + +static void aMR_PlacePullFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game) { + static s_xyz move_table[4] = { + { 0, 0, -1 }, /* aMR_DIRECT_UP */ + { -1, 0, 0 }, /* aMR_DIRECT_LEFT */ + { 0, 0, 1 }, /* aMR_DIRECT_DOWN */ + { 1, 0, 0 }, /* aMR_DIRECT_RIGHT */ + }; + + static xyz_t target_table[4] = { + { 0.0f, 0.0f, -mFI_UT_WORLDSIZE_Z_F }, /* aMR_DIRECT_UP */ + { -mFI_UT_WORLDSIZE_X_F, 0.0f, 0.0f }, /* aMR_DIRECT_LEFT */ + { 0.0f, 0.0f, mFI_UT_WORLDSIZE_Z_F }, /* aMR_DIRECT_DOWN */ + { mFI_UT_WORLDSIZE_X_F, 0.0f, 0.0f }, /* aMR_DIRECT_RIGHT */ + }; + + if (contact_info->ftrID >= 0 && contact_info->ftrID < l_aMR_work.list_size && contact_info->contact_flag == TRUE && + contact_info->contact_side == aMR_DIRECT_DOWN && l_aMR_work.used_list[contact_info->ftrID] == TRUE && + my_room->state == 8 && my_room->pull_timer > 16 && + mPlib_check_player_actor_main_index_Furniture_Move(game) == FALSE) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + + if (ftr_actor->state == aFTR_STATE_STOP) { + int direct = contact_info->direction; + int ut_x; + int ut_z; + int ut; + int target_ut_x; + int target_ut_z; + int target_ut; + + aMR_Wpos2PlaceNumber(&ut_x, &ut_z, ftr_actor->position, ftr_actor->shape_type); + ut = ut_x + ut_z * UT_X_NUM; + + target_ut_x = ut_x + move_table[direct].x; + target_ut_z = ut_z + move_table[direct].z; + target_ut = target_ut_x + target_ut_z * UT_X_NUM; + + if (aMR_JudgeStickFull(direct, game) == TRUE) { + xyz_t* target_pos = &target_table[direct]; + + if (aMR_CheckPullPlayerObstacle(&my_room->pull_target_pos0, &my_room->pull_target_pos1, player, + *target_pos, direct) == FALSE) { + if (aMR_CheckPullPlayerObstacle2(&my_room->pull_target_pos0, &my_room->pull_target_pos1, + contact_info, player, *target_pos) == FALSE) { + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, ut, aMR_NO_FTR_ID, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, FALSE); + + if (aMR_JudgeFurnitureMove(ftr_actor->shape_type, target_ut) && + aMR_RequestItemToFitFurniture((ACTOR*)my_room, ftr_actor)) { + xyz_t goki_pos; + + my_room->state = 3; + ftr_actor->state = aFTR_STATE_WAIT_PULL; + ftr_actor->target_direction = direct; + ftr_actor->target_position.x = ftr_actor->position.x + target_table[direct].x; + ftr_actor->target_position.y = ftr_actor->position.y + target_table[direct].y; + ftr_actor->target_position.z = ftr_actor->position.z + target_table[direct].z; + + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, target_ut, ftr_actor->id, + ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->target_position, TRUE); + aMR_SetPullMoveAnime(ftr_actor, game, my_room, contact_info); + aMR_SetMoveSE(ftr_actor); + my_room->pull_timer = 0; + mMkRm_ReportChangePlayerRoom(); + my_room->keep_pull_flag = TRUE; + + if (aMR_GokiburiPos_Pull(&goki_pos, ftr_actor, player)) { + aMR_MakeGokiburi(&goki_pos, game, 1); + } + } else { + /* Can't move the furniture */ + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, ut, ftr_actor->id, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, TRUE); + aMR_SetBubu(player, my_room, game, &my_room->pull_bubu); + } + } else { + aMR_SetBubu(player, my_room, game, &my_room->pull_bubu); + } + } else { + aMR_SetBubu(player, my_room, game, &my_room->pull_bubu); + } + } + } + } +} + +static void aMR_PlacePushFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, f32* point, + PLAYER_ACTOR* player, GAME* game) { + static s_xyz push_move_table[4] = { + { 0, 0, 1 }, /* aMR_DIRECT_UP */ + { 1, 0, 0 }, /* aMR_DIRECT_LEFT */ + { 0, 0, -1 }, /* aMR_DIRECT_DOWN */ + { -1, 0, 0 }, /* aMR_DIRECT_RIGHT */ + }; + + static xyz_t push_target_table[4] = { + { 0.0f, 0.0f, mFI_UT_WORLDSIZE_Z_F }, /* aMR_DIRECT_UP */ + { mFI_UT_WORLDSIZE_X_F, 0.0f, 0.0f }, /* aMR_DIRECT_LEFT */ + { 0.0f, 0.0f, -mFI_UT_WORLDSIZE_Z_F }, /* aMR_DIRECT_DOWN */ + { -mFI_UT_WORLDSIZE_X_F, 0.0f, 0.0f }, /* aMR_DIRECT_RIGHT */ + }; + + if (my_room->state == 7 && contact_info->contact_flag == TRUE && contact_info->contact_side == aMR_DIRECT_DOWN && + l_aMR_work.used_list[contact_info->ftrID] == TRUE && my_room->push_timer > 16 && + mPlib_check_player_actor_main_index_Furniture_Move(game) == FALSE) { + int direct = contact_info->direction; + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + + if (ftr_actor->state == aFTR_STATE_STOP) { + int ut_x; + int ut_z; + int ut; + int target_ut_x; + int target_ut_z; + int target_ut; + + aMR_Wpos2PlaceNumber(&ut_x, &ut_z, ftr_actor->position, ftr_actor->shape_type); + ut = ut_x + ut_z * UT_X_NUM; + + target_ut_x = ut_x + push_move_table[direct].x; + target_ut_z = ut_z + push_move_table[direct].z; + target_ut = target_ut_x + target_ut_z * UT_X_NUM; + + if (aMR_JudgeStickFull(aMR_PullDirect2PushDirect(direct), game)) { + xyz_t* target_pos = &push_target_table[direct]; + + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, ut, aMR_NO_FTR_ID, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, FALSE); + + if (aMR_JudgeFurnitureMove(ftr_actor->shape_type, target_ut) && + aMR_RequestItemToFitFurniture((ACTOR*)my_room, ftr_actor)) { + xyz_t goki_pos; + + my_room->state = 2; + ftr_actor->state = aFTR_STATE_WAIT_PUSH; + ftr_actor->target_direction = aMR_PullDirect2PushDirect(direct); + ftr_actor->target_position.x = ftr_actor->position.x + push_target_table[direct].x; + ftr_actor->target_position.y = ftr_actor->position.y + push_target_table[direct].y; + ftr_actor->target_position.z = ftr_actor->position.z + push_target_table[direct].z; + + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, target_ut, ftr_actor->id, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->target_position, TRUE); + aMR_SetPushMoveAnime(ftr_actor, game, my_room, contact_info); + aMR_SetMoveSE(ftr_actor); + mMkRm_ReportChangePlayerRoom(); + my_room->keep_push_flag = TRUE; + + if (aMR_GokiburiPos_Push(&goki_pos, ftr_actor, player)) { + aMR_MakeGokiburi(&goki_pos, game, 1); + } + } else { + /* Can't move the furniture */ + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, ut, ftr_actor->id, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, TRUE); + aMR_SetBubu(player, my_room, game, &my_room->push_bubu); + } + } + } + } +} + +static int aMR_DecideKurukuruDirect(MY_ROOM_ACTOR* my_room, s16* state, aMR_contact_info_c* contact_info, + FTR_ACTOR* ftr_actor, GAME* game) { + int direct = contact_info->direction; + int left = rotateDt[direct].left; + int right = rotateDt[direct].right; + + if (my_room->allow_rotation_flag) { + if (aMR_JudgeStickFull(left, game)) { + *state = aFTR_STATE_WAIT_LROTATE; + ftr_actor->rotation_delay_timer = 3; + return TRUE; + } + + if (aMR_JudgeStickFull(right, game)) { + *state = aFTR_STATE_WAIT_RROTATE; + ftr_actor->rotation_delay_timer = 3; + return TRUE; + } + } + + return FALSE; +} + +static void aMR_SetTargetAngle(FTR_ACTOR* ftr_actor) { + if (ftr_actor->state == aFTR_STATE_WAIT_RROTATE) { + ftr_actor->angle_y_target = ftr_actor->angle_y - 90.0f; + } else { + ftr_actor->angle_y_target = ftr_actor->angle_y + 90.0f; + } +} + +static s_xyz* aMR_GetRotateForbidData(s16 rotation_state, u8 shape) { + int idx = (int)shape; + + if (rotation_state == aFTR_STATE_WAIT_RROTATE) { + return rotate_forbid_table[idx].right; + } else { + return rotate_forbid_table[idx].left; + } +} + +static int aMR_SearchCompleteObstacle(FTR_ACTOR* ftr_actor, s16 rotation_state, int player_ut, int ftr_ut) { + u8 shape = ftr_actor->shape_type; + mActor_name_t* fg_p = mFI_BkNumtoUtFGTop(0, 0); + s_xyz* rotate_forbid_data = aMR_GetRotateForbidData(rotation_state, shape); + int i; + + for (i = 0; i < 2; i++) { + int ut = ftr_ut + rotate_forbid_data[i].z * UT_X_NUM + rotate_forbid_data[i].x; + + if (l_place_table[ut] != aMR_NO_FTR_ID) { + return FALSE; + } + + if (fg_p[ut] != EMPTY_NO) { + return FALSE; + } + + if (ut == player_ut) { + return FALSE; + } + } + + return TRUE; +} + +static int aMR_SearchFrictionObstacle(FTR_ACTOR* ftr_actor, s16 rotation_state, int ftr_ut) { + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + int shape = ftr_actor->shape_type; + + if (profile->check_rotation && shape <= aFTR_SHAPE_TYPEB_0) { + int i; + s_xyz* rotate_forbid_data; + + if (rotation_state == aFTR_STATE_WAIT_RROTATE) { + rotate_forbid_data = rotate_forbid_friction_table[shape].right; + } else { + rotate_forbid_data = rotate_forbid_friction_table[shape].left; + } + + for (i = 0; i < 2; i++) { + int ut = ftr_ut + rotate_forbid_data[i].z * UT_X_NUM + rotate_forbid_data[i].x; + + if (l_place_table[ut] != aMR_NO_FTR_ID) { + FTR_ACTOR* other_ftr_actor = &l_aMR_work.ftr_actor_list[l_place_table[ut]]; + aFTR_PROFILE* other_profile = aMR_GetFurnitureProfile(other_ftr_actor->name); + + if (other_profile->check_rotation) { + return FALSE; + } + } + } + } + + return TRUE; +} + +static int aMR_RotatePermission(FTR_ACTOR* ftr_actor, PLAYER_ACTOR* player, s16 rotation_state) { + int player_ut_x; + int player_ut_z; + int player_ut; + int ftr_ut_x; + int ftr_ut_z; + int ftr_ut; + + aMR_Wpos2PlaceNumber(&player_ut_x, &player_ut_z, player->actor_class.world.position, 0); + player_ut = player_ut_z * UT_X_NUM + player_ut_x; + + aMR_Wpos2PlaceNumber(&ftr_ut_x, &ftr_ut_z, ftr_actor->position, ftr_actor->shape_type); + ftr_ut = ftr_ut_z * UT_X_NUM + ftr_ut_x; + + if (aMR_SearchCompleteObstacle(ftr_actor, rotation_state, player_ut, ftr_ut)) { + if (aMR_SearchFrictionObstacle(ftr_actor, rotation_state, ftr_ut)) { + return TRUE; + } else { + return FALSE; + } + } else { + return FALSE; + } +} + +static int aMR_ResetFurnitureType(FTR_ACTOR* ftr_actor, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + s16 rotation_state) { + int sub_idx; + u8 shape; + int direct; + f32 contact_ratio; + aMR_type_target_c type_target; + + contact_ratio = contact_info->contact_percent; + direct = contact_info->direction; + + if (contact_ratio >= 0.5f) { + sub_idx = 0; + } else { + sub_idx = 1; + } + + shape = ftr_actor->shape_type; + type_target = type_target_table[shape][direct][sub_idx]; + + if (type_target.type != shape) { + ftr_actor->shape_type = type_target.type; + ftr_actor->position.x += type_target.offset.x; + ftr_actor->position.y += type_target.offset.y; + ftr_actor->position.z += type_target.offset.z; + aMR_MoveShapeCenter(ftr_actor); + } + + return aMR_RotatePermission(ftr_actor, player, rotation_state); +} + +static void aMR_TypeChangeByRotate(FTR_ACTOR* ftr_actor) { + static u8 rt_place_tbl[] = { aFTR_SHAPE_TYPEB_0, aFTR_SHAPE_TYPEB_90, aFTR_SHAPE_TYPEB_180, aFTR_SHAPE_TYPEB_270 }; + static u8 lt_place_tbl[] = { aFTR_SHAPE_TYPEB_180, aFTR_SHAPE_TYPEB_270, aFTR_SHAPE_TYPEB_0, aFTR_SHAPE_TYPEB_90 }; + + if (ftr_actor->state == aFTR_STATE_WAIT_LROTATE) { + ftr_actor->shape_type = lt_place_tbl[ftr_actor->shape_type]; + } else { + ftr_actor->shape_type = rt_place_tbl[ftr_actor->shape_type]; + } +} + +static int aMR_SearchNextSituation(FTR_ACTOR* ftr_actor) { + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + int shape = ftr_actor->shape_type; + int ut_x; + int ut_z; + int ut; + + aMR_Wpos2PlaceNumber(&ut_x, &ut_z, ftr_actor->position, shape); + ut = ut_z * UT_X_NUM + ut_x; + + if (shape > aFTR_SHAPE_TYPEB_0 && profile->check_rotation) { + aMR_place_info_c* place_info = next_table[shape]; + + if (place_info != NULL) { + int count = place_info->count; + s_xyz* ofs_p = place_info->ofs_p; + int i; + + for (i = 0; i < count; i++) { + int check_ut = ut + ofs_p[i].z * UT_Z_NUM + ofs_p[i].x; + + if (l_place_table[check_ut] != aMR_NO_FTR_ID) { + FTR_ACTOR* other_ftr_actor = &l_aMR_work.ftr_actor_list[l_place_table[check_ut]]; + aFTR_PROFILE* other_profile = aMR_GetFurnitureProfile(other_ftr_actor->name); + + if (other_profile->check_rotation) { + return FALSE; + } + } + } + } + } + + return TRUE; +} + +typedef struct sit_data_s { + u8* direction_p; + int direction_count; +} aMR_sit_data_c; + +static u8 aMR_sit_small_chair1[] = { aMR_CONTACT_DIR_FRONT }; +static aMR_sit_data_c aMR_sit_small_chair1_data = { aMR_sit_small_chair1, ARRAY_COUNT(aMR_sit_small_chair1) }; + +static u8 aMR_sit_small_chair4[] = { aMR_CONTACT_DIR_BACK, aMR_CONTACT_DIR_RIGHT, aMR_CONTACT_DIR_FRONT, + aMR_CONTACT_DIR_LEFT }; +static aMR_sit_data_c aMR_sit_small_chair4_data = { aMR_sit_small_chair4, ARRAY_COUNT(aMR_sit_small_chair4) }; + +static u8 aMR_sit_middle_sofa[] = { aMR_CONTACT_DIR_FRONT }; +static aMR_sit_data_c aMR_sit_middle_sofa_data = { aMR_sit_middle_sofa, ARRAY_COUNT(aMR_sit_middle_sofa) }; + +static aMR_sit_data_c* aME_sit_data[] = { + &aMR_sit_small_chair1_data, + &aMR_sit_small_chair4_data, + &aMR_sit_middle_sofa_data, +}; + +static void aMR_SitDownFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + int angle = (u16)((s16)(DEG2SHORT_ANGLE2(270.0f) + gamePT->mcon.move_angle + (s16)getCamera2AngleY(play)) - + player->actor_class.shape_info.rotation.y); + + if (contact_info->contact_flag) { + f32 point[] = { 0.0f, -1.0f }; + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + f32 angle_f; + + aMR_RotateY(point, SHORT2RAD_ANGLE2(player->actor_class.shape_info.rotation.y)); + angle_f = ABS(mCoBG_Get2VectorAngleF(contact_info->normal_p, point, 1)); // This gets called 3 times due to ABS + + if (ftr_actor->state != aFTR_STATE_BYE && ftr_actor->state != aFTR_STATE_BIRTH_WAIT && + ftr_actor->state != aFTR_STATE_BIRTH && ftr_actor->state != aFTR_STATE_DEATH && + contact_info->contact_side == aMR_CONTACT_DIR_FRONT && my_room->state == 0 && + aMR_3DStickNuetral() == FALSE && angle < DEG2SHORT_ANGLE2(15.0f) && angle_f < 15.0f && + gamePT->mcon.move_pR > 0.6f) { + my_room->sit_timer++; + } else { + my_room->sit_timer = 0; + } + } else { + my_room->sit_timer = 0; + } + + if (my_room->sit_timer > 14 && my_room->state == 0 && contact_info->contact_flag == TRUE && + contact_info->contact_side == aMR_CONTACT_DIR_FRONT) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + u8 used = l_aMR_work.used_list[contact_info->ftrID]; + int ftr_no = ftr_actor->name; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_no); + + if (profile != NULL && used) { + u8 contact_action = profile->contact_action; + int i; + + for (i = 0; i < 3; i++) { + if (((contact_action >> i) & 1) != 0) { + aMR_sit_data_c* sit_data = aME_sit_data[i]; + int j; + + for (j = 0; j < sit_data->direction_count; j++) { + if (contact_info->contact_direction == sit_data->direction_p[j]) { + xyz_t nice_pos = { 0.0f, 0.0f, 0.0f }; + + aMR_SetNicePos(&nice_pos, player->actor_class.world.position, + contact_info->contact_edge_start, contact_info->contact_edge_end, + contact_info, 2); + my_room->nice_pos = nice_pos; + mPlib_request_main_sitdown_type1(game, aMR_GetPlayerDirect(contact_info->normal_p), + &nice_pos, ftr_no); + return; + } + } + } + } + } + } +} + +static int aMR_GetBedHeadDirect(FTR_ACTOR* ftr_actor) { + u16 angle = ftr_actor->s_angle_y; + + if (angle >= (DEG2SHORT_ANGLE2(90.0f) - 2) && angle <= (DEG2SHORT_ANGLE2(90.0f) + 2)) { + return aMR_DIRECT_DOWN; + } else if (angle >= (DEG2SHORT_ANGLE2(180.0f) - 2) && angle <= (DEG2SHORT_ANGLE2(180.0f) + 2)) { + return aMR_DIRECT_RIGHT; + } else if (angle >= (DEG2SHORT_ANGLE2(270.0f) - 2) && angle <= (DEG2SHORT_ANGLE2(270.0f) + 2)) { + return aMR_DIRECT_UP; + } else { + return aMR_DIRECT_LEFT; + } +} + +static FTR_ACTOR* aMR_Wpos2FtrInfo(xyz_t pos, u8* action, u16* inter, s16 layer) { + int ut_x; + int ut_z; + + *action = aFTR_CONTACT_ACTION_NONE; + *inter = aFTR_INTERACTION_NONE; + + if (mFI_Wpos2UtNum(&ut_x, &ut_z, pos)) { + mActor_name_t item_no; + int ftrID; + + aMR_UnitNum2FtrItemNoFtrID(&item_no, &ftrID, ut_x, ut_z, layer); + if ((ITEM_IS_FTR(item_no) || item_no == RSV_FE1F) && ftrID >= 0 && ftrID < l_aMR_work.list_size) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[ftrID]; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + if (profile != NULL) { + *action = profile->contact_action; + *inter = profile->interaction_type; + return ftr_actor; + } + } + } + + return NULL; +} + +static int aMR_GetUnderfootSidePos(xyz_t* left, xyz_t* right, FTR_ACTOR* ftr_actor, u8 exist) { + static xyz_t pos0 = { 0.0f, 0.0f, 0.0f }; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + *left = pos0; + *right = pos0; + + if (profile != NULL && exist) { + if ((profile->contact_action >> aFTR_CONTACT_ACTION_TYPE_BED_SINGLE) & 1) { + xyz_t pos = ftr_actor->base_position; + f32 angle = SHORT2RAD_ANGLE2(ftr_actor->s_angle_y); + + left->x = pos.x + mFI_UT_WORLDSIZE_X_F; + left->y = pos.y; + left->z = pos.z - mFI_UT_WORLDSIZE_Z_F; + + sMath_RotateY(left, angle); + left->x += ftr_actor->position.x; + left->y += ftr_actor->position.y; + left->z += ftr_actor->position.z; + + right->x = pos.x + mFI_UT_WORLDSIZE_X_F; + right->y = pos.y; + right->z = pos.z + mFI_UT_WORLDSIZE_Z_F; + sMath_RotateY(right, angle); + right->x += ftr_actor->position.x; + right->y += ftr_actor->position.y; + right->z += ftr_actor->position.z; + + return TRUE; + } + + if ((profile->contact_action >> aFTR_CONTACT_ACTION_TYPE_BED_DOUBLE) & 1) { + xyz_t pos = ftr_actor->base_position; + f32 angle = SHORT2RAD_ANGLE2(ftr_actor->s_angle_y); + + left->x = pos.x + mFI_UT_WORLDSIZE_HALF_X_F; + left->y = pos.y; + left->z = pos.z - (mFI_UT_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F); + + sMath_RotateY(left, angle); + left->x += ftr_actor->position.x; + left->y += ftr_actor->position.y; + left->z += ftr_actor->position.z; + + right->x = pos.x + mFI_UT_WORLDSIZE_HALF_X_F; + right->y = pos.y; + right->z = pos.z + (mFI_UT_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F); + sMath_RotateY(right, angle); + right->x += ftr_actor->position.x; + right->y += ftr_actor->position.y; + right->z += ftr_actor->position.z; + + return TRUE; + } + } + + return FALSE; +} + +static int aMR_GetPillowSidePos(xyz_t* left, xyz_t* right, FTR_ACTOR* ftr_actor, u8 exist) { + static xyz_t pos0 = { 0.0f, 0.0f, 0.0f }; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + *left = pos0; + *right = pos0; + + if (profile != NULL && exist) { + if ((profile->contact_action >> aFTR_CONTACT_ACTION_TYPE_BED_SINGLE) & 1) { + xyz_t pos = ftr_actor->base_position; + f32 angle = SHORT2RAD_ANGLE2(ftr_actor->s_angle_y); + + left->x = pos.x; + left->y = pos.y; + left->z = pos.z - mFI_UT_WORLDSIZE_Z_F; + + sMath_RotateY(left, angle); + left->x += ftr_actor->position.x; + left->y += ftr_actor->position.y; + left->z += ftr_actor->position.z; + + right->x = pos.x; + right->y = pos.y; + right->z = pos.z + mFI_UT_WORLDSIZE_Z_F; + sMath_RotateY(right, angle); + right->x += ftr_actor->position.x; + right->y += ftr_actor->position.y; + right->z += ftr_actor->position.z; + + return TRUE; + } + + if ((profile->contact_action >> aFTR_CONTACT_ACTION_TYPE_BED_DOUBLE) & 1) { + xyz_t pos = ftr_actor->base_position; + f32 angle = SHORT2RAD_ANGLE2(ftr_actor->s_angle_y); + + left->x = pos.x - mFI_UT_WORLDSIZE_HALF_X_F; + left->y = pos.y; + left->z = pos.z - (mFI_UT_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F); + + sMath_RotateY(left, angle); + left->x += ftr_actor->position.x; + left->y += ftr_actor->position.y; + left->z += ftr_actor->position.z; + + right->x = pos.x - mFI_UT_WORLDSIZE_HALF_X_F; + right->y = pos.y; + right->z = pos.z + (mFI_UT_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F); + sMath_RotateY(right, angle); + right->x += ftr_actor->position.x; + right->y += ftr_actor->position.y; + right->z += ftr_actor->position.z; + + return TRUE; + } + } + + return FALSE; +} + +static int aMR_CheckBedUnderfoot(aMR_contact_info_c* contact_info, PLAYER_ACTOR* player) { + if (contact_info->contact_flag == TRUE) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + u8 used = l_aMR_work.used_list[contact_info->ftrID]; + mActor_name_t* fg_p = aMR_GetLayerTopFg(mCoBG_LAYER0); + xyz_t pillow_left; + xyz_t pillow_right; + + if (aMR_GetPillowSidePos(&pillow_left, &pillow_right, ftr_actor, used)) { + int player_ut_x = (int)(player->actor_class.world.position.x / mFI_UT_WORLDSIZE_X_F); + int player_ut_z = (int)(player->actor_class.world.position.z / mFI_UT_WORLDSIZE_Z_F); + int pillow_left_ut_x = (int)(pillow_left.x / mFI_UT_WORLDSIZE_X_F); + int pillow_left_ut_z = (int)(pillow_left.z / mFI_UT_WORLDSIZE_Z_F); + int pillow_right_ut_x = (int)(pillow_right.x / mFI_UT_WORLDSIZE_X_F); + int pillow_right_ut_z = (int)(pillow_right.z / mFI_UT_WORLDSIZE_Z_F); + xyz_t underfoot_left; + xyz_t underfoot_right; + u8 contact_action_type; + u16 inter_type; + + /* Check left first */ + if (player_ut_x == pillow_left_ut_x && player_ut_z == pillow_left_ut_z) { + if (aMR_GetUnderfootSidePos(&underfoot_left, &underfoot_right, ftr_actor, used)) { + if (aMR_Wpos2FtrInfo(underfoot_left, &contact_action_type, &inter_type, mCoBG_LAYER0) != NULL) { + if (aFTR_CHECK_INTERACTION(inter_type, aFTR_INTERACTION_TYPE_NO_COLLISION) == FALSE) { + return TRUE; + } + } else { + int underfoot_left_ut_x = (int)(underfoot_left.x / mFI_UT_WORLDSIZE_X_F); + int underfoot_left_ut_z = (int)(underfoot_left.z / mFI_UT_WORLDSIZE_Z_F); + int underfoot_left_ut = underfoot_left_ut_z * UT_X_NUM + underfoot_left_ut_x; + + if (fg_p[underfoot_left_ut] == RSV_WALL_NO || fg_p[underfoot_left_ut] == RSV_FE1C || + ITEM_NAME_GET_TYPE(fg_p[underfoot_left_ut]) == NAME_TYPE_WARP) { + return TRUE; + } + } + } + } + + /* Check right */ + if (player_ut_x == pillow_right_ut_x && player_ut_z == pillow_right_ut_z) { + if (aMR_GetUnderfootSidePos(&underfoot_left, &underfoot_right, ftr_actor, used)) { + if (aMR_Wpos2FtrInfo(underfoot_right, &contact_action_type, &inter_type, mCoBG_LAYER0) != NULL) { + if (aFTR_CHECK_INTERACTION(inter_type, aFTR_INTERACTION_TYPE_NO_COLLISION) == FALSE) { + return TRUE; + } + } else { + int underfoot_right_ut_x = (int)(underfoot_right.x / mFI_UT_WORLDSIZE_X_F); + int underfoot_right_ut_z = (int)(underfoot_right.z / mFI_UT_WORLDSIZE_Z_F); + int underfoot_right_ut = underfoot_right_ut_z * UT_X_NUM + underfoot_right_ut_x; + + if (fg_p[underfoot_right_ut] == RSV_WALL_NO || fg_p[underfoot_right_ut] == RSV_FE1C || + ITEM_NAME_GET_TYPE(fg_p[underfoot_right_ut]) == NAME_TYPE_WARP) { + return TRUE; + } + } + } + } + } + } + + return FALSE; +} + +static void aMR_JudgeGoToBed(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + u16 angle = (s16)(DEG2SHORT_ANGLE2(270.0f) + gamePT->mcon.move_angle + (s16)getCamera2AngleY(play)) - + player->actor_class.shape_info.rotation.y; + + if (contact_info->contact_flag == TRUE) { + f32 point[] = { 0.0f, -1.0f }; + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + f32 angle_f; + + aMR_RotateY(point, SHORT2RAD_ANGLE2(player->actor_class.shape_info.rotation.y)); + angle_f = ABS(mCoBG_Get2VectorAngleF(contact_info->normal_p, point, 1)); // This gets called 3 times due to ABS + + if (ftr_actor->state != aFTR_STATE_BYE && ftr_actor->state != aFTR_STATE_BIRTH_WAIT && + ftr_actor->state != aFTR_STATE_BIRTH && ftr_actor->state != aFTR_STATE_DEATH && my_room->state == 0 && + aMR_3DStickNuetral() == FALSE && angle < DEG2SHORT_ANGLE(35.0f) && angle_f < 35.0f && + gamePT->mcon.move_pR > 0.6f) { + if (aMR_CheckBedUnderfoot(contact_info, player) == FALSE) { + my_room->bed_timer++; + } else { + my_room->bed_timer = 0; + } + } else { + my_room->bed_timer = 0; + } + } else { + my_room->bed_timer = 0; + } + + if (my_room->bed_timer > 14 && my_room->state == 0 && contact_info->contact_flag == TRUE && + contact_info->contact_side == aMR_CONTACT_DIR_FRONT) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + u8 used = l_aMR_work.used_list[contact_info->ftrID]; + int ftr_no = ftr_actor->name; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_no); + + if (profile != NULL && used) { + if (aFTR_CHK_BED(profile->contact_action)) { + if (contact_info->contact_direction == aMR_CONTACT_DIR_FRONT || + contact_info->contact_direction == aMR_CONTACT_DIR_BACK) { + xyz_t nice_pos = { 0.0f, 0.0f, 0.0f }; + int player_direct; + int head_direct; + + aMR_SetNicePos(&nice_pos, player->actor_class.world.position, contact_info->contact_edge_start, + contact_info->contact_edge_end, contact_info, 0); + my_room->nice_pos = nice_pos; + player_direct = aMR_ConvertDirectLevel(aMR_GetPlayerDirect(contact_info->normal_p)); + my_room->head_direction = aMR_GetBedHeadDirect(ftr_actor); + my_room->bed_ftr_actor_idx = contact_info->ftrID; + head_direct = aMR_ConvertDirectLevel(my_room->head_direction); + + if (player_direct != -1 && head_direct != -1) { + mPlib_request_main_lie_bed_type1(game, player_direct, &nice_pos, head_direct, ftr_no); + } + } + } + } + } +} + +static int aMR_CheckHikidashi(FTR_ACTOR* ftr_actor, PLAYER_ACTOR* player, aMR_contact_info_c* contact_info) { + int direct = contact_info->direction; + int x0; + int z0; + int x1; + int z1; + + if (aMR_GetTypeBPlaceInfo(&x0, &z0, &x1, &z1, ftr_actor->shape_type, ftr_actor->position)) { + mActor_name_t* fg_p = aMR_GetLayerTopFg(mCoBG_LAYER0); + + if (fg_p != NULL && aMR_Direct2PlussUnit(&x0, &z0, direct) && aMR_Direct2PlussUnit(&x1, &z1, direct)) { + int ut0 = z0 * UT_X_NUM + x0; + int ut1 = z1 * UT_X_NUM + x1; + mActor_name_t fg0 = fg_p[ut0]; + mActor_name_t fg1 = fg_p[ut1]; + + if (!(ITEM_IS_FTR(fg0) || fg0 == RSV_FE1F) && !(ITEM_IS_FTR(fg1) || fg1 == RSV_FE1F)) { + return TRUE; + } + } + } + + return FALSE; +} + +static void aMR_SetOpenFtrDemoData(MY_ROOM_ACTOR* my_room, FTR_ACTOR* ftr_actor, aMR_contact_info_c* contact_info) { + ftr_actor->demo_status = 1; + my_room->msg_timer = 0; + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_MSG; + my_room->demo_flag = TRUE; + my_room->demo_ftrID = contact_info->ftrID; + my_room->pull_timer = 0; +} + +static void aMR_SetMDFtrDemoData(MY_ROOM_ACTOR* my_room, FTR_ACTOR* ftr_actor, aMR_contact_info_c* contact_info) { + ftr_actor->demo_status = 1; + my_room->msg_timer = 0; + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_MD; + my_room->demo_flag = TRUE; + my_room->demo_ftrID = contact_info->ftrID; + my_room->pull_timer = 0; +} + +static int aMR_JudgeDemoStart(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, GAME* game, + PLAYER_ACTOR* player) { + if (my_room->force_open_demo_flag == TRUE && my_room->state == 8 && my_room->demo_flag == FALSE && + contact_info->contact_flag == TRUE && contact_info->contact_side == aMR_CONTACT_DIR_FRONT && + mPlib_check_player_warp_forEvent() == FALSE) { + int stick_direct = aMR_Get3dDirectStatus(contact_info->direction); + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + if (profile != NULL) { + if (contact_info->contact_direction == aMR_CONTACT_DIR_FRONT && + (aFTR_CHECK_INTERACTION(profile->interaction_type, aFTR_INTERACTION_TYPE_WARDROBE) || + aFTR_CHECK_INTERACTION(profile->interaction_type, aFTR_INTERACTION_TYPE_CLOSET))) { + if (ftr_actor->demo_status == FALSE) { + /* Open closet/wardrobe */ + aMR_SetOpenFtrDemoData(my_room, ftr_actor, contact_info); + my_room->force_open_demo_flag = FALSE; + return TRUE; + } + } else if (contact_info->contact_direction == aMR_CONTACT_DIR_FRONT && + aFTR_CHECK_INTERACTION(profile->interaction_type, aFTR_INTERACTION_TYPE_DRAWERS)) { + /* Open drawers if nothing is blocking them */ + if (ftr_actor->demo_status == FALSE) { + if (profile->shape == aFTR_SHAPE_TYPEA) { + aMR_SetOpenFtrDemoData(my_room, ftr_actor, contact_info); + my_room->force_open_demo_flag = FALSE; + return TRUE; + } + + if (aMR_CheckHikidashi(ftr_actor, player, contact_info)) { + aMR_SetOpenFtrDemoData(my_room, ftr_actor, contact_info); + my_room->force_open_demo_flag = FALSE; + return TRUE; + } else { + /* Something is blocking the 2x1 drawers on one side */ + aMR_SetBubu(player, my_room, game, &my_room->pull_bubu); + my_room->force_open_demo_flag = FALSE; + return FALSE; + } + } + } else { + my_room->state = 6; + my_room->pull_timer = 0; + } + } + } + + if (my_room->demo_flag == TRUE) { + return TRUE; + } + + return FALSE; +} + +static void aMR_PlaceKurukuruFurniture(MY_ROOM_ACTOR* my_room, aMR_contact_info_c* contact_info, PLAYER_ACTOR* player, + GAME* game) { + if (my_room->state == 6 && my_room->allow_rotation_flag == TRUE && contact_info->contact_flag == TRUE && + contact_info->contact_side == aMR_CONTACT_DIR_FRONT) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[contact_info->ftrID]; + u8 used = l_aMR_work.used_list[contact_info->ftrID]; + + if (used && ftr_actor->state == aFTR_STATE_STOP) { + s16 rotation_state; + + if (aMR_DecideKurukuruDirect(my_room, &rotation_state, contact_info, ftr_actor, game)) { + u8 shape = ftr_actor->shape_type; + int ftr_ut_x; + int ftr_ut_z; + int ftr_ut; + + aMR_Wpos2PlaceNumber(&ftr_ut_x, &ftr_ut_z, ftr_actor->position, ftr_actor->shape_type); + ftr_ut = ftr_ut_z * UT_X_NUM + ftr_ut_x; + + if (ftr_actor->shape_type <= aFTR_SHAPE_TYPEB_0) { + aMR_SetInfoFurnitureTable(shape, ftr_ut, aMR_NO_FTR_ID, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, FALSE); + + if (aMR_ResetFurnitureType(ftr_actor, contact_info, player, rotation_state) && + aMR_RequestItemToFitFurniture((ACTOR*)my_room, ftr_actor)) { + int next_ut_x; + int next_ut_z; + int next_ut; + xyz_t goki_pos; + + ftr_actor->state = rotation_state; + my_room->state = 4; + aMR_SetTargetAngle(ftr_actor); + my_room->allow_rotation_flag = FALSE; + aMR_TypeChangeByRotate(ftr_actor); + aMR_Wpos2PlaceNumber(&next_ut_x, &next_ut_z, ftr_actor->position, ftr_actor->shape_type); + next_ut = next_ut_z * UT_X_NUM + next_ut_x; + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, next_ut, ftr_actor->id, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, TRUE); + aMR_SetRotateSE(ftr_actor); + mMkRm_ReportChangePlayerRoom(); + + if (aMR_GokiburiPos_Rotate(&goki_pos, ftr_actor, player)) { + aMR_MakeGokiburi(&goki_pos, game, 1); + } + return; + } else { + /* Failed to rotate */ + aMR_SetInfoFurnitureTable(shape, ftr_ut, ftr_actor->id, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, TRUE); + aMR_SetBubu(player, my_room, game, NULL); + } + } else { + if (aMR_SearchNextSituation(ftr_actor) && + aMR_RequestItemToFitFurniture((ACTOR*)my_room, ftr_actor)) { + ftr_actor->state = rotation_state; + my_room->state = 4; + aMR_SetTargetAngle(ftr_actor); + my_room->allow_rotation_flag = FALSE; + aMR_SetRotateSE(ftr_actor); + aMR_SetInfoFurnitureTable(ftr_actor->shape_type, ftr_ut, ftr_actor->id, ftr_actor->layer); + aMR_SetFurniture2FG(ftr_actor, ftr_actor->position, TRUE); + mMkRm_ReportChangePlayerRoom(); + return; + } else { + aMR_SetBubu(player, my_room, game, NULL); + } + } + + my_room->allow_rotation_flag = FALSE; + } + } + } +} + +static void aMR_GetBedTurnPos(xyz_t* player_pos, int direct) { + static xyz_t offset_data[mFI_MOVEDIR_NUM] = { + { 0.0f, 0.0f, 0.0f }, // mFI_MOVEDIR_NONE + { mFI_UT_WORLDSIZE_X_F, 0.0f, 0.0f }, // mFI_MOVEDIR_RIGHT + { -mFI_UT_WORLDSIZE_X_F, 0.0f, 0.0f }, // mFI_MOVEDIR_LEFT + { 0.0f, 0.0f, -mFI_UT_WORLDSIZE_Z_F }, // mFI_MOVEDIR_UP + { 0.0f, 0.0f, mFI_UT_WORLDSIZE_Z_F }, // mFI_MOVEDIR_DOWN + }; + + player_pos->x += offset_data[direct].x; + player_pos->y += offset_data[direct].y; + player_pos->z += offset_data[direct].z; +} + +static int aMR_GetBedAction(ACTOR* player_actorx, int direct) { + xyz_t player_pos; + ACTOR* actorx; + xyz_t head_pos; + xyz_t next_player_pos; + xyz_t next_head_pos; + mActor_name_t* fg_p; + + player_pos = player_actorx->world.position; + actorx = aMR_CLIP->my_room_actor_p; + head_pos = ((PLAYER_ACTOR*)player_actorx)->head_pos; + next_player_pos = player_pos; + next_head_pos = head_pos; + fg_p = aMR_GetLayerTopFg(mCoBG_LAYER0); + + aMR_GetBedTurnPos(&next_player_pos, direct); + aMR_GetBedTurnPos(&next_head_pos, direct); + if (actorx != NULL) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int ut_x; + int ut_z; + + if (mFI_Wpos2UtNum(&ut_x, &ut_z, next_player_pos)) { + mActor_name_t item_no; + int ftrID; + + aMR_UnitNum2FtrItemNoFtrID(&item_no, &ftrID, ut_x, ut_z, mCoBG_LAYER0); + if ((ITEM_IS_FTR(item_no) || item_no == RSV_FE1F) && ftrID >= 0 && ftrID < l_aMR_work.list_size) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[ftrID]; + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + if (profile != NULL) { + if (ftrID == my_room->bed_ftr_actor_idx) { + return mPlayer_BED_ACTION_ROLL; + } + + if (aFTR_CHECK_INTERACTION(profile->interaction_type, aFTR_INTERACTION_TYPE_NO_COLLISION)) { + return mPlayer_BED_ACTION_OUT; + } + + if (aFTR_CHK_BED(profile->contact_action)) { + int cur_ut_x = (int)(player_pos.x / mFI_UT_WORLDSIZE_X_F); + int cur_ut_z = (int)(player_pos.z / mFI_UT_WORLDSIZE_Z_F); + mActor_name_t item_no2 = EMPTY_NO; + int ftrID2 = 0; + + aMR_UnitNum2FtrItemNoFtrID(&item_no2, &ftrID2, cur_ut_x, cur_ut_z, mCoBG_LAYER0); + if ((ITEM_IS_FTR(item_no2) || item_no2 == RSV_FE1F) && ftrID2 >= 0 && + ftrID2 < l_aMR_work.list_size) { + FTR_ACTOR* ftr_actor2 = &l_aMR_work.ftr_actor_list[ftrID2]; + + /* Check if the beds are aligned so that you can roll across them */ + if (ftr_actor->s_angle_y == ftr_actor2->s_angle_y) { + xyz_t bed0_uf_left; + xyz_t bed0_uf_right; + xyz_t bed1_uf_left; + xyz_t bed1_uf_right; + + if (aMR_GetUnderfootSidePos(&bed0_uf_left, &bed0_uf_right, ftr_actor, + l_aMR_work.used_list[ftrID]) && + aMR_GetUnderfootSidePos(&bed1_uf_left, &bed1_uf_right, ftr_actor2, + l_aMR_work.used_list[ftrID2])) { + if (mFI_POS2UT(bed0_uf_left.x) == mFI_POS2UT(bed1_uf_left.x) || + mFI_POS2UT(bed0_uf_left.z) == mFI_POS2UT(bed1_uf_left.z)) { + return mPlayer_BED_ACTION_ROLL; + } + } + } + } + } + + return mPlayer_BED_ACTION_NONE; + } + } else { + int ut = ut_z * UT_X_NUM + ut_x; + + if (fg_p[ut] == RSV_WALL_NO || fg_p[ut] == RSV_FE1C || ITEM_NAME_GET_TYPE(fg_p[ut]) == NAME_TYPE_WARP) { + return mPlayer_BED_ACTION_NONE; + } + } + + return mPlayer_BED_ACTION_OUT; + } + } + + return mPlayer_BED_ACTION_NONE; +} diff --git a/src/ac_my_room_data.c_inc b/src/ac_my_room_data.c_inc index 883e56e5..ea000ba6 100644 --- a/src/ac_my_room_data.c_inc +++ b/src/ac_my_room_data.c_inc @@ -22,32 +22,170 @@ typedef struct { xyz_t offset; } aMR_type_target_c; -static aMR_type_target_c type_target_table[] = { - { 2, { 0.0f, 0.0f, -40.0f } }, { 2, { 0.0f, 0.0f, -40.0f } }, { 2, { 0.0f, 0.0f, -40.0f } }, - { 0, { 0.0f, 0.0f, 0.0f } }, { 0, { 0.0f, 0.0f, 0.0f } }, { 0, { 0.0f, 0.0f, 0.0f } }, - { 0, { 0.0f, 0.0f, 0.0f } }, { 2, { 0.0f, 0.0f, -40.0f } }, { 1, { 0.0f, 0.0f, 0.0f } }, - { 3, { -40.0f, 0.0f, 0.0f } }, { 3, { -40.0f, 0.0f, 0.0f } }, { 3, { -40.0f, 0.0f, 0.0f } }, - { 3, { -40.0f, 0.0f, 0.0f } }, { 1, { 0.0f, 0.0f, 0.0f } }, { 1, { 0.0f, 0.0f, 0.0f } }, - { 1, { 0.0f, 0.0f, 0.0f } }, { 2, { 0.0f, 0.0f, 0.0f } }, { 2, { 0.0f, 0.0f, 0.0f } }, - { 2, { 0.0f, 0.0f, 0.0f } }, { 0, { 0.0f, 0.0f, 40.0f } }, { 0, { 0.0f, 0.0f, 40.0f } }, - { 0, { 0.0f, 0.0f, 40.0f } }, { 0, { 0.0f, 0.0f, 40.0f } }, { 2, { 0.0f, 0.0f, 0.0f } }, - { 1, { 40.0f, 0.0f, 0.0f } }, { 3, { 0.0f, 0.0f, 0.0f } }, { 3, { 0.0f, 0.0f, 0.0f } }, - { 3, { 0.0f, 0.0f, 0.0f } }, { 3, { 0.0f, 0.0f, 0.0f } }, { 1, { 40.0f, 0.0f, 0.0f } }, - { 1, { 40.0f, 0.0f, 0.0f } }, { 1, { 40.0f, 0.0f, 0.0f } }, +static aMR_type_target_c type_target_table[4][4][2] = { + { + { + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, -40.0f } }, + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, -40.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, -40.0f } }, + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, -40.0f } }, + }, + }, + { + { + { aFTR_SHAPE_TYPEB_180, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_0, { -40.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_0, { -40.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_0, { -40.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_0, { -40.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_180, { 0.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_180, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_180, { 0.0f, 0.0f, 0.0f } }, + }, + }, + { + { + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 40.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 40.0f } }, + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 40.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_90, { 0.0f, 0.0f, 40.0f } }, + { aFTR_SHAPE_TYPEB_270, { 0.0f, 0.0f, 0.0f } }, + }, + }, + { + { + { aFTR_SHAPE_TYPEB_180, { 40.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_0, { 0.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_0, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_0, { 0.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_0, { 0.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_180, { 40.0f, 0.0f, 0.0f } }, + }, + { + { aFTR_SHAPE_TYPEB_180, { 40.0f, 0.0f, 0.0f } }, + { aFTR_SHAPE_TYPEB_180, { 40.0f, 0.0f, 0.0f } }, + }, + }, }; -static s16 rotate_forbid_table[][2] = { - { -1, 0 }, { -1, -1 }, { 0, 0 }, { 1, 0 }, { -1, 1 }, { 0, 0 }, { -1, 0 }, { 1, 0 }, - { 0, 1 }, { -1, 0 }, { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 }, { 0, 1 }, { -1, 0 }, - { 0, -1 }, { 0, 1 }, { 0, 0 }, { -1, 1 }, { 0, -1 }, { 0, 0 }, { 1, 1 }, { 0, 1 }, +typedef struct rotate_forbid_data_s { + s_xyz left[2]; + s_xyz right[2]; +} aMR_rotate_forbid_data_c; + +static aMR_rotate_forbid_data_c rotate_forbid_table[4] = { + { + { + { -1, 0, -1 }, + { -1, 0, 0 }, + }, + { + { 1, 0, -1 }, + { 1, 0, 0 }, + }, + }, + { + { + { -1, 0, 1 }, + { 0, 0, 1 }, + }, + { + { -1, 0, -1 }, + { 0, 0, -1 }, + }, + }, + { + { + { 1, 0, 0 }, + { 1, 0, 1 }, + }, + { + { -1, 0, 0 }, + { -1, 0, 1 }, + }, + }, + { + { + { 0, 0, -1 }, + { 1, 0, -1 }, + }, + { + { 0, 0, 1 }, + { 1, 0, 1 }, + }, + }, }; -static s16 rotate_forbid_friction_table[][2] = { - { 0x0000, 0x0000 }, { 0x0001, 0x0001 }, { 0x0000, 0x0000 }, { 0x0000, 0x0000 }, { 0x0001, 0xffff }, - { 0x0000, 0x0000 }, { 0x0001, 0x0000 }, { 0x0000, 0x0000 }, { 0x0000, 0xffff }, { 0x0001, 0x0000 }, - { 0x0000, 0x0000 }, { 0x0000, 0x0001 }, { 0x0000, 0x0000 }, { 0xffff, 0xffff }, { 0x0000, 0x0000 }, - { 0x0000, 0x0000 }, { 0xffff, 0x0001 }, { 0x0000, 0x0000 }, { 0xffff, 0x0000 }, { 0x0000, 0x0000 }, - { 0x0000, 0x0001 }, { 0xffff, 0x0000 }, { 0x0000, 0x0000 }, { 0x0000, 0xffff }, +static aMR_rotate_forbid_data_c rotate_forbid_friction_table[4] = { + { + { + { 0, 0, 1 }, + { 1, 0, 0 }, + }, + { + { 0, 0, 1 }, + { -1, 0, 0 }, + }, + }, + { + { + { 1, 0, 0 }, + { 0, 0, -1 }, + }, + { + { 1, 0, 0 }, + { 0, 0, 1 }, + }, + }, + { + { + { 0, 0, -1 }, + { -1, 0, 0 }, + }, + { + { 0, 0, -1 }, + { 1, 0, 0 }, + }, + }, + { + { + { -1, 0, 0 }, + { 0, 0, 1 }, + }, + { + { -1, 0, 0 }, + { 0, 0, -1 }, + }, + }, }; typedef struct { diff --git a/src/ac_my_room_draw.c_inc b/src/ac_my_room_draw.c_inc new file mode 100644 index 00000000..c20f2cdb --- /dev/null +++ b/src/ac_my_room_draw.c_inc @@ -0,0 +1,378 @@ +static void aMR_SetKankyoMapping(FTR_ACTOR* ftr_actor, GAME_PLAY* play) { + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + switch (profile->kankyo_map) { + case aFTR_KANKYO_MAP_OPA: + Setpos_HiliteReflect_init(&ftr_actor->position, play); + break; + case aFTR_KANKYO_MAP_XLU: + Setpos_HiliteReflect_xlu_init(&ftr_actor->position, play); + break; + } +} + +static void aMR_LoadPallet(aFTR_PROFILE* profile, GAME* game) { + if (profile->palette != NULL) { + if (profile->opaque0 != NULL || profile->opaque1 != NULL || profile->rig != NULL) { + OPEN_DISP(game->graph); + + gDPPipeSync(NEXT_POLY_OPA_DISP); + gDPLoadTLUT_pal16(NEXT_POLY_OPA_DISP, 15, profile->palette); + + CLOSE_DISP(game->graph); + } + + if (profile->translucent0 != NULL || profile->translucent1 != NULL || profile->rig != NULL) { + OPEN_DISP(game->graph); + + gDPPipeSync(NEXT_POLY_XLU_DISP); + gDPLoadTLUT_pal16(NEXT_POLY_XLU_DISP, 15, profile->palette); + + CLOSE_DISP(game->graph); + } + } +} + +static void aMR_LoadTexture(aFTR_PROFILE* profile, GAME* game) { + if (profile->texture != NULL) { + if (profile->opaque0 != NULL || profile->opaque1 != NULL || profile->rig != NULL) { + OPEN_DISP(game->graph); + + gDPPipeSync(NEXT_POLY_OPA_DISP); + gDPLoadTextureBlockS(NEXT_POLY_OPA_DISP, profile->texture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, + G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 7, 7, G_TX_NOLOD, G_TX_NOLOD); + + CLOSE_DISP(game->graph); + } + + if (profile->translucent0 != NULL || profile->translucent1 != NULL || profile->rig != NULL) { + OPEN_DISP(game->graph); + + gDPPipeSync(NEXT_POLY_XLU_DISP); + gDPLoadTextureBlockS(NEXT_POLY_XLU_DISP, profile->texture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, + G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 7, 7, G_TX_NOLOD, G_TX_NOLOD); + + CLOSE_DISP(game->graph); + } + } +} + +static void aMR_SetLoopTextureAnime(FTR_ACTOR* ftr_actor, aFTR_PROFILE* profile, GAME* game) { + aFTR_tex_anim_c* tex_anime = profile->tex_anim; + + if (tex_anime != NULL) { + u8* tex_p = tex_anime->animation[ftr_actor->tex_animation.frame]; + + OPEN_DISP(game->graph); + + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, tex_p); + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_8, tex_p); + + CLOSE_DISP(game->graph); + } +} + +static void aMR_DrawRegistModel(aFTR_PROFILE* profile, GAME* game) { + OPEN_DISP(game->graph); + + if (profile->opaque0 != NULL || profile->opaque1 != NULL) { + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + if (profile->opaque0 != NULL) { + gSPDisplayList(NEXT_POLY_OPA_DISP, profile->opaque0); + } + + if (profile->opaque1 != NULL) { + gSPDisplayList(NEXT_POLY_OPA_DISP, profile->opaque1); + } + + if (profile->translucent0 != NULL || profile->translucent1 != NULL) { + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + if (profile->translucent0 != NULL) { + gSPDisplayList(NEXT_POLY_XLU_DISP, profile->translucent0); + } + + if (profile->translucent1 != NULL) { + gSPDisplayList(NEXT_POLY_XLU_DISP, profile->translucent1); + } + + CLOSE_DISP(game->graph); +} + +static void aMR_DrawSkelShape(FTR_ACTOR* ftr_actor, aFTR_PROFILE* profile, GAME* game) { + if (profile->rig != NULL) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + int mtx_idx = game->frame_counter & 1; + Mtx* mtx = ftr_actor->skeleton_mtx[mtx_idx]; + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, NULL, NULL, NULL); + } +} + +static void aMR_DrawUniqueShape(FTR_ACTOR* ftr_actor, ACTOR* actorx, aFTR_PROFILE* profile, GAME* game) { + if (profile->vtable != NULL && profile->vtable->draw_proc != NULL) { + u8* bank = aMR_FtrNo2BankAddress(ftr_actor->name); + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISP(game->graph); + + profile->vtable->draw_proc(ftr_actor, actorx, game, bank); + } +} + +static void aMR_DrawItemOnMovingFurniture(ACTOR* actorx, FTR_ACTOR* ftr_actor, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + aMR_parent_ftr_c* parent_ftr = &my_room->parent_ftr; + + if (parent_ftr->ftrID == ftr_actor->id) { + int i; + + OPEN_DISP(game->graph); + + gDPSetTexEdgeAlpha(NEXT_POLY_OPA_DISP, 144); + gDPSetTexEdgeAlpha(NEXT_POLY_XLU_DISP, 144); + + for (i = 0; i < aMR_FIT_FTR_MAX; i++) { + if (parent_ftr->fit_ftr_table[i].exist_flag == TRUE) { + mActor_name_t item_no = parent_ftr->fit_ftr_table[i].item_no; + xyz_t* pos = &parent_ftr->fit_ftr_table[i].ut_pos; + + if (Common_Get(clip).shop_goods_clip != NULL && + Common_Get(clip).shop_goods_clip->single_draw_proc != NULL) { + Common_Get(clip).shop_goods_clip->single_draw_proc(game, item_no, pos, 0.01f, + parent_ftr->fit_ftr_table[i].angle_y + + (ftr_actor->s_angle_y - parent_ftr->angle_y), + mCoBG_LAYER1); + } + } + } + + CLOSE_DISP(game->graph); + } +} + +static int aMR_GetFitNo(ACTOR* actorx, FTR_ACTOR* ftr_actor) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + aMR_parent_ftr_c* parent_ftr = &my_room->parent_ftr; + int i; + + for (i = 0; i < aMR_FIT_FTR_MAX; i++) { + if (parent_ftr->fit_ftr_table[i].ftr_ID == ftr_actor->id) { + return i; + } + } + + return -1; +} + +static void aMR_FurnitureLightSet(FTR_ACTOR* ftr_actor, GAME_PLAY* play) { + LightsN* lights; + xyz_t center; + + aMR_GetFtrShapeCenter(¢er, ftr_actor); + lights = Global_light_read(&play->global_light, play->game.graph); + LightsN_list_check(lights, play->global_light.list, ¢er); + LightsN_disp(lights, play->game.graph); +} + +static void aMR_DrawOneFurniture(FTR_ACTOR* ftr_actor, ACTOR* actorx, GAME* game, int fit_flag) { + xyz_t ftr_scale = ftr_actor->scale; + GAME_PLAY* play = (GAME_PLAY*)game; + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + aFTR_PROFILE* profile; + + profile = aMR_GetFurnitureProfile(ftr_actor->name); + if (profile != NULL) { + f32 scale = profile->scale; + + _texture_z_light_fog_prim_xlu(game->graph); + _texture_z_light_fog_prim(game->graph); + aMR_FurnitureLightSet(ftr_actor, play); + aMR_LoadTexture(profile, game); + aMR_LoadPallet(profile, game); + aMR_SetKankyoMapping(ftr_actor, play); + + if (fit_flag == TRUE) { + aMR_parent_ftr_c* parent_ftr = &my_room->parent_ftr; + FTR_ACTOR* fit_ftr_p = &l_aMR_work.ftr_actor_list[parent_ftr->ftrID]; + int fit_no = aMR_GetFitNo(actorx, ftr_actor); + s16 angle = fit_ftr_p->s_angle_y - parent_ftr->angle_y; + aMR_fit_ftr_c* fit_ftr_info_p = &parent_ftr->fit_ftr_table[fit_no & 3]; + xyz_t* pos = &fit_ftr_info_p->pos; + + Matrix_translate(fit_ftr_p->position.x, fit_ftr_p->position.y, fit_ftr_p->position.z, 0); + Matrix_RotateY(angle, 1); + Matrix_translate(fit_ftr_p->base_position.x, fit_ftr_p->base_position.y, fit_ftr_p->base_position.z, 1); + + if (ftr_actor->name == 0x9A) { /* lower alarm clock ftr's height */ + Matrix_translate(pos->x, pos->y - 4.0f, pos->z, 1); + } else { + Matrix_translate(pos->x, pos->y, pos->z, 1); + } + + Matrix_RotateY(ftr_actor->s_angle_y, 1); + Matrix_translate(ftr_actor->base_position.x, ftr_actor->base_position.y, ftr_actor->base_position.z, 1); + + if (ftr_actor->state == aFTR_STATE_BIRTH && ftr_actor->shape_type <= aFTR_SHAPE_TYPEB_0) { + Matrix_translate(mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, 0.0f, 1); + } + Matrix_scale(ftr_scale.x, ftr_scale.y, ftr_scale.z, 1); + + if (ftr_actor->state == aFTR_STATE_BIRTH && ftr_actor->shape_type <= aFTR_SHAPE_TYPEB_0) { + Matrix_translate(-mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, 0.0f, 1); + } + Matrix_scale(scale, scale, scale, 1); + } else { + if (ftr_actor->name == 0x9A) { /* lower alarm clock ftr's height */ + Matrix_translate(ftr_actor->position.x, ftr_actor->position.y - 4.0f, ftr_actor->position.z, 0); + } else { + Matrix_translate(ftr_actor->position.x, ftr_actor->position.y, ftr_actor->position.z, 0); + } + + Matrix_RotateY(ftr_actor->s_angle_y, 1); + + if (Save_Get(scene_no) == SCENE_MUSEUM_ROOM_FOSSIL && + aFTR_CHECK_INTERACTION(profile->interaction_type, aFTR_INTERACTION_TYPE_FOSSIL) && + profile->shape <= aFTR_SHAPE_TYPEB_0) { + Matrix_translate(ftr_actor->base_position.x + 2.5f, ftr_actor->base_position.y, + ftr_actor->base_position.z, 1); + } else { + Matrix_translate(ftr_actor->base_position.x, ftr_actor->base_position.y, ftr_actor->base_position.z, 1); + } + + if (ftr_actor->state == aFTR_STATE_BIRTH && ftr_actor->shape_type <= aFTR_SHAPE_TYPEB_0) { + Matrix_translate(mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, 0.0f, 1); + } + Matrix_scale(ftr_scale.x, ftr_scale.y, ftr_scale.z, 1); + + if (ftr_actor->state == aFTR_STATE_BIRTH && ftr_actor->shape_type <= aFTR_SHAPE_TYPEB_0) { + Matrix_translate(-mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, 0.0f, 1); + } + Matrix_scale(scale, scale, scale, 1); + } + + aMR_SetLoopTextureAnime(ftr_actor, profile, game); + aMR_DrawRegistModel(profile, game); + aMR_DrawSkelShape(ftr_actor, profile, game); + aMR_DrawUniqueShape(ftr_actor, actorx, profile, game); + aMR_DrawItemOnMovingFurniture(actorx, ftr_actor, game); + } +} + +static void aMR_DrawFurniture(MY_ROOM_ACTOR* my_room, GAME_PLAY* play, int ftr_flag, u16 ftr_no) { + ACTOR* actorx = (ACTOR*)my_room; + GAME* game = (GAME*)play; + int i; + int z; + + OPEN_DISP(game->graph); + + gDPSetTexEdgeAlpha(NEXT_POLY_OPA_DISP, 127); + gDPSetTexEdgeAlpha(NEXT_POLY_XLU_DISP, 127); + + CLOSE_DISP(game->graph); + + for (z = UT_Z_NUM - 1; z >= 0; z--) { + FTR_ACTOR* ftr_actor = l_aMR_work.ftr_actor_list; + u8* used = l_aMR_work.used_list; + + for (i = 0; i < l_aMR_work.list_size; i++) { + if (*used == TRUE && mFI_POS2UT(ftr_actor->position.z) == z) { + if ((ftr_flag == FALSE && ftr_actor->name != ftr_no) || + (ftr_flag == TRUE && ftr_actor->name == ftr_no)) { + int alpha_edge; + int fit_flag = (ftr_actor->layer == mCoBG_LAYER0 || my_room->parent_ftr.ftrID == -1 || + (my_room->parent_ftr.ftrID != -1 && + my_room->parent_ftr.fit_ftr_table[0].ftr_ID != ftr_actor->id && + my_room->parent_ftr.fit_ftr_table[1].ftr_ID != ftr_actor->id && + my_room->parent_ftr.fit_ftr_table[2].ftr_ID != ftr_actor->id && + my_room->parent_ftr.fit_ftr_table[3].ftr_ID != ftr_actor->id)) == FALSE; + + alpha_edge = aMR_GetAlphaEdge(ftr_actor->name); + + OPEN_DISP(game->graph); + + gDPSetTexEdgeAlpha(NEXT_POLY_OPA_DISP, alpha_edge); + gDPSetTexEdgeAlpha(NEXT_POLY_XLU_DISP, alpha_edge); + + CLOSE_DISP(game->graph); + + if (aMR_DrawDolphinMode(ftr_actor->name)) { + OPEN_DISP(game->graph); + + gDPSetTextureAdjustMode(NEXT_POLY_OPA_DISP, G_TA_DOLPHIN); + gDPSetTextureAdjustMode(NEXT_POLY_XLU_DISP, G_TA_DOLPHIN); + + CLOSE_DISP(game->graph); + } + + aMR_DrawOneFurniture(ftr_actor, actorx, game, fit_flag); + + if (aMR_DrawDolphinMode(ftr_actor->name)) { + OPEN_DISP(game->graph); + + gDPSetTextureAdjustMode(NEXT_POLY_OPA_DISP, G_TA_N64); + gDPSetTextureAdjustMode(NEXT_POLY_XLU_DISP, G_TA_N64); + + CLOSE_DISP(game->graph); + } + } + } + + ftr_actor++; + used++; + } + } + + OPEN_DISP(game->graph); + + gDPSetTexEdgeAlpha(NEXT_POLY_OPA_DISP, 144); + gDPSetTexEdgeAlpha(NEXT_POLY_XLU_DISP, 144); + + CLOSE_DISP(game->graph); +} + +static void aMR_DrawLeaf(MY_ROOM_ACTOR* my_room, GAME_PLAY* play) { + GAME* game = (GAME*)play; + + if (my_room->leaf_info.exist_flag) { + f32 scale = my_room->leaf_info.scale; + + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + Matrix_translate(my_room->leaf_info.pos.x, my_room->leaf_info.pos.y, my_room->leaf_info.pos.z, 0); + Matrix_scale(scale, scale, scale, 1); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(NEXT_POLY_OPA_DISP, aMR_IconNo2Gfx1(my_room->pickup_info.icon)); + gSPDisplayList(NEXT_POLY_OPA_DISP, aMR_IconNo2Gfx2(my_room->pickup_info.icon)); + + CLOSE_DISP(game->graph); + + my_room->leaf_info.exist_flag = FALSE; + } +} + +static void My_Room_Actor_draw(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + + aMR_DrawFurniture(my_room, play, FALSE, 0x41C); /* lighthouse model */ + aMR_DrawFurniture(my_room, play, TRUE, 0x41C); /* lighthouse model */ + aMR_DrawLeaf(my_room, play); +} diff --git a/src/ac_my_room_move.c_inc b/src/ac_my_room_move.c_inc index 925e47e0..5e552eda 100644 --- a/src/ac_my_room_move.c_inc +++ b/src/ac_my_room_move.c_inc @@ -5,16 +5,16 @@ typedef struct process_info_s { s16 unit_ofs[4]; } aMR_process_info_c; -static aMR_process_info_c aMR_process_typeB90 = { 2, { 0, -UT_X_NUM, 0, 0 } }; -static aMR_process_info_c aMR_process_typeB180 = { 2, { 0, -1, 0, 0 } }; -static aMR_process_info_c aMR_process_typeB270 = { 2, { 0, UT_X_NUM, 0, 0 } }; -static aMR_process_info_c aMR_process_typeB0 = { 2, { 0, 1, 0, 0 } }; -static aMR_process_info_c aMR_process_typeA = { 1, { 0, 0, 0, 0 } }; -static aMR_process_info_c aMR_process_typeC = { 4, { 0, 1, UT_X_NUM, UT_X_NUM + 1 } }; +static aMR_process_info_c aMR_poccess_typeB90 = { 2, { 0, -UT_X_NUM, 0, 0 } }; +static aMR_process_info_c aMR_poccess_typeB180 = { 2, { 0, -1, 0, 0 } }; +static aMR_process_info_c aMR_poccess_typeB270 = { 2, { 0, UT_X_NUM, 0, 0 } }; +static aMR_process_info_c aMR_poccess_typeB0 = { 2, { 0, 1, 0, 0 } }; +static aMR_process_info_c aMR_poccess_typeA = { 1, { 0, 0, 0, 0 } }; +static aMR_process_info_c aMR_poccess_typeC = { 4, { 0, 1, UT_X_NUM, UT_X_NUM + 1 } }; -static aMR_process_info_c* aMR_process_table[aFTR_SHAPE_TYPE_NUM] = { - &aMR_process_typeB90, &aMR_process_typeB180, &aMR_process_typeB270, - &aMR_process_typeB0, &aMR_process_typeA, &aMR_process_typeC, +static aMR_process_info_c* aMR_poccess_table[aFTR_SHAPE_TYPE_NUM] = { + &aMR_poccess_typeB90, &aMR_poccess_typeB180, &aMR_poccess_typeB270, + &aMR_poccess_typeB0, &aMR_poccess_typeA, &aMR_poccess_typeC, }; static int aMR_GetFurniturePoccessUnitNo(int* ut_info, int ut_x, int ut_z, u8 type) { @@ -22,7 +22,7 @@ static int aMR_GetFurniturePoccessUnitNo(int* ut_info, int ut_x, int ut_z, u8 ty int ut = ut_x + ut_z * UT_X_NUM; if (type < aFTR_SHAPE_TYPE_NUM) { - aMR_process_info_c* process_info = aMR_process_table[type]; + aMR_process_info_c* process_info = aMR_poccess_table[type]; int count = process_info->unit_count; int i; @@ -360,19 +360,19 @@ static void aMR_SetCleanUpFtrSE(xyz_t pos) { } static int aMR_GetPlayerDirect(const f32* normal_xz) { - if (normal_xz[0] > (F_PI / 4.0f)) { + if (normal_xz[0] > F_SQRT2_DIV2) { return aMR_DIRECT_LEFT; } - if (normal_xz[0] < -(F_PI / 4.0f)) { + if (normal_xz[0] < -F_SQRT2_DIV2) { return aMR_DIRECT_RIGHT; } - if (normal_xz[1] > (F_PI / 4.0f)) { + if (normal_xz[1] > F_SQRT2_DIV2) { return aMR_DIRECT_UP; } - if (normal_xz[1] < -(F_PI / 4.0f)) { + if (normal_xz[1] < -F_SQRT2_DIV2) { return aMR_DIRECT_DOWN; } @@ -397,19 +397,19 @@ static void aMR_MoveShapeCenter(FTR_ACTOR* ftr_actor) { } static int aMR_Norm2DirectName(f32* normal_xz) { - if (normal_xz[0] > (F_PI / 4.0f)) { + if (normal_xz[0] > F_SQRT2_DIV2) { return aMR_DIRECT_RIGHT; } - if (normal_xz[0] <= -(F_PI / 4.0f)) { + if (normal_xz[0] <= -F_SQRT2_DIV2) { return aMR_DIRECT_LEFT; } - if (normal_xz[1] > (F_PI / 4.0f)) { + if (normal_xz[1] > F_SQRT2_DIV2) { return aMR_DIRECT_DOWN; } - if (normal_xz[1] <= -(F_PI / 4.0f)) { + if (normal_xz[1] <= -F_SQRT2_DIV2) { return aMR_DIRECT_UP; } @@ -1332,6 +1332,8 @@ static void aMR_MngFtrContactAction(ACTOR* actorx, GAME* game) { } } +#include "../src/ac_my_room_action.c_inc" + static f32 aMR_GetDistXZ(const xyz_t* pos0, const xyz_t* pos1) { f32 diff_x = pos0->x - pos1->x; f32 diff_z = pos0->z - pos1->z; @@ -1472,14 +1474,14 @@ static int aMR_CheckPlaceSituation(int ut, int target_ut, u16 ftr_no, u16 angle_ aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_no); if (profile != NULL) { - u32 shape = profile->shape; + u8 shape = profile->shape; if (shape == aFTR_SHAPE_TYPEB_0) { static u8 rotate_angle_types[] = { + aFTR_SHAPE_TYPEB_0, aFTR_SHAPE_TYPEB_90, aFTR_SHAPE_TYPEB_180, aFTR_SHAPE_TYPEB_270, - aFTR_SHAPE_TYPEB_0, }; shape = rotate_angle_types[angle_idx & 3]; diff --git a/src/ac_my_room_msg_ctrl.c_inc b/src/ac_my_room_msg_ctrl.c_inc index cc04018f..9ba626d5 100644 --- a/src/ac_my_room_msg_ctrl.c_inc +++ b/src/ac_my_room_msg_ctrl.c_inc @@ -147,7 +147,6 @@ static void aMR_SetEmulatorStartMessage(ACTOR* actorx, int internal_rom) { mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); mMsg_Set_ForceNext(mMsg_Get_base_window_p()); break; - case FAMICOM_RESULT_NOFILE: default: mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3071); mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); diff --git a/src/audio.c b/src/audio.c index 057d63f4..3540a8ce 100644 --- a/src/audio.c +++ b/src/audio.c @@ -171,7 +171,7 @@ extern void sAdo_SetVoiceMode(u8 mode) { Na_SetVoiceMode(mode); } -extern void sAdo_FloorTrgStart(u16 id, const xyz_t* pos) { +extern void sAdo_FloorTrgStart(u8 id, const xyz_t* pos) { u16 scalc; f32 fcalc; diff --git a/src/m_actor.c b/src/m_actor.c index 5aec1060..7841654d 100644 --- a/src/m_actor.c +++ b/src/m_actor.c @@ -608,18 +608,18 @@ extern void Actor_get_overlay_area(ACTOR_DLFTBL* dlftbl, int unused, size_t allo } } -static int Actor_data_bank_regist_check_npc(int* bank_id, ACTOR_PROFILE* profile, ACTOR_DLFTBL* dlftbl, GAME* game, +static int Actor_data_bank_regist_check_npc(int* bank_id, ACTOR_PROFILE* profile, ACTOR_DLFTBL* dlftbl, GAME_PLAY* play, mActor_name_t name_id) { return TRUE; } -static int Actor_data_bank_regist_check(int* bank_id, ACTOR_PROFILE* profile, ACTOR_DLFTBL* dlftbl, GAME* game, +static int Actor_data_bank_regist_check(int* bank_id, ACTOR_PROFILE* profile, ACTOR_DLFTBL* dlftbl, GAME_PLAY* play, mActor_name_t name_id) { int res = TRUE; if (*bank_id == -1) { if (profile->part == ACTOR_PART_NPC) { - res = Actor_data_bank_regist_check_npc(bank_id, profile, dlftbl, game, name_id); + res = Actor_data_bank_regist_check_npc(bank_id, profile, dlftbl, play, name_id); } else { // in DnM, this was another func call res = TRUE; @@ -687,31 +687,32 @@ extern void Actor_init_actor_class(ACTOR* actor, ACTOR_PROFILE* profile, ACTOR_D actor->npc_id = name_id; } -#ifndef MUST_MATCH -/* @nonmatching */ +typedef struct overlay_struct { + const char* actor_name; +} mAc_overlay_info_c; + extern ACTOR* Actor_info_make_actor(Actor_info* actor_info, GAME* game, s16 profile_no, f32 x, f32 y, f32 z, s16 rot_x, s16 rot_y, s16 rot_z, s8 block_x, s8 block_z, s16 move_actor_list_idx, mActor_name_t name_id, s16 arg, s8 npc_info_idx, int data_bank_idx) { - const char* test = ""; - GAME_PLAY* play = (GAME_PLAY*)game; + GAME_PLAY* play; ACTOR* actor; ACTOR_PROFILE* profile; ACTOR_DLFTBL* dlftbl; + mAc_overlay_info_c overlay_info; /* Required to be a struct, stubbed in GC */ - test = ""; // removing this line helps a bit... - - dlftbl = &actor_dlftbls[profile_no]; - + play = (GAME_PLAY*)game; + dlftbl = actor_dlftbls + profile_no; + overlay_info.actor_name = ""; if (actor_info->total_num > mAc_MAX_ACTORS) { return NULL; } profile = dlftbl->profile; - if (Actor_data_bank_regist_check(&data_bank_idx, profile, dlftbl, game, name_id) == FALSE) { + if (Actor_data_bank_regist_check(&data_bank_idx, profile, dlftbl, play, name_id) == FALSE) { return NULL; } - if (Actor_malloc_actor_class(&actor, profile, dlftbl, test, name_id) == FALSE) { + if (Actor_malloc_actor_class(&actor, profile, dlftbl, overlay_info.actor_name, name_id) == FALSE) { return NULL; } @@ -720,18 +721,10 @@ extern ACTOR* Actor_info_make_actor(Actor_info* actor_info, GAME* game, s16 prof move_actor_list_idx, name_id, arg); Actor_info_part_new(actor_info, actor, profile->part); mNpc_SetNpcinfo(actor, npc_info_idx); - Actor_ct(actor, (GAME*)play); + Actor_ct(actor, game); return actor; } -#else -extern asm ACTOR* Actor_info_make_actor(Actor_info* actor_info, GAME* game, s16 profile_no, f32 x, f32 y, f32 z, - s16 rot_x, s16 rot_y, s16 rot_z, s8 block_x, s8 block_z, - s16 move_actor_list_idx, mActor_name_t name_id, s16 arg, s8 npc_info_idx, - int data_bank_idx) { -#include "asm/80375830.s" -} -#endif extern ACTOR* Actor_info_make_child_actor(Actor_info* actor_info, ACTOR* parent_actor, GAME* game, s16 profile, f32 x, f32 y, f32 z, s16 rot_x, s16 rot_y, s16 rot_z, s16 move_actor_list_idx,