From e126e3708411981b49db13f7d6d9002dc1dfde62 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Mon, 27 Apr 2020 03:12:27 +0200 Subject: [PATCH] func_800418D0 and func_800417A0 in z_bgcheck.c, matching (#79) * func_800418D0 and func_800417A0 in z_bgcheck.c, matching * func_800417A0 cleanup * More func_800418D0 cleanup Co-authored-by: fig02 --- include/z64.h | 4 ++-- include/z64actor.h | 20 +++++++++++--------- src/code/z_bgcheck.c | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/include/z64.h b/include/z64.h index 616ea24e87..fd6361f84f 100644 --- a/include/z64.h +++ b/include/z64.h @@ -481,8 +481,8 @@ typedef struct { } StaticCollisionContext; // size = 0x50 typedef struct { - /* 0x0000 */ char unk_00[0x04]; - /* 0x0004 */ ActorMesh actorMeshArr[50]; + /* 0x0000 */ ActorMesh actorMeshArr[50]; + /* 0x1388 */ char unk_1388[0x04]; /* 0x138C */ u16 flags[50]; /* 0x13F0 */ char unk_13F0[0x24]; } DynaCollisionContext; // size = 0x1414 diff --git a/include/z64actor.h b/include/z64actor.h index 770ca1581d..5b5c77f56c 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -174,15 +174,17 @@ typedef struct Actor { } Actor; // size = 0x14C typedef struct { - /* 0x00 */ Actor* actor; - /* 0x04 */ char unk_04[0x10]; - /* 0x14 */ Vec3f scale1; - /* 0x20 */ Vec3s rot1; - /* 0x28 */ Vec3f pos1; - /* 0x34 */ Vec3f scale2; - /* 0x40 */ Vec3s rot2; - /* 0x48 */ Vec3f pos2; - /* 0x54 */ char unk_54[0x10]; + /* 0x00 */ char unk_00[0x04]; + /* 0x04 */ Actor* actor; + /* 0x08 */ void* unk_08; // Struct800417A0* + /* 0x0C */ char unk_0C[0x0C]; + /* 0x18 */ Vec3f scale1; + /* 0x24 */ Vec3s rot1; + /* 0x2C */ Vec3f pos1; + /* 0x38 */ Vec3f scale2; + /* 0x44 */ Vec3s rot2; + /* 0x4C */ Vec3f pos2; + /* 0x58 */ char unk_58[0x0C]; } ActorMesh; // size = 0x64 typedef struct { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 12c66c975c..f0532b86b5 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -298,11 +298,44 @@ void func_8003E954(u32 uParm1, u8* puParm2) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_80041648.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800417A0.s") +typedef struct { + /* 0x00 */ char unk_00[0x10]; + /* 0x10 */ void* unk_10; + /* 0x14 */ char unk_[0x04]; + /* 0x18 */ void* unk_18; + /* 0x1C */ void* unk_1C; + /* 0x20 */ void* unk_20; + /* 0x24 */ char unk_24[4]; + /* 0x28 */ void* unk_28; +} Struct800417A0; // size = 0x32 + +// called by func_800418D0 with actorMesh->unk_08 +void func_800417A0(Struct800417A0* arg0) { + arg0->unk_10 = SEGMENTED_TO_VIRTUAL(arg0->unk_10); + arg0->unk_18 = SEGMENTED_TO_VIRTUAL(arg0->unk_18); + arg0->unk_1C = SEGMENTED_TO_VIRTUAL(arg0->unk_1C); + arg0->unk_20 = SEGMENTED_TO_VIRTUAL(arg0->unk_20); + arg0->unk_28 = SEGMENTED_TO_VIRTUAL(arg0->unk_28); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_80041880.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800418D0.s") +void func_800418D0(CollisionContext* colCtx, GlobalContext* globalCtx) { + ActorMesh* actorMesh; + DynaCollisionContext* dynaColCtx; + s32 i; + u16 flag; + + dynaColCtx = &colCtx->dyna; + for (i = 0; i < 50; i++) { + flag = dynaColCtx->flags[i]; + if ((flag & 1) && !(flag & 2)) { + actorMesh = &dynaColCtx->actorMeshArr[i]; + Actor_SetObjectDependency(globalCtx, actorMesh->actor); + func_800417A0(actorMesh->unk_08); + } + } +} #ifdef NON_MATCHING void func_80041978(int iParm1, int iParm2) {