From bd1a7963fc12d089aceafb64c3486d24b3f7abed Mon Sep 17 00:00:00 2001 From: rr- Date: Thu, 25 Feb 2021 18:24:07 +0100 Subject: [PATCH] port GetDoor --- docs/progress.svg | 12 ++++++------ docs/progress.txt | 2 +- src/game/control.c | 27 +++++++++++++++++++++++++++ src/game/control.h | 1 + 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/docs/progress.svg b/docs/progress.svg index e0f5d7955..ef8af569b 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -162,7 +162,7 @@ - + @@ -1232,7 +1232,7 @@ - + @@ -1459,10 +1459,10 @@ -Functions decompiled (count): 32.10% -Functions decompiled (bytesize): 31.55% -Functions not decompiled, but with known names (count): 53.91% -Functions not decompiled, but with known names (bytesize): 52.48% +Functions decompiled (count): 32.24% +Functions decompiled (bytesize): 31.58% +Functions not decompiled, but with known names (count): 53.77% +Functions not decompiled, but with known names (bytesize): 52.45% Functions not decompiled, with unknown names (count): 13.99% Functions not decompiled, with unknown names (bytesize): 15.97% diff --git a/docs/progress.txt b/docs/progress.txt index fa5714bd4..25f3fa37a 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -202,7 +202,7 @@ RefreshCamera 0x00413FA0 0x000000D4 - TestTriggers 0x00414080 0x0000074E * TriggerActive 0x00414820 0x00000055 - GetCeiling 0x00414880 0x0000024B * -GetDoor 0x00414AE0 0x0000004E - +GetDoor 0x00414AE0 0x0000004E + LOS 0x00414B30 0x000000A0 * zLOS 0x00414BD0 0x00000272 - xLOS 0x00414E50 0x00000270 - diff --git a/src/game/control.c b/src/game/control.c index a42cb2bd0..7076d85e9 100644 --- a/src/game/control.c +++ b/src/game/control.c @@ -291,10 +291,37 @@ void TranslateItem(ITEM_INFO* item, int32_t x, int32_t y, int32_t z) item->pos.z += (c * z - s * x) >> W2V_SHIFT; } +int16_t GetDoor(FLOOR_INFO* floor) +{ + if (!floor->index) { + return NO_ROOM; + } + + int16_t* data = &FloorData[floor->index]; + int16_t type = *data++; + + if (type == FT_TILT) { + data++; + type = *data++; + } + + if (type == FT_ROOF) { + data++; + type = *data++; + } + + if ((type & DATA_TYPE) == FT_DOOR) { + return *data; + } + + return NO_ROOM; +} + void T1MInjectGameControl() { INJECT(0x004133B0, ControlPhase); INJECT(0x00413660, AnimateItem); INJECT(0x00413960, GetChange); INJECT(0x00413A10, TranslateItem); + INJECT(0x00414AE0, GetDoor); } diff --git a/src/game/control.h b/src/game/control.h index 7db3620b9..0dce634bd 100644 --- a/src/game/control.h +++ b/src/game/control.h @@ -18,6 +18,7 @@ int32_t ControlPhase(int32_t nframes, int demo_mode); void AnimateItem(ITEM_INFO* item); int32_t GetChange(ITEM_INFO* item, ANIM_STRUCT* anim); void TranslateItem(ITEM_INFO* item, int32_t x, int32_t y, int32_t z); +int16_t GetDoor(FLOOR_INFO* floor); void T1MInjectGameControl();