From 52c5a47bbd02aeaa4a46ca5fdaa6c1cdb6d8aaf3 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 12 Feb 2022 15:59:03 +0200 Subject: [PATCH] Match sub_0801B938 + data --- asm/non_matching/playerItemC/sub_0801B938.inc | 89 ------------------- assets/assets.json | 10 --- data/const/playerItem/playerItemC.s | 15 ---- linker.ld | 2 +- src/playerItem/playerItemC.c | 43 +++++++-- 5 files changed, 39 insertions(+), 120 deletions(-) delete mode 100644 asm/non_matching/playerItemC/sub_0801B938.inc delete mode 100644 data/const/playerItem/playerItemC.s diff --git a/asm/non_matching/playerItemC/sub_0801B938.inc b/asm/non_matching/playerItemC/sub_0801B938.inc deleted file mode 100644 index 5c7e9e8c..00000000 --- a/asm/non_matching/playerItemC/sub_0801B938.inc +++ /dev/null @@ -1,89 +0,0 @@ - .syntax unified - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x14] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _0801B960 - ldr r3, _0801B95C @ =gPlayerEntity - ldrb r1, [r3, #0x18] - lsls r1, r1, #0x19 - lsrs r1, r1, #0x1f - movs r0, #1 - eors r1, r0 - lsls r1, r1, #6 - ldrb r2, [r4, #0x18] - subs r0, #0x42 - b _0801B96E - .align 2, 0 -_0801B95C: .4byte gPlayerEntity -_0801B960: - ldr r3, _0801B998 @ =gPlayerEntity - ldrb r0, [r3, #0x18] - movs r1, #0x40 - ands r1, r0 - ldrb r2, [r4, #0x18] - movs r0, #0x41 - rsbs r0, r0, #0 -_0801B96E: - ands r0, r2 - orrs r0, r1 - strb r0, [r4, #0x18] - adds r0, r3, #0 - adds r0, #0x58 - ldrb r0, [r0] - adds r0, #0x68 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #3 - bhi _0801B99C - ldrb r0, [r3, #0x1e] - adds r0, #0x2e - strb r0, [r4, #0x1e] - ldrb r1, [r4, #0x1e] - ldrh r2, [r4, #0x12] - adds r0, r4, #0 - bl sub_080042D0 - b _0801B9A0 - .align 2, 0 -_0801B998: .4byte gPlayerEntity -_0801B99C: - movs r0, #0xff - strb r0, [r4, #0x1e] -_0801B9A0: - ldrb r3, [r4, #0x14] - lsrs r3, r3, #1 - lsls r0, r3, #3 - ldr r1, _0801B9E0 @ =gUnk_080B7850 - adds r0, r0, r1 - str r0, [r4, #0x48] - lsls r3, r3, #1 - ldr r0, _0801B9E4 @ =gUnk_080B7848 - adds r3, r3, r0 - ldr r0, _0801B9E8 @ =gPlayerState - adds r0, #0xac - ldrh r0, [r0] - movs r1, #8 - ands r1, r0 - lsls r1, r1, #0x10 - lsrs r1, r1, #0x10 - rsbs r1, r1, #0 - lsrs r1, r1, #0x1f - movs r2, #0 - ldrsb r2, [r3, r2] - ldrb r3, [r3, #1] - lsls r3, r3, #0x18 - asrs r3, r3, #0x18 - adds r0, r4, #0 - bl sub_08008782 - ldr r1, _0801B9EC @ =gPlayerEntity - adds r0, r4, #0 - bl sub_08078E84 - pop {r4, pc} - .align 2, 0 -_0801B9E0: .4byte gUnk_080B7850 -_0801B9E4: .4byte gUnk_080B7848 -_0801B9E8: .4byte gPlayerState -_0801B9EC: .4byte gPlayerEntity - .syntax divided diff --git a/assets/assets.json b/assets/assets.json index 84a7f1db..d69851c3 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -20860,16 +20860,6 @@ "start": 751604, "size": 8 }, - { - "path": "playerItemC/gUnk_080B7848.bin", - "start": 751688, - "size": 8 - }, - { - "path": "playerItemC/gUnk_080B7850.bin", - "start": 751696, - "size": 32 - }, { "path": "playerItemSwordSpin/gUnk_080B7878.bin", "start": 751736, diff --git a/data/const/playerItem/playerItemC.s b/data/const/playerItem/playerItemC.s deleted file mode 100644 index 468fbd06..00000000 --- a/data/const/playerItem/playerItemC.s +++ /dev/null @@ -1,15 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_080B7840:: @ 080B7840 - .4byte sub_0801B8B0 - .4byte sub_0801B8FC - -gUnk_080B7848:: @ 080B7848 - .incbin "playerItemC/gUnk_080B7848.bin" - -gUnk_080B7850:: @ 080B7850 - .incbin "playerItemC/gUnk_080B7850.bin" diff --git a/linker.ld b/linker.ld index 1791d97b..7041a1f7 100644 --- a/linker.ld +++ b/linker.ld @@ -930,7 +930,7 @@ SECTIONS { data/data_080B4410.o(.rodata); data/const/playerItem/playerItemBomb.o(.rodata); src/playerItem/playerItem3.o(.rodata); - data/const/playerItem/playerItemC.o(.rodata); + src/playerItem/playerItemC.o(.rodata); data/const/playerItem/playerItemSwordSpin.o(.rodata); data/data_080B7910.o(.rodata); data/const/playerItem/playerItemCellOverwriteSet.o(.rodata); diff --git a/src/playerItem/playerItemC.c b/src/playerItem/playerItemC.c index aa08e1bc..f376fdd2 100644 --- a/src/playerItem/playerItemC.c +++ b/src/playerItem/playerItemC.c @@ -3,17 +3,21 @@ #include "player.h" #include "functions.h" -extern void (*const gUnk_080B7840[])(Entity*); - extern void sub_08079BD8(Entity*); -void sub_0801B8FC(Entity*); +extern Entity* sub_08008782(Entity*, u32, s32, s32); +void sub_0801B8FC(Entity*); +void sub_0801B8B0(Entity*); void sub_0801B938(Entity*); extern void sub_08017744(Entity*); void PlayerItemC(Entity* this) { - gUnk_080B7840[this->action](this); + static void (*const PlayerItemC_Actions[])(Entity*) = { + sub_0801B8B0, + sub_0801B8FC, + }; + PlayerItemC_Actions[this->action](this); } void sub_0801B8B0(Entity* this) { @@ -48,7 +52,36 @@ void sub_0801B8FC(Entity* this) { } } -ASM_FUNC("asm/non_matching/playerItemC/sub_0801B938.inc", void sub_0801B938(Entity* this)) +void sub_0801B938(Entity* this) { + static const s8 gUnk_080B7848[] = { + 0, -15, 12, -3, 0, 9, -12, -3, + }; + static const Hitbox gUnk_080B7850[] = { + { 0, -18, { 0 }, 4, 8 }, + { 16, 0, { 0 }, 8, 4 }, + { 2, 11, { 0 }, 4, 8 }, + { -16, 0, { 0 }, 8, 4 }, + }; + const s8* ptr; + + if ((this->animationState & 2)) { + this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX ^ 1; + } else { + this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; + } + + if ((u8)(gPlayerEntity.animIndex + 0x68) < 4) { + this->frameIndex = gPlayerEntity.frameIndex + 0x2e; + sub_080042D0(this, this->frameIndex, this->spriteIndex); + } else { + this->frameIndex = 0xff; + } + + this->hitbox = (Hitbox*)&gUnk_080B7850[this->animationState >> 1]; + ptr = &gUnk_080B7848[(this->animationState >> 1) * 2]; + sub_08008782(this, -(gPlayerState.field_0xac & 8) != 0, ptr[0], ptr[1]); + sub_08078E84(this, &gPlayerEntity); +} void sub_0801B9F0(Entity* this) { COLLISION_OFF(this);