diff --git a/asm/enemyUtils.s b/asm/enemyUtils.s deleted file mode 100644 index 87d302b2..00000000 --- a/asm/enemyUtils.s +++ /dev/null @@ -1,426 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - .text - - thumb_func_start sub_0804A720 -sub_0804A720: @ 0x0804A720 - push {r4, r5, r6, lr} - adds r2, r0, #0 - adds r0, #0x6d - ldrb r1, [r0] - movs r0, #4 - ands r0, r1 - cmp r0, #0 - bne _0804A7D0 - ldrb r0, [r2, #9] - lsls r0, r0, #1 - ldr r1, _0804A76C @ =gUnk_080D3D94 - adds r3, r0, r1 - adds r4, r2, #0 - adds r4, #0x68 - ldrb r1, [r4, #0x16] - cmp r1, #0 - bne _0804A744 - ldrb r1, [r3] -_0804A744: - adds r0, r2, #0 - adds r0, #0x6e - strb r1, [r0] - adds r5, r0, #0 - ldrb r1, [r4, #0x17] - cmp r1, #0 - bne _0804A754 - ldrb r1, [r3, #1] -_0804A754: - adds r0, r2, #0 - adds r0, #0x6f - strb r1, [r0] - adds r6, r0, #0 - ldrh r1, [r4, #0x1c] - adds r3, r1, #0 - cmp r3, #0 - beq _0804A774 - ldr r0, _0804A770 @ =gRoomControls - ldrh r0, [r0, #6] - adds r0, r1, r0 - b _0804A784 - .align 2, 0 -_0804A76C: .4byte gUnk_080D3D94 -_0804A770: .4byte gRoomControls -_0804A774: - ldrb r0, [r5] - lsls r1, r0, #2 - movs r5, #0x2e - ldrsh r0, [r2, r5] - cmp r0, r1 - blt _0804A78C - ldrh r0, [r2, #0x2e] - subs r0, r0, r1 -_0804A784: - adds r1, r2, #0 - adds r1, #0x70 - strh r0, [r1] - b _0804A792 -_0804A78C: - adds r0, r2, #0 - adds r0, #0x70 - strh r3, [r0] -_0804A792: - ldrh r1, [r4, #0x1e] - adds r3, r1, #0 - cmp r3, #0 - beq _0804A7A8 - ldr r0, _0804A7A4 @ =gRoomControls - ldrh r0, [r0, #8] - adds r0, r1, r0 - b _0804A7B8 - .align 2, 0 -_0804A7A4: .4byte gRoomControls -_0804A7A8: - ldrb r0, [r6] - lsls r1, r0, #2 - movs r4, #0x32 - ldrsh r0, [r2, r4] - cmp r0, r1 - blt _0804A7C0 - ldrh r0, [r2, #0x32] - subs r0, r0, r1 -_0804A7B8: - adds r1, r2, #0 - adds r1, #0x72 - strh r0, [r1] - b _0804A7C6 -_0804A7C0: - adds r0, r2, #0 - adds r0, #0x72 - strh r3, [r0] -_0804A7C6: - adds r2, #0x6d - ldrb r1, [r2] - movs r0, #4 - orrs r0, r1 - strb r0, [r2] -_0804A7D0: - pop {r4, r5, r6, pc} - .align 2, 0 - - thumb_func_start sub_0804A7D4 -sub_0804A7D4: @ 0x0804A7D4 - push {lr} - ldrb r1, [r0, #9] - movs r2, #0 - bl CreateDeathFx - pop {pc} - - thumb_func_start CreateDeathFx -CreateDeathFx: @ 0x0804A7E0 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - adds r5, r0, #0 - mov sb, r1 - mov sl, r2 - adds r6, r5, #0 - adds r6, #0x6d - ldrb r1, [r6] - movs r7, #1 - adds r0, r7, #0 - ands r0, r1 - cmp r0, #0 - beq _0804A864 - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _0804A80A - b _0804A982 -_0804A80A: - ldrb r1, [r5, #9] - movs r0, #1 - movs r2, #0 - bl CreateObject - adds r4, r0, #0 - cmp r4, #0 - bne _0804A81C - b _0804A982 -_0804A81C: - adds r0, #0x6c - strb r7, [r0] - adds r0, r5, #0 - adds r1, r4, #0 - movs r2, #0 - movs r3, #1 - bl PositionRelative - str r5, [r4, #0x50] - ldrb r1, [r6] - movs r0, #2 - orrs r0, r1 - strb r0, [r6] - ldrb r0, [r5, #9] - cmp r0, #0x37 - bne _0804A84A - ldr r0, _0804A85C @ =gRoomTransition - adds r0, #0x39 - ldrb r0, [r0] - cmp r0, #0 - beq _0804A84A - bl DeleteThisEntity -_0804A84A: - bl sub_0807CD9C - ldr r0, _0804A860 @ =0x80100000 - bl SoundReq - bl DeleteThisEntity - b _0804A982 - .align 2, 0 -_0804A85C: .4byte gRoomTransition -_0804A860: .4byte 0x80100000 -_0804A864: - adds r4, r5, #0 - adds r4, #0x3a - ldrb r1, [r4] - movs r0, #2 - ands r0, r1 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - mov r8, r0 - cmp r0, #0 - bne _0804A934 - adds r0, r5, #0 - bl sub_08049CF4 - ldr r1, _0804A8E8 @ =gSave - ldr r0, [r1, #0x50] - adds r0, #1 - str r0, [r1, #0x50] - ldrb r0, [r4] - movs r7, #0 - movs r1, #2 - orrs r0, r1 - strb r0, [r4] - movs r0, #0xff - strb r0, [r5, #0xe] - adds r0, r5, #0 - movs r1, #3 - bl SetDefaultPriority - ldrb r1, [r5, #9] - movs r0, #1 - movs r2, #0 - bl CreateObject - adds r4, r0, #0 - cmp r4, #0 - beq _0804A8CA - adds r0, #0x6c - mov r2, r8 - strb r2, [r0] - adds r0, #1 - mov r1, sb - strb r1, [r0] - adds r0, #1 - mov r2, sl - strb r2, [r0] - str r5, [r4, #0x50] - str r5, [r4, #0x54] - adds r0, r5, #0 - adds r1, r4, #0 - bl CopyPosition -_0804A8CA: - ldrb r1, [r6] - movs r0, #8 - ands r0, r1 - cmp r0, #0 - beq _0804A8EC - adds r0, r4, #0 - adds r0, #0x6c - ldrb r1, [r0] - movs r2, #8 - orrs r1, r2 - strb r1, [r0] - adds r0, r5, #0 - bl DeleteEntity - b _0804A982 - .align 2, 0 -_0804A8E8: .4byte gSave -_0804A8EC: - adds r0, r5, #0 - adds r0, #0x41 - ldrb r1, [r0] - movs r0, #0x7f - ands r0, r1 - cmp r0, #0x13 - bne _0804A934 - ldrb r0, [r5, #0x1c] - movs r1, #0xf - ands r1, r0 - cmp r1, #1 - beq _0804A91A - cmp r1, #2 - bne _0804A92A - cmp r4, #0 - beq _0804A92A - adds r1, r4, #0 - adds r1, #0x6c - ldrb r0, [r1] - movs r2, #2 - orrs r0, r2 - strb r0, [r1] - b _0804A92A -_0804A91A: - cmp r4, #0 - beq _0804A92A - adds r0, r4, #0 - adds r0, #0x6c - ldrb r1, [r0] - movs r2, #4 - orrs r1, r2 - strb r1, [r0] -_0804A92A: - movs r0, #0 - str r0, [r4, #0x50] - bl DeleteThisEntity - b _0804A982 -_0804A934: - ldrb r0, [r5, #0xe] - cmp r0, #0 - bne _0804A940 - bl DeleteThisEntity - b _0804A982 -_0804A940: - subs r1, r0, #1 - strb r1, [r5, #0xe] - lsls r0, r1, #0x18 - cmp r0, #0 - bne _0804A95E - ldrb r1, [r5, #0x18] - movs r0, #4 - rsbs r0, r0, #0 - ands r0, r1 - strb r0, [r5, #0x18] - adds r0, r5, #0 - movs r1, #0 - bl SetDefaultPriority - b _0804A982 -_0804A95E: - lsls r0, r1, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #8 - bhi _0804A982 - ldrb r1, [r5, #0x18] - lsls r0, r1, #0x1e - cmp r0, #0 - beq _0804A976 - movs r0, #4 - rsbs r0, r0, #0 - ands r0, r1 - b _0804A980 -_0804A976: - movs r0, #4 - rsbs r0, r0, #0 - ands r0, r1 - movs r1, #1 - orrs r0, r1 -_0804A980: - strb r0, [r5, #0x18] -_0804A982: - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7, pc} - - thumb_func_start CreateProjectileWithParent -CreateProjectileWithParent: @ 0x0804A98C - push {r4, r5, r6, lr} - adds r6, r0, #0 - adds r0, r1, #0 - adds r5, r2, #0 - bl CreateProjectile - adds r4, r0, #0 - cmp r4, #0 - beq _0804A9A8 - strb r5, [r4, #0xa] - adds r0, r6, #0 - adds r1, r4, #0 - bl CopyPosition -_0804A9A8: - adds r0, r4, #0 - pop {r4, r5, r6, pc} - - thumb_func_start SetChildOffset -SetChildOffset: @ 0x0804A9AC - push {r4, r5, r6, r7, lr} - adds r5, r0, #0 - adds r6, r1, #0 - adds r7, r2, #0 - mov ip, r3 - ldr r4, [r5, #0x68] - cmp r4, #0 - beq _0804A9FA - ldrb r2, [r5, #0x19] - lsrs r2, r2, #6 - lsls r2, r2, #6 - ldrb r3, [r4, #0x19] - movs r1, #0x3f - adds r0, r1, #0 - ands r0, r3 - orrs r0, r2 - strb r0, [r4, #0x19] - ldrb r0, [r5, #0x1b] - lsrs r0, r0, #6 - lsls r0, r0, #6 - ldrb r2, [r4, #0x1b] - ands r1, r2 - orrs r1, r0 - strb r1, [r4, #0x1b] - ldrh r0, [r5, #0x2e] - adds r0, r0, r6 - strh r0, [r4, #0x2e] - ldrh r0, [r5, #0x32] - adds r0, r0, r7 - strh r0, [r4, #0x32] - ldrh r0, [r5, #0x36] - add r0, ip - strh r0, [r4, #0x36] - adds r0, r5, #0 - adds r0, #0x38 - ldrb r1, [r0] - adds r0, r4, #0 - adds r0, #0x38 - strb r1, [r0] -_0804A9FA: - pop {r4, r5, r6, r7, pc} - - thumb_func_start sub_0804A9FC -sub_0804A9FC: @ 0x0804A9FC - push {r4, lr} - adds r4, r0, #0 - ldr r0, [r4, #0x68] - cmp r0, #0 - bne _0804AA16 - adds r0, r4, #0 - movs r2, #0 - bl CreateFx - cmp r0, #0 - beq _0804AA16 - str r0, [r4, #0x68] - b _0804AA18 -_0804AA16: - movs r0, #0 -_0804AA18: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_0804AA1C -sub_0804AA1C: @ 0x0804AA1C - push {lr} - adds r2, r0, #0 - ldr r1, [r2, #0x68] - cmp r1, #0 - beq _0804AA2C - movs r0, #0 - str r0, [r1, #0x50] - str r0, [r2, #0x68] -_0804AA2C: - pop {pc} - .align 2, 0 diff --git a/asm/object/deathFx.s b/asm/object/deathFx.s index ac049903..f23716a0 100644 --- a/asm/object/deathFx.s +++ b/asm/object/deathFx.s @@ -21,7 +21,7 @@ DeathFx: @ 0x0808161C _08081630: .4byte gUnk_0811EBFC thumb_func_start sub_08081634 -sub_08081634: @ 0x08081634 +DeathFx_Action0: @ 0x08081634 push {r4, r5, lr} adds r4, r0, #0 adds r0, #0x6c @@ -136,7 +136,7 @@ _08081718: .4byte gUnk_0811EC08 _0808171C: .4byte gUnk_0811EC20 thumb_func_start sub_08081720 -sub_08081720: @ 0x08081720 +DeathFx_Action1: @ 0x08081720 push {r4, lr} adds r4, r0, #0 bl GetNextFrame @@ -170,7 +170,7 @@ _0808175E: pop {r4, pc} thumb_func_start sub_08081760 -sub_08081760: @ 0x08081760 +DeathFx_Action2: @ 0x08081760 push {r4, lr} adds r4, r0, #0 bl UpdateAnimationSingleFrame @@ -228,7 +228,7 @@ _080817C6: _080817C8: .4byte gUnk_0811EC24 thumb_func_start sub_080817CC -sub_080817CC: @ 0x080817CC +DeathFx_DropRandom9: @ 0x080817CC push {lr} movs r1, #9 bl CreateRandomItemDrop @@ -236,7 +236,7 @@ sub_080817CC: @ 0x080817CC .align 2, 0 thumb_func_start sub_080817D8 -sub_080817D8: @ 0x080817D8 +DeathFx_DropRandom13: @ 0x080817D8 push {lr} movs r1, #0xd bl CreateRandomItemDrop @@ -244,7 +244,7 @@ sub_080817D8: @ 0x080817D8 .align 2, 0 thumb_func_start sub_080817E4 -sub_080817E4: @ 0x080817E4 +DeathFx_DropRandom14: @ 0x080817E4 push {lr} movs r1, #0xe bl CreateRandomItemDrop @@ -252,7 +252,7 @@ sub_080817E4: @ 0x080817E4 .align 2, 0 thumb_func_start sub_080817F0 -sub_080817F0: @ 0x080817F0 +DeathFx_DropRandom1: @ 0x080817F0 push {lr} movs r1, #1 bl CreateRandomItemDrop @@ -260,7 +260,7 @@ sub_080817F0: @ 0x080817F0 .align 2, 0 thumb_func_start sub_080817FC -sub_080817FC: @ 0x080817FC +DeathFx_DropFixedItem: @ 0x080817FC push {lr} adds r1, r0, #0 adds r1, #0x6e @@ -270,7 +270,7 @@ sub_080817FC: @ 0x080817FC pop {pc} thumb_func_start sub_0808180C -sub_0808180C: @ 0x0808180C +DeathFx_Delete: @ 0x0808180C push {lr} bl DeleteThisEntity pop {pc} diff --git a/data/const/object/deathFx.s b/data/const/object/deathFx.s deleted file mode 100644 index 8c911d44..00000000 --- a/data/const/object/deathFx.s +++ /dev/null @@ -1,37 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0811EBFC:: @ 0811EBFC - .4byte sub_08081634 - .4byte sub_08081720 - .4byte sub_08081760 - -gUnk_0811EC08:: @ 0811EC08 - .incbin "deathFx/gUnk_0811EC08.bin" - -gUnk_0811EC20:: @ 0811EC20 - .incbin "deathFx/gUnk_0811EC20.bin" - -gUnk_0811EC24:: @ 0811EC24 - .4byte sub_080817CC - .4byte sub_080817D8 - .4byte sub_080817F0 - .4byte sub_080817E4 - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817CC - .4byte sub_080817FC - -gUnk_0811EC64:: @ 0811EC64 - .incbin "deathFx/gUnk_0811EC64.bin" diff --git a/include/object/deathFx.h b/include/object/deathFx.h new file mode 100644 index 00000000..99cffc86 --- /dev/null +++ b/include/object/deathFx.h @@ -0,0 +1,17 @@ +#ifndef TMC_DEATHFX_H +#define TMC_DEATHFX_H + +#ifndef NENT_DEPRECATED +#error "deathFx.h requires new entities" +#endif +#include "entity.h" + +typedef struct { + Entity base; + int filler68; + u8 unk6c; + u8 parentId; + u8 item; +} DeathFxObject; + +#endif // TMC_DEATHFX_H diff --git a/linker.ld b/linker.ld index bbe4d9a3..59c2a67c 100644 --- a/linker.ld +++ b/linker.ld @@ -645,7 +645,7 @@ SECTIONS { asm/code_0808091C.o(.text); /* scroll.c */ /* objects */ src/object/itemOnGround.o(.text); - asm/object/deathFx.o(.text); + src/object/deathFx.o(.text); asm/object/itemForSale.o(.text); src/object/button.o(.text); asm/object/minishEmoticon.o(.text); @@ -1357,7 +1357,7 @@ SECTIONS { src/script.o(.rodata); data/data_0811E750.o(.rodata); data/const/object/itemOnGround.o(.rodata); - data/const/object/deathFx.o(.rodata); + src/object/deathFx.o(.rodata); data/animations/object/deathFx.o(.rodata); data/const/object/itemForSale.o(.rodata); data/const/object/button.o(.rodata); diff --git a/src/enemyUtils.c b/src/enemyUtils.c index ead7c845..d37c33a1 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -1,9 +1,11 @@ +#define NENT_DEPRECATED #include "entity.h" #include "definitions.h" #include "functions.h" #include "object.h" #include "save.h" #include "projectile.h" +#include "object/deathFx.h" extern void sub_08049CF4(Entity*); @@ -21,45 +23,45 @@ const EnemyDefinition* GetEnemyDefinition(Entity* entity) { return definition; } -bool32 EnemyInit(Entity* this) { - if ((this->flags & ENT_DID_INIT) == 0) { - const EnemyDefinition* definition = GetEnemyDefinition(this); - if (LoadEnemySprite(this, definition) == FALSE) { +bool32 EnemyInit(GenericEntity* this) { + if ((super->flags & ENT_DID_INIT) == 0) { + const EnemyDefinition* definition = GetEnemyDefinition(super); + if (LoadEnemySprite(super, definition) == FALSE) { return FALSE; } - this->flags |= ENT_DID_INIT; + super->flags |= ENT_DID_INIT; if (definition->spriteFlags.collision != 0) { - COLLISION_ON(this); + COLLISION_ON(super); } - this->spriteIndex = definition->spriteIndex; - if (this->spriteSettings.draw == 0) { - this->spriteSettings.draw = definition->spriteFlags.draw; + super->spriteIndex = definition->spriteIndex; + if (super->spriteSettings.draw == 0) { + super->spriteSettings.draw = definition->spriteFlags.draw; } - this->spritePriority.b1 = definition->spriteFlags.spritePriority; - this->spriteSettings.shadow = definition->spriteFlags.shadow; - if (this->speed == 0) { - this->speed = definition->speed; + super->spritePriority.b1 = definition->spriteFlags.spritePriority; + super->spriteSettings.shadow = definition->spriteFlags.shadow; + if (super->speed == 0) { + super->speed = definition->speed; } - this->flags2 = definition->flags2; - this->hitType = definition->damageType; - this->hitbox = (Hitbox*)definition->ptr.hitbox; - this->health = definition->health; - if (this->hurtType == 0) { - this->hurtType = 0x41; + super->flags2 = definition->flags2; + super->hitType = definition->damageType; + super->hitbox = (Hitbox*)definition->ptr.hitbox; + super->health = definition->health; + if (super->hurtType == 0) { + super->hurtType = 0x41; } - UpdateSpriteForCollisionLayer(this); + UpdateSpriteForCollisionLayer(super); if ((this->field_0x6c.HALF.HI & 0x20) != 0) { - u32 uVar4 = gUnk_080D3E74[this->id >> 3] >> ((this->id & 7) << 1) & 3; + u32 uVar4 = gUnk_080D3E74[super->id >> 3] >> ((super->id & 7) << 1) & 3; if (uVar4 != 0) { Entity* object = CreateObject(OBJECT_A9, uVar4 - 1, 0); if (object != NULL) { - object->actionDelay = this->flags; - object->field_0xf = this->spriteSettings.draw; + object->actionDelay = super->flags; + object->field_0xf = super->spriteSettings.draw; object->spritePriority.b0 = 3; - object->parent = this; - CopyPosition(this, object); - this->flags &= ~ENT_COLLIDE; - this->spriteSettings.draw = 0; + object->parent = super; + CopyPosition(super, object); + super->flags &= ~ENT_COLLIDE; + super->spriteSettings.draw = 0; this->field_0x6c.HALF.HI |= 0x10; } } @@ -93,29 +95,29 @@ bool32 LoadEnemySprite(Entity* entity, const EnemyDefinition* definition) { ASM_FUNC("asm/non_matching/enemyUtils/sub_0804A720.inc", void sub_0804A720(Entity* this)) -void CreateDeathFx(Entity* param_1, u32 param_2, u32 param_3); -void sub_0804A7D4(Entity* param_1) { - CreateDeathFx(param_1, (u32)param_1->id, 0); +void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem); +void sub_0804A7D4(Entity* this) { + CreateDeathFx((GenericEntity*)this, this->id, 0); } -void CreateDeathFx(Entity* param_1, u32 param_2, u32 param_3) { - Entity* pEVar2; - Entity* pEVar3; +void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { + DeathFxObject* deathFx; + DeathFxObject* deathFx2; u8 bVar3; - if ((param_1->field_0x6c.HALF.HI & 1) != 0) { - if ((param_1->field_0x6c.HALF.HI & 2) != 0) { + if ((parent->field_0x6c.HALF.HI & 1) != 0) { + if ((parent->field_0x6c.HALF.HI & 2) != 0) { return; } - pEVar2 = CreateObject(DEATH_FX, param_1->id, 0); - if (pEVar2 == NULL) { + deathFx = (DeathFxObject*)CreateObject(DEATH_FX, parent->base.id, 0); + if (deathFx == NULL) { return; } - pEVar2->field_0x6c.HALF.LO = 1; - PositionRelative(param_1, pEVar2, 0, 1); - pEVar2->parent = param_1; - param_1->field_0x6c.HALF.HI |= 2; - if ((param_1->id == '7') && (gRoomTransition.field_0x39 != 0)) { + deathFx->unk6c = 1; + PositionRelative(&(parent->base), &(deathFx->base), 0, 1); + deathFx->base.parent = &(parent->base); + parent->field_0x6c.HALF.HI |= 2; + if ((parent->base.id == 0x37) && (gRoomTransition.field_0x39 != 0)) { DeleteThisEntity(); } sub_0807CD9C(); @@ -123,56 +125,56 @@ void CreateDeathFx(Entity* param_1, u32 param_2, u32 param_3) { DeleteThisEntity(); return; } else { - int tmp = param_1->field_0x3a & 2; + int tmp = parent->base.field_0x3a & 2; if (tmp == 0) { - sub_08049CF4(param_1); + sub_08049CF4(&(parent->base)); gSave.unk50 += 1; - param_1->field_0x3a |= 2; - param_1->actionDelay = 0xff; - SetDefaultPriority(param_1, 3); - pEVar3 = CreateObject(DEATH_FX, param_1->id, 0); - if (pEVar3 != NULL) { - pEVar3->field_0x6c.HALF.LO = tmp; - pEVar3->field_0x6c.HALF.HI = param_2; - pEVar3->field_0x6e.HALF.LO = param_3; - pEVar3->parent = param_1; - pEVar3->child = param_1; - CopyPosition(param_1, pEVar3); + parent->base.field_0x3a |= 2; + parent->base.actionDelay = 0xff; + SetDefaultPriority(&(parent->base), 3); + deathFx2 = (DeathFxObject*)CreateObject(DEATH_FX, parent->base.id, 0); + if (deathFx2 != NULL) { + deathFx2->unk6c = tmp; + deathFx2->parentId = parentId; + deathFx2->item = fixedItem; + deathFx2->base.parent = &(parent->base); + deathFx2->base.child = &(parent->base); + CopyPosition(&(parent->base), &(deathFx2->base)); } - if ((param_1->field_0x6c.HALF.HI & 8) != 0) { - pEVar3->field_0x6c.HALF.LO |= 8; - DeleteEntity(param_1); + if ((parent->field_0x6c.HALF.HI & 8) != 0) { + deathFx2->unk6c |= 8; + DeleteEntity(&(parent->base)); return; } - if ((param_1->bitfield & 0x7f) == 0x13) { - bVar3 = param_1->field_0x1c & 0xf; + if ((parent->base.bitfield & 0x7f) == 0x13) { + bVar3 = parent->base.field_0x1c & 0xf; if (bVar3 != 1) { - if ((bVar3 == 2) && (pEVar3 != NULL)) { - pEVar3->field_0x6c.HALF.LO |= 2; + if ((bVar3 == 2) && (deathFx2 != NULL)) { + deathFx2->unk6c |= 2; } } else { - if (pEVar3 != NULL) { - pEVar3->field_0x6c.HALF.LO |= 4; + if (deathFx2 != NULL) { + deathFx2->unk6c |= 4; } } - pEVar3->parent = NULL; + deathFx2->base.parent = NULL; DeleteThisEntity(); return; } } - if (param_1->actionDelay == 0) { + if (parent->base.actionDelay == 0) { DeleteThisEntity(); } else { - if (--param_1->actionDelay == 0) { - param_1->spriteSettings.draw = 0; - SetDefaultPriority(param_1, 0); + if (--parent->base.actionDelay == 0) { + parent->base.spriteSettings.draw = 0; + SetDefaultPriority(&(parent->base), 0); } else { - if (param_1->actionDelay < 9) { - if (param_1->spriteSettings.draw != 0) { - param_1->spriteSettings.draw = 0; + if (parent->base.actionDelay < 9) { + if (parent->base.spriteSettings.draw) { + parent->base.spriteSettings.draw = 0; } else { - param_1->spriteSettings.draw = 1; + parent->base.spriteSettings.draw = 1; } } } @@ -194,32 +196,35 @@ Entity* CreateProjectileWithParent(Entity* parent, u32 projectileId, u32 project void SetChildOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) { Entity* other; + GenericEntity* this = (GenericEntity*)entity; - other = *(Entity**)&entity->field_0x68; + other = *(Entity**)&this->field_0x68; if (other != NULL) { - other->spriteRendering.b3 = entity->spriteRendering.b3; - other->spriteOrientation.flipY = entity->spriteOrientation.flipY; - other->x.HALF.HI = entity->x.HALF.HI + xOffset; - other->y.HALF.HI = entity->y.HALF.HI + yOffset; - other->z.HALF.HI = entity->z.HALF.HI + zOffset; - other->collisionLayer = entity->collisionLayer; + other->spriteRendering.b3 = super->spriteRendering.b3; + other->spriteOrientation.flipY = super->spriteOrientation.flipY; + other->x.HALF.HI = super->x.HALF.HI + xOffset; + other->y.HALF.HI = super->y.HALF.HI + yOffset; + other->z.HALF.HI = super->z.HALF.HI + zOffset; + other->collisionLayer = super->collisionLayer; } } Entity* sub_0804A9FC(Entity* parent, u32 fxType) { Entity* fx; + GenericEntity* this = (GenericEntity*)parent; - if ((*(Entity**)&parent->field_0x68 == NULL) && (fx = CreateFx(parent, fxType, 0), fx != NULL)) { - *(Entity**)&parent->field_0x68 = fx; + if ((*(Entity**)&this->field_0x68 == NULL) && (fx = CreateFx(super, fxType, 0), fx != NULL)) { + *(Entity**)&this->field_0x68 = fx; } else { fx = NULL; } return fx; } -void sub_0804AA1C(Entity* param_1) { - if (*(Entity**)¶m_1->field_0x68 != NULL) { - (*(Entity**)¶m_1->field_0x68)->parent = NULL; - *(Entity**)¶m_1->field_0x68 = NULL; +void sub_0804AA1C(Entity* entity) { + GenericEntity* this = (GenericEntity*)entity; + if (*(Entity**)&this->field_0x68 != NULL) { + (*(Entity**)&this->field_0x68)->parent = NULL; + *(Entity**)&this->field_0x68 = NULL; } } diff --git a/src/object/deathFx.c b/src/object/deathFx.c new file mode 100644 index 00000000..0179bded --- /dev/null +++ b/src/object/deathFx.c @@ -0,0 +1,260 @@ +#include "global.h" +#define NENT_DEPRECATED +#include "entity.h" +#include "sound.h" +#include "functions.h" +#include "object/deathFx.h" +#include "enemy.h" + +void sub_08081790(DeathFxObject* this); +void DeathFx_Delete(DeathFxObject* this); + +void DeathFx_Action0(DeathFxObject* this); +void DeathFx_Action1(DeathFxObject* this); +void DeathFx_Action2(DeathFxObject* this); +void DeathFx(Entity* this) { + static void (*const DeathFx_Actions[])(DeathFxObject*) = { + DeathFx_Action0, + DeathFx_Action1, + DeathFx_Action2, + }; + DeathFx_Actions[this->action]((DeathFxObject*)this); +} + +void DeathFx_Action0(DeathFxObject* this) { + static const u8 gUnk_0811EC08[] = { + 0, 64, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }; + static const u8 gUnk_0811EC20[] = { + 26, + 14, + 26, + 26, + }; + Entity* parent; + int uVar4; + u32 tmp; + + if (this->unk6c & 1) { + super->spriteIndex = 0x65; + super->action = 2; + super->direction = 0; + super->speed = 0x40; + super->collisionLayer = 2; + UpdateSpriteForCollisionLayer(&this->base); + super->spriteRendering.b0 = 3; + if (super->actionDelay == 0) { + tmp = 0x80; + } else { + tmp = super->actionDelay; + super->actionDelay = 0; + } + sub_0805EC9C(super, tmp, tmp, 0); + LoadSwapGFX(super, 4, 0); + InitAnimationForceUpdate(super, 0); + SoundReq(SFX_BOSS_EXPLODE); + } else { + if (this->unk6c & 0xc) { + sub_08081790(this); + DeathFx_Delete(this); + } else { + if (this->unk6c & 2) { + InitializeAnimation(&this->base, 2); + } else { + super->spritePriority.b0 = 3; + uVar4 = gUnk_0811EC08[super->type >> 2]; + uVar4 >>= ((super->type % 4) << 1); + uVar4 &= 3; + parent = super->parent; + if (parent != NULL) { + parent->actionDelay = gUnk_0811EC20[uVar4]; + } + InitializeAnimation(&this->base, uVar4); + } + } + super->action = 1; + EnqueueSFX(SFX_FF); + } + SetDefaultPriority(super, 3); +} + +void DeathFx_Action1(DeathFxObject* this) { + GetNextFrame(super); + if (super->frame & 0x80) { + sub_08081790(this); + DeathFx_Delete(this); + } else { + if ((super->frame & 1) != 0) { + super->spritePriority.b0 = 4; + } + } +} + +void DeathFx_Action2(DeathFxObject* this) { + UpdateAnimationSingleFrame(super); + if (super->frame & 0x80) { + DeathFx_Delete(this); + } else { + if ((super->frame & 1) != 0) { + LinearMoveUpdate(super); + } + } +} + +void DeathFx_DropRandom9(DeathFxObject* this); +void DeathFx_DropRandom13(DeathFxObject* this); +void DeathFx_DropRandom1(DeathFxObject* this); +void DeathFx_DropRandom14(DeathFxObject* this); +void DeathFx_DropFixedItem(DeathFxObject* this); +void sub_08081790(DeathFxObject* this) { + static void (*const DeathFx_DropFunctions[])(DeathFxObject*) = { + DeathFx_DropRandom9, DeathFx_DropRandom13, DeathFx_DropRandom1, DeathFx_DropRandom14, + DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, + DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, + DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropFixedItem, + }; + static const u8 gUnk_0811EC64[] = { + [OCTOROK] = 6, + [CHUCHU] = 6, + [LEEVER] = 6, + [PEAHAT] = 6, + [ROLLOBITE] = 0, + [DARK_NUT] = 11, + [HANGING_SEED] = 0, + [BEETLE] = 6, + [KEESE] = 6, + [DOOR_MIMIC] = 0, + [ROCK_CHUCHU] = 10, + [SPINY_CHUCHU] = 6, + [CUCCO_CHICK_AGGR] = 6, + [MOLDORM] = 7, + [ENEMY_E] = 6, + [MOLDWORM] = 6, + [SLUGGULA] = 6, + [PESTO] = 0, + [PUFFSTOOL] = 6, + [CHUCHU_BOSS] = 6, + [LIKE_LIKE] = 6, + [SPEAR_MOBLIN] = 8, + [BUSINESS_SCRUB] = 0, + [RUPEE_LIKE] = 8, + [MADDERPILLAR] = 6, + [WATER_DROP] = 6, + [WALL_MASTER] = 8, + [BOMB_PEAHAT] = 10, + [SPARK] = 6, + [CHASER] = 0, + [SPIKED_BEETLE] = 6, + [SENSOR_BLADE_TRAP] = 0, + [HELMASAUR] = 6, + [FALLING_BOULDER] = 0, + [BOBOMB] = 10, + [WALL_MASTER_2] = 8, + [GLEEROK] = 6, + [VAATI_EYES_MACRO] = 0, + [TEKTITE] = 6, + [WIZZROBE_WIND] = 6, + [WIZZROBE_FIRE] = 6, + [WIZZROBE_ICE] = 6, + [ARMOS] = 11, + [EYEGORE] = 9, + [ROPE] = 6, + [SMALL_PESTO] = 1, + [ACRO_BANDIT] = 6, + [BLADE_TRAP] = 0, + [KEATON] = 7, + [CROW] = 6, + [MULLDOZER] = 6, + [BOMBAROSSA] = 6, + [WISP] = 0, + [SPINY_BEETLE] = 6, + [MAZAAL_HEAD] = 6, + [MAZAAL_MACRO] = 6, + [MAZAAL_HAND] = 6, + [OCTOROK_BOSS] = 6, + [FLYING_POT] = 6, + [GOBDO] = 6, + [OCTOROK_GOLDEN] = 6, + [TEKTITE_GOLDEN] = 6, + [ROPE_GOLDEN] = 6, + [CLOUD_PIRANHA] = 6, + [SCISSORS_BEETLE] = 7, + [CUCCO_AGGR] = 6, + [STALFOS] = 7, + [FLYING_SKULL] = 6, + [MAZAAL_BRACELET] = 6, + [TAKKURI] = 6, + [BOW_MOBLIN] = 8, + [LAKITU] = 6, + [LAKITU_CLOUD] = 6, + [TORCH_TRAP] = 6, + [VAATI_REBORN_ENEMY] = 6, + [VAATI_PROJECTILE] = 6, + [BALL_CHAIN_SOLIDER] = 8, + [ENEMY_4D] = 8, + [GHINI] = 6, + [VAATI_TRANSFIGURED] = 6, + [ENEMY_50] = 6, + [VAATI_WRATH] = 6, + [VAATI_ARM] = 12, + [DUST] = 0, + [VAATI_BALL] = 6, + [OCTOROK2] = 6, + [SLIME] = 6, + [MINI_SLIME] = 6, + [FIREBALL_GUY] = 6, + [MINI_FIREBALL_GUY] = 6, + [VAATI_TRANSFIGURED_EYE] = 6, + [BUSINESS_SCRUB_PROLOGUE] = 0, + [GYORG_FEMALE] = 6, + [GYORG_MALE] = 6, + [CURTAIN] = 0, + [VAATI_WRATH_EYE] = 6, + [GYORG_CHILD] = 12, + [GYORG_FEMALE_EYE] = 6, + [GYORG_MALE_EYE] = 6, + [GYORG_FEMALE_MOUTH] = 6, + [ENEMY_64] = 6, + [TREE_ITEM] = 6, + [ENEMY_66] = 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + }; + if (this->parentId < 0xf0) { + CreateRandomItemDrop(super, gUnk_0811EC64[this->parentId]); + } else { + DeathFx_DropFunctions[this->parentId - 0xf0](this); + } +} + +void DeathFx_DropRandom9(DeathFxObject* this) { + CreateRandomItemDrop(super, 9); +} + +void DeathFx_DropRandom13(DeathFxObject* this) { + CreateRandomItemDrop(super, 13); +} + +void DeathFx_DropRandom14(DeathFxObject* this) { + CreateRandomItemDrop(super, 14); +} + +void DeathFx_DropRandom1(DeathFxObject* this) { + CreateRandomItemDrop(super, 1); +} + +u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter); +void DeathFx_DropFixedItem(DeathFxObject* this) { + CreateItemDrop(super, this->item, 0); +} + +void DeathFx_Delete(DeathFxObject* this) { + DeleteThisEntity(); +}