diff --git a/include/audio.h b/include/audio.h index 4cce2ad7..f20a82ec 100644 --- a/include/audio.h +++ b/include/audio.h @@ -115,9 +115,9 @@ extern u16 sAdo_Get_WalkLabel(int type); extern int sAdo_Get_KokeruLabel(int type); extern void sAdo_SceneMode(u8 mode); -extern void sAdo_RoomIncectPos(int f, u16 u, xyz_t* pos); +extern void sAdo_RoomIncectPos(u32 f, u16 u, xyz_t* pos); -extern void sAdo_FurnitureInstPos(int f, xyz_t* pos); +extern void sAdo_FurnitureInstPos(u32 f, xyz_t* pos); extern void sAdo_Set_ongenpos_refuse_fg(int state); extern int sAdo_GameframeEnd_Check(); diff --git a/src/audio.c b/src/audio.c index a732439f..d67f5fd8 100644 --- a/src/audio.c +++ b/src/audio.c @@ -443,7 +443,7 @@ extern void sAdo_SceneMode(u8 mode) { Na_SceneMode(mode); } -extern void sAdo_RoomIncectPos(int f, u16 u, xyz_t* pos) { +extern void sAdo_RoomIncectPos(u32 f, u16 u, xyz_t* pos) { u16 scalc; f32 fcalc; @@ -452,7 +452,7 @@ extern void sAdo_RoomIncectPos(int f, u16 u, xyz_t* pos) { Na_RoomIncectPos(f, u, scalc, fcalc); } -extern void sAdo_FurnitureInstPos(int f, xyz_t* pos) { +extern void sAdo_FurnitureInstPos(u32 f, xyz_t* pos) { u16 scalc; f32 fcalc; diff --git a/src/f_furniture.c b/src/f_furniture.c index c359e179..ea07b40a 100644 --- a/src/f_furniture.c +++ b/src/f_furniture.c @@ -235,7 +235,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_kon_blueclock.c" #include "../src/ftr/ac_kon_cracker.c" #include "../src/ftr/ac_kon_gomi03.c" -// #include "../src/ftr/ac_kon_gomi04.c" +#include "../src/ftr/ac_kon_gomi04.c" #include "../src/ftr/ac_kon_grclock.c" #include "../src/ftr/ac_kon_isi01.c" #include "../src/ftr/ac_kon_isi02.c" @@ -269,7 +269,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_myfumbrella.c" #include "../src/ftr/ac_nog_amenbo.c" #include "../src/ftr/ac_nog_ari.c" -// #include "../src/ftr/ac_nog_balloon_common.c" +#include "../src/ftr/ac_nog_balloon_common.c" #include "../src/ftr/ac_nog_beachbed.c" // #include "../src/ftr/ac_nog_beachtable.c" #include "../src/ftr/ac_nog_bishopB.c" @@ -283,26 +283,26 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_nog_harddiary.c" #include "../src/ftr/ac_nog_isidai.c" // #include "../src/ftr/ac_nog_ka.c" -// #include "../src/ftr/ac_nog_kaeru.c" -// #include "../src/ftr/ac_nog_kamakura.c" -// #include "../src/ftr/ac_nog_kera.c" +#include "../src/ftr/ac_nog_kaeru.c" +#include "../src/ftr/ac_nog_kamakura.c" +#include "../src/ftr/ac_nog_kera.c" #include "../src/ftr/ac_nog_kingB.c" #include "../src/ftr/ac_nog_kingW.c" #include "../src/ftr/ac_nog_knightB.c" #include "../src/ftr/ac_nog_knightW.c" -// #include "../src/ftr/ac_nog_koban.c" +#include "../src/ftr/ac_nog_koban.c" #include "../src/ftr/ac_nog_kumo.c" #include "../src/ftr/ac_nog_kurage.c" #include "../src/ftr/ac_nog_maimai.c" #include "../src/ftr/ac_nog_mino.c" #include "../src/ftr/ac_nog_mikanbox.c" #include "../src/ftr/ac_nog_medaka.c" -// #include "../src/ftr/ac_nog_museum.c" -// #include "../src/ftr/ac_nog_myhome2.c" -// #include "../src/ftr/ac_nog_myhome4.c" +#include "../src/ftr/ac_nog_museum.c" +#include "../src/ftr/ac_nog_myhome2.c" +#include "../src/ftr/ac_nog_myhome4.c" // #include "../src/ftr/ac_nog_nabe.c" -// #include "../src/ftr/ac_nog_pawnB.c" -// #include "../src/ftr/ac_nog_pawnW.c" +#include "../src/ftr/ac_nog_pawnB.c" +#include "../src/ftr/ac_nog_pawnW.c" #include "../src/ftr/ac_nog_piraluku.c" #include "../src/ftr/ac_nog_queenB.c" #include "../src/ftr/ac_nog_queenW.c" @@ -310,14 +310,14 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_nog_rookB.c" #include "../src/ftr/ac_nog_rookW.c" #include "../src/ftr/ac_nog_schoolnote.c" -// #include "../src/ftr/ac_nog_shrine.c" +#include "../src/ftr/ac_nog_shrine.c" #include "../src/ftr/ac_nog_snowman.c" -// #include "../src/ftr/ac_nog_station.c" +#include "../src/ftr/ac_nog_station.c" #include "../src/ftr/ac_nog_systemnote.c" #include "../src/ftr/ac_nog_s_tree.c" #include "../src/ftr/ac_nog_f_tree.c" #include "../src/ftr/ac_nog_suzuki.c" -// #include "../src/ftr/ac_nog_shop1.c" +#include "../src/ftr/ac_nog_shop1.c" #include "../src/ftr/ac_nog_tai.c" // #include "../src/ftr/ac_nog_tri_audio01.c" #include "../src/ftr/ac_nog_tri_bed01.c" @@ -331,9 +331,9 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_nog_tri_table01.c" #include "../src/ftr/ac_nog_tudurinote.c" #include "../src/ftr/ac_nog_xtree.c" -// #include "../src/ftr/ac_nog_uranai.c" -// #include "../src/ftr/ac_nog_yamishop.c" -// #include "../src/ftr/ac_nog_yubin.c" +#include "../src/ftr/ac_nog_uranai.c" +#include "../src/ftr/ac_nog_yamishop.c" +#include "../src/ftr/ac_nog_yubin.c" #include "../src/ftr/ac_nog_zarigani.c" #include "../src/ftr/ac_nog_zassou.c" #include "../src/ftr/ac_nog_w_tree.c" @@ -371,7 +371,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol // #include "../src/ftr/ac_sum_bass01.c" #include "../src/ftr/ac_sum_bassl.c" #include "../src/ftr/ac_sum_bassm.c" -// #include "../src/ftr/ac_sum_bdcake01.c" +#include "../src/ftr/ac_sum_bdcake01.c" #include "../src/ftr/ac_sum_billiads.c" // #include "../src/ftr/ac_sum_biwa01.c" #include "../src/ftr/ac_sum_bla_bed01.c" @@ -391,7 +391,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_blue_chair01.c" #include "../src/ftr/ac_sum_blue_chest01.c" #include "../src/ftr/ac_sum_blue_chest02.c" -// #include "../src/ftr/ac_sum_blue_clk.c" +#include "../src/ftr/ac_sum_blue_clk.c" // #include "../src/ftr/ac_sum_blue_lowchest01.c" #include "../src/ftr/ac_sum_blue_table01.c" #include "../src/ftr/ac_sum_bon_boke.c" @@ -441,7 +441,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_demekin.c" #include "../src/ftr/ac_sum_desk01.c" #include "../src/ftr/ac_sum_dojyo.c" -// #include "../src/ftr/ac_sum_doll01.c" +#include "../src/ftr/ac_sum_doll01.c" #include "../src/ftr/ac_sum_doll02.c" #include "../src/ftr/ac_sum_doll03.c" #include "../src/ftr/ac_sum_doll04.c" @@ -460,11 +460,11 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_fruitchair04.c" // #include "../src/ftr/ac_sum_fruitchest01.c" // #include "../src/ftr/ac_sum_fruitchest03.c" -// #include "../src/ftr/ac_sum_fruitclk.c" +#include "../src/ftr/ac_sum_fruitclk.c" #include "../src/ftr/ac_sum_fruittable01.c" #include "../src/ftr/ac_sum_fruittable02.c" #include "../src/ftr/ac_sum_fruittable03.c" -// #include "../src/ftr/ac_sum_fruittv01.c" +#include "../src/ftr/ac_sum_fruittv01.c" #include "../src/ftr/ac_sum_funa.c" // #include "../src/ftr/ac_sum_genji.c" #include "../src/ftr/ac_sum_gill.c" @@ -490,14 +490,14 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_gupi.c" #include "../src/ftr/ac_sum_hachi.c" #include "../src/ftr/ac_sum_hal_bed01.c" -// #include "../src/ftr/ac_sum_hal_box01.c" +#include "../src/ftr/ac_sum_hal_box01.c" #include "../src/ftr/ac_sum_hal_chair01.c" #include "../src/ftr/ac_sum_hal_chest01.c" // #include "../src/ftr/ac_sum_hal_chest02.c" // #include "../src/ftr/ac_sum_hal_chest03.c" -// #include "../src/ftr/ac_sum_hal_clk01.c" -// #include "../src/ftr/ac_sum_hal_lanp01.c" -// #include "../src/ftr/ac_sum_hal_mirror01.c" +#include "../src/ftr/ac_sum_hal_clk01.c" +#include "../src/ftr/ac_sum_hal_lanp01.c" +#include "../src/ftr/ac_sum_hal_mirror01.c" #include "../src/ftr/ac_sum_hal_pkin.c" #include "../src/ftr/ac_sum_hal_sofa01.c" #include "../src/ftr/ac_sum_hal_table01.c" @@ -528,7 +528,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_liccalanp.c" // #include "../src/ftr/ac_sum_liccalowchest.c" #include "../src/ftr/ac_sum_liccalowtable.c" -// #include "../src/ftr/ac_sum_liccamirror.c" +#include "../src/ftr/ac_sum_liccamirror.c" // #include "../src/ftr/ac_sum_liccapiano.c" #include "../src/ftr/ac_sum_liccasofa.c" #include "../src/ftr/ac_sum_liccatable.c" @@ -539,17 +539,17 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol // #include "../src/ftr/ac_sum_log_chest01.c" // #include "../src/ftr/ac_sum_log_chest02.c" #include "../src/ftr/ac_sum_log_chest03.c" -// #include "../src/ftr/ac_sum_log_hatoclk.c" +#include "../src/ftr/ac_sum_log_hatoclk.c" #include "../src/ftr/ac_sum_log_table01.c" #include "../src/ftr/ac_sum_log_table02.c" // #include "../src/ftr/ac_sum_lv_stereo.c" // #include "../src/ftr/ac_sum_matumushi.c" // #include "../src/ftr/ac_sum_md01.c" -// #include "../src/ftr/ac_sum_mezaclock.c" +#include "../src/ftr/ac_sum_mezaclock.c" // #include "../src/ftr/ac_sum_minmin.c" #include "../src/ftr/ac_sum_misin01.c" #include "../src/ftr/ac_sum_miyama.c" -// #include "../src/ftr/ac_sum_mizunomi.c" +#include "../src/ftr/ac_sum_mizunomi.c" #include "../src/ftr/ac_sum_monki.c" #include "../src/ftr/ac_sum_monshiro.c" #include "../src/ftr/ac_sum_namazu.c" @@ -560,9 +560,9 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_nokogiri.c" #include "../src/ftr/ac_sum_ohmurasaki.c" #include "../src/ftr/ac_sum_oikawa.c" -// #include "../src/ftr/ac_sum_okiagari01.c" +#include "../src/ftr/ac_sum_okiagari01.c" #include "../src/ftr/ac_sum_okuwa.c" -// #include "../src/ftr/ac_sum_oldclk01.c" +#include "../src/ftr/ac_sum_oldclk01.c" #include "../src/ftr/ac_sum_oldsofa01.c" #include "../src/ftr/ac_sum_oniyanma.c" #include "../src/ftr/ac_sum_oonamazu.c" @@ -600,11 +600,11 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_ratan_isu01.c" #include "../src/ftr/ac_sum_ratan_isu02.c" #include "../src/ftr/ac_sum_ratan_lanp.c" -// #include "../src/ftr/ac_sum_ratan_mirror.c" +#include "../src/ftr/ac_sum_ratan_mirror.c" #include "../src/ftr/ac_sum_ratan_screen.c" #include "../src/ftr/ac_sum_ratan_table01.c" // #include "../src/ftr/ac_sum_reco01.c" -// #include "../src/ftr/ac_sum_roboclk.c" +#include "../src/ftr/ac_sum_roboclk.c" // #include "../src/ftr/ac_sum_roboconpo.c" #include "../src/ftr/ac_sum_sabo01.c" #include "../src/ftr/ac_sum_sabo02.c" @@ -612,13 +612,13 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_sake.c" #include "../src/ftr/ac_sum_shiokara.c" #include "../src/ftr/ac_sum_shoukaki.c" -// #include "../src/ftr/ac_sum_slot.c" +#include "../src/ftr/ac_sum_slot.c" #include "../src/ftr/ac_sum_sofe01.c" #include "../src/ftr/ac_sum_sofe02.c" #include "../src/ftr/ac_sum_sofe03.c" // #include "../src/ftr/ac_sum_stereo01.c" // #include "../src/ftr/ac_sum_stereo02.c" -// #include "../src/ftr/ac_sum_stove01.c" +#include "../src/ftr/ac_sum_stove01.c" #include "../src/ftr/ac_sum_suberi01.c" // #include "../src/ftr/ac_sum_suzumushi.c" // #include "../src/ftr/ac_sum_syouryou.c" @@ -641,8 +641,8 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol #include "../src/ftr/ac_sum_touro03.c" #include "../src/ftr/ac_sum_touro04.c" // #include "../src/ftr/ac_sum_tukutuku.c" -// #include "../src/ftr/ac_sum_tv01.c" -// #include "../src/ftr/ac_sum_tv02.c" +#include "../src/ftr/ac_sum_tv01.c" +#include "../src/ftr/ac_sum_tv02.c" #include "../src/ftr/ac_sum_ugui.c" #include "../src/ftr/ac_sum_unagi.c" #include "../src/ftr/ac_sum_uwa_cup01.c" @@ -658,7 +658,7 @@ static Gfx* fFTR_GetTwoTileGfx(int width0, int height0, int scroll_x0, int scrol // #include "../src/ftr/ac_sum_whi_chest01.c" // #include "../src/ftr/ac_sum_whi_chest02.c" // #include "../src/ftr/ac_sum_whi_lanp.c" -// #include "../src/ftr/ac_sum_whi_mirror.c" +#include "../src/ftr/ac_sum_whi_mirror.c" #include "../src/ftr/ac_sum_whi_sofa01.c" #include "../src/ftr/ac_sum_x_bed01.c" #include "../src/ftr/ac_sum_x_chair01.c" diff --git a/src/ftr/ac_kon_gomi04.c b/src/ftr/ac_kon_gomi04.c index d2b29a38..ad00f376 100644 --- a/src/ftr/ac_kon_gomi04.c +++ b/src/ftr/ac_kon_gomi04.c @@ -1,17 +1,70 @@ -static void aKonGomi04_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aKonGomi04_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aKonGomi04_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aKonGomi04_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_kon_gomi04; +extern cKF_Animation_R_c cKF_ba_r_int_kon_gomi04; + +static void aKonGomi04_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_kon_gomi04, &cKF_ba_r_int_kon_gomi04, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_stop(keyframe, &cKF_ba_r_int_kon_gomi04, NULL); + keyframe->frame_control.speed = 0.0f; + cKF_SkeletonInfo_R_play(keyframe); + ftr_actor->dynamic_work_s[0] = FALSE; +} + +static void aKonGomi04_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + if (ftr_actor->dynamic_work_s[0] == TRUE) { + int current_frame = (int)keyframe->frame_control.current_frame; + // missing 'static' qualifier + int frame_se_table[] = { 0, 18, 33, 48, 63, 78, 95, 107, 124 }; + // missing 'static' qualifier + u16 se_table[] = { 0x425, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A }; + int i; + + for (i = 0; i < ARRAY_COUNT(frame_se_table); i++) { + if (current_frame == frame_se_table[i] + 15) { + sAdo_OngenTrgStart(se_table[i], &ftr_actor->position); + break; + } + } + + if (cKF_SkeletonInfo_R_play(keyframe) != cKF_STATE_STOPPED) { + keyframe->frame_control.speed = 0.5f; + } else { + ftr_actor->dynamic_work_s[0] = FALSE; + } + } else if (ftr_actor->switch_changed_flag) { + ftr_actor->dynamic_work_s[0] = TRUE; + keyframe->frame_control.current_frame = 1.0f; + keyframe->frame_control.speed = 0.5f; + } +} + +static void aKonGomi04_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[game->frame_counter & 1]; + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_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 aKonGomi04_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aKonGomi04_func = { - &aKonGomi04_ct, - &aKonGomi04_mv, - &aKonGomi04_dw, - &aKonGomi04_dt, - NULL, + &aKonGomi04_ct, &aKonGomi04_mv, &aKonGomi04_dw, &aKonGomi04_dt, NULL, }; aFTR_PROFILE iam_kon_gomi04 = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +82,5 @@ aFTR_PROFILE iam_kon_gomi04 = { 0, 0, &aKonGomi04_func, + //clang-format on }; diff --git a/src/ftr/ac_nog_balloon_common.c b/src/ftr/ac_nog_balloon_common.c index d265370f..b0f51983 100644 --- a/src/ftr/ac_nog_balloon_common.c +++ b/src/ftr/ac_nog_balloon_common.c @@ -1,17 +1,102 @@ -static void fNBC_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNBC_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNBC_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNBC_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon1; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon2; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon3; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon4; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon5; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon6; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon7; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_balloon8; + +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon1; +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon2; +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon3; +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon4; +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon5; +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon6; +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon7; +extern cKF_Animation_R_c cKF_ba_r_int_nog_balloon8; + +static cKF_Skeleton_R_c* fNBC_balloon_skel_table[] = { + &cKF_bs_r_int_nog_balloon1, &cKF_bs_r_int_nog_balloon2, &cKF_bs_r_int_nog_balloon3, &cKF_bs_r_int_nog_balloon4, + &cKF_bs_r_int_nog_balloon5, &cKF_bs_r_int_nog_balloon6, &cKF_bs_r_int_nog_balloon7, &cKF_bs_r_int_nog_balloon8, +}; + +static cKF_Animation_R_c* fNBC_balloon_anime_table[] = { + &cKF_ba_r_int_nog_balloon1, &cKF_ba_r_int_nog_balloon2, &cKF_ba_r_int_nog_balloon3, &cKF_ba_r_int_nog_balloon4, + &cKF_ba_r_int_nog_balloon5, &cKF_ba_r_int_nog_balloon6, &cKF_ba_r_int_nog_balloon7, &cKF_ba_r_int_nog_balloon8, +}; + +static void fNBC_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + int balloon_no = (ftr_actor->name - 0x3FC) & 7; + + cKF_SkeletonInfo_R_ct(keyframe, fNBC_balloon_skel_table[balloon_no], fNBC_balloon_anime_table[balloon_no], + ftr_actor->joint, ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, fNBC_balloon_anime_table[balloon_no], NULL); + ftr_actor->dynamic_work_f[0] = 0.0f; + ftr_actor->dynamic_work_f[1] = 0.5f; + keyframe->frame_control.speed = ftr_actor->dynamic_work_f[0]; + cKF_SkeletonInfo_R_play(keyframe); +} + +static void fNBC_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + if (ftr_actor->switch_changed_flag) { + ftr_actor->dynamic_work_f[1] = 1.25f; + } else if (ftr_actor->dynamic_work_f[0] >= 1.25f) { + ftr_actor->dynamic_work_f[1] = 0.5f; + } + + if (ftr_actor->dynamic_work_f[0] < ftr_actor->dynamic_work_f[1]) { + ftr_actor->dynamic_work_f[0] += 0.01f; + if (ftr_actor->dynamic_work_f[0] > ftr_actor->dynamic_work_f[1]) { + ftr_actor->dynamic_work_f[0] = ftr_actor->dynamic_work_f[1]; + } + } else if (ftr_actor->dynamic_work_f[0] > ftr_actor->dynamic_work_f[1]) { + ftr_actor->dynamic_work_f[0] -= 0.01f; + if (ftr_actor->dynamic_work_f[0] < ftr_actor->dynamic_work_f[1]) { + ftr_actor->dynamic_work_f[0] = ftr_actor->dynamic_work_f[1]; + } + } + + keyframe->frame_control.speed = ftr_actor->dynamic_work_f[0]; + cKF_SkeletonInfo_R_play(keyframe); +} + +static int fNBC_DrawBalloonBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + return TRUE; +} + +static int fNBC_DrawBalloonAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + return TRUE; +} + +static void fNBC_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[game->frame_counter & 1]; + + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_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, &fNBC_DrawBalloonBefore, &fNBC_DrawBalloonAfter, ftr_actor); +} + +static void fNBC_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c fNBC_func = { - &fNBC_ct, - &fNBC_mv, - &fNBC_dw, - &fNBC_dt, - NULL, + &fNBC_ct, &fNBC_mv, &fNBC_dw, &fNBC_dt, NULL, }; aFTR_PROFILE iam_nog_balloon_common = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +114,5 @@ aFTR_PROFILE iam_nog_balloon_common = { 0, 0, &fNBC_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_kaeru.c b/src/ftr/ac_nog_kaeru.c index 7a334ea6..db6897b6 100644 --- a/src/ftr/ac_nog_kaeru.c +++ b/src/ftr/ac_nog_kaeru.c @@ -1,15 +1,17 @@ extern aFTR_rig_c aNogKaeru_key_anime_data; -static void fNKR_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void fNKR_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_RoomIncectPos((u32)ftr_actor, 0x41, &ftr_actor->position); + } +} static aFTR_vtable_c fNKR_func = { - NULL, - &fNKR_mv, - NULL, - NULL, - NULL, + NULL, &fNKR_mv, NULL, NULL, NULL, }; aFTR_PROFILE iam_nog_kaeru = { + // clang-format off NULL, NULL, NULL, @@ -27,4 +29,5 @@ aFTR_PROFILE iam_nog_kaeru = { 0, aFTR_INTERACTION_FISH, &fNKR_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_kamakura.c b/src/ftr/ac_nog_kamakura.c index 938fa2cd..ff7b5fd1 100644 --- a/src/ftr/ac_nog_kamakura.c +++ b/src/ftr/ac_nog_kamakura.c @@ -1,32 +1,61 @@ -static void fNogKamakura_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNogKamakura_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNogKamakura_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNogKamakura_dt(FTR_ACTOR* ftr_actor, u8* data); +extern u16 int_nog_kamakura_off_pal[]; +extern u16 int_nog_kamakura_on_pal[]; + +static void fNogKamakura_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, int_nog_kamakura_off_pal, int_nog_kamakura_on_pal, ftr_actor); +} + +static void fNogKamakura_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + fFTR_MorphHousePalette(ftr_actor->pal_p, int_nog_kamakura_off_pal, int_nog_kamakura_on_pal, ftr_actor); +} + +static void fNogKamakura_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_kamakura_on_model[]; +extern Gfx int_nog_kamakura_onT_model[]; +extern Gfx int_nog_kamakura_offT_model[]; + +static void fNogKamakura_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_kamakura_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_kamakura_onT_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_kamakura_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNogKamakura_func = { - &fNogKamakura_ct, - &fNogKamakura_mv, - &fNogKamakura_dw, - &fNogKamakura_dt, - NULL, + &fNogKamakura_ct, &fNogKamakura_mv, &fNogKamakura_dw, &fNogKamakura_dt, NULL, }; aFTR_PROFILE iam_nog_kamakura = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 15.7f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &fNogKamakura_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 15.7f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &fNogKamakura_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_kera.c b/src/ftr/ac_nog_kera.c index 6803d8bb..3053d84c 100644 --- a/src/ftr/ac_nog_kera.c +++ b/src/ftr/ac_nog_kera.c @@ -1,30 +1,33 @@ extern aFTR_rig_c aNogKera_key_anime_data; -static void fNgKr_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void fNgKr_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_RoomIncectPos((u32)ftr_actor, 0x42, &ftr_actor->position); + } +} static aFTR_vtable_c fNgKr_func = { - NULL, - &fNgKr_mv, - NULL, - NULL, - NULL, + NULL, &fNgKr_mv, NULL, NULL, NULL, }; aFTR_PROFILE iam_nog_kera = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &aNogKera_key_anime_data, - NULL, - 30.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 2, - 0, - aFTR_INTERACTION_INSECT, - &fNgKr_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &aNogKera_key_anime_data, + NULL, + 30.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 2, + 0, + aFTR_INTERACTION_INSECT, + &fNgKr_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_koban.c b/src/ftr/ac_nog_koban.c index e5d770fd..16962f23 100644 --- a/src/ftr/ac_nog_koban.c +++ b/src/ftr/ac_nog_koban.c @@ -1,17 +1,45 @@ -static void fNKN_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNKN_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNKN_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNKN_dt(FTR_ACTOR* ftr_actor, u8* data); +extern u16 int_nog_kouban_off_pal[]; +extern u16 int_nog_kouban_on_pal[]; + +static void fNKN_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, int_nog_kouban_off_pal, int_nog_kouban_on_pal, ftr_actor); +} + +static void fNKN_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + fFTR_MorphHousePalette(ftr_actor->pal_p, int_nog_kouban_off_pal, int_nog_kouban_on_pal, ftr_actor); +} + +static void fNKN_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_koban_on_model[]; +extern Gfx int_nog_koban_onT_model[]; +extern Gfx int_nog_koban_offT_model[]; + +static void fNKN_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_koban_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_koban_onT_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_koban_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNKN_func = { - &fNKN_ct, - &fNKN_mv, - &fNKN_dw, - &fNKN_dt, - NULL, + &fNKN_ct, &fNKN_mv, &fNKN_dw, &fNKN_dt, NULL, }; aFTR_PROFILE iam_nog_koban = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +57,5 @@ aFTR_PROFILE iam_nog_koban = { 0, 0, &fNKN_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_museum.c b/src/ftr/ac_nog_museum.c index 46b98e32..595ac7d6 100644 --- a/src/ftr/ac_nog_museum.c +++ b/src/ftr/ac_nog_museum.c @@ -1,17 +1,45 @@ -static void fNMM_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNMM_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNMM_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNMM_dt(FTR_ACTOR* ftr_actor, u8* data); +extern u16 int_nog_museum_off_pal[]; +extern u16 int_nog_museum_on_pal[]; + +static void fNMM_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, int_nog_museum_off_pal, int_nog_museum_on_pal, ftr_actor); +} + +static void fNMM_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + fFTR_MorphHousePalette(ftr_actor->pal_p, int_nog_museum_off_pal, int_nog_museum_on_pal, ftr_actor); +} + +static void fNMM_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_museum_on_model[]; +extern Gfx int_nog_museum_onT_model[]; +extern Gfx int_nog_museum_offT_model[]; + +static void fNMM_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_museum_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_museum_onT_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_museum_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNMM_func = { - &fNMM_ct, - &fNMM_mv, - &fNMM_dw, - &fNMM_dt, - NULL, + &fNMM_ct, &fNMM_mv, &fNMM_dw, &fNMM_dt, NULL, }; aFTR_PROFILE iam_nog_museum = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +57,5 @@ aFTR_PROFILE iam_nog_museum = { 0, 0, &fNMM_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_myhome2.c b/src/ftr/ac_nog_myhome2.c index c61f20c7..c9c816fa 100644 --- a/src/ftr/ac_nog_myhome2.c +++ b/src/ftr/ac_nog_myhome2.c @@ -1,17 +1,74 @@ -static void fNM2_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNM2_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNM2_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNM2_dt(FTR_ACTOR* ftr_actor, u8* data); +static int fNM2_GetPalletIndex(FTR_ACTOR* ftr_actor) { + if (ftr_actor->ctr_type == aFTR_CTR_TYPE_GAME_PLAY) { + mActor_name_t field_id = mFI_GetFieldId(); + + if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { + return 0; + } + + if (mFI_GET_TYPE(field_id) == mFI_FIELD_PLAYER0_ROOM) { + int arrange_idx = mFI_GetFieldId() - mFI_FIELD_PLAYER0_ROOM; + + return Save_Get(homes[arrange_idx & 3]).outlook_pal; + } + } else { + int player_no = Common_Get(player_no); + + if (player_no >= 0 && player_no < PLAYER_NUM) { + int arrange_idx = mHS_get_arrange_idx(player_no); + + return Save_Get(homes[arrange_idx]).outlook_pal; + } + } + + return 0; +} + +static void fNM2_ct(FTR_ACTOR* ftr_actor, u8* data) { + int pallet_idx = fNM2_GetPalletIndex(ftr_actor); + + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, fFTR_myhome_off_pal_table[pallet_idx], + fFTR_myhome_on_pal_table[pallet_idx], ftr_actor); +} + +static void fNM2_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int pallet_idx = fNM2_GetPalletIndex(ftr_actor); + + fFTR_MorphHousePalette(ftr_actor->pal_p, fFTR_myhome_off_pal_table[pallet_idx], + fFTR_myhome_on_pal_table[pallet_idx], ftr_actor); +} + +static void fNM2_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_myhome2_on_model[]; +extern Gfx int_nog_myhome2_onT_model[]; +extern Gfx int_nog_myhome2_off_model[]; + +static void fNM2_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_myhome2_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_myhome2_off_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_myhome2_onT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNM2_func = { - &fNM2_ct, - &fNM2_mv, - &fNM2_dw, - &fNM2_dt, - NULL, + &fNM2_ct, &fNM2_mv, &fNM2_dw, &fNM2_dt, NULL, }; aFTR_PROFILE iam_nog_myhome2 = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +86,5 @@ aFTR_PROFILE iam_nog_myhome2 = { 0, 0, &fNM2_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_myhome4.c b/src/ftr/ac_nog_myhome4.c index 70fd9101..46875532 100644 --- a/src/ftr/ac_nog_myhome4.c +++ b/src/ftr/ac_nog_myhome4.c @@ -1,17 +1,27 @@ -static void fNM2_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNM2_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNM4_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNM2_dt(FTR_ACTOR* ftr_actor, u8* data); +extern Gfx int_nog_myhome4_on_model[]; +extern Gfx int_nog_myhome4_onT_model[]; +extern Gfx int_nog_myhome4_off_model[]; + +static void fNM4_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_myhome4_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_myhome4_onT_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_myhome4_off_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNM4_func = { - &fNM2_ct, - &fNM2_mv, - &fNM4_dw, - &fNM2_dt, - NULL, + &fNM2_ct, &fNM2_mv, &fNM4_dw, &fNM2_dt, NULL, }; aFTR_PROFILE iam_nog_myhome4 = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +39,5 @@ aFTR_PROFILE iam_nog_myhome4 = { 0, 0, &fNM4_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_pawnB.c b/src/ftr/ac_nog_pawnB.c index 09ff9285..d666cf30 100644 --- a/src/ftr/ac_nog_pawnB.c +++ b/src/ftr/ac_nog_pawnB.c @@ -1,32 +1,105 @@ -static void aNogPawnB_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aNogPawnB_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aNogPawnB_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aNogPawnB_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_pawnB; +extern cKF_Animation_R_c cKF_ba_r_int_nog_pawnB; + +static void aNogPawnB_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_nog_pawnB, &cKF_ba_r_int_nog_pawnB, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_nog_pawnB, NULL); + keyframe->frame_control.speed = 0.5f; + cKF_SkeletonInfo_R_play(keyframe); +} + +static void aNogPawnB_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +extern Gfx int_nog_pawnB_top_model[]; + +static int aNogPawnB_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + FTR_ACTOR* ftr_actor = (FTR_ACTOR*)arg; + GAME_PLAY* play = (GAME_PLAY*)game; + xyz_t pos; + xyz_t old_pos = { 0.0f, 0.0f, 0.0f }; + + if (joint_idx == 1) { + f32 scale_x = ftr_actor->scale.x * 0.01f; + f32 scale_y = ftr_actor->scale.y * 0.01f; + f32 scale_z = ftr_actor->scale.z * 0.01f; + + OPEN_DISP(game->graph); + + Matrix_Position(&old_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_mult(&play->billboard_matrix, 1); + Matrix_RotateY(DEG2SHORT_ANGLE(-90.0f), 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_pawnB_top_model); + + CLOSE_DISP(game->graph); + } + + return TRUE; +} + +static int aNogPawnB_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 1) { + *joint_shape = NULL; + } + + return TRUE; +} + +static void aNogPawnB_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + 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); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aNogPawnB_DwBefore, &aNogPawnB_DwAfter, ftr_actor); +} + +static void aNogPawnB_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aNogPawnB_func = { - &aNogPawnB_ct, - &aNogPawnB_mv, - &aNogPawnB_dw, - &aNogPawnB_dt, - NULL, + &aNogPawnB_ct, &aNogPawnB_mv, &aNogPawnB_dw, &aNogPawnB_dt, NULL, }; aFTR_PROFILE iam_nog_pawnB = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 40.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &aNogPawnB_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 40.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &aNogPawnB_func, + // clang-format off }; diff --git a/src/ftr/ac_nog_pawnW.c b/src/ftr/ac_nog_pawnW.c index 0f3148e3..3e6105d2 100644 --- a/src/ftr/ac_nog_pawnW.c +++ b/src/ftr/ac_nog_pawnW.c @@ -1,32 +1,105 @@ -static void aNogpawnW_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aNogpawnW_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aNogpawnW_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aNogpawnW_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_pawnW; +extern cKF_Animation_R_c cKF_ba_r_int_nog_pawnW; + +static void aNogpawnW_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_nog_pawnW, &cKF_ba_r_int_nog_pawnW, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_nog_pawnW, NULL); + keyframe->frame_control.speed = 0.5f; + cKF_SkeletonInfo_R_play(keyframe); +} + +static void aNogpawnW_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +extern Gfx int_nog_pawnW_top_model[]; + +static int aNogpawnW_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + FTR_ACTOR* ftr_actor = (FTR_ACTOR*)arg; + GAME_PLAY* play = (GAME_PLAY*)game; + xyz_t pos; + xyz_t old_pos = { 0.0f, 0.0f, 0.0f }; + + if (joint_idx == 1) { + f32 scale_x = ftr_actor->scale.x * 0.01f; + f32 scale_y = ftr_actor->scale.y * 0.01f; + f32 scale_z = ftr_actor->scale.z * 0.01f; + + OPEN_DISP(game->graph); + + Matrix_Position(&old_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_mult(&play->billboard_matrix, 1); + Matrix_RotateY(DEG2SHORT_ANGLE(-90.0f), 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_pawnW_top_model); + + CLOSE_DISP(game->graph); + } + + return TRUE; +} + +static int aNogpawnW_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 1) { + *joint_shape = NULL; + } + + return TRUE; +} + +static void aNogpawnW_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + 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); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aNogpawnW_DwBefore, &aNogpawnW_DwAfter, ftr_actor); +} + +static void aNogpawnW_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aNogpawnW_func = { - &aNogpawnW_ct, - &aNogpawnW_mv, - &aNogpawnW_dw, - &aNogpawnW_dt, - NULL, + &aNogpawnW_ct, &aNogpawnW_mv, &aNogpawnW_dw, &aNogpawnW_dt, NULL, }; aFTR_PROFILE iam_nog_pawnW = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 40.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &aNogpawnW_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 40.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &aNogpawnW_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_shop1.c b/src/ftr/ac_nog_shop1.c index 781fbdf4..62515138 100644 --- a/src/ftr/ac_nog_shop1.c +++ b/src/ftr/ac_nog_shop1.c @@ -1,17 +1,45 @@ -static void fNS1_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNS1_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNS1_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNS1_dt(FTR_ACTOR* ftr_actor, u8* data); +extern u16 int_nog_shop1_off_pal[]; +extern u16 int_nog_shop1_on_pal[]; + +static void fNS1_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, int_nog_shop1_off_pal, int_nog_shop1_on_pal, ftr_actor); +} + +static void fNS1_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + fFTR_MorphHousePalette(ftr_actor->pal_p, int_nog_shop1_off_pal, int_nog_shop1_on_pal, ftr_actor); +} + +static void fNS1_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_shop1_on_model[]; +extern Gfx int_nog_shop1_onT_model[]; +extern Gfx int_nog_shop1_offT_model[]; + +static void fNS1_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_shop1_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_shop1_onT_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_shop1_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNS1_func = { - &fNS1_ct, - &fNS1_mv, - &fNS1_dw, - &fNS1_dt, - NULL, + &fNS1_ct, &fNS1_mv, &fNS1_dw, &fNS1_dt, NULL, }; aFTR_PROFILE iam_nog_shop1 = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +57,5 @@ aFTR_PROFILE iam_nog_shop1 = { 0, 0, &fNS1_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_shrine.c b/src/ftr/ac_nog_shrine.c index e2cbe3d3..d5b4e28c 100644 --- a/src/ftr/ac_nog_shrine.c +++ b/src/ftr/ac_nog_shrine.c @@ -1,17 +1,56 @@ -static void fNSH_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNSH_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNSH_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNSH_dt(FTR_ACTOR* ftr_actor, u8* data); +static void fNSH_ct(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} + +static void fNSH_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + // nothing +} + +static void fNSH_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} + +static Gfx* fNSH_GetTileGfx(int x0, int y0, GAME* game) { + return two_tex_scroll_dolphin(game->graph, 0, x0, y0, 16, 16, 1, 0, 0, 0, 0); +} + +extern Gfx int_nog_shrine_grass_model[]; +extern Gfx int_nog_shrine_figure_model[]; +extern Gfx int_nog_shrine_baseT_model[]; +extern Gfx int_nog_shrine_waterT_model[]; + +static void fNSH_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + GAME_PLAY* play = (GAME_PLAY*)game; + u32 ctr; + Gfx* scroll_gfx; + + if (ftr_actor->ctr_type == aFTR_CTR_TYPE_GAME_PLAY) { + ctr = play->game_frame; + } else { + ctr = game->frame_counter; + } + + scroll_gfx = fNSH_GetTileGfx(ctr * 3, 0, game); + + 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); + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_9, scroll_gfx); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_shrine_grass_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_shrine_figure_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_shrine_baseT_model); + gSPDisplayList(NEXT_POLY_XLU_DISP, int_nog_shrine_waterT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNSH_func = { - &fNSH_ct, - &fNSH_mv, - &fNSH_dw, - &fNSH_dt, - NULL, + &fNSH_ct, &fNSH_mv, &fNSH_dw, &fNSH_dt, NULL, }; aFTR_PROFILE iam_nog_shrine = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +68,5 @@ aFTR_PROFILE iam_nog_shrine = { 0, 0, &fNSH_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_station.c b/src/ftr/ac_nog_station.c index dbcc481c..81ca93c1 100644 --- a/src/ftr/ac_nog_station.c +++ b/src/ftr/ac_nog_station.c @@ -1,17 +1,108 @@ -static void fNSN_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNSN_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNSN_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNSN_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_station1; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_station2; +extern cKF_Skeleton_R_c cKF_bs_r_int_nog_station3; + +extern cKF_Animation_R_c cKF_ba_r_int_nog_station1; +extern cKF_Animation_R_c cKF_ba_r_int_nog_station2; +extern cKF_Animation_R_c cKF_ba_r_int_nog_station3; + +static cKF_Skeleton_R_c* fNSN_station_skel_table[] = { + &cKF_bs_r_int_nog_station1, &cKF_bs_r_int_nog_station1, &cKF_bs_r_int_nog_station1, &cKF_bs_r_int_nog_station1, + &cKF_bs_r_int_nog_station1, &cKF_bs_r_int_nog_station2, &cKF_bs_r_int_nog_station2, &cKF_bs_r_int_nog_station2, + &cKF_bs_r_int_nog_station2, &cKF_bs_r_int_nog_station2, &cKF_bs_r_int_nog_station3, &cKF_bs_r_int_nog_station3, + &cKF_bs_r_int_nog_station3, &cKF_bs_r_int_nog_station3, &cKF_bs_r_int_nog_station3, +}; + +static cKF_Animation_R_c* fNSN_station_anime_table[] = { + &cKF_ba_r_int_nog_station1, &cKF_ba_r_int_nog_station1, &cKF_ba_r_int_nog_station1, &cKF_ba_r_int_nog_station1, + &cKF_ba_r_int_nog_station1, &cKF_ba_r_int_nog_station2, &cKF_ba_r_int_nog_station2, &cKF_ba_r_int_nog_station2, + &cKF_ba_r_int_nog_station2, &cKF_ba_r_int_nog_station2, &cKF_ba_r_int_nog_station3, &cKF_ba_r_int_nog_station3, + &cKF_ba_r_int_nog_station3, &cKF_ba_r_int_nog_station3, &cKF_ba_r_int_nog_station3, +}; + +static void fNSN_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + int station_idx = (ftr_actor->name - 0x42A) & 15; + + cKF_SkeletonInfo_R_ct(keyframe, fNSN_station_skel_table[station_idx], fNSN_station_anime_table[station_idx], + ftr_actor->joint, ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, fNSN_station_anime_table[station_idx], NULL); + keyframe->frame_control.speed = 0.5f; + cKF_SkeletonInfo_R_play(keyframe); +} + +static void fNSN_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_play(keyframe); +} + +static void fNSN_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} + +static int fNSN_DrawBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 3) { + joint_rot->z -= Common_Get(time.rad_hour); + } else if (joint_idx == 4) { + joint_rot->z -= Common_Get(time.rad_min); + } + + return TRUE; +} + +static int fNSN_DrawAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, u8* joint_flags, + void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + return TRUE; +} + +extern u16 int_nog_station1_a_pal[]; +extern u16 int_nog_station1_b_pal[]; +extern u16 int_nog_station1_c_pal[]; +extern u16 int_nog_station1_d_pal[]; +extern u16 int_nog_station1_e_pal[]; +extern u16 int_nog_station2_a_pal[]; +extern u16 int_nog_station2_b_pal[]; +extern u16 int_nog_station2_c_pal[]; +extern u16 int_nog_station2_d_pal[]; +extern u16 int_nog_station2_e_pal[]; +extern u16 int_nog_station3_a_pal[]; +extern u16 int_nog_station3_b_pal[]; +extern u16 int_nog_station3_c_pal[]; +extern u16 int_nog_station3_d_pal[]; +extern u16 int_nog_station3_e_pal[]; + +static u16* fMSM_palette_table[] = { + int_nog_station1_a_pal, int_nog_station1_b_pal, int_nog_station1_c_pal, int_nog_station1_d_pal, + int_nog_station1_e_pal, int_nog_station2_a_pal, int_nog_station2_b_pal, int_nog_station2_c_pal, + int_nog_station2_d_pal, int_nog_station2_e_pal, int_nog_station3_a_pal, int_nog_station3_b_pal, + int_nog_station3_c_pal, int_nog_station3_d_pal, int_nog_station3_e_pal, +}; + +static void fNSN_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[mtx_idx]; + int station_idx = (ftr_actor->name - 0x42A) & 15; + u16* pal = fMSM_palette_table[station_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); + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, pal); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aNogPawnB_DwBefore, &aNogPawnB_DwAfter, ftr_actor); +} static aFTR_vtable_c fNSN_func = { - &fNSN_ct, - &fNSN_mv, - &fNSN_dw, - &fNSN_dt, - NULL, + &fNSN_ct, &fNSN_mv, &fNSN_dw, &fNSN_dt, NULL, }; aFTR_PROFILE iam_nog_station = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +120,5 @@ aFTR_PROFILE iam_nog_station = { 0, 0, &fNSN_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_uranai.c b/src/ftr/ac_nog_uranai.c index 917b2e46..3ab88546 100644 --- a/src/ftr/ac_nog_uranai.c +++ b/src/ftr/ac_nog_uranai.c @@ -1,17 +1,45 @@ -static void fNU_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNU_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNU_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNU_dt(FTR_ACTOR* ftr_actor, u8* data); +extern u16 int_nog_uranai_off_pal[]; +extern u16 int_nog_uranai_on_pal[]; + +static void fNU_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, int_nog_uranai_off_pal, int_nog_uranai_on_pal, ftr_actor); +} + +static void fNU_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + fFTR_MorphHousePalette(ftr_actor->pal_p, int_nog_uranai_off_pal, int_nog_uranai_on_pal, ftr_actor); +} + +static void fNU_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_uranai_on_model[]; +extern Gfx int_nog_uranai_onT_model[]; +extern Gfx int_nog_uranai_off_model[]; + +static void fNU_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_uranai_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_uranai_off_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_uranai_onT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNU_func = { - &fNU_ct, - &fNU_mv, - &fNU_dw, - &fNU_dt, - NULL, + &fNU_ct, &fNU_mv, &fNU_dw, &fNU_dt, NULL, }; aFTR_PROFILE iam_nog_uranai = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +57,5 @@ aFTR_PROFILE iam_nog_uranai = { 0, 0, &fNU_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_yamishop.c b/src/ftr/ac_nog_yamishop.c index 8a87202c..b06f0d74 100644 --- a/src/ftr/ac_nog_yamishop.c +++ b/src/ftr/ac_nog_yamishop.c @@ -1,17 +1,45 @@ -static void fNYS_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNYS_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNYS_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNYS_dt(FTR_ACTOR* ftr_actor, u8* data); +extern u16 int_nog_yamishop_off_pal[]; +extern u16 int_nog_yamishop_on_pal[]; + +static void fNYS_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, int_nog_yamishop_off_pal, int_nog_yamishop_on_pal, ftr_actor); +} + +static void fNYS_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + fFTR_MorphHousePalette(ftr_actor->pal_p, int_nog_yamishop_off_pal, int_nog_yamishop_on_pal, ftr_actor); +} + +static void fNYS_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_yamishop_on_model[]; +extern Gfx int_nog_yamishop_onT_model[]; +extern Gfx int_nog_yamishop_offT_model[]; + +static void fNYS_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_yamishop_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_yamishop_onT_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_yamishop_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNYS_func = { - &fNYS_ct, - &fNYS_mv, - &fNYS_dw, - &fNYS_dt, - NULL, + &fNYS_ct, &fNYS_mv, &fNYS_dw, &fNYS_dt, NULL, }; aFTR_PROFILE iam_nog_yamishop = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +57,5 @@ aFTR_PROFILE iam_nog_yamishop = { 0, 0, &fNYS_func, + // clang-format on }; diff --git a/src/ftr/ac_nog_yubin.c b/src/ftr/ac_nog_yubin.c index cde323ee..727b22a8 100644 --- a/src/ftr/ac_nog_yubin.c +++ b/src/ftr/ac_nog_yubin.c @@ -1,17 +1,45 @@ -static void fNYB_ct(FTR_ACTOR* ftr_actor, u8* data); -static void fNYB_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNYB_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void fNYB_dt(FTR_ACTOR* ftr_actor, u8* data); +extern u16 int_nog_yubin_off_pal[]; +extern u16 int_nog_yubin_on_pal[]; + +static void fNYB_ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->pal_p = (u16*)zelda_malloc_align(16 * sizeof(u16), 32); + fFTR_MorphHousepaletteCt(ftr_actor->pal_p, int_nog_yubin_off_pal, int_nog_yubin_on_pal, ftr_actor); +} + +static void fNYB_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + fFTR_MorphHousePalette(ftr_actor->pal_p, int_nog_yubin_off_pal, int_nog_yubin_on_pal, ftr_actor); +} + +static void fNYB_dt(FTR_ACTOR* ftr_actor, u8* data) { + if (ftr_actor->pal_p != NULL) { + zelda_free(ftr_actor->pal_p); + } +} + +extern Gfx int_nog_yubin_on_model[]; +extern Gfx int_nog_yubin_onT_model[]; +extern Gfx int_nog_yubin_offT_model[]; + +static void fNYB_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + u16* pal_p = ftr_actor->pal_p; + + 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_8, pal_p); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_yubin_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_yubin_onT_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_nog_yubin_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c fNYB_func = { - &fNYB_ct, - &fNYB_mv, - &fNYB_dw, - &fNYB_dt, - NULL, + &fNYB_ct, &fNYB_mv, &fNYB_dw, &fNYB_dt, NULL, }; aFTR_PROFILE iam_nog_yubin = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +57,5 @@ aFTR_PROFILE iam_nog_yubin = { 0, 0, &fNYB_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_bdcake01.c b/src/ftr/ac_sum_bdcake01.c index 0a618933..c5497e5b 100644 --- a/src/ftr/ac_sum_bdcake01.c +++ b/src/ftr/ac_sum_bdcake01.c @@ -1,31 +1,62 @@ -static void aSB_SumBdcake01Ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSB_SumBdcake01Move(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSB_SumBdcake01Draw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern u8 int_sum_bdcake01_a_candol1_TA_tex_txt[]; +extern u8 int_sum_bdcake01_a_candol2_TA_tex_txt[]; + +extern u8 int_sum_bdcake01_b_candol1_TA_tex_txt[]; +extern u8 int_sum_bdcake01_b_candol2_TA_tex_txt[]; + +extern Gfx int_sum_bdcake01_on_model[]; +extern Gfx int_sum_bdcake01_off_model[]; +extern Gfx int_sum_bdcake01_off1_model[]; + +static void aSB_SumBdcake01Draw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + s16 frame = ftr_actor->dynamic_work_s[0] & 1; + + OPEN_DISP(game->graph); + + if (frame == 0) { + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_8, int_sum_bdcake01_a_candol2_TA_tex_txt); + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_9, int_sum_bdcake01_b_candol1_TA_tex_txt); + } else { + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_8, int_sum_bdcake01_a_candol1_TA_tex_txt); + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_9, int_sum_bdcake01_b_candol2_TA_tex_txt); + } + + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(NEXT_POLY_XLU_DISP, int_sum_bdcake01_on_model); + gSPDisplayList(NEXT_POLY_XLU_DISP, int_sum_bdcake01_off1_model); + gSPDisplayList(NEXT_POLY_XLU_DISP, int_sum_bdcake01_off_model); + + CLOSE_DISP(game->graph); +} + +static void aSB_SumBdcake01Move(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + ftr_actor->dynamic_work_s[0]++; +} + +static void aSB_SumBdcake01Ct(FTR_ACTOR* ftr_actor, u8* data) { + ftr_actor->dynamic_work_s[0] = 0; +} static aFTR_vtable_c sum_bdcake01_func = { - &aSB_SumBdcake01Ct, - &aSB_SumBdcake01Move, - &aSB_SumBdcake01Draw, - NULL, - NULL, + &aSB_SumBdcake01Ct, &aSB_SumBdcake01Move, &aSB_SumBdcake01Draw, NULL, NULL, }; aFTR_PROFILE iam_sum_bdcake01 = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &sum_bdcake01_func, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &sum_bdcake01_func, }; diff --git a/src/ftr/ac_sum_blue_clk.c b/src/ftr/ac_sum_blue_clk.c index 7e002062..f432e785 100644 --- a/src/ftr/ac_sum_blue_clk.c +++ b/src/ftr/ac_sum_blue_clk.c @@ -1,17 +1,134 @@ -static void aSumBlueClk_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumBlueClk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumBlueClk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumBlueClk_dt(FTR_ACTOR* ftr_actor, u8* data); +extern Gfx int_sum_blue_clk_evw_model[]; +extern Gfx int_sum_blue_clk_short_model[]; +extern Gfx int_sum_blue_clk_long_model[]; + +static int aSumBlueClk_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + FTR_ACTOR* ftr_actor = (FTR_ACTOR*)arg; + GAME_PLAY* play = (GAME_PLAY*)game; + xyz_t pos; + xyz_t save_pos = { 0.0f, 0.0f, 0.0f }; + s16 base_angle_y = RAD2SHORT_ANGLE2(DEG2RAD(ftr_actor->angle_y)); + f32 scale_x = ftr_actor->scale.x * 0.01f; + f32 scale_y = ftr_actor->scale.y * 0.01f; + f32 scale_z = ftr_actor->scale.z * 0.01f; + GRAPH* graph = game->graph; + + if (joint_idx == 6) { + _texture_z_light_fog_prim_xlu(graph); + Setpos_HiliteReflect_xlu_init(&ftr_actor->position, play); + Matrix_Position(&save_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateY(base_angle_y, 1); + Matrix_RotateZ(DEG2SHORT_ANGLE(90.0f), 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + OPEN_DISP(graph); + + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_XLU_DISP, int_sum_blue_clk_evw_model); + + CLOSE_DISP(graph); + } else if (joint_idx == 5) { + Matrix_Position(&save_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateY(base_angle_y, 1); + Matrix_RotateZ(DEG2SHORT_ANGLE(90.0f) - Common_Get(time.rad_hour), 1); + Matrix_translate(0.0f, 0.0f, 1.0f, 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + OPEN_DISP(graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_blue_clk_short_model); + + CLOSE_DISP(graph); + } else if (joint_idx == 7) { + Matrix_Position(&save_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateY(base_angle_y, 1); + Matrix_RotateZ(DEG2SHORT_ANGLE(90.0f) - Common_Get(time.rad_min), 1); + Matrix_translate(0.0f, 0.0f, 1.0f, 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + OPEN_DISP(graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_blue_clk_long_model); + + CLOSE_DISP(graph); + } + + return TRUE; +} + +static int aSumBlueClk_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 5 || joint_idx == 7 || joint_idx == 6) { + *joint_shape = NULL; + } + + return TRUE; +} + +static void aSumBlueClk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[game->frame_counter & 1]; + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aSumBlueClk_DwBefore, &aSumBlueClk_DwAfter, ftr_actor); +} + +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_blue_clk; +extern cKF_Animation_R_c cKF_ba_r_int_sum_blue_clk; + +static void aSumBlueClk_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_blue_clk, &cKF_ba_r_int_sum_blue_clk, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_sum_blue_clk, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +static void aSumBlueClk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + if (Common_Get(clip).my_room_clip != NULL) { + aMR_clock_info_c* clock_info = Common_Get(clip).my_room_clip->clock_info_p; + + if (clock_info->tick_stop) { + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_sum_blue_clk, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; + } else if (clock_info->tick0 == TRUE || clock_info->tick1 == TRUE) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenTrgStart(0x12D, &ftr_actor->position); + } + + cKF_SkeletonInfo_R_play(keyframe); + } else { + cKF_SkeletonInfo_R_play(keyframe); + } + } +} + +static void aSumBlueClk_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumBlueClk_func = { - &aSumBlueClk_ct, - &aSumBlueClk_mv, - &aSumBlueClk_dw, - &aSumBlueClk_dt, - NULL, + &aSumBlueClk_ct, &aSumBlueClk_mv, &aSumBlueClk_dw, &aSumBlueClk_dt, NULL, }; aFTR_PROFILE iam_sum_blue_clk = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +146,5 @@ aFTR_PROFILE iam_sum_blue_clk = { 0, 0, &aSumBlueClk_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_doll01.c b/src/ftr/ac_sum_doll01.c index 9e6bc19c..d777a812 100644 --- a/src/ftr/ac_sum_doll01.c +++ b/src/ftr/ac_sum_doll01.c @@ -1,31 +1,39 @@ extern Gfx int_sum_doll01_on_model[]; extern Gfx int_sum_doll01_onT_model[]; -static void aSumDoll01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern Gfx int_sum_doll01_offT_model[]; + +static void aSumDoll01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + 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, int_sum_doll01_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c aSumDoll01_func = { - NULL, - NULL, - &aSumDoll01_dw, - NULL, - NULL, + NULL, NULL, &aSumDoll01_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_doll01 = { - int_sum_doll01_on_model, - int_sum_doll01_onT_model, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEC, - mCoBG_FTR_TYPEC, - 0, - 0, - 0, - 0, - &aSumDoll01_func, + // clang-format off + int_sum_doll01_on_model, + int_sum_doll01_onT_model, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEC, + mCoBG_FTR_TYPEC, + 0, + 0, + 0, + 0, + &aSumDoll01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_fruitclk.c b/src/ftr/ac_sum_fruitclk.c index 1d2db205..f0184465 100644 --- a/src/ftr/ac_sum_fruitclk.c +++ b/src/ftr/ac_sum_fruitclk.c @@ -1,32 +1,74 @@ -static void aSumfruitclk_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumfruitclk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumfruitclk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumfruitclk_dt(FTR_ACTOR* ftr_actor, u8* data); +extern Gfx int_sum_hal_clk01_short_model[]; +extern Gfx int_sum_hal_clk01_long_model[]; + +static int aSumfruitclk_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + return TRUE; +} + +static int aSumfruitclk_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 3) { + joint_rot->z -= Common_Get(time.rad_hour); + } else if (joint_idx == 4) { + joint_rot->z -= Common_Get(time.rad_min); + } + + return TRUE; +} + +static void aSumfruitclk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[game->frame_counter & 1]; + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aSumfruitclk_DwBefore, &aSumfruitclk_DwAfter, ftr_actor); +} + +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_fruitclk; +extern cKF_Animation_R_c cKF_ba_r_int_sum_fruitclk; + +static void aSumfruitclk_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_fruitclk, &cKF_ba_r_int_sum_fruitclk, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_sum_fruitclk, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +static void aSumfruitclk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_play(keyframe); +} + +static void aSumfruitclk_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumfruitclk_func = { - &aSumfruitclk_ct, - &aSumfruitclk_mv, - &aSumfruitclk_dw, - &aSumfruitclk_dt, - NULL, + &aSumfruitclk_ct, &aSumfruitclk_mv, &aSumfruitclk_dw, &aSumfruitclk_dt, NULL, }; aFTR_PROFILE iam_sum_fruitclk = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 2, - 0, - 0, - &aSumfruitclk_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 2, + 0, + 0, + &aSumfruitclk_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_fruittv01.c b/src/ftr/ac_sum_fruittv01.c index 4e168fe9..cc936533 100644 --- a/src/ftr/ac_sum_fruittv01.c +++ b/src/ftr/ac_sum_fruittv01.c @@ -1,32 +1,89 @@ -static void aSumFruittv01_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumFruittv01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumFruittv01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumFruittv01_dt(FTR_ACTOR* ftr_actor, u8* data); +static void aSumFruittv01_ct(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} + +static void aSumFruittv01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (ftr_actor->switch_bit) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenPos((u32)ftr_actor, 6, &ftr_actor->position); + } + + ftr_actor->tex_animation.frame++; + if (ftr_actor->tex_animation.frame >= 26 || ftr_actor->tex_animation.frame < 0) { + ftr_actor->tex_animation.frame = 0; + } + } + + if (ftr_actor->switch_changed_flag) { + if (ftr_actor->switch_bit) { + sAdo_OngenTrgStart(0x16, &ftr_actor->position); + } else { + sAdo_OngenTrgStart(0x17, &ftr_actor->position); + } + } +} + +extern u8 int_sum_fruittv01_front1_TA_tex_txt[]; +extern u8 int_sum_fruittv01_front2_TA_tex_txt[]; +extern u8 int_sum_fruittv01_front3_TA_tex_txt[]; +extern u8 int_sum_fruittv01_front4_TA_tex_txt[]; + +extern Gfx int_sum_fruittv01_on_model[]; +extern Gfx int_sum_fruittv01_off_model[]; + +static u8* aSumFruittv01_on_anime[] = { + int_sum_fruittv01_front2_TA_tex_txt, int_sum_fruittv01_front2_TA_tex_txt, int_sum_fruittv01_front2_TA_tex_txt, + int_sum_fruittv01_front2_TA_tex_txt, int_sum_fruittv01_front3_TA_tex_txt, int_sum_fruittv01_front3_TA_tex_txt, + int_sum_fruittv01_front3_TA_tex_txt, int_sum_fruittv01_front3_TA_tex_txt, int_sum_fruittv01_front4_TA_tex_txt, + int_sum_fruittv01_front4_TA_tex_txt, int_sum_fruittv01_front4_TA_tex_txt, int_sum_fruittv01_front4_TA_tex_txt, + int_sum_fruittv01_front4_TA_tex_txt, +}; + +static void aSumFruittv01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (ftr_actor->switch_bit) { + int frame = (s16)(ftr_actor->tex_animation.frame >> 1); + + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, aSumFruittv01_on_anime[frame]); + } else { + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, int_sum_fruittv01_front1_TA_tex_txt); + } + + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_fruittv01_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_fruittv01_off_model); + + CLOSE_DISP(game->graph); +} + +static void aSumFruittv01_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumFruittv01_func = { - &aSumFruittv01_ct, - &aSumFruittv01_mv, - &aSumFruittv01_dw, - &aSumFruittv01_dt, - NULL, + &aSumFruittv01_ct, &aSumFruittv01_mv, &aSumFruittv01_dw, &aSumFruittv01_dt, NULL, }; aFTR_PROFILE iam_sum_fruittv01 = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - aFTR_INTERACTION_START_DISABLED, - &aSumFruittv01_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + aFTR_INTERACTION_START_DISABLED, + &aSumFruittv01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_hal_box01.c b/src/ftr/ac_sum_hal_box01.c index 17b42b84..521ec825 100644 --- a/src/ftr/ac_sum_hal_box01.c +++ b/src/ftr/ac_sum_hal_box01.c @@ -1,32 +1,80 @@ -static void aSumHalBox01_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumHalBox01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumHalBox01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumHalBox01_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_hal_box01; +extern cKF_Animation_R_c cKF_ba_r_int_sum_hal_box01; + +static void aSumHalBox01_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_hal_box01, &cKF_ba_r_int_sum_hal_box01, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_stop(keyframe, &cKF_ba_r_int_sum_hal_box01, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; + ftr_actor->dynamic_work_s[0] = 0; +} + +static void aSumHalBox01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + if (ftr_actor->dynamic_work_s[0] == 1) { + if (cKF_SkeletonInfo_R_play(keyframe) != cKF_STATE_STOPPED) { + keyframe->frame_control.speed = 0.5f; + } else { + ftr_actor->dynamic_work_s[0] = 0; + } + } else { + if (ftr_actor->switch_changed_flag) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenTrgStart(0x144, &ftr_actor->position); + } + + ftr_actor->dynamic_work_s[0] = 1; + keyframe->frame_control.current_frame = 1.0f; + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; + } + } +} + +static void aSumHalBox01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + 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); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, NULL, NULL, NULL); +} + +static void aSumHalBox01_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumHalBox01_func = { - &aSumHalBox01_ct, - &aSumHalBox01_mv, - &aSumHalBox01_dw, - &aSumHalBox01_dt, - NULL, + &aSumHalBox01_ct, &aSumHalBox01_mv, &aSumHalBox01_dw, &aSumHalBox01_dt, NULL, }; aFTR_PROFILE iam_sum_hal_box01 = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 27.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &aSumHalBox01_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 27.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &aSumHalBox01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_hal_clk01.c b/src/ftr/ac_sum_hal_clk01.c index 79fc08f4..1b61c39d 100644 --- a/src/ftr/ac_sum_hal_clk01.c +++ b/src/ftr/ac_sum_hal_clk01.c @@ -1,17 +1,102 @@ -static void aSumHalClk01_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumHalClk01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumHalClk01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumHalClk01_dt(FTR_ACTOR* ftr_actor, u8* data); +extern Gfx int_sum_hal_clk01_short_model[]; +extern Gfx int_sum_hal_clk01_long_model[]; + +static int aSumHalClk01_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + FTR_ACTOR* ftr_actor = (FTR_ACTOR*)arg; + GAME_PLAY* play = (GAME_PLAY*)game; + xyz_t pos; + xyz_t save_pos = { 0.0f, 0.0f, 0.0f }; + s16 base_angle_y = RAD2SHORT_ANGLE2(DEG2RAD(ftr_actor->angle_y)); + f32 scale_x = ftr_actor->scale.x * 0.01f; + f32 scale_y = ftr_actor->scale.y * 0.01f; + f32 scale_z = ftr_actor->scale.z * 0.01f; + GRAPH* graph = game->graph; + + if (joint_idx == 3) { + Matrix_Position(&save_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateY(base_angle_y, 1); + Matrix_RotateZ(DEG2SHORT_ANGLE(90.0f) - Common_Get(time.rad_hour), 1); + Matrix_translate(0.0f, 0.0f, 1.0f, 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + OPEN_DISP(graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_hal_clk01_short_model); + + CLOSE_DISP(graph); + } else if (joint_idx == 4) { + Matrix_Position(&save_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateY(base_angle_y, 1); + Matrix_RotateZ(DEG2SHORT_ANGLE(90.0f) - Common_Get(time.rad_min), 1); + Matrix_translate(0.0f, 0.0f, 1.0f, 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + OPEN_DISP(graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_hal_clk01_long_model); + + CLOSE_DISP(graph); + } + + return TRUE; +} + +static int aSumHalClk01_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 3) { + *joint_shape = NULL; + } else if (joint_idx == 4) { + *joint_shape = NULL; + } + + return TRUE; +} + +static void aSumHalClk01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[game->frame_counter & 1]; + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aSumHalClk01_DwBefore, &aSumHalClk01_DwAfter, ftr_actor); +} + +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_hal_clk01; +extern cKF_Animation_R_c cKF_ba_r_int_sum_hal_clk01; + +static void aSumHalClk01_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_hal_clk01, &cKF_ba_r_int_sum_hal_clk01, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_sum_hal_clk01, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +static void aSumHalClk01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_play(keyframe); +} + +static void aSumHalClk01_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumHalClk01_func = { - &aSumHalClk01_ct, - &aSumHalClk01_mv, - &aSumHalClk01_dw, - &aSumHalClk01_dt, - NULL, + &aSumHalClk01_ct, &aSumHalClk01_mv, &aSumHalClk01_dw, &aSumHalClk01_dt, NULL, }; aFTR_PROFILE iam_sum_hal_clk01 = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +114,5 @@ aFTR_PROFILE iam_sum_hal_clk01 = { 0, 0, &aSumHalClk01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_hal_lanp01.c b/src/ftr/ac_sum_hal_lanp01.c index 80d8d803..87dc3c40 100644 --- a/src/ftr/ac_sum_hal_lanp01.c +++ b/src/ftr/ac_sum_hal_lanp01.c @@ -1,31 +1,39 @@ extern Gfx int_sum_hal_lanp01_off_model[]; extern Gfx int_sum_hal_lanp01_onT_model[]; -static void aSumHalLanp01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern Gfx int_sum_hal_lanp01_offT_model[]; + +static void aSumHalLanp01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + 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, int_sum_hal_lanp01_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c aSumHalLanp01_func = { - NULL, - NULL, - &aSumHalLanp01_dw, - NULL, - NULL, + NULL, NULL, &aSumHalLanp01_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_hal_lanp01 = { - int_sum_hal_lanp01_off_model, - int_sum_hal_lanp01_onT_model, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &aSumHalLanp01_func, + // clang-format off + int_sum_hal_lanp01_off_model, + int_sum_hal_lanp01_onT_model, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &aSumHalLanp01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_hal_mirror01.c b/src/ftr/ac_sum_hal_mirror01.c index 41c4adc8..8475e911 100644 --- a/src/ftr/ac_sum_hal_mirror01.c +++ b/src/ftr/ac_sum_hal_mirror01.c @@ -1,31 +1,39 @@ extern Gfx int_sum_hal_mirror01_evw_model[]; extern Gfx int_sum_hal_mirror01_onT_model[]; -static void aSumHalMirror01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern Gfx int_sum_hal_mirror01_on_model[]; + +static void aSumHalMirror01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + 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, int_sum_hal_mirror01_on_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c aSumHalMirror01_func = { - NULL, - NULL, - &aSumHalMirror01_dw, - NULL, - NULL, + NULL, NULL, &aSumHalMirror01_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_hal_mirror01 = { - int_sum_hal_mirror01_evw_model, - int_sum_hal_mirror01_onT_model, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 1, - 0, - 0, - &aSumHalMirror01_func, + // clang-format off + int_sum_hal_mirror01_evw_model, + int_sum_hal_mirror01_onT_model, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 1, + 0, + 0, + &aSumHalMirror01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_liccamirror.c b/src/ftr/ac_sum_liccamirror.c index 7252808e..0b4a02e6 100644 --- a/src/ftr/ac_sum_liccamirror.c +++ b/src/ftr/ac_sum_liccamirror.c @@ -1,31 +1,39 @@ extern Gfx int_sum_liccamirror_on_model[]; extern Gfx int_sum_liccamirror_onT_model[]; -static void aSumLiccaMirror_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern Gfx int_sum_liccamirror_env_model[]; + +static void aSumLiccaMirror_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + 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, int_sum_liccamirror_env_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c aSumLiccaMirror_func = { - NULL, - NULL, - &aSumLiccaMirror_dw, - NULL, - NULL, + NULL, NULL, &aSumLiccaMirror_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_liccamirror = { - int_sum_liccamirror_on_model, - int_sum_liccamirror_onT_model, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 1, - 0, - 0, - &aSumLiccaMirror_func, + // clang-format off + int_sum_liccamirror_on_model, + int_sum_liccamirror_onT_model, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 1, + 0, + 0, + &aSumLiccaMirror_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_log_hatoclk.c b/src/ftr/ac_sum_log_hatoclk.c index 80b7b47f..ffde39b5 100644 --- a/src/ftr/ac_sum_log_hatoclk.c +++ b/src/ftr/ac_sum_log_hatoclk.c @@ -1,32 +1,172 @@ -static void aSumLogHatoclk_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumLogHatoclk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumLogHatoclk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumLogHatoclk_dt(FTR_ACTOR* ftr_actor, u8* data); +static void aSumLogHatoclk_StopAnimeInitNormal(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* anime, f32 speed) { + cKF_SkeletonInfo_R_init_standard_stop(keyframe, anime, NULL); + keyframe->frame_control.speed = speed; + cKF_SkeletonInfo_R_play(keyframe); +} + +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_log_hatoclk; +extern cKF_Animation_R_c cKF_ba_r_int_sum_log_hatoclk; + +static void aSumLogHatoclk_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_log_hatoclk, &cKF_ba_r_int_sum_log_hatoclk, ftr_actor->joint, + ftr_actor->morph); + aSumLogHatoclk_StopAnimeInitNormal(keyframe, &cKF_ba_r_int_sum_log_hatoclk, 1.0f); + ftr_actor->dynamic_work_s[0] = 0; +} + +extern Gfx int_sum_log_hatoclk_short_model[]; +extern Gfx int_sum_log_hatoclk_long_model[]; + +static int aSumLogHatoclk_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + FTR_ACTOR* ftr_actor = (FTR_ACTOR*)arg; + GAME_PLAY* play = (GAME_PLAY*)game; + xyz_t pos; + xyz_t save_pos = { 0.0f, 0.0f, 0.0f }; + s16 base_angle_y = RAD2SHORT_ANGLE2(DEG2RAD(ftr_actor->angle_y)); + f32 scale_x = ftr_actor->scale.x * 0.01f; + f32 scale_y = ftr_actor->scale.y * 0.01f; + f32 scale_z = ftr_actor->scale.z * 0.01f; + GRAPH* graph = game->graph; + + if (joint_idx == 7) { + Matrix_Position(&save_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateY(base_angle_y, 1); + Matrix_RotateZ(DEG2SHORT_ANGLE(90.0f) - Common_Get(time.rad_hour), 1); + Matrix_translate(0.0f, 0.0f, 1.0f, 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + OPEN_DISP(graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_log_hatoclk_short_model); + + CLOSE_DISP(graph); + } else if (joint_idx == 8) { + Matrix_Position(&save_pos, &pos); + Matrix_push(); + Matrix_translate(pos.x, pos.y, pos.z, 0); + Matrix_RotateY(base_angle_y, 1); + Matrix_RotateZ(DEG2SHORT_ANGLE(90.0f) - Common_Get(time.rad_min), 1); + Matrix_translate(0.0f, 0.0f, 1.0f, 1); + Matrix_scale(scale_x, scale_y, scale_z, 1); + + OPEN_DISP(graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_pull(); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_log_hatoclk_long_model); + + CLOSE_DISP(graph); + } + return TRUE; +} + +static int aSumLogHatoclk_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 7 || joint_idx == 8) { + *joint_shape = NULL; + } + + return TRUE; +} + +static void aSumLogHatoclk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[game->frame_counter & 1]; + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aSumLogHatoclk_DwBefore, &aSumLogHatoclk_DwAfter, ftr_actor); +} + +static void aSumLogHatoclk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + static u8 pappo_count_table[lbRTC_HOURS_PER_DAY] = { + 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + }; + + switch (ftr_actor->dynamic_work_s[0]) { + case 0: { + if (rtc_time.min == 0) { + ftr_actor->dynamic_work_s[1] = pappo_count_table[rtc_time.hour]; + ftr_actor->dynamic_work_s[0] = 1; + aSumLogHatoclk_StopAnimeInitNormal(keyframe, &cKF_ba_r_int_sum_log_hatoclk, 1.0f); + keyframe->frame_control.current_frame = 1.0f; + } else if (rtc_time.min == 30) { + ftr_actor->dynamic_work_s[1] = 1; + ftr_actor->dynamic_work_s[0] = 1; + aSumLogHatoclk_StopAnimeInitNormal(keyframe, &cKF_ba_r_int_sum_log_hatoclk, 1.0f); + keyframe->frame_control.current_frame = 1.0f; + } + + break; + } + + case 1: { + if (keyframe->frame_control.current_frame == ((f32)(int)GETREG(MYKREG, 33) + 2.0f)) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenTrgStart(0x133, &ftr_actor->position); + } + + if (cKF_SkeletonInfo_R_play(keyframe) == cKF_STATE_STOPPED) { + if (keyframe->frame_control.speed == 0.0f) { + aSumLogHatoclk_StopAnimeInitNormal(keyframe, &cKF_ba_r_int_sum_log_hatoclk, 1.0f); + keyframe->frame_control.current_frame = 1.0f; + ftr_actor->dynamic_work_s[1]--; + + if (ftr_actor->dynamic_work_s[1] <= 0) { + ftr_actor->dynamic_work_s[0] = 2; // last 'pappo' was played + } + } else { + keyframe->frame_control.speed = 0.0f; + } + } + } + + break; + } + + case 2: { + if (rtc_time.min != 0 && rtc_time.min != 30) { + ftr_actor->dynamic_work_s[0] = 0; + } + + break; + } + } +} + +static void aSumLogHatoclk_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumLogHatoclk_func = { - &aSumLogHatoclk_ct, - &aSumLogHatoclk_mv, - &aSumLogHatoclk_dw, - &aSumLogHatoclk_dt, - NULL, + &aSumLogHatoclk_ct, &aSumLogHatoclk_mv, &aSumLogHatoclk_dw, &aSumLogHatoclk_dt, NULL, }; aFTR_PROFILE iam_sum_log_hatoclk = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &aSumLogHatoclk_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &aSumLogHatoclk_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_mezaclock.c b/src/ftr/ac_sum_mezaclock.c index 7b4260be..6ebde6dd 100644 --- a/src/ftr/ac_sum_mezaclock.c +++ b/src/ftr/ac_sum_mezaclock.c @@ -1,30 +1,69 @@ extern aFTR_rig_c aSumMezaClock_sklkey; -static void aSumMezaClock_Dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern Gfx int_sum_mezaclock_short_model[]; +extern Gfx int_sum_mezaclock_long_model[]; + +static int aSumMezaClock_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 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); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_mezaclock_short_model); + + CLOSE_DISP(game->graph); + } else if (joint_idx == 4) { + OPEN_DISP(game->graph); + + 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, int_sum_mezaclock_long_model); + + CLOSE_DISP(game->graph); + } + + return TRUE; +} + +static int aSumMezaClock_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 3) { + joint_rot->z -= Common_Get(time.rad_hour); + } else if (joint_idx == 4) { + joint_rot->z -= Common_Get(time.rad_min); + } + + return TRUE; +} + +static void aSumMezaClock_Dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[mtx_idx]; + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aSumMezaClock_DwBefore, &aSumMezaClock_DwAfter, ftr_actor); +} static aFTR_vtable_c aSumMezaClock_func = { - NULL, - NULL, - &aSumMezaClock_Dw, - NULL, - NULL, + NULL, NULL, &aSumMezaClock_Dw, NULL, NULL, }; aFTR_PROFILE iam_sum_mezaclock = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &aSumMezaClock_sklkey, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &aSumMezaClock_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &aSumMezaClock_sklkey, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &aSumMezaClock_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_mizunomi.c b/src/ftr/ac_sum_mizunomi.c index c8df7b27..6ee91cb5 100644 --- a/src/ftr/ac_sum_mizunomi.c +++ b/src/ftr/ac_sum_mizunomi.c @@ -1,33 +1,49 @@ extern aFTR_rig_c aSumMizunomi_sklkey; -static void aSumMizunomi_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumMizunomi_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumMizunomi_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumMizunomi_dt(FTR_ACTOR* ftr_actor, u8* data); + +static void aSumMizunomi_ct(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} + +static void aSumMizunomi_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + if (keyframe->frame_control.current_frame == 19.0f) { + sAdo_OngenTrgStart(0x12A, &ftr_actor->position); + } + } +} + +static void aSumMizunomi_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + // nothing +} + +static void aSumMizunomi_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumMizunomi_func = { - &aSumMizunomi_ct, - &aSumMizunomi_mv, - &aSumMizunomi_dw, - &aSumMizunomi_dt, - NULL, + &aSumMizunomi_ct, &aSumMizunomi_mv, &aSumMizunomi_dw, &aSumMizunomi_dt, NULL, }; aFTR_PROFILE iam_sum_mizunomi = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &aSumMizunomi_sklkey, - NULL, - 40.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 2, - 0, - 0, - &aSumMizunomi_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &aSumMizunomi_sklkey, + NULL, + 40.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 2, + 0, + 0, + &aSumMizunomi_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_okiagari01.c b/src/ftr/ac_sum_okiagari01.c index 66029286..5c28c4be 100644 --- a/src/ftr/ac_sum_okiagari01.c +++ b/src/ftr/ac_sum_okiagari01.c @@ -1,31 +1,69 @@ -static void aSumOkiagari01_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumOkiagari01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumOkiagari01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_okiagari01; +extern cKF_Animation_R_c cKF_ba_r_int_sum_okiagari01; + +static void aSumOkiagari01_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_okiagari01, &cKF_ba_r_int_sum_okiagari01, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_stop(keyframe, &cKF_ba_r_int_sum_okiagari01, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +static void aSumOkiagari01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + if (cKF_SkeletonInfo_R_play(keyframe) != cKF_STATE_STOPPED) { + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; + } else if (ftr_actor->switch_changed_flag) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenTrgStart(0x145, &ftr_actor->position); + } + + keyframe->frame_control.current_frame = 1.0f; + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; + } +} + +static void aSumOkiagari01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + 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); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, NULL, NULL, NULL); +} static aFTR_vtable_c aSumOkiagari01_func = { - &aSumOkiagari01_ct, - &aSumOkiagari01_mv, - &aSumOkiagari01_dw, - NULL, - NULL, + &aSumOkiagari01_ct, &aSumOkiagari01_mv, &aSumOkiagari01_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_okiagari01 = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 40.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 0, - 0, - 0, - &aSumOkiagari01_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 40.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 0, + 0, + 0, + &aSumOkiagari01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_oldclk01.c b/src/ftr/ac_sum_oldclk01.c index ff7f48b3..f8040c18 100644 --- a/src/ftr/ac_sum_oldclk01.c +++ b/src/ftr/ac_sum_oldclk01.c @@ -1,32 +1,87 @@ -static void aSumOldClk01_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumOldClk01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumOldClk01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumOldClk01_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_oldclk01; +extern cKF_Animation_R_c cKF_ba_r_int_sum_oldclk01; + +static void aSumOldClk01_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_oldclk01, &cKF_ba_r_int_sum_oldclk01, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_sum_oldclk01, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +static int aSumOldClk01_dwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + return TRUE; +} + +static int aSumOldClk01_dwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 5) { + joint_rot->z -= Common_Get(time.rad_hour); + } else if (joint_idx == 7) { + joint_rot->z -= Common_Get(time.rad_min); + } + + return TRUE; +} + +static void aSumOldClk01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[mtx_idx]; + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aSumOldClk01_dwBefore, &aSumOldClk01_dwAfter, ftr_actor); +} + +static void aSumOldClk01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (Common_Get(clip).my_room_clip != NULL) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + aMR_clock_info_c* clock_info = Common_Get(clip).my_room_clip->clock_info_p; + + if (clock_info->tick_stop) { + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_sum_oldclk01, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; + } else if (clock_info->tick0 == TRUE || clock_info->tick1 == TRUE) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenTrgStart(0x12D, &ftr_actor->position); + } + + cKF_SkeletonInfo_R_play(keyframe); + } else { + cKF_SkeletonInfo_R_play(keyframe); + } + } +} + +static void aSumOldClk01_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumOldClk01_func = { - &aSumOldClk01_ct, - &aSumOldClk01_mv, - &aSumOldClk01_dw, - &aSumOldClk01_dt, - NULL, + &aSumOldClk01_ct, &aSumOldClk01_mv, &aSumOldClk01_dw, &aSumOldClk01_dt, NULL, }; aFTR_PROFILE iam_sum_oldclk01 = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 18.0f, - 0.01f, - aFTR_SHAPE_TYPEA, - mCoBG_FTR_TYPEA, - 0, - 2, - 0, - 0, - &aSumOldClk01_func, + // clang-format off + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 18.0f, + 0.01f, + aFTR_SHAPE_TYPEA, + mCoBG_FTR_TYPEA, + 0, + 2, + 0, + 0, + &aSumOldClk01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_ratan_mirror.c b/src/ftr/ac_sum_ratan_mirror.c index 9a59fd33..a4e5b78f 100644 --- a/src/ftr/ac_sum_ratan_mirror.c +++ b/src/ftr/ac_sum_ratan_mirror.c @@ -1,16 +1,23 @@ extern Gfx int_sum_ratan_mirror_evw_model[]; +extern Gfx int_sum_ratan_mirror_on_model[]; extern Gfx int_sum_ratan_mirror_onT_model[]; -static void aSumRatanMirror_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void aSumRatanMirror_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + 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, int_sum_ratan_mirror_on_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c aSumRatanMirror_func = { - NULL, - NULL, - &aSumRatanMirror_dw, - NULL, - NULL, + NULL, NULL, &aSumRatanMirror_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_ratan_mirror = { + // clang-format off int_sum_ratan_mirror_evw_model, int_sum_ratan_mirror_onT_model, NULL, @@ -28,4 +35,5 @@ aFTR_PROFILE iam_sum_ratan_mirror = { 0, 0, &aSumRatanMirror_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_roboclk.c b/src/ftr/ac_sum_roboclk.c index f5288554..ab07d2ac 100644 --- a/src/ftr/ac_sum_roboclk.c +++ b/src/ftr/ac_sum_roboclk.c @@ -1,17 +1,72 @@ -static void aSumroboclk_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumroboclk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumroboclk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumroboclk_dt(FTR_ACTOR* ftr_actor, u8* data); +static int aSumroboclk_DwAfter(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + return TRUE; +} + +static int aSumroboclk_DwBefore(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int joint_idx, Gfx** joint_shape, + u8* joint_flags, void* arg, s_xyz* joint_rot, xyz_t* joint_pos) { + if (joint_idx == 4) { + joint_rot->z -= Common_Get(time.rad_hour); + } else if (joint_idx == 3) { + joint_rot->z -= Common_Get(time.rad_min); + } + + return TRUE; +} + +extern u8 int_sum_roboclk_eye1_TA_tex_txt[]; +extern u8 int_sum_roboclk_eye2_TA_tex_txt[]; + +static void aSumroboclk_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[mtx_idx]; + int tex_idx = game->frame_counter & 3; + static u8* texture_table[] = { + int_sum_roboclk_eye1_TA_tex_txt, + int_sum_roboclk_eye1_TA_tex_txt, + int_sum_roboclk_eye2_TA_tex_txt, + int_sum_roboclk_eye2_TA_tex_txt, + }; + + OPEN_DISP(game->graph); + + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, texture_table[tex_idx]); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, &aSumroboclk_DwBefore, &aSumroboclk_DwAfter, ftr_actor); +} + +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_roboclk; +extern cKF_Animation_R_c cKF_ba_r_int_sum_roboclk; + +static void aSumroboclk_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_roboclk, &cKF_ba_r_int_sum_roboclk, ftr_actor->joint, + ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_repeat(keyframe, &cKF_ba_r_int_sum_roboclk, NULL); + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; +} + +static void aSumroboclk_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_play(keyframe); +} + +static void aSumroboclk_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumroboclk_func = { - &aSumroboclk_ct, - &aSumroboclk_mv, - &aSumroboclk_dw, - &aSumroboclk_dt, - NULL, + &aSumroboclk_ct, &aSumroboclk_mv, &aSumroboclk_dw, &aSumroboclk_dt, NULL, }; aFTR_PROFILE iam_sum_roboclk = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +84,5 @@ aFTR_PROFILE iam_sum_roboclk = { 0, 0, &aSumroboclk_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_slot.c b/src/ftr/ac_sum_slot.c index 2cae4f1c..1b822d8e 100644 --- a/src/ftr/ac_sum_slot.c +++ b/src/ftr/ac_sum_slot.c @@ -1,17 +1,81 @@ -static void aSumSlot_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumSlot_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumSlot_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumSlot_dt(FTR_ACTOR* ftr_actor, u8* data); +extern cKF_Skeleton_R_c cKF_bs_r_int_sum_slot; +extern cKF_Animation_R_c cKF_ba_r_int_sum_slot; + +static void aSumSlot_ct(FTR_ACTOR* ftr_actor, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_int_sum_slot, &cKF_ba_r_int_sum_slot, ftr_actor->joint, ftr_actor->morph); + cKF_SkeletonInfo_R_init_standard_stop(keyframe, &cKF_ba_r_int_sum_slot, NULL); + keyframe->frame_control.speed = 0.5f; + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.0f; + ftr_actor->dynamic_work_s[0] = FALSE; +} + +static void aSumSlot_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + + if (ftr_actor->dynamic_work_s[0] == TRUE) { + if (cKF_SkeletonInfo_R_play(keyframe) != cKF_STATE_STOPPED) { + keyframe->frame_control.speed = 0.5f; + ftr_actor->tex_animation.frame++; + + if (ftr_actor->tex_animation.frame >= 242 || ftr_actor->tex_animation.frame < 0) { + ftr_actor->tex_animation.frame = 0; + } + + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenPos((u32)ftr_actor, 2, &ftr_actor->position); + } + } else { + ftr_actor->dynamic_work_s[0] = FALSE; + } + } else if (ftr_actor->switch_changed_flag) { + ftr_actor->dynamic_work_s[0] = TRUE; + keyframe->frame_control.current_frame = 1.0f; + cKF_SkeletonInfo_R_play(keyframe); + keyframe->frame_control.speed = 0.5f; + } +} + +extern u8 int_sum_slot_reel1_TA_tex_txt[]; +extern u8 int_sum_slot_reel2_TA_tex_txt[]; + +static u8* aSumSlot_anim[] = { int_sum_slot_reel1_TA_tex_txt, int_sum_slot_reel2_TA_tex_txt }; + +static u8 aSumSlot_aime_idx[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, +}; + +static void aSumSlot_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + int mtx_idx = game->frame_counter & 1; + cKF_SkeletonInfo_R_c* keyframe = &ftr_actor->keyframe; + Mtx* mtx = ftr_actor->skeleton_mtx[mtx_idx]; + int idx = ftr_actor->tex_animation.frame >> 1; + + 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_8, aSumSlot_anim[aSumSlot_aime_idx[idx]]); + + CLOSE_DISP(game->graph); + + cKF_Si3_draw_R_SV(game, keyframe, mtx, NULL, NULL, NULL); +} + +static void aSumSlot_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumSlot_func = { - &aSumSlot_ct, - &aSumSlot_mv, - &aSumSlot_dw, - &aSumSlot_dt, - NULL, + &aSumSlot_ct, &aSumSlot_mv, &aSumSlot_dw, &aSumSlot_dt, NULL, }; aFTR_PROFILE iam_sum_slot = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +93,5 @@ aFTR_PROFILE iam_sum_slot = { 0, 0, &aSumSlot_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_stove01.c b/src/ftr/ac_sum_stove01.c index ffa0608b..507c4c63 100644 --- a/src/ftr/ac_sum_stove01.c +++ b/src/ftr/ac_sum_stove01.c @@ -1,16 +1,23 @@ extern Gfx int_sum_stove01_on_model[]; extern Gfx int_sum_stove01_onT_model[]; -static void aSumStove01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); +extern Gfx int_sum_stove_offT_model[]; + +static void aSumStove01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + 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, int_sum_stove_offT_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c aSumStove01_func = { - NULL, - NULL, - &aSumStove01_dw, - NULL, - NULL, + NULL, NULL, &aSumStove01_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_stove01 = { + // clang-format off int_sum_stove01_on_model, int_sum_stove01_onT_model, NULL, @@ -28,4 +35,5 @@ aFTR_PROFILE iam_sum_stove01 = { 0, 0, &aSumStove01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_tv01.c b/src/ftr/ac_sum_tv01.c index b27db14d..9c1b9e7a 100644 --- a/src/ftr/ac_sum_tv01.c +++ b/src/ftr/ac_sum_tv01.c @@ -1,17 +1,78 @@ -static void aSumTv01_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumTv01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumTv01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumTv01_dt(FTR_ACTOR* ftr_actor, u8* data); +static void aSumTv01_ct(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} + +static void aSumTv01_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (ftr_actor->switch_bit) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenPos((u32)ftr_actor, 5, &ftr_actor->position); + } + + ftr_actor->tex_animation.frame++; + if (ftr_actor->tex_animation.frame >= 54 || ftr_actor->tex_animation.frame < 0) { + ftr_actor->tex_animation.frame = 0; + } + } + + if (ftr_actor->switch_changed_flag) { + if (ftr_actor->switch_bit) { + sAdo_OngenTrgStart(0x16, &ftr_actor->position); + } else { + sAdo_OngenTrgStart(0x17, &ftr_actor->position); + } + } +} + +extern u8 int_sum_tv01_front1_TA_tex_txt[]; +extern u8 int_sum_tv01_front2_TA_tex_txt[]; +extern u8 int_sum_tv01_front3_TA_tex_txt[]; +extern u8 int_sum_tv01_front4_TA_tex_txt[]; + +extern Gfx int_sum_tv01_on_model[]; +extern Gfx int_sum_tv01_off_model[]; + +static u8* aSumTv01_on_anime[] = { + int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, + int_sum_tv01_front3_TA_tex_txt, int_sum_tv01_front3_TA_tex_txt, int_sum_tv01_front3_TA_tex_txt, + int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, + int_sum_tv01_front3_TA_tex_txt, int_sum_tv01_front3_TA_tex_txt, int_sum_tv01_front3_TA_tex_txt, + int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, + int_sum_tv01_front3_TA_tex_txt, int_sum_tv01_front3_TA_tex_txt, int_sum_tv01_front3_TA_tex_txt, + int_sum_tv01_front4_TA_tex_txt, int_sum_tv01_front4_TA_tex_txt, int_sum_tv01_front4_TA_tex_txt, + int_sum_tv01_front4_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, + int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, int_sum_tv01_front2_TA_tex_txt, +}; + +static void aSumTv01_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (ftr_actor->switch_bit) { + int frame = (s16)(ftr_actor->tex_animation.frame >> 1); + u8* tex = aSumTv01_on_anime[frame]; + + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, tex); + } else { + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, int_sum_tv01_front1_TA_tex_txt); + } + + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_tv01_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_tv01_off_model); + + CLOSE_DISP(game->graph); +} + +static void aSumTv01_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumTv01_func = { - &aSumTv01_ct, - &aSumTv01_mv, - &aSumTv01_dw, - &aSumTv01_dt, - NULL, + &aSumTv01_ct, &aSumTv01_mv, &aSumTv01_dw, &aSumTv01_dt, NULL, }; aFTR_PROFILE iam_sum_tv01 = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +90,5 @@ aFTR_PROFILE iam_sum_tv01 = { 0, aFTR_INTERACTION_START_DISABLED, &aSumTv01_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_tv02.c b/src/ftr/ac_sum_tv02.c index bcb3566f..943fdc5b 100644 --- a/src/ftr/ac_sum_tv02.c +++ b/src/ftr/ac_sum_tv02.c @@ -1,17 +1,70 @@ -static void aSumTv02_ct(FTR_ACTOR* ftr_actor, u8* data); -static void aSumTv02_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumTv02_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); -static void aSumTv02_dt(FTR_ACTOR* ftr_actor, u8* data); +static void aSumTv02_ct(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} + +static void aSumTv02_mv(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + if (ftr_actor->switch_bit) { + if (aFTR_CAN_PLAY_SE(ftr_actor)) { + sAdo_OngenPos((u32)ftr_actor, 4, &ftr_actor->position); + } + + ftr_actor->tex_animation.frame++; + if (ftr_actor->tex_animation.frame >= 10 || ftr_actor->tex_animation.frame < 0) { + ftr_actor->tex_animation.frame = 0; + } + } + + if (ftr_actor->switch_changed_flag) { + if (ftr_actor->switch_bit) { + sAdo_OngenTrgStart(0x16, &ftr_actor->position); + } else { + sAdo_OngenTrgStart(0x17, &ftr_actor->position); + } + } +} + +extern u8 int_sum_tv02_front1_TA_tex_txt[]; +extern u8 int_sum_tv02_front2_TA_tex_txt[]; +extern u8 int_sum_tv02_front3_TA_tex_txt[]; + +extern Gfx int_sum_tv02_on_model[]; +extern Gfx int_sum_tv02_off_model[]; + +static u8* aSumTv02_on_anime[] = { + int_sum_tv02_front2_TA_tex_txt, int_sum_tv02_front2_TA_tex_txt, int_sum_tv02_front3_TA_tex_txt, + int_sum_tv02_front3_TA_tex_txt, int_sum_tv02_front3_TA_tex_txt, +}; + +static void aSumTv02_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (ftr_actor->switch_bit) { + int frame = (s16)(ftr_actor->tex_animation.frame >> 1); + u8* tex = aSumTv02_on_anime[frame]; + + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, tex); + } else { + gSPSegment(NEXT_POLY_OPA_DISP, G_MWO_SEGMENT_8, int_sum_tv02_front1_TA_tex_txt); + } + + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_tv02_on_model); + gSPDisplayList(NEXT_POLY_OPA_DISP, int_sum_tv02_off_model); + + CLOSE_DISP(game->graph); +} + +static void aSumTv02_dt(FTR_ACTOR* ftr_actor, u8* data) { + // nothing +} static aFTR_vtable_c aSumTv02_func = { - &aSumTv02_ct, - &aSumTv02_mv, - &aSumTv02_dw, - &aSumTv02_dt, - NULL, + &aSumTv02_ct, &aSumTv02_mv, &aSumTv02_dw, &aSumTv02_dt, NULL, }; aFTR_PROFILE iam_sum_tv02 = { + // clang-format off NULL, NULL, NULL, @@ -29,4 +82,5 @@ aFTR_PROFILE iam_sum_tv02 = { 0, aFTR_INTERACTION_START_DISABLED, &aSumTv02_func, + // clang-format on }; diff --git a/src/ftr/ac_sum_whi_mirror.c b/src/ftr/ac_sum_whi_mirror.c index e61d68fb..577a6189 100644 --- a/src/ftr/ac_sum_whi_mirror.c +++ b/src/ftr/ac_sum_whi_mirror.c @@ -1,16 +1,23 @@ extern Gfx int_sum_whi_mirror_evw_model[]; +extern Gfx int_sum_whi_mirror_on_model[]; extern Gfx int_sum_whi_mirror_onT_model[]; -static void aSumWhiMirror_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data); + +static void aSumWhiMirror_dw(FTR_ACTOR* ftr_actor, ACTOR* my_room_actor, GAME* game, u8* data) { + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim(game->graph); + 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, int_sum_whi_mirror_on_model); + + CLOSE_DISP(game->graph); +} static aFTR_vtable_c aSumWhiMirror_func = { - NULL, - NULL, - &aSumWhiMirror_dw, - NULL, - NULL, + NULL, NULL, &aSumWhiMirror_dw, NULL, NULL, }; aFTR_PROFILE iam_sum_whi_mirror = { + // clang-format off int_sum_whi_mirror_evw_model, int_sum_whi_mirror_onT_model, NULL, @@ -28,4 +35,5 @@ aFTR_PROFILE iam_sum_whi_mirror = { 0, 0, &aSumWhiMirror_func, + // clang-format on };