From ad5ec244aa927be5a6d496837ea21facb67698d0 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Fri, 18 Aug 2023 10:32:15 -0400 Subject: [PATCH] Match sub_80053D0 --- asm/sprite.s | 59 ------------------------------------------------ include/sprite.h | 19 ++++++++++------ src/sprite.c | 23 +++++++++++++++++++ 3 files changed, 35 insertions(+), 66 deletions(-) diff --git a/asm/sprite.s b/asm/sprite.s index 69cd5112c..171c43f0e 100644 --- a/asm/sprite.s +++ b/asm/sprite.s @@ -5,65 +5,6 @@ .text - thumb_func_start sub_80053D0 -sub_80053D0: - push {r4-r7,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - adds r7, r3, 0 - ldr r0, [sp, 0x1C] - lsls r0, 24 - movs r2, 0 - movs r3, 0x80 - lsls r3, 8 - strh r3, [r4] - cmp r0, 0 - beq _080053F6 - movs r0, 0x80 - lsls r0, 5 - adds r1, r0, 0 - adds r0, r3, 0 - orrs r0, r1 - strh r0, [r4] -_080053F6: - strh r2, [r4, 0x2] - ldr r0, [sp, 0x18] - strh r0, [r4, 0x4] - strh r2, [r4, 0xC] - strh r2, [r4, 0xE] - ldr r0, [sp, 0x14] - strh r0, [r4, 0x1C] - ldr r0, _08005438 - strh r0, [r4, 0x20] - movs r0, 0x1 - negs r0, r0 - strh r0, [r4, 0x22] - str r2, [r4, 0x14] - str r2, [r4, 0x18] - strh r2, [r4, 0x6] - ldr r1, [r5, 0x4] - lsls r0, r6, 2 - adds r0, r1 - ldr r1, [r0] - lsls r0, r7, 2 - adds r0, r1 - ldr r0, [r0] - str r0, [r4, 0x28] - str r0, [r4, 0x2C] - ldr r0, [r5] - str r0, [r4, 0x34] - ldr r0, [r5, 0xC] - str r0, [r4, 0x38] - ldr r0, [r5, 0x10] - str r0, [r4, 0x30] - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08005438: .4byte 0x0000ffff - thumb_func_end sub_80053D0 - thumb_func_start sub_800543C sub_800543C: push {r4,r5,lr} diff --git a/include/sprite.h b/include/sprite.h index 1716a4be5..9e5918406 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -56,7 +56,11 @@ struct Entity_Sub28 /* 0x8 */ struct Position spritePos; // Offset of the sprite from its position at the start of the animation. Changes alongside spritePos. /* 0xC */ struct Position spritePosOffset; - u8 fill10[0x20 - 0x10]; + u8 fill10[0x14 - 0x10]; + u32 unk14; + u32 unk18; + u16 unk1C; + u8 fill1E[0x20 - 0x1E]; // The sprite index to display, among the Pokémon's possible sprites. /* 0x20 */ u16 spriteIndexForEntity; /* 0x22 */ u16 spriteIndexForEntity2; @@ -64,17 +68,18 @@ struct Entity_Sub28 // Some kind of base sprite index depending on which way the Pokémon is facing. // and which animation is playing (e.g., idle, moving). // Compared to 0x20, 0x28 and 0x2C are much larger and could be global indexes among all sprites in the game. - /* 0x28 */ u16 spriteBaseForDirection; - u8 fill2A[0x2C - 0x2A]; - /* 0x2C */ u16 spriteGlobalIndex; - u8 fill2E[0x3C - 0x2E]; + /* 0x28 */ u32 spriteBaseForDirection; + /* 0x2C */ u32 spriteGlobalIndex; + u32 unk30; + u32 unk34; + u32 unk38; }; // size: ? struct Dungeon_Sub17B44_Sub4 { u32 unk0; - u32 unk4; + u32 **unk4; u8 fill8[0xC - 0x8]; u32 unkC; u32 unk10; @@ -97,6 +102,6 @@ void sub_8004E8C(struct unkStruct_2039DB0 *); void sub_8005180(void); void sub_8005304(void); void sub_80053AC(struct Entity_Sub28 *, struct Dungeon_Sub17B44 *, u32, u32, u32, u32, bool8); -extern void sub_80053D0(struct Entity_Sub28 *a0, struct Dungeon_Sub17B44_Sub4 *a1, u32 a2, u32 a3, u32 a4, u32 spriteAnimIndex, bool8 a6); +void sub_80053D0(struct Entity_Sub28 *, struct Dungeon_Sub17B44_Sub4 *, u32, u32, u32, u32, bool8); #endif // GUARD_SPRITE_H \ No newline at end of file diff --git a/src/sprite.c b/src/sprite.c index fe6e0949c..150fc7176 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -888,4 +888,27 @@ void sub_800533C(struct ax_pose **a0, struct UnkSpriteMem **a1, struct axdata1 * void sub_80053AC(struct Entity_Sub28 *a0, struct Dungeon_Sub17B44 *a1, u32 a2, u32 a3, u32 a4, u32 spriteAnimIndex, bool8 a6) { sub_80053D0(a0, a1->unk4, a2, a3, a4, spriteAnimIndex, a6); +} + +void sub_80053D0(struct Entity_Sub28 *a0, struct Dungeon_Sub17B44_Sub4 *a1, u32 a2, u32 direction, u32 a4, u32 spriteAnimIndex, bool8 a6) +{ + a0->unk0 = 0x8000; + if (a6) + a0->unk0 |= 0x1000; + + a0->spriteAnimationCounter = 0; + a0->spriteAnimationIndex = spriteAnimIndex; + a0->spritePosOffset.x = 0; + a0->spritePosOffset.y = 0; + a0->unk1C = a4; + a0->spriteIndexForEntity = 0xFFFF; + a0->spriteIndexForEntity2 = 0xFFFF; + a0->unk14 = 0; + a0->unk18 = 0; + a0->spriteAnimationCounter2 = 0; + a0->spriteBaseForDirection = a1->unk4[a2][direction]; + a0->spriteGlobalIndex = a0->spriteBaseForDirection; + a0->unk34 = a1->unk0; + a0->unk38 = a1->unkC; + a0->unk30 = a1->unk10; } \ No newline at end of file