diff --git a/asm/non_matching/playerUtils/sub_08077880.inc b/asm/non_matching/playerUtils/sub_08077880.inc deleted file mode 100644 index ee9a0c39..00000000 --- a/asm/non_matching/playerUtils/sub_08077880.inc +++ /dev/null @@ -1,40 +0,0 @@ - .syntax unified - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r6, r1, #0 - subs r0, r4, #1 - cmp r0, #0x1e - bhi _080778C0 - lsls r0, r4, #1 - adds r0, r0, r4 - lsls r0, r0, #2 - ldr r1, _080778C4 @ =gUnk_0811BE48 - adds r5, r0, r1 - ldr r1, _080778C8 @ =gPlayerState + 0x90 - ldrb r0, [r5] - cmp r0, #0 - beq _080778A0 - adds r1, #2 -_080778A0: - ldrh r0, [r1] - ands r0, r6 - cmp r0, #0 - bne _080778AC - cmp r2, #0 - beq _080778C0 -_080778AC: - adds r0, r4, #0 - bl sub_0807794C - adds r1, r0, #0 - cmp r1, #0 - beq _080778C0 - ldrb r0, [r5, #1] - strb r0, [r1, #9] - strb r4, [r1, #1] - strb r6, [r1, #3] -_080778C0: - pop {r4, r5, r6, pc} - .align 2, 0 -_080778C4: .4byte gUnk_0811BE48 -_080778C8: .4byte gPlayerState + 0x90 - .syntax divided diff --git a/src/playerUtils.c b/src/playerUtils.c index 35a80159..923f5db3 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -215,27 +215,27 @@ bool32 sub_080777A0(void) { } } -NONMATCH("asm/non_matching/playerUtils/sub_08077880.inc", void sub_08077880(u32 param_1, u32 param_2, u32 param_3)) { +void sub_08077880(Item itemId, u32 param_2, u32 param_3) { ItemBehavior* item; u16* puVar2; - if (param_1 - 1 < 0x1f) { - if (gUnk_0811BE48[param_1].unk0[0] != 0) { + if (itemId - 1 < 0x1f) { + struct_0811BE48* ptr = &gUnk_0811BE48[itemId]; + puVar2 = &gPlayerState.field_0x90; + if (ptr->unk0[0] != 0) { puVar2 = &gPlayerState.field_0x92; - } else { - puVar2 = &gPlayerState.field_0x90; } + if (((*puVar2 & param_2) != 0) || (param_3 != 0)) { - item = sub_0807794C(param_1); + item = sub_0807794C(itemId); if (item != NULL) { - item->field_0x5[4] = gUnk_0811BE48[param_1].unk0[1]; - item->behaviorID = (u8)param_1; - item->field_0x2[1] = (u8)param_2; + item->field_0x5[4] = gUnk_0811BE48[itemId].unk0[1]; + item->behaviorID = itemId; + item->field_0x2[1] = param_2; } } } } -END_NONMATCH bool32 sub_080778CC(void) { ItemBehavior* item; @@ -246,9 +246,9 @@ bool32 sub_080778CC(void) { (((sub_080789A8() != 0 || ((gPlayerState.field_0x90 & 0xf03) == 0)))))) { return FALSE; } - item = sub_0807794C(0x1b); + item = sub_0807794C(ITEM_TRAP); if (item != NULL) { - item->behaviorID = 0x1b; + item->behaviorID = ITEM_TRAP; item->field_0x5[4] = gUnk_0811BE48[0].unk0[0x145]; return TRUE; } else { @@ -256,16 +256,16 @@ bool32 sub_080778CC(void) { } } -ItemBehavior* sub_0807794C(u32 param_1) { - if (((((gPlayerState.queued_action == PLAYER_ROLL) && (param_1 != 0x1b)) || - (((gPlayerState.flags & (PL_ROLLING | PL_CLONING)) != 0 && (6 < param_1)))) || - ((((gPlayerState.jump_status != 0 || (gPlayerEntity.z.WORD != 0)) && (6 < param_1)) || - (((gPlayerState.flags & PL_MINISH) != 0 && (gUnk_0811BE48[param_1].unk6[2] == 0)))))) || - ((gPlayerState.floor_type == SURFACE_SWAMP && ((gPlayerState.field_0x37 != 0 && (1 < param_1 - 0x14)))))) { +ItemBehavior* sub_0807794C(Item itemId) { + if (((((gPlayerState.queued_action == PLAYER_ROLL) && (itemId != ITEM_TRAP)) || + (((gPlayerState.flags & (PL_ROLLING | PL_CLONING)) != 0 && (ITEM_FOURSWORD < itemId)))) || + ((((gPlayerState.jump_status != 0 || (gPlayerEntity.z.WORD != 0)) && (ITEM_FOURSWORD < itemId)) || + (((gPlayerState.flags & PL_MINISH) != 0 && (gUnk_0811BE48[itemId].unk6[2] == 0)))))) || + ((gPlayerState.floor_type == SURFACE_SWAMP && ((gPlayerState.field_0x37 != 0 && (1 < itemId - 0x14)))))) { return NULL; } else { - u32 tmp = gUnk_0811BE48[param_1].unk0[2]; - return gUnk_0811BFC8[tmp](param_1); + u32 tmp = gUnk_0811BE48[itemId].unk0[2]; + return gUnk_0811BFC8[tmp](itemId); } }