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

Consistent naming for Math_ functions (#542)

* Darkmeiro decompilation

Bg_Gnd_Darkmeiro decompiled, matched, and documented.

* give this a shot

* fix conflict

* one more try

* could be useful

* whoops

* ZAP2 stuff

* ZAP why

* ZAP again

* maths

* Factoriali -> Factorial

* soon, soon

* renames

* rand

* docs

* merged

* formatting

* little more cleanup

* asm crept back in

* changes to MathF

* smooth criminal

* functions.h
This commit is contained in:
petrie911 2020-12-26 04:44:53 -06:00 committed by GitHub
parent 81c269b417
commit 8fa6cb6ff9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1329 changed files with 8413 additions and 8374 deletions

View file

@ -81,8 +81,8 @@ void EnTkEff_Update(EnTk* this) {
if (eff->timeLeft == 0) {
eff->active = 0;
}
eff->accel.x = Math_Rand_ZeroOne() * 0.4f - 0.2f;
eff->accel.z = Math_Rand_ZeroOne() * 0.4f - 0.2f;
eff->accel.x = Rand_ZeroOne() * 0.4f - 0.2f;
eff->accel.z = Rand_ZeroOne() * 0.4f - 0.2f;
eff->pos.x += eff->speed.x;
eff->pos.y += eff->speed.y;
eff->pos.z += eff->speed.z;
@ -123,13 +123,13 @@ void EnTkEff_Draw(EnTk* this, GlobalContext* globalCtx) {
gfxSetup = 1;
}
alpha = eff->timeLeft * (255.f / eff->timeTotal);
alpha = eff->timeLeft * (255.0f / eff->timeTotal);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha);
gDPPipeSync(POLY_XLU_DISP++);
Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW);
func_800D1FD4(&globalCtx->mf_11DA0);
Matrix_Scale(eff->size, eff->size, 1.f, MTXMODE_APPLY);
Matrix_Scale(eff->size, eff->size, 1.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_tk_eff.c", 140),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
@ -145,10 +145,10 @@ void EnTkEff_Draw(EnTk* this, GlobalContext* globalCtx) {
}
s32 EnTkEff_CreateDflt(EnTk* this, Vec3f* pos, u8 duration, f32 size, f32 growth, f32 yAccelMax) {
Vec3f speed = { 0.f, 0.f, 0.f };
Vec3f accel = { 0.f, 0.3f, 0.f };
Vec3f speed = { 0.0f, 0.0f, 0.0f };
Vec3f accel = { 0.0f, 0.3f, 0.0f };
accel.y += Math_Rand_ZeroOne() * yAccelMax;
accel.y += Rand_ZeroOne() * yAccelMax;
EnTkEff_Create(this, pos, &speed, &accel, duration, size, growth);
@ -170,24 +170,24 @@ static CollisionCheckInfoInit2 sColChkInfoInit = {
void EnTk_RestAnim(EnTk* this, GlobalContext* globalCtx) {
AnimationHeader* anim = &D_06002F84;
SkelAnime_ChangeAnim(&this->skelAnim, anim, 1.f, 0.f, SkelAnime_GetFrameCount(&D_06002F84), 0, -10.f);
SkelAnime_ChangeAnim(&this->skelAnim, anim, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06002F84), 0, -10.0f);
this->actionCountdown = Math_Rand_S16Offset(60, 60);
this->actor.speedXZ = 0.f;
this->actionCountdown = Rand_S16Offset(60, 60);
this->actor.speedXZ = 0.0f;
}
void EnTk_WalkAnim(EnTk* this, GlobalContext* globalCtx) {
AnimationHeader* anim = &D_06001FA8;
SkelAnime_ChangeAnim(&this->skelAnim, anim, 1.f, 0.f, SkelAnime_GetFrameCount(&D_06002F84), 0, -10.f);
SkelAnime_ChangeAnim(&this->skelAnim, anim, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06002F84), 0, -10.0f);
this->actionCountdown = Math_Rand_S16Offset(240, 240);
this->actionCountdown = Rand_S16Offset(240, 240);
}
void EnTk_DigAnim(EnTk* this, GlobalContext* globalCtx) {
AnimationHeader* anim = &D_06001144;
SkelAnime_ChangeAnim(&this->skelAnim, anim, 1.f, 0.f, SkelAnime_GetFrameCount(&D_06001144), 0, -10.f);
SkelAnime_ChangeAnim(&this->skelAnim, anim, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06001144), 0, -10.0f);
if (EnTk_CheckNextSpot(this, globalCtx) >= 0) {
this->validDigHere = 1;
@ -200,9 +200,9 @@ void EnTk_UpdateEyes(EnTk* this) {
if (this->eyeTextureIdx > 2) {
this->blinkCycles--;
if (this->blinkCycles < 0) {
this->blinkCountdown = Math_Rand_S16Offset(30, 30);
this->blinkCountdown = Rand_S16Offset(30, 30);
this->blinkCycles = 2;
if (Math_Rand_ZeroOne() > 0.5f) {
if (Rand_ZeroOne() > 0.5f) {
this->blinkCycles++;
}
}
@ -215,7 +215,7 @@ s32 EnTk_CheckFacingPlayer(EnTk* this) {
s16 v0;
s16 v1;
if (this->actor.xyzDistFromLinkSq > 10000.f) {
if (this->actor.xyzDistFromLinkSq > 10000.0f) {
return 0;
}
@ -251,7 +251,7 @@ s32 EnTk_CheckNextSpot(EnTk* this, GlobalContext* globalCtx) {
dy = prop->posRot.pos.y - this->actor.groundY;
dxz = func_8002DB8C(&this->actor, prop);
if (dxz > 40.f || dy > 10.f) {
if (dxz > 40.0f || dy > 10.0f) {
prop = prop->next;
continue;
}
@ -270,36 +270,36 @@ void EnTk_CheckCurrentSpot(EnTk* this) {
if (this->currentSpot != NULL) {
dy = this->currentSpot->posRot.pos.y - this->actor.groundY;
dxz = func_8002DB8C(&this->actor, this->currentSpot);
if (dxz > 40.f || dy > 10.f) {
if (dxz > 40.0f || dy > 10.0f) {
this->currentSpot = NULL;
}
}
}
f32 EnTk_Step(EnTk* this, GlobalContext* globalCtx) {
f32 stepFrames[] = { 36.f, 10.f };
f32 stepFrames[] = { 36.0f, 10.0f };
f32 a1_;
s32 i;
if (this->skelAnim.animCurrentFrame == 0.f || this->skelAnim.animCurrentFrame == 25.f) {
if (this->skelAnim.animCurrentFrame == 0.0f || this->skelAnim.animCurrentFrame == 25.0f) {
Audio_PlayActorSound2(&this->actor, NA_SE_EN_MORIBLIN_WALK);
}
if (this->skelAnim.animation != &D_06001FA8) {
return 0.f;
return 0.0f;
}
a1_ = this->skelAnim.animCurrentFrame;
for (i = 0; i < ARRAY_COUNT(stepFrames); i++) {
if (a1_ < stepFrames[i] + 12.f && a1_ >= stepFrames[i]) {
if (a1_ < stepFrames[i] + 12.0f && a1_ >= stepFrames[i]) {
break;
}
}
if (i >= ARRAY_COUNT(stepFrames)) {
return 0.f;
return 0.0f;
} else {
a1_ = (0x8000 / 12.f) * (a1_ - stepFrames[i]);
return Math_Sins(a1_) * 2.f;
a1_ = (0x8000 / 12.0f) * (a1_ - stepFrames[i]);
return Math_SinS(a1_) * 2.0f;
}
}
@ -320,10 +320,10 @@ s32 EnTk_Orient(EnTk* this, GlobalContext* globalCtx) {
dx = point->x - this->actor.posRot.pos.x;
dz = point->z - this->actor.posRot.pos.z;
Math_SmoothScaleMaxMinS(&this->actor.shape.rot.y, Math_atan2f(dx, dz) * (0x8000 / M_PI), 10, 1000, 1);
Math_SmoothStepToS(&this->actor.shape.rot.y, Math_FAtan2F(dx, dz) * (0x8000 / M_PI), 10, 1000, 1);
this->actor.posRot.rot = this->actor.shape.rot;
if (SQ(dx) + SQ(dz) < 10.f) {
if (SQ(dx) + SQ(dz) < 10.0f) {
this->currentWaypoint++;
if (this->currentWaypoint >= path->count) {
this->currentWaypoint = 0;
@ -406,7 +406,7 @@ s32 EnTk_ChooseReward(EnTk* this) {
f32 luck;
s32 reward;
luck = Math_Rand_ZeroOne();
luck = Rand_ZeroOne();
if (luck < 0.4f) {
reward = 0;
@ -469,15 +469,15 @@ s32 EnTk_ChooseReward(EnTk* this) {
}
void EnTk_DigEff(EnTk* this) {
Vec3f pos = { 0.f, 0.f, 0.f };
Vec3f speed = { 0.f, 0.f, 0.f };
Vec3f accel = { 0.f, 0.3f, 0.f };
Vec3f pos = { 0.0f, 0.0f, 0.0f };
Vec3f speed = { 0.0f, 0.0f, 0.0f };
Vec3f accel = { 0.0f, 0.3f, 0.0f };
if (this->skelAnim.animCurrentFrame >= 32.f && this->skelAnim.animCurrentFrame < 40.f) {
pos.x = (Math_Rand_ZeroOne() - 0.5f) * 12.f + this->v3f_304.x;
pos.y = (Math_Rand_ZeroOne() - 0.5f) * 8.f + this->v3f_304.y;
pos.z = (Math_Rand_ZeroOne() - 0.5f) * 12.f + this->v3f_304.z;
EnTkEff_CreateDflt(this, &pos, 12, 0.2f, 0.1f, 0.f);
if (this->skelAnim.animCurrentFrame >= 32.0f && this->skelAnim.animCurrentFrame < 40.0f) {
pos.x = (Rand_ZeroOne() - 0.5f) * 12.0f + this->v3f_304.x;
pos.y = (Rand_ZeroOne() - 0.5f) * 8.0f + this->v3f_304.y;
pos.z = (Rand_ZeroOne() - 0.5f) * 12.0f + this->v3f_304.z;
EnTkEff_CreateDflt(this, &pos, 12, 0.2f, 0.1f, 0.0f);
}
}
@ -485,10 +485,10 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) {
EnTk* this = THIS;
s32 pad;
ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawFunc_Circle, 24.f);
ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawFunc_Circle, 24.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnim, &D_0600BE40, NULL, this->hz_22A, this->hz_296, 18);
SkelAnime_ChangeAnim(&this->skelAnim, &D_06002F84, 1.f, 0.f, SkelAnime_GetFrameCount(&D_06002F84), 0, 0.f);
SkelAnime_ChangeAnim(&this->skelAnim, &D_06002F84, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06002F84), 0, 0.0f);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
@ -532,7 +532,7 @@ void EnTk_Rest(EnTk* this, GlobalContext* globalCtx) {
return;
}
func_800343CC(globalCtx, &this->actor, &this->h_1E0, this->collider.dim.radius + 30.f, func_80B1C54C,
func_800343CC(globalCtx, &this->actor, &this->h_1E0, this->collider.dim.radius + 30.0f, func_80B1C54C,
func_80B1C5A0);
} else if (EnTk_CheckFacingPlayer(this) != 0) {
v1 = this->actor.shape.rot.y;
@ -540,7 +540,7 @@ void EnTk_Rest(EnTk* this, GlobalContext* globalCtx) {
v1 = this->actor.yawTowardsLink - v1;
this->actionCountdown = 0;
func_800343CC(globalCtx, &this->actor, &this->h_1E0, this->collider.dim.radius + 30.f, func_80B1C54C,
func_800343CC(globalCtx, &this->actor, &this->h_1E0, this->collider.dim.radius + 30.0f, func_80B1C54C,
func_80B1C5A0);
} else if (func_8002F194(&this->actor, globalCtx) != 0) {
v1 = this->actor.shape.rot.y;
@ -559,7 +559,7 @@ void EnTk_Rest(EnTk* this, GlobalContext* globalCtx) {
}
a1_ = CLAMP(-v1, 1270, 10730);
Math_SmoothScaleMaxMinS(&this->headRot, a1_, 6, 1000, 1);
Math_SmoothStepToS(&this->headRot, a1_, 6, 1000, 1);
}
void EnTk_Walk(EnTk* this, GlobalContext* globalCtx) {
@ -570,7 +570,7 @@ void EnTk_Walk(EnTk* this, GlobalContext* globalCtx) {
} else {
this->actor.speedXZ = EnTk_Step(this, globalCtx);
EnTk_Orient(this, globalCtx);
Math_SmoothScaleMaxMinS(&this->headRot, 0, 6, 1000, 1);
Math_SmoothStepToS(&this->headRot, 0, 6, 1000, 1);
EnTk_CheckCurrentSpot(this);
DECR(this->actionCountdown);
@ -594,16 +594,16 @@ void EnTk_Dig(EnTk* this, GlobalContext* globalCtx) {
EnTk_DigEff(this);
if (this->skelAnim.animCurrentFrame == 32.f) {
if (this->skelAnim.animCurrentFrame == 32.0f) {
/* What's gonna come out? */
Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIG_UP);
this->rewardTimer = 0;
if (this->validDigHere == 1) {
rewardOrigin.x = 0.f;
rewardOrigin.y = 0.f;
rewardOrigin.z = -40.f;
rewardOrigin.x = 0.0f;
rewardOrigin.y = 0.0f;
rewardOrigin.z = -40.0f;
Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW);
Matrix_MultVec3f(&rewardOrigin, &rewardPos);
@ -628,7 +628,7 @@ void EnTk_Dig(EnTk* this, GlobalContext* globalCtx) {
}
}
if (this->skelAnim.animCurrentFrame >= 32.f && this->rewardTimer == 10) {
if (this->skelAnim.animCurrentFrame >= 32.0f && this->rewardTimer == 10) {
/* Play a reward sound shortly after digging */
if (this->validDigHere == 0) {
/* Bad dig spot */
@ -670,7 +670,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) {
Actor_MoveForward(&this->actor);
func_8002E4B4(globalCtx, &this->actor, 40.f, 10.f, 0.f, 5);
func_8002E4B4(globalCtx, &this->actor, 40.0f, 10.0f, 0.0f, 5);
this->actionFunc(this, globalCtx);
@ -707,8 +707,8 @@ s32 EnTk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList,
void EnTk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) {
EnTk* this = THIS;
Vec3f sp28 = { 0.f, 0.f, 4600.f };
Vec3f sp1C = { 0.f, 0.f, 0.f };
Vec3f sp28 = { 0.0f, 0.0f, 4600.0f };
Vec3f sp1C = { 0.0f, 0.0f, 0.0f };
/* Limb 16 - Jaw */
if (limbIndex == 16) {