From 2816176661b0262387408411f95b0c02af3a7d41 Mon Sep 17 00:00:00 2001 From: KEKW555 <152369890+KEKW555@users.noreply.github.com> Date: Thu, 28 Dec 2023 09:50:15 +0530 Subject: [PATCH 1/6] Remove sub_0809CBE4 fake match --- src/object/frozenOctorok.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/object/frozenOctorok.c b/src/object/frozenOctorok.c index 7aaaac94..6f46ac27 100644 --- a/src/object/frozenOctorok.c +++ b/src/object/frozenOctorok.c @@ -421,16 +421,9 @@ void sub_0809CB70(FrozenOctorokEntity* this, s32 angle, s32 radius) { } void sub_0809CBE4(FrozenOctorokEntity* this) { - u16 tmp1; - FORCE_REGISTER(u8 tmp4, r4); - u8* tmp3 = &this->unk_79; - tmp1 = super->subtimer; - tmp4 = *tmp3; - tmp1 += tmp4; - this->unk_79 = tmp1; + this->unk_79 += super->subtimer; if ((s8)super->subtimer < 0) { - u8 tmp_r0 = super->timer; - if (tmp1 << 0x18 < -tmp_r0 << 0x18) { + if ((s8)this->unk_79 < (s8)-super->timer) { super->subtimer = -super->subtimer; SoundReq(SFX_19E); } From acc75c269df3ddcc3eea32bae5725c94a132fa24 Mon Sep 17 00:00:00 2001 From: theo3 Date: Thu, 28 Dec 2023 16:04:32 -0800 Subject: [PATCH 2/6] use correct signedness for char in tools --- tools/src/asset_processor/reader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/src/asset_processor/reader.h b/tools/src/asset_processor/reader.h index dc2159fc..d31bf0f0 100644 --- a/tools/src/asset_processor/reader.h +++ b/tools/src/asset_processor/reader.h @@ -13,7 +13,7 @@ class Reader { [[nodiscard]] s8 read_s8() { // TODO range check - return data[static_cast(cursor++)]; + return static_cast(data[static_cast(cursor++)]); } [[nodiscard]] u8 read_u8() { @@ -35,4 +35,4 @@ class Reader { // const int size; }; -#endif \ No newline at end of file +#endif From 7c1c612c9ba95b47f33cfd217ab99c4c9102531e Mon Sep 17 00:00:00 2001 From: theo3 Date: Thu, 28 Dec 2023 17:48:05 -0800 Subject: [PATCH 3/6] fix fakematch in LinkHoldingItem_Action3 --- include/player.h | 32 +++++++++++------------ src/beanstalkSubtask.c | 6 ++--- src/code_0805EC04.c | 26 +++++++++---------- src/enemy/likeLike.c | 8 +++--- src/item/itemPegasusBoots.c | 6 ++--- src/item/itemTryPickupObject.c | 4 +-- src/itemUtils.c | 20 +++++++------- src/manager/miscManager.c | 2 +- src/menu/pauseMenu.c | 4 +-- src/npc/bigGoron.c | 2 +- src/npc/bladeBrothers.c | 4 +-- src/npc/npc4E.c | 4 +-- src/object/crenelBeanSprout.c | 2 +- src/object/houseDoorExterior.c | 2 +- src/object/itemForSale.c | 4 +-- src/object/linkHoldingItem.c | 10 +++---- src/player.c | 15 +++++------ src/playerItem/playerItemBomb.c | 4 +-- src/playerUtils.c | 46 ++++++++++++++++----------------- src/title.c | 2 +- src/ui.c | 2 +- 21 files changed, 101 insertions(+), 104 deletions(-) diff --git a/include/player.h b/include/player.h index 49a4bce7..19be9997 100644 --- a/include/player.h +++ b/include/player.h @@ -243,23 +243,21 @@ typedef struct { } PlayerMacroEntry; typedef enum { - PLAYER_INPUT_1 = 0x1, // A - PLAYER_INPUT_2 = 0x2, // B - PLAYER_INPUT_8 = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2 - PLAYER_INPUT_10 = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2 - PLAYER_INPUT_20 = 0x20, // R sub_0807953C - PLAYER_INPUT_40 = 0x40, // A CrenelBeanSprout_Action1 - PLAYER_INPUT_80 = + INPUT_USE_ITEM1 = 0x1, // A + INPUT_USE_ITEM2 = 0x2, // B + INPUT_INTERACT = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2 + INPUT_CANCEL = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2 + INPUT_CONTEXT = 0x20, // R sub_0807953C + INPUT_40 = 0x40, // A CrenelBeanSprout_Action1 + INPUT_ACTION = 0x80, // R sub_08073584, IsPreventedFromUsingItem, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2 - PLAYER_INPUT_RIGHT = 0x100, - PLAYER_INPUT_LEFT = 0x200, - PLAYER_INPUT_UP = 0x400, - PLAYER_INPUT_DOWN = 0x800, - PLAYER_INPUT_ANY_DIRECTION = 0xf00, - PLAYER_INPUT_1000 = 0x1000, // L, where is it set? sub_080782C0 - PLAYER_INPUT_8000 = 0x8000, // R, IsTryingToPickupObject, sub_08076518 - - // TODO What is the result of u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000;? + INPUT_RIGHT = 0x100, + INPUT_LEFT = 0x200, + INPUT_UP = 0x400, + INPUT_DOWN = 0x800, + INPUT_ANY_DIRECTION = 0xf00, + INPUT_FUSE = 0x1000, // L, where is it set? sub_080782C0 + INPUT_LIFT_THROW = 0x8000, // R, IsTryingToPickupObject, sub_08076518 } PlayerInputState; typedef struct { @@ -535,7 +533,7 @@ typedef struct { /*0x09*/ u8 _hasAllFigurines; /*0x0a*/ u8 charm; /*0x0b*/ u8 picolyteType; - /*0x0c*/ u8 itemButtons[2]; + /*0x0c*/ u8 equipped[2]; /*0x0e*/ u8 bottles[4]; /*0x12*/ u8 effect; /*0x13*/ u8 hasAllFigurines; diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 3d425817..a115acc1 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -313,7 +313,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_READ; - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) { return 0; } gPlayerState.mobility = 1; @@ -327,7 +327,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN; - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) { return 0; } gPlayerState.mobility = 1; @@ -338,7 +338,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN; - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) { return 0; } gPlayerState.mobility = 1; diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c index 1a040933..4d584da9 100644 --- a/src/code_0805EC04.c +++ b/src/code_0805EC04.c @@ -138,40 +138,40 @@ void UpdatePlayerInput(void) { gPlayerState.playerInput.heldInput = state; gPlayerState.playerInput.newInput = state & prevState; // Calculate the direction from the currently held input. - gPlayerState.direction = gUnk_08109202[(state & PLAYER_INPUT_ANY_DIRECTION) >> 8]; + gPlayerState.direction = gUnk_08109202[(state & INPUT_ANY_DIRECTION) >> 8]; } u32 ConvInputToState(u32 keys) { u32 result; if (keys & L_BUTTON) { - result = 0x1000; + result = INPUT_FUSE; } else { result = 0; } if (keys & R_BUTTON) { - result |= PLAYER_INPUT_20; - result |= PLAYER_INPUT_8000; - result |= PLAYER_INPUT_80; + result |= INPUT_CONTEXT; + result |= INPUT_LIFT_THROW; + result |= INPUT_ACTION; } if (keys & A_BUTTON) { - result |= PLAYER_INPUT_8; - result |= PLAYER_INPUT_40 | PLAYER_INPUT_1; + result |= INPUT_INTERACT; + result |= INPUT_40 | INPUT_USE_ITEM1; } if (keys & B_BUTTON) { - result |= PLAYER_INPUT_10; - result |= PLAYER_INPUT_2; + result |= INPUT_CANCEL; + result |= INPUT_USE_ITEM2; } if (keys & DPAD_RIGHT) { - result |= PLAYER_INPUT_RIGHT; + result |= INPUT_RIGHT; } if (keys & DPAD_LEFT) { - result |= PLAYER_INPUT_LEFT; + result |= INPUT_LEFT; } if (keys & DPAD_UP) { - result |= PLAYER_INPUT_UP; + result |= INPUT_UP; } if (keys & DPAD_DOWN) { - result |= PLAYER_INPUT_DOWN; + result |= INPUT_DOWN; } return result; } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 886aa8b7..782a51b2 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -260,12 +260,12 @@ void sub_080281A0(LikeLikeEntity* this) { bool32 LikeLike_StealItem(u32 item) { bool32 ret = FALSE; if (GetInventoryValue(item) == 1) { - if (ItemIsShield(gSave.stats.itemButtons[SLOT_A])) { - gSave.stats.itemButtons[SLOT_A] = ITEM_NONE; + if (ItemIsShield(gSave.stats.equipped[SLOT_A])) { + gSave.stats.equipped[SLOT_A] = ITEM_NONE; } - if (ItemIsShield(gSave.stats.itemButtons[SLOT_B])) { - gSave.stats.itemButtons[SLOT_B] = ITEM_NONE; + if (ItemIsShield(gSave.stats.equipped[SLOT_B])) { + gSave.stats.equipped[SLOT_B] = ITEM_NONE; } SetInventoryValue(item, 0); diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 1f4aa52a..55088984 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -107,10 +107,10 @@ void sub_08076964(ItemBehavior* this, u32 index) { SetItemAnim(this, ANIM_DASH); entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD); if (entity != NULL) { - if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) { - uVar3 = gSave.stats.itemButtons[SLOT_A]; + if (ItemIsSword(gSave.stats.equipped[SLOT_A]) != 0) { + uVar3 = gSave.stats.equipped[SLOT_A]; } else { - uVar3 = gSave.stats.itemButtons[SLOT_B]; + uVar3 = gSave.stats.equipped[SLOT_B]; } entity->field_0x68.HALF.LO = uVar3; return; diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index c1fc697e..1eb76da5 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -145,7 +145,7 @@ void sub_080762D8(ItemBehavior* this, u32 index) { if (gPlayerEntity.iframes < 9 && gPlayerEntity.knockbackDuration == 0) { if (this->field_0x18 != NULL) { if (this->field_0x18->action == 2 && this->field_0x18->subAction == 5) { - if (!(gPlayerState.playerInput.heldInput & PLAYER_INPUT_80)) { // Pressing R + if (!(gPlayerState.playerInput.heldInput & INPUT_ACTION)) { // Pressing R this->field_0x18->subAction = 6; PlayerCancelHoldItem(this, index); return; @@ -263,7 +263,7 @@ void sub_08076518(ItemBehavior* this, u32 index) { if (gPlayerEntity.knockbackDuration != 0) { PlayerCancelHoldItem(this, index); } else { - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_8000 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_LIFT_THROW | INPUT_CANCEL | INPUT_INTERACT)) != 0) { sub_0806F948(&gPlayerEntity); gPlayerState.heldObject = 5; this->field_0x18->subAction = 2; diff --git a/src/itemUtils.c b/src/itemUtils.c index 1b3cf948..c78c0da3 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -255,9 +255,9 @@ void ModArrows(s32 arrows) { EquipSlot IsItemEquipped(u32 itemId) { EquipSlot equipSlot; - if (itemId == gSave.stats.itemButtons[SLOT_A]) { + if (itemId == gSave.stats.equipped[SLOT_A]) { equipSlot = EQUIP_SLOT_A; - } else if (itemId == gSave.stats.itemButtons[SLOT_B]) { + } else if (itemId == gSave.stats.equipped[SLOT_B]) { equipSlot = EQUIP_SLOT_B; } else { equipSlot = EQUIP_SLOT_NONE; @@ -273,17 +273,17 @@ void PutItemOnSlot(u32 itemId) { } if (itemId2 - 1 < 0x1f) { equipSlot = EQUIP_SLOT_NONE; - if (gSave.stats.itemButtons[SLOT_A] == ITEM_NONE) { + if (gSave.stats.equipped[SLOT_A] == ITEM_NONE) { equipSlot = EQUIP_SLOT_A; - } else if (gSave.stats.itemButtons[SLOT_B] == ITEM_NONE) { + } else if (gSave.stats.equipped[SLOT_B] == ITEM_NONE) { equipSlot = EQUIP_SLOT_B; } if (equipSlot == EQUIP_SLOT_NONE) { u32 temp = gItemMetaData[itemId2].menuSlot; - if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_A]].menuSlot) { + if (temp == gItemMetaData[gSave.stats.equipped[SLOT_A]].menuSlot) { equipSlot = EQUIP_SLOT_A; } else { - if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_B]].menuSlot) { + if (temp == gItemMetaData[gSave.stats.equipped[SLOT_B]].menuSlot) { equipSlot = EQUIP_SLOT_B; } } @@ -302,13 +302,13 @@ void ForceEquipItem(u32 itemId, u32 equipSlot) { if ((itemId - 1 < 0x1f) && (equipSlot < EQUIP_SLOT_NONE)) { otherItemSlot = equipSlot == EQUIP_SLOT_A; - replacedItem = gSave.stats.itemButtons[equipSlot]; - otherItem = gSave.stats.itemButtons[otherItemSlot]; + replacedItem = gSave.stats.equipped[equipSlot]; + otherItem = gSave.stats.equipped[otherItemSlot]; if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemId].menuSlot) { otherItem = replacedItem; } - gSave.stats.itemButtons[equipSlot] = itemId; - gSave.stats.itemButtons[otherItemSlot] = otherItem; + gSave.stats.equipped[equipSlot] = itemId; + gSave.stats.equipped[otherItemSlot] = otherItem; gUnk_0200AF00.unk_13 = 0x7f; gUnk_0200AF00.unk_14 = 0x7f; } diff --git a/src/manager/miscManager.c b/src/manager/miscManager.c index 5ae26ace..80d4cffc 100644 --- a/src/manager/miscManager.c +++ b/src/manager/miscManager.c @@ -364,7 +364,7 @@ void MiscManager_TypeB(MiscManager* this) { bool32 sub_080593CC(MiscManager* this) { if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 && - (gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) == PLAYER_INPUT_UP) { + (gPlayerState.playerInput.heldInput & INPUT_ANY_DIRECTION) == INPUT_UP) { return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6); } return FALSE; diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index 2ea79113..6b1d0cef 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -529,14 +529,14 @@ void PauseMenu_ItemMenu_Draw(void) { gOamCmd._8 = 0x800; DrawDirect(sub_080A5384_draw_constant0, 0x22); } - i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_A]); + i = GetMenuSlotForItem(gSave.stats.equipped[SLOT_A]); if (i < MENU_SLOT_COUNT) { entry = &gItemMenuTable[i]; gOamCmd.x = entry->x; gOamCmd.y = entry->y; DrawDirect(sub_080A5384_draw_constant0, 3); } - i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_B]); + i = GetMenuSlotForItem(gSave.stats.equipped[SLOT_B]); if (i < MENU_SLOT_COUNT) { entry = &gItemMenuTable[i]; gOamCmd.x = entry->x; diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 83205c44..059f6163 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -434,7 +434,7 @@ void sub_0806D5D4(void) { InitBiggoronTimer(); equipSlot = IsItemEquipped(ITEM_SHIELD); if (equipSlot != EQUIP_SLOT_NONE) { - gSave.stats.itemButtons[equipSlot] = ITEM_NONE; + gSave.stats.equipped[equipSlot] = ITEM_NONE; } SetInventoryValue(ITEM_SHIELD, 0); } diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index ecb97fe2..598b0523 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -339,10 +339,10 @@ void BladeBrothers_StartPlayerDemonstration(Entity* this, ScriptExecutionContext } void sub_08068BB4(BladeBrothersEntity* this) { - u32 item = gSave.stats.itemButtons[SLOT_A]; + u32 item = gSave.stats.equipped[SLOT_A]; this->itemSlotA = item; - item = gSave.stats.itemButtons[SLOT_B]; + item = gSave.stats.equipped[SLOT_B]; this->itemSlotB = item; } diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 910fb485..e60812b2 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -186,8 +186,8 @@ Item NPC4E_GetItemWithSwordUpgraded(Item itemId) { } void NPC4E_SaveEquippedItems(NPC4EEntity* this) { - this->unk_68 = gSave.stats.itemButtons[SLOT_A]; - this->unk_69 = gSave.stats.itemButtons[SLOT_B]; + this->unk_68 = gSave.stats.equipped[SLOT_A]; + this->unk_69 = gSave.stats.equipped[SLOT_B]; } void NPC4E_RestoreEquippedItems(NPC4EEntity* this) { diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index a9d500cd..1e28d988 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -179,7 +179,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { RestorePrevTileEntity(0xdc, super->collisionLayer); sub_08096A78(this); } - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) { return; } if (gUnk_0200AF00.rActionPlayerState != R_ACTION_THROW) { diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 5b0a94f6..a921f8ba 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -184,7 +184,7 @@ void sub_0808692C(HouseDoorExteriorEntity* this) { static u8 sub_08086954(HouseDoorExteriorEntity* this) { if (sub_0800445C(super)) { if (GetAnimationStateInRectRadius(super, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && - (u16)gPlayerState.playerInput.heldInput == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) { + (u16)gPlayerState.playerInput.heldInput == INPUT_UP && gPlayerState.jump_status == 0) { super->timer--; } } else { diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index 7dcef6c5..aca8b2fd 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -118,8 +118,8 @@ void ItemForSale_Action2(ItemForSaleEntity* this) { ptr = sub_080784E4(); if (((*(int*)(ptr + 8) == 0) || ((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.rActionPlayerState = R_ACTION_SPEAK, (gPlayerState.playerInput.newInput & - (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) && - ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) { + (INPUT_ACTION | INPUT_INTERACT)) == 0)))) && + ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_CANCEL | INPUT_INTERACT)) != 0)) { sub_080819B4(this); } } diff --git a/src/object/linkHoldingItem.c b/src/object/linkHoldingItem.c index ae982637..cf14269a 100644 --- a/src/object/linkHoldingItem.c +++ b/src/object/linkHoldingItem.c @@ -123,8 +123,8 @@ void LinkHoldingItem_Action2(LinkHoldingItemEntity* this) { } void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) { - u32 tmp; - if ((super->parent)->action == 8) { + u32 bottle_no; + if (super->parent->action == PLAYER_ITEMGET) { return; } switch (super->timer) { @@ -149,9 +149,9 @@ void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) { ModHealth(160); break; case 3: - tmp = GetBottleContaining(super->type); - if (tmp != 0) { - gSave.stats.itemButtons[tmp + 1] = ITEM_BOTTLE_EMPTY; + bottle_no = GetBottleContaining(super->type); + if (bottle_no != 0) { + gSave.stats.bottles[bottle_no - 1] = ITEM_BOTTLE_EMPTY; } else { SetInventoryValue(super->type, ITEM_GREEN_SWORD); } diff --git a/src/player.c b/src/player.c index 12b1ff45..cc028dba 100644 --- a/src/player.c +++ b/src/player.c @@ -2750,7 +2750,7 @@ static void sub_08073504(Entity* this) { static void sub_08073584(Entity* this) { u32 state, dir, idx; - if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_80) || this->iframes > 0 || gPlayerState.field_0x3c || + if ((gPlayerState.playerInput.newInput & INPUT_ACTION) || this->iframes > 0 || gPlayerState.field_0x3c || (gPlayerState.flags & PL_PARACHUTE) == 0) { gPlayerState.jump_status |= 0x40; PlayerSetNormalAndCollide(); @@ -3447,10 +3447,10 @@ void SurfaceAction_14(Entity* this) { void SurfaceAction_CloneTile(Entity* this) { if (gPlayerState.chargeState.action == 4) { u32 item, n, i; - if (ItemIsSword(gSave.stats.itemButtons[SLOT_A])) { - item = gSave.stats.itemButtons[SLOT_A]; + if (ItemIsSword(gSave.stats.equipped[SLOT_A])) { + item = gSave.stats.equipped[SLOT_A]; } else { - item = gSave.stats.itemButtons[SLOT_B]; + item = gSave.stats.equipped[SLOT_B]; } switch (item) { case 1: @@ -3523,8 +3523,7 @@ void SurfaceAction_ShallowWater(Entity* this) { this->spritePriority.b0 = 4; gPlayerState.swim_state = 0; } - if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) || - gPlayerState.surfacePositionSameTimer == 1) + if ((gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) || gPlayerState.surfacePositionSameTimer == 1) SoundReq(SFX_WATER_WALK); } } @@ -3567,7 +3566,7 @@ void SurfaceAction_Swamp(Entity* this) { CreateObjectWithParent(this, OBJECT_70, 0, 0); CreateFx(this, FX_GREEN_SPLASH, 0); SoundReq(SFX_161); - } else if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) != 0) { + } else if ((gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) != 0) { SoundReq(SFX_161); } else if ((gRoomTransition.frameCount & 0xf) == 0) { SoundReq(SFX_161); @@ -3723,7 +3722,7 @@ void SurfaceAction_Dust(Entity* this) { if (!sub_080741C4()) { gPlayerState.speed_modifier -= 128; if (gPlayerState.surfacePositionSameTimer == 1 || - (gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) != 0) { + (gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) != 0) { if (gPlayerState.floor_type == SURFACE_DUST) CreateObjectWithParent(this, DIRT_PARTICLE, 1, 0); else diff --git a/src/playerItem/playerItemBomb.c b/src/playerItem/playerItemBomb.c index 63647459..af443266 100644 --- a/src/playerItem/playerItemBomb.c +++ b/src/playerItem/playerItemBomb.c @@ -113,10 +113,10 @@ void PlayerItemBomb_Action1(PlayerItemBombEntity* this) { } switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) { case EQUIP_SLOT_A: - input = PLAYER_INPUT_1; + input = INPUT_USE_ITEM1; break; case EQUIP_SLOT_B: - input = PLAYER_INPUT_2; + input = INPUT_USE_ITEM2; break; case EQUIP_SLOT_NONE: input = 0; diff --git a/src/playerUtils.c b/src/playerUtils.c index cddb108a..cff07abb 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -175,8 +175,8 @@ void UpdateActiveItems(PlayerEntity* this) { gPlayerState.attack_status &= 0xf; if (((gPlayerState.field_0x7 | gPlayerState.jump_status) & 0x80) == 0 && (gPlayerState.jump_status & 0x40) == 0 && gPlayerState.swim_state == 0 && IsAbleToUseItem(this) && !IsPreventedFromUsingItem()) { - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_A], PLAYER_INPUT_1, FALSE); - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_B], PLAYER_INPUT_2, FALSE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_A], INPUT_USE_ITEM1, FALSE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_B], INPUT_USE_ITEM2, FALSE); IsTryingToPickupObject(); } @@ -189,9 +189,9 @@ void UpdateActiveItems(PlayerEntity* this) { void CreateItemEquippedAtSlot(EquipSlot equipSlot) { if (equipSlot == EQUIP_SLOT_A) { - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_A], PLAYER_INPUT_1, TRUE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_A], INPUT_USE_ITEM1, TRUE); } else { - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_B], PLAYER_INPUT_2, TRUE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_B], INPUT_USE_ITEM2, TRUE); } } @@ -210,7 +210,7 @@ bool32 IsAbleToUseItem(PlayerEntity* this) { } bool32 IsPreventedFromUsingItem(void) { - if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_80) != 0) { + if ((gPlayerState.playerInput.newInput & INPUT_ACTION) != 0) { if ((gPlayerState.flags & PL_CLONING) != 0) { gPlayerState.chargeState.action = 1; DeleteClones(); @@ -233,7 +233,7 @@ bool32 IsPreventedFromUsingItem(void) { default: if ((((gUnk_0200AF00.rActionInteractObject == R_ACTION_ROLL) && (gPlayerState.field_0x1c == 0)) && (gPlayerState.floor_type != SURFACE_SWAMP)) && - ((((gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) != 0 && + ((((gPlayerState.playerInput.heldInput & INPUT_ANY_DIRECTION) != 0 && ((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) && ((gPlayerState.jump_status == 0 && (gPlayerState.attack_status == 0)))))) { gPlayerState.queued_action = PLAYER_ROLL; @@ -274,9 +274,9 @@ bool32 IsTryingToPickupObject(void) { if (!((((gPlayerState.flags & (PL_USE_PORTAL | PL_MINISH | PL_ROLLING)) == 0) && (((gNewPlayerEntity.unk_79 != 0 || (gPlayerState.heldObject != 0)) || - ((gPlayerState.playerInput.newInput & PLAYER_INPUT_8000) != 0)))) && + ((gPlayerState.playerInput.newInput & INPUT_LIFT_THROW) != 0)))) && (((sub_080789A8() != 0 || ((gPlayerState.playerInput.heldInput & - (PLAYER_INPUT_ANY_DIRECTION | PLAYER_INPUT_1 | PLAYER_INPUT_2)) == 0)))))) { + (INPUT_ANY_DIRECTION | INPUT_USE_ITEM1 | INPUT_USE_ITEM2)) == 0)))))) { return FALSE; } item = CreateItem(ITEM_TRY_PICKUP_OBJECT); @@ -631,10 +631,10 @@ bool32 IsItemActiveByInput(ItemBehavior* this, PlayerInputState input) { u32 val; Stats* stats = &gSave.stats; u32 id = this->behaviorId; - if (stats->itemButtons[SLOT_A] == id) { - val = PLAYER_INPUT_1; - } else if (stats->itemButtons[SLOT_B] == id) { - val = PLAYER_INPUT_2; + if (stats->equipped[SLOT_A] == id) { + val = INPUT_USE_ITEM1; + } else if (stats->equipped[SLOT_B] == id) { + val = INPUT_USE_ITEM2; } else { val = 0; } @@ -901,10 +901,10 @@ bool32 sub_08077FEC(u32 action) { bool32 sub_08078008(ChargeState* state) { Item swordType; - if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != ITEM_NONE) { - swordType = gSave.stats.itemButtons[SLOT_A]; - } else if (ItemIsSword(gSave.stats.itemButtons[SLOT_B]) != ITEM_NONE) { - swordType = gSave.stats.itemButtons[SLOT_B]; + if (ItemIsSword(gSave.stats.equipped[SLOT_A]) != ITEM_NONE) { + swordType = gSave.stats.equipped[SLOT_A]; + } else if (ItemIsSword(gSave.stats.equipped[SLOT_B]) != ITEM_NONE) { + swordType = gSave.stats.equipped[SLOT_B]; } else { swordType = ITEM_NONE; } @@ -1110,7 +1110,7 @@ bool32 sub_080782C0(void) { return FALSE; } } - if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && + if (((gPlayerState.playerInput.newInput & INPUT_FUSE) != 0) && ((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) < 100)) { AddKinstoneToBag(KINSTONE_NONE); if (gSave.kinstones.amounts[0] != 0) { @@ -1123,7 +1123,7 @@ bool32 sub_080782C0(void) { ForceSetPlayerState(PL_STATE_TALKEZLO); return TRUE; } - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) { return FALSE; } switch (gPossibleInteraction.currentObject->type) { @@ -1973,7 +1973,7 @@ void sub_08079520(Entity* this) { } u32 sub_0807953C(void) { - u32 tmp = PLAYER_INPUT_ANY_DIRECTION | PLAYER_INPUT_20 | PLAYER_INPUT_10 | PLAYER_INPUT_8; + u32 tmp = INPUT_ANY_DIRECTION | INPUT_CONTEXT | INPUT_CANCEL | INPUT_INTERACT; return gPlayerState.playerInput.newInput & tmp; } @@ -2549,10 +2549,10 @@ void DeleteClones(void) { } bool32 HasSwordEquipped(void) { - if (ItemIsSword((u32)gSave.stats.itemButtons[SLOT_A]) != 0) { + if (ItemIsSword((u32)gSave.stats.equipped[SLOT_A]) != 0) { return TRUE; } else { - return ItemIsSword((u32)gSave.stats.itemButtons[SLOT_B]); + return ItemIsSword((u32)gSave.stats.equipped[SLOT_B]); } } @@ -3009,7 +3009,7 @@ void PlayerSwimming(Entity* this) { } bool32 ToggleDiving(Entity* this) { - if (gPlayerState.playerInput.newInput & PLAYER_INPUT_10) { + if (gPlayerState.playerInput.newInput & INPUT_CANCEL) { gPlayerState.swim_state ^= 0x80; if (gPlayerState.swim_state & 0x80) { gPlayerState.remainingDiveTime = 0x78; @@ -3026,7 +3026,7 @@ bool32 ToggleDiving(Entity* this) { void PlayerUpdateSwimming(Entity* this) { if ((((this->action != 0x17) || (gPlayerState.field_0xa == 0)) && (gRoomControls.reload_flags == 0)) && - ((gPlayerState.playerInput.newInput & PLAYER_INPUT_8) != 0)) { + ((gPlayerState.playerInput.newInput & INPUT_INTERACT) != 0)) { if (GetInventoryValue(ITEM_SWIM_BUTTERFLY) == 1) { this->speed = 0x1c0; } else { diff --git a/src/title.c b/src/title.c index 353604e3..238e11d1 100644 --- a/src/title.c +++ b/src/title.c @@ -89,7 +89,7 @@ static const SaveFile gDemoSave = { .stats = { .health = 40, .maxHealth = 40, - .itemButtons = { ITEM_SHIELD, ITEM_SMITH_SWORD }, + .equipped = { ITEM_SHIELD, ITEM_SMITH_SWORD }, .rupees = 5, }, .inventory = { diff --git a/src/ui.c b/src/ui.c index dcc5b573..1bff0dae 100644 --- a/src/ui.c +++ b/src/ui.c @@ -663,7 +663,7 @@ void ButtonUIElement_Action1(UIElement* element) { u32 sub_0801CC80(UIElement* element) { u8 type = element->type; u32 buttonId = (type ^ 3) != 0; - u32 itemId = gSave.stats.itemButtons[buttonId]; + u32 itemId = gSave.stats.equipped[buttonId]; if (ItemIsBottle(itemId)) { itemId = gSave.stats.bottles[itemId - ITEM_BOTTLE1]; } From a030120a0c3b65cd1a35ec83644edca6985e5346 Mon Sep 17 00:00:00 2001 From: theo3 Date: Thu, 28 Dec 2023 19:05:06 -0800 Subject: [PATCH 4/6] clean up linkAnimation.c --- include/entity.h | 2 +- include/functions.h | 2 +- include/object/linkAnimation.h | 23 +++++ include/player.h | 2 +- src/enemy/businessScrub.c | 2 +- src/enemy/businessScrubPrologue.c | 4 +- src/enemy/likeLike.c | 2 +- src/enemyUtils.c | 4 +- src/entity.c | 8 +- src/itemUtils.c | 2 +- src/manager/cloudOverlayManager.c | 2 +- src/manager/delayedEntityLoadManager.c | 2 +- src/manager/enterRoomTextboxManager.c | 2 +- src/manager/ezloHintManager.c | 2 +- src/manager/fightManager.c | 4 +- src/manager/holeManager.c | 2 +- src/manager/hyruleTownTilesetManager.c | 2 +- src/manager/lightManager.c | 2 +- src/manager/minishVillageTilesetManager.c | 2 +- src/manager/miscManager.c | 4 +- src/manager/powBackgroundManager.c | 2 +- src/manager/repeatedSoundManager.c | 2 +- src/manager/secretManager.c | 4 +- src/manager/staticBackgroundManager.c | 2 +- src/manager/templeOfDropletsManager.c | 4 +- src/manager/vaati3BackgroundManager.c | 2 +- src/npc/bigGoron.c | 14 +-- src/npc/carpenter.c | 4 +- src/npc/cat.c | 4 +- src/npc/cucco.c | 2 +- src/npc/cuccoChick.c | 2 +- src/npc/dampe.c | 2 +- src/npc/dog.c | 4 +- src/npc/drLeft.c | 2 +- src/npc/emma.c | 2 +- src/npc/epona.c | 2 +- src/npc/ezlo.c | 2 +- src/npc/farmers.c | 2 +- src/npc/festari.c | 4 +- src/npc/forestMinish.c | 4 +- src/npc/gentari.c | 4 +- src/npc/ghostBrothers.c | 2 +- src/npc/gregal.c | 10 +- src/npc/hurdyGurdyMan.c | 4 +- src/npc/kingGustaf.c | 2 +- src/npc/librari.c | 2 +- src/npc/mama.c | 2 +- src/npc/marcy.c | 2 +- src/npc/mayorHagen.c | 2 +- src/npc/melari.c | 2 +- src/npc/minishEzlo.c | 2 +- src/npc/mountainMinish.c | 2 +- src/npc/mutoh.c | 2 +- src/npc/pita.c | 2 +- src/npc/postman.c | 2 +- src/npc/rem.c | 6 +- src/npc/stockwell.c | 2 +- src/npc/syrup.c | 2 +- src/npc/teachers.c | 2 +- src/npc/vaati.c | 2 +- src/npc/wheaton.c | 2 +- src/npc/zelda.c | 2 +- src/npc/zeldaFollower.c | 2 +- src/object/beanstalk.c | 2 +- src/object/bigBarrel.c | 4 +- src/object/bigVortex.c | 2 +- src/object/bird.c | 8 +- src/object/cameraTarget.c | 2 +- src/object/crenelBeanSprout.c | 2 +- src/object/cutsceneMiscObject.c | 22 ++-- src/object/deathFx.c | 2 +- src/object/fairy.c | 2 +- src/object/figurineDevice.c | 4 +- src/object/fourElements.c | 2 +- src/object/frozenOctorok.c | 2 +- src/object/greatFairy.c | 4 +- src/object/guruguruBar.c | 2 +- src/object/houseDoorExterior.c | 2 +- src/object/itemForSale.c | 2 +- src/object/itemOnGround.c | 4 +- src/object/linkAnimation.c | 118 +++++++++++----------- src/object/linkHoldingItem.c | 2 +- src/object/minishVillageObject.c | 2 +- src/object/moleMittsParticle.c | 2 +- src/object/object30.c | 2 +- src/object/objectA2.c | 2 +- src/object/objectA8.c | 2 +- src/object/parallaxRoomView.c | 2 +- src/object/shrinkingHieroglyphs.c | 2 +- src/object/specialFx.c | 2 +- src/object/windTribeTeleporter.c | 2 +- src/objectUtils.c | 34 ++++--- src/player.c | 6 +- src/playerUtils.c | 6 +- src/script.c | 6 +- 95 files changed, 245 insertions(+), 216 deletions(-) create mode 100644 include/object/linkAnimation.h diff --git a/include/entity.h b/include/entity.h index 78dcde47..cbb54201 100644 --- a/include/entity.h +++ b/include/entity.h @@ -386,7 +386,7 @@ Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2); * @param entity Entity to set the priority of. * @param prio #Priority level. */ -void SetDefaultPriority(Entity* entity, u32 prio); +void SetEntityPriority(Entity* entity, u32 prio); /** * Check if entity will be deleted next frame. diff --git a/include/functions.h b/include/functions.h index a770563b..49fb3f31 100644 --- a/include/functions.h +++ b/include/functions.h @@ -83,7 +83,7 @@ extern void sub_08030118(u32); extern void sub_0803C0AC(Entity*); extern void sub_08049CF4(Entity*); extern u32 sub_0804A024(Entity*, u32, u32); -extern u32 sub_080542AC(u32); +extern u32 IsMinishItem(u32); extern void DisableRandomDrops(); extern void EnableRandomDrops(void); extern s32 sub_08056338(void); diff --git a/include/object/linkAnimation.h b/include/object/linkAnimation.h new file mode 100644 index 00000000..9fb2fad4 --- /dev/null +++ b/include/object/linkAnimation.h @@ -0,0 +1,23 @@ +#ifndef LINKANIMATION_H +#define LINKANIMATION_H + +#ifndef NENT_DEPRECATED +#error "linkAnimtion.h requires new entities" +#endif +#include "entity.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 storeDrawFlags; + /*0x69*/ u8 storeFlags; + /*0x6a*/ u8 storeIFrames; + /*0x6b*/ u8 storeField7; + /*0x6c*/ u8 storeKeepFacing; + /*0x6d*/ u8 storeFieldA; + /*0x6e*/ u8 storeField27; + /*0x6f*/ u8 storeMobility; + /*0x70*/ u32 storeStateFlags; + /*0x74*/ u8 store8A; +} LinkAnimationEntity; + +#endif // LINKANIMATION_H diff --git a/include/player.h b/include/player.h index 19be9997..db8c1f08 100644 --- a/include/player.h +++ b/include/player.h @@ -263,7 +263,7 @@ typedef enum { typedef struct { /*0x0*/ u16 heldInput; /**< Input currently held @see PlayerInputState */ /*0x2*/ u16 newInput; /**< New input this frame @see PlayerInputState */ - /*0x4*/ u32 field_0x94; + /*0x4*/ u32 unused; /*0x8*/ u16 playerMacroWaiting; /*0xa*/ u16 playerMacroHeldKeys; /*0xc*/ PlayerMacroEntry* playerMacro; diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index cd52da10..873ff039 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -211,7 +211,7 @@ void BusinessScrub_Action3(Entity* this) { if (iVar1 != NULL) { iVar1->spritePriority.b0 = 3; iVar1->z.HALF.HI -= 12; - SetDefaultPriority(iVar1, PRIO_MESSAGE); + SetEntityPriority(iVar1, PRIO_MESSAGE); } SetFlag(this->field_0x86.HWORD); sub_0802925C(this); diff --git a/src/enemy/businessScrubPrologue.c b/src/enemy/businessScrubPrologue.c index 657d9d0b..28995f4d 100644 --- a/src/enemy/businessScrubPrologue.c +++ b/src/enemy/businessScrubPrologue.c @@ -54,7 +54,7 @@ void BusinessScrubPrologue_OnCollision(BusinessScrubPrologueEntity* this) { gPlayerState.field_0x27[0] = 0xff; EnqueueSFX(SFX_EM_DEKUSCRUB_HIT); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } } } @@ -189,7 +189,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) { if (ent != NULL) { ent->spritePriority.b0 = 3; ent->z.HALF.HI -= 0xc; - SetDefaultPriority(ent, PRIO_MESSAGE); + SetEntityPriority(ent, PRIO_MESSAGE); } } break; diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 782a51b2..2c7fa88f 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -73,7 +73,7 @@ void LikeLike_OnCollision(LikeLikeEntity* this) { void LikeLike_OnDeath(LikeLikeEntity* this) { if (super->timer == 2 && this->stolenItem != 0xff) { - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); LikeLike_ReturnStolenItem(this->stolenItem); } GenericDeath(super); diff --git a/src/enemyUtils.c b/src/enemyUtils.c index 05d59a98..e030edb1 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -195,7 +195,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { gSave.enemies_killed++; parent->base.gustJarState |= 2; parent->base.timer = 255; - SetDefaultPriority(&(parent->base), 3); + SetEntityPriority(&(parent->base), 3); deathFx2 = (DeathFxObject*)CreateObject(DEATH_FX, parent->base.id, 0); if (deathFx2 != NULL) { deathFx2->unk6c = tmp; @@ -232,7 +232,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { } else { if (--parent->base.timer == 0) { parent->base.spriteSettings.draw = 0; - SetDefaultPriority(&(parent->base), 0); + SetEntityPriority(&(parent->base), 0); } else { if (parent->base.timer < 9) { if (parent->base.spriteSettings.draw) { diff --git a/src/entity.c b/src/entity.c index 2ac2b37f..1a9ac121 100644 --- a/src/entity.c +++ b/src/entity.c @@ -74,17 +74,17 @@ const u8 gUnk_081091F8[] = { 0, 3, 0, 3, 3, 0, 3, 3, 3, 3, }; -void SetDefaultPriorityForKind(Entity* e) { +void SetEntityPriorityForKind(Entity* e) { u8 r3 = gRoomTransition.entity_update_type; const u8* array = gUnk_081091F8; if (r3 != 2) { array = gUnk_081091EE; } - SetDefaultPriority(e, array[e->kind]); + SetEntityPriority(e, array[e->kind]); } -void SetDefaultPriority(Entity* ent, u32 prio) { +void SetEntityPriority(Entity* ent, u32 prio) { ent->updatePriorityPrev = prio; ent->updatePriority = prio; } @@ -508,7 +508,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) { } else { gManagerCount++; } - SetDefaultPriorityForKind(entity); + SetEntityPriorityForKind(entity); } void PrependEntityToList(Entity* entity, u32 listIndex) { diff --git a/src/itemUtils.c b/src/itemUtils.c index c78c0da3..00cfd5e9 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -200,7 +200,7 @@ u32 getItemMetaDataGetTextIndex(s32 itemIndex) { return ptr[2]; } -u32 sub_080542AC(u32 param_1) { +u32 IsMinishItem(u32 param_1) { const ItemMetaData* ptr1 = gItemMetaData; u8* ptr = (u8*)&((ptr1)[param_1]); return ptr[3] & 1; diff --git a/src/manager/cloudOverlayManager.c b/src/manager/cloudOverlayManager.c index 3cc20ca9..b9563b46 100644 --- a/src/manager/cloudOverlayManager.c +++ b/src/manager/cloudOverlayManager.c @@ -27,7 +27,7 @@ void CloudOverlayManager_Main(CloudOverlayManager* this) { super->timer = 0; super->subtimer = 8; this->field_0x20 = gUnk_0810865C[0]; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805AEDC, sub_0805AF3C); } else { diff --git a/src/manager/delayedEntityLoadManager.c b/src/manager/delayedEntityLoadManager.c index de9a8390..0a13bf40 100644 --- a/src/manager/delayedEntityLoadManager.c +++ b/src/manager/delayedEntityLoadManager.c @@ -37,7 +37,7 @@ void DelayedEntityLoadManager_Main(DelayedEntityLoadManager* this) { if (super->action == 0) { super->action++; this->unk_20 = gArea.filler[1]; - SetDefaultPriority((Entity*)this, 6); + SetEntityPriority((Entity*)this, 6); npcPtr = gNPCData; npcPtr += (super->type2 + this->unk_20); index1 = 0; diff --git a/src/manager/enterRoomTextboxManager.c b/src/manager/enterRoomTextboxManager.c index 959e90f9..a720a788 100644 --- a/src/manager/enterRoomTextboxManager.c +++ b/src/manager/enterRoomTextboxManager.c @@ -45,7 +45,7 @@ void sub_0805E140(EnterRoomTextboxManager* this) { this->unk_20 = gRoomControls.room; super->timer = 120; super->subtimer = 60; - SetDefaultPriority((Entity*)this, PRIO_HIGHEST); + SetEntityPriority((Entity*)this, PRIO_HIGHEST); sub_0805E1F8(gUnk_08108DE8[gArea.locationIndex], AreaIsDungeon()); } diff --git a/src/manager/ezloHintManager.c b/src/manager/ezloHintManager.c index afe8394a..f98b97f3 100644 --- a/src/manager/ezloHintManager.c +++ b/src/manager/ezloHintManager.c @@ -35,7 +35,7 @@ static void EzloHintManager_Init(EzloHintManager* this) { this->ry = this->ry_raw << 3; this->x = this->rx + (this->x_raw << 4); this->y = this->ry + (this->y_raw << 4); - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); if (this->flag2 == 0) { super->action = 2; } else { diff --git a/src/manager/fightManager.c b/src/manager/fightManager.c index 1f54b143..3f34f5c4 100644 --- a/src/manager/fightManager.c +++ b/src/manager/fightManager.c @@ -55,7 +55,7 @@ void FightManager_Init(FightManager* this) { if (!this->fightStartFlag) { FightManager_LoadFight(this); } - SetDefaultPriority((Entity*)this, PRIO_NO_BLOCK); + SetEntityPriority((Entity*)this, PRIO_NO_BLOCK); } else { DeleteThisEntity(); } @@ -157,7 +157,7 @@ void FightManagerHelper_Main(FightManagerHelper* this) { if (super->action == 0) { super->action = 1; - SetDefaultPriority((Entity*)this, PRIO_NO_BLOCK); + SetEntityPriority((Entity*)this, PRIO_NO_BLOCK); } // go through and check all monitored enemies. anyRemaining = FALSE; diff --git a/src/manager/holeManager.c b/src/manager/holeManager.c index 3b1d17cf..c220332b 100644 --- a/src/manager/holeManager.c +++ b/src/manager/holeManager.c @@ -57,7 +57,7 @@ void sub_0805B328(HoleManager*); void sub_0805B048(HoleManager* this) { struct_08108764* tmp; Entity* obj; - SetDefaultPriority((Entity*)super, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)super, PRIO_PLAYER_EVENT); MemClear(&this->unk_20, 0x20); super->action = 1; this->unk_3f = gRoomControls.room; diff --git a/src/manager/hyruleTownTilesetManager.c b/src/manager/hyruleTownTilesetManager.c index 308204f0..9797a0c2 100644 --- a/src/manager/hyruleTownTilesetManager.c +++ b/src/manager/hyruleTownTilesetManager.c @@ -66,7 +66,7 @@ void HyruleTownTilesetManager_Main(HyruleTownTilesetManager* this) { this->field_0x21 = 0xff; this->field_0x20 = 0xff; RegisterTransitionManager(this, sub_08059A2C, NULL); - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); } sub_08059A58(this); } diff --git a/src/manager/lightManager.c b/src/manager/lightManager.c index edad0b7d..c8d8241d 100644 --- a/src/manager/lightManager.c +++ b/src/manager/lightManager.c @@ -37,7 +37,7 @@ void LightManager_Main(LightManager* this) { super->flags |= ENT_PERSIST; super->timer = 17; this->unk20 = 0; - SetDefaultPriority((Entity*)this, 6); + SetEntityPriority((Entity*)this, 6); sub_0801E120(); sub_0801E154(super->timer); } diff --git a/src/manager/minishVillageTilesetManager.c b/src/manager/minishVillageTilesetManager.c index f82b9153..225ba477 100644 --- a/src/manager/minishVillageTilesetManager.c +++ b/src/manager/minishVillageTilesetManager.c @@ -111,7 +111,7 @@ void MinishVillageTilesetManager_Main(MinishVillageTilesetManager* this) { super->timer = 8; this->unk_20 = 0xFF; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); RegisterTransitionManager(this, sub_08057E30, 0); } if (sub_08057E40(this)) { diff --git a/src/manager/miscManager.c b/src/manager/miscManager.c index 80d4cffc..2fe982bb 100644 --- a/src/manager/miscManager.c +++ b/src/manager/miscManager.c @@ -212,7 +212,7 @@ void MiscManager_Type3(MiscManager* this) { void MiscManager_Type4(MiscManager* this) { if (super->action == 0) { super->action = 1; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); } if (CheckLocalFlag(0x6c)) { if (CheckLocalFlag(0x4b)) { @@ -430,7 +430,7 @@ void MiscManager_TypeE(MiscManager* this) { #if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP) void MiscManager_TypeF(MiscManager* this) { - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gPlayerEntity.action == PLAYER_TALKEZLO) { DeleteThisEntity(); } diff --git a/src/manager/powBackgroundManager.c b/src/manager/powBackgroundManager.c index 1aa2a0e1..d7a24f25 100644 --- a/src/manager/powBackgroundManager.c +++ b/src/manager/powBackgroundManager.c @@ -20,7 +20,7 @@ void PowBackgroundManager_Main(PowBackgroundManager* this) { if (super->action == 0) { super->action = 1; super->flags |= ENT_PERSIST; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805AFFC, NULL); } else { diff --git a/src/manager/repeatedSoundManager.c b/src/manager/repeatedSoundManager.c index d55677d6..ff2c534b 100644 --- a/src/manager/repeatedSoundManager.c +++ b/src/manager/repeatedSoundManager.c @@ -37,7 +37,7 @@ void CreateRepeatedSoundManager(Entity* entity, ScriptExecutionContext* context) manager->id = REPEATED_SOUND_MANAGER; manager->type = context->intVariable; AppendEntityToList((Entity*)manager, 6); - SetDefaultPriority((Entity*)manager, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)manager, PRIO_PLAYER_EVENT); } } diff --git a/src/manager/secretManager.c b/src/manager/secretManager.c index 4a9ba020..ca2ec125 100644 --- a/src/manager/secretManager.c +++ b/src/manager/secretManager.c @@ -51,7 +51,7 @@ void SecretManager_Type0_Init(SecretManager* this) { if (super->timer == 0) { super->timer = 30; } - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); } void SecretManager_Type0_Action1(SecretManager* this) { @@ -94,7 +94,7 @@ void SecretManager_Type1_Init(SecretManager* this) { super->timer = 30; } super->subtimer = super->timer; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); } void SecretManager_Type1_Action1(SecretManager* this) { diff --git a/src/manager/staticBackgroundManager.c b/src/manager/staticBackgroundManager.c index a8bd1810..2163b280 100644 --- a/src/manager/staticBackgroundManager.c +++ b/src/manager/staticBackgroundManager.c @@ -35,7 +35,7 @@ void StaticBackgroundManager_Main(StaticBackgroundManager* this) { if (super->action == 0) { super->action = 1; super->flags |= ENT_PERSIST; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); if (super->type != 0) { RegisterTransitionManager(this, sub_0805B4B4, NULL); } diff --git a/src/manager/templeOfDropletsManager.c b/src/manager/templeOfDropletsManager.c index b1b97aba..7472dcbd 100644 --- a/src/manager/templeOfDropletsManager.c +++ b/src/manager/templeOfDropletsManager.c @@ -370,7 +370,7 @@ void TempleOfDropletsManager_Type7(TempleOfDropletsManager* this) { } super->subAction = 1; super->flags |= ENT_PERSIST; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); break; case 1: if (CheckLocalFlag(this->unk_3e)) @@ -402,7 +402,7 @@ void TempleOfDropletsManager_Type7(TempleOfDropletsManager* this) { void sub_0805AAC8(TempleOfDropletsManager*); void sub_0805A89C(TempleOfDropletsManager* this) { - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); super->action = 1; super->flags |= ENT_PERSIST; super->timer = 8; diff --git a/src/manager/vaati3BackgroundManager.c b/src/manager/vaati3BackgroundManager.c index 5b3bcc18..bc8847cf 100644 --- a/src/manager/vaati3BackgroundManager.c +++ b/src/manager/vaati3BackgroundManager.c @@ -22,7 +22,7 @@ void Vaati3BackgroundManager_Main(Vaati3BackgroundManager* this) { if (super->action == 0) { super->action = 1; super->flags |= ENT_PERSIST; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); + SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805D470, NULL); } else { diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 059f6163..0767433b 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -81,7 +81,7 @@ void sub_0806CF30(BigGoronEntity* this) { super->action = 1; super->subAction = 1; this->originalX = super->x.HALF.HI; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); sub_0806D0B0(super); sub_0807DD64(super); } else { @@ -215,7 +215,7 @@ void sub_0806D1D0(BigGoronEntity* this) { super->spriteSettings.draw = 3; super->frameIndex = 0; super->timer = 30; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } switch (super->subAction) { @@ -256,7 +256,7 @@ void sub_0806D274(BigGoronEntity* this) { super->spritePriority.b0 = 7; super->frameIndex = 2; super->timer = 8; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); npc = CreateNPC(BIG_GORON, 3, 0); if (npc != NULL) { npc->child = super; @@ -303,7 +303,7 @@ void sub_0806D348(BigGoronEntity* this) { super->spritePriority.b0 = 6; super->spriteSettings.draw = 0; super->frameIndex = 5; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } if (super->child->frameIndex == 4) { super->spriteSettings.draw = 3; @@ -321,7 +321,7 @@ void sub_0806D3C0(BigGoronEntity* this) { } super->action = 1; super->hitbox = (Hitbox*)&gHitbox_3; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); sub_0807DD64(super); } else { super->x.HALF.HI = super->parent->x.HALF.HI; @@ -344,7 +344,7 @@ void sub_0806D41C(BigGoronEntity* this) { sub_0806D4C0(this, 1); sub_0806D4C0(this, 2); sub_0806D4C0(this, 3); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } else { ExecuteScriptForEntity(super, NULL); HandleEntity0x82Actions(super); @@ -368,7 +368,7 @@ void sub_0806D4C0(BigGoronEntity* this, u32 type) { npc->parent = super; CopyPosition(super, npc); SortEntityAbove(super, npc); - SetDefaultPriority(npc, PRIO_MESSAGE); + SetEntityPriority(npc, PRIO_MESSAGE); } } diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index 2157168f..3c4dda2a 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -35,7 +35,7 @@ void Carpenter(CarpenterEntity* this) { break; super->action = 1; this->animIndex = 0; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); sub_0807DD64(super); case 1: @@ -115,7 +115,7 @@ void Carpenter_Fusion(Entity* this) { if (LoadExtraSpriteData(this, &gUnk_08110CA8[this->type * 4])) { this->action++; this->spriteSettings.draw = 1; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitializeAnimation(this, (u32)this->type * 8 + 2); } } else { diff --git a/src/npc/cat.c b/src/npc/cat.c index aa2d221e..d2f42aec 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -221,7 +221,7 @@ void sub_0806799C(CatEntity* this) { UpdateAnimationSingleFrame(super); if ((gMessage.doTextBox & 0x7f) == 0) { sub_08067B08(this); - SetDefaultPriority(super, PRIO_PLAYER); + SetEntityPriority(super, PRIO_PLAYER); } } @@ -409,7 +409,7 @@ void sub_08067C44(CatEntity* this) { } else { super->action = 4; sub_08067790(super); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } super->interactType = INTERACTION_NONE; SoundReq(SFX_VO_CAT); diff --git a/src/npc/cucco.c b/src/npc/cucco.c index f936bc1e..33a7d46a 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -30,7 +30,7 @@ void Cucco_Init(CuccoEntity* this) { super->action++; this->fusionOffer = GetFusionToOffer(super); AddInteractableAsMinishFuser(super, this->fusionOffer); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); super->subAction = 0; sub_0806E4EC(this); } diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c index fa4da6a6..07b03baf 100644 --- a/src/npc/cuccoChick.c +++ b/src/npc/cuccoChick.c @@ -37,7 +37,7 @@ void CuccoChick_Init(CuccoChickEntity* this) { super->action++; this->fusionOffer = GetFusionToOffer(super); AddInteractableAsMinishFuser(super, this->fusionOffer); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); super->subAction = 0; sub_0806E764(this); } diff --git a/src/npc/dampe.c b/src/npc/dampe.c index 4fd41240..88cc9e0a 100644 --- a/src/npc/dampe.c +++ b/src/npc/dampe.c @@ -23,7 +23,7 @@ void Dampe(Entity* this) { case 0: this->action = 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); return; case 1: diff --git a/src/npc/dog.c b/src/npc/dog.c index 1969c89a..82708d84 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -226,7 +226,7 @@ void sub_08069B44(DogEntity* this) { super->animationState = 2; this->unk_6a = 0xff; this->unk_74 = GetFusionToOffer(super); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitAnimationForceUpdate(super, 10); if ((super->flags & ENT_SCRIPTED) != 0) { InitScriptForNPC(super); @@ -525,7 +525,7 @@ void Dog_Fusion(DogEntity* this) { if (sub_08069EF0(this)) { super->action++; super->spriteSettings.draw = 1; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitializeAnimation(super, 0x23); } } else { diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index f6519407..32b2f062 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -15,7 +15,7 @@ void DrLeft(Entity* this) { if (this->type == 0) { if (this->action == 0) { this->action++; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); } ExecuteScriptForEntity(this, NULL); diff --git a/src/npc/emma.c b/src/npc/emma.c index 098d61b7..9cd04780 100644 --- a/src/npc/emma.c +++ b/src/npc/emma.c @@ -13,7 +13,7 @@ void Emma(Entity* this) { if (this->action == 0) { this->action++; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); } else { ExecuteScriptAndHandleAnimation(this, NULL); diff --git a/src/npc/epona.c b/src/npc/epona.c index b467d900..91bfc6de 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -101,7 +101,7 @@ void sub_08065AA4(EponaEntity* this) { InitializeNPCFusion(super); } else { super->action = 3; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); sub_08065A50(this); } InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); diff --git a/src/npc/ezlo.c b/src/npc/ezlo.c index 45368147..c490a29e 100644 --- a/src/npc/ezlo.c +++ b/src/npc/ezlo.c @@ -14,7 +14,7 @@ const u8 gUnk_08114144[]; void Ezlo(Entity* this) { if (this->action == 0) { this->action++; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); } ExecuteScriptForEntity(this, NULL); diff --git a/src/npc/farmers.c b/src/npc/farmers.c index 7b9e1036..a1f69c55 100644 --- a/src/npc/farmers.c +++ b/src/npc/farmers.c @@ -38,7 +38,7 @@ void Farmers(Entity* this) { } void sub_0806BC58(Entity* this) { - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); } void Farmers_Head(Entity* this) { diff --git a/src/npc/festari.c b/src/npc/festari.c index 9d42eb8c..d32badf2 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -35,7 +35,7 @@ void Festari(FestariEntity* this) { void sub_0805FE10(FestariEntity* this) { super->action = 1; super->spriteSettings.draw = TRUE; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); this->fusionOffer = GetFusionToOffer(super); AddInteractableWhenBigFuser(super, this->fusionOffer); InitScriptForNPC(super); @@ -127,7 +127,7 @@ void Festari_Fusion(FestariEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 1; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitAnimationForceUpdate(super, 8); } else { UpdateAnimationSingleFrame(super); diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 7943e305..8d5cf8dc 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -526,7 +526,7 @@ void ForestMinish(ForestMinishEntity* this) { super->spriteSettings.draw = TRUE; this->animIndex = super->animationState = super->timer << 1; super->timer = 0; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); StartCutscene(super, (u16*)gUnk_08109D18[super->type2]); InitScriptForNPC(super); } @@ -755,7 +755,7 @@ void ForestMinish_Fusion(Entity* this) { if (LoadExtraSpriteData(this, gUnk_0810A348)) { this->action++; this->spriteSettings.draw = TRUE; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 6); } } else { diff --git a/src/npc/gentari.c b/src/npc/gentari.c index e8621c42..a2e02a34 100644 --- a/src/npc/gentari.c +++ b/src/npc/gentari.c @@ -18,7 +18,7 @@ void Gentari(GentariEntity* this) { case 0: super->action = 1; super->spriteSettings.draw = TRUE; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); this->fusionOffer = GetFusionToOffer(super); AddInteractableWhenBigFuser(super, this->fusionOffer); InitScriptForNPC(super); @@ -45,7 +45,7 @@ void Gentari_Fusion(Entity* this) { if (this->action == 0) { this->action++; this->spriteSettings.draw = TRUE; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 10); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index 56597734..9458205b 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -136,7 +136,7 @@ void sub_08065D18(GhostBrothersEntity* this) { super->spriteSettings.draw = 1; super->spriteRendering.alphaBlend = 1; this->unk_6c = gUnk_08110188; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitAnimationForceUpdate(super, 2); gScreen.controls.layerFXControl = 0x3f40; gScreen.controls.alphaBlend = 0x1000; diff --git a/src/npc/gregal.c b/src/npc/gregal.c index 66d89c93..781cfec0 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -41,7 +41,7 @@ void sub_0806CAF4(GregalEntity* this) { if (super->action == 0) { super->action++; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); npc = CreateNPC(GREGAL, 1, 0); if (npc != NULL) { npc->parent = super; @@ -68,7 +68,7 @@ void sub_0806CB80(GregalEntity* this) { super->action++; super->animationState = 2; super->frameIndex = 0; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } if (super->parent != NULL) { super->frameIndex = (super->parent->frame & 3) + 0x21; @@ -79,7 +79,7 @@ void sub_0806CBB4(GregalEntity* this) { if (super->action == 0) { super->action++; super->animationState = 2; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitializeAnimation(super, 0x11); } GetNextFrame(super); @@ -96,7 +96,7 @@ void sub_0806CC08(GregalEntity* this) { case 0: super->action = 1; super->spriteSettings.draw = 1; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); sub_0807DD64(super); case 1: if (super->interactType == INTERACTION_FUSE) { @@ -177,7 +177,7 @@ void Gregal_Fusion(Entity* this) { if (this->action == 0) { this->action++; this->spriteSettings.draw = 1; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 6); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/hurdyGurdyMan.c b/src/npc/hurdyGurdyMan.c index 93cb3c36..dfb0c4fc 100644 --- a/src/npc/hurdyGurdyMan.c +++ b/src/npc/hurdyGurdyMan.c @@ -29,7 +29,7 @@ void HurdyGurdyMan(HurdyGurdyManEntity* this) { if (LoadExtraSpriteData(super, gUnk_081144F0)) { super->action = 1; this->unk_69 = 0; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitScriptForNPC(super); } break; @@ -123,7 +123,7 @@ void HurdyGurdyMan_Fusion(Entity* this) { if (LoadExtraSpriteData(this, gUnk_081144F0)) { this->action++; this->spriteSettings.draw = 1; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 10); } } else { diff --git a/src/npc/kingGustaf.c b/src/npc/kingGustaf.c index 880441c8..f71678dc 100644 --- a/src/npc/kingGustaf.c +++ b/src/npc/kingGustaf.c @@ -16,7 +16,7 @@ void KingGustaf(Entity* this) { this->action++; this->spriteRendering.alphaBlend = 1; this->collisionLayer = 2; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); gScreen.controls.layerFXControl = 0x3f40; gScreen.controls.alphaBlend = 0x1000; diff --git a/src/npc/librari.c b/src/npc/librari.c index f1feaf98..f0778371 100644 --- a/src/npc/librari.c +++ b/src/npc/librari.c @@ -22,7 +22,7 @@ void Librari(LibrariEntity* this) { super->animationState = super->timer; this->fusionOffer = GetFusionToOffer(super); AddInteractableWhenBigFuser(super, this->fusionOffer); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitScriptForNPC(super); break; case 1: diff --git a/src/npc/mama.c b/src/npc/mama.c index 8590e994..43cdd164 100644 --- a/src/npc/mama.c +++ b/src/npc/mama.c @@ -62,7 +62,7 @@ bool32 sub_0806C454(Entity* this) { if (!LoadExtraSpriteData(this, gUnk_08113754)) { return FALSE; } else { - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); return TRUE; } } diff --git a/src/npc/marcy.c b/src/npc/marcy.c index d30ef441..bfef099e 100644 --- a/src/npc/marcy.c +++ b/src/npc/marcy.c @@ -14,7 +14,7 @@ void Marcy(Entity* this) { if (this->action == 0) { this->action++; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); sub_0807DD64(this); } ExecuteScriptAndHandleAnimation(this, NULL); diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index b817987d..161b9f36 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -24,7 +24,7 @@ void MayorHagen(MayorHagenEntity* this) { super->action = 1; this->animIndex = 0; this->fusionOffer = GetFusionToOffer(super); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitScriptForNPC(super); break; case 1: diff --git a/src/npc/melari.c b/src/npc/melari.c index 22f303f4..75ae8ed3 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -78,7 +78,7 @@ void sub_08068780(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; this->animationState = this->type; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); break; case 1: diff --git a/src/npc/minishEzlo.c b/src/npc/minishEzlo.c index 2306f107..b509b1db 100644 --- a/src/npc/minishEzlo.c +++ b/src/npc/minishEzlo.c @@ -33,7 +33,7 @@ void MinishEzlo(Entity* this) { } this->action++; this->animationState = this->timer * 2; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); } ExecuteScriptForEntity(this, NULL); diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c index 15aa1d06..baf3e231 100644 --- a/src/npc/mountainMinish.c +++ b/src/npc/mountainMinish.c @@ -126,7 +126,7 @@ void sub_08067EF0(MountainMinishEntity* this) { super->spriteSettings.draw = 1; super->animationState = super->type; this->animIndex = 0; - SetDefaultPriority(super, 2); + SetEntityPriority(super, 2); InitScriptForNPC(super); InitializeAnimation(super, gUnk_08111304[super->type2]); break; diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index afe2d86f..a9adf6e0 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -36,7 +36,7 @@ void Mutoh(MutohEntity* this) { if (LoadExtraSpriteData(super, gUnk_08110C00)) { super->action = 1; super->spriteSettings.draw = TRUE; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitScriptForNPC(super); } break; diff --git a/src/npc/pita.c b/src/npc/pita.c index ccf79c69..673de68b 100644 --- a/src/npc/pita.c +++ b/src/npc/pita.c @@ -28,7 +28,7 @@ void Pita(PitaEntity* this) { }; if (super->action == 0) { super->action++; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); SortEntityAbove(super, super); super->hitbox = (Hitbox*)&gUnk_0810C428; sub_0807DD64(super); diff --git a/src/npc/postman.c b/src/npc/postman.c index f8e9b0fa..12711abc 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -234,7 +234,7 @@ void sub_080604DC(Entity* this) { ent = CreateFx(this, FX_DASH, 0x40); if (ent != NULL) { ent->y.HALF.HI++; - SetDefaultPriority(ent, 3); + SetEntityPriority(ent, 3); } } } diff --git a/src/npc/rem.c b/src/npc/rem.c index 5470b36b..45d66679 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -76,7 +76,7 @@ void sub_0806a370(RemEntity* this) { void sub_0806A3D8(RemEntity* this) { super->action = 1; super->timer = 180; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); sub_0806A8C8(super); this->context = StartCutscene(super, &script_Rem); ExecuteScriptAndHandleAnimation(super, NULL); @@ -297,7 +297,7 @@ void sub_0806A830(RemEntity* this) { if (super->action == 0) { super->action = 1; InitializeAnimation(super, 0x14); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } if ((gActiveScriptInfo.syncFlags & 0x200) != 0) { DeleteThisEntity(); @@ -316,7 +316,7 @@ void sub_0806A890(RemEntity* this) { if (super->action == 0) { super->action = 1; InitializeAnimation(super, 0x15); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } GetNextFrame(super); if ((super->frame & ANIM_DONE) != 0) { diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index 3560137b..68d63b46 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -59,7 +59,7 @@ void sub_08065080(StockwellEntity* this) { super->action = 1; super->spriteSettings.draw = 1; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitializeAnimation(super, 4); AddInteractableWhenBigObject(super); #ifndef EU diff --git a/src/npc/syrup.c b/src/npc/syrup.c index ae1f8eb1..c8d5d6c4 100644 --- a/src/npc/syrup.c +++ b/src/npc/syrup.c @@ -48,7 +48,7 @@ void sub_0806A1F8(SyrupEntity* this) { if (LoadExtraSpriteData(super, paVar2)) { super->action = 1; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitScriptForNPC(super); InitializeAnimation(super, 0); } diff --git a/src/npc/teachers.c b/src/npc/teachers.c index 52ea9b4f..527e357a 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -30,7 +30,7 @@ void Teachers(TeachersEntity* this) { super->spriteSettings.draw = TRUE; super->animationState = super->timer; this->animIndex = 0; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitScriptForNPC(super); } break; diff --git a/src/npc/vaati.c b/src/npc/vaati.c index f55e285f..9f1c9482 100644 --- a/src/npc/vaati.c +++ b/src/npc/vaati.c @@ -42,7 +42,7 @@ void VaatiAction0(VaatiEntity* this) { super->spriteSettings.draw = 1; this->unk_68 = 0; this->unk_69 = 0; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); sub_0807DD64(super); VaatiAction1(this); } diff --git a/src/npc/wheaton.c b/src/npc/wheaton.c index aa24f321..7638a205 100644 --- a/src/npc/wheaton.c +++ b/src/npc/wheaton.c @@ -12,7 +12,7 @@ void Wheaton(Entity* this) { if (this->action == 0) { this->action++; - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); SortEntityAbove(this, this); this->hitbox = (Hitbox*)&gUnk_0810C3C0; this->spriteOffsetY = 0xfe; diff --git a/src/npc/zelda.c b/src/npc/zelda.c index a2882348..9fa4612e 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -31,7 +31,7 @@ void sub_08066CCC(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; PrependEntityToList(this, 7); - SetDefaultPriority(this, PRIO_MESSAGE); + SetEntityPriority(this, PRIO_MESSAGE); InitScriptForNPC(this); } diff --git a/src/npc/zeldaFollower.c b/src/npc/zeldaFollower.c index fd9c71d9..349c9338 100644 --- a/src/npc/zeldaFollower.c +++ b/src/npc/zeldaFollower.c @@ -51,7 +51,7 @@ void ZeldaFollower(ZeldaFollowerEntity* this) { super->animationState = 4; this->unk_68 = 0; this->unk_69 = 0; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); InitAnimationForceUpdate(super, 0); sub_0806854C(this, NULL); } diff --git a/src/object/beanstalk.c b/src/object/beanstalk.c index d265052e..d2f7899c 100644 --- a/src/object/beanstalk.c +++ b/src/object/beanstalk.c @@ -67,7 +67,7 @@ void Beanstalk_Init(BeanstalkEntity* this) { super->spriteRendering.b3 = 2; super->spriteOrientation.flipY = 1; - SetDefaultPriority(super, 4); + SetEntityPriority(super, 4); if (super->type == 7) { #ifndef EU if ((super->flags & ENT_DID_INIT) == 0) { diff --git a/src/object/bigBarrel.c b/src/object/bigBarrel.c index e1515106..07708c40 100644 --- a/src/object/bigBarrel.c +++ b/src/object/bigBarrel.c @@ -208,7 +208,7 @@ void BigBarrel_Type2(BigBarrelEntity* this) { super->spriteSettings.draw = 1; super->frameIndex = super->type2 * 4 + 6; super->collisionLayer = 2; - SetDefaultPriority(super, 3); + SetEntityPriority(super, 3); super->type2 = super->type2 == 0 ? 0x15 : 0x16; UpdateSpriteForCollisionLayer(super); break; @@ -346,7 +346,7 @@ void sub_08089094(BigBarrelEntity* this) { void sub_080890EC(BigBarrelEntity* this, const s16* offsets, s32 yOffset) { Entity* pEVar1 = CreateObject(BIG_BARREL, 3, 0); if (pEVar1) { - SetDefaultPriority(pEVar1, 3); + SetEntityPriority(pEVar1, 3); pEVar1->x.HALF.HI = super->x.HALF.HI; pEVar1->y.HALF.HI = super->y.HALF.HI + yOffset; pEVar1->parent = super; diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index f7bacd3d..7efe0113 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -49,7 +49,7 @@ void BigVortex_Init(BigVortexEntity* this) { super->spriteSettings.draw = TRUE; sub_08098E88(super); } - SetDefaultPriority(super, PRIO_PLAYER_EVENT); + SetEntityPriority(super, PRIO_PLAYER_EVENT); InitAnimationForceUpdate(super, 0); } diff --git a/src/object/bird.c b/src/object/bird.c index 2fc5ed83..2b4b0dac 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -214,7 +214,7 @@ void Bird_Type8(BirdEntity* this) { super->x.HALF.HI = gRoomControls.scroll_x; super->y.HALF.HI = gPlayerEntity.y.HALF.HI; super->child = NULL; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); InitAnimationForceUpdate(super, 0); SoundReq(0x123); break; @@ -307,7 +307,7 @@ void Bird_Type9(BirdEntity* this) { super->spritePriority.b0 = 0; super->spriteRendering.b3 = 0; super->spriteOrientation.flipY = 1; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); super->x.HALF.HI = gRoomControls.scroll_x; super->y.HALF.HI = gPlayerEntity.y.HALF.HI; SoundReq(SFX_123); @@ -364,7 +364,7 @@ void Bird_Type10(BirdEntity* this) { super->spritePriority.b0 = 0; super->spriteRendering.b3 = 0; super->spriteOrientation.flipY = 1; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); InitAnimationForceUpdate(super, 0xe0); case 1: UpdateAnimationSingleFrame(super); @@ -400,7 +400,7 @@ void sub_0809D738(void) { pEVar1 = CreateObject(BIRD, 9, 0); if (pEVar1 != NULL) { gRoomControls.camera_target = NULL; - SetDefaultPriority(pEVar1, 6); + SetEntityPriority(pEVar1, 6); SetPlayerEventPriority(); pEVar2 = CreateObject(BIRD, 10, 0); if (pEVar2 != NULL) { diff --git a/src/object/cameraTarget.c b/src/object/cameraTarget.c index 9c001915..e19d0499 100644 --- a/src/object/cameraTarget.c +++ b/src/object/cameraTarget.c @@ -96,7 +96,7 @@ void CameraTarget_Init(Entity* this) { } this->action = 1; this->flags |= ENT_PERSIST; - SetDefaultPriority(this, 6); + SetEntityPriority(this, 6); } void CameraTarget_Action1(Entity* this) { diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index 1e28d988..74db801c 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -100,7 +100,7 @@ void CrenelBeanSprout_Init(CrenelBeanSproutEntity* this) { break; case 1: super->spriteRendering.b0 = 3; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); break; case 2: if (CheckLocalFlag((u32)super->type2) == 0) { diff --git a/src/object/cutsceneMiscObject.c b/src/object/cutsceneMiscObject.c index 6cf374ad..00fdc5e7 100644 --- a/src/object/cutsceneMiscObject.c +++ b/src/object/cutsceneMiscObject.c @@ -212,7 +212,7 @@ void CutsceneMiscObject_Type2(CutsceneMiscObjectEntity* this) { DeleteThisEntity(); if (super->action == 0) { super->action++; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); super->spriteRendering.b3 = gUnk_08114F30[p->spriteRendering.b3]; InitAnimationForceUpdate(super, 1); } @@ -231,7 +231,7 @@ void CutsceneMiscObject_Type3(CutsceneMiscObjectEntity* this) { } else { super->action++; super->spriteSettings.draw = 1; - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); switch (super->type2) { case 0x40: case 0x41: @@ -290,7 +290,7 @@ void CutsceneMiscObject_Type4(CutsceneMiscObjectEntity* this) { } else { super->action++; super->spriteSettings.draw = 1; - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); InitAnimationForceUpdate(super, 0); } UpdateAnimationSingleFrame(super); @@ -330,7 +330,7 @@ void CutsceneMiscObject_Type5(CutsceneMiscObjectEntity* this) { super->action++; super->z.WORD = Q_16_16(-160.0); super->zVelocity = 0; - SetDefaultPriority(super, PRIO_PLAYER_EVENT); + SetEntityPriority(super, PRIO_PLAYER_EVENT); InitializeAnimation(super, 0); if (GetTileUnderEntity(super) == 13) { super->action = 3; @@ -472,7 +472,7 @@ void CutsceneMiscObject_Type7(CutsceneMiscObjectEntity* this) { void CutsceneMiscObject_Type8(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action = 1; - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); SortEntityBelow(super, super); sub_0807DD64(super); InitAnimationForceUpdate(super, 2); @@ -492,7 +492,7 @@ void sub_08095164(CutsceneMiscObjectEntity* this) { void CutsceneMiscObject_Type9(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action = 1; - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); SortEntityBelow(super, super); sub_0807DD64(super); InitAnimationForceUpdate(super, 0); @@ -547,7 +547,7 @@ void CutsceneMiscObject_Type11(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->subAction = 0; - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); InitAnimationForceUpdate(super, 0); } if (super->subAction != 0) { @@ -607,7 +607,7 @@ void CutsceneMiscObject_Type12(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->z.HALF.HI = -16; - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); super->spriteRendering.b3 = gUnk_08114F30[super->spriteRendering.b3]; SortEntityAbove(super, super); sub_0807DD64(super); @@ -844,7 +844,7 @@ void CutsceneMiscObject_Type19(CutsceneMiscObjectEntity* this) { void CutsceneMiscObject_Type20(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; - SetDefaultPriority(super, PRIO_PLAYER_EVENT); + SetEntityPriority(super, PRIO_PLAYER_EVENT); sub_0807DD64(super); InitializeAnimation(super, 0); } @@ -879,7 +879,7 @@ void CutsceneMiscObject_Type22(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 0; - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); sub_0807DD64(super); } ExecuteScriptForEntity(super, 0); @@ -1035,7 +1035,7 @@ void CutsceneMiscObject_Type28(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 0; - SetDefaultPriority(super, PRIO_PLAYER_EVENT); + SetEntityPriority(super, PRIO_PLAYER_EVENT); sub_0807DD64(super); } ExecuteScriptForEntity(super, 0); diff --git a/src/object/deathFx.c b/src/object/deathFx.c index e6121ec0..2d4204e4 100644 --- a/src/object/deathFx.c +++ b/src/object/deathFx.c @@ -81,7 +81,7 @@ void DeathFx_Action0(DeathFxObject* this) { super->action = 1; EnqueueSFX(SFX_FF); } - SetDefaultPriority(super, 3); + SetEntityPriority(super, 3); } void DeathFx_Action1(DeathFxObject* this) { diff --git a/src/object/fairy.c b/src/object/fairy.c index ba3b6703..e937288f 100644 --- a/src/object/fairy.c +++ b/src/object/fairy.c @@ -110,7 +110,7 @@ void Fairy_Init(FairyEntity* this) { super->gustJarFlags = 1; this->unk_74 = super->x.HALF.HI; this->unk_76 = super->y.HALF.HI; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); EnqueueSFX(SFX_136); switch (super->type2) { diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c index 624824ae..86c09f1d 100644 --- a/src/object/figurineDevice.c +++ b/src/object/figurineDevice.c @@ -102,7 +102,7 @@ void FigurineDevice_Init(FigurineDeviceEntity* this) { case 2: this->unk_7a = 0; - SetDefaultPriority(super, 7); + SetEntityPriority(super, 7); InitializeAnimation(super, 1); break; case 3: @@ -113,7 +113,7 @@ void FigurineDevice_Init(FigurineDeviceEntity* this) { this->unk_7b = 0; this->unk_80 = 0; sub_0808804C(this); - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); break; } } diff --git a/src/object/fourElements.c b/src/object/fourElements.c index a9e02140..1c3942ea 100644 --- a/src/object/fourElements.c +++ b/src/object/fourElements.c @@ -108,7 +108,7 @@ void FourElements_Action3(FourElementsEntity* this) { if (super->timer != 0) { sub_080A0424(this); if (--super->timer == 0) { - SetDefaultPriority(&gPlayerEntity, 0); + SetEntityPriority(&gPlayerEntity, 0); } } else { RequestPriorityDuration(NULL, 60); diff --git a/src/object/frozenOctorok.c b/src/object/frozenOctorok.c index 6f46ac27..540a85dd 100644 --- a/src/object/frozenOctorok.c +++ b/src/object/frozenOctorok.c @@ -64,7 +64,7 @@ void FrozenOctorok_Init(FrozenOctorokEntity* this) { super->action = 1; switch (super->type) { case 0: - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); this->unk_7e = 0; case 6: super->timer = 1; diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index 6820317a..1416d564 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -497,7 +497,7 @@ void GreatFairy_InitializeAnimation(GreatFairyEntity* this) { super->type2 = super->type % temp; super->collisionLayer = 2; InitializeAnimation(super, super->type2); - SetDefaultPriority(super, PRIO_MESSAGE); + SetEntityPriority(super, PRIO_MESSAGE); } Entity* GreatFairy_CreateForm(GreatFairyEntity* this, u32 curForm, u32 parameter) { @@ -544,7 +544,7 @@ void sub_08087424(GreatFairyEntity* this, ScriptExecutionContext* context) { if (ent != NULL) { ent->parent = &gPlayerEntity; CopyPosition(&gPlayerEntity, ent); - SetDefaultPriority(ent, PRIO_MESSAGE); + SetEntityPriority(ent, PRIO_MESSAGE); } switch (context->intVariable) { diff --git a/src/object/guruguruBar.c b/src/object/guruguruBar.c index 0de3796d..2c1365c1 100644 --- a/src/object/guruguruBar.c +++ b/src/object/guruguruBar.c @@ -52,7 +52,7 @@ void GuruguruBar_Init(GuruguruBarEntity* this) { bVar1 = this->unk7e; this->unk76 = bVar1 << 8; super->animationState = bVar1 << 6; - SetDefaultPriority(super, 0); + SetEntityPriority(super, 0); if (super->type != 0) { super->child = (Entity*)GetCurrentRoomProperty(super->type); UpdateRailMovement(super, (u16**)&super->child, &this->unk74); diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index a921f8ba..2835e202 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -62,7 +62,7 @@ void HouseDoorExterior_Type0(HouseDoorExteriorEntity* this) { super->action = 1; *((u32*)(&this->unk_68)) = 0; this->unk_6c = super->timer; - SetDefaultPriority(super, PRIO_PLAYER_EVENT); + SetEntityPriority(super, PRIO_PLAYER_EVENT); } prop = GetCurrentRoomProperty(this->unk_6c); diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index aca8b2fd..9a87f5c6 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -66,7 +66,7 @@ void ItemForSale_Init(ItemForSaleEntity* this) { super->spritePriority.b1 = 0; super->carryFlags = 0; #ifdef EU - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); #endif super->child = super; ItemForSale_MakeInteractable(this); diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index bf70e601..8aff156f 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -143,7 +143,7 @@ void ItemOnGround_Init(ItemOnGroundEntity* this) { this->unk_6c = 0; this->unk_68 = 0; super->timer = 0; - SetDefaultPriority(super, PRIO_NO_BLOCK); + SetEntityPriority(super, PRIO_NO_BLOCK); super->gustJarFlags = sub_0808147C(super->type); gUnk_0811E7E8[this->unk_69](this); } else { @@ -370,7 +370,7 @@ void sub_08081404(ItemOnGroundEntity* this, u32 arg1) { bool32 sub_08081420(ItemOnGroundEntity* this) { if (CheckShouldPlayItemGetCutscene(this)) { - SetDefaultPriority(super, PRIO_PLAYER_EVENT); + SetEntityPriority(super, PRIO_PLAYER_EVENT); CreateItemEntity(super->type, super->type2, 0); return TRUE; } else { diff --git a/src/object/linkAnimation.c b/src/object/linkAnimation.c index 8a9d361d..c811373c 100644 --- a/src/object/linkAnimation.c +++ b/src/object/linkAnimation.c @@ -2,126 +2,122 @@ * @file linkAnimation.c * @ingroup Objects * - * @brief Link Animation object + * @brief Link Animation object. This is used during "item get" sequences and + * replaces the player entity for the duration. */ #define NENT_DEPRECATED #include "functions.h" #include "message.h" #include "object.h" +#include "object/linkAnimation.h" -typedef struct { - /*0x00*/ Entity base; - /*0x68*/ u8 unk_68; - /*0x69*/ u8 unk_69; - /*0x6a*/ u8 unk_6a; - /*0x6b*/ u8 unk_6b; - /*0x6c*/ u8 unk_6c; - /*0x6d*/ u8 unk_6d; - /*0x6e*/ u8 unk_6e; - /*0x6f*/ u8 unk_6f; - /*0x70*/ u32 unk_70; - /*0x74*/ u8 unk_74; -} LinkAnimationEntity; +typedef enum { + ITEMGET_INIT, + ITEMGET_UPDATE, + ITEMGET_WAIT, +} ItemGetState; void LinkAnimation_Init(LinkAnimationEntity*); -void LinkAnimation_Action1(LinkAnimationEntity*); -void LinkAnimation_Action8(LinkAnimationEntity*); +void LinkAnimation_Default(LinkAnimationEntity*); +void LinkAnimation_ItemGet(LinkAnimationEntity*); void LinkAnimation(LinkAnimationEntity* this) { static void (*const LinkAnimation_Actions[])(LinkAnimationEntity*) = { - LinkAnimation_Init, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, - LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, - LinkAnimation_Action8, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, - LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, - LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, - LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, - LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, - LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, LinkAnimation_Action1, + LinkAnimation_Init, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, + LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, + LinkAnimation_ItemGet, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, + LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, + LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, + LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, + LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, + LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, LinkAnimation_Default, }; LinkAnimation_Actions[super->action](this); } void LinkAnimation_Init(LinkAnimationEntity* this) { - super->action = 8; - LinkAnimation_Action8(this); + super->action = PLAYER_ITEMGET; + LinkAnimation_ItemGet(this); } -void LinkAnimation_Action1(LinkAnimationEntity* this) { +void LinkAnimation_Default(LinkAnimationEntity* this) { ResetPlayerEventPriority(); gPauseMenuOptions.disabled = 0; DeleteThisEntity(); } -void LinkAnimation_Action8(LinkAnimationEntity* this) { +void LinkAnimation_ItemGet(LinkAnimationEntity* this) { u32 one; - u32 tmp; - Entity* parent; + u32 sprite; + Entity* held_obj; u8* ptr; + // hide player entity gPlayerEntity.flags &= ~ENT_COLLIDE; gPlayerEntity.spriteSettings.draw = 0; + super->palette.b.b0 = gPlayerEntity.palette.b.b0; switch (super->subAction) { - case 0: + case ITEMGET_INIT: one = 1; super->subAction = one; super->spriteSettings.draw = one; super->collisionLayer = gPlayerEntity.collisionLayer; super->spritePriority.b0 = gPlayerEntity.spritePriority.b0; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; super->spriteSettings.flipX = 0; super->animationState = 4; - SetDefaultPriority(super, 6); - if ((gPlayerState.flags & PL_NO_CAP) != 0) { - if (sub_080542AC(super->type)) { - tmp = 0x45e; + SetEntityPriority(super, PRIO_PLAYER_EVENT); + if (gPlayerState.flags & PL_NO_CAP) { + if (IsMinishItem(super->type)) { + sprite = ANIM_GET_ITEM_SMALL_NOCAP; } else { - tmp = 0x45b; + sprite = ANIM_GET_ITEM_BIG_NOCAP; } } else { - if (sub_080542AC(super->type)) { - tmp = 0x2e0; + if (IsMinishItem(super->type)) { + sprite = ANIM_GET_ITEM_SMALL; } else { - tmp = 0x1b9; + sprite = ANIM_GET_ITEM_BIG; } } - super->spriteIndex = (tmp >> 8); - InitAnimationForceUpdate(super, tmp & 0xff); + super->spriteIndex = (sprite >> 8); + InitAnimationForceUpdate(super, sprite & 0xff); break; - case 1: + case ITEMGET_UPDATE: UpdateAnimationSingleFrame(super); if (super->frame != 0) { super->subAction++; } break; - case 2: + case ITEMGET_WAIT: UpdateAnimationSingleFrame(super); if ((gMessage.doTextBox & 0x7f) != 0) { return; } - if ((super->frame & ANIM_DONE) != 0) { - super->action = 1; - gPlayerEntity.flags = this->unk_69; - gPlayerEntity.spriteSettings.draw = this->unk_68; - gPlayerEntity.iframes = this->unk_6a; - gPlayerState.field_0x7 = this->unk_6b; - gPlayerState.keepFacing = this->unk_6c; - gPlayerState.field_0xa = this->unk_6d; - gPlayerState.field_0x27[0] = this->unk_6e; - gPlayerState.mobility = this->unk_6f; - gPlayerState.flags = this->unk_70; - gPlayerState.field_0x8a = this->unk_74; + if (super->frame & ANIM_DONE) { + super->action = PLAYER_NORMAL; + // restore player state + gPlayerEntity.flags = this->storeFlags; + gPlayerEntity.spriteSettings.draw = this->storeDrawFlags; + gPlayerEntity.iframes = this->storeIFrames; + gPlayerState.field_0x7 = this->storeField7; + gPlayerState.keepFacing = this->storeKeepFacing; + gPlayerState.field_0xa = this->storeFieldA; + gPlayerState.field_0x27[0] = this->storeField27; + gPlayerState.mobility = this->storeMobility; + gPlayerState.flags = this->storeStateFlags; + gPlayerState.field_0x8a = this->store8A; } break; } - parent = super->parent; - if (parent != NULL) { - PositionEntityOnTop(super, parent); + held_obj = super->parent; + if (held_obj != NULL) { + PositionEntityOnTop(super, held_obj); ptr = GetSpriteSubEntryOffsetDataPointer((u16)super->spriteIndex, super->frameIndex); - parent->spriteOffsetX = *ptr; - parent->spriteOffsetY = ptr[1]; + held_obj->spriteOffsetX = ptr[0]; + held_obj->spriteOffsetY = ptr[1]; } } diff --git a/src/object/linkHoldingItem.c b/src/object/linkHoldingItem.c index cf14269a..009535a7 100644 --- a/src/object/linkHoldingItem.c +++ b/src/object/linkHoldingItem.c @@ -38,7 +38,7 @@ void LinkHoldingItem(LinkHoldingItemEntity* this) { } void LinkHoldingItem_Init(LinkHoldingItemEntity* this) { - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); super->action = 1; } diff --git a/src/object/minishVillageObject.c b/src/object/minishVillageObject.c index 7abd4675..dbefdeb9 100644 --- a/src/object/minishVillageObject.c +++ b/src/object/minishVillageObject.c @@ -127,7 +127,7 @@ void sub_0808D2CC(void) { Entity* obj = FindEntity(6, MINISH_VILLAGE_OBJECT, 6, 1, 0); if (obj != NULL) { obj->type = 9; - SetDefaultPriority(obj, 2); + SetEntityPriority(obj, 2); } } diff --git a/src/object/moleMittsParticle.c b/src/object/moleMittsParticle.c index 15b19439..93a0379c 100644 --- a/src/object/moleMittsParticle.c +++ b/src/object/moleMittsParticle.c @@ -63,7 +63,7 @@ void MoleMittsParticle_Init(Entity* this) { break; } } - SetDefaultPriority(this, 3); + SetEntityPriority(this, 3); InitializeAnimation(this, this->type2 * 4 + this->animationState); } diff --git a/src/object/object30.c b/src/object/object30.c index fdda1933..446d2bf6 100644 --- a/src/object/object30.c +++ b/src/object/object30.c @@ -106,6 +106,6 @@ void sub_0808A968(Object30Entity* this) { super->spriteSettings.shadow = 0; super->collisionFlags |= 0x10; super->hitbox = (Hitbox*)&gUnk_08121C58; - SetDefaultPriority(super, 2); + SetEntityPriority(super, 2); this->gravity = Q_8_8(40.0); } diff --git a/src/object/objectA2.c b/src/object/objectA2.c index 1dedecaf..4f9c55cb 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -45,7 +45,7 @@ void ObjectA2_Init(Entity* this) { this->spriteOrientation.flipY = 2; this->action = 1; ChangeObjPalette(this, gUnk_08124704[this->type]); - SetDefaultPriority(this, PRIO_HIGHEST); + SetEntityPriority(this, PRIO_HIGHEST); } void ObjectA2_Action1(Entity* this) { diff --git a/src/object/objectA8.c b/src/object/objectA8.c index dca5a903..819495d4 100644 --- a/src/object/objectA8.c +++ b/src/object/objectA8.c @@ -83,7 +83,7 @@ void ObjectA8_Init(ObjectA8Entity* this) { super->gustJarFlags = 1; this->unk_74 = super->x.HALF.HI; this->unk_76 = super->y.HALF.HI; - SetDefaultPriority(super, 3); + SetEntityPriority(super, 3); EnqueueSFX(SFX_136); } diff --git a/src/object/parallaxRoomView.c b/src/object/parallaxRoomView.c index f72cc80b..bd08c984 100644 --- a/src/object/parallaxRoomView.c +++ b/src/object/parallaxRoomView.c @@ -34,7 +34,7 @@ void ParallaxRoomView(ParallaxRoomViewEntity* this) { } this->unk_68 = super->x.HALF.HI; this->unk_6a = super->y.HALF.HI; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); } if ((super->flags & 0x10) == 0) { iVar4 = super->x.HALF.HI - gRoomControls.scroll_x; diff --git a/src/object/shrinkingHieroglyphs.c b/src/object/shrinkingHieroglyphs.c index be8462b5..daa132f1 100644 --- a/src/object/shrinkingHieroglyphs.c +++ b/src/object/shrinkingHieroglyphs.c @@ -52,7 +52,7 @@ void ShrinkingHieroglyphs_Init(ShrinkingHieroglyphsEntity* this) { super->subtimer = 30; this->objDir.HALF.HI = ShrinkingHieroglyphs_Directions[super->type]; this->unk74 = 0x2000; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); if (super->type == 0) { this->unk7e = 0x40; LoadSwapGFX(super, 1, 0); diff --git a/src/object/specialFx.c b/src/object/specialFx.c index 3a5ca962..8780cf0c 100644 --- a/src/object/specialFx.c +++ b/src/object/specialFx.c @@ -153,7 +153,7 @@ void SpecialFx_Init(SpecialFxObject* this) { super->action = 1; super->flags &= ~0x80; super->spriteSettings.draw = 1; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); if (super->collisionLayer == 0) { ResolveCollisionLayer(super); } diff --git a/src/object/windTribeTeleporter.c b/src/object/windTribeTeleporter.c index bd94a171..997a91d0 100644 --- a/src/object/windTribeTeleporter.c +++ b/src/object/windTribeTeleporter.c @@ -39,7 +39,7 @@ void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) { super->frameDuration = 8; super->spritePriority.b0 = 7; super->hitbox = (Hitbox*)&gHitbox_22; - SetDefaultPriority(super, 6); + SetEntityPriority(super, 6); if (sub_080A11C0(this)) { gPlayerEntity.x.HALF.HI = super->x.HALF.HI; gPlayerEntity.y.HALF.HI = super->y.HALF.HI; diff --git a/src/objectUtils.c b/src/objectUtils.c index a688564d..254be88f 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -1,3 +1,5 @@ +#define NENT_DEPRECATED + #include "global.h" #include "entity.h" #include "physics.h" @@ -5,6 +7,8 @@ #include "object.h" #include "functions.h" #include "definitions.h" +#include "object/linkAnimation.h" +#include "object/itemOnGround.h" extern const Hitbox* const gObjectHitboxes[]; @@ -29,6 +33,7 @@ const s8 gUnk_08126EEC[] = { Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) { Entity* e = CreateItemGetEntity(); if (e != NULL) { + LinkAnimationEntity* this = (LinkAnimationEntity*)e; e->id = LINK_ANIMATION; e->kind = OBJECT; e->type = type; @@ -39,16 +44,20 @@ Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) { CopyPosition(&gPlayerEntity, e); gPriorityHandler.sys_priority = 6; gPauseMenuOptions.disabled = 1; - e->field_0x68.HALF.HI = gPlayerEntity.flags; - e->field_0x68.HALF.LO = gPlayerEntity.spriteSettings.draw; - e->field_0x6a.HALF.LO = gPlayerEntity.iframes; - e->field_0x6a.HALF.HI = gPlayerState.field_0x7; - e->field_0x6c.HALF.LO = gPlayerState.keepFacing; - e->field_0x6c.HALF.HI = gPlayerState.field_0xa; - e->field_0x6e.HALF.LO = gPlayerState.field_0x27[0]; - e->field_0x6e.HALF.HI = gPlayerState.mobility; - e->field_0x70.WORD = gPlayerState.flags; - e->field_0x74.HALF.LO = gPlayerState.field_0x8a; + + // store player state + this->storeFlags = gPlayerEntity.flags; + this->storeDrawFlags = gPlayerEntity.spriteSettings.draw; + this->storeIFrames = gPlayerEntity.iframes; + this->storeField7 = gPlayerState.field_0x7; + this->storeKeepFacing = gPlayerState.keepFacing; + this->storeFieldA = gPlayerState.field_0xa; + this->storeField27 = gPlayerState.field_0x27[0]; + this->storeMobility = gPlayerState.mobility; + this->storeStateFlags = gPlayerState.flags; + this->store8A = gPlayerState.field_0x8a; + + // redundant, this is done by the LinkAnimation object gPlayerEntity.flags &= ~ENT_COLLIDE; gPlayerEntity.spriteSettings.draw = 0; } @@ -179,8 +188,9 @@ Entity* CreateGroundItemWithFlags(Entity* parent, u32 form, u32 subtype, u32 fla ent = CreateObjectWithParent(parent, GROUND_ITEM, form, subtype); if (ent != NULL) { + ItemOnGroundEntity* this = (ItemOnGroundEntity*)ent; ent->timer = 5; - ent->field_0x86.HWORD = flags; + this->unk_86 = flags; } return ent; } @@ -352,7 +362,7 @@ static Entity* CreateSpeechBubble(Entity* parent, u32 type2, s32 xOffset, s32 yO obj->parent = parent; obj->spriteOffsetX = xOffset; obj->spriteOffsetY = yOffset; - SetDefaultPriority(obj, parent->updatePriority); + SetEntityPriority(obj, parent->updatePriority); } return obj; } diff --git a/src/player.c b/src/player.c index cc028dba..90a10af1 100644 --- a/src/player.c +++ b/src/player.c @@ -778,13 +778,13 @@ static void PlayerItemGetInit(Entity* this) { if ((gPlayerState.flags & PL_MINISH) == 0) { u32 anim; if (gPlayerState.flags & PL_NO_CAP) { - if (sub_080542AC(gPlayerState.field_0x38)) { + if (IsMinishItem(gPlayerState.field_0x38)) { anim = ANIM_GET_ITEM_SMALL_NOCAP; } else { anim = ANIM_GET_ITEM_BIG_NOCAP; } } else { - if (sub_080542AC(gPlayerState.field_0x38)) { + if (IsMinishItem(gPlayerState.field_0x38)) { anim = ANIM_GET_ITEM_SMALL; } else { anim = ANIM_GET_ITEM_BIG; @@ -4094,7 +4094,7 @@ void sub_080751E8(u32 a1, u32 a2, void* script) { e2 = CreateSpeechBubbleSleep(&gPlayerEntity, -14, -28); *(Entity**)&gPlayerEntity.field_0x6c.HWORD = e2; if (e2 != NULL) { - SetDefaultPriority(e2, PRIO_NO_BLOCK); + SetEntityPriority(e2, PRIO_NO_BLOCK); } } diff --git a/src/playerUtils.c b/src/playerUtils.c index cff07abb..c987c761 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -23,7 +23,7 @@ static void sub_08077E54(ItemBehavior* beh); extern void sub_0800857C(Entity*); -extern void SetDefaultPriorityForKind(Entity*); +extern void SetEntityPriorityForKind(Entity*); extern void sub_0809D738(Entity*); extern s32 Mod(s32, s32); extern u32 sub_08003FDE(Entity*, Entity*, u32, u32); @@ -1853,7 +1853,7 @@ void PlayerSetNormalAndCollide(void) { PL_MOLDWORM_RELEASED | PL_PARACHUTE); ResolvePlayerAnimation(); SetPlayerActionNormal(); - SetDefaultPriorityForKind(&gPlayerEntity); + SetEntityPriorityForKind(&gPlayerEntity); } void PlayerMinishSetNormalAndCollide(void) { @@ -1869,7 +1869,7 @@ void PlayerMinishSetNormalAndCollide(void) { ~(PL_BUSY | PL_DROWNING | PL_DISABLE_ITEMS | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_PARACHUTE); gPlayerState.swim_state = 0; gPlayerState.queued_action = PLAYER_INIT; - SetDefaultPriorityForKind(&gPlayerEntity); + SetEntityPriorityForKind(&gPlayerEntity); } void sub_080792BC(s32 speed, u32 direction, u32 field_0x38) { diff --git a/src/script.c b/src/script.c index 33fcbcf2..8216a438 100644 --- a/src/script.c +++ b/src/script.c @@ -1671,15 +1671,15 @@ void DeleteHitbox(Entity* entity, ScriptExecutionContext* context) { } void SetPriorityMessage(Entity* entity, ScriptExecutionContext* context) { - SetDefaultPriority(entity, PRIO_MESSAGE); + SetEntityPriority(entity, PRIO_MESSAGE); } void SetPriorityPlayerEvent(Entity* entity, ScriptExecutionContext* context) { - SetDefaultPriority(entity, PRIO_PLAYER_EVENT); + SetEntityPriority(entity, PRIO_PLAYER_EVENT); } void SetPriorityHighest(Entity* entity, ScriptExecutionContext* context) { - SetDefaultPriority(entity, PRIO_NO_BLOCK); + SetEntityPriority(entity, PRIO_NO_BLOCK); } void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) { From d07c41664190a12c4f56d2e71eae8aa41f40ce21 Mon Sep 17 00:00:00 2001 From: theo3 Date: Thu, 28 Dec 2023 21:58:54 -0800 Subject: [PATCH 5/6] message definitions --- asm/src/enemy.s | 2 +- asm/src/projectileUpdate.s | 2 +- include/entity.h | 9 ++-- include/message.h | 4 +- include/player.h | 2 +- include/structures.h | 2 +- src/collision.c | 4 +- src/common.c | 4 +- src/cutscene.c | 8 ++-- src/enemy/businessScrub.c | 6 +-- src/enemy/chuchuBoss.c | 12 ++--- src/enemy/gleerok.c | 6 +-- src/enemy/octorokBoss.c | 12 ++--- src/enemy/vaatiTransfigured.c | 2 +- src/enemy/vaatiTransfiguredEye.c | 4 +- src/enemy/vaatiWrath.c | 2 +- src/enterPortalSubtask.c | 2 +- src/entity.c | 24 +++++----- src/game.c | 8 ++-- src/interrupts.c | 6 +-- src/manager.c | 2 +- src/manager/enterRoomTextboxManager.c | 4 +- src/manager/entitySpawnManager.c | 2 +- src/manager/ezloHintManager.c | 2 +- src/manager/lightManager.c | 67 +++++++++++---------------- src/manager/vaati3StartManager.c | 4 +- src/menu/kinstoneMenu.c | 2 +- src/message.c | 24 +++++----- src/npc.c | 2 +- src/npc/beedle.c | 2 +- src/npc/bigGoron.c | 2 +- src/npc/brocco.c | 2 +- src/npc/castleMaid.c | 2 +- src/npc/cat.c | 2 +- src/npc/epona.c | 2 +- src/npc/ghostBrothers.c | 4 +- src/npc/goron.c | 2 +- src/npc/goronMerchant.c | 4 +- src/npc/guard.c | 4 +- src/npc/kid.c | 2 +- src/npc/mountainMinish.c | 2 +- src/npc/npc23.c | 2 +- src/npc/npc9.c | 2 +- src/npc/percy.c | 4 +- src/npc/pina.c | 2 +- src/npc/postman.c | 2 +- src/npc/stamp.c | 2 +- src/npc/stockwell.c | 12 ++--- src/npc/sturgeon.c | 2 +- src/npc/talon.c | 2 +- src/npc/townMinish.c | 2 +- src/npc/townsperson.c | 2 +- src/npc/windTribespeople.c | 2 +- src/object.c | 2 +- src/object/bird.c | 12 ++--- src/object/book.c | 6 +-- src/object/bush.c | 2 +- src/object/cameraTarget.c | 2 +- src/object/cloud.c | 2 +- src/object/crenelBeanSprout.c | 2 +- src/object/cutsceneMiscObject.c | 2 +- src/object/ezloCap.c | 4 +- src/object/fourElements.c | 2 +- src/object/frozenOctorok.c | 2 +- src/object/gleerokParticle.c | 2 +- src/object/itemForSale.c | 2 +- src/object/lilypadLarge.c | 4 +- src/object/linkAnimation.c | 2 +- src/object/moleMittsParticle.c | 2 +- src/object/octorokBossObject.c | 2 +- src/object/well.c | 2 +- src/object/windTribeTeleporter.c | 12 ++--- src/objectUtils.c | 2 +- src/player.c | 14 +++--- src/playerItem.c | 2 +- src/playerUtils.c | 6 +-- src/script.c | 6 +-- src/scroll.c | 4 +- src/staffroll.c | 2 +- src/subtask.c | 2 +- src/ui.c | 6 +-- 81 files changed, 200 insertions(+), 206 deletions(-) diff --git a/asm/src/enemy.s b/asm/src/enemy.s index 4bada3c6..a19f232f 100644 --- a/asm/src/enemy.s +++ b/asm/src/enemy.s @@ -18,7 +18,7 @@ EnemyUpdate: @ 0x080011C4 bne _080011EA bl DeleteThisEntity _080011DC: - bl EntityIsDeleted + bl EntityDisabled cmp r0, #0 bne _0800120A adds r0, r4, #0 diff --git a/asm/src/projectileUpdate.s b/asm/src/projectileUpdate.s index 590744ce..2888a5fb 100644 --- a/asm/src/projectileUpdate.s +++ b/asm/src/projectileUpdate.s @@ -18,7 +18,7 @@ ProjectileUpdate: @ 0x08016AE4 bne _08016B0A bl DeleteThisEntity _08016AFC: - bl EntityIsDeleted + bl EntityDisabled cmp r0, #0 bne _08016B22 adds r0, r4, #0 diff --git a/include/entity.h b/include/entity.h index cbb54201..5b5c328d 100644 --- a/include/entity.h +++ b/include/entity.h @@ -389,9 +389,12 @@ Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2); void SetEntityPriority(Entity* entity, u32 prio); /** - * Check if entity will be deleted next frame. + * Check if entity is disabled. Entities are disabled if: + * - They are deleted. + * - There is an event and the entity doesn't have priority + * (n/a if entity is in action 0). */ -bool32 EntityIsDeleted(Entity* entity); +bool32 EntityDisabled(Entity* entity); /** * Check if system or entity is blocking updates. @@ -477,7 +480,7 @@ void SetInitializationPriority(void); /** * Reset the system update priority. */ -void ResetSystemPriority(void); +void ClearEventPriority(void); void sub_0805E958(void); diff --git a/include/message.h b/include/message.h index 344bf4ed..32f9f582 100644 --- a/include/message.h +++ b/include/message.h @@ -5,8 +5,10 @@ #include "entity.h" #include "structures.h" +#define MESSAGE_ACTIVE 0x7f + typedef struct { - u8 doTextBox; + u8 state; u8 unk; u8 textSpeed; u8 unk3; // HI? diff --git a/include/player.h b/include/player.h index db8c1f08..38e186e5 100644 --- a/include/player.h +++ b/include/player.h @@ -720,7 +720,7 @@ s32 AddInteractableObject(Entity*, u32, u32); void RemoveInteractableObject(Entity*); s32 GetInteractableObjectIndex(); void sub_08078AC0(u32, u32, u32); -void sub_08078B48(void); +void PausePlayer(void); void sub_08078E84(Entity*, Entity*); void sub_08078FB0(Entity*); void sub_080792BC(s32, u32, u32); diff --git a/include/structures.h b/include/structures.h index 0cbe9c71..6125cba9 100644 --- a/include/structures.h +++ b/include/structures.h @@ -191,7 +191,7 @@ extern ItemBehavior gActiveItems[MAX_ACTIVE_ITEMS]; static_assert(sizeof(gActiveItems) == 0x70); typedef struct { - u8 sys_priority; // system requested priority + u8 event_priority; // system requested priority u8 ent_priority; // entity requested priority u8 queued_priority; u8 queued_priority_reset; diff --git a/src/collision.c b/src/collision.c index 402c9bfa..7fb08ca4 100644 --- a/src/collision.c +++ b/src/collision.c @@ -63,8 +63,8 @@ void CollisionMain(void) { u32 prio; // pick highest priority - prio = gPriorityHandler.sys_priority; - if (gPriorityHandler.sys_priority <= gPriorityHandler.ent_priority) + prio = gPriorityHandler.event_priority; + if (gPriorityHandler.event_priority <= gPriorityHandler.ent_priority) prio = gPriorityHandler.ent_priority; // if any priority is set, dont do collision diff --git a/src/common.c b/src/common.c index 81cec6d1..10e200c0 100644 --- a/src/common.c +++ b/src/common.c @@ -747,7 +747,7 @@ void Fuse_Action0(void) { } void Fuse_Action1(void) { - if ((gMessage.doTextBox & 0x7F) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { MenuFadeIn(4, 0); gFuseInfo.fusionState = FUSION_STATE_4; gFuseInfo.action = 2; @@ -773,7 +773,7 @@ void Fuse_Action2(void) { } void Fuse_Action3(void) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { if (gFuseInfo.entity != NULL) { gFuseInfo.entity->updatePriority = gFuseInfo.prevUpdatePriority; } diff --git a/src/cutscene.c b/src/cutscene.c index 93ea6eac..bb1f7187 100644 --- a/src/cutscene.c +++ b/src/cutscene.c @@ -52,7 +52,7 @@ void sub_080535AC(void) { void sub_080535F4(void) { if (gFadeControl.active == 0) { - ResetSystemPriority(); + ClearEventPriority(); gMenu.overlayType = 2; } } @@ -234,7 +234,7 @@ void sub_08053758(void) { gScreen.bg1.control = 0x1c4e; gScreen.bg2.control = 0x1dc1; SoundReq(BGM_STORY); - ResetSystemPriority(); + ClearEventPriority(); SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100); } @@ -344,7 +344,7 @@ void sub_08053A1C(void) { } void sub_08053A5C(void) { - if (((gMessage.doTextBox & 0x7f) == 0) && --gMenu.transitionTimer == 0) { + if (((gMessage.state & MESSAGE_ACTIVE) == 0) && --gMenu.transitionTimer == 0) { gMenu.overlayType++; SetFade(FADE_IN_OUT | FADE_INSTANT, 8); } @@ -451,7 +451,7 @@ void sub_08053B74(void) { gMenu.overlayType++; gUpdateVisibleTiles = 1; LoadRoomEntityList(gUnk_080FCDE0); - ResetSystemPriority(); + ClearEventPriority(); ResetEntityPriority(); SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100); } diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 873ff039..14c52621 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -247,7 +247,7 @@ void BusinessScrub_Action5(Entity* this) { struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD; u32 subtype; - if ((gMessage.doTextBox & 0x7f) == 0 && sub_0802915C(this) && !sub_08056338()) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0 && sub_0802915C(this) && !sub_08056338()) { if (offer->price <= gSave.stats.rupees) { if (BusinessScrub_CheckRefillFitsBag(this)) { /* Bag full. */ @@ -316,11 +316,11 @@ void BusinessScrub_Action6(Entity* this) { } void BusinessScrub_Action7(Entity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD; this->action = 4; - this->subAction = gMessage.doTextBox & 0x7f; + this->subAction = gMessage.state & MESSAGE_ACTIVE; this->timer = 1; if (!CheckLocalFlag(offer->local_flag)) { SetLocalFlag(offer->local_flag); diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 2ea26212..e0ebdb24 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -270,7 +270,7 @@ void ChuchuBoss_OnDeath(ChuchuBossEntity* this) { Entity* child; Entity* parent; - sub_08078B48(); + PausePlayer(); if (super->type == 0) { if (super->subAction != 12) { super->subAction = 12; @@ -464,7 +464,7 @@ void sub_08026090(ChuchuBossEntity* this) { } CopyPosition(super->child, super); } else { - sub_08078B48(); + PausePlayer(); if (super->timer-- == 0) { gRoomControls.camera_target = &gPlayerEntity; DeleteThisEntity(); @@ -543,7 +543,7 @@ void sub_0802626C(ChuchuBossEntity* this) { gPauseMenuOptions.disabled = 1; gUnk_080CC20C[this->unk_84->unk_03](this); if (gPlayerEntity.action != PLAYER_ROOMTRANSITION && gPlayerEntity.action != PLAYER_ROOM_EXIT) { - sub_08078B48(); + PausePlayer(); } } @@ -1127,7 +1127,7 @@ void sub_08026E1C(ChuchuBossEntity* this) { } if ((sub_08027C54(this)) && this->unk_84->unk_04 == 2) { sub_08027C7C(this, 0x3f); - sub_08078B48(); + PausePlayer(); } } @@ -1156,7 +1156,7 @@ void sub_08026FA4(ChuchuBossEntity* this) { ChuchuBossEntity* pEVar3; ChuchuBossEntity* pEVar4; - sub_08078B48(); + PausePlayer(); COLLISION_OFF(super); pEVar4 = (ChuchuBossEntity*)super->child; pEVar3 = (ChuchuBossEntity*)super->parent; @@ -1362,7 +1362,7 @@ void sub_080272D4(ChuchuBossEntity* this) { if (sub_08027C54(super->child) == 0 || ((ChuchuBossEntity*)super->child)->unk_84->unk_04 != 2) { SoundReq(SFX_BOSS_HIT); } else { - sub_08078B48(); + PausePlayer(); gRoomControls.camera_target = super->child; gPauseMenuOptions.disabled = 1; gRoomControls.camera_target->subAction = 9; diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index b04a0d24..6773d849 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -145,7 +145,7 @@ void Gleerok(GleerokEntity* this) { } void Gleerok_OnDeath(GleerokEntity* this) { - sub_08078B48(); + PausePlayer(); switch (super->type) { case 2: @@ -420,7 +420,7 @@ void sub_0802D3B8(GleerokEntity* this) { void sub_0802D650(GleerokEntity* this) { #ifdef EU - sub_08078B48(); + PausePlayer(); #endif gUnk_080CD7E4[super->subAction](this); @@ -1014,7 +1014,7 @@ void sub_0802E0B8(GleerokEntity* this) { if (this->unk_79 > 1) { super->health = 0; super->action = 0; - sub_08078B48(); + PausePlayer(); SoundReq(SFX_BOSS_DIE); return; } else { diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index d8931e9c..7a59d4a9 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -113,17 +113,17 @@ void OctorokBoss_Hit(OctorokBossEntity* this) { if (super->subAction != 3) { gRoomControls.camera_target = &this->heap->tailObjects[0]->base; this->heap->field_0x7 = 0x5a; - sub_08078B48(); + PausePlayer(); } } else { if (this->heap->field_0x7 != 0) { this->heap->field_0x7--; - sub_08078B48(); + PausePlayer(); } } OctorokBoss_Hit_SubActions[super->subAction](this); if (super->subAction > 3) { - sub_08078B48(); + PausePlayer(); } sub_0800445C(super); SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); @@ -136,7 +136,7 @@ void OctorokBoss_Hit_SubAction0(OctorokBossEntity* this) { if (this->bossPhase == 4) { super->subAction = 4; gPauseMenuOptions.disabled = 1; - sub_08078B48(); + PausePlayer(); SoundReq(SFX_BOSS_DIE); } else { if (IS_FROZEN(this) == FALSE) { @@ -442,7 +442,7 @@ void OctorokBoss_Intro(OctorokBossEntity* this) { OctorokBoss_Intro_SubAction0, OctorokBoss_Intro_SubAction1, OctorokBoss_Intro_SubAction2, OctorokBoss_Intro_SubAction3, OctorokBoss_Intro_SubAction4, OctorokBoss_Intro_SubAction5, }; - sub_08078B48(); + PausePlayer(); gPauseMenuOptions.disabled = 1; sub_08036F60(this); OctorokBoss_Intro_SubActions[super->subAction](this); @@ -796,7 +796,7 @@ void OctorokBoss_Action1_Attack(OctorokBossEntity* this) { gPlayerEntity.spriteSettings.draw = 0; gPlayerEntity.flags &= ~ENT_COLLIDE; gPlayerEntity.collisionLayer = 2; - sub_08078B48(); + PausePlayer(); PutAwayItems(); gPlayerEntity.parent = super; sub_08036914(&gPlayerEntity, (u8) - (this->angle.HALF.HI + 0x80), 0x3800); diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 6b58c2af..57b830d6 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -547,7 +547,7 @@ void VaatiTransfiguredType0Action7(Entity* this) { Entity* pEVar3; u32 uVar4; - sub_08078B48(); + PausePlayer(); if (this->timer) { if (--this->timer == 0) { SetRoomFlag(2); diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index f56a6eb0..2d180951 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -99,8 +99,8 @@ void VaatiTransfiguredEyeFunction0Action0(Entity* this) { Entity* child; u8 bVar2; - bVar2 = gMessage.doTextBox & 0x7f; - if ((gMessage.doTextBox & 0x7f) == 0) { + bVar2 = gMessage.state & MESSAGE_ACTIVE; + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->action = 1; this->spriteSettings.draw = 0; this->field_0x80.HALF.LO = bVar2; diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 1c4e74ac..20bd4a17 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -634,7 +634,7 @@ void sub_08041D14(Entity* this) { Entity* pEVar1; GetNextFrame(((VaatiWrathHeapStruct*)this->myHeap)->type2); - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { if (this->timer != 0) { this->timer--; } else { diff --git a/src/enterPortalSubtask.c b/src/enterPortalSubtask.c index 3bac0702..3d445fd6 100644 --- a/src/enterPortalSubtask.c +++ b/src/enterPortalSubtask.c @@ -189,7 +189,7 @@ void Subtask_PortalCutscene_0(void) { gUsedPalettes |= 0x200000; EraseAllEntities(); LoadRoomEntityList(gUnk_080D4110[portalId]); - ResetSystemPriority(); + ClearEventPriority(); gArea.filler3[0]++; SetFade(FADE_INSTANT, 8); } diff --git a/src/entity.c b/src/entity.c index 1a9ac121..b93fa3a3 100644 --- a/src/entity.c +++ b/src/entity.c @@ -89,7 +89,7 @@ void SetEntityPriority(Entity* ent, u32 prio) { ent->updatePriority = prio; } -bool32 EntityIsDeleted(Entity* this) { +bool32 EntityDisabled(Entity* this) { u32 value; if (this->flags & ENT_DELETED) @@ -98,19 +98,19 @@ bool32 EntityIsDeleted(Entity* this) { return FALSE; // pick highest - if (gPriorityHandler.sys_priority > gPriorityHandler.ent_priority) - value = gPriorityHandler.sys_priority; + if (gPriorityHandler.event_priority > gPriorityHandler.ent_priority) + value = gPriorityHandler.event_priority; else value = gPriorityHandler.ent_priority; - if (gMessage.doTextBox & 0x7F) + if (gMessage.state & MESSAGE_ACTIVE) value = max(value, PRIO_MESSAGE); return value > this->updatePriority; } bool32 AnyPrioritySet(void) { - u32 prio = gPriorityHandler.sys_priority; - if (gPriorityHandler.sys_priority <= gPriorityHandler.ent_priority) + u32 prio = gPriorityHandler.event_priority; + if (gPriorityHandler.event_priority <= gPriorityHandler.ent_priority) prio = gPriorityHandler.ent_priority; return prio != PRIO_MIN; } @@ -180,12 +180,12 @@ static void UpdatePriorityTimer(void) { } void SetPlayerEventPriority(void) { - gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT; + gPriorityHandler.event_priority = PRIO_PLAYER_EVENT; gPlayerEntity.updatePriority = PRIO_PLAYER_EVENT; } void ResetPlayerEventPriority(void) { - gPriorityHandler.sys_priority = PRIO_MIN; + gPriorityHandler.event_priority = PRIO_MIN; gPlayerEntity.updatePriority = PRIO_PLAYER; } @@ -195,15 +195,15 @@ void RevokePriority(Entity* e) { } void SetRoomReloadPriority(void) { - gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT; + gPriorityHandler.event_priority = PRIO_PLAYER_EVENT; } void SetInitializationPriority(void) { - gPriorityHandler.sys_priority = PRIO_HIGHEST; + gPriorityHandler.event_priority = PRIO_HIGHEST; } -void ResetSystemPriority(void) { - gPriorityHandler.sys_priority = PRIO_MIN; +void ClearEventPriority(void) { + gPriorityHandler.event_priority = PRIO_MIN; } void UpdateEntities(void) { diff --git a/src/game.c b/src/game.c index e1a0822f..84b99bc8 100644 --- a/src/game.c +++ b/src/game.c @@ -208,7 +208,7 @@ static void GameMain_ChangeRoom(void) { return; UpdatePlayerMapCoords(); - ResetSystemPriority(); + ClearEventPriority(); UpdateWindcrests(); sub_080300C4(); gMain.substate = GAMEMAIN_UPDATE; @@ -252,8 +252,8 @@ static void GameMain_Update(void) { return; } - if ((gMessage.doTextBox & 0x7f) || gPriorityHandler.priority_timer != 0) - sub_08078B48(); + if ((gMessage.state & MESSAGE_ACTIVE) || gPriorityHandler.priority_timer != 0) + PausePlayer(); FlushSprites(); UpdateEntities(); @@ -305,7 +305,7 @@ static void GameMain_BarrelUpdate(void) { CheckGameOver(); CopyOAM(); if (!gFadeControl.active) - ResetSystemPriority(); + ClearEventPriority(); } static void GameMain_ChangeArea(void) { diff --git a/src/interrupts.c b/src/interrupts.c index 69a0f137..44b59a73 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -204,7 +204,7 @@ void PlayerUpdate(Entity* this) { else gPlayerState.flags &= ~PL_DRUGGED; - if (!EntityIsDeleted(this)) { + if (!EntityDisabled(this)) { if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) { PutAwayItems(); if (gPlayerState.flags & PL_MOLDWORM_RELEASED) { @@ -258,7 +258,7 @@ static void HandlePlayerLife(Entity* this) { return; } - if ((gPlayerState.controlMode != CONTROL_ENABLED) || (gMessage.doTextBox & 0x7f)) + if ((gPlayerState.controlMode != CONTROL_ENABLED) || (gMessage.state & 0x7f)) return; #ifdef EU @@ -274,7 +274,7 @@ static void HandlePlayerLife(Entity* this) { } } #else - gRoomVars.unk2 = gMessage.doTextBox & 0x7f; + gRoomVars.unk2 = gMessage.state & MESSAGE_ACTIVE; temp = gSave.stats.maxHealth / 4; if (temp > 24) temp = 24; diff --git a/src/manager.c b/src/manager.c index 338d2d7d..6c649a9c 100644 --- a/src/manager.c +++ b/src/manager.c @@ -61,6 +61,6 @@ void (*const gMiscManagerunctions[])() = { NULL, EnterRoomTextboxManager_Main }; void ManagerUpdate(Entity* this) { - if (!EntityIsDeleted(this)) + if (!EntityDisabled(this)) gMiscManagerunctions[this->id](this); } diff --git a/src/manager/enterRoomTextboxManager.c b/src/manager/enterRoomTextboxManager.c index a720a788..61276437 100644 --- a/src/manager/enterRoomTextboxManager.c +++ b/src/manager/enterRoomTextboxManager.c @@ -34,7 +34,7 @@ void sub_0805E1F8(u32, bool32); void EnterRoomTextboxManager_Main(EnterRoomTextboxManager* this) { EnterRoomTextboxManager_Actions[super->action](this); - if ((gRoomControls.room != this->unk_20) || (gMessage.doTextBox & 0x7F)) { + if ((gRoomControls.room != this->unk_20) || (gMessage.state & MESSAGE_ACTIVE)) { sub_0805E1D8(this); } } @@ -56,7 +56,7 @@ void sub_0805E18C(EnterRoomTextboxManager* this) { if (--super->subtimer == 0) { super->type2 = 0; gPlayerState.controlMode = CONTROL_1; - ResetSystemPriority(); + ClearEventPriority(); } } if (--super->timer == 0) { diff --git a/src/manager/entitySpawnManager.c b/src/manager/entitySpawnManager.c index 900b6480..6303d998 100644 --- a/src/manager/entitySpawnManager.c +++ b/src/manager/entitySpawnManager.c @@ -26,7 +26,7 @@ void EntitySpawnManager_Main(EntitySpawnManager* this) { if (super->type2 != 0) { super->type2 = 0; SetPlayerControl(0xff); - sub_08078B48(); + PausePlayer(); } if (this->spawnTimer == 0) { if (this->sound != 0) { diff --git a/src/manager/ezloHintManager.c b/src/manager/ezloHintManager.c index f98b97f3..4f6a2723 100644 --- a/src/manager/ezloHintManager.c +++ b/src/manager/ezloHintManager.c @@ -69,7 +69,7 @@ static void EzloHintManager_Action2(EzloHintManager* this) { if (!PlayerStateValid(this)) return; SetPlayerControl(3); - sub_08078B48(); + PausePlayer(); SetPlayerEventPriority(); super->action = 3; super->subAction = 0; diff --git a/src/manager/lightManager.c b/src/manager/lightManager.c index c8d8241d..c34c4755 100644 --- a/src/manager/lightManager.c +++ b/src/manager/lightManager.c @@ -20,8 +20,8 @@ extern void sub_0801E120(void); extern void sub_0801E154(u32); extern void sub_0801E160(u32, u32, u32); -bool32 sub_0805BA78(); -void sub_0805BAD4(); +bool32 LerpLightLevel(); +void UpdateLightAlpha(); void LightManager_Main(LightManager* this) { s32 sVar1; @@ -43,8 +43,8 @@ void LightManager_Main(LightManager* this) { } if (gMain.substate == GAMEMAIN_UPDATE) { gScreen.lcd.displayControl |= DISPCNT_BG3_ON; - sub_0805BA78(); - sub_0805BAD4(); + LerpLightLevel(); + UpdateLightAlpha(); } if (gArea.lightType == 2) { gScreen.lcd.displayControl &= ~DISPCNT_WIN0_ON; @@ -87,44 +87,33 @@ void LightManager_Main(LightManager* this) { #define ABS(x) ((unsigned)(x < 0 ? -(x) : x)) -bool32 sub_0805BA78() { - u32 uVar1; - s32 iVar1; - s32 iVar2; +bool32 LerpLightLevel() { + s32 tgt; + s32 cur; - iVar2 = (short)gArea.lightLevel; - iVar1 = gRoomVars.lightLevel; + cur = (short)gArea.lightLevel; + tgt = gRoomVars.lightLevel; - if (iVar1 < 0) { - iVar1 = 0; - } + tgt = max(tgt, 0); + tgt = min(tgt, 0x100); - if (0x100 < iVar1) { - iVar1 = 0x100; - } - - if (iVar2 != iVar1) { - if (ABS(iVar1 - iVar2) <= 4) { - iVar2 = iVar1; - } else { - if (iVar1 < iVar2) { - iVar2 = iVar2 - 4; - } else { - if (iVar1 > iVar2) { - iVar2 = iVar2 + 4; - } - } + if (cur != tgt) { + if (ABS(tgt - cur) <= 4) { + cur = tgt; + } else if (tgt < cur) { + cur -= 4; + } else if (tgt > cur) { + cur += 4; } - gArea.lightLevel = iVar2; - } else { - return FALSE; + gArea.lightLevel = cur; + return TRUE; } - return TRUE; + return FALSE; } extern u16 gUnk_08108CA8[]; -void sub_0805BAD4() { +void UpdateLightAlpha() { static const u16 gUnk_08108CA8[] = { 0x10, 0x10f, 0x20e, 0x30d, 0x40c, 0x50b, 0x60a, 0x709, 0x808, 0x907, 0xa06, 0xb05, 0xc04, 0xd03, 0xe02, 0xf01, 0x1000, 0x00 }; if (gArea.lightType != 0) { @@ -164,8 +153,8 @@ void sub_0805BB74(s32 lightLevel) { if (manager) { LightManager_Main(manager); gScreen.lcd.displayControl |= DISPCNT_BG3_ON; - sub_0805BA78(); - sub_0805BAD4(); + LerpLightLevel(); + UpdateLightAlpha(); } } @@ -175,9 +164,9 @@ bool32 UpdateLightLevel() { iVar1 = FALSE; if (gArea.lightType && gRoomVars.lightLevel < (s16)gArea.lightLevel) { gScreen.lcd.displayControl |= DISPCNT_BG3_ON; - iVar1 = sub_0805BA78(); + iVar1 = LerpLightLevel(); if (iVar1) { - sub_0805BAD4(); + UpdateLightAlpha(); } } return iVar1; @@ -189,9 +178,9 @@ s32 sub_0805BC04(void) { iVar1 = 0; if (gArea.lightType && gRoomVars.lightLevel > (short)gArea.lightLevel) { gScreen.lcd.displayControl |= DISPCNT_BG3_ON; - iVar1 = sub_0805BA78(); + iVar1 = LerpLightLevel(); if (iVar1) { - sub_0805BAD4(); + UpdateLightAlpha(); } } return iVar1; diff --git a/src/manager/vaati3StartManager.c b/src/manager/vaati3StartManager.c index 6d1c666d..c30c1e4b 100644 --- a/src/manager/vaati3StartManager.c +++ b/src/manager/vaati3StartManager.c @@ -70,7 +70,7 @@ void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) { super->subAction = 0; super->timer = 120; SetPlayerControl(2); - sub_08078B48(); + PausePlayer(); object = CreateObject(THUNDERBOLT, 0, 0); if (object != NULL) { object->x.HALF.HI = gRoomControls.origin_x + 0x88; @@ -100,7 +100,7 @@ void Vaati3StartManager_Type0_Action2(Vaati3StartManager* this) { } void Vaati3StartManager_Type0_Action3(Vaati3StartManager* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { if (super->timer != 0) { super->timer--; } else { diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index b41d3707..cfc0473a 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -331,7 +331,7 @@ void KinstoneMenu_Type5_Overlay0(void) { } void KinstoneMenu_Type5_Overlay1(void) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { gMenu.overlayType = 2; SoundReq(SFX_147); } diff --git a/src/message.c b/src/message.c index 165c58d1..87d6e461 100644 --- a/src/message.c +++ b/src/message.c @@ -49,7 +49,7 @@ static void StatusUpdate(u32 status); static void SwitchChoice(u32 to, u32 from); static void MsgChangeLine(u32 lineNo); -static void SetDoTextBox(u32 doTextbox); +static void SetState(u32 status); static void DeleteWindow(void); static u32 ChangeWindowSize(u32 delta); @@ -122,14 +122,14 @@ s32 sub_08056338(void) { s32 result; result = -1; - if (((gMessage.doTextBox & 0x7f) == 0) && (gUnk_02000040.unk_00 == 3)) + if (((gMessage.state & MESSAGE_ACTIVE) == 0) && (gUnk_02000040.unk_00 == 3)) result = gUnk_02000040.unk_01; return result; } void MessageClose(void) { - if ((gMessage.doTextBox & 0x7f) != 0) { - gMessage.doTextBox = 0x88; + if (gMessage.state & MESSAGE_ACTIVE) { + gMessage.state = 0x88; } } @@ -173,7 +173,7 @@ void MessageRequest(u32 index) { gMessage.textWindowHeight = 4; gMessage.textWindowPosX = 1; gMessage.textWindowPosY = 12; - gMessage.doTextBox = 1; + gMessage.state = 1; } void MessageInitialize(void) { @@ -190,7 +190,7 @@ void MessageMain(void) { [MSG_OPEN] = MsgOpen, [MSG_CLOSE] = MsgClose, [MSG_DIE] = MsgDie, }; - if (gMessage.doTextBox == 1) { + if (gMessage.state == 1) { MemClear((u32*)&gTextRender, sizeof(gTextRender)); StatusUpdate(MSG_INIT); } @@ -258,7 +258,7 @@ u32 MsgInit(void) { gTextRender.curToken._c = &gUnk_08107BE0; gTextRender._50.unk8 = gTextGfxBuffer; gTextRender._50.unk4 = 0xd0; - SetDoTextBox(2); + SetState(2); MsgChangeLine(0); StatusUpdate(MSG_UPDATE); return 1; @@ -295,7 +295,7 @@ static u32 MsgClose(void) { } static u32 MsgDie(void) { - SetDoTextBox(0); + SetState(0); StatusUpdate(MSG_IDLE); return 0; } @@ -306,7 +306,7 @@ static u32 MsgUpdate(void) { [RENDER_WAIT] = TextDispWait, [RENDER_ROLL] = TextDispRoll, [RENDER_ENQUIRY] = TextDispEnquiry, }; - SetDoTextBox(4); + SetState(4); gTextDispFunctions[gTextRender.renderStatus](&gTextRender); ChangeWindowSize(0); return 0; @@ -604,7 +604,7 @@ static void TextDispRoll(TextRender* this) { static void TextDispDie(TextRender* this) { gMessage.unk = 0; - SetDoTextBox(7); + SetState(7); if ((this->_8e != 1) && (this->_8e == 2 || MESSAGE_PRESS_ANY_ADVANCE_KEYS)) { StatusUpdate(MSG_CLOSE); } @@ -628,8 +628,8 @@ static void MsgChangeLine(u32 lineNo) { PaletteChange(&gTextRender, gTextRender._8f | 0x40); } -static void SetDoTextBox(u32 doTextbox) { - gMessage.doTextBox = gTextRender.message.doTextBox = doTextbox; +static void SetState(u32 status) { + gMessage.state = gTextRender.message.state = status; } static void DeleteWindow(void) { diff --git a/src/npc.c b/src/npc.c index 94896d5e..1609e901 100644 --- a/src/npc.c +++ b/src/npc.c @@ -14,7 +14,7 @@ void NPCUpdate(Entity* this) { DeleteThisEntity(); if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0) NPCInit(this); - if (!EntityIsDeleted(this)) + if (!EntityDisabled(this)) gNPCFunctions[this->id][0](this); if (this->next != NULL) { if (gNPCFunctions[this->id][1] != NULL) diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 38bcb381..07a3d0fc 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -94,7 +94,7 @@ void Beedle_Action1(Entity* this) { } void Beedle_Action2(Entity* this) { - if ((gMessage.doTextBox & 0x7F) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->action++; InitializeAnimation(this, 8); } diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 0767433b..ce6d1bab 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -266,7 +266,7 @@ void sub_0806D274(BigGoronEntity* this) { case 0: case 1: default: - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->frameIndex = 2; break; } diff --git a/src/npc/brocco.c b/src/npc/brocco.c index 9236bb60..ea14ac04 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -72,7 +72,7 @@ void sub_08063584(Entity* this) { } void sub_08063608(Entity* this) { - u8 tmp = gMessage.doTextBox & 0x7f; + u8 tmp = gMessage.state & MESSAGE_ACTIVE; if (tmp == 0) { this->action = 1; this->subtimer = tmp; diff --git a/src/npc/castleMaid.c b/src/npc/castleMaid.c index 2001f0d2..f5e888e3 100644 --- a/src/npc/castleMaid.c +++ b/src/npc/castleMaid.c @@ -99,7 +99,7 @@ void sub_08064570(CastleMaidEntity* this) { } break; case 2: - if ((gMessage.doTextBox & 0x7f) != 0) { + if ((gMessage.state & MESSAGE_ACTIVE) != 0) { return; } super->action = 1; diff --git a/src/npc/cat.c b/src/npc/cat.c index d2f42aec..eb364e8f 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -219,7 +219,7 @@ void sub_0806797C(CatEntity* this) { void sub_0806799C(CatEntity* this) { UpdateAnimationSingleFrame(super); - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { sub_08067B08(this); SetEntityPriority(super, PRIO_PLAYER); } diff --git a/src/npc/epona.c b/src/npc/epona.c index 91bfc6de..a852af99 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -54,7 +54,7 @@ void sub_08065A00(EponaEntity* this) { } void sub_08065A10(EponaEntity* this) { - if ((gMessage.doTextBox & 0x7F) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->action = 1; InitAnimationForceUpdate(super, super->animationState / 2); } diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index 9458205b..6628b572 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -162,7 +162,7 @@ void sub_08065D74(GhostBrothersEntity* this) { void sub_08065DB8(GhostBrothersEntity* this) { switch (super->subAction) { case 0: { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->subAction++; super->timer = 60; InitAnimationForceUpdate(super, 4); @@ -188,7 +188,7 @@ void sub_08065DB8(GhostBrothersEntity* this) { break; } case 4: { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->subAction++; super->timer = 30; this->unk_6c = gUnk_0811022E; diff --git a/src/npc/goron.c b/src/npc/goron.c index 6ed59d26..422fe6cc 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -72,7 +72,7 @@ void sub_08069328(Entity* this) { void sub_08069390(Entity* this) { UpdateAnimationSingleFrame(this); - if ((gMessage.doTextBox & 0x7F) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->action = 1; this->interactType = INTERACTION_NONE; RevokePriority(this); diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 24bb04e7..2f497dff 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -57,9 +57,9 @@ void sub_080695AC(Entity* this) { void sub_080695E8(Entity* this) { UpdateAnimationSingleFrame(this); - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->action = 1; - this->interactType = gMessage.doTextBox & 0x7f; + this->interactType = gMessage.state & MESSAGE_ACTIVE; RevokePriority(this); InitAnimationForceUpdate(this, this->animationState); } diff --git a/src/npc/guard.c b/src/npc/guard.c index cb1b7060..617d5d13 100644 --- a/src/npc/guard.c +++ b/src/npc/guard.c @@ -346,7 +346,7 @@ void sub_08063E54(Entity* this) { } void sub_08063E6C(Entity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->action = 1; InitializeAnimation(this, this->animationState + 4); } @@ -397,7 +397,7 @@ void sub_08063F20(GuardEntity* this) { } void sub_08063F78(GuardEntity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->action = super->action - 1; InitializeAnimation(super, (super->animationState >> 1) + 4 + this->unk_70); } diff --git a/src/npc/kid.c b/src/npc/kid.c index 957b4426..70e94ee3 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -319,7 +319,7 @@ void sub_080621AC(KidEntity* this) { break; case 2: GetNextFrame(super); - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->action = 1; } break; diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c index baf3e231..6f68a069 100644 --- a/src/npc/mountainMinish.c +++ b/src/npc/mountainMinish.c @@ -150,7 +150,7 @@ void sub_08067EF0(MountainMinishEntity* this) { } break; case 2: - if ((gMessage.doTextBox & 0x7f) != 0) + if ((gMessage.state & MESSAGE_ACTIVE) != 0) break; super->action = 1; InitializeAnimation(super, (super->animationState >> 1) + 4); diff --git a/src/npc/npc23.c b/src/npc/npc23.c index e3dab558..51ef213e 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -101,7 +101,7 @@ void sub_080663D4(NPC23Entity* this) { } ProcessMovement0(super); } - sub_08078B48(); + PausePlayer(); GetNextFrame(super); } diff --git a/src/npc/npc9.c b/src/npc/npc9.c index 6e66716b..71a45f04 100644 --- a/src/npc/npc9.c +++ b/src/npc/npc9.c @@ -51,7 +51,7 @@ void sub_08062B48(Entity* this) { } void sub_08062B70(Entity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { InitializeAnimation(this, 2); this->action = 1; RevokePriority(this); diff --git a/src/npc/percy.c b/src/npc/percy.c index 5c6108cd..c0d0eac2 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -149,13 +149,13 @@ void sub_0806B540(Entity* this) { SetLocalFlag(0x3f); break; case 1: - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { context->unk_18 = 2; MessageNoOverlap(TEXT_INDEX(TEXT_PERCY, 0x15), this); } break; case 2: - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { context->unk_18 = 3; if (gSave.stats.hasAllFigurines != 0) { InitItemGetSequence(ITEM_RUPEE100, 0, 0); diff --git a/src/npc/pina.c b/src/npc/pina.c index cb73eabc..a7a2448d 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -74,7 +74,7 @@ void sub_08063AC0(Entity* this) { } void sub_08063B44(Entity* this) { - u8 tmp = gMessage.doTextBox & 0x7f; + u8 tmp = gMessage.state & MESSAGE_ACTIVE; if (tmp == 0) { this->action = 1; this->subtimer = tmp; diff --git a/src/npc/postman.c b/src/npc/postman.c index 12711abc..1ae6aa81 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -273,7 +273,7 @@ void sub_08060528(PostmanEntity* this) { break; case 2: UpdateAnimationSingleFrame(super); - if ((gMessage.doTextBox & 0x7f) != 0) { + if ((gMessage.state & MESSAGE_ACTIVE) != 0) { break; } super->action = 1; diff --git a/src/npc/stamp.c b/src/npc/stamp.c index 380e5be4..59322c18 100644 --- a/src/npc/stamp.c +++ b/src/npc/stamp.c @@ -64,7 +64,7 @@ void sub_08062C24(Entity* this) { } void sub_08062C54(Entity* this) { - if ((gMessage.doTextBox & 127) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->action = 1; InitializeAnimation(this, 0); RevokePriority(this); diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index 68d63b46..2c9dbe00 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -108,8 +108,8 @@ void sub_080650CC(StockwellEntity* this) { void sub_080651AC(StockwellEntity* this) { GetNextFrame(super); - if ((gMessage.doTextBox & 0x7f) == 0) { - super->interactType = gMessage.doTextBox & 0x7f; + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { + super->interactType = gMessage.state & MESSAGE_ACTIVE; super->action = 1; InitializeAnimation(super, 4); } @@ -164,7 +164,7 @@ void sub_0806528C(Entity* this) { } void sub_080652B0(Entity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->subAction++; this->timer = 10; gRoomVars.animFlags = this->subtimer; @@ -184,16 +184,16 @@ void sub_080652E4(Entity* this) { } void sub_08065314(Entity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->subAction++; MenuFadeIn(3, 3); } } void sub_08065338(Entity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->action = 1; - this->subAction = gMessage.doTextBox & 0x7f; + this->subAction = gMessage.state & MESSAGE_ACTIVE; gRoomVars.animFlags = this->subtimer; InitializeAnimation(this, 4); } diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c index 6367bf76..4ba1906e 100644 --- a/src/npc/sturgeon.c +++ b/src/npc/sturgeon.c @@ -127,7 +127,7 @@ void sub_08064B88(SturgeonEntity* this) { } void sub_08064C2C(SturgeonEntity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->action = 1; InitializeAnimation(super, (u32)super->subtimer); } diff --git a/src/npc/talon.c b/src/npc/talon.c index 4b62dd22..7a93007e 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -119,7 +119,7 @@ void sub_08065680(TalonEntity* this) { } void sub_080656A4(TalonEntity* this) { - if ((gMessage.doTextBox & 0x7F) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->action = this->unk_69; InitAnimationForceUpdate(super, this->unk_6a); } diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index d818f4fa..e8914c76 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -250,7 +250,7 @@ void sub_0806ACC4(TownMinishEntity* this) { } break; case 2: - if (gMessage.doTextBox & 0x7f) + if (gMessage.state & MESSAGE_ACTIVE) break; super->action = 1; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 9feb45ea..593c3160 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -153,7 +153,7 @@ void sub_08061D64(TownspersonEntity* this) { void sub_08061E24(TownspersonEntity* this) { GetNextFrame(super); - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { super->action = 1; InitializeAnimation(super, this->unk_69); } diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c index 41eb3567..ef37526f 100644 --- a/src/npc/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -78,7 +78,7 @@ void sub_0806C7D4(Entity* this) { } void sub_0806C834(Entity* this) { - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { --this->action; InitializeAnimation(this, (this->animationState / 2) + 4); } diff --git a/src/object.c b/src/object.c index 58806614..8f23887e 100644 --- a/src/object.c +++ b/src/object.c @@ -205,7 +205,7 @@ void ObjectUpdate(Entity* this) { ObjectInit(this); if (this->iframes != 0) this->iframes++; - if (!EntityIsDeleted(this)) { + if (!EntityDisabled(this)) { gObjectFunctions[this->id](this); this->contactFlags &= ~0x80; } diff --git a/src/object/bird.c b/src/object/bird.c index 2b4b0dac..485c0695 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -225,7 +225,7 @@ void Bird_Type8(BirdEntity* this) { super->speed = 0x300; } - if ((gPlayerEntity.flags & ENT_COLLIDE) && (gMessage.doTextBox & 0x7f) == 0 && + if ((gPlayerEntity.flags & ENT_COLLIDE) && (gMessage.state & MESSAGE_ACTIVE) == 0 && gPlayerEntity.action != PLAYER_SLEEP && gPlayerEntity.action != PLAYER_BOUNCE && gPlayerEntity.action != PLAYER_MINISH && gPlayerState.framestate != PL_STATE_CLIMB && gPlayerState.framestate != PL_STATE_JUMP && gPlayerState.framestate != PL_STATE_PARACHUTE && @@ -240,21 +240,21 @@ void Bird_Type8(BirdEntity* this) { super->speed = 0x300; this->gravity = Q_8_8(-32.0); PlayerDropHeldObject(); - sub_08078B48(); + PausePlayer(); ResetPlayerAnimationAndAction(); PutAwayItems(); gPlayerState.swim_state = 0; gPlayerState.jump_status = 0; gPlayerEntity.flags &= ~0x80; gPlayerEntity.spriteSettings.draw = 0; - gPriorityHandler.sys_priority = 6; + gPriorityHandler.event_priority = 6; gPauseMenuOptions.disabled = 1; } } } break; default: - sub_08078B48(); + PausePlayer(); gPlayerEntity.spriteSettings.draw = 0; break; } @@ -313,7 +313,7 @@ void Bird_Type9(BirdEntity* this) { SoundReq(SFX_123); super->spritePriority.b1 = 2; InitAnimationForceUpdate(super, 0); - sub_08078B48(); + PausePlayer(); } else if (super->action == 1) { gPlayerEntity.spriteSettings.draw = 0; child = super->child; @@ -324,7 +324,7 @@ void Bird_Type9(BirdEntity* this) { child->spriteRendering.b3 = super->spriteRendering.b3; child->spriteOrientation.flipY = super->spriteOrientation.flipY; } - sub_08078B48(); + PausePlayer(); if (gRoomControls.scroll_x + 0x78 < super->x.HALF.HI) { super->action++; super->spritePriority.b1 = 1; diff --git a/src/object/book.c b/src/object/book.c index 36f76c6a..4ebd3f7d 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -208,10 +208,10 @@ void Book_Action5(BookEntity* this) { break; } case 1: { - u8 doTextBox = gMessage.doTextBox & 0x7f; - if (!doTextBox) { + u8 status = gMessage.state & MESSAGE_ACTIVE; + if (!status) { super->spriteSettings.draw = 1; - super->subAction = doTextBox; + super->subAction = status; } break; } diff --git a/src/object/bush.c b/src/object/bush.c index e12d3883..857e63f7 100644 --- a/src/object/bush.c +++ b/src/object/bush.c @@ -38,7 +38,7 @@ void Bush(BushEntity* this) { Bush_Action1, Bush_Action2, }; - if (!EntityIsDeleted(super)) { + if (!EntityDisabled(super)) { Bush_Actions[super->action](this); } } diff --git a/src/object/cameraTarget.c b/src/object/cameraTarget.c index e19d0499..e21b2f7d 100644 --- a/src/object/cameraTarget.c +++ b/src/object/cameraTarget.c @@ -53,7 +53,7 @@ void CameraTarget(Entity* this) { case FUSION_STATE_0: case FUSION_STATE_1: case FUSION_STATE_2: - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { break; } default: diff --git a/src/object/cloud.c b/src/object/cloud.c index 1252aca6..9f99213d 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -104,7 +104,7 @@ void sub_0809F5F0(CloudEntity* this) { super->action = 2; super->timer = 120; SetPlayerControl(3); - sub_08078B48(); + PausePlayer(); gRoomControls.camera_target = super; } } diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index 74db801c..7480ba07 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -266,7 +266,7 @@ void CrenelBeanSprout_Action6(CrenelBeanSproutEntity* this) { CrenelBeanSprout_Action6SubAction2, }; if (super->subAction != 2) { - sub_08078B48(); + PausePlayer(); } CrenelBeanSprout_Action6SubActions[super->subAction](this); } diff --git a/src/object/cutsceneMiscObject.c b/src/object/cutsceneMiscObject.c index 00fdc5e7..44fc603f 100644 --- a/src/object/cutsceneMiscObject.c +++ b/src/object/cutsceneMiscObject.c @@ -457,7 +457,7 @@ void CutsceneMiscObject_Type7(CutsceneMiscObjectEntity* this) { } break; case 2: - if ((gMessage.doTextBox & 0x7F) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { CreateItemEntity(ITEM_JABBERNUT, 0, 0); DeleteThisEntity(); } diff --git a/src/object/ezloCap.c b/src/object/ezloCap.c index 6465dad9..4c7f39bb 100644 --- a/src/object/ezloCap.c +++ b/src/object/ezloCap.c @@ -81,11 +81,11 @@ void EzloCap_Type0Action1(EzloCapEntity* this) { static const u8 gUnk_0811F16C[] = { 4, 0, 2, 6, 10, 8, 9, 5, 1, 0, 0, 0 }; u32 tmp = gPlayerEntity.palette.b.b0; super->palette.b.b0 = tmp; - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { DeleteEntity(super); return; } - if ((gMessage.doTextBox & 0x7f) != 5) { + if ((gMessage.state & MESSAGE_ACTIVE) != 5) { if (((gMessage.unk == 0xa) || (gMessage.unk == 0)) || ((gMessage.unk & 0xf) > 9)) { if (super->animIndex != (super->subtimer | 3)) { InitAnimationForceUpdate(super, super->subtimer | 3); diff --git a/src/object/fourElements.c b/src/object/fourElements.c index 1c3942ea..bb99e701 100644 --- a/src/object/fourElements.c +++ b/src/object/fourElements.c @@ -138,7 +138,7 @@ void FourElements_Action5(FourElementsEntity* this) { void FourElements_Action6(FourElementsEntity* this) { RequestPriorityDuration(NULL, 10); - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { SetPriorityTimer(90); gPlayerState.controlMode = 1; EnablePauseMenu(); diff --git a/src/object/frozenOctorok.c b/src/object/frozenOctorok.c index 540a85dd..089436dc 100644 --- a/src/object/frozenOctorok.c +++ b/src/object/frozenOctorok.c @@ -267,7 +267,7 @@ void FrozenOctorok_Action1SubAction0(FrozenOctorokEntity* this) { void FrozenOctorok_Action1SubAction1(FrozenOctorokEntity* this) { Entity* obj; - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { if (this->unk_79-- == 0) { obj = CreateObjectWithParent(super, FROZEN_OCTOROK, 7, 0); if (obj != NULL) { diff --git a/src/object/gleerokParticle.c b/src/object/gleerokParticle.c index 5595ccda..67efcb36 100644 --- a/src/object/gleerokParticle.c +++ b/src/object/gleerokParticle.c @@ -82,7 +82,7 @@ void GleerokParticle_Init(GleerokParticleEntity* this) { DeleteThisEntity(); } } - sub_08078B48(); + PausePlayer(); return; case 0: super->direction = gUnk_081229D0[super->type2].direction; diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index 9a87f5c6..0106fb63 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -96,7 +96,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) { if (super->interactType != INTERACTION_NONE) { super->interactType = INTERACTION_NONE; super->subAction = 1; - sub_08078B48(); + PausePlayer(); ResetActiveItems(); gPlayerState.heldObject = 4; gNewPlayerEntity.unk_74 = super; diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index 5c1e9949..5571ca47 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -325,7 +325,7 @@ void LilypadLarge_Action2(LilypadLargeEntity* this) { }; subActionFuncs[super->subAction](this); gPlayerState.flags |= PL_FLAGS2; - sub_08078B48(); + PausePlayer(); } void sub_08085A44(LilypadLargeEntity* this) { @@ -460,7 +460,7 @@ void sub_08085D28(LilypadLargeEntity* this) { (GetRelativeCollisionTile(super, 0, 0x18) == 0x11)) { super->action = 2; super->subAction = 0; - sub_08078B48(); + PausePlayer(); } } diff --git a/src/object/linkAnimation.c b/src/object/linkAnimation.c index c811373c..5f790559 100644 --- a/src/object/linkAnimation.c +++ b/src/object/linkAnimation.c @@ -93,7 +93,7 @@ void LinkAnimation_ItemGet(LinkAnimationEntity* this) { break; case ITEMGET_WAIT: UpdateAnimationSingleFrame(super); - if ((gMessage.doTextBox & 0x7f) != 0) { + if ((gMessage.state & MESSAGE_ACTIVE) != 0) { return; } if (super->frame & ANIM_DONE) { diff --git a/src/object/moleMittsParticle.c b/src/object/moleMittsParticle.c index 93a0379c..02f3e72e 100644 --- a/src/object/moleMittsParticle.c +++ b/src/object/moleMittsParticle.c @@ -18,7 +18,7 @@ void MoleMittsParticle(Entity* this) { MoleMittsParticle_Init, MoleMittsParticle_Action1, }; - if (!EntityIsDeleted(this)) { + if (!EntityDisabled(this)) { MoleMittsParticle_Actions[this->action](this); } } diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index 4619d170..1410d0d1 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -316,7 +316,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) { } break; case 9: - sub_08078B48(); + PausePlayer(); if ((this->unk_78.WORD_U)-- == 0) { gRoomControls.camera_target = &gPlayerEntity; DeleteThisEntity(); diff --git a/src/object/well.c b/src/object/well.c index 8b26a476..ed033493 100644 --- a/src/object/well.c +++ b/src/object/well.c @@ -40,7 +40,7 @@ void Well_Init(WellEntity* this) { void Well_Action1(WellEntity* this) { u32 tileIndex = GetTileType(this->unk_80, 1); if (tileIndex != 0x407D) { - sub_08078B48(); + PausePlayer(); gPlayerEntity.x.WORD = super->x.WORD; gPlayerEntity.y.HALF.HI = super->y.HALF.HI + 4; DeleteThisEntity(); diff --git a/src/object/windTribeTeleporter.c b/src/object/windTribeTeleporter.c index 997a91d0..fd785ab9 100644 --- a/src/object/windTribeTeleporter.c +++ b/src/object/windTribeTeleporter.c @@ -21,7 +21,7 @@ void WindTribeTeleporter_Action1(WindTribeTeleporterEntity*); void WindTribeTeleporter_Action2(WindTribeTeleporterEntity*); void WindTribeTeleporter_Action3(WindTribeTeleporterEntity*); void sub_080A11E0(WindTribeTeleporterEntity*); -bool32 sub_080A11C0(WindTribeTeleporterEntity*); +static bool32 PlayerCollidingTeleporter(WindTribeTeleporterEntity*); void WindTribeTeleporter(WindTribeTeleporterEntity* this) { static void (*const WindTribeTeleporter_Actions[])(WindTribeTeleporterEntity*) = { @@ -40,11 +40,11 @@ void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) { super->spritePriority.b0 = 7; super->hitbox = (Hitbox*)&gHitbox_22; SetEntityPriority(super, 6); - if (sub_080A11C0(this)) { + if (PlayerCollidingTeleporter(this)) { gPlayerEntity.x.HALF.HI = super->x.HALF.HI; gPlayerEntity.y.HALF.HI = super->y.HALF.HI; SetPlayerControl(CONTROL_DISABLED); - sub_08078B48(); + PausePlayer(); SetPlayerEventPriority(); SoundReq(SFX_112); super->action = 3; @@ -54,12 +54,12 @@ void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) { } void WindTribeTeleporter_Action1(WindTribeTeleporterEntity* this) { - if (sub_080A11C0(this)) { + if (PlayerCollidingTeleporter(this)) { if (this->unk_68 == 0) { gPlayerEntity.x.HALF.HI = super->x.HALF.HI; gPlayerEntity.y.HALF.HI = super->y.HALF.HI; SetPlayerControl(CONTROL_DISABLED); - sub_08078B48(); + PausePlayer(); SetPlayerEventPriority(); SoundReq(SFX_112); super->action = 2; @@ -177,7 +177,7 @@ void WindTribeTeleporter_Action3(WindTribeTeleporterEntity* this) { } } -bool32 sub_080A11C0(WindTribeTeleporterEntity* this) { +static bool32 PlayerCollidingTeleporter(WindTribeTeleporterEntity* this) { if (gPlayerEntity.z.HALF.HI != 0) { return FALSE; } else { diff --git a/src/objectUtils.c b/src/objectUtils.c index 254be88f..e3db7806 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -42,7 +42,7 @@ Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) { AppendEntityToList(e, 6); PrependEntityToList(e, 6); CopyPosition(&gPlayerEntity, e); - gPriorityHandler.sys_priority = 6; + gPriorityHandler.event_priority = 6; gPauseMenuOptions.disabled = 1; // store player state diff --git a/src/player.c b/src/player.c index 90a10af1..bb2b14f9 100644 --- a/src/player.c +++ b/src/player.c @@ -280,7 +280,7 @@ extern ScriptExecutionContext gPlayerScriptExecutionContext; bool32 CheckInitPauseMenu(void) { u32 framestate; if (((gInput.newKeys & START_BUTTON) == 0 || gFadeControl.active || gPauseMenuOptions.disabled || - (gMessage.doTextBox & 0x7F) || gSave.stats.health == 0 || !gSave.inventory[0] || + (gMessage.state & MESSAGE_ACTIVE) || gSave.stats.health == 0 || !gSave.inventory[0] || gPlayerState.controlMode != 0 || gPriorityHandler.priority_timer != 0)) { return FALSE; } @@ -728,7 +728,7 @@ static void sub_08070E9C(Entity* this) { static void sub_08070EDC(Entity* this) { this->updatePriority = PRIO_MESSAGE; - if ((gMessage.doTextBox & 0x7f) != 0) + if (gMessage.state & MESSAGE_ACTIVE) this->subAction = 1; if ((gPlayerState.flags & PL_MINISH) == 0) @@ -739,7 +739,7 @@ static void sub_08070EDC(Entity* this) { static void sub_08070f24(Entity* this) { UpdateAnimationSingleFrame(this); - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->updatePriority = this->updatePriorityPrev; ResetPlayerAnimationAndAction(); } @@ -808,7 +808,7 @@ static void sub_08071038(Entity* this) { UpdateAnimationSingleFrame(this); // player is still reading message - if (CheckQueuedAction() || (gMessage.doTextBox & 0x7f)) + if (CheckQueuedAction() || (gMessage.state & MESSAGE_ACTIVE)) return; if (this->frame & ANIM_DONE) { @@ -1286,7 +1286,7 @@ static void PlayerTalkEzlo_Init(Entity* this) { ResetActiveItems(); gActiveItems[ACTIVE_ITEM_LANTERN].animPriority = 0; this->iframes = 0; - gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT; + gPriorityHandler.event_priority = PRIO_PLAYER_EVENT; this->updatePriority = PRIO_PLAYER_EVENT; if (gPlayerState.flags & PL_MINISH) { @@ -1335,7 +1335,7 @@ static void PlayerTalkEzlo_CreateMessage(Entity* this) { static void PlayerTalkEzlo_MessageIdle(Entity* this) { u32 rightOrLeft; - if ((gMessage.doTextBox & 0x7f) == 0) { + if ((gMessage.state & MESSAGE_ACTIVE) == 0) { this->subAction++; if ((gPlayerState.flags & PL_MINISH) == 0) { if (this->animationState == IdleEast) @@ -1380,7 +1380,7 @@ static void PlayerTalkEzlo_Leave(Entity* this) { } static void reset_priority(void) { - gPriorityHandler.sys_priority = PRIO_MIN; + gPriorityHandler.event_priority = PRIO_MIN; gPlayerEntity.updatePriority = gPlayerEntity.updatePriorityPrev; } diff --git a/src/playerItem.c b/src/playerItem.c index f6fbd5bf..69b1557e 100644 --- a/src/playerItem.c +++ b/src/playerItem.c @@ -72,7 +72,7 @@ void ItemUpdate(Entity* this) { if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0 && this->subAction == 0) ItemInit(this); - if (!EntityIsDeleted(this)) { + if (!EntityDisabled(this)) { gPlayerItemFunctions[this->id](this); this->contactFlags &= ~0x80; if (this->iframes != 0) { diff --git a/src/playerUtils.c b/src/playerUtils.c index c987c761..2cd630f7 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -988,7 +988,7 @@ bool32 sub_08078140(ChargeState* info) { void ForceSetPlayerState(u32 framestate) { gPlayerState.framestate = framestate; gPlayerEntity.flags &= ~ENT_COLLIDE; - sub_08078B48(); + PausePlayer(); } void DetermineRButtonInteraction(void) { @@ -1504,7 +1504,7 @@ void SetPlayerItemGetState(Entity* item, u8 param_2, u8 param_3) { DeleteClones(); } -void sub_08078B48(void) { +void PausePlayer(void) { gPlayerState.field_0x7 |= 0x80; gPlayerState.keepFacing |= 0x80; gPlayerState.field_0xa |= 0x80; @@ -2494,7 +2494,7 @@ u32 sub_08079FD4(Entity* this, u32 param_2) { void UpdatePlayerPalette(void) { u32 palette; - if ((gPlayerState.hurtBlinkSpeed != 0) && ((gMessage.doTextBox & 0x7f) == 0)) { + if ((gPlayerState.hurtBlinkSpeed != 0) && ((gMessage.state & MESSAGE_ACTIVE) == 0)) { gPlayerState.hurtBlinkSpeed--; } palette = GetPlayerPalette(FALSE); diff --git a/src/script.c b/src/script.c index 8216a438..278ad227 100644 --- a/src/script.c +++ b/src/script.c @@ -1054,7 +1054,7 @@ void ScriptCommand_0807E858(Entity* entity, ScriptExecutionContext* context) { void ScriptCommand_SetPlayerIdle(Entity* entity, ScriptExecutionContext* context) { gPlayerState.controlMode = CONTROL_DISABLED; - sub_08078B48(); + PausePlayer(); } void ScriptCommand_EnablePlayerControl(Entity* entity, ScriptExecutionContext* context) { @@ -1129,7 +1129,7 @@ void ScriptCommand_0807E974(Entity* entity, ScriptExecutionContext* context) { MessageFromTarget(context->scriptInstructionPointer[1]); break; case 1: - if (gMessage.doTextBox & 0x7F) + if (gMessage.state & MESSAGE_ACTIVE) break; context->unk_18 = 2; context->unk_19 = 0xF; @@ -1191,7 +1191,7 @@ void ScriptCommand_AddInteractableFuser(Entity* entity, ScriptExecutionContext* } void ScriptCommand_WaitUntilTextboxCloses(Entity* entity, ScriptExecutionContext* context) { - if (gMessage.doTextBox & 0x7F) { + if (gMessage.state & MESSAGE_ACTIVE) { gActiveScriptInfo.commandSize = 0; } } diff --git a/src/scroll.c b/src/scroll.c index abb3c136..25c20cd6 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -268,7 +268,7 @@ void sub_0807FF1C(RoomControls* controls) { gUpdateVisibleTiles = 3; if (++controls->unk_18 > 0x13) { controls->scrollAction = 0; - ResetSystemPriority(); + ClearEventPriority(); } } } @@ -408,7 +408,7 @@ void sub_080801BC(RoomControls* controls) { if (controls->unk_1c == 0) { controls->scrollAction = 0; controls->reload_flags = 0; - ResetSystemPriority(); + ClearEventPriority(); gScreen.lcd.displayControl &= ~DISPCNT_WIN1_ON; gScreen.controls.windowInsideControl &= 0xff; gScreen.controls.windowOutsideControl &= 0xff00; diff --git a/src/staffroll.c b/src/staffroll.c index a2df531f..dcd0fad7 100644 --- a/src/staffroll.c +++ b/src/staffroll.c @@ -93,7 +93,7 @@ void StaffrollTask_State0(void) { gScreen.bg1.control = 0x1e4d; gScreen.bg2.control = 0x1dc3; InitSoundPlayingInfo(); - ResetSystemPriority(); + ClearEventPriority(); SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100); } diff --git a/src/subtask.c b/src/subtask.c index e801bade..ab9a4500 100644 --- a/src/subtask.c +++ b/src/subtask.c @@ -278,7 +278,7 @@ void Subtask_Die(void) { gMain.substate = gUI.pauseFadeIn; gUI.nextToLoad = gFadeControl.active; gUI.lastState = gFadeControl.active; - ResetSystemPriority(); + ClearEventPriority(); } } diff --git a/src/ui.c b/src/ui.c index 1bff0dae..95a10ef4 100644 --- a/src/ui.c +++ b/src/ui.c @@ -626,7 +626,7 @@ void ButtonUIElement_Action1(UIElement* element) { MAX_MOVEMENT = (!element->type2) ? 4 : 8; - if (element->type2 == 0 && (((gUnk_0200AF00.unk_1 >> element->type) & 1) || (gMessage.doTextBox & 0x7f) != 0)) { + if (element->type2 == 0 && (((gUnk_0200AF00.unk_1 >> element->type) & 1) || (gMessage.state & MESSAGE_ACTIVE) != 0)) { y = (s16)gUnk_0200AF00.buttonY[element->type] - 0x28; } else { y = (s16)gUnk_0200AF00.buttonY[element->type]; @@ -792,7 +792,7 @@ void HeartUIElement(UIElement* element) { u32 health; u32 frameIndex; element->unk_0_1 = 0; - if (((gUnk_0200AF00.unk_1 & 0x10) == 0) && ((gMessage.doTextBox & 0x7f) == 0)) { + if (((gUnk_0200AF00.unk_1 & 0x10) == 0) && ((gMessage.state & MESSAGE_ACTIVE) == 0)) { health = gUnk_0200AF00.health; if (health != 0) { element->unk_0_1 = 1; @@ -845,7 +845,7 @@ void EzloNagUIElement_Action1(UIElement* element) { } void EzloNagUIElement_Action2(UIElement* element) { - if (gUnk_0200AF00.ezloNagFuncIndex >= 5 || (gMessage.doTextBox & 0x7f)) { + if (gUnk_0200AF00.ezloNagFuncIndex >= 5 || (gMessage.state & MESSAGE_ACTIVE)) { element->action = 0; element->unk_0_1 = 0; return; From 72509b18a0406f93b6ffc59904cc2c09c0adbf80 Mon Sep 17 00:00:00 2001 From: theo3 Date: Fri, 29 Dec 2023 00:56:36 -0800 Subject: [PATCH 6/6] label some asm functions --- asm/src/code_08000F10.s | 48 +++++++++++++++++++------------------ include/entity.h | 25 +++++++++++-------- include/structures.h | 2 +- linker.ld | 4 ++-- src/enemy/acroBandits.c | 2 +- src/enemy/fireballGuy.c | 2 +- src/enemy/slime.c | 2 +- src/entity.c | 36 ++++++++++++++-------------- src/itemUtils.c | 8 +++---- src/object/gentariCurtain.c | 2 +- src/objectUtils.c | 2 +- src/playerItemUtils.c | 2 +- src/playerUtils.c | 4 ++-- src/ui.c | 3 ++- 14 files changed, 75 insertions(+), 67 deletions(-) diff --git a/asm/src/code_08000F10.s b/asm/src/code_08000F10.s index e7ce35aa..7ecc84d5 100644 --- a/asm/src/code_08000F10.s +++ b/asm/src/code_08000F10.s @@ -10,41 +10,43 @@ CheckBits: @ 0x08000F10 ldr r3, _08000F50 @ =ram_CheckBits bx r3 - thumb_func_start sub_08000F14 -sub_08000F14: @ 0x08000F14 + // sum 3 drop probability vectors + thumb_func_start SumDropProbabilities +SumDropProbabilities: @ 0x08000F14 push {r4, r5, r6} - movs r4, #0x1e + movs r4, #30 // vector addition for 16 shorts in reverse _08000F18: - ldrsh r5, [r1, r4] - ldrsh r6, [r2, r4] - adds r5, r5, r6 - ldrsh r6, [r3, r4] - adds r5, r5, r6 - strh r5, [r0, r4] + ldrsh r5, [r1, r4] // row 1 + ldrsh r6, [r2, r4] // + row 2 + adds r5, r6 + ldrsh r6, [r3, r4] // + row 3 + adds r5, r6 + strh r5, [r0, r4] // store in output subs r4, #2 bpl _08000F18 pop {r4, r5, r6} bx lr - thumb_func_start sub_08000F2C -sub_08000F2C: @ 0x08000F2C + // sum 3 drop probabilities, clamp to 0, return scalar sum + thumb_func_start SumDropProbabilities2 +SumDropProbabilities2: @ 0x08000F2C push {r4, r5, r6, r7} - movs r4, #0x1e - movs r7, #0 + movs r4, #30 + movs r7, #0 // sum _08000F32: - ldrsh r5, [r1, r4] - ldrsh r6, [r2, r4] - adds r5, r5, r6 - ldrsh r6, [r3, r4] - adds r5, r5, r6 - bpl _08000F40 + ldrsh r5, [r1, r4] // row 1 + ldrsh r6, [r2, r4] // + row 2 + adds r5, r6 + ldrsh r6, [r3, r4] // + row 3 + adds r5, r6 + bpl positive_drop_chance // clamp to 0 movs r5, #0 -_08000F40: - strh r5, [r0, r4] - adds r7, r7, r5 +positive_drop_chance: + strh r5, [r0, r4] // store in output + adds r7, r5 subs r4, #2 bpl _08000F32 - adds r0, r7, #0 + adds r0, r7, #0 // return sum pop {r4, r5, r6, r7} bx lr .align 2, 0 diff --git a/include/entity.h b/include/entity.h index 5b5c328d..067e9ff4 100644 --- a/include/entity.h +++ b/include/entity.h @@ -6,7 +6,9 @@ #include "color.h" #include "sprite.h" -#define MAX_ENTITIES 71 +#define MAX_ENTITIES 72 +#define MAX_MANAGERS 32 +#define MAX_AUX_PLAYER_ENTITIES 7 /** Kinds of Entity's supported by the game. */ typedef enum { @@ -38,6 +40,8 @@ typedef enum { typedef enum { ENT_DID_INIT = 0x1, /**< Graphics and other data loaded. */ ENT_SCRIPTED = 0x2, /**< Execute in a scripted environment. */ + ENT_UNUSED1 = 0x4, /**< Unused delete flag. */ + ENT_UNUSED2 = 0x8, /**< Unused delete flag. */ ENT_DELETED = 0x10, /**< Queue deletion next frame. */ ENT_PERSIST = 0x20, /**< Persist between rooms. */ ENT_COLLIDE = 0x80, /**< Collide with other Entity's. */ @@ -238,6 +242,15 @@ typedef struct LinkedList { Entity* first; } LinkedList; +/** + * LinkedList's which point to allocate Entities. + * These work together with Entity.prev and Entity.next fields + * to allow the iteration of all Entity's. + */ +extern LinkedList gEntityLists[9]; +extern Entity gAuxPlayerEntities[MAX_AUX_PLAYER_ENTITIES]; +extern Entity gEntities[MAX_ENTITIES]; + typedef void(EntityAction)(Entity*); typedef void (*EntityActionPtr)(Entity*); typedef void (*const* EntityActionArray)(Entity*); @@ -283,7 +296,7 @@ Entity* CreateEnemy(u32 id, u32 type); Entity* CreateNPC(u32 id, u32 type, u32 type2); Entity* CreateObject(u32 id, u32 type, u32 type2); Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2); -Entity* CreateItemGetEntity(void); +Entity* CreateAuxPlayerEntity(void); Entity* CreateFx(Entity* parent, u32 type, u32 type2); /// @} @@ -484,14 +497,6 @@ void ClearEventPriority(void); void sub_0805E958(void); -/** - * LinkedList's which point to allocate Entities. - * These work together with Entity.prev and Entity.next fields - * to allow the iteration of all Entity's. - */ -extern LinkedList gEntityLists[9]; -extern Entity gItemGetEntities[7]; - typedef struct { u8 unk_0; u8 unk_1; diff --git a/include/structures.h b/include/structures.h index 6125cba9..f4dc51cd 100644 --- a/include/structures.h +++ b/include/structures.h @@ -192,7 +192,7 @@ static_assert(sizeof(gActiveItems) == 0x70); typedef struct { u8 event_priority; // system requested priority - u8 ent_priority; // entity requested priority + u8 ent_priority; // entity requested priority u8 queued_priority; u8 queued_priority_reset; Entity* requester; diff --git a/linker.ld b/linker.ld index dbfc5c3c..18f9d27d 100644 --- a/linker.ld +++ b/linker.ld @@ -132,8 +132,8 @@ SECTIONS { . = 0x000010A0; gRoomTransition = .; . = 0x00001150; gRand = .; . = 0x00001160; gPlayerEntity = .; - . = 0x000011E8; gItemGetEntities = .; - . = 0x000015A0; gUnk_030015A0 = .; + . = 0x000011E8; gAuxPlayerEntities = .; + . = 0x000015A0; gEntities = .; . = 0x00003BE0; gCarriedEntity = .; . = 0x00003C70; gUnk_03003C70 = .; . = 0x00003D70; gEntityLists = .; diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index aeeed7f6..58457d1d 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -240,7 +240,7 @@ void AcroBandit_Type0Action5(Entity* this) { GetNextFrame(this); if (this->frame & ANIM_DONE) { - if (gEntCount < MAX_ENTITIES - 4) { + if (gEntCount < MAX_ENTITIES - 5) { u32 tmp = Random(); tmp &= 3; diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index 3eb404a1..0aeaf781 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -81,7 +81,7 @@ void FireballGuy_Action2(Entity* this) { /* Can we create enough new entities? */ count = typeEntityCount[this->type]; - if (MAX_ENTITIES + 1 - count <= gEntCount) + if (MAX_ENTITIES - count <= gEntCount) return; /* Create 2-5 new MiniFireballGuy */ diff --git a/src/enemy/slime.c b/src/enemy/slime.c index 494d0459..47bf27b5 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -105,7 +105,7 @@ void sub_080450A8(Entity* this) { /* Can we create enough new entities? */ count = typeEntityCount[this->type]; - if (MAX_ENTITIES + 1 - count <= gEntCount) + if (MAX_ENTITIES - count <= gEntCount) return; /* Create 2-4 new MiniSlime */ diff --git a/src/entity.c b/src/entity.c index b93fa3a3..b13d5261 100644 --- a/src/entity.c +++ b/src/entity.c @@ -6,6 +6,12 @@ #include "npc.h" #include "manager/diggingCaveEntranceManager.h" +typedef struct Temp { + void* prev; + void* next; + u8 _0[0x38]; +} Temp; + extern u8 gUpdateVisibleTiles; extern Manager gUnk_02033290; void UpdatePlayerInput(void); @@ -241,8 +247,6 @@ void EraseAllEntities(void) { gOAMControls.unk[1].unk6 = 1; } -extern Entity gUnk_030015A0[0x48]; - Entity* GetEmptyEntity() { u8 flags_ip; Entity* end; @@ -253,9 +257,9 @@ Entity* GetEmptyEntity() { LinkedList* listPtr; LinkedList* endListPtr; - if (gEntCount <= 0x46) { - currentEnt = gUnk_030015A0; - end = currentEnt + ARRAY_COUNT(gUnk_030015A0); + if (gEntCount < MAX_ENTITIES - 1) { + currentEnt = gEntities; + end = currentEnt + ARRAY_COUNT(gEntities); do { if (currentEnt->prev == 0) { @@ -267,7 +271,8 @@ Entity* GetEmptyEntity() { currentEnt = &gPlayerEntity; do { - if ((s32)currentEnt->prev < 0 && (currentEnt->flags & 0xc) && currentEnt != gUpdateContext.current_entity) { + if ((s32)currentEnt->prev < 0 && (currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2)) && + currentEnt != gUpdateContext.current_entity) { ClearDeletedEntity(currentEnt); return currentEnt; } @@ -282,9 +287,10 @@ Entity* GetEmptyEntity() { currentEnt = listPtr->first; nextList = listPtr + 1; while ((u32)currentEnt != (u32)listPtr) { - if (currentEnt->kind != MANAGER && flags_ip < (currentEnt->flags & 0x1c) && + if (currentEnt->kind != MANAGER && + flags_ip < (currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED)) && gUpdateContext.current_entity != currentEnt) { - flags_ip = currentEnt->flags & 0x1c; + flags_ip = currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED); rv = currentEnt; } currentEnt = currentEnt->next; @@ -301,16 +307,16 @@ Entity* GetEmptyEntity() { return rv; } -extern Entity gItemGetEntities[7]; +extern Entity gAuxPlayerEntities[7]; -Entity* CreateItemGetEntity(void) { - Entity* ent = gItemGetEntities; +Entity* CreateAuxPlayerEntity(void) { + Entity* ent = gAuxPlayerEntities; do { if (ent->prev == NULL) { return ent; } - } while (++ent < &gItemGetEntities[7]); + } while (++ent < &gAuxPlayerEntities[7]); return NULL; } @@ -407,12 +413,6 @@ void DeleteAllEntities(void) { } } -typedef struct Temp { - void* prev; - void* next; - u8 _0[0x38]; -} Temp; - // fix this Manager* GetEmptyManager(void) { Temp* it; diff --git a/src/itemUtils.c b/src/itemUtils.c index 00cfd5e9..832c68ce 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -403,8 +403,8 @@ void EnableRandomDrops(void) { gRoomVars.randomDropsDisabled = FALSE; } -extern void sub_08000F14(s16*, const s16*, const s16*, const s16*); -extern u32 sub_08000F2C(s16*, const s16*, const s16*, const s16*); +extern void SumDropProbabilities(s16*, const s16*, const s16*, const s16*); +extern u32 SumDropProbabilities2(s16*, const s16*, const s16*, const s16*); u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter); u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) { extern const u8 gUnk_080FE1B4[] /* = { @@ -459,7 +459,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) { #endif } // vector addition, s0 = ptr4 + ptr2 + ptr3 - sub_08000F14(droptable.a, ptr4->a, ptr2->a, ptr3->a); + SumDropProbabilities(droptable.a, ptr4->a, ptr2->a, ptr3->a); if (gSave.stats.health <= 8) { droptable.s.hearts += 5; } @@ -486,7 +486,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) { // vector addition, s0 = s0 + ptr2 + ptr3 // resulting values are clamped to be >= 0 // returns sum over s0 - summOdds = sub_08000F2C(droptable.a, droptable.a, ptr2->a, ptr3->a); + summOdds = SumDropProbabilities2(droptable.a, droptable.a, ptr2->a, ptr3->a); rand = Random(); item = (rand >> 0x18); item &= 0xF; diff --git a/src/object/gentariCurtain.c b/src/object/gentariCurtain.c index 14a25cea..bcfce42e 100644 --- a/src/object/gentariCurtain.c +++ b/src/object/gentariCurtain.c @@ -96,7 +96,7 @@ void sub_080921BC(GentariCurtainEntity* this) { GenericEntity* pEVar1; GenericEntity* end; - pEVar1 = (GenericEntity*)gItemGetEntities; + pEVar1 = (GenericEntity*)gAuxPlayerEntities; end = pEVar1 + 0x4f; do { diff --git a/src/objectUtils.c b/src/objectUtils.c index e3db7806..29e4deb8 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -31,7 +31,7 @@ const s8 gUnk_08126EEC[] = { }; Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) { - Entity* e = CreateItemGetEntity(); + Entity* e = CreateAuxPlayerEntity(); if (e != NULL) { LinkAnimationEntity* this = (LinkAnimationEntity*)e; e->id = LINK_ANIMATION; diff --git a/src/playerItemUtils.c b/src/playerItemUtils.c index b09ed736..6e7bb5f8 100644 --- a/src/playerItemUtils.c +++ b/src/playerItemUtils.c @@ -36,7 +36,7 @@ static Entity* GiveItemWithCutscene(u32 item, u32 type2, u32 delay) { item = ITEM_RUPEE50; type2 = 0; } - e = CreateItemGetEntity(); + e = CreateAuxPlayerEntity(); if (e != NULL) { e->type = item; e->type2 = type2; diff --git a/src/playerUtils.c b/src/playerUtils.c index 2cd630f7..9ab584e5 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -462,7 +462,7 @@ Entity* CreatePlayerItemWithParent(ItemBehavior* this, u32 id) { } void* CreateItemGetPlayerItemWithParent(ItemBehavior* this) { - GenericEntity* playerItem = (GenericEntity*)CreateItemGetEntity(); + GenericEntity* playerItem = (GenericEntity*)CreateAuxPlayerEntity(); if (playerItem != NULL) { playerItem->base.id = gItemDefinitions[this->behaviorId].playerItemId; playerItem->base.kind = PLAYER_ITEM; @@ -501,7 +501,7 @@ Entity* CreatePlayerItem(u32 id, u32 type, u32 type2, u32 unk) { Entity* sub_08077CF8(u32 id, u32 type, u32 type2, u32 unk) { GenericEntity* ent; - ent = (GenericEntity*)CreateItemGetEntity(); + ent = (GenericEntity*)CreateAuxPlayerEntity(); if (ent != NULL) { ent->base.flags = ENT_COLLIDE; ent->base.kind = PLAYER_ITEM; diff --git a/src/ui.c b/src/ui.c index 95a10ef4..b983b0b3 100644 --- a/src/ui.c +++ b/src/ui.c @@ -626,7 +626,8 @@ void ButtonUIElement_Action1(UIElement* element) { MAX_MOVEMENT = (!element->type2) ? 4 : 8; - if (element->type2 == 0 && (((gUnk_0200AF00.unk_1 >> element->type) & 1) || (gMessage.state & MESSAGE_ACTIVE) != 0)) { + if (element->type2 == 0 && + (((gUnk_0200AF00.unk_1 >> element->type) & 1) || (gMessage.state & MESSAGE_ACTIVE) != 0)) { y = (s16)gUnk_0200AF00.buttonY[element->type] - 0x28; } else { y = (s16)gUnk_0200AF00.buttonY[element->type];