From 710638ad7adc04f82fea4eef8068c03b5b05fe99 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Fri, 18 Aug 2023 11:20:19 -0400 Subject: [PATCH] Match sub_800543C and sub_800545C --- asm/sprite.s | 71 ------------------------------------------------ include/sprite.h | 1 + src/sprite.c | 28 +++++++++++++++++++ 3 files changed, 29 insertions(+), 71 deletions(-) diff --git a/asm/sprite.s b/asm/sprite.s index 171c43f0e..4d186bd53 100644 --- a/asm/sprite.s +++ b/asm/sprite.s @@ -5,77 +5,6 @@ .text - thumb_func_start sub_800543C -sub_800543C: - push {r4,r5,lr} - sub sp, 0x8 - ldr r5, [sp, 0x14] - ldr r4, [sp, 0x18] - lsls r4, 24 - lsrs r4, 24 - ldr r1, [r1, 0x4] - str r5, [sp] - str r4, [sp, 0x4] - bl sub_800545C - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_800543C - - thumb_func_start sub_800545C -sub_800545C: - push {r4-r7,lr} - adds r4, r0, 0 - adds r6, r1, 0 - adds r7, r2, 0 - adds r5, r3, 0 - ldr r0, [sp, 0x18] - lsls r0, 24 - movs r2, 0 - movs r3, 0x80 - lsls r3, 8 - strh r3, [r4] - cmp r0, 0 - beq _08005482 - movs r0, 0x80 - lsls r0, 5 - adds r1, r0, 0 - adds r0, r3, 0 - orrs r0, r1 - strh r0, [r4] -_08005482: - strh r2, [r4, 0x2] - ldr r0, [sp, 0x14] - strh r0, [r4, 0x4] - strh r2, [r4, 0xC] - strh r2, [r4, 0xE] - strh r5, [r4, 0x1C] - ldr r0, _080054B8 - 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, [r6, 0x4] - lsls r0, r7, 2 - adds r0, r1 - ldr r0, [r0] - ldr r0, [r0] - str r0, [r4, 0x28] - str r0, [r4, 0x2C] - ldr r0, [r6] - str r0, [r4, 0x34] - str r2, [r4, 0x30] - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080054B8: .4byte 0x0000ffff - thumb_func_end sub_800545C - thumb_func_start sub_80054BC sub_80054BC: push {r4,lr} diff --git a/include/sprite.h b/include/sprite.h index 9e5918406..653bc2702 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -103,5 +103,6 @@ void sub_8005180(void); void sub_8005304(void); void sub_80053AC(struct Entity_Sub28 *, struct Dungeon_Sub17B44 *, u32, u32, u32, u32, bool8); void sub_80053D0(struct Entity_Sub28 *, struct Dungeon_Sub17B44_Sub4 *, u32, u32, u32, u32, bool8); +void sub_800543C(struct Entity_Sub28 *, struct Dungeon_Sub17B44 *, 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 150fc7176..db0b4caa8 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -19,6 +19,7 @@ extern struct unkStruct_20266B0 *gUnknown_203B074; extern void nullsub_3(s32, s32); void RegisterSpriteParts_80052BC(struct UnkSpriteMem *); +void sub_800545C(struct Entity_Sub28 *, struct Dungeon_Sub17B44_Sub4 *, u32, u32, u32, bool8); void InitSprites(void) { @@ -911,4 +912,31 @@ void sub_80053D0(struct Entity_Sub28 *a0, struct Dungeon_Sub17B44_Sub4 *a1, u32 a0->unk34 = a1->unk0; a0->unk38 = a1->unkC; a0->unk30 = a1->unk10; +} + +void sub_800543C(struct Entity_Sub28 *a0, struct Dungeon_Sub17B44 *a1, u32 a2, u32 a3, u32 spriteAnimIndex, bool8 a5) +{ + sub_800545C(a0, a1->unk4, a2, a3, spriteAnimIndex, a5); +} + +void sub_800545C(struct Entity_Sub28 *a0, struct Dungeon_Sub17B44_Sub4 *a1, u32 a2, u32 a3, u32 spriteAnimIndex, bool8 a5) +{ + a0->unk0 = 0x8000; + if (a5) + a0->unk0 |= 0x1000; + + a0->spriteAnimationCounter = 0; + a0->spriteAnimationIndex = spriteAnimIndex; + a0->spritePosOffset.x = 0; + a0->spritePosOffset.y = 0; + a0->unk1C = a3; + a0->spriteIndexForEntity = 0xFFFF; + a0->spriteIndexForEntity2 = 0xFFFF; + a0->unk14 = 0; + a0->unk18 = 0; + a0->spriteAnimationCounter2 = 0; + a0->spriteBaseForDirection = a1->unk4[a2][0]; + a0->spriteGlobalIndex = a0->spriteBaseForDirection; + a0->unk34 = a1->unk0; + a0->unk30 = 0; } \ No newline at end of file