diff --git a/data/const/npc/beedle.s b/data/const/npc/beedle.s deleted file mode 100644 index 4b053ebd..00000000 --- a/data/const/npc/beedle.s +++ /dev/null @@ -1,27 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810C88C:: @ 0810C88C - .incbin "beedle/gUnk_0810C88C.bin" - -gUnk_0810C894:: @ 0810C894 - .incbin "beedle/gUnk_0810C894.bin" - -gUnk_0810C89C:: @ 0810C89C - .incbin "beedle/gUnk_0810C89C.bin" - -gUnk_0810C8D4:: @ 0810C8D4 - .incbin "beedle/gUnk_0810C8D4.bin" - -gUnk_0810C8E0:: @ 0810C8E0 - .4byte sub_080632E0 - .4byte sub_08063314 - .4byte sub_0806336C - .4byte sub_08063390 - -gUnk_0810C8F0:: @ 0810C8F0 - .incbin "beedle/gUnk_0810C8F0.bin" - diff --git a/include/player.h b/include/player.h index da70d4d1..d9c869f5 100644 --- a/include/player.h +++ b/include/player.h @@ -407,7 +407,7 @@ void PlayerSetNormalAndCollide(void); bool32 PlayerTryDropObject(ItemBehavior* arg0, u32 unk); void InitItemGetSequence(u32, u32, u32); void sub_0807B7D8(u32, u32, u32); -void sub_08078850(Entity*, u32, u32, void*); +void sub_08078850(Entity*, u32, u32, const void*); void sub_08079D84(void); u32 sub_0807953C(void); void sub_0807BB68(s16*, u32, u32); diff --git a/include/structures.h b/include/structures.h index 0b0dc185..0f77cac0 100644 --- a/include/structures.h +++ b/include/structures.h @@ -268,7 +268,7 @@ typedef struct { /*0x01*/ u8 unk_1; /*0x02*/ u8 unk_2; /*0x03*/ u8 unk_3; - /*0x04*/ u8* unk_4; + /*0x04*/ const u8* unk_4; /*0x08*/ Entity* entity; } struct_03003DF8; diff --git a/linker.ld b/linker.ld index cdf1d2c3..1c2aed32 100644 --- a/linker.ld +++ b/linker.ld @@ -1177,7 +1177,7 @@ SECTIONS { data/animations/npc/minishEzlo.o(.rodata); src/npc/mailbox.o(.rodata); data/animations/npc/mailbox.o(.rodata); - data/const/npc/beedle.o(.rodata); + src/npc/beedle.o(.rodata); data/animations/npc/beedle.o(.rodata); src/npc/brocco.o(.rodata); data/const/npc/brocco.o(.rodata); diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 002f3253..3660b074 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -8,16 +8,35 @@ #include "functions.h" typedef struct { - u32 unk_00; + s8 unk_00; + u8 unk_01; + u8 unk_02; + u8 unk_03; s8 unk_04; + s8 unk_05; + s8 unk_06; + s8 unk_07; } gUnk_0810C89C_struct; -extern u8 gUnk_0810C88C[]; -extern Hitbox gUnk_0810C894; -extern gUnk_0810C89C_struct gUnk_0810C89C[]; -extern SpriteLoadData gUnk_0810C8D4; -extern void (*gUnk_0810C8E0[])(Entity*); -extern u8 gUnk_0810C8F0[]; +void sub_080632E0(Entity* this); +void sub_08063314(Entity* this); +void sub_0806336C(Entity* this); +void sub_08063390(Entity* this); + +static const u8 gUnk_0810C88C[] = { + 0, 0x2d, 0x2c, 0x29, 0x2a, 0x2b, 0x2e, 0, +}; +static const Hitbox gUnk_0810C894 = { 0, 0, { 0, 0, 0, 0 }, 16, 6 }; +static const gUnk_0810C89C_struct gUnk_0810C89C[] = { + { 0, 0, 6, 6, 0, 0, 0, 0 }, { -24, 0, 6, 6, 0, 0, 0, 0 }, { -24, 16, 6, 6, 0, 0, 0, 0 }, + { -24, 32, 6, 6, 0, 0, 0, 0 }, { 24, 0, 6, 6, 0, 0, 0, 0 }, { 24, 16, 6, 6, 0, 0, 0, 0 }, + { 24, 32, 6, 6, 0, 0, 0, 0 }, +}; +static const SpriteLoadData gUnk_0810C8D4[] = { + { 0x3e, 0x31, 0x4 }, + { 0x203e, 0x31, 0x4 }, + { 0, 0, 0 }, +}; void sub_080632C8(Entity* this); void sub_08063410(Entity* this); @@ -33,11 +52,17 @@ void Beedle(Entity* this) { } void sub_080632C8(Entity* this) { + static void (*const gUnk_0810C8E0[])(Entity*) = { + sub_080632E0, + sub_08063314, + sub_0806336C, + sub_08063390, + }; gUnk_0810C8E0[this->action](this); } void sub_080632E0(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_0810C8D4) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810C8D4) != 0) { InitializeAnimation(this, 0); sub_08078778(this); this->spriteSettings.draw = 1; @@ -94,12 +119,12 @@ void Beedle_Head(Entity* this) { void sub_08063410(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_0810C8D4) == 0) { + if (LoadExtraSpriteData(this, gUnk_0810C8D4) == 0) { return; } this->action++; if (this->type != 0) { - this->hitbox = &gUnk_0810C894; + this->hitbox = (Hitbox*)&gUnk_0810C894; this->type2 = 0; } sub_0807DD64(this); @@ -114,6 +139,48 @@ void sub_08063410(Entity* this) { } void sub_0806346C(Entity* this) { + static const u8 gUnk_0810C8F0[][6][4] = { + { + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 4, 4, 4, 4 }, + { 4, 4, 4, 4 }, + }, + { + { 1, 1, 1, 1 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 4, 4, 4, 4 }, + }, + { + { 2, 2, 2, 2 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 2 }, + { 0, 5, 0, 0 }, + { 0, 0, 0, 0 }, + { 5, 5, 5, 5 }, + }, + { + { 3, 3, 3, 3 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 3 }, + { 0, 6, 0, 0 }, + { 0, 0, 0, 0 }, + { 6, 6, 6, 6 }, + }, + { + { 3, 3, 3, 3 }, + { 3, 3, 3, 3 }, + { 3, 3, 3, 3 }, + { 6, 6, 6, 6 }, + { 6, 6, 6, 6 }, + { 6, 6, 6, 6 }, + }, + }; u8 bVar1; s32 iVar2; s32 iVar3; @@ -139,9 +206,9 @@ void sub_0806346C(Entity* this) { iVar3 >>= 4; iVar2 >>= 4; - bVar1 = gUnk_0810C8F0[(gPlayerEntity.animationState >> 1) + iVar3 * 4 + iVar2 * 0x18]; + bVar1 = gUnk_0810C8F0[iVar2][iVar3][gPlayerEntity.animationState >> 1]; if (bVar1 != this->type2) { - gUnk_0810C89C_struct* temp = &gUnk_0810C89C[bVar1]; + const gUnk_0810C89C_struct* temp = &gUnk_0810C89C[bVar1]; sub_08078850(this, 1, temp->unk_04, temp); this->type2 = bVar1; } diff --git a/src/playerUtils.c b/src/playerUtils.c index 2e5da41e..d5062e2a 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -875,7 +875,7 @@ s32 sub_08078828(Entity* ent) { return iVar1; } -void sub_08078850(Entity* arg0, u32 arg1, u32 arg2, void* arg3) { +void sub_08078850(Entity* arg0, u32 arg1, u32 arg2, const void* arg3) { s32 iVar1; iVar1 = sub_08078904(arg0);