diff --git a/configure.py b/configure.py index 4e1a7f33..9dd682c1 100644 --- a/configure.py +++ b/configure.py @@ -1253,9 +1253,9 @@ config.libs = [ Object(Matching, "effect/ef_effect_control.c"), Object(Matching, "effect/ef_flash.c"), Object(Matching, "effect/ef_footprint.c"), - Object(NonMatching, "effect/ef_furo_yuge.c"), - Object(NonMatching, "effect/ef_gimonhu.c"), - Object(NonMatching, "effect/ef_goki.c"), + Object(Matching, "effect/ef_furo_yuge.c"), + Object(Matching, "effect/ef_gimonhu.c"), + Object(Matching, "effect/ef_goki.c"), Object(NonMatching, "effect/ef_ha.c"), Object(Matching, "effect/ef_halloween.c"), Object(Matching, "effect/ef_halloween_smoke.c"), diff --git a/src/effect/ef_furo_yuge.c b/src/effect/ef_furo_yuge.c index e526265d..dc2188cf 100644 --- a/src/effect/ef_furo_yuge.c +++ b/src/effect/ef_furo_yuge.c @@ -1,12 +1,30 @@ #include "ef_effect_control.h" +#include "m_common_data.h" +#include "m_debug.h" + +// Furo Yuge == Bath Steam + +#define EFFECT_STAGE1 41 +#define EFFECT_FADEOUT 3 +#define EFFECT_LIFETIME (EFFECT_STAGE1 + EFFECT_FADEOUT) static void eFuro_Yuge_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1); static void eFuro_Yuge_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg); static void eFuro_Yuge_mv(eEC_Effect_c* effect, GAME* game); static void eFuro_Yuge_dw(eEC_Effect_c* effect, GAME* game); +// clang-format off + +extern Gfx ef_dust01_0[], ef_dust01_1[], ef_dust01_2[], ef_dust01_3[], ef_dust01_modelT[]; + +Gfx* eFuro_Yuge_texture_table[] = { + ef_dust01_0, + ef_dust01_1, + ef_dust01_2, + ef_dust01_3 +}; + eEC_PROFILE_c iam_ef_furo_yuge = { - // clang-format off &eFuro_Yuge_init, &eFuro_Yuge_ct, &eFuro_Yuge_mv, @@ -14,21 +32,107 @@ eEC_PROFILE_c iam_ef_furo_yuge = { eEC_IGNORE_DEATH, eEC_NO_CHILD_ID, eEC_IGNORE_DEATH_DIST, - // clang-format on }; +u8 eFuro_Yuge_2tile_texture_idx[][2] = { + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 1, 1 }, + { 1, 2 }, + { 1, 2 }, + { 1, 2 }, + { 2, 2 }, + { 2, 3 }, + { 2, 3 }, + { 2, 3 }, + { 3, 3 }, + { 3, 3 }, + { 3, 3 }, + { 3, 3 }, + { 3, 3 } +}; + +u8 eFuro_Yuge_prim_f[] = { + 0, + 0, + 0, + 0, + 0, + 0, + 64, + 128, + 192, + 0, + 64, + 128, + 192, + 0, + 64, + 128, + 192, + 0, + 0, + 0, + 0, + 0 +}; + +// clang-format on + static void eFuro_Yuge_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { - // TODO + eEC_CLIP->make_effect_proc(eEC_EFFECT_FURO_YUGE, pos, NULL, game, NULL, item_name, prio, arg0, arg1); } static void eFuro_Yuge_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { - // TODO + qrand(); + effect->position.y += GETREG(TAKREG, 0x34) + 1.f; + effect->scale.x = effect->scale.y = effect->scale.z = GETREG(TAKREG, 0x37) * 0.0001f + 0.001f; + effect->timer = EFFECT_LIFETIME; + effect->acceleration = ZeroVec; + effect->acceleration.y = GETREG(TAKREG, 0x32) * 0.001f + 0.05f; + effect->velocity = ZeroVec; + effect->position.x += RANDOM2_F(effect->arg0); + effect->position.z += RANDOM2_F(effect->arg0); } static void eFuro_Yuge_mv(eEC_Effect_c* effect, GAME* game) { - // TODO + xyz_t_add(&effect->velocity, &effect->acceleration, &effect->velocity); + xyz_t_add(&effect->position, &effect->velocity, &effect->position); + effect->velocity.y *= GETREG(TAKREG, 0x39) * 0.001f + 0.9f; } static void eFuro_Yuge_dw(eEC_Effect_c* effect, GAME* game) { - // TODO + int opacity; + s16 frames_alive = EFFECT_LIFETIME - effect->timer; + s16 half_timer = CLAMP(frames_alive >> 1, 0, EFFECT_LIFETIME / 2); + int texIdx1 = eFuro_Yuge_2tile_texture_idx[half_timer][0]; + int texIdx2 = eFuro_Yuge_2tile_texture_idx[half_timer][1]; + + effect->scale.x = + eEC_CLIP->calc_adjust_proc(frames_alive, 0, EFFECT_LIFETIME, GETREG(TAKREG, 0x37) * 0.0001f + 0.0015f, + GETREG(TAKREG, 0x38) * 0.0001f + 0.009f); + effect->scale.y = effect->scale.z = effect->scale.x; + + if (frames_alive < EFFECT_STAGE1) { + opacity = eEC_CLIP->calc_adjust_proc(frames_alive, 0, EFFECT_STAGE1, GETREG(TAKREG, 0x35) + 50.f, + GETREG(TAKREG, 0x36) + 80.f); + } else { + opacity = + eEC_CLIP->calc_adjust_proc(frames_alive, EFFECT_STAGE1, EFFECT_LIFETIME, GETREG(TAKREG, 0x36) + 80.f, 0.0f); + } + + OPEN_DISP(game->graph); + eEC_CLIP->auto_matrix_xlu_proc(game, &effect->position, &effect->scale); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, eFuro_Yuge_texture_table[texIdx1]); + gSPSegment(NEXT_POLY_XLU_DISP, ANIME_2_TXT_SEG, eFuro_Yuge_texture_table[texIdx2]); + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, eFuro_Yuge_prim_f[half_timer], 255, 255, 255, opacity); + gSPDisplayList(NEXT_POLY_XLU_DISP, ef_dust01_modelT); + CLOSE_DISP(game->graph); } diff --git a/src/effect/ef_gimonhu.c b/src/effect/ef_gimonhu.c index 514db582..da8ecb56 100644 --- a/src/effect/ef_gimonhu.c +++ b/src/effect/ef_gimonhu.c @@ -1,12 +1,19 @@ #include "ef_effect_control.h" +#include "m_common_data.h" +#include "m_rcp.h" +#include "sys_matrix.h" static void eGM_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1); static void eGM_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg); static void eGM_mv(eEC_Effect_c* effect, GAME* game); static void eGM_dw(eEC_Effect_c* effect, GAME* game); +#define EFFECT_LIFETIME 72 +#define EFFECT_STAGE2 64 +#define EFFECT_STAGE1 50 + +// clang-format off eEC_PROFILE_c iam_ef_gimonhu = { - // clang-format off &eGM_init, &eGM_ct, &eGM_mv, @@ -14,21 +21,78 @@ eEC_PROFILE_c iam_ef_gimonhu = { eEC_IGNORE_DEATH, eEC_NO_CHILD_ID, eEC_DEFAULT_DEATH_DIST, - // clang-format on }; +f32 eGM_scale_data[][2] = { + { 0.5f, 0.5f }, + { 0.5f, 1.2f }, + { 0.5f, 2.f }, + { 1.2f, 1.4f }, + { 2.f, 0.7f }, + { 1.5f, 0.8f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f }, + { 1.f, 1.f } +}; + +extern Gfx ef_gimonhu01_00_modelT[]; + +// clang-format on static void eGM_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { - // TODO + const float delta = 9.58738e-05f; // not sure about this constant, close to 1e-4, but not quite + xyz_t p = { 0.f, 15.f, 7.f }; + sMath_RotateY(&p, angle * delta); + pos.x += p.x; + pos.y += p.y; + eEC_CLIP->make_effect_proc(eEC_EFFECT_GIMONHU, pos, NULL, game, NULL, item_name, prio, 0, 0); } static void eGM_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { - // TODO + effect->timer = EFFECT_LIFETIME; + effect->offset.x = effect->offset.y = effect->offset.z = 0.f; } static void eGM_mv(eEC_Effect_c* effect, GAME* game) { - // TODO + s16 currentFrame = EFFECT_LIFETIME - effect->timer; + if (currentFrame == 0) { + sAdo_OngenTrgStart(0X2F, &effect->position); + } } static void eGM_dw(eEC_Effect_c* effect, GAME* game) { - // TODO + s16 frameIndex; + s16 currentFrame = EFFECT_LIFETIME - effect->timer; + int v = (u8)eEC_CLIP->calc_adjust_proc(currentFrame, EFFECT_STAGE2, EFFECT_LIFETIME, 255.f, 0.f); + if (currentFrame > EFFECT_STAGE1) { + currentFrame = EFFECT_STAGE1; + } + frameIndex = currentFrame >> 1; + frameIndex = CLAMP(frameIndex, 0, EFFECT_STAGE1 / 2); + effect->scale.x = eGM_scale_data[frameIndex][0] * 0.008f; + effect->scale.y = eGM_scale_data[frameIndex][1] * 0.008f; + effect->scale.z = 0.008f; + OPEN_DISP(game->graph); + _texture_z_light_fog_prim_xlu(game->graph); + eEC_CLIP->auto_matrix_xlu_offset_proc(game, &effect->position, &effect->scale, &effect->offset); + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, 128, 255, 255, 255, v); + gSPDisplayList(NEXT_POLY_XLU_DISP, ef_gimonhu01_00_modelT); + CLOSE_DISP(game->graph); } diff --git a/src/effect/ef_goki.c b/src/effect/ef_goki.c index 2883149a..49d04217 100644 --- a/src/effect/ef_goki.c +++ b/src/effect/ef_goki.c @@ -1,10 +1,22 @@ #include "ef_effect_control.h" +#include "m_common_data.h" +#include "m_rcp.h" +#include "sys_matrix.h" +#include "m_debug.h" static void eGoki_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1); static void eGoki_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg); static void eGoki_mv(eEC_Effect_c* effect, GAME* game); static void eGoki_dw(eEC_Effect_c* effect, GAME* game); +#define EFFECT_LIFETIME 190 + +#define CALC_EASE(x) (1.0f - sqrtf(1.0f - (x))) +#define CALC_EASE2(x) CALC_EASE(CALC_EASE(x)) + +extern EVW_ANIME_DATA ef_goki01_01_evw_anime[]; +extern Gfx ef_goki01_01_modelT[]; + eEC_PROFILE_c iam_ef_goki = { // clang-format off &eGoki_init, @@ -18,17 +30,60 @@ eEC_PROFILE_c iam_ef_goki = { }; static void eGoki_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { - // TODO + eEC_CLIP->make_effect_proc(eEC_EFFECT_GOKI, pos, NULL, game, NULL, item_name, prio, arg0, arg1); } static void eGoki_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { - // TODO + effect->timer = EFFECT_LIFETIME; + effect->scale = ZeroVec; + effect->velocity = ZeroVec; + effect->acceleration = ZeroVec; + + effect->velocity.y = 2.25f; + + effect->acceleration.y = 0.075f; + + effect->effect_specific[0] = 0; + + effect->offset.y = 2.f; + effect->offset.z = 2000.f; } static void eGoki_mv(eEC_Effect_c* effect, GAME* game) { - // TODO + s16 now_timer = effect->timer; + if (effect->timer > 160) { + effect->scale.x = eEC_CLIP->calc_adjust_proc(effect->timer, 0xa0, EFFECT_LIFETIME, 0.005f, 0.f); + effect->scale.y = effect->scale.z = effect->scale.x; + } else if (effect->timer < 60) { + effect->scale.x = eEC_CLIP->calc_adjust_proc(effect->timer, 0, 0x3c, 0.f, 0.005f); + effect->scale.y = eEC_CLIP->calc_adjust_proc(effect->timer, 0, 0x3c, 0.01f, 0.005f); + } + if (effect->timer < 80) { + add_calc0(&effect->offset.y, CALC_EASE(0.06f), 0.5f); + add_calc0(&effect->offset.z, CALC_EASE(0.06f), 50.f); + } + xyz_t_add(&effect->velocity, &effect->acceleration, &effect->velocity); + xyz_t_add(&effect->position, &effect->velocity, &effect->position); + effect->velocity.y *= sqrtf(0.65f); + effect->effect_specific[1] += 1000; + effect->offset.x = effect->offset.y * sin_s(effect->effect_specific[1]); + effect->effect_specific[0] = -effect->offset.z * cos_s(effect->effect_specific[1]); } static void eGoki_dw(eEC_Effect_c* effect, GAME* game) { - // TODO + GAME_PLAY* play = (GAME_PLAY*)game; + int opacity = (u8)eEC_CLIP->calc_adjust_proc(effect->timer, 0, 20, 100.f, 255.f); + _texture_z_light_fog_prim_xlu(game->graph); + OPEN_DISP(game->graph); + Matrix_translate(effect->position.x + effect->offset.x, effect->position.y, effect->position.z, FALSE); + Matrix_scale(effect->scale.x * (GETREG(MYKREG, 0x1b) * 0.01f + 1.f), + effect->scale.y * (GETREG(MYKREG, 0x1b) * 0.01f + 1.f), + effect->scale.z * (GETREG(MYKREG, 0x1b) * 0.01f + 1.f), TRUE); + Matrix_mult(&play->billboard_matrix, TRUE); + Matrix_RotateZ(effect->effect_specific[0], TRUE); + Evw_Anime_Set(play, ef_goki01_01_evw_anime); + gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, 255, 255, 255, 255, opacity); + gSPDisplayList(NEXT_POLY_XLU_DISP, ef_goki01_01_modelT); + CLOSE_DISP(game->graph); }