1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-27 23:36:22 +00:00

Document some z_actor.c functions (#1091)

This commit is contained in:
hatal175 2022-01-31 11:36:58 +02:00 committed by GitHub
parent 82cedcc3ef
commit aecd883bbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 59 deletions

View file

@ -347,7 +347,7 @@ void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCt
void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx); void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx);
void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex,
Vec3f* rightFootPos); Vec3f* rightFootPos);
void func_8002BE04(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3); void Actor_ProjectPos(GlobalContext* globalCtx, Vec3f* src, Vec3f* xyzDest, f32* cappedInvWDest);
void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx); void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx);
s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag); s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag);
void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag); void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag);
@ -369,7 +369,7 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx
u8 height); u8 height);
void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y,
s32 width, s32 height, s32 delay); s32 width, s32 height, s32 delay);
s32 func_8002D53C(GlobalContext* globalCtx, TitleCardContext* titleCtx); s32 TitleCard_Clear(GlobalContext* globalCtx, TitleCardContext* titleCtx);
void Actor_Kill(Actor* actor); void Actor_Kill(Actor* actor);
void Actor_SetFocus(Actor* actor, f32 offset); void Actor_SetFocus(Actor* actor, f32 offset);
void Actor_SetScale(Actor* actor, f32 scale); void Actor_SetScale(Actor* actor, f32 scale);

View file

