1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-14 20:05:02 +00:00

Match Jsjutan and Tr and improve match of Yabusame_mark and holl (#769)

* some cleanup

* .s

* more matches

* .s and yabu

* holl try

* format

* Update src/overlays/actors/ovl_En_Holl/z_en_holl.c

Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>

Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
This commit is contained in:
petrie911 2021-04-09 18:19:30 -05:00 committed by GitHub
parent ab05eb9776
commit ed78d18a25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 173 additions and 1189 deletions

View file

@ -171,7 +171,7 @@ void func_80A58DD4(EnHoll* this, GlobalContext* globalCtx) {
// Horizontal Planes
#ifdef NON_MATCHING
// Small regalloc near the end
// a/v regalloc near the end. Also ugly float thing in the conditional that seems needed to match.
void func_80A59014(EnHoll* this, GlobalContext* globalCtx) {
s32 pad;
s32 pad1;
@ -184,15 +184,18 @@ void func_80A59014(EnHoll* this, GlobalContext* globalCtx) {
s32 transitionActorIdx;
f32 absZ;
s32 side;
s8 test;
func_8002DBD0(&this->actor, &vec, (useViewEye) ? &globalCtx->view.eye : &player->actor.world.pos);
planeHalfWidth = (((this->actor.params >> 6) & 7) == 6) ? PLANE_HALFWIDTH : PLANE_HALFWIDTH_2;
if (EnHoll_IsKokiriSetup8() || (vec.y > PLANE_Y_MIN && vec.y < PLANE_Y_MAX && fabsf(vec.x) < planeHalfWidth &&
fabsf(vec.z) < 100.0f && fabsf(vec.z) > 50.0f)) {
if (EnHoll_IsKokiriSetup8() || (PLANE_Y_MIN < vec.y && vec.y < PLANE_Y_MAX && fabsf(vec.x) < planeHalfWidth &&
(absZ = fabsf(vec.z), 100.0f > absZ && absZ > 50.0f))) {
transitionActorIdx = (u16)this->actor.params >> 0xA;
side = (vec.z < 0.0f) ? 0 : 1;
transitionEntry = &globalCtx->transitionActorList[transitionActorIdx];
this->actor.room = transitionEntry->sides[side].room;
test = transitionEntry->sides[side].room;
this->actor.room = test;
if (this->actor.room != globalCtx->roomCtx.curRoom.num &&
func_8009728C(globalCtx, &globalCtx->roomCtx, (u32)this->actor.room)) {
EnHoll_SetupAction(this, EnHoll_NextAction);

View file

@ -47,7 +47,7 @@ void EnJsjutan_Init(Actor* thisx, GlobalContext* globalCtx) {
CollisionHeader_GetVirtual(&gJsjutanCol, &header);
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, header);
Actor_SetScale(thisx, 0.02f);
this->unk_164 = 1;
this->unk_164 = true;
this->shadowAlpha = 100.0f;
}
@ -58,11 +58,10 @@ void EnJsjutan_Destroy(Actor* thisx, GlobalContext* globalCtx) {
}
void func_80A89860(EnJsjutan* this, GlobalContext* globalCtx) {
s32 pad;
s16 i;
Vtx* phi_s0;
Vtx* phi_s2;
Vec3f actorPos = this->dyna.actor.world.pos;
s16 i;
phi_s0 = SEGMENTED_TO_VIRTUAL(gJsjutanShadowOddVtx);
phi_s2 = SEGMENTED_TO_VIRTUAL(gJsjutanShadowEvenVtx);
@ -82,10 +81,8 @@ void func_80A89860(EnJsjutan* this, GlobalContext* globalCtx) {
}
}
#ifdef NON_MATCHING
// regalloc differences
void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
u8 isPlayerOnTop;
u8 isPlayerOnTop = false; // sp127
s16 i;
s16 j;
Vtx* phi_s0;
@ -93,12 +90,12 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
Vtx* phi_s0_2;
Vec3f sp108;
Vec3f spFC;
Vtx* phi_s0_3;
f32 temp_f0_3;
Player* player;
Actor* parent;
Actor* actorExplosive;
f32 phi_f28;
Actor* actorProfessor;
Actor* actorBeanGuy;
f32 dxVtx;
f32 dyVtx;
f32 dzVtx;
f32 distVtx;
// 0 if no actor in that index of diffToTracked
u8 spE0[3];
// Tracks distance to other actors.
@ -110,28 +107,16 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
f32 spB8; // diffToPlayer X
f32 spB4; // diffToPlayer Y
f32 spB0; // diffToPlayer Z
f32 phi_f2_4;
f32 weight;
f32 spA8; // wave amplitude (?)
Actor* actorProfessor;
Actor* actorBeanGuy;
f32 distance_1;
f32 temp_f14_2;
f32 distance_2;
f32 phi_f2_2;
f32 phi_f2_3;
u8 isInCreditsScene;
s16 index; // phi_v1_5
f32 phi_f22;
f32 aux_f20;
s16 phi_v1_4;
s16 temp_a0_3;
u16 dayTime;
isPlayerOnTop = 0;
player = PLAYER;
parent = this->dyna.actor.parent;
actorExplosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head;
isInCreditsScene = 0;
f32 offset;
f32 maxOffset;
f32 maxAmp;
f32 waveform;
Player* player = PLAYER;
Actor* parent = this->dyna.actor.parent;
Actor* actorExplosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head;
u8 isInCreditsScene = false; // sp8B
if (globalCtx->gameplayFrames % 2 != 0) {
phi_s0 = SEGMENTED_TO_VIRTUAL(gJsjutanCarpetOddVtx);
@ -148,7 +133,7 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
phi_s0_2 = phi_s0;
if ((fabsf(spB8) < 5500.0f) && (fabsf(spB4) < 3000.0f) && (fabsf(spB0) < 5500.0f)) {
isPlayerOnTop = 1;
isPlayerOnTop = true;
}
// Distance of Magic Carpet Salesman to carpet.
@ -165,7 +150,7 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
// Credits scene. The magic carpet man is friends with the bean guy and the lakeside professor.
if ((gSaveContext.entranceIndex == 0x157) && (gSaveContext.sceneSetupIndex == 8)) {
isInCreditsScene = 1;
isInCreditsScene = true;
actorProfessor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].head;
while (actorProfessor != NULL) {
@ -199,9 +184,9 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
// Player can place bombs in carpet and it will react to it.
while (actorExplosive != NULL) {
if (i < 3) {
spD4[i] = 50.0f * (actorExplosive->world.pos.x - this->dyna.actor.world.pos.x);
spC8[i] = 50.0f * (actorExplosive->world.pos.y - this->unk_168);
spBC[i] = 50.0f * (actorExplosive->world.pos.z - this->dyna.actor.world.pos.z);
spD4[i] = (actorExplosive->world.pos.x - this->dyna.actor.world.pos.x) * 50.0f;
spC8[i] = (actorExplosive->world.pos.y - this->unk_168) * 50.0f;
spBC[i] = (actorExplosive->world.pos.z - this->dyna.actor.world.pos.z) * 50.0f;
if ((fabsf(spD4[i]) < 5500.0f) && (fabsf(spC8[i]) < 3000.0f) && (fabsf(spBC[i]) < 5500.0f)) {
if (actorExplosive->params == BOMB_EXPLOSION) {
@ -217,74 +202,66 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
}
}
if (1) {}
// Fancy math to make a woobly and reactive carpet.
for (j = 0; j < ARRAY_COUNT(D_80A8EE10); j++, phi_s0++, phi_s3++) {
for (i = 0; i < ARRAY_COUNT(D_80A8EE10); i++, phi_s0++, phi_s3++) {
if (isPlayerOnTop) {
// Linear distance from j-th wave to player, in XZ plane.
distance_1 = sqrtf(SQ(phi_s0->n.ob[2] - spB0) + SQ(phi_s0->n.ob[0] - spB8));
dxVtx = phi_s0->n.ob[0] - spB8;
dzVtx = phi_s0->n.ob[2] - spB0;
distVtx = sqrtf(SQ(dxVtx) + SQ(dzVtx));
// Distance percentage. 0.0f to 1.0f. 2500.0f is the max distance to an actor that this wave will consider.
phi_f2_4 = (2500.0f - distance_1) / 2500.0f;
if (phi_f2_4 < 0.0f) {
phi_f2_4 = 0.0f;
weight = (2500.0f - distVtx) / 2500.0f;
if (weight < 0.0f) {
weight = 0.0f;
}
offset = (spB4 * weight) + ((this->unk_170 - (this->unk_170 * weight)) - 200.0f);
distVtx -= 1500.0f;
if (distVtx < 0.0f) {
distVtx = 0.0f;
}
// phi_f28 = (spB4 * phi_f2_4) + ((this->unk_170 - (this->unk_170 * phi_f2_4)) - 200.0f);
spA8 = (spB4 * phi_f2_4) + ((this->unk_170 - (this->unk_170 * phi_f2_4)) - 200.0f);
phi_f28 = spA8;
spA8 = 100.0f * distVtx * 0.01f;
spA8 = CLAMP_MAX(spA8, 100.0f);
distance_1 -= 1500.0f;
if (distance_1 < 0.0f) {
distance_1 = 0.0f;
}
spA8 = 100.0f * distance_1 * 0.01f;
if (spA8 > 100.0f) {
spA8 = 100.0f;
}
} else {
phi_f28 = this->unk_170 - 200.f;
offset = this->unk_170 - 200.f;
spA8 = 100.0f;
}
for (i = 0; i < 3; i++) {
if (spE0[i] != 0) {
for (j = 0; j < 3; j++) {
if (spE0[j] != 0) {
dxVtx = phi_s0->n.ob[0] - spD4[j];
dzVtx = phi_s0->n.ob[2] - spBC[j];
// Linear distance from j-th wave to whatever actor is there, in XZ plane.
distance_2 = sqrtf(SQ(phi_s0->n.ob[2] - spBC[i]) + SQ(phi_s0->n.ob[0] - spD4[i]));
distVtx = sqrtf(SQ(dxVtx) + SQ(dzVtx));
if ((i == 0) || isInCreditsScene) {
phi_f2_2 = (3000.0f - distance_2) / 3000.0f;
if ((j == 0) || isInCreditsScene) {
weight = (3000.0f - distVtx) / 3000.0f;
} else {
phi_f2_2 = (2000.0f - distance_2) / 2000.0f;
weight = (2000.0f - distVtx) / 2000.0f;
}
if (weight < 0.0f) {
weight = 0.0f;
}
if (phi_f2_2 < 0.0f) {
phi_f2_2 = 0.0f;
// should be the following, but doesn't match that way.
// maxoffset = (spC8[i] * weight) + ((this->unk_170 - (this->unk_170 * weight)) - 200.0f);
maxOffset = (spC8[j] * weight);
maxOffset += ((this->unk_170 - (this->unk_170 * weight)) - 200.0f);
distVtx -= 1500.0f;
if (distVtx < 0.0f) {
distVtx = 0.0f;
}
// temp_f14_2 = (spC8[i] * phi_f2_2) + ((this->unk_170 - (this->unk_170 * phi_f2_2)) - 200.0f);
temp_f14_2 = (spC8[i] * phi_f2_2);
temp_f14_2 += ((this->unk_170 - (this->unk_170 * phi_f2_2)) - 200.0f);
maxAmp = 100.0f * distVtx * 0.01f;
maxAmp = CLAMP_MAX(maxAmp, 100.0f);
distance_2 = distance_2 - 1500.0f;
if (distance_2 < 0.0f) {
distance_2 = 0.0f;
}
offset = CLAMP_MAX(offset, maxOffset);
phi_f2_3 = 100.0f * distance_2 * 0.01f;
if (phi_f2_3 > 100.0f) {
phi_f2_3 = 100.0f;
}
if (temp_f14_2 < phi_f28) {
phi_f28 = temp_f14_2;
}
if (phi_f2_3 < spA8) {
spA8 = phi_f2_3;
}
spA8 = CLAMP_MAX(spA8, maxAmp);
}
}
@ -297,13 +274,11 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
* A: spA8
* D: phi_f28
*/
temp_f0_3 = Math_SinS(globalCtx->gameplayFrames * 4000 + j * 10000);
waveform = spA8 * Math_SinS(globalCtx->gameplayFrames * 4000 + i * 10000);
if (this->unk_174) {
temp_f14_2 = temp_f0_3 * spA8;
phi_v1_4 = phi_f28 + (temp_f14_2);
temp_a0_3 = (phi_s3->n.ob[1] - this->unk_168) * 50.0f;
s16 phi_v1_4 = offset + waveform;
s16 temp_a0_3 = (phi_s3->n.ob[1] - this->unk_168) * 50.0f;
if (phi_v1_4 < temp_a0_3) {
phi_v1_4 = temp_a0_3;
@ -311,22 +286,19 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
phi_s0->n.ob[1] = phi_v1_4;
} else {
temp_f14_2 = temp_f0_3 * spA8;
phi_s0->n.ob[1] = offset + waveform;
phi_s0->n.ob[1] = phi_f28 + (temp_f14_2);
phi_s0->n.ob[0] = D_80A8EE10[i].x + (s16)(waveform * 0.5f);
phi_s0->n.ob[2] = D_80A8EE10[i].z + (s16)(waveform * 0.5f);
phi_v1_4 = temp_f14_2 * 0.5f;
phi_s0->n.ob[0] = D_80A8EE10[j].x + phi_v1_4;
phi_s0->n.ob[2] = D_80A8EE10[j].z + phi_v1_4;
phi_v1_4 = temp_f14_2;
phi_s3->n.ob[0] = D_80A8EE10[j].x + phi_v1_4;
phi_s3->n.ob[2] = D_80A8EE10[j].z + phi_v1_4;
phi_s3->n.ob[0] = D_80A8EE10[i].x + (s16)waveform;
phi_s3->n.ob[2] = D_80A8EE10[i].z + (s16)waveform;
}
}
// address: ac4 ~ bb8
if (!this->unk_174) {
u16 dayTime;
this->dyna.actor.velocity.y = 0.0f;
this->dyna.actor.world.pos.y = this->unk_168;
@ -339,69 +311,54 @@ void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx) {
this->unk_170 = 1000.0f;
} else {
Math_ApproachF(&this->dyna.actor.world.pos.y, this->unk_168 - 1000.0f, 1.0f, this->dyna.actor.velocity.y);
//! Note to whoever tries to match this function:
//! daytime commonly needs the (void)0 trick.
//! could help with the temp above and some of these other memes.
//! -fig02 (https://github.com/zeldaret/oot/pull/713#discussion_r593921251)
if (!gSaveContext.dayTime) {
if (1) {}
if (1) {}
if (1) {}
if (1) {}
}
Math_ApproachF(&this->dyna.actor.velocity.y, 5.0f, 1.0f, 0.5f);
Math_ApproachF(&this->shadowAlpha, 0.0f, 1.0f, 3.0f);
Math_ApproachF(&this->unk_170, -5000.0f, 1.0f, 100.0f);
}
// address: bbc
phi_s0_3 = phi_s0_2;
if (1) {}
if (1) {}
phi_s0 = phi_s0_2;
sp108.x = 0.0f;
sp108.y = 0.0f;
sp108.z = 120.0f;
// Fancy math to smooth each part of the wave considering its neighborhood.
for (j = 0; j < ARRAY_COUNT(gJsjutanCarpetOddVtx); j++, phi_s0_3++) {
for (i = 0; i < ARRAY_COUNT(gJsjutanCarpetOddVtx); i++, phi_s0++) {
f32 rotX;
f32 rotZ;
s32 pad;
// Carpet size is 12x12.
if ((j % 12) == 11) { // Last column.
index = j - 1;
phi_f22 = phi_s0_3->n.ob[2] - phi_s0_2[index].n.ob[2];
if ((i % 12) == 11) { // Last column.
j = i - 1;
dzVtx = phi_s0->n.ob[2] - phi_s0_2[j].n.ob[2];
} else {
index = j + 1;
phi_f22 = phi_s0_2[index].n.ob[2] - phi_s0_3->n.ob[2];
j = i + 1;
dzVtx = phi_s0_2[j].n.ob[2] - phi_s0->n.ob[2];
}
temp_f0_3 = phi_s0_2[index].n.ob[1] - phi_s0_3->n.ob[1];
dyVtx = phi_s0_2[j].n.ob[1] - phi_s0->n.ob[1];
phi_f22 = Math_Atan2F(phi_f22, temp_f0_3);
rotX = Math_Atan2F(dzVtx, dyVtx);
if (j >= 132) { // Last row.
index = j - 12;
aux_f20 = phi_s0_3->n.ob[0] - phi_s0_2[index].n.ob[0];
if (i >= 132) { // Last row.
j = i - 12;
dxVtx = phi_s0->n.ob[0] - phi_s0_2[j].n.ob[0];
} else {
index = j + 12;
aux_f20 = phi_s0_2[index].n.ob[0] - phi_s0_3->n.ob[0];
j = i + 12;
dxVtx = phi_s0_2[j].n.ob[0] - phi_s0->n.ob[0];
}
aux_f20 = Math_Atan2F(aux_f20, temp_f0_3);
rotZ = Math_Atan2F(dxVtx, dyVtx);
Matrix_RotateX(phi_f22, MTXMODE_NEW);
Matrix_RotateZ(aux_f20, MTXMODE_APPLY);
Matrix_RotateX(rotX, MTXMODE_NEW);
Matrix_RotateZ(rotZ, MTXMODE_APPLY);
Matrix_MultVec3f(&sp108, &spFC);
phi_s0_3->n.n[0] = spFC.x;
phi_s0_3->n.n[1] = spFC.y;
phi_s0_3->n.n[2] = spFC.z;
phi_s0->n.n[0] = spFC.x;
phi_s0->n.n[1] = spFC.y;
phi_s0->n.n[2] = spFC.z;
}
}
#else
void func_80A89A6C(EnJsjutan* this, GlobalContext* globalCtx);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Jsjutan/func_80A89A6C.s")
#endif
void EnJsjutan_Update(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2;
@ -423,12 +380,12 @@ void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) {
thisx->world.pos.y = parent->world.pos.y;
thisx->world.pos.z = parent->world.pos.z;
this->unk_168 = thisx->world.pos.y;
if (this->unk_175 == 0) {
this->unk_175 = 1;
if (!this->unk_175) {
this->unk_175 = true;
func_80A89860(this, globalCtx);
}
} else if (this->unk_175 == 0) {
this->unk_175 = 1;
} else if (!this->unk_175) {
this->unk_175 = true;
thisx->world.pos.x = Math_SinS(parent->shape.rot.y) * 60.0f + parent->world.pos.x;
thisx->world.pos.y = (parent->world.pos.y + 5.0f) - 10.0f;
thisx->world.pos.z = Math_CosS(parent->shape.rot.y) * 60.0f + parent->world.pos.z;
@ -437,8 +394,8 @@ void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) {
}
func_80A89A6C(this, globalCtx);
if (this->unk_164 != 0) {
this->unk_164 = 0;
if (this->unk_164) {
this->unk_164 = false;
for (i = 0; i < ARRAY_COUNT(gJsjutanShadowTex); i++) {
if (((u16*)gJsjutanCarpetTex)[i] != 0) { // Hack to bypass ZAPD exporting textures as u64.
gJsjutanShadowTex[i] = 0xFF;

View file

@ -185,21 +185,17 @@ void EnTr_ChooseAction2(EnTr* this, GlobalContext* globalCtx) {
}
void EnTr_FlyKidnapCutscene(EnTr* this, GlobalContext* globalCtx) {
Vec3f originalPos;
s16 actionIndex;
Vec3f originalPos = this->actor.world.pos;
originalPos = this->actor.world.pos;
if (globalCtx->csCtx.state != CS_STATE_IDLE) {
actionIndex = this->actionIndex;
if (globalCtx->csCtx.npcActions[actionIndex] != NULL) {
if (globalCtx->csCtx.npcActions[actionIndex]->action == 8) {
func_80B24038(this, globalCtx, actionIndex);
if (globalCtx->csCtx.npcActions[this->actionIndex] != NULL) {
if (globalCtx->csCtx.npcActions[this->actionIndex]->action == 8) {
func_80B24038(this, globalCtx, this->actionIndex);
this->actor.world.rot.y = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x);
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 10, 0x400, 0x100);
this->actor.world.rot.y = this->actor.shape.rot.y;
} else {
EnTr_SetStartPosRot(this, globalCtx, actionIndex);
EnTr_SetStartPosRot(this, globalCtx, this->actionIndex);
this->actor.world.pos.x += Math_SinS(this->timer) * 150.0f;
this->actor.world.pos.y += -100.0f;
this->actor.world.pos.z += Math_CosS(this->timer) * 150.0f;
@ -226,16 +222,12 @@ void func_80B23254(EnTr* this, GlobalContext* globalCtx, s32 arg2, f32 arg3, f32
Vec3f sp58;
Color_RGBA8* primColor;
Color_RGBA8* envColor;
Vec3f cameraEye;
s16 yaw;
s16 reversePitch;
Vec3f cameraEye = ACTIVE_CAM->eye;
s16 yaw = Math_Vec3f_Yaw(&cameraEye, &this->actor.world.pos);
s16 reversePitch = -Math_Vec3f_Pitch(&cameraEye, &this->actor.world.pos);
f32 sp3C;
cameraEye = ACTIVE_CAM->eye;
yaw = Math_Vec3f_Yaw(&cameraEye, &this->actor.world.pos);
reversePitch = -Math_Vec3f_Pitch(&cameraEye, &this->actor.world.pos);
accel.z = 0.0f;
accel.x = 0.0f;
accel.x = accel.z = 0.0f;
sp3C = Math_SinS(yaw);
velocity.x = Math_CosS(reversePitch) * (arg3 * sp3C);
velocity.y = Math_SinS(reversePitch) * arg3;
@ -258,8 +250,6 @@ void func_80B23254(EnTr* this, GlobalContext* globalCtx, s32 arg2, f32 arg3, f32
}
void EnTr_ShrinkVanish(EnTr* this, GlobalContext* globalCtx) {
s32 temp_hi;
if (this->timer >= 17) {
this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68;
} else {
@ -267,7 +257,8 @@ void EnTr_ShrinkVanish(EnTr* this, GlobalContext* globalCtx) {
Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f);
this->actor.shape.rot.y = (this->actor.shape.rot.y - (this->timer * 0x28F)) + 0x3D68;
} else if (this->timer > 0) {
temp_hi = (this->timer * 2) % 7;
s32 temp_hi = (this->timer * 2) % 7;
func_80B23254(this, globalCtx, temp_hi, 5.0f, 0.2f);
func_80B23254(this, globalCtx, (temp_hi + 1) % 7, 5.0f, 0.2f);
Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f);
@ -288,10 +279,8 @@ void EnTr_ShrinkVanish(EnTr* this, GlobalContext* globalCtx) {
}
void EnTr_Reappear(EnTr* this, GlobalContext* globalCtx) {
s32 temp_hi;
if (this->timer >= 31) {
temp_hi = (this->timer * 2) % 7;
s32 temp_hi = (this->timer * 2) % 7;
func_80B23254(this, globalCtx, temp_hi, 5.0f, 1.0f);
func_80B23254(this, globalCtx, (temp_hi + 1) % 7, 5.0f, 1.0f);
@ -383,7 +372,8 @@ void EnTr_ChooseAction1(EnTr* this, GlobalContext* globalCtx) {
EnTr_SetupAction(this, EnTr_FlyKidnapCutscene);
Animation_PlayLoop(&this->skelAnime, &D_060049C8);
this->animation = NULL;
this->timer = ((this->actor.params != TR_KOUME) ? ((u8)frames << 10) + 0x8000 : (u8)frames << 10);
this->timer =
((this->actor.params != TR_KOUME) ? ((u8)frames * 0x400) + 0x8000 : (u8)frames * 0x400);
break;
}
}
@ -452,37 +442,31 @@ void EnTr_Draw(Actor* thisx, GlobalContext* globalCtx) {
if ((globalCtx->csCtx.state == CS_STATE_IDLE) || (globalCtx->csCtx.npcActions[this->actionIndex] == 0)) {
this->actor.shape.shadowDraw = NULL;
return;
}
} else {
this->actor.shape.shadowDraw = ActorShadow_DrawCircle;
this->actor.shape.shadowDraw = ActorShadow_DrawCircle;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 840);
func_800943C8(globalCtx->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex]));
func_8002EBCC(&this->actor, globalCtx, 0);
SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount,
EnTr_OverrideLimbDraw, NULL, this);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 854);
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 840);
func_800943C8(globalCtx->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex]));
func_8002EBCC(&this->actor, globalCtx, 0);
SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable,
this->skelAnime.dListCount, EnTr_OverrideLimbDraw, NULL, this);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_tr.c", 854);
}
}
f32 func_80B23FDC(GlobalContext* globalCtx, s32 actionIndex) {
f32 phi_f2;
phi_f2 = func_8006F93C(globalCtx->csCtx.npcActions[actionIndex]->endFrame,
globalCtx->csCtx.npcActions[actionIndex]->startFrame, globalCtx->csCtx.frames);
f32 phi_f2 = func_8006F93C(globalCtx->csCtx.npcActions[actionIndex]->endFrame,
globalCtx->csCtx.npcActions[actionIndex]->startFrame, globalCtx->csCtx.frames);
phi_f2 = CLAMP_MAX(phi_f2, 1.0f);
return phi_f2;
}
#ifdef NON_MATCHING
// Major ordering issues, not making the three 0.1fs separate rodata, etc.
void func_80B24038(EnTr* this, GlobalContext* globalCtx, s32 actionIndex) {
Vec3f startPos;
Vec3f endPos;
Vec3f goalVel;
f32 temp_f0;
f32 temp_f0_2;
f32 temp_f2_2;
f32 phi_f12;
startPos.x = globalCtx->csCtx.npcActions[actionIndex]->startPos.x;
@ -495,47 +479,43 @@ void func_80B24038(EnTr* this, GlobalContext* globalCtx, s32 actionIndex) {
temp_f0 = func_80B23FDC(globalCtx, actionIndex);
goalVel.x = ((((endPos.x - startPos.x) * temp_f0) + startPos.x) - this->actor.world.pos.x) * 0.1f;
goalVel.y = ((((endPos.y - startPos.y) * temp_f0) + startPos.y) - this->actor.world.pos.y) * 0.1f;
goalVel.z = ((((endPos.z - startPos.z) * temp_f0) + startPos.z) - this->actor.world.pos.z) * 0.1f;
startPos.x = ((endPos.x - startPos.x) * temp_f0) + startPos.x;
startPos.y = ((endPos.y - startPos.y) * temp_f0) + startPos.y;
startPos.z = ((endPos.z - startPos.z) * temp_f0) + startPos.z;
temp_f0_2 = sqrtf(SQ(goalVel.x) + SQ(goalVel.y) + SQ(goalVel.z));
endPos.x = (startPos.x - this->actor.world.pos.x) * 0.1f;
endPos.y = (startPos.y - this->actor.world.pos.y) * 0.1f;
endPos.z = (startPos.z - this->actor.world.pos.z) * 0.1f;
temp_f0_2 = sqrtf(SQ(endPos.x) + SQ(endPos.y) + SQ(endPos.z));
phi_f12 = CLAMP(temp_f0_2, 0.0f, 20.0f);
if ((temp_f0_2 != phi_f12) && (temp_f0_2 != 0.0f)) {
temp_f2_2 = phi_f12 / temp_f0_2;
goalVel.x *= temp_f2_2;
goalVel.y *= temp_f2_2;
goalVel.z *= temp_f2_2;
endPos.x *= phi_f12 / temp_f0_2;
endPos.y *= phi_f12 / temp_f0_2;
endPos.z *= phi_f12 / temp_f0_2;
}
Math_StepToF(&this->actor.velocity.x, goalVel.x, 1.0f);
Math_StepToF(&this->actor.velocity.y, goalVel.y, 1.0f);
Math_StepToF(&this->actor.velocity.z, goalVel.z, 1.0f);
Math_StepToF(&this->actor.velocity.x, endPos.x, 1.0f);
Math_StepToF(&this->actor.velocity.y, endPos.y, 1.0f);
Math_StepToF(&this->actor.velocity.z, endPos.z, 1.0f);
func_8002D7EC(&this->actor);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tr/func_80B24038.s")
#endif
void EnTr_UpdateRotation(EnTr* this, GlobalContext* globalCtx, s32 actionIndex) {
s16 rotY;
s32 rotDiff;
s16 rotY = globalCtx->csCtx.npcActions[actionIndex]->rot.y;
s32 rotDiff = this->actor.world.rot.y - rotY;
s32 rotSign;
rotY = globalCtx->csCtx.npcActions[actionIndex]->rot.y;
rotDiff = this->actor.world.rot.y - rotY;
if (rotDiff < 0) {
rotDiff = 0 - rotDiff;
rotDiff = -rotDiff;
rotSign = 1;
} else {
rotSign = -1;
}
if (rotDiff >= 0x8000) {
rotSign = 0 - rotSign;
rotSign = -rotSign;
rotDiff = 0x10000 - rotDiff;
}
@ -551,6 +531,7 @@ void EnTr_SetStartPosRot(EnTr* this, GlobalContext* globalCtx, s32 actionIndex)
startPos.x = globalCtx->csCtx.npcActions[actionIndex]->startPos.x;
startPos.y = globalCtx->csCtx.npcActions[actionIndex]->startPos.y;
startPos.z = globalCtx->csCtx.npcActions[actionIndex]->startPos.z;
this->actor.world.pos = startPos;
this->actor.world.rot.y = this->actor.shape.rot.y = globalCtx->csCtx.npcActions[actionIndex]->rot.y;
}

View file

@ -75,9 +75,6 @@ unknownStruct D_80B4362C[] = {
{ 40.0f, 120.0f, 160.0f, 777.0f },
};
Vec3f D_80B4365C = { 0.0f, 0.0f, 0.0f };
Vec3f D_80B43668 = { 0.0f, 0.0f, 0.0f };
void EnYabusameMark_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnYabusameMark* this = THIS;
@ -126,20 +123,18 @@ void EnYabusameMark_Init(Actor* thisx, GlobalContext* globalCtx) {
#ifdef NON_MATCHING
// regalloc
void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) {
Vec3f effectAccel;
Vec3f effectVelocity;
Vec3f effectAccel = { 0.0f, 0.0f, 0.0f };
Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f };
Vec3f arrowHitPos;
Vec3f distanceFromCenter;
s32 pad;
s32 scoreIndex;
f32 scoreDistance100;
f32 scoreDistance60;
f32 scoreDistance30;
s32 scoreIndex;
effectAccel = D_80B4365C;
effectVelocity = D_80B43668;
if (this->collider.base.acFlags & 2) {
this->collider.base.acFlags &= ~2;
if (this->collider.base.acFlags & AC_HIT) {
this->collider.base.acFlags &= ~AC_HIT;
arrowHitPos.x = this->collider.info.bumper.hitPos.x;
arrowHitPos.y = this->collider.info.bumper.hitPos.y;
@ -151,13 +146,13 @@ void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) {
scoreIndex = 2;
distanceFromCenter.x = fabsf(D_80B435F0[this->subTypeIndex].x - arrowHitPos.x);
distanceFromCenter.y = fabsf(D_80B435F0[this->subTypeIndex].y - arrowHitPos.y);
distanceFromCenter.z = fabsf(D_80B435F0[this->subTypeIndex].z - arrowHitPos.z);
scoreDistance100 = D_80B4362C[this->typeIndex].unk_0;
scoreDistance60 = D_80B4362C[this->typeIndex].unk_4;
scoreDistance30 = D_80B4362C[this->typeIndex].unk_8;
// Needs to skip a t register somewhere around here.
distanceFromCenter.x = fabsf(D_80B435F0[this->subTypeIndex].x - arrowHitPos.x);
distanceFromCenter.y = fabsf(D_80B435F0[this->subTypeIndex].y - arrowHitPos.y);
distanceFromCenter.z = fabsf(D_80B435F0[this->subTypeIndex].z - arrowHitPos.z);
if (distanceFromCenter.x > scoreDistance100 || distanceFromCenter.y > scoreDistance100 ||
distanceFromCenter.z > scoreDistance100) {
@ -198,6 +193,8 @@ void func_80B42F74(EnYabusameMark* this, GlobalContext* globalCtx) {
}
}
#else
static Vec3f D_80B4365C = { 0.0f, 0.0f, 0.0f };
static Vec3f D_80B43668 = { 0.0f, 0.0f, 0.0f };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Yabusame_Mark/func_80B42F74.s")
#endif

View file

@ -264,16 +264,15 @@ void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) {
}
void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) {
Vec3f sp4C;
f32 sp4C[3];
f32 temp_f0;
f32 temp_f0_2;
f32 temp_f2_2;
MtxF* shieldMtx;
s32 pad;
Player* player = PLAYER;
f32* new_var;
MtxF* shieldMtx = &player->shieldMf;
this->reflectIntensity = 0.0f;
shieldMtx = &player->shieldMf;
if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->wx, shieldMtx->wy, shieldMtx->wz,
this->sourceEndRad, this->poolEndRad)) {
@ -290,16 +289,14 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) {
if (sMirRayData[this->actor.params].params & 1) {
this->reflectIntensity = 1.0f;
} else {
new_var = &sp4C.z; // permuter suggested this, does not match without
sp4C[0] = this->poolPt.x - this->sourcePt.x;
sp4C[1] = this->poolPt.y - this->sourcePt.y;
sp4C[2] = this->poolPt.z - this->sourcePt.z;
sp4C.x = this->poolPt.x - this->sourcePt.x;
sp4C.y = this->poolPt.y - this->sourcePt.y;
sp4C.z = this->poolPt.z - this->sourcePt.z;
temp_f2_2 = ((-shieldMtx->zx * sp4C.x) - (shieldMtx->zy * sp4C.y)) - (shieldMtx->zz * (*new_var));
temp_f2_2 = -shieldMtx->zx * sp4C[0] - shieldMtx->zy * sp4C[1] - shieldMtx->zz * sp4C[2];
if (temp_f2_2 < 0.0f) {
temp_f0_2 = sqrtf(SQ(sp4C.x) + SQ(sp4C.y) + SQ(*new_var));
temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2]));
if ((temp_f0 != 0.0f) && (temp_f0_2 != 0.0f)) {
this->reflectIntensity = -temp_f2_2 / (temp_f0 * temp_f0_2);
}