diff --git a/docs/progress.svg b/docs/progress.svg
index b8b5a46ac..d73d12923 100644
--- a/docs/progress.svg
+++ b/docs/progress.svg
@@ -497,7 +497,7 @@
NatlaControl
ControlNatlaGun
InitialiseDoor
-DoorControl
+DoorControl
OnDrawBridge
DrawBridgeFloor
DrawBridgeCeiling
@@ -859,7 +859,7 @@
WinPlayFMV
AnimateLara
ins_objectG3
-DoorControl
+DoorControl
TestBlockPull
GetHeight
LaraHangTest
@@ -1463,10 +1463,10 @@
sub_440EF0
sub_437BC0
S_CDVolume
-Functions decompiled (count): 53.90%
-Functions decompiled (bytesize): 50.57%
-Functions not decompiled, but with known names (count): 32.01%
-Functions not decompiled, but with known names (bytesize): 33.60%
+Functions decompiled (count): 54.04%
+Functions decompiled (bytesize): 50.80%
+Functions not decompiled, but with known names (count): 31.87%
+Functions not decompiled, but with known names (bytesize): 33.37%
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 ea6cebcf6..0d952f48b 100644
--- a/docs/progress.txt
+++ b/docs/progress.txt
@@ -700,9 +700,9 @@ NatlaGun ---------- ---------- x
# objects.cpp
ShutThatDoor ---------- ---------- +
-OpenThatDoor ---------- ---------- -
+OpenThatDoor ---------- ---------- +
InitialiseDoor 0x0042CA40 0x000004AE +
-DoorControl 0x0042CEF0 0x0000023B *
+DoorControl 0x0042CEF0 0x0000023B +
OnDrawBridge 0x0042D130 0x000000B1 -
DrawBridgeFloor 0x0042D1F0 0x0000003B *
DrawBridgeCeiling 0x0042D230 0x0000003F *
diff --git a/src/game/objects.c b/src/game/objects.c
index 1c59385c1..cc53341fa 100644
--- a/src/game/objects.c
+++ b/src/game/objects.c
@@ -24,6 +24,21 @@ void ShutThatDoor(DOORPOS_DATA* d)
}
}
+void OpenThatDoor(DOORPOS_DATA* d)
+{
+ FLOOR_INFO* floor = d->floor;
+ if (!floor) {
+ return;
+ }
+
+ *floor = d->data;
+
+ int16_t box_num = d->block;
+ if (box_num != NO_BOX) {
+ Boxes[box_num].overlap_index &= ~BLOCKED;
+ }
+}
+
void InitialiseDoor(int16_t item_num)
{
ITEM_INFO* item = &Items[item_num];
@@ -147,7 +162,36 @@ void InitialiseDoor(int16_t item_num)
ShutThatDoor(&door->d2flip);
}
+void DoorControl(int16_t item_num)
+{
+ ITEM_INFO* item = &Items[item_num];
+ DOOR_DATA* door = item->data;
+
+ if (TriggerActive(item)) {
+ if (item->current_anim_state == DOOR_CLOSED) {
+ item->goal_anim_state = DOOR_OPEN;
+ } else {
+ OpenThatDoor(&door->d1);
+ OpenThatDoor(&door->d2);
+ OpenThatDoor(&door->d1flip);
+ OpenThatDoor(&door->d2flip);
+ }
+ } else {
+ if (item->current_anim_state == DOOR_OPEN) {
+ item->goal_anim_state = DOOR_CLOSED;
+ } else {
+ ShutThatDoor(&door->d1);
+ ShutThatDoor(&door->d2);
+ ShutThatDoor(&door->d1flip);
+ ShutThatDoor(&door->d2flip);
+ }
+ }
+
+ AnimateItem(item);
+}
+
void T1MInjectGameObjects()
{
INJECT(0x0042CA40, InitialiseDoor);
+ INJECT(0x0042CEF0, DoorControl);
}
diff --git a/src/game/objects.h b/src/game/objects.h
index b9860bc2d..a4c44808f 100644
--- a/src/game/objects.h
+++ b/src/game/objects.h
@@ -5,7 +5,6 @@
#include
// clang-format off
-#define DoorControl ((void (*)(int16_t item_num))0x0042CEF0)
#define DrawBridgeFloor ((void (*)(ITEM_INFO *item, int32_t x, int32_t y, int32_t z, int16_t *height))0x0042D1F0)
#define DrawBridgeCeiling ((void (*)(ITEM_INFO *item, int32_t x, int32_t y, int32_t z, int16_t *height))0x0042D230)
#define DrawBridgeCollision ((void (*)(int16_t item_num, ITEM_INFO* litem, COLL_INFO* coll))0x0042D270)
@@ -41,7 +40,9 @@
// clang-format on
void ShutThatDoor(DOORPOS_DATA* d);
+void OpenThatDoor(DOORPOS_DATA* d);
void InitialiseDoor(int16_t item_num);
+void DoorControl(int16_t item_num);
void T1MInjectGameObjects();
diff --git a/src/game/types.h b/src/game/types.h
index fb7ecc073..e202aa78c 100644
--- a/src/game/types.h
+++ b/src/game/types.h
@@ -763,6 +763,11 @@ typedef enum {
IT_NUMBER_OF = 2,
} INV_TEXT;
+typedef enum {
+ DOOR_CLOSED = 0,
+ DOOR_OPEN = 1,
+} DOOR_ANIMS;
+
#pragma pack(push, 1)
typedef struct {