From 86f6f20b976cb2d2b31730b5addd26f7824631e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo?= Date: Sat, 20 Dec 2025 14:43:29 -0300 Subject: [PATCH] Skip interpolation when particles are freed. (#12) * Skip interpolation when particles are freed. * Update particle_transform_tagging.c --- patches/particle_transform_tagging.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/patches/particle_transform_tagging.c b/patches/particle_transform_tagging.c index 0fd3496..73f3be1 100644 --- a/patches/particle_transform_tagging.c +++ b/patches/particle_transform_tagging.c @@ -235,8 +235,23 @@ void func_803382FC(s32); void func_80338308(s32 arg0, s32 arg1); void func_8033837C(s32 arg0); void spriteRender_draw(Gfx **gfx, Vtx **vtx, BKSprite *sp, u32 frame); +void assetCache_free(void *arg0); extern Struct_B8860_0s D_80385000[0x32]; +u8 projectileSkipInterpolation[0x32]; + +// @recomp Patched to indicate the projectile should skip interpolation the next time it's used. +RECOMP_PATCH void projectile_freeByIndex(u8 indx) { + if (D_80385000[indx].sprite_0) { + assetCache_free(D_80385000[indx].sprite_0); + } + + D_80385000[indx].sprite_0 = NULL; + D_80385000[indx].unk28_13 = 0; + + // @recomp Mark the projectile to skip interpolation the next time it's drawn. + projectileSkipInterpolation[indx] = TRUE; +} // @recomp Patched to tag projectiles. RECOMP_PATCH void func_8033F7F0(u8 indx, Gfx **gfx, Mtx **mtx, Vtx **vtx){ @@ -268,8 +283,15 @@ RECOMP_PATCH void func_8033F7F0(u8 indx, Gfx **gfx, Mtx **mtx, Vtx **vtx){ func_8033837C(1); func_80338370(); - // @recomp Set a matrix group before drawing the sprite. - gEXMatrixGroupSimpleNormal((*gfx)++, PROJECTILE_TRANSFORM_ID_START + indx, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); + // @recomp Set a matrix group before drawing the sprite. Skip interpolation if it was just freed. + u32 projectileID = PROJECTILE_TRANSFORM_ID_START + indx; + if (projectileSkipInterpolation[indx]) { + gEXMatrixGroupSkipAll((*gfx)++, projectileID, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); + projectileSkipInterpolation[indx] = FALSE; + } + else { + gEXMatrixGroupSimpleNormal((*gfx)++, projectileID, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); + } spriteRender_draw(gfx, vtx, sp54->sprite_0, sp54->frame_28_31); gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW);