1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +00:00

z_actor retail OK (#1670)

* actor ok

* cleanup

* cleanup

* cleanup

* player

* ACTOR_PRINTF

* PR Suggestion

* gcc

* c file

* ACTOR_DEBUG_PRINTF

* bool

* more review

* newline
This commit is contained in:
engineer124 2024-01-31 13:07:34 +11:00 committed by GitHub
parent 4bd005520d
commit 8ae003b0d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 172 additions and 151 deletions

View File

@ -199,6 +199,7 @@
#define R_GAME_OVER_RUMBLE_STRENGTH VREG(90) #define R_GAME_OVER_RUMBLE_STRENGTH VREG(90)
#define R_GAME_OVER_RUMBLE_DURATION VREG(91) #define R_GAME_OVER_RUMBLE_DURATION VREG(91)
#define R_GAME_OVER_RUMBLE_DECREASE_RATE VREG(92) #define R_GAME_OVER_RUMBLE_DECREASE_RATE VREG(92)
#define R_ENABLE_ACTOR_DEBUG_PRINTF HREG(20)
#define R_DISABLE_INPUT_DISPLAY HREG(47) #define R_DISABLE_INPUT_DISPLAY HREG(47)
#define R_ENABLE_PLAY_LOGS HREG(63) #define R_ENABLE_PLAY_LOGS HREG(63)
#define R_EN_GOROIWA_SPEED mREG(12) #define R_EN_GOROIWA_SPEED mREG(12)

View File

@ -42,7 +42,11 @@ typedef struct {
/** /**
* @see ACTOROVL_ALLOC_ABSOLUTE * @see ACTOROVL_ALLOC_ABSOLUTE
*/ */
#if OOT_DEBUG
#define ACTOROVL_ABSOLUTE_SPACE_SIZE 0x27A0 #define ACTOROVL_ABSOLUTE_SPACE_SIZE 0x27A0
#else
#define ACTOROVL_ABSOLUTE_SPACE_SIZE 0x24E0
#endif
/** /**
* The actor overlay should be allocated memory for when loading, * The actor overlay should be allocated memory for when loading,

View File

@ -11,6 +11,17 @@
static CollisionPoly* sCurCeilingPoly; static CollisionPoly* sCurCeilingPoly;
static s32 sCurCeilingBgId; static s32 sCurCeilingBgId;
#if OOT_DEBUG
#define ACTOR_DEBUG_PRINTF \
if (R_ENABLE_ACTOR_DEBUG_PRINTF) \
PRINTF
#elif defined(__sgi)
// See comment about PRINTF in macros.h
#define ACTOR_DEBUG_PRINTF(args) (void)0
#else
#define ACTOR_DEBUG_PRINTF(format, ...) (void)0
#endif
void ActorShape_Init(ActorShape* shape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale) { void ActorShape_Init(ActorShape* shape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale) {
shape->yOffset = yOffset; shape->yOffset = yOffset;
shape->shadowDraw = shadowDraw; shape->shadowDraw = shadowDraw;
@ -23,43 +34,44 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, PlayState* play, Gfx* dlist,
f32 temp2; f32 temp2;
MtxF sp60; MtxF sp60;
if (actor->floorPoly != NULL) { if (actor->floorPoly == NULL) {
temp1 = actor->world.pos.y - actor->floorHeight; return;
}
if (temp1 >= -50.0f && temp1 < 500.0f) { temp1 = actor->world.pos.y - actor->floorHeight;
OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 1553);
POLY_OPA_DISP = Gfx_SetupDL(POLY_OPA_DISP, SETUPDL_44); if (temp1 >= -50.0f && temp1 < 500.0f) {
OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 1553);
gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, POLY_OPA_DISP = Gfx_SetupDL(POLY_OPA_DISP, SETUPDL_44);
COMBINED);
temp1 = (temp1 < 0.0f) ? 0.0f : ((temp1 > 150.0f) ? 150.0f : temp1); gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0,
temp2 = 1.0f - (temp1 * (1.0f / 350)); COMBINED);
if (color != NULL) { temp1 = (temp1 < 0.0f) ? 0.0f : ((temp1 > 150.0f) ? 150.0f : temp1);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, color->r, color->g, color->b, temp2 = 1.0f - (temp1 * (1.0f / 350));
(u32)(actor->shape.shadowAlpha * temp2) & 0xFF);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u32)(actor->shape.shadowAlpha * temp2) & 0xFF);
}
func_80038A28(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &sp60); if (color != NULL) {
Matrix_Put(&sp60); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, color->r, color->g, color->b,
(u32)(actor->shape.shadowAlpha * temp2) & 0xFF);
if (dlist != gCircleShadowDL) { } else {
Matrix_RotateY(BINANG_TO_RAD(actor->shape.rot.y), MTXMODE_APPLY); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u32)(actor->shape.shadowAlpha * temp2) & 0xFF);
}
temp2 = (1.0f - (temp1 * (1.0f / 350))) * actor->shape.shadowScale;
Matrix_Scale(actor->scale.x * temp2, 1.0f, actor->scale.z * temp2, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 1588),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, dlist);
CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 1594);
} }
func_80038A28(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &sp60);
Matrix_Put(&sp60);
if (dlist != gCircleShadowDL) {
Matrix_RotateY(BINANG_TO_RAD(actor->shape.rot.y), MTXMODE_APPLY);
}
temp2 = (1.0f - (temp1 * (1.0f / 350))) * actor->shape.shadowScale;
Matrix_Scale(actor->scale.x * temp2, 1.0f, actor->scale.z * temp2, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 1588), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, dlist);
CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 1594);
} }
} }
@ -148,6 +160,8 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, PlayState* play) {
actor->shape.feetFloorFlag <<= 1; actor->shape.feetFloorFlag <<= 1;
distToFloor = feetPosPtr->y - *floorHeightPtr; distToFloor = feetPosPtr->y - *floorHeightPtr;
if (1) {}
if ((-1.0f <= distToFloor) && (distToFloor < 500.0f)) { if ((-1.0f <= distToFloor) && (distToFloor < 500.0f)) {
if (distToFloor <= 0.0f) { if (distToFloor <= 0.0f) {
actor->shape.feetFloorFlag++; actor->shape.feetFloorFlag++;
@ -284,13 +298,11 @@ void Actor_SetNaviToActor(TargetContext* targetCtx, Actor* actor, s32 actorCateg
} }
void func_8002C0C0(TargetContext* targetCtx, Actor* actor, PlayState* play) { void func_8002C0C0(TargetContext* targetCtx, Actor* actor, PlayState* play) {
targetCtx->arrowPointedActor = NULL; targetCtx->arrowPointedActor = targetCtx->targetedActor = targetCtx->unk_8C = targetCtx->bgmEnemy = NULL;
targetCtx->targetedActor = NULL;
targetCtx->unk_40 = 0.0f;
targetCtx->unk_8C = NULL;
targetCtx->bgmEnemy = NULL;
targetCtx->unk_4B = 0; targetCtx->unk_4B = 0;
targetCtx->unk_4C = 0; targetCtx->unk_4C = 0;
targetCtx->unk_40 = 0.0f;
Actor_SetNaviToActor(targetCtx, actor, actor->category, play); Actor_SetNaviToActor(targetCtx, actor, actor->category, play);
func_8002BE98(targetCtx, actor->category, play); func_8002BE98(targetCtx, actor->category, play);
} }
@ -304,13 +316,12 @@ void func_8002C124(TargetContext* targetCtx, PlayState* play) {
TargetContextEntry* entry; TargetContextEntry* entry;
Player* player; Player* player;
s16 spCE; s16 spCE;
f32 temp1; f32 var1;
Vec3f projTargetCenter; Vec3f projTargetCenter;
s32 spB8; s32 spB8;
f32 projTargetCappedInvW; f32 projTargetCappedInvW;
s32 spB0; s32 spB0;
s32 spAC; s32 spAC;
f32 var1;
f32 var2; f32 var2;
s32 i; s32 i;
@ -417,13 +428,6 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Pl
s32 actorCategory; s32 actorCategory;
Vec3f projectedFocusPos; Vec3f projectedFocusPos;
f32 cappedInvWDest; f32 cappedInvWDest;
f32 temp1;
f32 temp2;
f32 temp3;
f32 temp4;
f32 temp5;
f32 temp6;
s32 lockOnSfxId;
unkActor = NULL; unkActor = NULL;
@ -458,10 +462,12 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Pl
} }
if (Math_StepToF(&targetCtx->unk_40, 0.0f, 0.25f) == 0) { if (Math_StepToF(&targetCtx->unk_40, 0.0f, 0.25f) == 0) {
temp1 = 0.25f / targetCtx->unk_40; f32 temp1 = 0.25f / targetCtx->unk_40;
temp2 = unkActor->world.pos.x - targetCtx->naviRefPos.x; f32 temp2 = unkActor->world.pos.x - targetCtx->naviRefPos.x;
temp3 = (unkActor->world.pos.y + (unkActor->targetArrowOffset * unkActor->scale.y)) - targetCtx->naviRefPos.y; f32 temp3 =
temp4 = unkActor->world.pos.z - targetCtx->naviRefPos.z; (unkActor->world.pos.y + (unkActor->targetArrowOffset * unkActor->scale.y)) - targetCtx->naviRefPos.y;
f32 temp4 = unkActor->world.pos.z - targetCtx->naviRefPos.z;
targetCtx->naviRefPos.x += temp2 * temp1; targetCtx->naviRefPos.x += temp2 * temp1;
targetCtx->naviRefPos.y += temp3 * temp1; targetCtx->naviRefPos.y += temp3 * temp1;
targetCtx->naviRefPos.z += temp4 * temp1; targetCtx->naviRefPos.z += temp4 * temp1;
@ -479,6 +485,8 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Pl
if (actorArg != NULL) { if (actorArg != NULL) {
if (actorArg != targetCtx->targetedActor) { if (actorArg != targetCtx->targetedActor) {
s32 lockOnSfxId;
func_8002BE98(targetCtx, actorArg->category, play); func_8002BE98(targetCtx, actorArg->category, play);
targetCtx->targetedActor = actorArg; targetCtx->targetedActor = actorArg;
@ -496,8 +504,9 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Pl
targetCtx->targetCenterPos.z = actorArg->world.pos.z; targetCtx->targetCenterPos.z = actorArg->world.pos.z;
if (targetCtx->unk_4B == 0) { if (targetCtx->unk_4B == 0) {
temp5 = (500.0f - targetCtx->unk_44) * 3.0f; f32 temp5 = (500.0f - targetCtx->unk_44) * 3.0f;
temp6 = (temp5 < 30.0f) ? 30.0f : ((100.0f < temp5) ? 100.0f : temp5); f32 temp6 = (temp5 < 30.0f) ? 30.0f : ((100.0f < temp5) ? 100.0f : temp5);
if (Math_StepToF(&targetCtx->unk_44, 80.0f, temp6) != 0) { if (Math_StepToF(&targetCtx->unk_44, 80.0f, temp6) != 0) {
targetCtx->unk_4B++; targetCtx->unk_4B++;
} }
@ -715,9 +724,9 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) {
if (titleCtx->alpha != 0) { if (titleCtx->alpha != 0) {
width = titleCtx->width; width = titleCtx->width;
height = titleCtx->height; height = titleCtx->height;
doubleWidth = width * 2;
titleX = (titleCtx->x * 4) - (width * 2); titleX = (titleCtx->x * 4) - (width * 2);
titleY = (titleCtx->y * 4) - (height * 2); titleY = (titleCtx->y * 4) - (height * 2);
doubleWidth = width * 2;
OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2824); OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2824);
@ -832,11 +841,13 @@ void Actor_Destroy(Actor* actor, PlayState* play) {
actor->destroy(actor, play); actor->destroy(actor, play);
actor->destroy = NULL; actor->destroy = NULL;
} else { } else {
#if OOT_DEBUG
overlayEntry = actor->overlayEntry; overlayEntry = actor->overlayEntry;
name = overlayEntry->name != NULL ? overlayEntry->name : ""; name = overlayEntry->name != NULL ? overlayEntry->name : "";
// "No Actor class destruct [%s]" // "No Actor class destruct [%s]"
PRINTF("Actorクラス デストラクトがありません [%s]\n" VT_RST, name); PRINTF("Actorクラス デストラクトがありません [%s]\n" VT_RST, name);
#endif
} }
} }
@ -1291,12 +1302,6 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight,
f32 sp74; f32 sp74;
s32 pad; s32 pad;
Vec3f sp64; Vec3f sp64;
s32 bgId;
CollisionPoly* wallPoly;
f32 sp58;
WaterBox* waterBox;
f32 waterBoxYSurface;
Vec3f ripplePos;
sp74 = actor->world.pos.y - actor->prevPos.y; sp74 = actor->world.pos.y - actor->prevPos.y;
@ -1305,12 +1310,16 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight,
} }
if (flags & UPDBGCHECKINFO_FLAG_0) { if (flags & UPDBGCHECKINFO_FLAG_0) {
s32 bgId;
if ((!(flags & UPDBGCHECKINFO_FLAG_7) && if ((!(flags & UPDBGCHECKINFO_FLAG_7) &&
BgCheck_EntitySphVsWall3(&play->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius, BgCheck_EntitySphVsWall3(&play->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius,
&actor->wallPoly, &bgId, actor, wallCheckHeight)) || &actor->wallPoly, &bgId, actor, wallCheckHeight)) ||
((flags & UPDBGCHECKINFO_FLAG_7) && ((flags & UPDBGCHECKINFO_FLAG_7) &&
BgCheck_EntitySphVsWall4(&play->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius, BgCheck_EntitySphVsWall4(&play->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius,
&actor->wallPoly, &bgId, actor, wallCheckHeight))) { &actor->wallPoly, &bgId, actor, wallCheckHeight))) {
CollisionPoly* wallPoly;
wallPoly = actor->wallPoly; wallPoly = actor->wallPoly;
Math_Vec3f_Copy(&actor->world.pos, &sp64); Math_Vec3f_Copy(&actor->world.pos, &sp64);
actor->wallYaw = Math_Atan2S(wallPoly->normal.z, wallPoly->normal.x); actor->wallYaw = Math_Atan2S(wallPoly->normal.z, wallPoly->normal.x);
@ -1325,6 +1334,8 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight,
sp64.z = actor->world.pos.z; sp64.z = actor->world.pos.z;
if (flags & UPDBGCHECKINFO_FLAG_1) { if (flags & UPDBGCHECKINFO_FLAG_1) {
f32 sp58;
sp64.y = actor->prevPos.y + 10.0f; sp64.y = actor->prevPos.y + 10.0f;
if (BgCheck_EntityCheckCeiling(&play->colCtx, &sp58, &sp64, (ceilingCheckHeight + sp74) - 10.0f, if (BgCheck_EntityCheckCeiling(&play->colCtx, &sp58, &sp64, (ceilingCheckHeight + sp74) - 10.0f,
&sCurCeilingPoly, &sCurCeilingBgId, actor)) { &sCurCeilingPoly, &sCurCeilingBgId, actor)) {
@ -1336,6 +1347,9 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight,
} }
if (flags & UPDBGCHECKINFO_FLAG_2) { if (flags & UPDBGCHECKINFO_FLAG_2) {
WaterBox* waterBox;
f32 waterBoxYSurface;
sp64.y = actor->prevPos.y; sp64.y = actor->prevPos.y;
func_8002E2AC(play, actor, &sp64, flags); func_8002E2AC(play, actor, &sp64, flags);
waterBoxYSurface = actor->world.pos.y; waterBoxYSurface = actor->world.pos.y;
@ -1346,6 +1360,8 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight,
actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH);
} else { } else {
if (!(actor->bgCheckFlags & BGCHECKFLAG_WATER)) { if (!(actor->bgCheckFlags & BGCHECKFLAG_WATER)) {
Vec3f ripplePos;
actor->bgCheckFlags |= BGCHECKFLAG_WATER_TOUCH; actor->bgCheckFlags |= BGCHECKFLAG_WATER_TOUCH;
if (!(flags & UPDBGCHECKINFO_FLAG_6)) { if (!(flags & UPDBGCHECKINFO_FLAG_6)) {
ripplePos.x = actor->world.pos.x; ripplePos.x = actor->world.pos.x;
@ -1377,12 +1393,15 @@ Gfx* func_8002E830(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext*
*hilite = GRAPH_ALLOC(gfxCtx, sizeof(Hilite)); *hilite = GRAPH_ALLOC(gfxCtx, sizeof(Hilite));
#if OOT_DEBUG
if (R_HREG_MODE == HREG_MODE_PRINT_HILITE_INFO) { if (R_HREG_MODE == HREG_MODE_PRINT_HILITE_INFO) {
PRINTF("z_actor.c 3529 eye=[%f(%f) %f %f] object=[%f %f %f] light_direction=[%f %f %f]\n", correctedEyeX, PRINTF("z_actor.c 3529 eye=[%f(%f) %f %f] object=[%f %f %f] light_direction=[%f %f %f]\n", correctedEyeX,
eye->x, eye->y, eye->z, object->x, object->y, object->z, lightDir->x, lightDir->y, lightDir->z); eye->x, eye->y, eye->z, object->x, object->y, object->z, lightDir->x, lightDir->y, lightDir->z);
} }
View_ErrorCheckEyePosition(correctedEyeX, eye->y, eye->z); View_ErrorCheckEyePosition(correctedEyeX, eye->y, eye->z);
#endif
guLookAtHilite(&D_8015BBA8, lookAt, *hilite, correctedEyeX, eye->y, eye->z, object->x, object->y, object->z, 0.0f, guLookAtHilite(&D_8015BBA8, lookAt, *hilite, correctedEyeX, eye->y, eye->z, object->x, object->y, object->z, 0.0f,
1.0f, 0.0f, lightDir->x, lightDir->y, lightDir->z, lightDir->x, lightDir->y, lightDir->z, 16, 16); 1.0f, 0.0f, lightDir->x, lightDir->y, lightDir->z, lightDir->x, lightDir->y, lightDir->z, 16, 16);
@ -1773,8 +1792,8 @@ void func_8002F698(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4,
player->unk_8A0 = arg6; player->unk_8A0 = arg6;
player->unk_8A1 = arg5; player->unk_8A1 = arg5;
player->unk_8A2 = arg3;
player->unk_8A4 = arg2; player->unk_8A4 = arg2;
player->unk_8A2 = arg3;
player->unk_8A8 = arg4; player->unk_8A8 = arg4;
} }
@ -1903,11 +1922,12 @@ void func_8002FA60(PlayState* play) {
gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z = 0.0f; gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z = 0.0f;
} }
lightPos.x = gSaveContext.respawn[RESPAWN_MODE_TOP].pos.x; // clang-format off
lightPos.y = gSaveContext.respawn[RESPAWN_MODE_TOP].pos.y + 80.0f; lightPos.x = gSaveContext.respawn[RESPAWN_MODE_TOP].pos.x; \
lightPos.z = gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z; lightPos.y = gSaveContext.respawn[RESPAWN_MODE_TOP].pos.y + 80.0f; \
lightPos.z = gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z; \
Lights_PointNoGlowSetInfo(&D_8015BC00, lightPos.x, lightPos.y, lightPos.z, 0xFF, 0xFF, 0xFF, -1); Lights_PointNoGlowSetInfo(&D_8015BC00, lightPos.x, lightPos.y, lightPos.z, 0xFF, 0xFF, 0xFF, -1);
// clang-format on
D_8015BC10 = LightContext_InsertLight(play, &play->lightCtx, &D_8015BC00); D_8015BC10 = LightContext_InsertLight(play, &play->lightCtx, &D_8015BC00);
D_8015BC14 = 0; D_8015BC14 = 0;
@ -2137,7 +2157,7 @@ u32 sCategoryFreezeMasks[ACTORCAT_MAX] = {
}; };
void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
Actor* refActor; s32 i;
Actor* actor; Actor* actor;
Player* player; Player* player;
u32* categoryFreezeMaskP; u32* categoryFreezeMaskP;
@ -2145,7 +2165,6 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
u32 canFreezeCategory; u32 canFreezeCategory;
Actor* sp74; Actor* sp74;
ActorEntry* actorEntry; ActorEntry* actorEntry;
s32 i;
player = GET_PLAYER(play); player = GET_PLAYER(play);
@ -2169,12 +2188,15 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
actorCtx->unk_02--; actorCtx->unk_02--;
} }
#if OOT_DEBUG
if (KREG(0) == -100) { if (KREG(0) == -100) {
refActor = &GET_PLAYER(play)->actor; Actor* player = &GET_PLAYER(play)->actor;
KREG(0) = 0; KREG(0) = 0;
Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, refActor->world.pos.x, refActor->world.pos.y + 100.0f, Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, player->world.pos.x, player->world.pos.y + 100.0f,
refActor->world.pos.z, 0, 0, 0, 1); player->world.pos.z, 0, 0, 0, 1);
} }
#endif
categoryFreezeMaskP = &sCategoryFreezeMasks[0]; categoryFreezeMaskP = &sCategoryFreezeMasks[0];
@ -2288,10 +2310,14 @@ void Actor_FaultPrint(Actor* actor, char* command) {
FaultDrawer_Printf("ACTOR NAME is NULL"); FaultDrawer_Printf("ACTOR NAME is NULL");
} }
#if OOT_DEBUG
overlayEntry = actor->overlayEntry; overlayEntry = actor->overlayEntry;
name = overlayEntry->name != NULL ? overlayEntry->name : ""; name = overlayEntry->name != NULL ? overlayEntry->name : "";
PRINTF("アクターの名前(%08x:%s)\n", actor, name); // "Actor name (%08x:%s)" PRINTF("アクターの名前(%08x:%s)\n", actor, name); // "Actor name (%08x:%s)"
#else
name = "";
#endif
if (command != NULL) { if (command != NULL) {
PRINTF("コメント:%s\n", command); // "Command:%s" PRINTF("コメント:%s\n", command); // "Command:%s"
@ -2537,20 +2563,22 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) {
gDPNoOpString(POLY_OPA_DISP++, actorName, i); gDPNoOpString(POLY_OPA_DISP++, actorName, i);
gDPNoOpString(POLY_XLU_DISP++, actorName, i); gDPNoOpString(POLY_XLU_DISP++, actorName, i);
HREG(66) = i; if (OOT_DEBUG) {
HREG(66) = i;
}
if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(68) == 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(68) == 0)) {
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos, SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos,
&actor->projectedW); &actor->projectedW);
} }
if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(69) == 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(69) == 0)) {
if (actor->sfx != 0) { if (actor->sfx != 0) {
func_80030ED8(actor); func_80030ED8(actor);
} }
} }
if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(70) == 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(70) == 0)) {
if (func_800314B0(play, actor)) { if (func_800314B0(play, actor)) {
actor->flags |= ACTOR_FLAG_6; actor->flags |= ACTOR_FLAG_6;
} else { } else {
@ -2560,7 +2588,7 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) {
actor->isDrawn = false; actor->isDrawn = false;
if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(71) == 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(71) == 0)) {
if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & (ACTOR_FLAG_5 | ACTOR_FLAG_6))) { if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & (ACTOR_FLAG_5 | ACTOR_FLAG_6))) {
if ((actor->flags & ACTOR_FLAG_REACT_TO_LENS) && if ((actor->flags & ACTOR_FLAG_REACT_TO_LENS) &&
((play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) || play->actorCtx.lensActive || ((play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) || play->actorCtx.lensActive ||
@ -2570,7 +2598,8 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) {
invisibleActors[invisibleActorCounter] = actor; invisibleActors[invisibleActorCounter] = actor;
invisibleActorCounter++; invisibleActorCounter++;
} else { } else {
if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(72) == 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) ||
(HREG(72) == 0)) {
Actor_Draw(play, actor); Actor_Draw(play, actor);
actor->isDrawn = true; actor->isDrawn = true;
} }
@ -2582,15 +2611,15 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) {
} }
} }
if ((HREG(64) != 1) || (HREG(73) != 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || (HREG(73) != 0)) {
Effect_DrawAll(play->state.gfxCtx); Effect_DrawAll(play->state.gfxCtx);
} }
if ((HREG(64) != 1) || (HREG(74) != 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || (HREG(74) != 0)) {
EffectSs_DrawAll(play); EffectSs_DrawAll(play);
} }
if ((HREG(64) != 1) || (HREG(72) != 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || (HREG(72) != 0)) {
if (play->actorCtx.lensActive) { if (play->actorCtx.lensActive) {
Actor_DrawLensActors(play, invisibleActorCounter, invisibleActors); Actor_DrawLensActors(play, invisibleActorCounter, invisibleActors);
if ((play->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(play)) { if ((play->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(play)) {
@ -2605,7 +2634,7 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) {
Lights_DrawGlow(play); Lights_DrawGlow(play);
} }
if ((HREG(64) != 1) || (HREG(75) != 0)) { if (!OOT_DEBUG || (HREG(64) != 1) || (HREG(75) != 0)) {
TitleCard_Draw(play, &actorCtx->titleCtx); TitleCard_Draw(play, &actorCtx->titleCtx);
} }
@ -2695,9 +2724,7 @@ void func_80031C3C(ActorContext* actorCtx, PlayState* play) {
} }
} }
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("絶対魔法領域解放\n"); // "Absolute magic field deallocation"
PRINTF("絶対魔法領域解放\n"); // "Absolute magic field deallocation"
}
if (actorCtx->absoluteSpace != NULL) { if (actorCtx->absoluteSpace != NULL) {
ZELDA_ARENA_FREE(actorCtx->absoluteSpace, "../z_actor.c", 6731); ZELDA_ARENA_FREE(actorCtx->absoluteSpace, "../z_actor.c", 6731);
@ -2767,32 +2794,24 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) {
PRINTF(VT_FGCOL(CYAN)); PRINTF(VT_FGCOL(CYAN));
if (actorOverlay->numLoaded == 0) { if (actorOverlay->numLoaded == 0) {
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("アクタークライアントが0になりました\n"); // "Actor client is now 0"
PRINTF("アクタークライアントが0になりました\n"); // "Actor client is now 0"
}
if (actorOverlay->loadedRamAddr != NULL) { if (actorOverlay->loadedRamAddr != NULL) {
if (actorOverlay->allocType & ACTOROVL_ALLOC_PERSISTENT) { if (actorOverlay->allocType & ACTOROVL_ALLOC_PERSISTENT) {
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("オーバーレイ解放しません\n"); // "Overlay will not be deallocated"
PRINTF("オーバーレイ解放しません\n"); // "Overlay will not be deallocated"
}
} else if (actorOverlay->allocType & ACTOROVL_ALLOC_ABSOLUTE) { } else if (actorOverlay->allocType & ACTOROVL_ALLOC_ABSOLUTE) {
if (HREG(20) != 0) { // "Absolute magic field reserved, so deallocation will not occur"
// "Absolute magic field reserved, so deallocation will not occur" ACTOR_DEBUG_PRINTF("絶対魔法領域確保なので解放しません\n");
PRINTF("絶対魔法領域確保なので解放しません\n");
}
actorOverlay->loadedRamAddr = NULL; actorOverlay->loadedRamAddr = NULL;
} else { } else {
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("オーバーレイ解放します\n"); // "Overlay deallocated"
PRINTF("オーバーレイ解放します\n"); // "Overlay deallocated"
}
ZELDA_ARENA_FREE(actorOverlay->loadedRamAddr, "../z_actor.c", 6834); ZELDA_ARENA_FREE(actorOverlay->loadedRamAddr, "../z_actor.c", 6834);
actorOverlay->loadedRamAddr = NULL; actorOverlay->loadedRamAddr = NULL;
} }
} }
} else if (HREG(20) != 0) { } else {
// "%d of actor client remains" // "%d of actor client remains"
PRINTF("アクタークライアントはあと %d 残っています\n", actorOverlay->numLoaded); ACTOR_DEBUG_PRINTF("アクタークライアントはあと %d 残っています\n", actorOverlay->numLoaded);
} }
PRINTF(VT_RST); PRINTF(VT_RST);
@ -2812,13 +2831,14 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
overlayEntry = &gActorOverlayTable[actorId]; overlayEntry = &gActorOverlayTable[actorId];
ASSERT(actorId < ACTOR_ID_MAX, "profile < ACTOR_DLF_MAX", "../z_actor.c", 6883); ASSERT(actorId < ACTOR_ID_MAX, "profile < ACTOR_DLF_MAX", "../z_actor.c", 6883);
#if OOT_DEBUG
name = overlayEntry->name != NULL ? overlayEntry->name : ""; name = overlayEntry->name != NULL ? overlayEntry->name : "";
#endif
overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart; overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart;
if (HREG(20) != 0) { // "Actor class addition [%d:%s]"
// "Actor class addition [%d:%s]" ACTOR_DEBUG_PRINTF("アクタークラス追加 [%d:%s]\n", actorId, name);
PRINTF("アクタークラス追加 [%d:%s]\n", actorId, name);
}
if (actorCtx->total > ACTOR_NUMBER_MAX) { if (actorCtx->total > ACTOR_NUMBER_MAX) {
// " set number exceeded" // " set number exceeded"
@ -2827,16 +2847,12 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
} }
if (overlayEntry->vramStart == NULL) { if (overlayEntry->vramStart == NULL) {
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("オーバーレイではありません\n"); // "Not an overlay"
PRINTF("オーバーレイではありません\n"); // "Not an overlay"
}
actorInit = overlayEntry->initInfo; actorInit = overlayEntry->initInfo;
} else { } else {
if (overlayEntry->loadedRamAddr != NULL) { if (overlayEntry->loadedRamAddr != NULL) {
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("既にロードされています\n"); // "Already loaded"
PRINTF("既にロードされています\n"); // "Already loaded"
}
} else { } else {
if (overlayEntry->allocType & ACTOROVL_ALLOC_ABSOLUTE) { if (overlayEntry->allocType & ACTOROVL_ALLOC_ABSOLUTE) {
ASSERT(overlaySize <= ACTOROVL_ABSOLUTE_SPACE_SIZE, "actor_segsize <= AM_FIELD_SIZE", "../z_actor.c", ASSERT(overlaySize <= ACTOROVL_ABSOLUTE_SPACE_SIZE, "actor_segsize <= AM_FIELD_SIZE", "../z_actor.c",
@ -2845,10 +2861,8 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
if (actorCtx->absoluteSpace == NULL) { if (actorCtx->absoluteSpace == NULL) {
// "AMF: absolute magic field" // "AMF: absolute magic field"
actorCtx->absoluteSpace = ZELDA_ARENA_MALLOC_R(ACTOROVL_ABSOLUTE_SPACE_SIZE, "AMF:絶対魔法領域", 0); actorCtx->absoluteSpace = ZELDA_ARENA_MALLOC_R(ACTOROVL_ABSOLUTE_SPACE_SIZE, "AMF:絶対魔法領域", 0);
if (HREG(20) != 0) { // "Absolute magic field reservation - %d bytes reserved"
// "Absolute magic field reservation - %d bytes reserved" ACTOR_DEBUG_PRINTF("絶対魔法領域確保 %d バイト確保\n", ACTOROVL_ABSOLUTE_SPACE_SIZE);
PRINTF("絶対魔法領域確保 %d バイト確保\n", ACTOROVL_ABSOLUTE_SPACE_SIZE);
}
} }
overlayEntry->loadedRamAddr = actorCtx->absoluteSpace; overlayEntry->loadedRamAddr = actorCtx->absoluteSpace;
@ -2910,10 +2924,10 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
overlayEntry->numLoaded++; overlayEntry->numLoaded++;
if (HREG(20) != 0) { if (1) {}
// "Actor client No. %d"
PRINTF("アクタークライアントは %d 個目です\n", overlayEntry->numLoaded); // "Actor client No. %d"
} ACTOR_DEBUG_PRINTF("アクタークライアントは %d 個目です\n", overlayEntry->numLoaded);
Lib_MemSet((u8*)actor, actorInit->instanceSize, 0); Lib_MemSet((u8*)actor, actorInit->instanceSize, 0);
actor->overlayEntry = overlayEntry; actor->overlayEntry = overlayEntry;
@ -3011,9 +3025,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) {
overlayEntry = actor->overlayEntry; overlayEntry = actor->overlayEntry;
name = overlayEntry->name != NULL ? overlayEntry->name : ""; name = overlayEntry->name != NULL ? overlayEntry->name : "";
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("アクタークラス削除 [%s]\n", name); // "Actor class deleted [%s]"
PRINTF("アクタークラス削除 [%s]\n", name); // "Actor class deleted [%s]"
}
if ((player != NULL) && (actor == player->unk_664)) { if ((player != NULL) && (actor == player->unk_664)) {
func_8008EDF0(player); func_8008EDF0(player);
@ -3040,9 +3052,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) {
ZELDA_ARENA_FREE(actor, "../z_actor.c", 7242); ZELDA_ARENA_FREE(actor, "../z_actor.c", 7242);
if (overlayEntry->vramStart == NULL) { if (overlayEntry->vramStart == NULL) {
if (HREG(20) != 0) { ACTOR_DEBUG_PRINTF("オーバーレイではありません\n"); // "Not an overlay"
PRINTF("オーバーレイではありません\n"); // "Not an overlay"
}
} else { } else {
ASSERT(overlayEntry->loadedRamAddr != NULL, "actor_dlftbl->allocp != NULL", "../z_actor.c", 7251); ASSERT(overlayEntry->loadedRamAddr != NULL, "actor_dlftbl->allocp != NULL", "../z_actor.c", 7251);
ASSERT(overlayEntry->numLoaded > 0, "actor_dlftbl->clients > 0", "../z_actor.c", 7252); ASSERT(overlayEntry->numLoaded > 0, "actor_dlftbl->clients > 0", "../z_actor.c", 7252);
@ -3716,7 +3726,7 @@ void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) {
f32 chainRotZ; f32 chainRotZ;
f32 chainsTranslateX; f32 chainsTranslateX;
f32 chainsTranslateY; f32 chainsTranslateY;
f32 rotZStep; s32 pad;
entry = &sDoorLocksInfo[type]; entry = &sDoorLocksInfo[type];
chainRotZ = entry->chainsRotZInit; chainRotZ = entry->chainsRotZInit;
@ -3726,28 +3736,34 @@ void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) {
Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY);
Matrix_Get(&baseMtxF); Matrix_Get(&baseMtxF);
chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; {
chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; f32 rotZStep;
for (i = 0; i < 4; i++) { chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength;
Matrix_Put(&baseMtxF); chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength;
Matrix_RotateZ(chainRotZ, MTXMODE_APPLY);
Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY);
if (entry->chainsScale != 1.0f) { for (i = 0; i < 4; i++) {
Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY);
Matrix_Put(&baseMtxF);
Matrix_RotateZ(chainRotZ, MTXMODE_APPLY);
Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY);
if (entry->chainsScale != 1.0f) {
Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY);
}
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 8299),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, entry->chainDL);
if (i % 2) {
rotZStep = 2.0f * entry->chainAngle;
} else {
rotZStep = M_PI - (2.0f * entry->chainAngle);
}
chainRotZ += rotZStep;
} }
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 8299), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, entry->chainDL);
if (i % 2) {
rotZStep = 2.0f * entry->chainAngle;
} else {
rotZStep = M_PI - (2.0f * entry->chainAngle);
}
chainRotZ += rotZStep;
} }
Matrix_Put(&baseMtxF); Matrix_Put(&baseMtxF);
@ -4406,19 +4422,19 @@ Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3,
} }
void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2) { void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2) {
f32 floorPolyNormalX;
f32 floorPolyNormalY;
f32 floorPolyNormalZ;
f32 sp38;
f32 sp34;
f32 sp30;
f32 sp2C;
f32 sp28;
f32 sp24;
CollisionPoly* floorPoly;
s32 pad;
if (actor->floorPoly != NULL) { if (actor->floorPoly != NULL) {
f32 floorPolyNormalX;
f32 floorPolyNormalY;
f32 floorPolyNormalZ;
f32 sp38;
f32 sp34;
f32 sp30;
f32 sp2C;
f32 sp28;
f32 sp24;
CollisionPoly* floorPoly;
s32 pad;
floorPoly = actor->floorPoly; floorPoly = actor->floorPoly;
floorPolyNormalX = COLPOLY_GET_NORMAL(floorPoly->normal.x); floorPolyNormalX = COLPOLY_GET_NORMAL(floorPoly->normal.x);
floorPolyNormalY = COLPOLY_GET_NORMAL(floorPoly->normal.y); floorPolyNormalY = COLPOLY_GET_NORMAL(floorPoly->normal.y);