mirror of
https://github.com/zeldaret/mm.git
synced 2026-05-31 09:21:28 -04:00
6069a1585f
* Match Player_GetHeight * Another bunch * Fix merge conflict * rename Gfx_DrawDListXlu * add WEEROR * Actor_Spawn * almost Actor_SpawnTransitionActors and Actor_Delete * A bunch of small actors * More renames * format * Some Player renames * a few more * import data * run formatter * func_800B7170 * whoops * Fix merge issues * Whoops 2 * func_800B83BC and func_800B83F8 * Actor_IsActorFacingPlayerAndWithinRange * add some prototypes * match Actor_UpdateBgCheckInfo * func_800B7678 * mark Actor_SpawnAsChildAndCutscene as non_matching * Actor_Draw * Update is chaotic * 2 new matches * func_800BC8B8 * Another bunch * function renames * run formatter * cleanup * remove unnecesary casts * add missing sfx * Fix renames * fix merge * func_800BF7CC * small bunch * another bunch * func_800BE184 non_matching * two more * split z_cheap_proc * Another bunch * another bunch * a few and a non matching * yeee * a * Actor_DrawAll non_equivalent * Actor_RecordUndrawnActor * i don't know what to put in this commit message * func_800B4B50 non matching * func_800B42F8 non matching * func_800B5040 * func_800B5814 non_equiv * func_800B6584 * func_800B6608 * func_800B6680 * func_800B7E04 * func_800B8118 * func_800b9170 * , * func_800BC4EC * func_800BA6FC * func_800BA798 * func_800BA8B8 * Actor_LoadOverlay * small cleanup * func_800BB2D0 * meh * func_800BBAC0 * func_800BC270 * func_800B5208 non matching * Fix warnings * meh * rename some ActorShadow_ functions * fairy * Flags_ * fix warnings * format * Actor_PickUp and family * func_800B8E58 * match Actor_RemoveFromCategory * another bit of docs * Match func_800B86C8 * And another bit * rename Player_GetRunSpeedLimit * func_800B9E84 * func_800BE63C * func_800BB8EC * match func_800B5814 * match func_800B9334 * cleanup * fix conflicts: first pass * another fix * actorfixer fix * fix conflicts * func_800BE680 non_equivalent * Improve func_800BE680 a bit * func_800BE680 equivalent (?) * func_800BE680 equivalent * Actor_UpdateActor equivalent * format * use some ExchangeItemID enum values * Some more cleaning * more cleanup * More name stealing from OoT * match func_800B82EC * match func_800B9D1C and a bit of cleanup * Add ACTOR_FLAGS placeholders * Renames and match func_800BE184 * last pass of name stealing * format * fix conflicts * more cleanup * more cleanup * cleanup and OVERLAY_RELOCATION_OFFSET macro * Remove prototypes of obviously internal-only functions, update variable names, forward declare where necessary, remove all `param_\d`s * remove newlines * minor rename * Use ACTOR_FLAGS in z_actor * Match func_800BE3D0 * Rename movement functions * Document Actor_CalcOffsetOrientedToDrawRotation * velX -> horizontalSpeed * A bit of documentation for actor movement functions * format * Fix merge issues * format * Format * Fix renames * fix warnings * fix conflicts * review :D * Update src/overlays/actors/ovl_En_Ma4/z_en_ma4.c Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * Fix * format * Actor_SpawnSetupActors * engineer review * Update src/code/z_actor.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * A bunch of Engineer's reviews * more Engineer's review * a * whoops * run actorfixer * c'mon * 😮💨 * whoops * warning * More engineer's review * run format * I'm dumb * a * match func_800BE680 * Match Actor_DrawZTarget * Match Actor_SpawnAsChildAndCutscene, fix non-equivalent in Actor_UpdateActor * Fix merge issue * format * update actor * Steal a bit of @Thar0 documentation from OoT's z_message * Run actorfixer * Fix renames * Match func_800B4B50 thanks to @hensldm * Improve ActorShadow_DrawFeet thanks to @hensldm * whoops * Actor_PlaySfxAtProjectedPos * Actor_UpdateActor matched by @hensldm * Match func_800BA2FC by @hensldm * Match Actor_SpawnTransitionActors by @hensldm * Match func_800BB604 by @hensldm * Match Actor_DrawAll by @hensldm * ActorShadow_DrawFeet by @hensldm * Actor_UpdateAll by @hensldm * Match func_800BCCDC by @engineer124 * Small Actor_PlaySfxAtPos by @engineer124 * ACTOR_FLAGS_ALL and a bit of cleanup * Add invisible comment * Small docs pass * Fix merge * Engineer's review * format lol * Actor_DrawDoorLock docs * Actor_SpawnShieldParticlesMetal * fix merge issues * sActorFaultClient * fix * commit message * Run actorfixer.py && format.sh * Fix warnings * fixes * format * bss * Update include/functions.h Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * Address review * Fix merge issues, format and such * fix merge issues * Add ACTORCAT_MAX * actorList -> actorLists * Fix merge issues * format * Enable WERROR on jenkinsfile * Fix merge * Use object symbols * address review * format * review * fix merge issues * fix * VRAM_PTR_SIZE, small cleanup and format * review Co-authored-by: Elliptic Ellipsis <elliptic.ellipsis@gmail.com> Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: engineer124 <engineer124engineer124@gmail.com>
214 lines
6.4 KiB
C
214 lines
6.4 KiB
C
/*
|
|
* File: z_sub_s.c
|
|
* Description: Various miscellaneous helpers
|
|
*/
|
|
|
|
#include "global.h"
|
|
#include "overlays/actors/ovl_En_Door/z_en_door.h"
|
|
|
|
/**
|
|
* Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5.
|
|
*/
|
|
EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) {
|
|
Actor* actor = NULL;
|
|
EnDoor* door;
|
|
|
|
while (true) {
|
|
actor = SubS_FindActor(globalCtx, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR);
|
|
door = (EnDoor*)actor;
|
|
|
|
if (actor == NULL) {
|
|
break;
|
|
}
|
|
|
|
if ((door->unk_1A4 == 5) && (door->unk_1A5 == (u8)unk_1A5)) {
|
|
break;
|
|
}
|
|
|
|
if (actor->next == NULL) {
|
|
door = NULL;
|
|
break;
|
|
}
|
|
|
|
actor = actor->next;
|
|
}
|
|
|
|
return door;
|
|
}
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013A860.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AB00.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD6C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AED4.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B010.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B0C8.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B350.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B6B0.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s")
|
|
|
|
/**
|
|
* Finds the nearest actor instance of a specified Id and category to an actor.
|
|
*/
|
|
Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId) {
|
|
Actor* actorIter = NULL;
|
|
Actor* actorTmp;
|
|
f32 dist;
|
|
Actor* closestActor = NULL;
|
|
f32 minDist = 99999.0f;
|
|
s32 isSetup = false;
|
|
|
|
do {
|
|
actorIter = SubS_FindActor(globalCtx, actorIter, actorCategory, actorId);
|
|
|
|
actorTmp = actorIter;
|
|
if (actorTmp == NULL) {
|
|
break;
|
|
}
|
|
actorIter = actorTmp;
|
|
|
|
if (actorIter != actor) {
|
|
dist = Actor_DistanceBetweenActors(actor, actorIter);
|
|
if (!isSetup || dist < minDist) {
|
|
closestActor = actorIter;
|
|
minDist = dist;
|
|
isSetup = true;
|
|
}
|
|
}
|
|
|
|
actorIter = actorIter->next;
|
|
} while (actorIter != NULL);
|
|
|
|
return closestActor;
|
|
}
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BEDC.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C8B8.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CC2C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CD64.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CF04.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D5E8.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D68C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D720.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D768.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D8DC.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s")
|
|
|
|
/**
|
|
* Finds the first actor instance of a specified Id and category.
|
|
*/
|
|
Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId) {
|
|
Actor* actor = actorListStart;
|
|
|
|
if (actor == NULL) {
|
|
actor = globalCtx->actorCtx.actorLists[actorCategory].first;
|
|
}
|
|
|
|
while (actor != NULL && actorId != actor->id) {
|
|
actor = actor->next;
|
|
}
|
|
|
|
return actor;
|
|
}
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DC40.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCE0.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DE04.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DF3C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E054.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E07C.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E1C8.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E2D4.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E3B8.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s")
|
|
|
|
/**
|
|
* Finds the first actor instance of a specified Id and category verified with a custom callback.
|
|
* The callback should return `true` when the actor is succesfully verified.
|
|
*/
|
|
Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory,
|
|
s16 actorId, void* verifyData, VerifyActor verifyActor) {
|
|
Actor* actorIter = actorListStart;
|
|
|
|
if (actorListStart == NULL) {
|
|
actorIter = globalCtx->actorCtx.actorLists[actorCategory].first;
|
|
}
|
|
|
|
while (actorIter != NULL && (actorId != actorIter->id ||
|
|
(actorId == actorIter->id &&
|
|
(verifyActor == NULL ||
|
|
(verifyActor != NULL && !verifyActor(globalCtx, actor, actorIter, verifyData)))))) {
|
|
actorIter = actorIter->next;
|
|
}
|
|
|
|
return actorIter;
|
|
}
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E7C0.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E8F8.s")
|
|
|
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E950.s")
|