From ed41b6180f9894d71a935e7bd189b093f40d417a Mon Sep 17 00:00:00 2001 From: Norgesnerd <5824576+Norgesnerd@users.noreply.github.com> Date: Sun, 15 Jun 2025 16:58:39 +0200 Subject: [PATCH] Implement & link ef_shock --- configure.py | 2 +- src/effect/ef_shock.c | 92 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 7 deletions(-) diff --git a/configure.py b/configure.py index c86f6fc3..7c379b74 100644 --- a/configure.py +++ b/configure.py @@ -1316,7 +1316,7 @@ config.libs = [ Object(Matching, "effect/ef_room_sunshine_police.c"), Object(Matching, "effect/ef_room_sunshine_posthouse.c"), Object(Matching, "effect/ef_sandsplash.c"), - Object(NonMatching, "effect/ef_shock.c"), + Object(Matching, "effect/ef_shock.c"), Object(Matching, "effect/ef_shooting.c"), Object(Matching, "effect/ef_shooting_kira.c"), Object(Matching, "effect/ef_shooting_set.c"), diff --git a/src/effect/ef_shock.c b/src/effect/ef_shock.c index 60196607..6feaac8d 100644 --- a/src/effect/ef_shock.c +++ b/src/effect/ef_shock.c @@ -1,12 +1,16 @@ #include "ef_effect_control.h" +#include "m_common_data.h" + +extern Gfx ef_shock01_00_modelT[]; + static void eSK_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1); static void eSK_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg); static void eSK_mv(eEC_Effect_c* effect, GAME* game); static void eSK_dw(eEC_Effect_c* effect, GAME* game); +// clang-format off eEC_PROFILE_c iam_ef_shock = { - // clang-format off &eSK_init, &eSK_ct, &eSK_mv, @@ -14,21 +18,97 @@ eEC_PROFILE_c iam_ef_shock = { eEC_IGNORE_DEATH, eEC_NO_CHILD_ID, eEC_DEFAULT_DEATH_DIST, - // clang-format on }; +static rgba_t eSK_prim_table[] = { + { 255, 0, 0, 200 }, + { 255, 128, 0, 227 }, + { 255, 255, 0, 255 }, + { 255, 191, 0, 191 }, + { 255, 128, 0, 128 }, + { 255, 63, 0, 63 }, + { 255, 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 }, +}; + +static f32 eSK_scale_table[] = { + 0.019f, 0.02375f, 0.028499999f, 0.026124999f, 0.02375f, 0.021374999f, 0.019f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, +}; +// clang-format on + +typedef struct { + xyz_t velocity; + xyz_t acceleration; + f32 scale; +} eSK_dt_c; + static void eSK_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { - // TODO + xyz_t ofs; + eSK_dt_c data; + + data.velocity.x = 0.0f; + data.velocity.y = 1.0f; + data.velocity.z = 0.0f; + + data.acceleration.x = 0.0f; + data.acceleration.y = -0.1f; + data.acceleration.z = 0.0f; + + data.scale = 1.0f; + + ofs.x = 0.0f; + ofs.y = 4.0f; + ofs.z = 6.0f; + + eEC_CLIP->make_effect_proc(eEC_EFFECT_SHOCK, pos, &ofs, game, &data, item_name, prio, 0, 0); } static void eSK_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { - // TODO + eSK_dt_c* data = (eSK_dt_c*)ct_arg; + + effect->scale.x = data->scale; + effect->scale.y = data->scale; + effect->scale.z = data->scale; + + effect->timer = 14; + + effect->acceleration = data->acceleration; + + effect->velocity = data->velocity; } static void eSK_mv(eEC_Effect_c* effect, GAME* game) { - // TODO + s16 timer = 14 - effect->timer; + if (timer == 0) { + sAdo_OngenTrgStart(0x2d, &effect->position); + } } static void eSK_dw(eEC_Effect_c* effect, GAME* game) { - // TODO + xyz_t* pos = &effect->position; + xyz_t* scale = &effect->scale; + xyz_t* ofs = &effect->offset; + s16 idx = (14 - effect->timer) >> 1; + idx = CLAMP(idx, 0, 6); + + scale->x = eSK_scale_table[idx]; + scale->y = eSK_scale_table[idx]; + scale->z = eSK_scale_table[idx]; + + OPEN_DISP(game->graph); + + eEC_CLIP->auto_matrix_xlu_offset_proc(game, pos, scale, ofs); + + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, 128, eSK_prim_table[idx].r, eSK_prim_table[idx].g, eSK_prim_table[idx].b, + eSK_prim_table[idx].a); + gSPDisplayList(NEXT_POLY_XLU_DISP, ef_shock01_00_modelT); + + CLOSE_DISP(game->graph); }