@ -213,9 +213,9 @@ void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* lef
} }
} }
void func_8002BE04(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { void Actor_ProjectPos(GlobalContext* globalCtx, Vec3f* src, Vec3f* xyzDest, f32* cappedInvWDest) {
SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, src, xyzDest, cappedInvWDest);
*arg3 = (*arg3 < 1.0f) ? 1.0f : (1.0f / *arg3); *cappedInvWDest = (*cappedInvWDest < 1.0f) ? 1.0f : (1.0f / *cappedInvWDest);
} }
typedef struct { typedef struct {
@ -266,7 +266,7 @@ void func_8002BE98(TargetContext* targetCtx, s32 actorCategory, GlobalContext* g
} }
} }
void func_8002BF60(TargetContext* targetCtx, Actor* actor, s32 actorCategory, GlobalContext* globalCtx) { void Actor_SetNaviToActor(TargetContext* targetCtx, Actor* actor, s32 actorCategory, GlobalContext* globalCtx) {
NaviColor* naviColor = &sNaviColorList[actorCategory]; NaviColor* naviColor = &sNaviColorList[actorCategory];
targetCtx->naviRefPos.x = actor->focus.pos.x; targetCtx->naviRefPos.x = actor->focus.pos.x;
targetCtx->naviRefPos.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y); targetCtx->naviRefPos.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y);
@ -289,7 +289,7 @@ void func_8002C0C0(TargetContext* targetCtx, Actor* actor, GlobalContext* global
targetCtx->bgmEnemy = NULL; targetCtx->bgmEnemy = NULL;
targetCtx->unk_4B = 0; targetCtx->unk_4B = 0;
targetCtx->unk_4C = 0; targetCtx->unk_4C = 0;
func_8002BF60(targetCtx, actor, actor->category, globalCtx); Actor_SetNaviToActor(targetCtx, actor, actor->category, globalCtx);
func_8002BE98(targetCtx, actor->category, globalCtx); func_8002BE98(targetCtx, actor->category, globalCtx);
} }
@ -303,9 +303,9 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) {
Player* player; Player* player;
s16 spCE; s16 spCE;
f32 temp1; f32 temp1;
Vec3f spBC; Vec3f projTargetCenter;
s32 spB8; s32 spB8;
f32 spB4; f32 projTargetCappedInvW;
s32 spB0; s32 spB0;
s32 spAC; s32 spAC;
f32 var1; f32 var1;
@ -334,22 +334,22 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) {
spCE = targetCtx->unk_48; spCE = targetCtx->unk_48;
} }
func_8002BE04(globalCtx, &targetCtx->targetCenterPos, &spBC, &spB4); Actor_ProjectPos(globalCtx, &targetCtx->targetCenterPos, &projTargetCenter, &projTargetCappedInvW);
spBC.x = (160 * (spBC.x * spB4)) * var1; projTargetCenter.x = (160 * (projTargetCenter.x * projTargetCappedInvW)) * var1;
spBC.x = CLAMP(spBC.x, -320.0f, 320.0f); projTargetCenter.x = CLAMP(projTargetCenter.x, -320.0f, 320.0f);
spBC.y = (120 * (spBC.y * spB4)) * var1; projTargetCenter.y = (120 * (projTargetCenter.y * projTargetCappedInvW)) * var1;
spBC.y = CLAMP(spBC.y, -240.0f, 240.0f); projTargetCenter.y = CLAMP(projTargetCenter.y, -240.0f, 240.0f);
spBC.z = spBC.z * var1; projTargetCenter.z = projTargetCenter.z * var1;
targetCtx->unk_4C--; targetCtx->unk_4C--;
if (targetCtx->unk_4C < 0) { if (targetCtx->unk_4C < 0) {
targetCtx->unk_4C = 2; targetCtx->unk_4C = 2;
} }
func_8002BE64(targetCtx, targetCtx->unk_4C, spBC.x, spBC.y, spBC.z); func_8002BE64(targetCtx, targetCtx->unk_4C, projTargetCenter.x, projTargetCenter.y, projTargetCenter.z);
if ((!(player->stateFlags1 & PLAYER_STATE1_6)) || (actor != player->unk_664)) { if ((!(player->stateFlags1 & PLAYER_STATE1_6)) || (actor != player->unk_664)) {
OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x39); OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x39);
@ -414,8 +414,8 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl
s32 pad; s32 pad;
Actor* unkActor; Actor* unkActor;
s32 actorCategory; s32 actorCategory;
Vec3f sp50; Vec3f projectedFocusPos;
f32 sp4C; f32 cappedInvWDest;
f32 temp1; f32 temp1;
f32 temp2; f32 temp2;
f32 temp3; f32 temp3;
@ -465,12 +465,12 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl
targetCtx->naviRefPos.y += temp3 * temp1; targetCtx->naviRefPos.y += temp3 * temp1;
targetCtx->naviRefPos.z += temp4 * temp1; targetCtx->naviRefPos.z += temp4 * temp1;
} else { } else {
func_8002BF60(targetCtx, unkActor, actorCategory, globalCtx); Actor_SetNaviToActor(targetCtx, unkActor, actorCategory, globalCtx);
} }
if ((actorArg != NULL) && (targetCtx->unk_4B == 0)) { if ((actorArg != NULL) && (targetCtx->unk_4B == 0)) {
func_8002BE04(globalCtx, &actorArg->focus.pos, &sp50, &sp4C); Actor_ProjectPos(globalCtx, &actorArg->focus.pos, &projectedFocusPos, &cappedInvWDest);
if (((sp50.z <= 0.0f) || (1.0f <= fabsf(sp50.x * sp4C))) || (1.0f <= fabsf(sp50.y * sp4C))) { if (((projectedFocusPos.z <= 0.0f) || (1.0f <= fabsf(projectedFocusPos.x * cappedInvWDest))) || (1.0f <= fabsf(projectedFocusPos.y * cappedInvWDest))) {
actorArg = NULL; actorArg = NULL;
} }
} }
@ -655,7 +655,7 @@ void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag) {
} }
} }
void func_8002CDE4(GlobalContext* globalCtx, TitleCardContext* titleCtx) { void TitleCard_Init(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
titleCtx->durationTimer = titleCtx->delayTimer = titleCtx->intensity = titleCtx->alpha = 0; titleCtx->durationTimer = titleCtx->delayTimer = titleCtx->intensity = titleCtx->alpha = 0;
} }
@ -701,48 +701,49 @@ void TitleCard_Update(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
} }
void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
s32 spCC; s32 width;
s32 spC8; s32 height;
s32 unk1; s32 unused;
s32 spC0; s32 titleX;
s32 sp38; s32 doubleWidth;
s32 spB8; s32 titleY;
s32 spB4; s32 titleSecondY;
s32 spB0; s32 textureLanguageOffset;
if (titleCtx->alpha != 0) { if (titleCtx->alpha != 0) {
spCC = titleCtx->width; width = titleCtx->width;
spC8 = titleCtx->height; height = titleCtx->height;
spC0 = (titleCtx->x * 4) - (spCC * 2); titleX = (titleCtx->x * 4) - (width * 2);
spB8 = (titleCtx->y * 4) - (spC8 * 2); titleY = (titleCtx->y * 4) - (height * 2);
sp38 = spCC * 2; doubleWidth = width * 2;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 2824); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 2824);
spB0 = spCC * spC8 * gSaveContext.language; textureLanguageOffset = width * height * gSaveContext.language;
spC8 = (spCC * spC8 > 0x1000) ? 0x1000 / spCC : spC8; height = (width * height > 0x1000) ? 0x1000 / width : height;
spB4 = spB8 + (spC8 * 4); titleSecondY = titleY + (height * 4);
OVERLAY_DISP = func_80093808(OVERLAY_DISP); OVERLAY_DISP = func_80093808(OVERLAY_DISP);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->intensity, gDPSetPrimColor(OVERLAY_DISP++, 0, 0, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->intensity,
(u8)titleCtx->alpha); (u8)titleCtx->alpha);
gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + spB0, G_IM_FMT_IA, G_IM_SIZ_8b, spCC, spC8, 0, gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + textureLanguageOffset, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOLOD); G_TX_NOLOD);
gSPTextureRectangle(OVERLAY_DISP++, spC0, spB8, ((sp38 * 2) + spC0) - 4, spB8 + (spC8 * 4) - 1, G_TX_RENDERTILE, gSPTextureRectangle(OVERLAY_DISP++, titleX, titleY, ((doubleWidth * 2) + titleX) - 4, titleY + (height * 4) - 1, G_TX_RENDERTILE,
0, 0, 1 << 10, 1 << 10); 0, 0, 1 << 10, 1 << 10);
spC8 = titleCtx->height - spC8; height = titleCtx->height - height;
if (spC8 > 0) { // If texture is bigger than 0x1000, display the rest
gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + spB0 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_8b, spCC, if (height > 0) {
spC8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + textureLanguageOffset + 0x1000, G_IM_FMT_IA, G_IM_SIZ_8b, width,
height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD); G_TX_NOLOD, G_TX_NOLOD);
gSPTextureRectangle(OVERLAY_DISP++, spC0, spB4, ((sp38 * 2) + spC0) - 4, spB4 + (spC8 * 4) - 1, gSPTextureRectangle(OVERLAY_DISP++, titleX, titleSecondY, ((doubleWidth * 2) + titleX) - 4, titleSecondY + (height * 4) - 1,
G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
} }
@ -750,7 +751,7 @@ void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
} }
} }
s32 func_8002D53C(GlobalContext* globalCtx, TitleCardContext* titleCtx) { s32 TitleCard_Clear(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
if ((globalCtx->actorCtx.titleCtx.delayTimer != 0) || (globalCtx->actorCtx.titleCtx.alpha != 0)) { if ((globalCtx->actorCtx.titleCtx.delayTimer != 0) || (globalCtx->actorCtx.titleCtx.alpha != 0)) {
titleCtx->durationTimer = 0; titleCtx->durationTimer = 0;
titleCtx->delayTimer = 0; titleCtx->delayTimer = 0;
@ -1550,11 +1551,11 @@ s8 func_8002F368(GlobalContext* globalCtx) {
void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y) { void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y) {
Vec3f projectedPos; Vec3f projectedPos;
f32 w; f32 cappedInvW;
func_8002BE04(globalCtx, &actor->focus.pos, &projectedPos, &w); Actor_ProjectPos(globalCtx, &actor->focus.pos, &projectedPos, &cappedInvW);
*x = projectedPos.x * w * (SCREEN_WIDTH / 2) + (SCREEN_WIDTH / 2); *x = projectedPos.x * cappedInvW * (SCREEN_WIDTH / 2) + (SCREEN_WIDTH / 2);
*y = projectedPos.y * w * -(SCREEN_HEIGHT / 2) + (SCREEN_HEIGHT / 2); *y = projectedPos.y * cappedInvW * -(SCREEN_HEIGHT / 2) + (SCREEN_HEIGHT / 2);
} }
u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) {
@ -1977,7 +1978,7 @@ void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry*
actorCtx->flags.clear = savedSceneFlags->clear; actorCtx->flags.clear = savedSceneFlags->clear;
actorCtx->flags.collect = savedSceneFlags->collect; actorCtx->flags.collect = savedSceneFlags->collect;
func_8002CDE4(globalCtx, &actorCtx->titleCtx); TitleCard_Init(globalCtx, &actorCtx->titleCtx);
actorCtx->absoluteSpace = NULL; actorCtx->absoluteSpace = NULL;

View file

@ -321,7 +321,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
LightPoint* params; LightPoint* params;
Vec3f pos; Vec3f pos;
Vec3f multDest; Vec3f multDest;
f32 wDest; f32 cappedInvWDest;
f32 wX; f32 wX;
f32 wY; f32 wY;
s32 wZ; s32 wZ;
@ -336,13 +336,13 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
pos.x = params->x; pos.x = params->x;
pos.y = params->y; pos.y = params->y;
pos.z = params->z; pos.z = params->z;
func_8002BE04(globalCtx, &pos, &multDest, &wDest); Actor_ProjectPos(globalCtx, &pos, &multDest, &cappedInvWDest);
params->drawGlow = false; params->drawGlow = false;
wX = multDest.x * wDest; wX = multDest.x * cappedInvWDest;
wY = multDest.y * wDest; wY = multDest.y * cappedInvWDest;
if ((multDest.z > 1.0f) && (fabsf(wX) < 1.0f) && (fabsf(wY) < 1.0f)) { if ((multDest.z > 1.0f) && (fabsf(wX) < 1.0f) && (fabsf(wY) < 1.0f)) {
wZ = (s32)((multDest.z * wDest) * 16352.0f) + 16352; wZ = (s32)((multDest.z * cappedInvWDest) * 16352.0f) + 16352;
zBuf = gZBuffer[(s32)((wY * -120.0f) + 120.0f)][(s32)((wX * 160.0f) + 160.0f)] * 4; zBuf = gZBuffer[(s32)((wY * -120.0f) + 120.0f)][(s32)((wX * 160.0f) + 160.0f)] * 4;
if (1) {} if (1) {}
if (1) {} if (1) {}

View file

@ -77,7 +77,7 @@ void* ZeldaArena_Calloc(u32 num, u32 size) {
bzero(ret, n); bzero(ret, n);
} }
ZeldaArena_CheckPointer(ret, n, "zelda_calloc", "確保"); ZeldaArena_CheckPointer(ret, n, "zelda_calloc", "確保"); // "Secure"
return ret; return ret;
} }

View file

@ -2770,7 +2770,7 @@ void func_80835F44(GlobalContext* globalCtx, Player* this, s32 item) {
(actionParam >= PLAYER_AP_BOTTLE_FISH)) { (actionParam >= PLAYER_AP_BOTTLE_FISH)) {
if (!func_8008E9C4(this) || if (!func_8008E9C4(this) ||
((actionParam >= PLAYER_AP_BOTTLE_POTION_RED) && (actionParam <= PLAYER_AP_BOTTLE_FAIRY))) { ((actionParam >= PLAYER_AP_BOTTLE_POTION_RED) && (actionParam <= PLAYER_AP_BOTTLE_FAIRY))) {
func_8002D53C(globalCtx, &globalCtx->actorCtx.titleCtx); TitleCard_Clear(globalCtx, &globalCtx->actorCtx.titleCtx);
this->unk_6AD = 4; this->unk_6AD = 4;
this->itemActionParam = actionParam; this->itemActionParam = actionParam;
} }
@ -5890,7 +5890,7 @@ s32 func_8083E5A8(Player* this, GlobalContext* globalCtx) {
Actor* interactedActor; Actor* interactedActor;
if (iREG(67) || (((interactedActor = this->interactRangeActor) != NULL) && if (iREG(67) || (((interactedActor = this->interactRangeActor) != NULL) &&
func_8002D53C(globalCtx, &globalCtx->actorCtx.titleCtx))) { TitleCard_Clear(globalCtx, &globalCtx->actorCtx.titleCtx))) {
if (iREG(67) || (this->getItemId > GI_NONE)) { if (iREG(67) || (this->getItemId > GI_NONE)) {
if (iREG(67)) { if (iREG(67)) {
this->getItemId = iREG(68); this->getItemId = iREG(68);