From c6ff4964e53c1070113d0ac59a7b4ef89e0eb685 Mon Sep 17 00:00:00 2001 From: chandler Date: Wed, 15 Jul 2020 17:27:31 -0400 Subject: one non-matching in beedle --- src/npc/beedle.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 src/npc/beedle.c (limited to 'src') diff --git a/src/npc/beedle.c b/src/npc/beedle.c new file mode 100644 index 00000000..5d56a13f --- /dev/null +++ b/src/npc/beedle.c @@ -0,0 +1,171 @@ +#include "global.h" +#include "entity.h" +#include "functions.h" +#include "textbox.h" +#include "link.h" +#include "room.h" + +typedef struct { + u32 unk_00; + s8 unk_04; +} gUnk_0810C89C_struct; + +extern void sub_08078850(Entity*, u32, s8, gUnk_0810C89C_struct*); + +extern u8 gUnk_0810C88C[]; +extern BoundingBox gUnk_0810C894; +extern gUnk_0810C89C_struct gUnk_0810C89C[]; +extern SpriteLoadData gUnk_0810C8D4; +extern void (*gUnk_0810C8E0[])(Entity*); +extern u8 gUnk_0810C8F0[]; + +void sub_080632C8(Entity* this); +void sub_08063410(Entity* this); +s32 sub_080633C8(Entity* this); +void sub_0806346C(Entity* this); + +void Beedle(Entity* this) { + if (this->flags & 0x2) { + sub_08063410(this); + } else { + sub_080632C8(this); + } +} + +void sub_080632C8(Entity* this) { + gUnk_0810C8E0[this->action](this); +} + +void sub_080632E0(Entity* this) { + if (LoadExtraSpriteData(this, &gUnk_0810C8D4) != 0) { + InitializeAnimation(this, 0); + sub_08078778(this); + this->spriteSettings.b.draw = 1; + this->action = 1; + } +} + +#ifdef NON_MATCHING +void sub_08063314(Entity* this) { + u32 offset; + + this->field_0xf++; + if (((this->field_0xf & 0xF) == 0) && (offset = sub_080633C8(this), this->animIndex != offset)) { + InitializeAnimation(this, offset); + } + if (this->interactType != '\0') { + TextboxNoOverlapFollow(this->actionDelay + 0xA01); + this->action++; + } + sub_0806ED78(this); +} +#else +NAKED +void sub_08063314(Entity* this) { + asm(".include \"asm/non_matching/beedle/sub_08063314.inc\""); +} +#endif + +void sub_0806336C(Entity* this) { + if ((gTextBox.doTextBox & 0x7F) == 0) { + this->action++; + InitializeAnimation(this, 8); + } +} + +void sub_08063390(Entity* this) { + GetNextFrame(this); + if (this->frames.b.f3 != 0) { + this->action = 1; + InitializeAnimation(this, GetAnimationState(this)); + sub_08078778(this); + } + sub_0806ED78(this); +} + +s32 sub_080633C8(Entity* this) { + s32 uVar1; + + uVar1 = sub_0806ED9C(this, 0x20, 0x20); + if (uVar1 < 0) { + uVar1 = this->animIndex; + } + return uVar1; +} + +void Beedle_Head(Entity* this) { + SetExtraSpriteFrame(this, 0, this->frames.all & 0x3F); + SetExtraSpriteFrame(this, 1, this->frameIndex); + SetSpriteSubEntryOffsetData1(this, 1, 0); + sub_0807000C(this); +} + +void sub_08063410(Entity* this) { + if (this->action == 0) { + if (LoadExtraSpriteData(this, &gUnk_0810C8D4) == 0) { + return; + } + this->action++; + if (this->entityType.form != 0) { + this->boundingBox = &gUnk_0810C894; + this->entityType.parameter = 0; + } + sub_0807DD64(this); + sub_08078778(this); + } + if (this->entityType.form != 0) { + sub_0806346C(this); + } + sub_0807DDAC(this, 0); + sub_0807DDE4(this); + GetNextFrame(this); +} + +void sub_0806346C(Entity* this) { + u8 bVar1; + s32 iVar2; + s32 iVar3; + + iVar3 = (gLinkEntity.x.HALF.HI - this->x.HALF.HI); + iVar2 = (gLinkEntity.y.HALF.HI - this->y.HALF.HI); + + iVar3 += 0x30; + iVar2 += 0x18; + if (iVar3 < 0) { + iVar3 = 0; + } + if (iVar3 > 0x50) { + iVar3 = 0x50; + } + if (iVar2 < 0) { + iVar2 = 0; + } + if (iVar2 > 0x40) { + iVar2 = 0x40; + } + + iVar3 >>= 4; + iVar2 >>= 4; + + bVar1 = gUnk_0810C8F0[(gLinkEntity.animationState >> 1) + iVar3 * 4 + iVar2 * 0x18]; + if (bVar1 != this->entityType.parameter) { + gUnk_0810C89C_struct* temp = &gUnk_0810C89C[bVar1]; + sub_08078850(this, 1, temp->unk_04, temp); + this->entityType.parameter = bVar1; + } +} + +void sub_080634E4(Entity* this, u32* param_1) { + param_1[1] = this->entityType.parameter; +} + +void sub_080634EC(Entity* this) { + gRoomVars.itemForSaleIndex = gUnk_0810C88C[this->entityType.parameter]; +} + +void sub_08063504(Entity* this, u32* param_2) { + u32 uVar1; + + uVar1 = sub_080544DC(gUnk_0810C88C[this->entityType.parameter]); + param_2[5] = (-uVar1 | uVar1) >> 0x1F; +} -- cgit v1.2.3 From ca5de28b09f4e9e6d2912e91b58aaea421996772 Mon Sep 17 00:00:00 2001 From: chandler Date: Wed, 15 Jul 2020 20:10:22 -0400 Subject: beedle Ok --- src/npc/beedle.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src') diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 5d56a13f..bdcce8c7 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -45,12 +45,10 @@ void sub_080632E0(Entity* this) { } } -#ifdef NON_MATCHING void sub_08063314(Entity* this) { u32 offset; - this->field_0xf++; - if (((this->field_0xf & 0xF) == 0) && (offset = sub_080633C8(this), this->animIndex != offset)) { + if (((++this->field_0xf & 0xF) == 0) && (offset = sub_080633C8(this), this->animIndex != offset)) { InitializeAnimation(this, offset); } if (this->interactType != '\0') { @@ -59,12 +57,6 @@ void sub_08063314(Entity* this) { } sub_0806ED78(this); } -#else -NAKED -void sub_08063314(Entity* this) { - asm(".include \"asm/non_matching/beedle/sub_08063314.inc\""); -} -#endif void sub_0806336C(Entity* this) { if ((gTextBox.doTextBox & 0x7F) == 0) { -- cgit v1.2.3