summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2021-12-02 01:32:23 +0100
committerGitHub <noreply@github.com>2021-12-01 19:32:23 -0500
commitb3d5f549e70a2bfac36cb502b53d80860672544e (patch)
tree0986e58b575baa43b4e0648d385b67da2ed16b9f /src/code
parentff49ace524978236263cdc4f3f785f8fc5e20592 (diff)
Document `Actor_DrawDoorLock` (#1045)
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c78
1 files changed, 42 insertions, 36 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 4fcc8ded7..0318e51f0 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -4,6 +4,8 @@
#include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h"
#include "overlays/actors/ovl_En_Part/z_en_part.h"
#include "objects/gameplay_keep/gameplay_keep.h"
+#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
+#include "objects/object_bdoor/object_bdoor.h"
static CollisionPoly* sCurCeilingPoly;
static s32 sCurCeilingBgId;
@@ -3488,69 +3490,73 @@ f32 Rand_CenteredFloat(f32 f) {
}
typedef struct {
- /* 0x00 */ f32 unk_00;
- /* 0x04 */ f32 unk_04;
- /* 0x08 */ f32 unk_08;
- /* 0x0C */ f32 unk_0C;
- /* 0x10 */ f32 unk_10;
- /* 0x14 */ u32 unk_14;
- /* 0x18 */ u32 unk_18;
-} struct_801160DC; // size = 0x1C
-
-static struct_801160DC D_801160DC[] = {
- { 0.54f, 6000.0f, 5000.0f, 1.0f, 0.0f, 0x050011F0, 0x05001100 },
- { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, 0x06001530, 0x06001400 },
- { 0.64000005f, 8500.0f, 8000.0f, 1.75f, 0.1f, 0x050011F0, 0x05001100 },
+ /* 0x00 */ f32 chainAngle;
+ /* 0x04 */ f32 chainLength;
+ /* 0x08 */ f32 yShift;
+ /* 0x0C */ f32 chainsScale;
+ /* 0x10 */ f32 chainsRotZInit;
+ /* 0x14 */ Gfx* chainDL;
+ /* 0x18 */ Gfx* lockDL;
+} DoorLockInfo; // size = 0x1C
+
+static DoorLockInfo sDoorLocksInfo[] = {
+ /* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0f, 1.0f, 0.0f, gDoorChainsDL, gDoorLockDL },
+ /* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, object_bdoor_DL_001530, object_bdoor_DL_001400 },
+ /* DOORLOCK_NORMAL_SPIRIT */ { 0.64000005f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainsDL, gDoorLockDL },
};
+/**
+ * Draws chains and lock of a locked door, of the specified `type` (see `DoorLockType`).
+ * `frame` can be 0 to 10, where 0 is "open" and 10 is "closed", the chains slide accordingly.
+ */
void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) {
- struct_801160DC* entry;
+ DoorLockInfo* entry;
s32 i;
- MtxF spB0;
- f32 var;
- f32 temp1;
- f32 temp2;
- f32 temp3;
+ MtxF baseMtxF;
+ f32 chainRotZ;
+ f32 chainsTranslateX;
+ f32 chainsTranslateY;
+ f32 rotZStep;
- entry = &D_801160DC[type];
- var = entry->unk_10;
+ entry = &sDoorLocksInfo[type];
+ chainRotZ = entry->chainsRotZInit;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8265);
- Matrix_Translate(0.0f, entry->unk_08, 500.0f, MTXMODE_APPLY);
- Matrix_Get(&spB0);
+ Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY);
+ Matrix_Get(&baseMtxF);
- temp1 = sinf(entry->unk_00 - var) * -(10 - frame) * 0.1f * entry->unk_04;
- temp2 = cosf(entry->unk_00 - var) * (10 - frame) * 0.1f * entry->unk_04;
+ chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength;
+ chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength;
for (i = 0; i < 4; i++) {
- Matrix_Put(&spB0);
- Matrix_RotateZ(var, MTXMODE_APPLY);
- Matrix_Translate(temp1, temp2, 0.0f, MTXMODE_APPLY);
+ Matrix_Put(&baseMtxF);
+ Matrix_RotateZ(chainRotZ, MTXMODE_APPLY);
+ Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY);
- if (entry->unk_0C != 1.0f) {
- Matrix_Scale(entry->unk_0C, entry->unk_0C, entry->unk_0C, MTXMODE_APPLY);
+ if (entry->chainsScale != 1.0f) {
+ Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY);
}
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_actor.c", 8299),
G_MTX_MODELVIEW | G_MTX_LOAD);
- gSPDisplayList(POLY_OPA_DISP++, entry->unk_14);
+ gSPDisplayList(POLY_OPA_DISP++, entry->chainDL);
if (i % 2) {
- temp3 = entry->unk_00 + entry->unk_00;
+ rotZStep = 2.0f * entry->chainAngle;
} else {
- temp3 = M_PI - (entry->unk_00 + entry->unk_00);
+ rotZStep = M_PI - (2.0f * entry->chainAngle);
}
- var += temp3;
+ chainRotZ += rotZStep;
}
- Matrix_Put(&spB0);
+ Matrix_Put(&baseMtxF);
Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_actor.c", 8314),
G_MTX_MODELVIEW | G_MTX_LOAD);
- gSPDisplayList(POLY_OPA_DISP++, entry->unk_18);
+ gSPDisplayList(POLY_OPA_DISP++, entry->lockDL);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8319);
}