From 1208153d2524d1b8107750915d3a78634e0fe8d4 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Tue, 19 Apr 2022 23:12:29 +0300 Subject: [PATCH] Match functions and put const data in playerItemSword --- .../playerItemSword/sub_080A758C.inc | 156 ------------- .../playerItemSword/sub_080A76CC.inc | 180 --------------- assets/assets.json | 30 --- data/const/playerItem/playerItemSword.s | 28 --- linker.ld | 2 +- src/playerItem/playerItemSword.c | 207 +++++++++++++++++- 6 files changed, 199 insertions(+), 404 deletions(-) delete mode 100644 asm/non_matching/playerItemSword/sub_080A758C.inc delete mode 100644 asm/non_matching/playerItemSword/sub_080A76CC.inc delete mode 100644 data/const/playerItem/playerItemSword.s diff --git a/asm/non_matching/playerItemSword/sub_080A758C.inc b/asm/non_matching/playerItemSword/sub_080A758C.inc deleted file mode 100644 index ea464702..00000000 --- a/asm/non_matching/playerItemSword/sub_080A758C.inc +++ /dev/null @@ -1,156 +0,0 @@ - .syntax unified - push {r4, r5, lr} - adds r5, r0, #0 - ldrb r0, [r5, #0xa] - cmp r0, #0 - bne _080A75AC - ldr r1, _080A7654 @ =gPlayerState - ldrb r0, [r1, #4] - cmp r0, #0 - bne _080A75AC - ldrb r1, [r1, #2] - movs r0, #0x20 - ands r0, r1 - cmp r0, #0 - bne _080A75AC - bl DeleteThisEntity -_080A75AC: - adds r0, r5, #0 - bl AllocMutableHitbox - cmp r0, #0 - bne _080A75BA - bl DeleteThisEntity -_080A75BA: - adds r0, r5, #0 - movs r1, #1 - movs r2, #3 - bl LoadSwapGFX - ldr r1, _080A7658 @ =gPlayerEntity - adds r0, r1, #0 - adds r0, #0x3c - ldrb r0, [r0] - adds r0, #1 - movs r2, #0x20 - adds r3, r5, #0 - adds r3, #0x3c - movs r4, #0 - orrs r0, r2 - strb r0, [r3] - adds r1, #0x3b - ldrb r0, [r1] - adds r1, r5, #0 - adds r1, #0x3b - strb r0, [r1] - ldrb r1, [r5, #0x11] - movs r0, #0x10 - rsbs r0, r0, #0 - ands r0, r1 - movs r1, #6 - orrs r0, r1 - strb r0, [r5, #0x11] - adds r0, r5, #0 - adds r0, #0x41 - strb r4, [r0] - subs r0, #4 - strb r4, [r0] - adds r0, #5 - strb r4, [r0] - ldrb r0, [r5, #0xc] - adds r0, #1 - strb r0, [r5, #0xc] - movs r0, #0xff - strb r0, [r5, #0x1e] - adds r0, r5, #0 - bl sub_0801766C - ldrb r0, [r5, #0xa] - cmp r0, #0 - bne _080A76BC - ldr r2, _080A7654 @ =gPlayerState - ldrb r1, [r2, #2] - movs r0, #0x20 - ands r0, r1 - cmp r0, #0 - beq _080A767A - ldrb r1, [r5, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r5, #0x10] - movs r0, #2 - strb r0, [r5, #0xb] - adds r0, r2, #0 - adds r0, #0x3e - ldrb r0, [r0] - lsls r0, r0, #0x1e - lsrs r0, r0, #0x1d - adds r0, #8 - adds r1, r5, #0 - adds r1, #0x44 - strb r0, [r1] - adds r0, r5, #0 - adds r0, #0x68 - ldrb r0, [r0] - cmp r0, #1 - beq _080A765C - cmp r0, #6 - bne _080A7664 - subs r1, #4 - movs r0, #0x1a - b _080A766A - .align 2, 0 -_080A7654: .4byte gPlayerState -_080A7658: .4byte gPlayerEntity -_080A765C: - adds r1, r5, #0 - adds r1, #0x40 - movs r0, #0x18 - b _080A766A -_080A7664: - adds r1, r5, #0 - adds r1, #0x40 - movs r0, #0x19 -_080A766A: - strb r0, [r1] - ldrb r0, [r5, #0xc] - adds r0, #1 - strb r0, [r5, #0xc] - adds r0, r5, #0 - bl sub_080A7824 - b _080A7692 -_080A767A: - adds r0, r2, #0 - adds r0, #0x3e - ldrb r0, [r0] - lsls r0, r0, #0x1e - lsrs r0, r0, #0x1d - adds r0, #4 - adds r1, r5, #0 - adds r1, #0x44 - strb r0, [r1] - adds r0, r5, #0 - bl sub_080A76CC -_080A7692: - ldr r0, _080A76B0 @ =gPlayerState - str r5, [r0, #0x2c] - adds r0, r5, #0 - bl sub_08079BD8 - ldr r4, _080A76B4 @ =gUnk_0812906C - ldr r0, _080A76B8 @ =gUnk_08129068 - bl GetRandomByWeight - lsls r0, r0, #1 - adds r0, r0, r4 - ldrh r0, [r0] - bl SoundReq - b _080A76C2 - .align 2, 0 -_080A76B0: .4byte gPlayerState -_080A76B4: .4byte gUnk_0812906C -_080A76B8: .4byte gUnk_08129068 -_080A76BC: - adds r0, r5, #0 - bl sub_080A76CC -_080A76C2: - movs r0, #0x87 - lsls r0, r0, #1 - bl SoundReq - pop {r4, r5, pc} - .syntax divided diff --git a/asm/non_matching/playerItemSword/sub_080A76CC.inc b/asm/non_matching/playerItemSword/sub_080A76CC.inc deleted file mode 100644 index db126d8b..00000000 --- a/asm/non_matching/playerItemSword/sub_080A76CC.inc +++ /dev/null @@ -1,180 +0,0 @@ - .syntax unified - push {r4, r5, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xa] - cmp r0, #0 - beq _080A76D8 - b _080A77DC -_080A76D8: - ldr r5, _080A771C @ =gPlayerState - ldr r0, [r5, #0x2c] - cmp r0, r4 - beq _080A76E4 - bl DeleteThisEntity -_080A76E4: - ldrb r0, [r5, #4] - cmp r0, #0 - bne _080A76F2 - str r0, [r5, #0x2c] - strb r0, [r5, #0x1b] - bl DeleteThisEntity -_080A76F2: - ldrb r2, [r5, #0x1b] - cmp r2, #0 - beq _080A7744 - adds r1, r4, #0 - adds r1, #0x40 - movs r0, #0xd - strb r0, [r1] - movs r0, #0x40 - ands r0, r2 - cmp r0, #0 - beq _080A7728 - adds r0, r4, #0 - adds r0, #0x68 - ldrb r0, [r0] - cmp r0, #1 - beq _080A7720 - cmp r0, #6 - bne _080A7724 - movs r0, #0xa - b _080A7726 - .align 2, 0 -_080A771C: .4byte gPlayerState -_080A7720: - movs r0, #8 - b _080A7726 -_080A7724: - movs r0, #9 -_080A7726: - strb r0, [r1] -_080A7728: - ldr r0, _080A7740 @ =gPlayerEntity - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x20 - ands r0, r1 - cmp r0, #0 - beq _080A77C4 - movs r0, #0x8b - lsls r0, r0, #1 - bl SoundReq - b _080A77C4 - .align 2, 0 -_080A7740: .4byte gPlayerEntity -_080A7744: - ldr r0, [r5, #0x30] - movs r1, #0x80 - lsls r1, r1, #0x14 - ands r0, r1 - cmp r0, #0 - beq _080A776A - adds r0, r4, #0 - adds r0, #0x68 - ldrb r0, [r0] - cmp r0, #6 - bne _080A7762 - adds r1, r4, #0 - adds r1, #0x40 - movs r0, #0xc - b _080A7768 -_080A7762: - adds r1, r4, #0 - adds r1, #0x40 - movs r0, #0xb -_080A7768: - strb r0, [r1] -_080A776A: - ldr r0, _080A77D0 @ =gPlayerState - adds r0, #0x3e - ldrb r0, [r0] - movs r2, #3 - ands r2, r0 - cmp r2, #0 - beq _080A77C4 - ldr r0, _080A77D4 @ =gPlayerEntity - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x40 - ands r0, r1 - cmp r0, #0 - beq _080A77C4 - movs r1, #0x12 - cmp r2, #1 - bne _080A778E - movs r1, #0x14 -_080A778E: - adds r0, r4, #0 - movs r2, #0 - bl CreateFx - adds r2, r0, #0 - cmp r2, #0 - beq _080A77C4 - ldrb r1, [r4, #0x1e] - lsls r1, r1, #1 - ldr r0, _080A77D8 @ =gUnk_081292E2 - adds r1, r1, r0 - movs r0, #1 - ldrsb r0, [r1, r0] - ldrh r3, [r4, #0x32] - adds r0, r0, r3 - strh r0, [r2, #0x32] - ldrb r1, [r1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - ldrb r0, [r4, #0x18] - lsls r0, r0, #0x19 - cmp r0, #0 - bge _080A77BE - rsbs r1, r1, #0 -_080A77BE: - ldrh r0, [r4, #0x2e] - adds r0, r0, r1 - strh r0, [r2, #0x2e] -_080A77C4: - ldr r1, _080A77D4 @ =gPlayerEntity - adds r0, r4, #0 - bl sub_080A78B8 - b _080A7806 - .align 2, 0 -_080A77D0: .4byte gPlayerState -_080A77D4: .4byte gPlayerEntity -_080A77D8: .4byte gUnk_081292E2 -_080A77DC: - ldr r1, _080A7810 @ =gPlayerState - ldrb r0, [r1, #4] - cmp r0, #0 - beq _080A7814 - ldr r0, [r1, #0x2c] - adds r2, r0, #0 - adds r2, #0x40 - ldrb r0, [r2] - cmp r0, #0 - beq _080A7814 - ldrb r1, [r4, #0x10] - movs r0, #0x80 - orrs r0, r1 - strb r0, [r4, #0x10] - ldrb r1, [r2] - adds r0, r4, #0 - adds r0, #0x40 - strb r1, [r0] - adds r0, r4, #0 - bl sub_080A7A54 -_080A7806: - adds r0, r4, #0 - bl sub_080A7A84 - b _080A7820 - .align 2, 0 -_080A7810: .4byte gPlayerState -_080A7814: - movs r0, #0xff - strb r0, [r4, #0x1e] - ldrb r1, [r4, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r4, #0x10] -_080A7820: - pop {r4, r5, pc} - .align 2, 0 - .syntax divided diff --git a/assets/assets.json b/assets/assets.json index 0e0b3675..df4d5f82 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -44376,36 +44376,6 @@ "start": 1216516, "size": 24 }, - { - "path": "playerItemSword/gUnk_08129068.bin", - "start": 1216616, - "size": 4 - }, - { - "path": "playerItemSword/gUnk_0812906C.bin", - "start": 1216620, - "size": 6 - }, - { - "path": "playerItemSword/gUnk_08129072.bin", - "start": 1216626, - "size": 28 - }, - { - "path": "playerItemSword/gUnk_0812908E.bin", - "start": 1216654, - "size": 8 - }, - { - "path": "playerItemSword/gUnk_08129096.bin", - "start": 1216662, - "size": 588 - }, - { - "path": "playerItemSword/gUnk_081292E2.bin", - "start": 1217250, - "size": 62 - }, { "path": "animations/gSpriteAnimations_RockProjectile_0.bin", "start": 1218036, diff --git a/data/const/playerItem/playerItemSword.s b/data/const/playerItem/playerItemSword.s deleted file mode 100644 index 3a930629..00000000 --- a/data/const/playerItem/playerItemSword.s +++ /dev/null @@ -1,28 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0812905C:: @ 0812905C - .4byte sub_080A758C - .4byte sub_080A76CC - .4byte sub_080A7824 - -gUnk_08129068:: @ 08129068 - .incbin "playerItemSword/gUnk_08129068.bin" - -gUnk_0812906C:: @ 0812906C - .incbin "playerItemSword/gUnk_0812906C.bin" - -gUnk_08129072:: @ 08129072 - .incbin "playerItemSword/gUnk_08129072.bin" - -gUnk_0812908E:: @ 0812908E - .incbin "playerItemSword/gUnk_0812908E.bin" - -gUnk_08129096:: @ 08129096 - .incbin "playerItemSword/gUnk_08129096.bin" - -gUnk_081292E2:: @ 081292E2 - .incbin "playerItemSword/gUnk_081292E2.bin" diff --git a/linker.ld b/linker.ld index e0631d40..994aba5c 100644 --- a/linker.ld +++ b/linker.ld @@ -1579,7 +1579,7 @@ SECTIONS { data/data_08128A38.o(.rodata); src/menu/pause_menu.o(.rodata); data/data_08128BF4.o(.rodata); - data/const/playerItem/playerItemSword.o(.rodata); + src/playerItem/playerItemSword.o(.rodata); data/projectile_functions.o(.rodata); src/projectile/darkNutSwordSlash.o(.rodata); src/projectile/rockProjectile.o(.rodata); diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c index 6a0bd260..5f6ed69a 100644 --- a/src/playerItem/playerItemSword.c +++ b/src/playerItem/playerItemSword.c @@ -2,10 +2,8 @@ #include "entity.h" #include "functions.h" #include "sound.h" - -extern void (*const gUnk_0812905C[])(Entity*); - -extern u8 gUnk_08129096[]; +#include "asm.h" +#include "effects.h" typedef struct { Entity base; @@ -16,9 +14,18 @@ void sub_080A78B8(PlayerItemSwordEntity*, Entity*); void sub_080A7B98(PlayerItemSwordEntity*); void sub_080A7A54(PlayerItemSwordEntity*); +void sub_080A7824(PlayerItemSwordEntity*); +void sub_080A76CC(PlayerItemSwordEntity*); +void sub_080A758C(PlayerItemSwordEntity*); +void sub_080A7A84(PlayerItemSwordEntity*); void PlayerItemSword(Entity* this) { - gUnk_0812905C[this->action](this); + static void (*const gUnk_0812905C[])(PlayerItemSwordEntity*) = { + sub_080A758C, + sub_080A76CC, + sub_080A7824, + }; + gUnk_0812905C[this->action]((PlayerItemSwordEntity*)this); if (this->type == 0) { sub_08078E84(this, &gPlayerEntity); this->hitbox->offset_x += this->spriteOffsetX; @@ -26,9 +33,191 @@ void PlayerItemSword(Entity* this) { } } -ASM_FUNC("asm/non_matching/playerItemSword/sub_080A758C.inc", void sub_080A758C(Entity* this)) +void sub_080A758C(PlayerItemSwordEntity* this) { + static const u8 gUnk_08129068[] = { + 0x56, + 0x55, + 0x55, + 0x0, + }; + static const u16 gUnk_0812906C[] = { + SFX_PLY_VO1, + SFX_PLY_VO4, + SFX_PLY_VO5, + }; + if (((super->type == 0) && (gPlayerState.field_0x3[1] == 0)) && ((gPlayerState.jump_status & 0x20) == 0)) { + DeleteThisEntity(); + } + if (AllocMutableHitbox(super) == NULL) { + DeleteThisEntity(); + } + LoadSwapGFX(super, 1, 3); + super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20; + super->flags2 = gPlayerEntity.flags2; + super->updatePriority = 6; + super->contactFlags = 0; + super->iframes = 0; + super->knockbackDuration = 0; + super->action++; + super->frameIndex = 0xff; + sub_0801766C(super); + if (super->type == 0) { + if ((gPlayerState.jump_status & 0x20) != 0) { + super->flags &= ~ENT_COLLIDE; + super->type2 = 2; + super->damage = gPlayerState.swordDamage * 2 + 8; + switch (this->unk_68) { + case 6: + super->hurtType = 0x1a; + break; + case 1: + super->hurtType = 0x18; + break; + default: + super->hurtType = 0x19; + break; + } + super->action++; + sub_080A7824(this); + } else { + super->damage = gPlayerState.swordDamage * 2 + 4; + sub_080A76CC(this); + } + gPlayerState.item = super; + sub_08079BD8(super); + SoundReq(gUnk_0812906C[GetRandomByWeight(gUnk_08129068)]); + } else { + sub_080A76CC(this); + } + SoundReq(SFX_10E); +} -ASM_FUNC("asm/non_matching/playerItemSword/sub_080A76CC.inc", void sub_080A76CC(Entity* this)) +static const s8 gUnk_08129072[] = { 0x0, 0xd, 0xf, -0x3, 0x0, -0x16, -0x10, 0xd, 0x10, 0xd, + 0x10, -0x13, -0x10, -0x13, 0x0, -0x3, 0x10, -0x3, -0x10, -0x3, + -0xc, 0x7, 0xc, 0x7, 0xc, -0xf, -0xc, -0xf }; + +static const s8 gUnk_0812908E[] = { -0x2, -0xf, 0xb, -0x3, 0x2, 0x7, -0xb, -0x3 }; + +static const s8 gUnk_08129096[] = { + -0x10, 0x0, 0x6, 0x3, -0x8, 0x8, 0x8, 0x8, -0x8, 0x8, 0x8, 0x8, 0x0, 0xc, 0xb, 0xb, + 0x6, 0xc, 0x8, 0x8, 0xa, 0xb, 0x6, 0x6, 0xa, 0x8, 0x6, 0x6, 0xc, 0x4, 0x6, 0x6, + 0xc, 0x4, 0x6, 0x6, 0x0, 0x0, 0x0, 0x0, 0x2, 0xb, 0x4, 0x8, 0x2, 0xb, 0x4, 0x8, + 0x0, -0x10, 0x5, 0x6, -0xc, -0xc, 0x8, 0x8, -0x10, -0xc, 0x8, 0x8, -0x14, 0x0, 0xa, 0xa, + -0x12, 0x4, 0x8, 0x8, -0x10, 0x8, 0x6, 0x6, -0xc, 0x6, 0x6, 0x6, -0x8, 0x6, 0x6, 0x6, + -0x8, 0x6, 0x6, 0x6, 0x0, 0x0, 0x0, 0x0, -0x10, 0x0, 0x8, 0x4, -0x10, 0x0, 0x8, 0x4, + 0xe, -0x6, 0x6, 0x6, 0x10, -0x10, 0x8, 0x8, 0x10, -0x10, 0x8, 0x8, 0x0, -0x14, 0xa, 0xa, + 0x0, -0x14, 0x8, 0x8, -0xc, -0x12, 0x6, 0x6, -0xc, -0xe, 0x6, 0x6, -0xc, -0xa, 0x6, 0x6, + -0xc, -0xa, 0x6, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, -0x12, 0x4, 0x8, 0x0, -0x12, 0x4, 0x8, + 0x2, 0xb, 0x4, 0x8, 0x2, 0xb, 0x4, 0x8, 0x2, 0xb, 0x4, 0x8, 0x2, 0xb, 0x4, 0x8, + 0x2, 0xb, 0x4,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8, 0x0, -0x12, 0x4, 0x8, 0x0, -0x12, 0x4, 0x8, + 0x0, -0x12, 0x4, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 +}; + +static const s8 gUnk_081292E2[] = { 0x0, 0x2, -0x8, 0xa, -0x8, 0xa, 0x0, 0xe, 0x6, 0xe, 0xa, + 0xd, 0xa, 0xa, 0xc, 0x6, 0x0, 0x2, 0x2, 0xb, 0x2, 0xb, + -0x2, 0x0, -0xe, -0xc, -0x12, -0xc, -0x16, 0x0, -0x14, 0x4, -0x12, + 0x8, -0xe, 0x6, -0xa, 0xa, -0x2, 0x0, -0x10, 0x0, -0x10, 0x0, + 0x0, -0x2, 0x10, -0x12, 0x10, -0x12, 0x0, -0x16, 0x0, -0x16, -0xc, + -0x14, -0xc, -0x10, -0xc, -0xc, 0x0, -0x2 }; + +void sub_080A76CC(PlayerItemSwordEntity* this) { + Entity* effect; + Effect type; + const s8* ptr; + s32 tmp; + + if (super->type == 0) { + if ((PlayerItemSwordEntity*)gPlayerState.item != this) { + DeleteThisEntity(); + } + if (gPlayerState.field_0x3[1] == 0) { + gPlayerState.item = NULL; + gPlayerState.sword_state = 0; + DeleteThisEntity(); + } + if (gPlayerState.sword_state != 0) { + super->hurtType = 0xd; + if ((gPlayerState.sword_state & 0x40) != 0) { + switch (this->unk_68) { + case 6: + super->hurtType = 0xa; + break; + case 1: + super->hurtType = 8; + break; + default: + super->hurtType = 9; + break; + } + } + if ((gPlayerEntity.frame & 0x20) != 0) { + SoundReq(SFX_116); + } + } else { + + if ((gPlayerState.flags & 0x8000000) != 0) { + if (this->unk_68 == 6) { + super->hurtType = 0xc; + } else { + super->hurtType = 0xb; + } + } + if (((gPlayerState.swordDamage) != 0) && ((gPlayerEntity.frame & 0x40) != 0)) { + type = FX_BLUE_SPARKLE; + if ((gPlayerState.swordDamage) == 1) { + type = FX_SPARKLE2; + } + effect = CreateFx(super, type, 0); + if (effect != NULL) { + ptr = &gUnk_081292E2[super->frameIndex * 2]; + effect->y.HALF.HI = super->y.HALF.HI + ptr[1]; + tmp = ptr[0]; + if ((*(u8*)&super->spriteSettings * 0x2000000) < 0) { // TODO + tmp = -tmp; + } + effect->x.HALF.HI = super->x.HALF.HI + tmp; + } + } + } + sub_080A78B8(this, &gPlayerEntity); + sub_080A7A84(this); + } else { + if (!((gPlayerState.field_0x3[1] == 0) || (gPlayerState.item->hurtType == 0))) { + super->flags |= ENT_COLLIDE; + super->hurtType = gPlayerState.item->hurtType; + sub_080A7A54(this); + sub_080A7A84(this); + } else { + super->frameIndex = 0xff; + super->flags &= ~ENT_COLLIDE; + } + } +} void sub_080A7824(PlayerItemSwordEntity* this) { if (gPlayerState.item != super) { @@ -137,7 +326,7 @@ void sub_080A78B8(PlayerItemSwordEntity* this, Entity* param_2) { } void sub_080A7A54(PlayerItemSwordEntity* this) { - u8* tmp; + const u8* tmp; tmp = &gUnk_08129096[(gPlayerEntity.frameIndex - 0x6a) * 4]; super->hitbox->offset_x = tmp[0]; @@ -146,6 +335,6 @@ void sub_080A7A54(PlayerItemSwordEntity* this) { super->hitbox->height = tmp[3]; } -ASM_FUNC("asm/non_matching/playerItemSword/sub_080A7A84.inc", void sub_080A7A84(Entity* this)) +ASM_FUNC("asm/non_matching/playerItemSword/sub_080A7A84.inc", void sub_080A7A84(PlayerItemSwordEntity* this)) ASM_FUNC("asm/non_matching/playerItemSword/sub_080A7B98.inc", void sub_080A7B98(PlayerItemSwordEntity* this))