diff --git a/asm/non_matching/itemSword/sub_080754B8.inc b/asm/non_matching/itemSword/sub_080754B8.inc deleted file mode 100644 index ae6d7dce..00000000 --- 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 31991b9c..00000000 --- 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 d10ea4ab..00000000 --- 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/include/playeritem.h b/include/playeritem.h new file mode 100644 index 00000000..fcf643d9 --- /dev/null +++ b/include/playeritem.h @@ -0,0 +1,32 @@ +#ifndef PLAYERITEM_H +#define PLAYERITEM_H + +typedef enum { + PLAYER_ITEM_NONE, + PLAYER_ITEM_SWORD, + PLAYER_ITEM_BOMB, + PLAYER_ITEM_3, + PLAYER_ITEM_BOW, + PLAYER_ITEM_SHIELD, + PLAYER_ITEM_LANTERN, + PLAYER_ITEM_7, + PLAYER_ITEM_GUST_JAR, + PLAYER_ITEM_PACCI_CANE, + PLAYER_ITEM_A, + PLAYER_ITEM_B, + PLAYER_ITEM_C, + PLAYER_ITEM_CELL_OVERWRITE_SET, + PLAYER_ITEM_BOTTLE, + PLAYER_ITEM_SWORD_BEAM1, + PLAYER_ITEM_10, + PLAYER_ITEM_11, + PLAYER_ITEM_12, + PLAYER_ITEM_13, + PLAYER_ITEM_14, + PLAYER_ITEM_15, + PLAYER_ITEM_SWORD_BEAM2, + PLAYER_ITEM_17, + PLAYER_ITEM_CELL_OVERWRITE_SET2, +} PlayerItem; + +#endif diff --git a/src/code_08077B98.c b/src/code_08077B98.c index 2d011e33..970644d3 100644 --- a/src/code_08077B98.c +++ b/src/code_08077B98.c @@ -83,7 +83,7 @@ void* sub_08077C54(UnkItemStruct* unk) { Entity* sub_08077C94(ItemBehavior* arg0, u32 arg1) { Entity* iVar1; - iVar1 = FindEntityByID(8, gUnk_0811BE48[arg1].unk0[3], 2); + iVar1 = FindEntityByID(PLAYER_ITEM, gUnk_0811BE48[arg1].unk0[3], 2); if (iVar1 == NULL) { return NULL; } diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 9fa20418..f89f23e0 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -10,6 +10,7 @@ #include "game.h" #include "functions.h" #include "save.h" +#include "playeritem.h" void sub_080249F4(Entity*); void sub_08024940(Entity*); @@ -659,7 +660,7 @@ bool32 sub_08024B38(Entity* this) { } } - ent = FindEntityByID(8, 2, 2); + ent = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2); if (ent) { do { if (ent->action != 2 && ent->z.HALF.HI == 0 && sub_08049F1C(this, ent, 0xa0)) { @@ -676,7 +677,7 @@ bool32 sub_08024B38(Entity* this) { return iVar4; } - ent = FindEntityByID(6, 5, 6); + ent = FindEntityByID(OBJECT, POT, 6); if (ent) { do { if (ent->action == 1 && sub_08049F1C(this, ent, 0xa0)) { diff --git a/src/item/itemBomb.c b/src/item/itemBomb.c index 4cba1598..4154e1f6 100644 --- a/src/item/itemBomb.c +++ b/src/item/itemBomb.c @@ -2,6 +2,7 @@ #include "coord.h" #include "sound.h" #include "functions.h" +#include "playeritem.h" extern void (*const gUnk_0811BD98[])(ItemBehavior*, u32); @@ -23,7 +24,8 @@ void sub_08075FF8(ItemBehavior* this, u32 arg1) { if ((gPlayerState.jump_status | gPlayerState.field_0x3[1]) == 0) { bombCount = 0; - for (entity = FindEntityByID(8, 2, 2); entity != NULL; entity = FindNextDuplicateID(entity, 2)) { + for (entity = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2); entity != NULL; + entity = FindNextDuplicateID(entity, 2)) { bombCount += 1; } maxBombs = this->behaviorID == 7 ? 3 : 1; diff --git a/src/item/itemSword.c b/src/item/itemSword.c index 7a794159..ae15069d 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, PLAYER_ITEM_SWORD_BEAM1, 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) { diff --git a/src/manager/manager22.c b/src/manager/manager22.c index 4d6130cc..a8bb0794 100644 --- a/src/manager/manager22.c +++ b/src/manager/manager22.c @@ -159,7 +159,7 @@ void sub_0805BB74(s32 lightLevel) { } gArea.lightLevel = lightLevel; gRoomVars.lightLevel = gArea.lightLevel; - manager = (Manager22*)DeepFindEntityByID(9, 0x22); + manager = (Manager22*)DeepFindEntityByID(MANAGER, 0x22); if (manager) { Manager22_Main(manager); gScreen.lcd.displayControl |= DISPCNT_BG3_ON; diff --git a/src/manager/manager36.c b/src/manager/manager36.c index ca9c5c24..7dcf71c4 100644 --- a/src/manager/manager36.c +++ b/src/manager/manager36.c @@ -36,7 +36,7 @@ void CreateManager36(Entity* entity, ScriptExecutionContext* context) { } void DeleteManager36(Entity* entity, ScriptExecutionContext* context) { - Entity* manager = FindEntity(9, 0x36, 6, context->intVariable, 0); + Entity* manager = FindEntity(MANAGER, 0x36, 6, context->intVariable, 0); if (manager != NULL) { DeleteEntityAny(manager); } diff --git a/src/manager/managerF.c b/src/manager/managerF.c index f1cc1aca..1c3bd127 100644 --- a/src/manager/managerF.c +++ b/src/manager/managerF.c @@ -286,7 +286,7 @@ void sub_08059220(ManagerF* this) { void sub_08059278(void) { ManagerF* tmp; - tmp = (ManagerF*)FindEntityByID(0x9, 0xF, 0x6); + tmp = (ManagerF*)FindEntityByID(MANAGER, 0xF, 0x6); if (tmp) { sub_08058ECC(tmp); } diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index cb791a38..182b71f1 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -77,7 +77,7 @@ void sub_0806CF30(Entity* this) { } Entity* sub_0806D00C(Entity* this) { - Entity* entity = FindEntity(7, 76, 7, 0, 0); + Entity* entity = FindEntity(NPC, BIG_GORON, 7, 0, 0); if (entity != NULL) { this->parent = entity; } @@ -100,7 +100,7 @@ void sub_0806D0B0(Entity* this) { } void sub_0806D0F8(void) { - Entity* entity = FindEntityByID(7, 0x4c, 7); + Entity* entity = FindEntityByID(NPC, BIG_GORON, 7); if (entity != NULL) { sub_0806D0B0(entity); } @@ -359,22 +359,22 @@ void sub_0806D66C(Entity* this) { ASM_FUNC("asm/non_matching/bigGoron/sub_0806D67C.inc", void sub_0806D67C(Entity* this)) void sub_0806D6D0(void) { - Entity* entity = FindEntity(7, 0x4c, 7, 2, 0); + Entity* entity = FindEntity(NPC, BIG_GORON, 7, 2, 0); if (entity != NULL) { entity->subAction = 2; } - entity = FindEntity(7, 0x4c, 7, 1, 0); + entity = FindEntity(NPC, BIG_GORON, 7, 1, 0); if (entity != NULL) { entity->subAction = 1; } } void sub_0806D70C(void) { - Entity* entity = FindEntity(7, 0x4c, 7, 2, 0); + Entity* entity = FindEntity(NPC, BIG_GORON, 7, 2, 0); if (entity != NULL) { entity->subAction = 0; } - entity = FindEntity(7, 0x4c, 7, 1, 0); + entity = FindEntity(NPC, BIG_GORON, 7, 1, 0); if (entity != NULL) { entity->subAction = 0; entity->spriteSettings.draw = 3; @@ -382,22 +382,22 @@ void sub_0806D70C(void) { } void sub_0806D74C(void) { - Entity* entity = FindEntity(7, 0x4c, 7, 2, 0); + Entity* entity = FindEntity(NPC, BIG_GORON, 7, 2, 0); if (entity != NULL) { entity->subAction = 3; } - entity = FindEntity(7, 0x4c, 7, 1, 0); + entity = FindEntity(NPC, BIG_GORON, 7, 1, 0); if (entity != NULL) { entity->subAction = 2; } } void sub_0806D788(void) { - Entity* entity = FindEntity(7, 0x4c, 7, 2, 0); + Entity* entity = FindEntity(NPC, BIG_GORON, 7, 2, 0); if (entity != NULL) { entity->subAction = 4; } - entity = FindEntity(7, 0x4c, 7, 1, 0); + entity = FindEntity(NPC, BIG_GORON, 7, 1, 0); if (entity != NULL) { entity->subAction = 1; } @@ -408,14 +408,14 @@ void sub_0806D7C4(Entity* this, ScriptExecutionContext* context) { this->x.HALF.HI = gPlayerEntity.x.HALF.HI; this->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0x18; - entity = FindEntity(7, 0x4c, 7, 2, 0); + entity = FindEntity(NPC, BIG_GORON, 7, 2, 0); if (entity != NULL) { sub_0807DEDC(this, context, entity->x.HALF.HI, entity->y.HALF.HI); } } void sub_0806D804(Entity* this, ScriptExecutionContext* context) { - Entity* entity = FindEntity(7, 0x4c, 7, 2, 0); + Entity* entity = FindEntity(NPC, BIG_GORON, 7, 2, 0); if (entity != NULL) { this->x.HALF.HI = entity->x.HALF.HI; this->y.HALF.HI = entity->y.HALF.HI - 0x10; diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index ea0b9bb7..e31cb80d 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -1,6 +1,7 @@ #include "npc.h" #include "object.h" #include "functions.h" +#include "playeritem.h" extern void sub_080600F0(Entity*); extern void sub_08060158(Entity*); @@ -215,7 +216,7 @@ void sub_08060318(void) { int i; for (i = 2; i >= 0; i--) { - ent = FindEntityByID(8, 2, 2); + ent = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2); if (ent != NULL) { CreateDust(ent); DeleteEntity(ent); diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 07f6117f..0aae9b37 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -83,7 +83,7 @@ void sub_08069660(Entity* this) { void sub_08069684(void) { Manager* mgr; - if (FindEntityByID(9, 0x31, 8) == NULL) { + if (FindEntityByID(MANAGER, 0x31, 8) == NULL) { mgr = GetEmptyManager(); if (mgr != NULL) { mgr->type = 9; diff --git a/src/npc/guardWithSpear.c b/src/npc/guardWithSpear.c index ddb8ffde..8293f541 100644 --- a/src/npc/guardWithSpear.c +++ b/src/npc/guardWithSpear.c @@ -1,12 +1,13 @@ #include "entity.h" #include "script.h" #include "player.h" +#include "npc.h" ASM_FUNC("asm/non_matching/guardWithSpear/sub_0806407C.inc", void sub_0806407C(Entity* this, ScriptExecutionContext* context)) void sub_08064180(void) { - Entity* entity = FindEntityByID(7, 0x15, 7); + Entity* entity = FindEntityByID(NPC, GUARD_1, 7); if (entity != NULL) { DeleteEntity(entity); } diff --git a/src/npc/malon.c b/src/npc/malon.c index 77d6a20c..2a3b2fa1 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -56,12 +56,12 @@ void sub_08065900(Entity* this) { void sub_08065914(Entity* this) { Entity* target; - target = FindEntityByID(7, 0x1F, 7); + target = FindEntityByID(NPC, EPONA, 7); if (target != NULL) { PositionRelative(this, target, Q_16_16(24.0), Q_16_16(-1.0)); target->parent = this; } - target = FindEntityByID(7, 0x20, 7); + target = FindEntityByID(NPC, MILK_CART, 7); if (target != NULL) { PositionRelative(this, target, Q_16_16(40.0), 0); target->parent = this; diff --git a/src/npc/pina.c b/src/npc/pina.c index 5d49e1b3..3186f3ea 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -102,35 +102,35 @@ void sub_08063B68(Entity* this) { } void sub_08063C14(void) { - Entity* entity = DeepFindEntityByID(7, 0x14); + Entity* entity = DeepFindEntityByID(NPC, PINA); if (entity != NULL) { InitAnimationForceUpdate(entity, 8); } } void sub_08063C2C(void) { - Entity* entity = DeepFindEntityByID(7, 0x14); + Entity* entity = DeepFindEntityByID(NPC, PINA); if (entity != NULL) { InitAnimationForceUpdate(entity, 4); } } void sub_08063C44(void) { - Entity* entity = DeepFindEntityByID(7, 0x14); + Entity* entity = DeepFindEntityByID(NPC, PINA); if (entity != NULL) { InitAnimationForceUpdate(entity, 0); } } void sub_08063C5C(void) { - Entity* entity = DeepFindEntityByID(7, 0x14); + Entity* entity = DeepFindEntityByID(NPC, PINA); if (entity != NULL) { InitAnimationForceUpdate(entity, 9); } } void sub_08063C74(void) { - Entity* entity = DeepFindEntityByID(7, 0x14); + Entity* entity = DeepFindEntityByID(NPC, PINA); if (entity != NULL) { CreateSpeechBubbleExclamationMark(entity, 8, 0xffffffe8); } diff --git a/src/npc/rem.c b/src/npc/rem.c index 392c8198..8c2c98f8 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -309,7 +309,7 @@ void sub_0806AB74(Entity* this) { } void sub_0806AB9C(Entity* this, ScriptExecutionContext* context) { - Entity* entity = FindEntity(7, 0x37, 7, 1, 0); + Entity* entity = FindEntity(NPC, REM, 7, 1, 0); if (entity != NULL) { DeleteEntity(entity); } diff --git a/src/npc/zelda.c b/src/npc/zelda.c index 90222873..46187a72 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -30,7 +30,7 @@ void sub_08066CF8(Entity* this) { } void sub_08066D04(Entity* this) { - this->parent = DeepFindEntityByID(7, 0x2E); + this->parent = DeepFindEntityByID(NPC, ZELDA_FOLLOWER); } void sub_08066D14(Entity* this, ScriptExecutionContext* context) { @@ -85,7 +85,7 @@ void sub_08066D94(Entity* this) { void SetZeldaFollowTarget(Entity* this) { Entity* pEVar1; - pEVar1 = DeepFindEntityByID(7, 0x2E); + pEVar1 = DeepFindEntityByID(NPC, ZELDA_FOLLOWER); if (pEVar1 != NULL) { CopyPosition(this, pEVar1); sub_080686C4(this, pEVar1); diff --git a/src/npcUtils.c b/src/npcUtils.c index bf609c86..1fabfe67 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -34,7 +34,7 @@ void sub_0806EC20(Entity* ent) { } void sub_0806EC38(void) { - Entity* e = FindEntityByID(7, 0x58, 7); + Entity* e = FindEntityByID(NPC, NPC_UNK_58, 7); if (e != NULL) DeleteEntity(e); } diff --git a/src/object/book.c b/src/object/book.c index c0003115..3cea262b 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -2,6 +2,7 @@ #include "functions.h" #include "message.h" #include "item.h" +#include "npc.h" extern void (*const BookActionFuncs[])(Entity*); extern s8 const gUnk_08123D94[]; @@ -152,7 +153,7 @@ void sub_0809B5EC(Entity* this) { switch (this->subAction) { case 0: { Entity* parent; - parent = FindEntityByID(7, 26, 7); + parent = FindEntityByID(NPC, STURGEON, 7); if (!parent) { return; } diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index a0e29797..a03d9344 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -517,7 +517,7 @@ void sub_080873FC(void) { SoundReq(SFX_APPARATE); gRoomControls.camera_target = NULL; - while (ent = FindEntityByID(0x6, 0x1b, 0x6), ent != NULL) { + while (ent = FindEntityByID(OBJECT, GREAT_FAIRY, 0x6), ent != NULL) { DeleteEntity(ent); } } @@ -546,7 +546,7 @@ void sub_08087424(Entity* this, ScriptExecutionContext* context) { void sub_0808747C(Entity* this, ScriptExecutionContext* context) { u32 iVar1 = 0; - iVar1 = (u32)FindEntity(0x6, 0xf, 0x6, 0xb, 0x0); + iVar1 = (u32)FindEntity(OBJECT, SPECIAL_FX, 0x6, 0xb, 0x0); if (iVar1 != 0) { iVar1 = 1; } diff --git a/src/object/object6A.c b/src/object/object6A.c index 0d2fb68e..2b655443 100644 --- a/src/object/object6A.c +++ b/src/object/object6A.c @@ -195,7 +195,7 @@ void sub_08094B94(Object6AEntity* this) { } void sub_08094BE0(Entity* this) { - Entity* e = FindEntity(6, OBJECT_6A, 6, 0x22, 0); + Entity* e = FindEntity(OBJECT, OBJECT_6A, 6, 0x22, 0); if (e != NULL) { CopyPosition(&gPlayerEntity, e); e->z.HALF.HI = -12; @@ -257,14 +257,14 @@ void sub_08094CDC(Object6AEntity* this) { } void sub_08094D10(Object6AEntity* this) { - Entity* e = FindEntity(6, 0x6a, 6, 3, 98); + Entity* e = FindEntity(OBJECT, OBJECT_6A, 6, 3, 98); if (e != NULL) { e->action = 0xFF; } } void sub_08094D34(Object6AEntity* this) { - Entity* e = CreateObject(0x6a, 0x15, 0xd); + Entity* e = CreateObject(OBJECT_6A, 0x15, 0xd); if (e != NULL) { e->x.HALF.HI = gRoomControls.origin_x + Q_8_8(1.0); e->y.HALF.HI = gRoomControls.origin_y + Q_8_8(2.345); @@ -273,7 +273,7 @@ void sub_08094D34(Object6AEntity* this) { } void sub_08094D70(Object6AEntity* this) { - Entity* e = FindEntity(6, 0x6a, 6, 0x15, 0xd); + Entity* e = FindEntity(OBJECT, OBJECT_6A, 6, 0x15, 0xd); if (e != NULL) { e->action = 0xFF; } @@ -306,7 +306,7 @@ void sub_08094DD8(Object6AEntity* this) { } void sub_08094E0C(Object6AEntity* this) { - Entity* e = FindEntity(6, 0x6a, 6, 4, 0); + Entity* e = FindEntity(OBJECT, OBJECT_6A, 6, 4, 0); if (e != NULL) { e->action = 0xFF; } @@ -483,7 +483,7 @@ void sub_08095120(Object6AEntity* this) { } void sub_08095164(Object6AEntity* this) { - Entity* e = FindEntity(6, 0x6A, 6, 8, 0); + Entity* e = FindEntity(OBJECT, OBJECT_6A, 6, 8, 0); if (e != NULL) { InitAnimationForceUpdate(e, 3); }