diff --git a/include/ac_my_room.h b/include/ac_my_room.h index b0323881..fc9fbe6b 100644 --- a/include/ac_my_room.h +++ b/include/ac_my_room.h @@ -12,6 +12,35 @@ extern "C" { typedef struct my_room_actor_s MY_ROOM_ACTOR; +enum { + aMR_CONTACT_LEFT, + aMR_CONTACT_RIGHT, + aMR_CONTACT_CENTER, + + aMR_CONTACT_NUM +}; + +enum { + aMR_CONTACT_DIR_BACK, + aMR_CONTACT_DIR_RIGHT, + aMR_CONTACT_DIR_FRONT, + aMR_CONTACT_DIR_LEFT, + + aMR_CONTACT_DIR_NUM +}; + +typedef struct my_room_contact_s { + int contact_flag; + int ftr_no; + int direction; + int contact_side; + f32 contact_percent; + f32* normal_p; + f32 contact_edge0[2]; + f32 contact_edge1[2]; + int contact_direction; +} aMR_contact_info_c; + typedef struct my_room_clock_info_s { int tick0; /* set on frame 15 */ int tick1; /* set on frame 45 */ @@ -77,6 +106,8 @@ extern ACTOR_PROFILE My_Room_Profile; extern int aMR_CorrespondFurniture(mActor_name_t ftr0, mActor_name_t ftr1); extern int aMR_GetFurnitureUnit(mActor_name_t ftr); extern mActor_name_t aMR_FurnitureFg_to_FurnitureFgWithDirect(mActor_name_t ftr, int direct); +extern void aMR_SameFurnitureSwitchOFF(u16 ftr_name); +extern aMR_contact_info_c* aMR_GetContactInfoLayer1(void); #ifdef __cplusplus } diff --git a/include/m_player_lib.h b/include/m_player_lib.h index 470ac9ad..3ccd6215 100644 --- a/include/m_player_lib.h +++ b/include/m_player_lib.h @@ -59,6 +59,7 @@ extern int mPlib_request_main_demo_getoff_boat_standup_type1(const xyz_t* pos, s extern int mPlib_check_player_actor_main_index_RecieveMove(GAME* game); extern int mPlib_check_label_player_demo_wait(GAME* game, void* label); extern int mPlib_check_player_outdoor_start(GAME* game); +extern void mPlib_Set_change_color_request(); extern mPlayer_change_data_from_submenu_c* mPlib_Get_change_data_from_submenu_p(); diff --git a/src/f_furniture.c b/src/f_furniture.c index 70a24658..d8ecfcee 100644 --- a/src/f_furniture.c +++ b/src/f_furniture.c @@ -5,6 +5,8 @@ #include "m_play.h" #include "m_common_data.h" #include "audio.h" +#include "m_player_lib.h" +#include "ac_my_room.h" static u16 fFTR_myhome_off_pal_table[][16] = { // clang-format off @@ -119,6 +121,10 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol -(scroll_x1 * ofs), -(scroll_y1 * ofs), width1, height1); } +#define aFTR_CAN_PLAY_SE(ftr_actor) \ + (ftr_actor->state != aFTR_STATE_BIRTH && ftr_actor->state != aFTR_STATE_BYE && \ + ftr_actor->state != aFTR_STATE_DEATH && ftr_actor->state != aFTR_STATE_BIRTH_WAIT) + /** * How to add a completed furniture actor: * 1. ensure the furniture actor TU matches on decomp.me @@ -716,8 +722,8 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_hos_deskL.c" #include "../src/ftr/ac_hos_deskR.c" #include "../src/ftr/ac_hos_flip.c" -// #include "../src/ftr/ac_hos_mario_hata.c" -// #include "../src/ftr/ac_hos_mario_kinoko.c" +#include "../src/ftr/ac_hos_mario_hata.c" +#include "../src/ftr/ac_hos_mario_kinoko.c" #include "../src/ftr/ac_hos_piknic.c" #include "../src/ftr/ac_hos_Tdesk.c" #include "../src/ftr/ac_iku_bugzapper.c" @@ -738,13 +744,13 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_iku_ido.c" #include "../src/ftr/ac_iku_jack.c" #include "../src/ftr/ac_iku_jersey.c" -// #include "../src/ftr/ac_iku_mario_coin.c" -// #include "../src/ftr/ac_iku_mario_dokan.c" -// #include "../src/ftr/ac_iku_mario_hatena.c" -// #include "../src/ftr/ac_iku_mario_koura.c" +#include "../src/ftr/ac_iku_mario_coin.c" +#include "../src/ftr/ac_iku_mario_dokan.c" +#include "../src/ftr/ac_iku_mario_hatena.c" +#include "../src/ftr/ac_iku_mario_koura.c" #include "../src/ftr/ac_iku_mario_renga.c" -// #include "../src/ftr/ac_iku_mario_taihou.c" -// #include "../src/ftr/ac_iku_mario_star.c" +#include "../src/ftr/ac_iku_mario_taihou.c" +#include "../src/ftr/ac_iku_mario_star.c" #include "../src/ftr/ac_iku_orange.c" #include "../src/ftr/ac_iku_reducespeed.c" #include "../src/ftr/ac_iku_roller.c" @@ -769,7 +775,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_yaz_b_house.c" // #include "../src/ftr/ac_yaz_candle.c" // #include "../src/ftr/ac_yaz_fish_trophy.c" -// #include "../src/ftr/ac_yaz_mario_flower.c" +#include "../src/ftr/ac_yaz_mario_flower.c" #include "../src/ftr/ac_yaz_telescope.c" #include "../src/ftr/ac_yaz_tub.c" #include "../src/ftr/ac_yaz_turkey_chair.c" diff --git a/src/ftr/ac_hos_mario_hata.c b/src/ftr/ac_hos_mario_hata.c index 0c2883d8..630b0d78 100644 --- a/src/ftr/ac_hos_mario_hata.c +++ b/src/ftr/ac_hos_mario_hata.c @@ -1,30 +1,35 @@ extern Gfx int_hos_mario_hata_all_model[]; -static void fHMD_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void fHMD_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + sAdo_OngenTrgStart(SE_FLAG_15(0x179), &ftr_actor->position); + } + } +} static aFTR_vtable_c fHMD_func = { - NULL, - &fHMD_mv, - NULL, - NULL, - NULL, + NULL, &fHMD_mv, NULL, NULL, NULL, }; aFTR_PROFILE iam_hos_mario_hata = { - int_hos_mario_hata_all_model, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &fHMD_func, + // clang-format off + int_hos_mario_hata_all_model, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &fHMD_func, + // clang-format on }; diff --git a/src/ftr/ac_hos_mario_kinoko.c b/src/ftr/ac_hos_mario_kinoko.c index 79b367c0..afcbcaa4 100644 --- a/src/ftr/ac_hos_mario_kinoko.c +++ b/src/ftr/ac_hos_mario_kinoko.c @@ -1,15 +1,19 @@ extern Gfx int_hos_mario_kinoko_all_model[]; -static void fIMK_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void fIMK_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + sAdo_OngenTrgStart(0x44E, &ftr_actor->position); + } + } +} static aFTR_vtable_c fIMK_func = { - NULL, - &fIMK_mv, - NULL, - NULL, - NULL, + NULL, &fIMK_mv, NULL, NULL, NULL, }; aFTR_PROFILE iam_hos_mario_kinoko = { + // clang-format off int_hos_mario_kinoko_all_model, NULL, NULL, @@ -27,4 +31,5 @@ aFTR_PROFILE iam_hos_mario_kinoko = { 0, 0, &fIMK_func, + // clang-format on }; diff --git a/src/ftr/ac_iku_mario_coin.c b/src/ftr/ac_iku_mario_coin.c index 3f486aaa..6a78e0a1 100644 --- a/src/ftr/ac_iku_mario_coin.c +++ b/src/ftr/ac_iku_mario_coin.c @@ -1,15 +1,55 @@ -static void fIMC_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fIMC_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +static void fIMC_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + sAdo_OngenTrgStart(0x17A, &ftr_actor->position); + } + } +} + +extern u16 int_iku_mario_coin_a_pal[]; +extern u16 int_iku_mario_coin_b_pal[]; +extern u16 int_iku_mario_coin_c_pal[]; + +static u16* fIMC_palette_table[] = { + // clang-format off + int_iku_mario_coin_a_pal, + int_iku_mario_coin_a_pal, + int_iku_mario_coin_a_pal, + int_iku_mario_coin_a_pal, + int_iku_mario_coin_b_pal, + int_iku_mario_coin_c_pal, + int_iku_mario_coin_b_pal, + // clang-format on +}; + +extern Gfx int_iku_mario_coin_model[]; + +static void fIMC_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + GAME_PLAY* play = (GAME_PLAY*)game; + u32 ctr_ofs; + + if (ftr_actor->ctr_type == aFTR_CTR_TYPE_GAME_PLAY) { + ctr_ofs = play->game_frame; + } else { + ctr_ofs = game->frame_counter; + } + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_9, + fIMC_palette_table[(ctr_ofs / 8) % ARRAY_COUNT(fIMC_palette_table)]); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_iku_mario_coin_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fIMC_func = { - NULL, - &fIMC_mv, - &fIMC_dw, - NULL, - NULL, + NULL, &fIMC_mv, &fIMC_dw, NULL, NULL, }; aFTR_PROFILE iam_iku_mario_coin = { + // clang-format off NULL, NULL, NULL, @@ -27,4 +67,5 @@ aFTR_PROFILE iam_iku_mario_coin = { 0, 0, &fIMC_func, + // clang-format off }; diff --git a/src/ftr/ac_iku_mario_dokan.c b/src/ftr/ac_iku_mario_dokan.c index fb874458..b5387918 100644 --- a/src/ftr/ac_iku_mario_dokan.c +++ b/src/ftr/ac_iku_mario_dokan.c @@ -1,31 +1,36 @@ extern Gfx int_iku_mario_dokan_model_a_model[]; extern Gfx int_iku_mario_dokan_model_b_model[]; -static void fIMD_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void fIMD_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + sAdo_OngenTrgStart(0x178, &ftr_actor->position); + } + } +} static aFTR_vtable_c fIMD_func = { - NULL, - &fIMD_mv, - NULL, - NULL, - NULL, + NULL, &fIMD_mv, NULL, NULL, NULL, }; aFTR_PROFILE iam_iku_mario_dokan = { - int_iku_mario_dokan_model_a_model, - int_iku_mario_dokan_model_b_model, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEC, - mCoBG_FTR_TYPEC, - 0, - 1, - 0, - 0, - &fIMD_func, + // clang-format off + int_iku_mario_dokan_model_a_model, + int_iku_mario_dokan_model_b_model, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEC, + mCoBG_FTR_TYPEC, + 0, + 1, + 0, + 0, + &fIMD_func, + // clang-format on }; diff --git a/src/ftr/ac_iku_mario_hatena.c b/src/ftr/ac_iku_mario_hatena.c index b7dfae34..9f49f733 100644 --- a/src/ftr/ac_iku_mario_hatena.c +++ b/src/ftr/ac_iku_mario_hatena.c @@ -1,15 +1,57 @@ -static void fIMH_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fIMH_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern u16 int_iku_mario_hatena_a_pal[]; +extern u16 int_iku_mario_hatena_b_pal[]; +extern u16 int_iku_mario_hatena_c_pal[]; + +static u16* fIMH_palette_table[] = { + // clang-format off + int_iku_mario_hatena_a_pal, + int_iku_mario_hatena_a_pal, + int_iku_mario_hatena_a_pal, + int_iku_mario_hatena_a_pal, + int_iku_mario_hatena_b_pal, + int_iku_mario_hatena_c_pal, + int_iku_mario_hatena_b_pal, + // clang-format on +}; + +extern Gfx int_iku_mario_hatena_model_a_model[]; +extern Gfx int_iku_mario_hatena_model_b_model[]; + +static void fIMH_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + GAME_PLAY* play = (GAME_PLAY*)game; + u32 ctr_ofs; + + if (ftr_actor->ctr_type == aFTR_CTR_TYPE_GAME_PLAY) { + ctr_ofs = play->game_frame; + } else { + ctr_ofs = game->frame_counter; + } + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_9, + fIMH_palette_table[(ctr_ofs / 8) % ARRAY_COUNT(fIMH_palette_table)]); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_iku_mario_hatena_model_b_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_iku_mario_hatena_model_a_model); + + CLOSE_DISP(game->graph); +} + +static void fIMH_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + sAdo_OngenTrgStart(0x17F, &ftr_actor->position); + } + } +} static aFTR_vtable_c fIMH_func = { - NULL, - &fIMH_mv, - &fIMH_dw, - NULL, - NULL, + NULL, &fIMH_mv, &fIMH_dw, NULL, NULL, }; aFTR_PROFILE iam_iku_mario_hatena = { + // clang-format off NULL, NULL, NULL, @@ -27,4 +69,5 @@ aFTR_PROFILE iam_iku_mario_hatena = { 0, 0, &fIMH_func, + // clang-format on }; diff --git a/src/ftr/ac_iku_mario_koura.c b/src/ftr/ac_iku_mario_koura.c index 9d37eaae..19325f59 100644 --- a/src/ftr/ac_iku_mario_koura.c +++ b/src/ftr/ac_iku_mario_koura.c @@ -1,15 +1,19 @@ extern Gfx int_iku_mario_koura_model[]; -static void fIMKoura_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void fIMKoura_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + sAdo_OngenTrgStart(0x464, &ftr_actor->position); + } + } +} static aFTR_vtable_c fIMKoura_func = { - NULL, - &fIMKoura_mv, - NULL, - NULL, - NULL, + NULL, &fIMKoura_mv, NULL, NULL, NULL, }; aFTR_PROFILE iam_iku_mario_koura = { + // clang-format off int_iku_mario_koura_model, NULL, NULL, @@ -27,4 +31,5 @@ aFTR_PROFILE iam_iku_mario_koura = { 0, 0, &fIMKoura_func, + // clang-format on }; diff --git a/src/ftr/ac_iku_mario_star.c b/src/ftr/ac_iku_mario_star.c index 99d45a79..5a28be05 100644 --- a/src/ftr/ac_iku_mario_star.c +++ b/src/ftr/ac_iku_mario_star.c @@ -1,16 +1,71 @@ -static void fIMS_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fIMS_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fIMS_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +static void fIMS_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->switch_bit = FALSE; +} + +static void fIMS_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_bit == TRUE) { + sAdo_OngenPos((u32)ftr_actor, 0x5F, &ftr_actor->position); + mPlib_Set_change_color_request(); + } + + if (ftr_actor->switch_changed_flag && ftr_actor->switch_bit == TRUE) { + aMR_SameFurnitureSwitchOFF(0x4C7); + ftr_actor->switch_bit = TRUE; + } + } +} + +extern u16 int_iku_mario_start_a_pal[]; +extern u16 int_iku_mario_start_b_pal[]; +extern u16 int_iku_mario_start_c_pal[]; +extern u16 int_iku_mario_start_d_pal[]; + +static u16* fIMS_palette_table[] = { + int_iku_mario_start_a_pal, + int_iku_mario_start_b_pal, + int_iku_mario_start_c_pal, + int_iku_mario_start_d_pal, +}; + +extern Gfx int_iku_mario_star_model[]; + +static void fIMS_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + GAME_PLAY* play = (GAME_PLAY*)game; + int ctr_ofs; + int pal_idx; + + if (ftr_actor->ctr_type == aFTR_CTR_TYPE_GAME_PLAY) { + ctr_ofs = play->game_frame; + } else { + ctr_ofs = game->frame_counter; + } + + if (ftr_actor->ctr_type == aFTR_CTR_TYPE_GAME_PLAY) { + if (ftr_actor->switch_bit == TRUE) { + pal_idx = (ctr_ofs / 10) & 3; + } else { + pal_idx = 0; + } + } else { + pal_idx = (ctr_ofs / 10) & 3; + } + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_9, fIMS_palette_table[pal_idx]); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_iku_mario_star_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fIMS_func = { - &fIMS_ct, - &fIMS_mv, - &fIMS_dw, - NULL, - NULL, + &fIMS_ct, &fIMS_mv, &fIMS_dw, NULL, NULL, }; aFTR_PROFILE iam_iku_mario_star = { + // clang-format off NULL, NULL, NULL, @@ -28,4 +83,5 @@ aFTR_PROFILE iam_iku_mario_star = { 0, 0, &fIMS_func, + // clang-format on }; diff --git a/src/ftr/ac_iku_mario_taihou.c b/src/ftr/ac_iku_mario_taihou.c index 3aa9402f..a30d4efd 100644 --- a/src/ftr/ac_iku_mario_taihou.c +++ b/src/ftr/ac_iku_mario_taihou.c @@ -1,30 +1,47 @@ extern Gfx int_iku_mario_taihou_model[]; -static void fIMT_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void fIMT_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + aMR_contact_info_c* contact_info = aMR_GetContactInfoLayer1(); + + switch (contact_info->contact_direction) { + case aMR_CONTACT_DIR_BACK: + (*Common_Get(clip).effect_clip->effect_make_proc)(eEC_EFFECT_KILLER, ftr_actor->position, 2, + ftr_actor->s_angle_y, game, RSV_NO, 0, 0); + break; + case aMR_CONTACT_DIR_FRONT: + (*Common_Get(clip).effect_clip->effect_make_proc)(eEC_EFFECT_KILLER, ftr_actor->position, 2, + ftr_actor->s_angle_y + DEG2SHORT_ANGLE(180.0f), + game, RSV_NO, 0, 0); + break; + } + } + } +} static aFTR_vtable_c fIMT_func = { - NULL, - &fIMT_mv, - NULL, - NULL, - NULL, + NULL, &fIMT_mv, NULL, NULL, NULL, }; aFTR_PROFILE iam_iku_mario_taihou = { - int_iku_mario_taihou_model, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &fIMT_func, + // clang-format off + int_iku_mario_taihou_model, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &fIMT_func, + // clang-format on }; diff --git a/src/ftr/ac_tak_stew.c b/src/ftr/ac_tak_stew.c index 8ddcf6fa..74097d7a 100644 --- a/src/ftr/ac_tak_stew.c +++ b/src/ftr/ac_tak_stew.c @@ -5,8 +5,7 @@ static void fTSW_ct(FTR_ACTOR* ftr_actor, u8* data) { static void fTSW_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { GAME_PLAY* play = (GAME_PLAY*)game; - if (ftr_actor->state != aFTR_STATE_BIRTH && ftr_actor->state != aFTR_STATE_BYE && - ftr_actor->state != aFTR_STATE_DEATH && ftr_actor->state != aFTR_STATE_BIRTH_WAIT) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { u32 frame = play->game_frame; sAdo_OngenPos((u32)ftr_actor, 0x54, &ftr_actor->position); diff --git a/src/ftr/ac_yaz_mario_flower.c b/src/ftr/ac_yaz_mario_flower.c index 129842e8..596062de 100644 --- a/src/ftr/ac_yaz_mario_flower.c +++ b/src/ftr/ac_yaz_mario_flower.c @@ -1,15 +1,52 @@ -static void fYMF_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fYMF_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +static void fYMF_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + if (ftr_actor->switch_changed_flag == TRUE) { + sAdo_OngenTrgStart(0x17B, &ftr_actor->position); + } + } +} + +extern u16 int_yaz_mario_flower_a_pal[]; +extern u16 int_yaz_mario_flower_b_pal[]; +extern u16 int_yaz_mario_flower_c_pal[]; +extern u16 int_yaz_mario_flower_d_pal[]; + +static u16* fYMF_palette_table[] = { + int_yaz_mario_flower_a_pal, + int_yaz_mario_flower_b_pal, + int_yaz_mario_flower_c_pal, + int_yaz_mario_flower_d_pal, +}; + +extern Gfx int_yaz_mario_flower_hana_model[]; +extern Gfx int_yaz_mario_flower_body_model[]; + +static void fYMF_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + GAME_PLAY* play = (GAME_PLAY*)game; + u32 ctr_ofs; + + if (ftr_actor->ctr_type == aFTR_CTR_TYPE_GAME_PLAY) { + ctr_ofs = play->game_frame; + } else { + ctr_ofs = game->frame_counter; + } + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_9, fYMF_palette_table[(ctr_ofs / 20) & 3]); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_yaz_mario_flower_hana_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_yaz_mario_flower_body_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fYMF_func = { - NULL, - &fYMF_mv, - &fYMF_dw, - NULL, - NULL, + NULL, &fYMF_mv, &fYMF_dw, NULL, NULL, }; aFTR_PROFILE iam_yaz_mario_flower = { + // clang-format off NULL, NULL, NULL, @@ -27,4 +64,5 @@ aFTR_PROFILE iam_yaz_mario_flower = { 0, 0, &fYMF_func, + // clang-format on };