From 5d1f5e2834eac73533149a9e2adf1c08b4b54924 Mon Sep 17 00:00:00 2001 From: Norgesnerd <5824576+Norgesnerd@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:59:16 +0200 Subject: [PATCH] Implement & link ef_namida --- configure.py | 2 +- src/effect/ef_namida.c | 78 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/configure.py b/configure.py index b74ca083..ed7fdfb0 100644 --- a/configure.py +++ b/configure.py @@ -1297,7 +1297,7 @@ config.libs = [ Object(NonMatching, "effect/ef_motiyuge.c"), Object(Matching, "effect/ef_muka.c"), Object(Matching, "effect/ef_naku.c"), - Object(NonMatching, "effect/ef_namida.c"), + Object(Matching, "effect/ef_namida.c"), Object(Matching, "effect/ef_neboke.c"), Object(NonMatching, "effect/ef_neboke_akubi.c"), Object(NonMatching, "effect/ef_neboke_awa.c"), diff --git a/src/effect/ef_namida.c b/src/effect/ef_namida.c index 4d70f95a..9a8aa9b1 100644 --- a/src/effect/ef_namida.c +++ b/src/effect/ef_namida.c @@ -1,5 +1,12 @@ #include "ef_effect_control.h" +#include "m_common_data.h" +#include "m_debug.h" +#include "m_rcp.h" +#include "sys_matrix.h" + +extern Gfx ef_namida01_modelT[]; + static void eNamida_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1); static void eNamida_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg); static void eNamida_mv(eEC_Effect_c* effect, GAME* game); @@ -17,18 +24,81 @@ eEC_PROFILE_c iam_ef_namida = { // clang-format on }; +typedef struct { + s16 angle; + s16 arg0; +} eNamida_dt_c; + static void eNamida_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { - // TODO + xyz_t ofs; + eNamida_dt_c data; + + data.angle = angle; + data.arg0 = arg0; + + ofs.x = GETREG(MYKREG, 0x18); + ofs.y = GETREG(MYKREG, 0x19); + ofs.z = GETREG(MYKREG, 0x1a) + 10.0f; + + eEC_CLIP->make_effect_proc(eEC_EFFECT_NAMIDA, pos, &ofs, game, &data, item_name, prio, 0, 0); } static void eNamida_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { - // TODO + eNamida_dt_c* data = (eNamida_dt_c*)ct_arg; + + effect->timer = 30; + + effect->effect_specific[0] = data->angle; + effect->effect_specific[1] = data->arg0; + + eEC_CLIP->random_first_speed_proc(&effect->velocity, 1.85f, 40.0f, 40.0f); + if (effect->effect_specific[1] == 0) { + sMath_RotateZ(&effect->velocity, DEG2RAD(55.0f)); + } else if (effect->effect_specific[1] == 1) { + sMath_RotateZ(&effect->velocity, DEG2RAD(-55.0f)); + } + + effect->acceleration.x = 0.0f; + effect->acceleration.y = -0.0675f; + effect->acceleration.z = 0.0f; + + effect->scale.x = 0.0f; + effect->scale.y = 0.0f; + effect->scale.z = 0.0f; } static void eNamida_mv(eEC_Effect_c* effect, GAME* game) { - // TODO + s16 timer = 30 - effect->timer; + + xyz_t_add(&effect->velocity, &effect->acceleration, &effect->velocity); + xyz_t_add(&effect->offset, &effect->velocity, &effect->offset); + + if (timer < 20) { + effect->scale.x = eEC_CLIP->calc_adjust_proc(timer, 0, 18, 0.0f, 0.0027f); + } else { + effect->scale.x = eEC_CLIP->calc_adjust_proc(timer, 20, 30, 0.0027f, 0.0f); + } + effect->scale.y = effect->scale.x; + effect->scale.z = effect->scale.x; } static void eNamida_dw(eEC_Effect_c* effect, GAME* game) { - // TODO + s16 angle = effect->effect_specific[0]; + xyz_t vec = effect->offset; + + sMath_RotateY(&vec, SHORT2RAD_ANGLE2(angle)); + + OPEN_DISP(game->graph); + + _texture_z_light_fog_prim_xlu(game->graph); + + Matrix_translate(effect->position.x, effect->position.y, effect->position.z, FALSE); + Matrix_translate(vec.x, vec.y, vec.z, TRUE); + Matrix_mult(&((GAME_PLAY*)game)->billboard_matrix, TRUE); + Matrix_scale(effect->scale.x, effect->scale.y, effect->scale.z, TRUE); + + 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, ef_namida01_modelT); + + CLOSE_DISP(game->graph); }