Skip to content
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

d_a_e_ym (a.k.a. Twilight bugs) 99% equivalent (daE_YM_c::checkBeforeBg and daE_YM_c::create have regalloc issues) #2311

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

YunataSavior
Copy link
Contributor

No description provided.

@YunataSavior YunataSavior changed the title d_a_e_ym (a.k.a. Twilight bugs) WIP d_a_e_ym (a.k.a. Twilight bugs) 99% equivalent (daE_YM_c::checkBeforeBg and daE_YM_c::create have regalloc issues) Feb 28, 2025
@YunataSavior YunataSavior marked this pull request as ready for review February 28, 2025 07:42
@@ -28,7 +28,7 @@ class cBgS_LinChk : public cBgS_Chk, public cBgS_PolyInfo {
void ct();
void Set2(const cXyz*, const cXyz*, unsigned int);
void PreCalc();
void GetCross();
cXyz* GetCross() { return &mLin.GetEnd(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should return a reference, and you can remove the i_GetCross fake. be sure you've ensured no regressions by comparing a diff report before this change and after.

Comment on lines +340 to +353
int action = mAction;
if (action != ACT_WAIT && action != ACT_MOVE && action != ACT_SURPRISE && action != ACT_ATTACK && action != ACT_ATTACK_WALL) {
return 0;
}
if (field_0x6f6 != 0) {
return 0;
}
int val = field_0x6fc;
if (val != 0) {
return 0;
}
if (action != 8) {
bool truth = dComIfGp_getAttention().LockonTruth();
if (truth) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are some of these temp's necessary? they seem like they can be removed at a glance, but check if it affects regalloc

Comment on lines +450 to +507
if (mAcch.ChkGroundHit() == 0) {
return 0;
}
f32 my_val;
if (mType == 4) {
my_val = l_HIO.mSurpriseDistance + 200.0f;
} else {
if (field_0x6a9 != 0) {
my_val = l_HIO.mSurpriseDistance;
} else {
my_val = l_HIO.mSurpriseDistance + 200.0f;
}
}
if (mDistToPlayer < my_val) {
if (mSphCc.ChkCoHit()) {
cCcD_Obj* hit_obj = mSphCc.GetCoHitObj();
fopAc_ac_c* my_ac = dCc_GetAc(hit_obj->GetAc());
if (fopAcM_GetName(my_ac) == PROC_ALINK) {
if (mType == 4) {
return checkRailSurprise();
}
if (mTagPosP != NULL) {
setActionMode(ACT_FLY);
} else {
setActionMode(ACT_SURPRISE);
}
return 1;
}
}
if (mAction == ACT_ATTACK) {
return 0;
}
if (player->getSpeedF() >= 16.0f) {
field_0x6f6 = 0;
} else {
if (field_0x6f8) {
return 0;
}
if (mDistToPlayer > l_HIO.mSurpriseDistance - 100.0f) {
field_0x6f8 = 0x3c;
return 0;
}
}
if (field_0x6f6 == 0) {
if (mType == 4) {
return checkRailSurprise();
}
if (mTagPosP != NULL) {
setActionMode(ACT_FLY);
} else {
setActionMode(ACT_SURPRISE);
}
return 1;
}
} else {
field_0x6f8 = 0;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a minor style thing but i prefer separating unrelated if statement blocks with an empty line to increase readability.

if () {

} else {

}
// empty line
if () {
// . . .

if (player->checkWolfDig()) {
my_vec_0 = player->getLeftHandPos() - current.pos;
if (my_vec_0.abs() < 200.0f) {
field_0x714 &= 0xffffff7f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can usually be simplified to something like &= ~0x80

// NONMATCHING
daPy_py_c* player = daPy_getPlayerActorClass();
cXyz player_pos = player->current.pos;
attention_info.distances[2] = '<';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a ghidra-ism, should be a numerical value rather than a character

// NONMATCHING
if (mFlyType == 1) {
J3DModelData* model_data = (J3DModelData*)dComIfG_getObjectRes("E_TM", 0x11);
JUT_ASSERT(model_data != NULL, 0x1094);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these asserts are backwards, its line number first and then the assert condition. additionally, the way the condition is written does actually matter for matching debug and so should match the debug rom's string exactly. modelData != 0. variable should be renamed accordingly

}
}
if (mType == 6) {
field_0x6d0 = new cXyz[0x2d];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

putting this here but it applies generally, i like to use decimal in most places unless hex makes more sense (angles, values that come out to a clean number in hex, resource IDs for things like particles, etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants