-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys_math.c Rename #1258
sys_math.c Rename #1258
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why we haven't renamed those functions before.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also thoughts on doing the same for boot_80086760.c
?
Sounds good to me. Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray, this one's been a long time coming, thanks for doing it. I put it off for a long time mainly because I thought it'd actually be much worse than this, I'm surprised it's "only" about 130 files.
The comments on the mathematics functions I'd like addressed now, the rest can be added to a cleanup PR later if preferred.
src/boot_O2/boot_80086760.c
Outdated
return func_80086C70(x); | ||
} | ||
|
||
// Unused | ||
// Math_FCeilF | ||
f32 func_800867B4(f32 x) { | ||
f32 Math_FCeilF(f32 x) { | ||
return func_80086CA8(x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're doing these, you might as well name the inner ones as well (and use the same names as OoT, since this is the only place they actually occur).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nearbyint
is used in z_bgcheck.c, so there's 1 use case outside this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the weird one, wonder if it's close to the wrapper name or something.
/** | ||
* Returns a pseudo-random floating-point number between (- scale / 2) and (scale / 2). Originally in z_actor in OoT. | ||
*/ | ||
f32 randPlusMinusPoint5Scaled(f32 scale) { | ||
f32 Rand_CenteredFloat(f32 scale) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately these don't exist in DnM+ in any of the obvious places, at least, although at least we know the names of the random functions in qrand.c (which we should rename at some point):
qrand
sqrand
fqrand
fqrand2
sqrand_r
qrand_r
fqrand_r
fqrand2_r
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing a qrand.c
in the repo, what do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's currently called boot_80xxxxxx something, qrand is its actual name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh apparently it's rand.c now? No wonder I couldn't find it... it seems to be a common library file.
currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->x; | ||
currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->y; | ||
currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + limbPos->z; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep these explicit casts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an open PR looking at explicit casts (albeit not for floats) (#1266), I don't have a preference either way
@@ -1173,7 +1173,7 @@ void EnPp_BodyPart_SetupMove(EnPp* this) { | |||
this->deadBodyPartRotationalVelocity.z = (this->deadBodyPartIndex * 0x2E) + 0xFF00; | |||
if (EN_PP_GET_TYPE(&this->actor) != EN_PP_TYPE_BODY_PART_BODY) { | |||
this->actor.speed = Rand_ZeroFloat(4.0f) + 4.0f; | |||
this->actor.world.rot.y = ((s32)randPlusMinusPoint5Scaled(223.0f) + 0x1999) * this->deadBodyPartIndex; | |||
this->actor.world.rot.y = ((s32)Rand_CenteredFloat(223.0f) + 0x1999) * this->deadBodyPartIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird one, maybe 0xDF but probably not...
wobbleScale.x = 1.0f - (Math_SinF((f32)this->timer * (M_PI / 2.0f)) * 0.3f); | ||
wobbleScale.y = (Math_SinF((f32)this->timer * (M_PI / 2.0f)) * 0.3f) + 1.0f; | ||
wobbleScale.z = 1.0f - (Math_CosF((f32)this->timer * (M_PI / 2.0f)) * 0.3f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, do we care about the explicit cast here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a bit suspicious about that s16 cast but it's not that important to deal with it now.
Every function of
sys_math.c
had a comment with a name of each function. This simply follows those suggestions. If there's a reason for waiting to name these, let me know!