diff --git a/asm/object/houseDoorInterior.s b/asm/object/houseDoorInterior.s deleted file mode 100644 index 70f542b4..00000000 --- a/asm/object/houseDoorInterior.s +++ /dev/null @@ -1,163 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start HouseDoorInterior -HouseDoorInterior: @ 0x08092B74 - push {lr} - ldr r2, _08092B88 @ =gUnk_081227C0 - ldrb r1, [r0, #0xc] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_08092B88: .4byte gUnk_081227C0 - - thumb_func_start sub_08092B8C -sub_08092B8C: @ 0x08092B8C - push {r4, lr} - adds r4, r0, #0 - adds r1, r4, #0 - adds r1, #0x86 - ldrh r0, [r1] - cmp r0, #0 - beq _08092BA6 - bl CheckFlags - cmp r0, #0 - beq _08092BA6 - bl DeleteThisEntity -_08092BA6: - movs r2, #1 - movs r0, #1 - strb r0, [r4, #0xc] - ldrb r1, [r4, #0x18] - subs r0, #5 - ands r0, r1 - orrs r0, r2 - strb r0, [r4, #0x18] - ldrb r0, [r4, #0xe] - adds r1, r4, #0 - adds r1, #0x7d - strb r0, [r1] - adds r2, r4, #0 - adds r2, #0x29 - ldrb r0, [r2] - movs r1, #7 - orrs r0, r1 - strb r0, [r2] - ldr r0, _08092BE8 @ =gUnk_081227EC - str r0, [r4, #0x48] - movs r0, #8 - strb r0, [r4, #0xe] - ldrb r0, [r4, #0xa] - lsls r0, r0, #1 - ldr r1, _08092BEC @ =gUnk_081227B4 - adds r2, r0, r1 - ldrb r1, [r2] - adds r0, r1, #0 - cmp r0, #0xff - bne _08092BF0 - ldrb r0, [r4, #0xb] - strb r0, [r4, #0x1e] - b _08092BF6 - .align 2, 0 -_08092BE8: .4byte gUnk_081227EC -_08092BEC: .4byte gUnk_081227B4 -_08092BF0: - strb r1, [r4, #0x1e] - ldrb r0, [r2, #1] - strb r0, [r4, #0xb] -_08092BF6: - pop {r4, pc} - - thumb_func_start sub_08092BF8 -sub_08092BF8: @ 0x08092BF8 - push {r4, r5, lr} - adds r4, r0, #0 - adds r1, r4, #0 - adds r1, #0x86 - ldrh r0, [r1] - cmp r0, #0 - beq _08092C20 - bl CheckFlags - cmp r0, #0 - beq _08092C20 - movs r0, #2 - strb r0, [r4, #0xc] - ldr r0, _08092C1C @ =0x00000111 - bl SoundReq - b _08092C92 - .align 2, 0 -_08092C1C: .4byte 0x00000111 -_08092C20: - adds r0, r4, #0 - bl sub_0800445C - cmp r0, #0 - beq _08092C74 - adds r0, r4, #0 - adds r0, #0x7d - ldrb r0, [r0] - cmp r0, #0 - bne _08092C74 - ldrb r0, [r4, #0xb] - lsls r0, r0, #3 - ldr r1, _08092C68 @ =gUnk_081227CC - adds r5, r0, r1 - ldrh r1, [r5, #4] - ldrh r2, [r5, #6] - adds r0, r4, #0 - bl sub_0806ED9C - cmp r0, #0 - blt _08092C78 - ldr r1, _08092C6C @ =gPlayerEntity - ldrh r0, [r5] - ldrb r1, [r1, #0x14] - cmp r0, r1 - bne _08092C78 - ldr r0, _08092C70 @ =gPlayerState - adds r0, #0x90 - ldrh r1, [r0] - ldrh r0, [r5, #2] - ands r0, r1 - cmp r0, #0 - beq _08092C78 - ldrb r0, [r4, #0xe] - subs r0, #1 - b _08092C76 - .align 2, 0 -_08092C68: .4byte gUnk_081227CC -_08092C6C: .4byte gPlayerEntity -_08092C70: .4byte gPlayerState -_08092C74: - movs r0, #8 -_08092C76: - strb r0, [r4, #0xe] -_08092C78: - ldrb r0, [r4, #0xe] - cmp r0, #0 - bne _08092C92 - movs r0, #2 - strb r0, [r4, #0xc] - movs r0, #8 - movs r1, #0 - movs r2, #0 - bl sub_08078AC0 - ldr r0, _08092C94 @ =0x00000111 - bl SoundReq -_08092C92: - pop {r4, r5, pc} - .align 2, 0 -_08092C94: .4byte 0x00000111 - - thumb_func_start sub_08092C98 -sub_08092C98: @ 0x08092C98 - push {lr} - bl DeleteThisEntity - pop {pc} diff --git a/assets/assets.json b/assets/assets.json index 1ceb7ce0..2423e92b 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -44081,21 +44081,6 @@ "size": 4, "type": "animation" }, - { - "path": "houseDoorInterior/gUnk_081227B4.bin", - "start": 1189812, - "size": 12 - }, - { - "path": "houseDoorInterior/gUnk_081227CC.bin", - "start": 1189836, - "size": 32 - }, - { - "path": "houseDoorInterior/gUnk_081227EC.bin", - "start": 1189868, - "size": 8 - }, { "path": "animations/gSpriteAnimations_Whirlwind_0.bin", "start": 1189888, diff --git a/data/const/object/houseDoorInterior.s b/data/const/object/houseDoorInterior.s deleted file mode 100644 index 1404f8f6..00000000 --- a/data/const/object/houseDoorInterior.s +++ /dev/null @@ -1,20 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_081227B4:: @ 081227B4 - .incbin "houseDoorInterior/gUnk_081227B4.bin" - -gUnk_081227C0:: @ 081227C0 - .4byte sub_08092B8C - .4byte sub_08092BF8 - .4byte sub_08092C98 - -gUnk_081227CC:: @ 081227CC - .incbin "houseDoorInterior/gUnk_081227CC.bin" - -gUnk_081227EC:: @ 081227EC - .incbin "houseDoorInterior/gUnk_081227EC.bin" - diff --git a/include/npc.h b/include/npc.h index 1b84e617..cfe0f9cf 100644 --- a/include/npc.h +++ b/include/npc.h @@ -22,9 +22,9 @@ void sub_0806EC20(Entity* ent); void sub_0806EC38(void); u32 sub_0806ED78(Entity* ent); -s32 sub_0806ED9C(Entity*, u32, u32); +s32 GetAnimationStateInRectRadius(Entity*, u32, u32); u32 GetAnimationState(Entity* ent); -s32 sub_0806EDD8(Entity* ent, u32 x, u32 y); +s32 GetFacingDirectionInRectRadius(Entity* ent, u32 x, u32 y); void sub_0806EE04(Entity* ent, void* a2, u32 a3); u32 sub_0806EE20(Entity* ent); s32 sub_0806F078(Entity* ent, s32 a2); diff --git a/linker.ld b/linker.ld index 9ede4d17..33db833d 100644 --- a/linker.ld +++ b/linker.ld @@ -718,7 +718,7 @@ SECTIONS { asm/object/paper.o(.text); asm/object/object5B.o(.text); src/object/mask.o(.text); - asm/object/houseDoorInterior.o(.text); + src/object/houseDoorInterior.o(.text); src/object/whirlwind.o(.text); asm/object/objectBlockingStairs.o(.text); src/object/swordsmanNewsletter.o(.text); @@ -1461,7 +1461,7 @@ SECTIONS { data/const/object/paper.o(.rodata); data/const/object/object5B.o(.rodata); data/const/object/mask.o(.rodata); - data/const/object/houseDoorInterior.o(.rodata); + src/object/houseDoorInterior.o(.rodata); src/object/whirlwind.o(.rodata); data/animations/object/whirlwind.o(.rodata); data/const/object/objectBlockingStairs.o(.rodata); diff --git a/src/npc/beedle.c b/src/npc/beedle.c index c2c75cc8..ee5a33ac 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -78,7 +78,7 @@ void sub_08063390(Entity* this) { s32 sub_080633C8(Entity* this) { s32 uVar1; - uVar1 = sub_0806ED9C(this, 0x20, 0x20); + uVar1 = GetAnimationStateInRectRadius(this, 0x20, 0x20); if (uVar1 < 0) { uVar1 = this->animIndex; } diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 38cb9276..49aefdfe 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -70,7 +70,7 @@ void sub_08068A4C(Entity* this) { s32 uVar1; s32 iVar2; - uVar1 = sub_0806ED9C(this, 0x28, 0x28); + uVar1 = GetAnimationStateInRectRadius(this, 0x28, 0x28); if (uVar1 < 0) { uVar1 = 2; } else { diff --git a/src/npc/brocco.c b/src/npc/brocco.c index 794acd30..176f1e42 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -36,7 +36,7 @@ void sub_0806355C(Entity* this) { } void sub_08063584(Entity* this) { - if (sub_0806ED9C(this, 0x20, 0x20) >= 0) { + if (GetAnimationStateInRectRadius(this, 0x20, 0x20) >= 0) { if (this->field_0xf == 0) { if ((Random() & 0x3f) == 0) { this->field_0xf = 1; diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 3de83cc3..65f2ff56 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -104,7 +104,7 @@ void sub_08060158(Entity* this) { this->actionDelay--; } else { this->actionDelay = 2; - index = sub_0806EDD8(this, 0x20, 0x20); + index = GetFacingDirectionInRectRadius(this, 0x20, 0x20); if (index < 0) { int state = this->field_0x68.HALF.HI; this->animationState = state; diff --git a/src/npc/gorman.c b/src/npc/gorman.c index af735017..52ec2316 100644 --- a/src/npc/gorman.c +++ b/src/npc/gorman.c @@ -44,7 +44,7 @@ void sub_080697C4(Entity* this) { void sub_080697EC(Entity* this) { s32 tmp; - tmp = sub_0806ED9C(this, 0x20, 0x20); + tmp = GetAnimationStateInRectRadius(this, 0x20, 0x20); if (tmp >= 0) { if (this->field_0xf == 0) { this->field_0xf = 0x10; diff --git a/src/npc/goron.c b/src/npc/goron.c index 04602ffd..b6c943e5 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -29,7 +29,7 @@ void sub_08069328(Entity* this) { int action; this->field_0xf = 0; - action = sub_0806ED9C(this, 40, 40); + action = GetAnimationStateInRectRadius(this, 40, 40); if (action >= 0) { this->animationState = action; } diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 0aae9b37..a0d29023 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -38,7 +38,7 @@ void sub_080695AC(Entity* this) { if (++this->field_0xf > 0x10) { this->field_0xf = 0; - iVar2 = sub_0806ED9C(this, 0x28, 0x28); + iVar2 = GetAnimationStateInRectRadius(this, 0x28, 0x28); if (iVar2 > -1) { this->animationState = iVar2; } diff --git a/src/npc/kingDaltus.c b/src/npc/kingDaltus.c index d716d951..b39db01f 100644 --- a/src/npc/kingDaltus.c +++ b/src/npc/kingDaltus.c @@ -33,7 +33,7 @@ void sub_08066654(Entity* this) { } void sub_08066688(Entity* this) { - s32 tmp = sub_0806ED9C(this, 0x28, 0x28); + s32 tmp = GetAnimationStateInRectRadius(this, 0x28, 0x28); if (tmp < 0) { tmp = 2; } else { diff --git a/src/npc/melari.c b/src/npc/melari.c index 5fe4a280..37f97286 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -30,7 +30,7 @@ void sub_08068708(Entity* this) { void sub_08068730(Entity* this) { s32 animIndex; - animIndex = sub_0806ED9C(this, 0x20, 0x20); + animIndex = GetAnimationStateInRectRadius(this, 0x20, 0x20); if (-1 < animIndex) { if (this->field_0xf == 0) { this->field_0xf = 0x10; @@ -123,7 +123,7 @@ void sub_08068910(Entity* this) { } else { this->actionDelay = 0x10; if ((this->frame & 0x20) != 0) { - iVar1 = sub_0806EDD8(this, 0x30, 0x30); + iVar1 = GetFacingDirectionInRectRadius(this, 0x30, 0x30); if (iVar1 < 0) { iVar1 = 0x10; } else { diff --git a/src/npc/ministerPotho.c b/src/npc/ministerPotho.c index b0a94bed..282a7985 100644 --- a/src/npc/ministerPotho.c +++ b/src/npc/ministerPotho.c @@ -26,7 +26,7 @@ void sub_080667E4(Entity* this) { } void sub_08066808(Entity* this) { - s32 tmp = sub_0806ED9C(this, 0x28, 0x28); + s32 tmp = GetAnimationStateInRectRadius(this, 0x28, 0x28); if (tmp < 0) { tmp = 2; } else { diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c index 1e7ee149..8c9a24c7 100644 --- a/src/npc/mountainMinish.c +++ b/src/npc/mountainMinish.c @@ -65,7 +65,7 @@ void sub_08067E60(Entity* this) { void sub_08067E88(Entity* this) { s32 tmp; - tmp = sub_0806ED9C(this, 0x28, 0x28); + tmp = GetAnimationStateInRectRadius(this, 0x28, 0x28); if (tmp < 0) { tmp = 2; } else { @@ -195,7 +195,7 @@ void sub_0806811C(Entity* this) { this->actionDelay--; } else { this->actionDelay = 2; - iVar4 = sub_0806EDD8(this, 0x20, 0x20); + iVar4 = GetFacingDirectionInRectRadius(this, 0x20, 0x20); if (iVar4 < 0) { type = this->type; this->animationState = type; diff --git a/src/npc/npc26.c b/src/npc/npc26.c index 3603d246..e52d796e 100644 --- a/src/npc/npc26.c +++ b/src/npc/npc26.c @@ -25,7 +25,7 @@ static void sub_080669DC(Entity* this) { s32 sVar1; s32 sVar2; - sVar1 = sub_0806ED9C(this, 0x28, 0x28); + sVar1 = GetAnimationStateInRectRadius(this, 0x28, 0x28); if (sVar1 < 0) { sVar1 = 2; } else { diff --git a/src/npc/pina.c b/src/npc/pina.c index 3186f3ea..d4eea09e 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -38,7 +38,7 @@ void sub_08063A98(Entity* this) { } void sub_08063AC0(Entity* this) { - if (sub_0806ED9C(this, 0x20, 0x20) >= 0) { + if (GetAnimationStateInRectRadius(this, 0x20, 0x20) >= 0) { if (this->field_0xf == 0) { if ((Random() & 0x3f) == 0) { InitAnimationForceUpdate(this, 0); diff --git a/src/npc/postman.c b/src/npc/postman.c index 63c6fcf1..cc814d46 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -62,7 +62,7 @@ void sub_0806045C(Entity* this) { this->animationState = bVar1; InitAnimationForceUpdate(this, 4 + bVar1); } - temp = sub_0806ED9C(this, 0x18, 0x18); + temp = GetAnimationStateInRectRadius(this, 0x18, 0x18); if ((temp > -1) && (temp == this->animationState)) { bVar3 = 1; } else { diff --git a/src/npc/smith.c b/src/npc/smith.c index 1b922edc..02f9c472 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -64,7 +64,7 @@ void sub_080660EC(Entity* this) { void sub_08066118(Entity* this) { s32 uVar1; - uVar1 = sub_0806ED9C(this, 0x28, 0x28); + uVar1 = GetAnimationStateInRectRadius(this, 0x28, 0x28); if (uVar1 < 0) { uVar1 = 2; } else { diff --git a/src/npc/talon.c b/src/npc/talon.c index 4d8fddd2..87f6b3ad 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -35,7 +35,7 @@ void sub_0806559C(Entity* this) { this->actionDelay++; if (this->actionDelay >= 9) { this->actionDelay = 0; - result = sub_0806ED9C(this, 0x20, 0x20); + result = GetAnimationStateInRectRadius(this, 0x20, 0x20); if (result < 0) { offset = this->animationState + 4; } else { diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 2a461c64..eb7809cc 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -188,7 +188,7 @@ void sub_0806AEE4(Entity* this) { this->actionDelay--; } else { this->actionDelay = 2; - index = sub_0806EDD8(this, 0x20, 0x20); + index = GetFacingDirectionInRectRadius(this, 0x20, 0x20); if (index < 0) { int state = this->field_0x6a.HALF.LO; this->animationState = state * 2; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index a529c80a..401b4a86 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -45,7 +45,7 @@ void sub_08061BC8(Entity* this) { void sub_08061C00(Entity* this) { s32 uVar1; - uVar1 = sub_0806ED9C(this, 0x20, 0x20); + uVar1 = GetAnimationStateInRectRadius(this, 0x20, 0x20); if (uVar1 < 0) { uVar1 = this->animationState + 4; } else { diff --git a/src/npcUtils.c b/src/npcUtils.c index 1fabfe67..3c042b23 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -107,7 +107,7 @@ u32 sub_0806ED78(Entity* ent) { return result; } -s32 sub_0806ED9C(Entity* ent, u32 x, u32 y) { +s32 GetAnimationStateInRectRadius(Entity* ent, u32 x, u32 y) { s32 anim = -1; if (EntityInRectRadius(ent, &gPlayerEntity, x, y)) anim = GetAnimationState(ent); @@ -119,11 +119,11 @@ u32 GetAnimationState(Entity* ent) { return sub_0806F5A4(direction); } -s32 sub_0806EDD8(Entity* ent, u32 x, u32 y) { - s32 anim = -1; +s32 GetFacingDirectionInRectRadius(Entity* ent, u32 x, u32 y) { + s32 dir = -1; if (EntityInRectRadius(ent, &gPlayerEntity, x, y)) - anim = GetFacingDirection(ent, &gPlayerEntity); - return anim; + dir = GetFacingDirection(ent, &gPlayerEntity); + return dir; } void sub_0806EE04(Entity* ent, void* a2, u32 a3) { diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index f7eb966c..1627c7e8 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -164,7 +164,7 @@ void sub_0808692C(Entity* this) { static u8 sub_08086954(Entity* this) { if (sub_0800445C(this)) { - if (sub_0806ED9C(this, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && + if (GetAnimationStateInRectRadius(this, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && (u16)gPlayerState.field_0x90 == 0x400 && gPlayerState.jump_status == 0) { this->actionDelay--; } diff --git a/src/object/houseDoorInterior.c b/src/object/houseDoorInterior.c new file mode 100644 index 00000000..6ca11ef6 --- /dev/null +++ b/src/object/houseDoorInterior.c @@ -0,0 +1,105 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "flags.h" +#include "sound.h" +#include "functions.h" +#include "npc.h" + +typedef struct { + Entity base; + u8 filler[0x15]; + u8 unk7d; + u8 filler2[0x8]; + u16 doorFlags; +} HouseDoorInteriorEntity; + +void HouseDoorInterior_Init(HouseDoorInteriorEntity*); +void HouseDoorInterior_Action1(HouseDoorInteriorEntity*); +void HouseDoorInterior_Delete(HouseDoorInteriorEntity*); + +typedef struct { + u8 frameIndex; + u8 type2; +} PACKED HouseDoorInteriorFrameIndices_struct; + +static const HouseDoorInteriorFrameIndices_struct HouseDoorInteriorFrameIndices[] = { + { -1, 0 }, { -1, 0 }, { 0, 0 }, { 0, 3 }, { 2, 2 }, { 2, 2 }, +}; + +void HouseDoorInterior(Entity* this) { + static void (*const actionFuncs[])(HouseDoorInteriorEntity*) = { + HouseDoorInterior_Init, + HouseDoorInterior_Action1, + HouseDoorInterior_Delete, + }; + actionFuncs[this->action]((HouseDoorInteriorEntity*)this); +} + +typedef struct { + u16 animationState; + u16 unk2; + u16 x; + u16 y; +} gUnk_081227CC_struct; + +static const gUnk_081227CC_struct gUnk_081227CC[] = { + { 0x0, 0x400, 0x6, 0x10 }, + { 0x2, 0x100, 0x10, 0x6 }, + { 0x4, 0x800, 0x6, 0x10 }, + { 0x6, 0x200, 0x10, 0x6 }, +}; + +void HouseDoorInterior_Init(HouseDoorInteriorEntity* this) { + static const Hitbox HouseDoorInteriorHitbox = { + 0, 0, { 5, 3, 3, 5 }, 6, 6, + }; + + const HouseDoorInteriorFrameIndices_struct* ptr; + + if (this->doorFlags && CheckFlags(this->doorFlags)) { + DeleteThisEntity(); + } + super->action = 1; + super->spriteSettings.draw = 1; + this->unk7d = super->actionDelay; + super->spritePriority.b0 = 7; + super->hitbox = (Hitbox*)&HouseDoorInteriorHitbox; + super->actionDelay = 8; + ptr = HouseDoorInteriorFrameIndices + super->type; + if (ptr->frameIndex == 0xff) { + super->frameIndex = super->type2; + } else { + super->frameIndex = ptr->frameIndex; + super->type2 = ptr->type2; + } +} + +void HouseDoorInterior_Action1(HouseDoorInteriorEntity* this) { + const gUnk_081227CC_struct* ptr; + + if (this->doorFlags && CheckFlags(this->doorFlags)) { + super->action = 2; + SoundReq(SFX_111); + return; + } + + if (sub_0800445C(super) && this->unk7d == 0) { + ptr = gUnk_081227CC + super->type2; + if (GetAnimationStateInRectRadius(super, ptr->x, ptr->y) >= 0 && + ptr->animationState == gPlayerEntity.animationState && gPlayerState.field_0x90 & ptr->unk2) { + --super->actionDelay; + } + } else { + super->actionDelay = 8; + } + + if (super->actionDelay == 0) { + super->action = 2; + sub_08078AC0(8, 0, 0); + SoundReq(SFX_111); + } +} + +void HouseDoorInterior_Delete(HouseDoorInteriorEntity* this) { + DeleteThisEntity(); +}