diff --git a/docs/progress.svg b/docs/progress.svg
index ace1440c..dcb81a07 100644
--- a/docs/progress.svg
+++ b/docs/progress.svg
@@ -69,10 +69,10 @@
Tomb2.exe progress according to the physical function order:
-24.50% (294) · 73% (876) · 0.67% (8) · 1.83% (22)
+24.58% (295) · 72.92% (875) · 0.67% (8) · 1.83% (22)
-
-
+
+
@@ -450,7 +450,7 @@
void __cdecl ShowStatsText(char *time_str, int32_t type);
void __cdecl ShowEndStatsText(void);
void __cdecl Item_InitialiseArray(int32_t num_items);
-void __cdecl Item_Kill(int16_t item_num);
+void __cdecl Item_Kill(int16_t item_num);
int16_t __cdecl Item_Create(void);
void __cdecl Item_Initialise(int16_t item_num);
void __cdecl Item_RemoveActive(int16_t item_num);
@@ -1281,10 +1281,10 @@
Tomb2.exe progress according to the function sizes:
-21.07% · 78.60% · 0.02% · 0.31%
+21.16% · 78.51% · 0.02% · 0.31%
-
-
+
+
@@ -1607,7 +1607,7 @@
void __cdecl Lara_Col_Hang(struct ITEM_INFO *item, struct COLL_INFO *coll);
void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade1, int32_t shade2, ROOM_INFO *room);
BOOL __cdecl Key(KEYMAP keyMap);
-void __cdecl Item_Kill(int16_t item_num);
+void __cdecl Item_Kill(int16_t item_num);
void __cdecl InitialiseNewWeapon(void);
void __cdecl Lara_Col_UpJump(struct ITEM_INFO *item, struct COLL_INFO *coll);
void __cdecl SkidooGuns(void);
diff --git a/docs/progress.txt b/docs/progress.txt
index 906b4f25..45e921e3 100644
--- a/docs/progress.txt
+++ b/docs/progress.txt
@@ -1590,7 +1590,7 @@ typedef enum LARA_MESH {
# game/items.c
00426CF0 00000052 + void __cdecl Item_InitialiseArray(int32_t num_items);
-00426D50 0000011E - void __cdecl Item_Kill(int16_t item_num);
+00426D50 0000011E + void __cdecl Item_Kill(int16_t item_num);
00426E70 00000039 - int16_t __cdecl Item_Create(void);
00426EB0 000001B3 - void __cdecl Item_Initialise(int16_t item_num);
00427070 0000008A - void __cdecl Item_RemoveActive(int16_t item_num);
diff --git a/src/game/camera.c b/src/game/camera.c
index e0b199d4..fc53f6e0 100644
--- a/src/game/camera.c
+++ b/src/game/camera.c
@@ -262,7 +262,7 @@ void __cdecl Camera_SmartShift(
if (good_left) {
camera_box = good_left->box;
edge = (int32_t)g_Boxes[camera_box].left << WALL_SHIFT;
- if (camera_box != NO_ITEM && edge < left) {
+ if (camera_box != NO_BOX && edge < left) {
left = edge;
}
} else {
@@ -275,7 +275,7 @@ void __cdecl Camera_SmartShift(
if (good_right) {
camera_box = good_right->box;
edge = ((int32_t)g_Boxes[camera_box].right << WALL_SHIFT) - 1;
- if (camera_box != NO_ITEM && edge > right) {
+ if (camera_box != NO_BOX && edge > right) {
right = edge;
}
} else {
@@ -288,7 +288,7 @@ void __cdecl Camera_SmartShift(
if (good_top) {
camera_box = good_top->box;
edge = (int32_t)g_Boxes[camera_box].top << WALL_SHIFT;
- if (camera_box != NO_ITEM && edge < top) {
+ if (camera_box != NO_BOX && edge < top) {
top = edge;
}
} else {
@@ -301,7 +301,7 @@ void __cdecl Camera_SmartShift(
if (good_bottom) {
camera_box = good_bottom->box;
edge = ((int32_t)g_Boxes[camera_box].bottom << WALL_SHIFT) - 1;
- if (camera_box != NO_ITEM && edge > bottom) {
+ if (camera_box != NO_BOX && edge > bottom) {
bottom = edge;
}
} else {
diff --git a/src/game/items.c b/src/game/items.c
index 50d16552..1120ae16 100644
--- a/src/game/items.c
+++ b/src/game/items.c
@@ -19,6 +19,51 @@ void __cdecl Item_InitialiseArray(const int32_t num_items)
g_Items[num_items - 1].next_item = NO_ITEM;
}
+void __cdecl Item_Kill(const int16_t item_num)
+{
+ struct ITEM_INFO *const item = &g_Items[item_num];
+ item->active = 0;
+
+ int16_t link_num = g_NextItemActive;
+ if (link_num == item_num) {
+ g_NextItemActive = item->next_active;
+ } else {
+ while (link_num != NO_ITEM) {
+ if (g_Items[link_num].next_active == item_num) {
+ g_Items[link_num].next_active = item->next_active;
+ break;
+ }
+ link_num = g_Items[link_num].next_active;
+ }
+ }
+
+ if (item->room_num != NO_ROOM) {
+ link_num = g_Rooms[item->room_num].item_num;
+ if (link_num == item_num) {
+ g_Rooms[item->room_num].item_num = item->next_item;
+ } else {
+ while (link_num != NO_ITEM) {
+ if (g_Items[link_num].next_item == item_num) {
+ g_Items[link_num].next_item = item->next_item;
+ break;
+ }
+ link_num = g_Items[link_num].next_item;
+ }
+ }
+ }
+
+ if (item == g_Lara.target) {
+ g_Lara.target = NULL;
+ }
+
+ if (item_num < g_LevelItemCount) {
+ item->flags |= IF_KILLED_ITEM;
+ } else {
+ item->next_item = g_NextItemFree;
+ g_NextItemFree = item_num;
+ }
+}
+
bool Item_IsSmashable(const struct ITEM_INFO *item)
{
return (item->object_num == O_WINDOW_1 || item->object_num == O_BELL);
diff --git a/src/game/items.h b/src/game/items.h
index 5632d24e..17350a3a 100644
--- a/src/game/items.h
+++ b/src/game/items.h
@@ -3,5 +3,6 @@
#include "global/types.h"
void __cdecl Item_InitialiseArray(int32_t num_items);
+void __cdecl Item_Kill(int16_t item_num);
bool Item_IsSmashable(const struct ITEM_INFO *item);
diff --git a/src/global/const.h b/src/global/const.h
index 060f2352..06eb8f85 100644
--- a/src/global/const.h
+++ b/src/global/const.h
@@ -23,6 +23,7 @@
#define MIN_SQUARE SQUARE(WALL_L / 3)
#define NO_BOX (-1)
#define NO_ITEM (-1)
+#define NO_ROOM (-1)
#define NO_CAMERA (-1)
#define GRAVITY 6
diff --git a/src/global/funcs.h b/src/global/funcs.h
index 716496f6..fdf27878 100644
--- a/src/global/funcs.h
+++ b/src/global/funcs.h
@@ -288,7 +288,6 @@
#define ShowGymStatsText ((void __cdecl (*)(char *time_str, int32_t type))0x00426340)
#define ShowStatsText ((void __cdecl (*)(char *time_str, int32_t type))0x00426520)
#define ShowEndStatsText ((void __cdecl (*)(void))0x004268C0)
-#define Item_Kill ((void __cdecl (*)(int16_t item_num))0x00426D50)
#define Item_Create ((int16_t __cdecl (*)(void))0x00426E70)
#define Item_Initialise ((void __cdecl (*)(int16_t item_num))0x00426EB0)
#define Item_RemoveActive ((void __cdecl (*)(int16_t item_num))0x00427070)
diff --git a/src/global/types.h b/src/global/types.h
index 42c6a957..f53be2b1 100644
--- a/src/global/types.h
+++ b/src/global/types.h
@@ -281,7 +281,6 @@ typedef struct TEXTSTRING {
uint32_t bottom : 1;
uint32_t background : 1;
uint32_t outline : 1;
- uint32_t multiline : 1;
};
} flags;
uint16_t text_flags;
@@ -995,6 +994,14 @@ typedef struct CINE_FRAME {
int16_t roll;
} CINE_FRAME;
+typedef enum ITEM_FLAG {
+ IF_ONESHOT = 0x0100,
+ IF_CODE_BITS = 0x3E00,
+ IF_REVERSE = 0x4000,
+ IF_NOT_VISIBLE = 0x0100,
+ IF_KILLED_ITEM = 0x8000,
+} ITEM_FLAG;
+
typedef enum ITEM_STATUS {
IS_NOT_ACTIVE = 0,
IS_ACTIVE = 1,
diff --git a/src/inject_exec.c b/src/inject_exec.c
index 41b0f141..5c14ba0c 100644
--- a/src/inject_exec.c
+++ b/src/inject_exec.c
@@ -189,6 +189,7 @@ static void Inject_Sound(void)
static void Inject_Items(void)
{
INJECT(1, 0x00426CF0, Item_InitialiseArray);
+ INJECT(1, 0x00426D50, Item_Kill);
}
static void Inject_LOS(void)