diff --git a/docs/progress.svg b/docs/progress.svg
index 171ad4e41..50b361af2 100644
--- a/docs/progress.svg
+++ b/docs/progress.svg
@@ -327,7 +327,7 @@
GlobalItemReplace
InitialiseFXArray
CreateEffect
-KillEffect
+KillEffect
EffectNewRoom
LaraAboveWater
LaraAsWalk
@@ -1041,7 +1041,7 @@
HitTarget
InitialiseStatue
MoveLaraPosition
-KillEffect
+KillEffect
LaraDeflectEdgeJump
StatueControl
T_Print
@@ -1463,10 +1463,10 @@
sub_440EF0
sub_437BC0
S_CDVolume
-Functions decompiled (count): 46.92%
-Functions decompiled (bytesize): 44.65%
-Functions not decompiled, but with known names (count): 38.99%
-Functions not decompiled, but with known names (bytesize): 39.52%
+Functions decompiled (count): 47.06%
+Functions decompiled (bytesize): 44.74%
+Functions not decompiled, but with known names (count): 38.85%
+Functions not decompiled, but with known names (bytesize): 39.43%
Functions not decompiled, with unknown names (count): 14.09%
Functions not decompiled, with unknown names (bytesize): 15.83%
diff --git a/docs/progress.txt b/docs/progress.txt
index 3c8466ab1..303e5c392 100644
--- a/docs/progress.txt
+++ b/docs/progress.txt
@@ -444,7 +444,7 @@ SpawnItem 0x00422110 0x000000B6 +
GlobalItemReplace 0x004221D0 0x00000080 +
InitialiseFXArray 0x00422250 0x00000030 +
CreateEffect 0x00422280 0x00000069 +
-KillEffect 0x004222F0 0x000000E4 *
+KillEffect 0x004222F0 0x000000E4 +
EffectNewRoom 0x004223E0 0x00000096 *
# lara.cpp
diff --git a/src/game/items.c b/src/game/items.c
index 82c914fa1..6d96fbc3a 100644
--- a/src/game/items.c
+++ b/src/game/items.c
@@ -265,6 +265,39 @@ int16_t CreateEffect(int16_t room_num)
return fx_num;
}
+void KillEffect(int16_t fx_num)
+{
+ FX_INFO* fx = &Effects[fx_num];
+
+ int16_t linknum = NextFxActive;
+ if (linknum == fx_num) {
+ NextFxActive = fx->next_active;
+ } else {
+ for (; linknum != NO_ITEM; linknum = Effects[linknum].next_active) {
+ if (Effects[linknum].next_active == fx_num) {
+ Effects[linknum].next_active = fx->next_active;
+ break;
+ }
+ }
+ }
+
+ ROOM_INFO* r = &RoomInfo[fx->room_number];
+ linknum = r->fx_number;
+ if (linknum == fx_num) {
+ r->fx_number = fx->next_fx;
+ } else {
+ for (; linknum != NO_ITEM; linknum = Effects[linknum].next_fx) {
+ if (Effects[linknum].next_fx == fx_num) {
+ Effects[linknum].next_fx = fx->next_fx;
+ break;
+ }
+ }
+ }
+
+ fx->next_fx = NextFxFree;
+ NextFxFree = fx_num;
+}
+
void T1MInjectGameItems()
{
INJECT(0x00421B10, InitialiseItemArray);
@@ -279,4 +312,5 @@ void T1MInjectGameItems()
INJECT(0x004221D0, GlobalItemReplace);
INJECT(0x00422250, InitialiseFXArray);
INJECT(0x00422280, CreateEffect);
+ INJECT(0x004222F0, KillEffect);
}
diff --git a/src/game/items.h b/src/game/items.h
index f31cfae51..66ec4cbfc 100644
--- a/src/game/items.h
+++ b/src/game/items.h
@@ -5,7 +5,6 @@
#include
// clang-format off
-#define KillEffect ((void (*)(int16_t fx_num))0x004222F0)
#define EffectNewRoom ((void (*)(int16_t fx_num, int16_t room_num))0x004223E0)
// clang-format on
@@ -21,6 +20,7 @@ int16_t SpawnItem(ITEM_INFO* item, int16_t object_num);
int32_t GlobalItemReplace(int32_t src_object_num, int32_t dst_object_num);
void InitialiseFXArray();
int16_t CreateEffect(int16_t room_num);
+void KillEffect(int16_t fx_num);
void T1MInjectGameItems();