From 3fbdccbdbac4113ae04d77216b2a28b405e07734 Mon Sep 17 00:00:00 2001 From: fig02 Date: Tue, 27 Apr 2021 21:32:15 -0400 Subject: [PATCH] Document BodyBreak (en_part, body part spawner) (#797) * done * status defines * whoops * comment wording * size calc change * elseif --- .../actors/ovl_En_Skb/EnSkb_PostLimbDraw.s | 4 +- .../actors/ovl_En_Test/func_80862DBC.s | 2 +- .../actors/ovl_En_Test/func_80862E6C.s | 2 +- .../actors/ovl_En_Test/func_80863044.s | 2 +- .../actors/ovl_En_Test/func_8086318C.s | 2 +- .../actors/ovl_En_Test/func_808633E8.s | 2 +- .../actors/ovl_En_Test/func_80863CC4.s | 2 +- include/functions.h | 7 +- include/z64actor.h | 19 +-- src/code/z_actor.c | 113 ++++++++++-------- .../ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c | 2 +- .../actors/ovl_Efc_Erupc/z_efc_erupc.c | 2 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 15 ++- src/overlays/actors/ovl_En_Bb/z_en_bb.h | 2 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 8 +- src/overlays/actors/ovl_En_Ik/z_en_ik.h | 2 +- src/overlays/actors/ovl_En_Sb/z_en_sb.c | 6 +- src/overlays/actors/ovl_En_Sb/z_en_sb.h | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 25 ++-- src/overlays/actors/ovl_En_Skb/z_en_skb.h | 2 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 21 ++-- src/overlays/actors/ovl_En_Tite/z_en_tite.h | 2 +- 22 files changed, 128 insertions(+), 116 deletions(-) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Skb/EnSkb_PostLimbDraw.s b/asm/non_matchings/overlays/actors/ovl_En_Skb/EnSkb_PostLimbDraw.s index 785ce21e34..310b3c1832 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Skb/EnSkb_PostLimbDraw.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Skb/EnSkb_PostLimbDraw.s @@ -23,7 +23,7 @@ glabel EnSkb_PostLimbDraw /* 015D8 80AFDF78 AFB80018 */ sw $t8, 0x0018($sp) /* 015DC 80AFDF7C AFAF0010 */ sw $t7, 0x0010($sp) /* 015E0 80AFDF80 2407000C */ addiu $a3, $zero, 0x000C ## $a3 = 0000000C -/* 015E4 80AFDF84 0C00CBD5 */ jal func_80032F54 +/* 015E4 80AFDF84 0C00CBD5 */ jal BodyBreak_SetInfo /* 015E8 80AFDF88 AFA80014 */ sw $t0, 0x0014($sp) /* 015EC 80AFDF8C 1000000C */ beq $zero, $zero, .L80AFDFC0 /* 015F0 80AFDF90 8FBF0024 */ lw $ra, 0x0024($sp) @@ -36,7 +36,7 @@ glabel EnSkb_PostLimbDraw /* 01608 80AFDFA8 AFAA0010 */ sw $t2, 0x0010($sp) /* 0160C 80AFDFAC 00003025 */ or $a2, $zero, $zero ## $a2 = 00000000 /* 01610 80AFDFB0 24070012 */ addiu $a3, $zero, 0x0012 ## $a3 = 00000012 -/* 01614 80AFDFB4 0C00CBD5 */ jal func_80032F54 +/* 01614 80AFDFB4 0C00CBD5 */ jal BodyBreak_SetInfo /* 01618 80AFDFB8 AFA80014 */ sw $t0, 0x0014($sp) .L80AFDFBC: /* 0161C 80AFDFBC 8FBF0024 */ lw $ra, 0x0024($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862DBC.s b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862DBC.s index 00c9c70ad9..10df254fa4 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862DBC.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862DBC.s @@ -11,7 +11,7 @@ glabel func_80862DBC /* 0378C 80862DDC A20E07C8 */ sb $t6, 0x07C8($s0) ## 000007C8 /* 03790 80862DE0 8FA60024 */ lw $a2, 0x0024($sp) /* 03794 80862DE4 260407F0 */ addiu $a0, $s0, 0x07F0 ## $a0 = 000007F0 -/* 03798 80862DE8 0C00CB89 */ jal func_80032E24 +/* 03798 80862DE8 0C00CB89 */ jal BodyBreak_Alloc /* 0379C 80862DEC 2405003C */ addiu $a1, $zero, 0x003C ## $a1 = 0000003C /* 037A0 80862DF0 820F0808 */ lb $t7, 0x0808($s0) ## 00000808 /* 037A4 80862DF4 A6000014 */ sh $zero, 0x0014($s0) ## 00000014 diff --git a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862E6C.s b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862E6C.s index 43983c069a..aaf9815634 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862E6C.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80862E6C.s @@ -19,7 +19,7 @@ glabel func_80862E6C /* 0385C 80862EAC 8FA6002C */ lw $a2, 0x002C($sp) /* 03860 80862EB0 24E70008 */ addiu $a3, $a3, 0x0008 ## $a3 = 00000008 /* 03864 80862EB4 00073C00 */ sll $a3, $a3, 16 -/* 03868 80862EB8 0C00CC17 */ jal func_8003305C +/* 03868 80862EB8 0C00CC17 */ jal BodyBreak_SpawnParts /* 0386C 80862EBC 00073C03 */ sra $a3, $a3, 16 /* 03870 80862EC0 50400035 */ beql $v0, $zero, .L80862F98 /* 03874 80862EC4 8FBF0024 */ lw $ra, 0x0024($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863044.s b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863044.s index 4d6ecfff50..aedfd644c0 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863044.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863044.s @@ -27,7 +27,7 @@ glabel func_80863044 /* 03A50 808630A0 AE0F07E8 */ sw $t7, 0x07E8($s0) ## 000007E8 /* 03A54 808630A4 260407F0 */ addiu $a0, $s0, 0x07F0 ## $a0 = 000007F0 /* 03A58 808630A8 2405003C */ addiu $a1, $zero, 0x003C ## $a1 = 0000003C -/* 03A5C 808630AC 0C00CB89 */ jal func_80032E24 +/* 03A5C 808630AC 0C00CB89 */ jal BodyBreak_Alloc /* 03A60 808630B0 8FA60024 */ lw $a2, 0x0024($sp) /* 03A64 808630B4 C60A01A0 */ lwc1 $f10, 0x01A0($s0) ## 000001A0 .L808630B8: diff --git a/asm/non_matchings/overlays/actors/ovl_En_Test/func_8086318C.s b/asm/non_matchings/overlays/actors/ovl_En_Test/func_8086318C.s index 06645ab07a..d83af35dda 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Test/func_8086318C.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Test/func_8086318C.s @@ -27,7 +27,7 @@ glabel func_8086318C /* 03B98 808631E8 AE0F07E8 */ sw $t7, 0x07E8($s0) ## 000007E8 /* 03B9C 808631EC 260407F0 */ addiu $a0, $s0, 0x07F0 ## $a0 = 000007F0 /* 03BA0 808631F0 2405003C */ addiu $a1, $zero, 0x003C ## $a1 = 0000003C -/* 03BA4 808631F4 0C00CB89 */ jal func_80032E24 +/* 03BA4 808631F4 0C00CB89 */ jal BodyBreak_Alloc /* 03BA8 808631F8 8FA60024 */ lw $a2, 0x0024($sp) /* 03BAC 808631FC C60A01A0 */ lwc1 $f10, 0x01A0($s0) ## 000001A0 .L80863200: diff --git a/asm/non_matchings/overlays/actors/ovl_En_Test/func_808633E8.s b/asm/non_matchings/overlays/actors/ovl_En_Test/func_808633E8.s index 4c588c2fea..ca31a4e6f9 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Test/func_808633E8.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Test/func_808633E8.s @@ -8,7 +8,7 @@ glabel func_808633E8 /* 03DB0 80863400 A48E001C */ sh $t6, 0x001C($a0) ## 0000001C /* 03DB4 80863404 8607001C */ lh $a3, 0x001C($s0) ## 0000001C /* 03DB8 80863408 8FA60024 */ lw $a2, 0x0024($sp) -/* 03DBC 8086340C 0C00CC17 */ jal func_8003305C +/* 03DBC 8086340C 0C00CC17 */ jal BodyBreak_SpawnParts /* 03DC0 80863410 260507F0 */ addiu $a1, $s0, 0x07F0 ## $a1 = 000007F0 /* 03DC4 80863414 1040000D */ beq $v0, $zero, .L8086344C /* 03DC8 80863418 8FA40024 */ lw $a0, 0x0024($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863CC4.s b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863CC4.s index f9fff1d2f7..6b6da64444 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863CC4.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Test/func_80863CC4.s @@ -71,7 +71,7 @@ glabel func_80863CC4 /* 046B0 80863D00 2407003C */ addiu $a3, $zero, 0x003C ## $a3 = 0000003C /* 046B4 80863D04 00003025 */ or $a2, $zero, $zero ## $a2 = 00000000 /* 046B8 80863D08 260407F0 */ addiu $a0, $s0, 0x07F0 ## $a0 = 000007F0 -/* 046BC 80863D0C 0C00CBD5 */ jal func_80032F54 +/* 046BC 80863D0C 0C00CBD5 */ jal BodyBreak_SetInfo /* 046C0 80863D10 AFB80014 */ sw $t8, 0x0014($sp) /* 046C4 80863D14 8FA80084 */ lw $t0, 0x0084($sp) /* 046C8 80863D18 24010022 */ addiu $at, $zero, 0x0022 ## $at = 00000022 diff --git a/include/functions.h b/include/functions.h index a87be395ce..c6d32fe3fe 100644 --- a/include/functions.h +++ b/include/functions.h @@ -476,9 +476,10 @@ Actor* func_80032AF0(GlobalContext* globalCtx, ActorContext* actorCtx, Actor** a Actor* Actor_Find(ActorContext* actorCtx, s32 actorId, s32 actorCategory); void func_80032C7C(GlobalContext* globalCtx, Actor* actor); s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3); -void func_80032E24(struct_80032E24* arg0, s32 arg1, GlobalContext* globalCtx); -void func_80032F54(struct_80032E24* arg0, s32 arg1, s32 arg2, s32 arg3, u32 arg4, Gfx** dList, s16 arg6); -s32 func_8003305C(Actor* actor, struct_80032E24* arg1, GlobalContext* globalCtx, s16 params); +void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, GlobalContext* globalCtx); +void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, + Gfx** dList, s16 objectId); +s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, GlobalContext* globalCtx, s16 type); void func_80033260(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3, s32 arg4, f32 arg5, s16 arg6, s16 arg7, u8 arg8); void func_80033480(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, s32 arg3, s16 arg4, s16 arg5, u8 arg6); diff --git a/include/z64actor.h b/include/z64actor.h index a7ccc114eb..b04dd9eeb0 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -201,14 +201,17 @@ typedef struct DynaPolyActor { } DynaPolyActor; // size = 0x164 typedef struct { - /* 0x00 */ MtxF* unk_00; - /* 0x04 */ s16* unk_04; - /* 0x08 */ s16 unk_08; - /* 0x0A */ char unk_0A[0x02]; - /* 0x0C */ Gfx** unk_0C; - /* 0x10 */ s32 unk_10; - /* 0x14 */ s32 unk_14; -} struct_80032E24; + /* 0x00 */ MtxF* matrices; + /* 0x04 */ s16* objectIds; + /* 0x08 */ s16 count; + /* 0x0C */ Gfx** dLists; + /* 0x10 */ s32 val; // used for various purposes: both a status indicator and counter + /* 0x14 */ s32 prevLimbIndex; +} BodyBreak; + +#define BODYBREAK_OBJECT_DEFAULT -1 // use the same object as the actor +#define BODYBREAK_STATUS_READY -1 +#define BODYBREAK_STATUS_FINISHED 0 typedef enum { /* 0x00 */ ITEM00_RUPEE_GREEN, diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 9a0e62319f..aec121001d 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3037,104 +3037,111 @@ s16 func_80032D60(s16* arg0, s16 arg1, s16 arg2, s16 arg3) { return arg0[0]; } -void func_80032E24(struct_80032E24* arg0, s32 arg1, GlobalContext* globalCtx) { - u32 sp28; - u32 sp24; - u32 sp20; +void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, GlobalContext* globalCtx) { + u32 matricesSize; + u32 dListsSize; + u32 objectIdsSize; - sp28 = (arg1 * sizeof(*arg0->unk_00)) + sizeof(*arg0->unk_00); - arg0->unk_00 = ZeldaArena_MallocDebug(sp28, "../z_actor.c", 7540); - if (arg0->unk_00 != NULL) { - sp24 = (arg1 * sizeof(*arg0->unk_0C)) + sizeof(*arg0->unk_0C); - arg0->unk_0C = ZeldaArena_MallocDebug(sp24, "../z_actor.c", 7543); - if (arg0->unk_0C != NULL) { - sp20 = (arg1 * sizeof(*arg0->unk_04)) + sizeof(*arg0->unk_04); - arg0->unk_04 = ZeldaArena_MallocDebug(sp20, "../z_actor.c", 7546); - if (arg0->unk_04 != NULL) { - Lib_MemSet((u8*)arg0->unk_00, sp28, 0); - Lib_MemSet((u8*)arg0->unk_0C, sp24, 0); - Lib_MemSet((u8*)arg0->unk_04, sp20, 0); - arg0->unk_10 = 1; + matricesSize = (count + 1) * sizeof(*bodyBreak->matrices); + bodyBreak->matrices = ZeldaArena_MallocDebug(matricesSize, "../z_actor.c", 7540); + + if (bodyBreak->matrices != NULL) { + dListsSize = (count + 1) * sizeof(*bodyBreak->dLists); + bodyBreak->dLists = ZeldaArena_MallocDebug(dListsSize, "../z_actor.c", 7543); + + if (bodyBreak->dLists != NULL) { + objectIdsSize = (count + 1) * sizeof(*bodyBreak->objectIds); + bodyBreak->objectIds = ZeldaArena_MallocDebug(objectIdsSize, "../z_actor.c", 7546); + + if (bodyBreak->objectIds != NULL) { + Lib_MemSet((u8*)bodyBreak->matrices, matricesSize, 0); + Lib_MemSet((u8*)bodyBreak->dLists, dListsSize, 0); + Lib_MemSet((u8*)bodyBreak->objectIds, objectIdsSize, 0); + bodyBreak->val = 1; return; } } } - if (arg0->unk_00 != NULL) { - ZeldaArena_FreeDebug(arg0->unk_00, "../z_actor.c", 7558); + if (bodyBreak->matrices != NULL) { + ZeldaArena_FreeDebug(bodyBreak->matrices, "../z_actor.c", 7558); } - if (arg0->unk_0C != NULL) { - ZeldaArena_FreeDebug(arg0->unk_0C, "../z_actor.c", 7561); + if (bodyBreak->dLists != NULL) { + ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7561); } - if (arg0->unk_04 != NULL) { - ZeldaArena_FreeDebug(arg0->unk_04, "../z_actor.c", 7564); + if (bodyBreak->objectIds != NULL) { + ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7564); } } -void func_80032F54(struct_80032E24* arg0, s32 arg1, s32 arg2, s32 arg3, u32 arg4, Gfx** dList, s16 arg6) { +void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, Gfx** dList, + s16 objectId) { GlobalContext* globalCtx = Effect_GetGlobalCtx(); - if ((globalCtx->actorCtx.unk_00 == 0) && (arg0->unk_10 > 0)) { - if ((arg1 >= arg2) && (arg3 >= arg1) && (*dList != 0)) { - arg0->unk_0C[arg0->unk_10] = *dList; - Matrix_Get(&arg0->unk_00[arg0->unk_10]); - arg0->unk_04[arg0->unk_10] = arg6; - arg0->unk_10++; + if ((globalCtx->actorCtx.unk_00 == 0) && (bodyBreak->val > 0)) { + if ((limbIndex >= minLimbIndex) && (limbIndex <= maxLimbIndex) && (*dList != NULL)) { + bodyBreak->dLists[bodyBreak->val] = *dList; + Matrix_Get(&bodyBreak->matrices[bodyBreak->val]); + bodyBreak->objectIds[bodyBreak->val] = objectId; + bodyBreak->val++; } - if (arg1 != arg0->unk_14) { - arg0->unk_08++; + if (limbIndex != bodyBreak->prevLimbIndex) { + bodyBreak->count++; } - if ((u32)arg0->unk_08 >= arg4) { - arg0->unk_08 = arg0->unk_10 - 1; - arg0->unk_10 = -1; + if ((u32)bodyBreak->count >= count) { + bodyBreak->count = bodyBreak->val - 1; + bodyBreak->val = BODYBREAK_STATUS_READY; } } - arg0->unk_14 = arg1; + bodyBreak->prevLimbIndex = limbIndex; } -s32 func_8003305C(Actor* actor, struct_80032E24* arg1, GlobalContext* globalCtx, s16 params) { +s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, GlobalContext* globalCtx, s16 type) { EnPart* spawnedEnPart; MtxF* mtx; s16 objBankIndex; - if (arg1->unk_10 != -1) { + if (bodyBreak->val != BODYBREAK_STATUS_READY) { return false; } - while (arg1->unk_08 > 0) { - Matrix_Put(&arg1->unk_00[arg1->unk_08]); + while (bodyBreak->count > 0) { + Matrix_Put(&bodyBreak->matrices[bodyBreak->count]); Matrix_Scale(1.0f / actor->scale.x, 1.0f / actor->scale.y, 1.0f / actor->scale.z, MTXMODE_APPLY); - Matrix_Get(&arg1->unk_00[arg1->unk_08]); + Matrix_Get(&bodyBreak->matrices[bodyBreak->count]); - if (1) { // Necessary to match - if (arg1->unk_04[arg1->unk_08] >= 0) { - objBankIndex = arg1->unk_04[arg1->unk_08]; + if (1) { + if (bodyBreak->objectIds[bodyBreak->count] >= 0) { + objBankIndex = bodyBreak->objectIds[bodyBreak->count]; } else { objBankIndex = actor->objBankIndex; } } - mtx = &arg1->unk_00[arg1->unk_08]; + mtx = &bodyBreak->matrices[bodyBreak->count]; + spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, mtx->wx, - mtx->wy, mtx->wz, 0, 0, objBankIndex, params); + mtx->wy, mtx->wz, 0, 0, objBankIndex, type); + if (spawnedEnPart != NULL) { - func_800D20CC(&arg1->unk_00[arg1->unk_08], &spawnedEnPart->actor.shape.rot, 0); - spawnedEnPart->displayList = arg1->unk_0C[arg1->unk_08]; + func_800D20CC(&bodyBreak->matrices[bodyBreak->count], &spawnedEnPart->actor.shape.rot, 0); + spawnedEnPart->displayList = bodyBreak->dLists[bodyBreak->count]; spawnedEnPart->actor.scale = actor->scale; } - arg1->unk_08--; + bodyBreak->count--; } - arg1->unk_10 = 0; - ZeldaArena_FreeDebug(arg1->unk_00, "../z_actor.c", 7678); - ZeldaArena_FreeDebug(arg1->unk_0C, "../z_actor.c", 7679); - ZeldaArena_FreeDebug(arg1->unk_04, "../z_actor.c", 7680); + bodyBreak->val = BODYBREAK_STATUS_FINISHED; + + ZeldaArena_FreeDebug(bodyBreak->matrices, "../z_actor.c", 7678); + ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7679); + ZeldaArena_FreeDebug(bodyBreak->objectIds, "../z_actor.c", 7680); return true; } diff --git a/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c b/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c index c7cd5ec3fe..474f8711ea 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Movebg/z_bg_mizu_movebg.c @@ -362,7 +362,7 @@ void BgMizuMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { u32 frames; if (1) {} - + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mizu_movebg.c", 754); frames = globalCtx->gameplayFrames; diff --git a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c index e0b5ca130e..df841a5662 100644 --- a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c +++ b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c @@ -169,7 +169,7 @@ void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalC GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; s32 pad; - + OPEN_DISPS(gfxCtx, "../z_efc_erupc.c", 368); for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) { if (particles->isActive) { diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 8cc1cf3714..605e0406a7 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -468,7 +468,7 @@ void EnBb_SetupDeath(EnBb* this, GlobalContext* globalCtx) { } void EnBb_Death(EnBb* this, GlobalContext* globalCtx) { - s16 sp4E = 3; + s16 enpartType = 3; Vec3f sp40 = { 0.0f, 0.5f, 0.0f }; Vec3f sp34 = { 0.0f, 0.0f, 0.0f }; @@ -480,13 +480,16 @@ void EnBb_Death(EnBb* this, GlobalContext* globalCtx) { this->actor.shape.rot.x -= 0x4E20; return; } - if (this->enPartInfo.unk_10 == 0) { - func_80032E24(&this->enPartInfo, 0xC, globalCtx); + + if (this->bodyBreak.val == BODYBREAK_STATUS_FINISHED) { + BodyBreak_Alloc(&this->bodyBreak, 12, globalCtx); } + if ((this->dmgEffect == 7) || (this->dmgEffect == 5)) { - sp4E = 0xB; + enpartType = 11; } - if (!func_8003305C(&this->actor, &this->enPartInfo, globalCtx, sp4E)) { + + if (!BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, enpartType)) { return; } Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xD0); @@ -1263,7 +1266,7 @@ void EnBb_Update(Actor* thisx, GlobalContext* globalCtx2) { void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnBb* this = THIS; - func_80032F54(&this->enPartInfo, limbIndex, 4, 0xF, 0xF, dList, -1); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 4, 15, 15, dList, BODYBREAK_OBJECT_DEFAULT); } static Vec3f sFireIceOffsets[] = { diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.h b/src/overlays/actors/ovl_En_Bb/z_en_bb.h index d12fd825fe..f2d4156b4b 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.h +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.h @@ -42,7 +42,7 @@ typedef struct EnBb { /* 0x02AA */ u8 dmgEffect; /* 0x02AC */ ColliderJntSph collider; /* 0x02CC */ ColliderJntSphElement elements[1]; - /* 0x030C */ struct_80032E24 enPartInfo; + /* 0x030C */ BodyBreak bodyBreak; /* 0x0324 */ Actor* targetActor; } EnBb; // size = 0x0328 diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 85c10b2b3b..0b0d3f7377 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -632,8 +632,8 @@ void func_80A75790(EnIk* this) { void func_80A758B0(EnIk* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f); - if (func_8003305C(&this->actor, &this->unk_308, globalCtx, this->actor.params + 4)) { - this->unk_308.unk_10 = 0; + if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params + 4)) { + this->bodyBreak.val = BODYBREAK_STATUS_FINISHED; } if (SkelAnime_Update(&this->skelAnime)) { if (ABS((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) <= 0x4000) { @@ -730,7 +730,7 @@ void func_80A75C38(EnIk* this, GlobalContext* globalCtx) { if (this->actor.params != 0) { if ((prevHealth > 10) && (this->actor.colChkInfo.health <= 10)) { this->unk_2FB = 1; - func_80032E24(&this->unk_308, 3, globalCtx); + BodyBreak_Alloc(&this->bodyBreak, 3, globalCtx); } } else if (this->actor.colChkInfo.health <= 10) { Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_BOSS); @@ -884,7 +884,7 @@ void EnIk_PostLimbDraw3(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1201); if (this->unk_2FB & 1) { - func_80032F54(&this->unk_308, limbIndex, 0x1A, 0x1B, 0x1C, dList, -1); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 26, 27, 28, dList, BODYBREAK_OBJECT_DEFAULT); } if (limbIndex == 12) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_ik_inFight.c", 1217), diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.h b/src/overlays/actors/ovl_En_Ik/z_en_ik.h index 22a406ab23..24b110957b 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.h +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.h @@ -24,7 +24,7 @@ typedef struct EnIk { /* 0x0300 */ s16 unk_300; /* 0x0302 */ s16 switchFlags; /* 0x0304 */ EnIkActionFunc actionFunc; - /* 0x0308 */ struct_80032E24 unk_308; + /* 0x0308 */ BodyBreak bodyBreak; /* 0x0320 */ ColliderCylinder bodyCollider; /* 0x036C */ ColliderQuad axeCollider; /* 0x03EC */ ColliderTris shieldCollider; diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index 381d2949de..966f40b319 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -425,7 +425,7 @@ s32 EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.health == 0) { this->hitByWindArrow = hitByWindArrow; - func_80032E24(&this->unk_1E0, 8, globalCtx); + BodyBreak_Alloc(&this->bodyBreak, 8, globalCtx); this->isDead = true; func_80032C7C(globalCtx, &this->actor); Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_SHELL_DEAD); @@ -454,7 +454,7 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { } else { this->actor.params = 1; } - if (func_8003305C(&this->actor, &this->unk_1E0, globalCtx, this->actor.params) != 0) { + if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params)) { if (!this->hitByWindArrow) { Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); } else { @@ -480,7 +480,7 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { EnSb* this = THIS; - func_80032F54(&this->unk_1E0, limbIndex, 0, 6, 8, dList, -1); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 6, 8, dList, BODYBREAK_OBJECT_DEFAULT); } void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.h b/src/overlays/actors/ovl_En_Sb/z_en_sb.h index b35f79c850..3ffde5efd7 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.h +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.h @@ -13,7 +13,7 @@ typedef struct EnSb { /* 0x014C */ SkelAnime skelAnime; /* 0x0190 */ EnSbActionFunc actionFunc; /* 0x0194 */ ColliderCylinder collider; - /* 0x01E0 */ struct_80032E24 unk_1E0; + /* 0x01E0 */ BodyBreak bodyBreak; /* 0x01F8 */ s16 fire; /* 0x01FA */ s16 behavior; /* 0x01FC */ s16 isDead; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 146c7c302c..edaf434e97 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -380,7 +380,7 @@ void func_80AFD6CC(EnSkb* this, GlobalContext* globalCtx) { // this cast is likely not real, but allows for a match u8* new_var; new_var = &this->unk_283; - if ((this->unk_283 != 1) || func_8003305C(&this->actor, &this->unk_28C, globalCtx, 1)) { + if ((this->unk_283 != 1) || BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, 1)) { if ((*new_var) != 0) { this->unk_283 = (*new_var) | 2; } @@ -409,25 +409,24 @@ void func_80AFD7B4(EnSkb* this, GlobalContext* globalCtx) { } this->unk_280 = 1; this->actor.flags &= ~1; - func_80032E24(&this->unk_28C, 18, globalCtx); + BodyBreak_Alloc(&this->bodyBreak, 18, globalCtx); this->unk_283 |= 4; EffectSsDeadSound_SpawnStationary(globalCtx, &this->actor.projectedPos, NA_SE_EN_STALKID_DEAD, 1, 1, 0x28); EnSkb_SetupAction(this, func_80AFD880); } void func_80AFD880(EnSkb* this, GlobalContext* globalCtx) { - if (func_8003305C(&this->actor, &this->unk_28C, globalCtx, 1) != 0) { + if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, 1)) { if (this->actor.scale.x == 0.01f) { Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x10); + } else if (this->actor.scale.x <= 0.015f) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); } else { - if (this->actor.scale.x <= 0.015f) { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); - } else { - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); - Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); - } + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); } + this->unk_283 |= 8; Actor_Kill(&this->actor); } @@ -482,7 +481,7 @@ void func_80AFD968(EnSkb* this, GlobalContext* globalCtx) { ((this->actor.colChkInfo.damageEffect == 0xE) && ((player->swordAnimation >= 4 && player->swordAnimation <= 11) || (player->swordAnimation == 20 || player->swordAnimation == 21)))) { - func_80032E24(&this->unk_28C, 2, globalCtx); + BodyBreak_Alloc(&this->bodyBreak, 2, globalCtx); this->unk_283 = 1; } } @@ -545,9 +544,9 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Collider_UpdateSpheres(limbIndex, &this->collider); if ((this->unk_283 ^ 1) == 0) { - func_80032F54(&this->unk_28C, limbIndex, 0xB, 0xC, 0x12, dList, -1); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_DEFAULT); } else if ((this->unk_283 | 4) == this->unk_283) { - func_80032F54(&this->unk_28C, limbIndex, 0, 0x12, 0x12, dList, -1); + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_DEFAULT); } } #else diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index 64b08ee9eb..3e1392aa96 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -19,7 +19,7 @@ typedef struct EnSkb { /* 0x0283 */ u8 unk_283; /* 0x0284 */ EnSkbActionFunc actionFunc; /* 0x0288 */ s16 unk_288; - /* 0x028C */ struct_80032E24 unk_28C; + /* 0x028C */ BodyBreak bodyBreak; /* 0x02A4 */ ColliderJntSph collider; /* 0x02C4 */ ColliderJntSphElement colliderItem[2]; } EnSkb; // size = 0x0344 diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index f179c37f2a..f79c95e2fa 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -199,8 +199,8 @@ void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&thisx->shape, -200.0f, ActorShadow_DrawCircle, 70.0f); this->flipState = TEKTITE_INITIAL; thisx->colChkInfo.damageTable = sDamageTable; - this->actionVar1 = 0; // value immediately overwritten in SetupIdle - this->unk_2C4.unk_10 = 0; + this->actionVar1 = 0; + this->bodyBreak.val = BODYBREAK_STATUS_FINISHED; thisx->focus.pos = thisx->world.pos; thisx->focus.pos.y += 20.0f; thisx->colChkInfo.health = 2; @@ -769,14 +769,14 @@ void EnTite_DeathCry(EnTite* this, GlobalContext* globalCtx) { DEADSOUND_REPEAT_MODE_OFF, 40); this->action = TEKTITE_FALL_APART; EnTite_SetupAction(this, EnTite_FallApart); - func_80032E24(&this->unk_2C4, 0x18, globalCtx); + BodyBreak_Alloc(&this->bodyBreak, 24, globalCtx); } /** * Spawn EnPart and drop items */ void EnTite_FallApart(EnTite* this, GlobalContext* globalCtx) { - if (func_8003305C(&this->actor, &this->unk_2C4, globalCtx, (this->actor.params + 0xB))) { + if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, globalCtx, this->actor.params + 0xB)) { if (this->actor.params == TEKTITE_BLUE) { Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); } else { @@ -971,26 +971,25 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } -/** - * Get the locations where the tektite feet are rendered - */ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** limbDList, Vec3s* rot, void* thisx) { EnTite* this = THIS; + switch (limbIndex) { case 8: Matrix_MultVec3f(&sFootOffset, &this->backRightFootPos); break; - case 0xD: + case 13: Matrix_MultVec3f(&sFootOffset, &this->frontRightFootPos); break; - case 0x12: + case 18: Matrix_MultVec3f(&sFootOffset, &this->backLeftFootPos); break; - case 0x17: + case 23: Matrix_MultVec3f(&sFootOffset, &this->frontLeftFootPos); break; } - func_80032F54(&this->unk_2C4, limbIndex, 0, 0x18, 0x18, limbDList, -1); + + BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 24, 24, limbDList, BODYBREAK_OBJECT_DEFAULT); } void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index 40f2906778..6eea6a69ad 100755 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -21,7 +21,7 @@ typedef struct EnTite { /* 0x02BC */ u8 action; /* 0x02BD */ u8 flipState; /* 0x02C0 */ EnTiteActionFunc actionFunc; - /* 0x02C4 */ struct_80032E24 unk_2C4; // Data for EnPart which is spawned at death + /* 0x02C4 */ BodyBreak bodyBreak; /* 0x02DC */ s32 unk_2DC; // flags related to bgCheck drawn effects /* 0x02E0 */ s16 actionVar1; // Usage depends on current action function /* 0x02E2 */ u8 actionVar2; // Usage depends on current action function