diff --git a/asm/non_matching/itemSword/sub_080754B8.inc b/asm/non_matching/itemSword/sub_080754B8.inc deleted file mode 100644 index ae6d7dcea6..0000000000 --- a/asm/non_matching/itemSword/sub_080754B8.inc +++ /dev/null @@ -1,102 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - adds r4, r0, #0 - adds r6, r1, #0 - ldr r7, _080754D4 @ =gPlayerState - ldrb r1, [r7, #0x1b] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _080754D8 - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_08075694 - b _0807557E - .align 2, 0 -_080754D4: .4byte gPlayerState -_080754D8: - ldrb r0, [r7, #4] - cmp r0, #0 - beq _08075576 - adds r0, r4, #0 - bl UpdateItemAnim - ldrb r0, [r4, #0xe] - cmp r0, #0 - beq _080754F2 - ldrb r1, [r4, #9] - movs r0, #0x7f - ands r0, r1 - strb r0, [r4, #9] -_080754F2: - ldr r0, _0807552C @ =gPlayerEntity - adds r0, #0x5b - ldrb r1, [r0] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _08075538 - bl sub_0807B014 - adds r5, r0, #0 - cmp r5, #0 - beq _08075538 - movs r0, #8 - movs r1, #0xf - movs r2, #2 - bl FindEntityByID - cmp r0, #0 - bne _08075538 - adds r0, r4, #0 - movs r1, #0xf - bl CreatePlayerBomb - cmp r5, #0xf - bne _08075530 - adds r1, r7, #0 - adds r1, #0xab - movs r0, #5 - b _08075536 - .align 2, 0 -_0807552C: .4byte gPlayerEntity -_08075530: - adds r1, r7, #0 - adds r1, #0xab - movs r0, #8 -_08075536: - strb r0, [r1] -_08075538: - ldrb r1, [r4, #0xe] - movs r2, #0x80 - adds r0, r2, #0 - ands r0, r1 - cmp r0, #0 - beq _0807557E - ldr r1, _08075568 @ =gPlayerState - ldr r0, [r1, #0x30] - ands r0, r2 - cmp r0, #0 - bne _0807555C - adds r0, r1, #0 - adds r0, #0xac - ldrh r1, [r0] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - bne _0807556C -_0807555C: - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_080759B8 - b _0807557E - .align 2, 0 -_08075568: .4byte gPlayerState -_0807556C: - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_08075580 - b _0807557E -_08075576: - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_080759B8 -_0807557E: - pop {r4, r5, r6, r7, pc} - .syntax divided diff --git a/asm/non_matching/itemSword/sub_08075738.inc b/asm/non_matching/itemSword/sub_08075738.inc deleted file mode 100644 index 31991b9c0c..0000000000 --- a/asm/non_matching/itemSword/sub_08075738.inc +++ /dev/null @@ -1,177 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - adds r4, r0, #0 - adds r6, r1, #0 - ldr r5, _08075750 @ =gPlayerState - ldrb r0, [r5, #4] - cmp r0, #0 - bne _08075754 - adds r0, r4, #0 - bl sub_080759B8 - b _0807588C - .align 2, 0 -_08075750: .4byte gPlayerState -_08075754: - adds r0, r4, #0 - bl UpdateItemAnim - adds r0, r4, #0 - bl sub_08077F10 - cmp r0, #0 - beq _08075768 - movs r0, #2 - strb r0, [r4, #7] -_08075768: - ldrb r2, [r5, #0x1b] - movs r0, #0x10 - ands r0, r2 - cmp r0, #0 - beq _080757D4 - ldrb r1, [r5, #0xd] - movs r2, #0x80 - adds r0, r2, #0 - ands r0, r1 - cmp r0, #0 - bne _08075780 - strb r1, [r4, #0xb] -_08075780: - ldr r1, _080757D0 @ =gPlayerEntity - ldrb r0, [r4, #0xb] - strb r0, [r1, #0x15] - movs r0, #0xc0 - lsls r0, r0, #1 - strh r0, [r1, #0x24] - ldrb r1, [r4, #0xe] - adds r0, r2, #0 - ands r0, r1 - cmp r0, #0 - beq _0807588C - movs r2, #0xa - adds r0, r5, #0 - adds r0, #0xac - ldrh r1, [r0] - movs r0, #0x80 - lsls r0, r0, #4 - ands r0, r1 - cmp r0, #0 - beq _080757AA - movs r2, #0xf -_080757AA: - ldrb r0, [r4, #8] - adds r0, #1 - strb r0, [r4, #8] - movs r1, #0xff - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r2, r0 - bls _080757C6 - ldrb r0, [r4, #7] - subs r0, #1 - strb r0, [r4, #7] - ands r0, r1 - cmp r0, #0 - bne _0807588C -_080757C6: - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_080759B8 - b _0807588C - .align 2, 0 -_080757D0: .4byte gPlayerEntity -_080757D4: - ldr r7, _08075890 @ =gPlayerEntity - adds r0, r7, #0 - adds r0, #0x5b - ldrb r1, [r0] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _08075816 - movs r0, #0x80 - ands r0, r2 - cmp r0, #0 - bne _08075816 - adds r0, r5, #0 - adds r0, #0xac - ldrh r1, [r0] - movs r0, #0x80 - lsls r0, r0, #1 - ands r0, r1 - cmp r0, #0 - beq _08075816 - adds r0, r4, #0 - movs r1, #0x14 - bl CreatePlayerBomb - adds r2, r0, #0 - cmp r2, #0 - beq _08075816 - ldrb r0, [r7, #0x14] - movs r1, #6 - ands r1, r0 - movs r0, #0x80 - orrs r1, r0 - strb r1, [r2, #0x14] -_08075816: - ldr r5, _08075890 @ =gPlayerEntity - adds r0, r5, #0 - adds r0, #0x5b - ldrb r1, [r0] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _0807587A - ldr r2, _08075894 @ =gPlayerState - ldrb r3, [r2, #0x1b] - movs r0, #0x80 - ands r0, r3 - cmp r0, #0 - bne _0807587A - adds r0, r2, #0 - adds r0, #0xac - ldrh r1, [r0] - movs r0, #0x20 - ands r0, r1 - cmp r0, #0 - beq _0807587A - ldrb r0, [r4, #7] - subs r0, #1 - strb r0, [r4, #7] - lsls r0, r0, #0x18 - cmp r0, #0 - beq _0807587A - movs r0, #0x10 - orrs r0, r3 - strb r0, [r2, #0x1b] - adds r1, r2, #0 - adds r1, #0xab - movs r0, #6 - strb r0, [r1] - ldrb r0, [r5, #0x14] - lsls r0, r0, #2 - strb r0, [r4, #0xb] - movs r0, #1 - strb r0, [r4, #7] - strb r0, [r4, #8] - movs r1, #8 - asrs r1, r6 - ldrb r0, [r2, #0xa] - bics r0, r1 - strb r0, [r2, #0xa] - movs r1, #0x94 - lsls r1, r1, #1 - adds r0, r4, #0 - bl sub_08077DF4 -_0807587A: - ldrb r1, [r4, #0xe] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _0807588C - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_080759B8 -_0807588C: - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_08075890: .4byte gPlayerEntity -_08075894: .4byte gPlayerState - .syntax divided diff --git a/asm/non_matching/itemSword/sub_08075900.inc b/asm/non_matching/itemSword/sub_08075900.inc deleted file mode 100644 index d10ea4ab4c..0000000000 --- a/asm/non_matching/itemSword/sub_08075900.inc +++ /dev/null @@ -1,89 +0,0 @@ - .syntax unified - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r6, r1, #0 - ldr r5, _08075920 @ =gPlayerState - ldrb r0, [r5, #0x12] - cmp r0, #0x11 - bne _08075928 - ldr r0, [r5, #0x30] - ldr r1, _08075924 @ =0xFFFBFFFF - ands r0, r1 - str r0, [r5, #0x30] - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_080759B8 - b _080759B2 - .align 2, 0 -_08075920: .4byte gPlayerState -_08075924: .4byte 0xFFFBFFFF -_08075928: - adds r0, r4, #0 - bl UpdateItemAnim - ldrb r1, [r5, #0x1b] - movs r2, #0x80 - adds r0, r2, #0 - ands r0, r1 - cmp r0, #0 - beq _08075948 - movs r0, #0xa0 - strb r0, [r5, #0x1b] - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_0807564C - b _080759B2 -_08075948: - ldrb r0, [r4, #7] - cmp r0, #0 - beq _08075998 - subs r0, #1 - strb r0, [r4, #7] - lsls r0, r0, #0x18 - cmp r0, #0 - bne _08075962 - movs r1, #0x9a - lsls r1, r1, #1 - adds r0, r4, #0 - bl sub_08077DF4 -_08075962: - ldr r4, _08075990 @ =gPlayerEntity - ldrb r0, [r4, #0x14] - lsrs r0, r0, #1 - lsls r0, r0, #3 - strb r0, [r4, #0x15] - movs r0, #0xc0 - lsls r0, r0, #2 - strh r0, [r4, #0x24] - bl UpdatePlayerMovement - ldr r0, _08075994 @ =gRoomTransition - ldr r0, [r0] - movs r1, #3 - ands r0, r1 - cmp r0, #0 - bne _080759B2 - adds r0, r4, #0 - movs r1, #0x11 - movs r2, #0x40 - bl CreateFx - b _080759B2 - .align 2, 0 -_08075990: .4byte gPlayerEntity -_08075994: .4byte gRoomTransition -_08075998: - ldrb r1, [r4, #0xe] - adds r0, r2, #0 - ands r0, r1 - cmp r0, #0 - beq _080759B2 - ldr r0, [r5, #0x30] - ldr r1, _080759B4 @ =0xFFFBFFFF - ands r0, r1 - str r0, [r5, #0x30] - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_080759B8 -_080759B2: - pop {r4, r5, r6, pc} - .align 2, 0 -_080759B4: .4byte 0xFFFBFFFF - .syntax divided diff --git a/src/item/itemSword.c b/src/item/itemSword.c index 7a79415955..bcba405415 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -2,13 +2,19 @@ #include "functions.h" #include "sound.h" #include "object.h" +#include "playeritem.h" extern void (*const gUnk_0811BD44[])(ItemBehavior*, u32); extern void sub_08077B98(ItemBehavior*); +extern void UpdatePlayerMovement(void); +extern u32 sub_0807B014(); +extern Entity* CreatePlayerBomb(ItemBehavior*, u32); +extern bool32 sub_08077F10(ItemBehavior*); void sub_080759B8(ItemBehavior*, u32); void sub_080754B8(ItemBehavior*, u32); void sub_08075898(ItemBehavior*, u32); +void sub_08075580(ItemBehavior*, u32); extern u32 sub_08077EC8(ItemBehavior*); @@ -93,7 +99,40 @@ void sub_08075338(ItemBehavior* this, u32 arg1) { sub_08077B98(this); } -ASM_FUNC("asm/non_matching/itemSword/sub_080754B8.inc", void sub_080754B8(ItemBehavior* this, u32 arg1)) +void sub_080754B8(ItemBehavior* this, u32 arg1) { + u32 iVar1; + + if ((gPlayerState.sword_state & 0x80) != 0) { + sub_08075694(this, arg1); + } else if (gPlayerState.field_0x3[1] != 0) { + UpdateItemAnim(this); + if (this->field_0x5[9] != 0) { + this->field_0x5[4] = this->field_0x5[4] & 0x7f; + } + + if (gPlayerEntity.frameSpriteSettings & 1) { + iVar1 = sub_0807B014(); + if (iVar1 && FindEntityByID(PLAYER_ITEM, 15, 2) == 0) { + CreatePlayerBomb(this, 0xf); + if (iVar1 == 0xf) { + gPlayerState.field_0xab = 5; + } else { + gPlayerState.field_0xab = 8; + } + } + } + + if ((this->field_0x5[9] & 0x80) != 0) { + if (((gPlayerState.flags & 0x80) != 0) || ((gPlayerState.field_0xac & 1) == 0)) { + sub_080759B8(this, arg1); + } else { + sub_08075580(this, arg1); + } + } + } else { + sub_080759B8(this, arg1); + } +} void sub_08075580(ItemBehavior* this, u32 arg1) { if ((sub_08077EFC(this) != 0) && (gPlayerState.jump_status == 0)) { @@ -165,7 +204,59 @@ void sub_08075694(ItemBehavior* this, u32 arg1) { SoundReq(SFX_PLY_VO2); } -ASM_FUNC("asm/non_matching/itemSword/sub_08075738.inc", void sub_08075738(ItemBehavior* this, u32 arg1)) +void sub_08075738(ItemBehavior* this, u32 arg1) { + u32 bVar6; + + if (gPlayerState.field_0x3[1] == 0) { + sub_080759B8(this, arg1); + } else { + UpdateItemAnim(this); + if (sub_08077F10(this)) { + this->field_0x5[2] = 2; + } + + if ((gPlayerState.sword_state & 0x10) != 0) { + if ((gPlayerState.field_0xd & 0x80) == 0) { + this->field_0x5[6] = gPlayerState.field_0xd; + } + gPlayerEntity.direction = this->field_0x5[6]; + gPlayerEntity.speed = 0x180; + if ((this->field_0x5[9] & 0x80) != 0) { + bVar6 = 10; + if ((gPlayerState.field_0xac & 0x800) != 0) { + bVar6 = 0xf; + } + + if ((bVar6 <= ++this->field_0x5[3]) || (--this->field_0x5[2] == 0)) { + sub_080759B8(this, arg1); + } + } + } else { + if (((((gPlayerEntity.frameSpriteSettings & 1) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && + ((gPlayerState.field_0xac & 0x100) != 0))) { + Entity* bombEnt = CreatePlayerBomb(this, 0x14); + if (bombEnt) { + bombEnt->animationState = (gPlayerEntity.animationState & 6) | 0x80; + } + } + + if ((((gPlayerEntity.frameSpriteSettings & 2) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && + (((gPlayerState.field_0xac & 0x20) != 0 && (--this->field_0x5[2] != 0)))) { + gPlayerState.sword_state |= 0x10; + gPlayerState.field_0xab = 6; + this->field_0x5[6] = gPlayerEntity.animationState << 2; + this->field_0x5[2] = 1; + this->field_0x5[3] = 1; + gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> arg1); + sub_08077DF4(this, 0x128); + } + + if ((this->field_0x5[9] & 0x80) != 0) { + sub_080759B8(this, arg1); + } + } + } +} void sub_08075898(ItemBehavior* this, u32 arg1) { if (gPlayerState.field_0x3[1] == 0) { @@ -190,7 +281,36 @@ void sub_080758B0(ItemBehavior* this, u32 arg1) { } } -ASM_FUNC("asm/non_matching/itemSword/sub_08075900.inc", void sub_08075900(ItemBehavior* this, u32 arg1)) +void sub_08075900(ItemBehavior* this, u32 arg1) { + if (gPlayerState.floor_type == SURFACE_SWAMP) { + gPlayerState.flags &= ~PL_ROLLING; + sub_080759B8(this, arg1); + } else { + UpdateItemAnim(this); + if ((gPlayerState.sword_state & 0x80) != 0) { + gPlayerState.sword_state = 0xa0; + sub_0807564C(this, arg1); + + } else { + if (this->field_0x5[2] != 0) { + if (--this->field_0x5[2] == 0) { + sub_08077DF4(this, 0x134); + } + gPlayerEntity.direction = (gPlayerEntity.animationState >> 1) << 3; + gPlayerEntity.speed = 0x300; + UpdatePlayerMovement(); + if ((gRoomTransition.frameCount & 3) == 0) { + CreateFx(&gPlayerEntity, FX_DASH, 0x40); + } + } else { + if ((this->field_0x5[9] & 0x80) != 0) { + gPlayerState.flags &= ~PL_ROLLING; + sub_080759B8(this, arg1); + } + } + } + } +} void sub_080759B8(ItemBehavior* this, u32 arg1) { if ((gPlayerState.flags & PL_MINISH) == 0) {