From 2369df881f0d6d80c637addce5c8f4ab48c9f8c0 Mon Sep 17 00:00:00 2001 From: notyourav <65437533+notyourav@users.noreply.github.com> Date: Wed, 2 Mar 2022 15:49:12 -0800 Subject: [PATCH] Revert "Decompile evilSpirit" --- asm/object/evilSpirit.s | 566 +++++++++++++++++++++++++++++++++ assets/assets.json | 5 + data/const/object/evilSpirit.s | 15 + linker.ld | 4 +- src/coord.c | 3 +- src/item/itemGustJar.c | 5 +- src/object/evilSpirit.c | 214 ------------- 7 files changed, 591 insertions(+), 221 deletions(-) create mode 100644 asm/object/evilSpirit.s create mode 100644 data/const/object/evilSpirit.s delete mode 100644 src/object/evilSpirit.c diff --git a/asm/object/evilSpirit.s b/asm/object/evilSpirit.s new file mode 100644 index 00000000..c9e4c0f0 --- /dev/null +++ b/asm/object/evilSpirit.s @@ -0,0 +1,566 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + + thumb_func_start EvilSpirit +EvilSpirit: @ 0x08086284 + push {r4, lr} + adds r4, r0, #0 + ldr r1, _080862B4 @ =gUnk_08120668 + ldrb r0, [r4, #0xc] + lsls r0, r0, #2 + adds r0, r0, r1 + ldr r1, [r0] + adds r0, r4, #0 + bl _call_via_r1 + adds r1, r4, #0 + adds r1, #0x41 + movs r0, #0 + strb r0, [r1] + adds r0, r4, #0 + adds r0, #0x76 + ldrh r1, [r0] + adds r0, #4 + ldrh r2, [r0] + adds r0, r4, #0 + movs r3, #0 + bl sub_0805EC9C + pop {r4, pc} + .align 2, 0 +_080862B4: .4byte gUnk_08120668 + + thumb_func_start sub_080862B8 +sub_080862B8: @ 0x080862B8 + push {r4, r5, lr} + adds r4, r0, #0 + movs r0, #0x63 + bl CheckLocalFlag + cmp r0, #0 + beq _080862CA + bl DeleteThisEntity +_080862CA: + movs r3, #1 + strb r3, [r4, #0xc] + ldr r1, _08086350 @ =gUnk_08120678 + ldrb r0, [r4, #0xa] + lsls r0, r0, #1 + adds r0, r0, r1 + ldrh r0, [r0] + adds r1, r4, #0 + adds r1, #0x7c + strh r0, [r1] + adds r2, r4, #0 + adds r2, #0x76 + strh r0, [r2] + ldrh r0, [r1] + subs r1, #2 + strh r0, [r1] + ldrb r0, [r4, #0xa] + cmp r0, #0 + bne _08086354 + adds r1, #6 + ldr r0, [r4, #0x2c] + str r0, [r1] + adds r1, #4 + ldr r0, [r4, #0x30] + str r0, [r1] + ldrb r1, [r4, #0x19] + movs r0, #0x3f + ands r0, r1 + strb r0, [r4, #0x19] + str r4, [r4, #0x50] + ldrb r0, [r4, #0x10] + movs r1, #0x80 + orrs r0, r1 + strb r0, [r4, #0x10] + adds r1, r4, #0 + adds r1, #0x3c + movs r0, #7 + strb r0, [r1] + adds r0, r4, #0 + adds r0, #0x3f + strb r3, [r0] + subs r1, #1 + movs r0, #4 + strb r0, [r1] + movs r2, #0 +_08086324: + adds r5, r2, #1 + adds r0, r4, #0 + movs r1, #0x18 + adds r2, r5, #0 + movs r3, #0 + bl CreateObjectWithParent + adds r1, r0, #0 + str r1, [r4, #0x54] + cmp r1, #0 + beq _08086346 + ldr r0, [r4, #0x50] + str r0, [r1, #0x50] + ldr r0, [r4, #0x54] + str r4, [r0, #0x54] + ldr r0, [r4, #0x54] + str r0, [r4, #0x50] +_08086346: + adds r2, r5, #0 + cmp r2, #3 + bls _08086324 + b _08086360 + .align 2, 0 +_08086350: .4byte gUnk_08120678 +_08086354: + ldrb r0, [r4, #0x19] + movs r1, #0x3f + ands r1, r0 + movs r0, #0x40 + orrs r1, r0 + strb r1, [r4, #0x19] +_08086360: + ldrb r1, [r4, #0xa] + adds r0, r4, #0 + bl InitializeAnimation + adds r0, r4, #0 + bl sub_08086370 + pop {r4, r5, pc} + + thumb_func_start sub_08086370 +sub_08086370: @ 0x08086370 + push {r4, r5, r6, lr} + adds r6, r0, #0 + ldrb r2, [r6, #0xa] + cmp r2, #0 + beq _08086440 + ldr r0, [r6, #0x54] + adds r0, #0x7f + ldrb r0, [r0] + cmp r0, #0 + bne _080863B6 + adds r1, r6, #0 + adds r1, #0x7c + ldrh r0, [r1] + adds r2, r6, #0 + adds r2, #0x76 + strh r0, [r2] + ldrh r0, [r1] + subs r1, #2 + strh r0, [r1] + movs r0, #0xc0 + lsls r0, r0, #2 + strh r0, [r6, #0x24] + ldr r2, [r6, #0x50] + ldr r0, [r2, #0x2c] + ldr r1, [r6, #0x2c] + subs r0, r0, r1 + ldr r1, [r2, #0x30] + ldr r2, [r6, #0x30] + subs r1, r1, r2 + bl sub_080045DA + movs r1, #0x80 + eors r0, r1 + strb r0, [r6, #0x15] + b _08086428 +_080863B6: + movs r0, #0xc0 + lsls r0, r0, #3 + strh r0, [r6, #0x24] + ldr r2, _080863E8 @ =gPlayerEntity + ldr r0, [r2, #0x2c] + ldr r1, [r6, #0x2c] + subs r0, r0, r1 + ldr r1, [r2, #0x30] + ldr r2, [r6, #0x30] + subs r1, r1, r2 + bl sub_080045DA + adds r1, r0, #0 + movs r0, #0x80 + eors r1, r0 + ldrb r2, [r6, #0x15] + cmp r1, r2 + beq _080863F0 + subs r0, r1, r2 + lsls r0, r0, #0x18 + lsrs r0, r0, #0x18 + cmp r0, #0x80 + bls _080863EC + adds r0, r2, #3 + b _080863EE + .align 2, 0 +_080863E8: .4byte gPlayerEntity +_080863EC: + subs r0, r2, #3 +_080863EE: + strb r0, [r6, #0x15] +_080863F0: + ldr r0, _0808640C @ =gPlayerEntity + ldrb r1, [r0, #0x14] + movs r0, #2 + ands r0, r1 + cmp r0, #0 + bne _08086410 + adds r0, r6, #0 + adds r0, #0x7c + ldrh r0, [r0] + adds r0, #0x40 + adds r1, r6, #0 + adds r1, #0x76 + b _08086426 + .align 2, 0 +_0808640C: .4byte gPlayerEntity +_08086410: + adds r0, r6, #0 + adds r0, #0x7c + ldrh r1, [r0] + subs r1, #0x20 + adds r2, r6, #0 + adds r2, #0x76 + strh r1, [r2] + ldrh r0, [r0] + adds r0, #0x50 + adds r1, r6, #0 + adds r1, #0x7a +_08086426: + strh r0, [r1] +_08086428: + ldr r1, [r6, #0x50] + ldr r0, [r1, #0x2c] + str r0, [r6, #0x2c] + ldr r0, [r1, #0x30] + str r0, [r6, #0x30] + movs r0, #0x24 + ldrsh r1, [r6, r0] + ldrb r2, [r6, #0x15] + adds r0, r6, #0 + bl LinearMoveAngle + b _0808654A +_08086440: + adds r0, r6, #0 + adds r0, #0x41 + ldrb r1, [r0] + movs r0, #0x7f + ands r0, r1 + cmp r0, #0x13 + bne _08086498 + ldrb r0, [r6, #0x15] + adds r0, #1 + strb r0, [r6, #0x15] + ldrb r0, [r6, #0x1d] + subs r0, #1 + strb r0, [r6, #0x1d] + adds r2, r6, #0 + adds r2, #0x7f + movs r0, #1 + strb r0, [r2] + ldr r0, _08086480 @ =gPlayerEntity + ldrb r1, [r0, #0x14] + movs r0, #2 + ands r0, r1 + adds r3, r2, #0 + cmp r0, #0 + bne _08086484 + adds r0, r6, #0 + adds r0, #0x7c + ldrh r0, [r0] + adds r0, #0x10 + adds r1, r6, #0 + adds r1, #0x76 + strh r0, [r1] + b _080864BC + .align 2, 0 +_08086480: .4byte gPlayerEntity +_08086484: + adds r1, r6, #0 + adds r1, #0x7c + ldrh r0, [r1] + subs r0, #0x20 + adds r2, r6, #0 + adds r2, #0x76 + strh r0, [r2] + ldrh r0, [r1] + adds r0, #0x30 + b _080864B6 +_08086498: + ldrb r0, [r6, #0x15] + adds r0, #2 + strb r0, [r6, #0x15] + movs r0, #0xf0 + strb r0, [r6, #0x1d] + adds r3, r6, #0 + adds r3, #0x7f + strb r2, [r3] + adds r1, r6, #0 + adds r1, #0x7c + ldrh r0, [r1] + adds r2, r6, #0 + adds r2, #0x76 + strh r0, [r2] + ldrh r0, [r1] +_080864B6: + subs r1, #2 + strh r0, [r1] + adds r1, r2, #0 +_080864BC: + ldrb r2, [r6, #0x1d] + cmp r2, #0 + bne _080864CA + movs r0, #2 + strb r0, [r6, #0xc] + strb r2, [r3] + b _0808654A +_080864CA: + ldrb r0, [r6, #0x15] + adds r0, #0x40 + lsls r0, r0, #0x18 + cmp r0, #0 + blt _080864E0 + ldrh r2, [r1] + movs r3, #0 + ldrsh r0, [r1, r3] + cmp r0, #0 + ble _080864EE + b _080864EA +_080864E0: + ldrh r2, [r1] + movs r3, #0 + ldrsh r0, [r1, r3] + cmp r0, #0 + bge _080864EE +_080864EA: + rsbs r0, r2, #0 + strh r0, [r1] +_080864EE: + ldr r5, _0808654C @ =gSineTable + ldrb r0, [r6, #0x15] + lsls r0, r0, #1 + adds r0, r0, r5 + movs r1, #0 + ldrsh r0, [r0, r1] + movs r1, #0x80 + lsls r1, r1, #6 + bl FixedMul + lsls r0, r0, #0x10 + asrs r0, r0, #0x10 + movs r4, #0x80 + lsls r4, r4, #1 + adds r1, r4, #0 + bl FixedDiv + adds r1, r6, #0 + adds r1, #0x80 + lsls r0, r0, #0x10 + asrs r0, r0, #8 + ldr r1, [r1] + adds r1, r1, r0 + str r1, [r6, #0x2c] + ldrb r0, [r6, #0x15] + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r5 + movs r3, #0 + ldrsh r0, [r0, r3] + movs r1, #0x80 + lsls r1, r1, #5 + bl FixedMul + lsls r0, r0, #0x10 + asrs r0, r0, #0x10 + adds r1, r4, #0 + bl FixedDiv + adds r1, r6, #0 + adds r1, #0x84 + lsls r0, r0, #0x10 + asrs r0, r0, #8 + ldr r1, [r1] + subs r1, r1, r0 + str r1, [r6, #0x30] +_0808654A: + pop {r4, r5, r6, pc} + .align 2, 0 +_0808654C: .4byte gSineTable + + thumb_func_start sub_08086550 +sub_08086550: @ 0x08086550 + push {r4, r5, lr} + adds r4, r0, #0 + adds r0, #0x41 + ldrb r1, [r0] + movs r0, #0x7f + ands r0, r1 + cmp r0, #0x13 + beq _08086566 + movs r0, #3 + strb r0, [r4, #0xc] + b _08086592 +_08086566: + adds r0, r4, #0 + bl sub_0806F3E4 + cmp r0, #0 + beq _08086592 + movs r0, #0x63 + bl SetLocalFlag + movs r0, #0 + bl SetRoomFlag + movs r5, #0 +_0808657E: + ldr r0, [r4, #0x54] + ldr r1, [r0, #0x50] + str r1, [r4, #0x54] + bl DeleteEntity + adds r5, #1 + cmp r5, #3 + bls _0808657E + bl DeleteThisEntity +_08086592: + pop {r4, r5, pc} + + thumb_func_start sub_08086594 +sub_08086594: @ 0x08086594 + push {r4, r5, r6, r7, lr} + adds r7, r0, #0 + adds r0, #0x80 + ldr r0, [r0] + ldr r1, [r7, #0x2c] + subs r0, r0, r1 + adds r1, r7, #0 + adds r1, #0x84 + ldr r1, [r1] + ldr r2, [r7, #0x30] + subs r1, r1, r2 + bl sub_080045DA + strb r0, [r7, #0x15] + adds r0, r7, #0 + adds r0, #0x41 + ldrb r1, [r0] + movs r0, #0x7f + ands r0, r1 + cmp r0, #0x13 + bne _08086608 + movs r0, #0x80 + lsls r0, r0, #1 + strh r0, [r7, #0x24] + ldrb r0, [r7, #0x1d] + subs r0, #1 + strb r0, [r7, #0x1d] + adds r2, r7, #0 + adds r2, #0x7f + movs r0, #1 + strb r0, [r2] + ldr r0, _080865EC @ =gPlayerEntity + ldrb r1, [r0, #0x14] + movs r0, #2 + ands r0, r1 + cmp r0, #0 + bne _080865F0 + adds r0, r7, #0 + adds r0, #0x7c + ldrh r0, [r0] + adds r0, #0x10 + adds r1, r7, #0 + adds r1, #0x76 + b _0808662A + .align 2, 0 +_080865EC: .4byte gPlayerEntity +_080865F0: + adds r0, r7, #0 + adds r0, #0x7c + ldrh r1, [r0] + subs r1, #0x20 + adds r3, r7, #0 + adds r3, #0x76 + strh r1, [r3] + ldrh r0, [r0] + adds r0, #0x30 + adds r1, r7, #0 + adds r1, #0x7a + b _0808662A +_08086608: + movs r1, #0 + movs r0, #0x80 + lsls r0, r0, #2 + strh r0, [r7, #0x24] + movs r0, #0xf0 + strb r0, [r7, #0x1d] + adds r2, r7, #0 + adds r2, #0x7f + strb r1, [r2] + adds r1, r7, #0 + adds r1, #0x7c + ldrh r0, [r1] + adds r3, r7, #0 + adds r3, #0x76 + strh r0, [r3] + ldrh r0, [r1] + subs r1, #2 +_0808662A: + strh r0, [r1] + ldrb r1, [r7, #0x1d] + cmp r1, #0 + bne _0808663A + movs r0, #2 + strb r0, [r7, #0xc] + strb r1, [r2] + b _080866B8 +_0808663A: + movs r0, #0x24 + ldrsh r1, [r7, r0] + ldrb r2, [r7, #0x15] + adds r0, r7, #0 + bl LinearMoveAngle + ldrb r0, [r7, #0x15] + movs r1, #0x80 + eors r0, r1 + strb r0, [r7, #0x15] + ldr r6, _080866BC @ =gSineTable + ldrb r0, [r7, #0x15] + lsls r0, r0, #1 + adds r0, r0, r6 + movs r1, #0 + ldrsh r0, [r0, r1] + movs r1, #0x80 + lsls r1, r1, #6 + bl FixedMul + lsls r0, r0, #0x10 + asrs r0, r0, #0x10 + movs r5, #0x80 + lsls r5, r5, #1 + adds r1, r5, #0 + bl FixedDiv + adds r1, r7, #0 + adds r1, #0x80 + lsls r0, r0, #0x10 + asrs r0, r0, #8 + ldr r4, [r1] + adds r4, r4, r0 + ldrb r0, [r7, #0x15] + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r6 + movs r1, #0 + ldrsh r0, [r0, r1] + movs r1, #0x80 + lsls r1, r1, #5 + bl FixedMul + lsls r0, r0, #0x10 + asrs r0, r0, #0x10 + adds r1, r5, #0 + bl FixedDiv + adds r1, r7, #0 + adds r1, #0x84 + lsls r0, r0, #0x10 + asrs r0, r0, #8 + ldr r2, [r1] + subs r2, r2, r0 + adds r0, r7, #0 + adds r1, r4, #0 + movs r3, #2 + bl EntityWithinDistance + cmp r0, #0 + beq _080866B8 + movs r0, #1 + strb r0, [r7, #0xc] +_080866B8: + pop {r4, r5, r6, r7, pc} + .align 2, 0 +_080866BC: .4byte gSineTable diff --git a/assets/assets.json b/assets/assets.json index c337b482..c4c1c7a2 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -42769,6 +42769,11 @@ "start": 1181272, "size": 8 }, + { + "path": "evilSpirit/gUnk_08120678.bin", + "start": 1181304, + "size": 10 + }, { "path": "animations/gSpriteAnimations_EvilSpirit_0.bin", "start": 1181314, diff --git a/data/const/object/evilSpirit.s b/data/const/object/evilSpirit.s new file mode 100644 index 00000000..81dbaa64 --- /dev/null +++ b/data/const/object/evilSpirit.s @@ -0,0 +1,15 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + +gUnk_08120668:: @ 08120668 + .4byte sub_080862B8 + .4byte sub_08086370 + .4byte sub_08086550 + .4byte sub_08086594 + +gUnk_08120678:: @ 08120678 + .incbin "evilSpirit/gUnk_08120678.bin" + diff --git a/linker.ld b/linker.ld index e283aee6..53999ff4 100644 --- a/linker.ld +++ b/linker.ld @@ -666,7 +666,7 @@ SECTIONS { asm/object/object15.o(.text); asm/object/floatingPlatform.o(.text); asm/object/object17.o(.text); - src/object/evilSpirit.o(.text); + asm/object/evilSpirit.o(.text); src/object/houseDoorExterior.o(.text); src/object/rupee.o(.text); src/object/greatFairy.o(.text); @@ -1387,7 +1387,7 @@ SECTIONS { data/const/object/object15.o(.rodata); data/const/object/floatingPlatform.o(.rodata); data/const/object/object17.o(.rodata); - src/object/evilSpirit.o(.rodata); + data/const/object/evilSpirit.o(.rodata); data/animations/object/evilSpirit.o(.rodata); data/const/object/houseDoorExterior.o(.rodata); src/object/rupee.o(.rodata); diff --git a/src/coord.c b/src/coord.c index 9a6a6ce5..0bce952b 100644 --- a/src/coord.c +++ b/src/coord.c @@ -7,7 +7,6 @@ #include "room.h" #include "functions.h" #include "color.h" -#include "playeritem.h" const u8 gSpriteSortAboveTable[]; const u8 gSpriteSortBelowTable[]; @@ -89,7 +88,7 @@ u32 sub_0806F3E4(Entity* ent) { ent->subAction = 3; (Entity*)gPlayerEntity.field_0x70.WORD = ent; gPlayerState.field_0x1c = 7; - item = CreatePlayerItem(PLAYER_ITEM_11, 0, 0, 0); + item = CreatePlayerItem(0x11, 0, 0, 0); if (item != NULL) { item->child = ent; ent->parent = item; diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c index eb70ffe3..60d9bb89 100644 --- a/src/item/itemGustJar.c +++ b/src/item/itemGustJar.c @@ -2,7 +2,6 @@ #include "entity.h" #include "item.h" #include "functions.h" -#include "playeritem.h" void (*const ItemGustJar_StateFunctions[])(ItemBehavior* beh, u32); extern u32 sub_0807A894(Entity*); @@ -103,7 +102,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { gPlayerState.field_0xa &= ~(8 >> arg1); this->stateID = 2; sub_08077DF4(this, 0x504); - item = CreatePlayerItem(PLAYER_ITEM_10, 0, 0, 0); + item = CreatePlayerItem(0x10, 0, 0, 0); if (item) { item->parent = player; } @@ -141,7 +140,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { gPlayerState.field_0x1c = 5; gPlayerEntity.field_0x70.WORD = 0; if (gPlayerState.field_0x1d) { - CreatePlayerItem(PLAYER_ITEM_11, 0, 0, 0); + CreatePlayerItem(0x11, 0, 0, 0); } } diff --git a/src/object/evilSpirit.c b/src/object/evilSpirit.c deleted file mode 100644 index 39fa5cd9..00000000 --- a/src/object/evilSpirit.c +++ /dev/null @@ -1,214 +0,0 @@ -#define NENT_DEPRECATED -#include "entity.h" -#include "functions.h" -#include "flags.h" -#include "object.h" - -typedef struct { - Entity base; - u8 filler[0xe]; - u16 unk76; - u16 unk78; - u16 unk7a; - u16 unk7c; - u8 filler2; - u8 unk7f; - s32 x; - s32 y; -} EvilSpiritEntity; - -void EvilSpirit_Init(EvilSpiritEntity*); -void EvilSpirit_Action1(EvilSpiritEntity*); -void EvilSpirit_Action2(EvilSpiritEntity*); -void EvilSpirit_Action3(EvilSpiritEntity*); - -void EvilSpirit(Entity* this) { - static void (*const EvilSpirit_Actions[])(EvilSpiritEntity*) = { - EvilSpirit_Init, - EvilSpirit_Action1, - EvilSpirit_Action2, - EvilSpirit_Action3, - }; - EvilSpirit_Actions[this->action]((EvilSpiritEntity*)this); - this->bitfield = 0; - sub_0805EC9C(this, ((EvilSpiritEntity*)this)->unk76, ((EvilSpiritEntity*)this)->unk7a, 0); -} - -void EvilSpirit_Init(EvilSpiritEntity* this) { - static const u16 gUnk_08120678[] = { 0x100, 0x110, 0x150, 0x1c0, 0x200 }; - u32 uVar1; - Entity* evilSpiritEnt; - u32 index; - - if (CheckLocalFlag(SORA_ELDER_RECOVER)) { - DeleteThisEntity(); - } - super->action = 1; - uVar1 = gUnk_08120678[super->type]; - this->unk7c = uVar1; - this->unk76 = uVar1; - this->unk7a = this->unk7c; - if (super->type == 0) { - this->x = super->x.WORD; - this->y = super->y.WORD; - super->spriteRendering.b3 = 0; - super->parent = super; - COLLISION_ON(super); - super->field_0x3c = 7; - super->hitType = 1; - super->flags2 = 4; - for (index = 0; index < 4; index++) { - evilSpiritEnt = CreateObjectWithParent(super, EVIL_SPIRIT, index + 1, 0); - super->child = evilSpiritEnt; - if (evilSpiritEnt != NULL) { - evilSpiritEnt->parent = super->parent; - super->child->child = super; - super->parent = super->child; - } - } - } else { - super->spriteRendering.b3 = 1; - } - InitializeAnimation(super, super->type); - EvilSpirit_Action1(this); -} - -void EvilSpirit_Action1(EvilSpiritEntity* this) { - s32 sVar3; - u32 dir; - s16 iVar5; - - if (super->type != 0) { - if (((EvilSpiritEntity*)super->child)->unk7f == 0) { - this->unk76 = this->unk7c; - this->unk7a = this->unk7c; - super->speed = 0x300; - super->direction = - sub_080045DA(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80; - } else { - super->speed = 0x600; - dir = sub_080045DA(gPlayerEntity.x.WORD - super->x.WORD, gPlayerEntity.y.WORD - super->y.WORD) ^ 0x80; - if (dir != super->direction) { - if ((u8)(dir - super->direction) > 0x80) { - super->direction += 3; - } else { - super->direction -= 3; - } - } - if ((gPlayerEntity.animationState & 2) == 0) { - this->unk76 = this->unk7c + 0x40; - } else { - this->unk76 = this->unk7c - 0x20; - this->unk7a = this->unk7c + 0x50; - ; - } - } - super->x = super->parent->x; - super->y = super->parent->y; - LinearMoveAngle(super, (int)super->speed, super->direction); - return; - } - - if ((super->bitfield & 0x7f) == 0x13) { - super->direction++; - super->field_0x1d--; - this->unk7f = 1; - if ((gPlayerEntity.animationState & 2) == 0) { - this->unk76 = this->unk7c + 0x10; - } else { - this->unk76 = this->unk7c - 0x20; - this->unk7a = this->unk7c + 0x30; - } - } else { - super->direction = super->direction + 2; - super->field_0x1d = 0xf0; - this->unk7f = 0; - this->unk76 = this->unk7c; - this->unk7a = this->unk7c; - } - - if (super->field_0x1d == 0) { - super->action = 2; - this->unk7f = 0; - return; - } - - if ((super->direction + 0x40) * 0x1000000 >= 0) { - sVar3 = this->unk76; - if ((short)this->unk76 >= 1) { - this->unk76 = -sVar3; - } - } else { - sVar3 = this->unk76; - if (-1 >= (short)this->unk76) { - this->unk76 = -sVar3; - } - } - - sVar3 = FixedMul(gSineTable[super->direction], 0x2000); - iVar5 = FixedDiv(sVar3, 0x100); - super->x.WORD = this->x + (iVar5 << 8); - sVar3 = FixedMul(gSineTable[super->direction + 0x40], 0x1000); - iVar5 = FixedDiv(sVar3, 0x100); - super->y.WORD = this->y - (iVar5 << 8); -} - -void EvilSpirit_Action2(EvilSpiritEntity* this) { - u32 index; - - if ((super->bitfield & 0x7f) != 0x13) { - super->action = 3; - } else { - if (sub_0806F3E4(super)) { - SetLocalFlag(SORA_ELDER_RECOVER); - SetRoomFlag(0); - - for (index = 0; index < 4; index++) { - Entity* ent = super->child; - super->child = ent->parent; - DeleteEntity(ent); - } - DeleteThisEntity(); - } - } -} - -void EvilSpirit_Action3(EvilSpiritEntity* this) { - short sVar2; - short iVar4; - int iVar6; - - super->direction = sub_080045DA(this->x - super->x.WORD, this->y - super->y.WORD); - if ((super->bitfield & 0x7f) == 0x13) { - super->speed = 0x100; - super->field_0x1d--; - this->unk7f = 1; - - if ((gPlayerEntity.animationState & 2) == 0) { - this->unk76 = this->unk7c + 0x10; - } else { - this->unk76 = this->unk7c - 0x20; - this->unk7a = this->unk7c + 0x30; - } - } else { - super->speed = 0x200; - super->field_0x1d = 0xf0; - this->unk7f = 0; - this->unk76 = this->unk7c; - this->unk7a = this->unk7c; - } - - if (super->field_0x1d == 0) { - super->action = 2; - this->unk7f = 0; - } else { - LinearMoveAngle(super, super->speed, super->direction); - super->direction ^= 0x80; - sVar2 = FixedMul(gSineTable[super->direction], 0x2000); - iVar6 = this->x + (FixedDiv(sVar2, 0x100) << 8); - sVar2 = FixedMul(gSineTable[super->direction + 0x40], 0x1000); - if (EntityWithinDistance(super, iVar6, this->y - (FixedDiv(sVar2, 0x100) << 8), 2)) { - super->action = 1; - } - } -}