OdysseyDecomp icon indicating copy to clipboard operation
OdysseyDecomp copied to clipboard

Enemy: Implement Bubble

Open german77 opened this issue 2 months ago β€’ 21 comments

137 functions, 2782 new lines, 238KB, 7 mismatches. This PR fully implements bubble although there are some serious mismatches remaining that need to be addressed. I spent nearly two weeks trying to fix these with no avail.

~~updateLavaWave https://decomp.me/scratch/ffVkSI~~ Fixed by monster ~~tryBoundMoveWall https://decomp.me/scratch/VidWI~~ Fixed by monster ~~updateHackOnGround https://decomp.me/scratch/d5cE6~~ Fixed by monster ~~makeDisplayQuatInHackJump https://decomp.me/scratch/EE9He~~ Fixed by monster accelStick https://decomp.me/scratch/ACufd exeHackJump https://decomp.me/scratch/P9h4T ~~exeHackResetPos https://decomp.me/scratch/7bYZR~~ Fixed


This change is Reviewable


Report for 1.0 (b83d2ce - be5d520)

πŸ“ˆ Matched code: 9.90% (+0.25%, +31576 bytes)

βœ… 135 new matches
Unit Function Bytes Before After
Enemy/Bubble Bubble::receiveMsg(al::SensorMsg const*, al::HitSensor*, al::HitSensor*) +2592 0.00% 100.00%
Enemy/Bubble Bubble::control() +1816 0.00% 100.00%
Enemy/Bubble Bubble::constrainLavaDomain() +1652 0.00% 100.00%
Enemy/Bubble Bubble::init(al::ActorInitInfo const&) +1640 0.00% 100.00%
Enemy/Bubble Bubble::updateHackOnGround() +1348 0.00% 100.00%
Enemy/Bubble Bubble::exeHackResetPos() +1060 0.00% 100.00%
Enemy/Bubble Bubble::attackSensor(al::HitSensor*, al::HitSensor*) +1048 0.00% 100.00%
Enemy/Bubble Bubble::makeDisplayQuatInHackJump(sead::Quat<float> const&, sead::Quat<float> const&, sead::Quat<float> const&, bool) +916 0.00% 100.00%
Enemy/Bubble Bubble::exeHackMove() +772 0.00% 100.00%
Enemy/Bubble Bubble::exeHackInLauncher() +676 0.00% 100.00%
Enemy/Bubble Bubble::tryShiftLand() +660 0.00% 100.00%
Enemy/Bubble Bubble::exeUp() +600 0.00% 100.00%
Enemy/Bubble Bubble::tryBoundMoveWall() +600 0.00% 100.00%
Enemy/Bubble Bubble::exeDown() +584 0.00% 100.00%
Enemy/Bubble Bubble::endHackCommon() +572 0.00% 100.00%
Enemy/Bubble Bubble::updateLavaWave() +564 0.00% 100.00%
Enemy/Bubble Bubble::faceToMoveVec() +536 0.00% 100.00%
Enemy/Bubble Bubble::Bubble(char const*) +528 0.00% 100.00%
Enemy/Bubble Bubble::Bubble(char const*) +516 0.00% 100.00%
Enemy/Bubble Bubble::recalcClippingInfo() +508 0.00% 100.00%
Enemy/Bubble Bubble::exeHackLand() +484 0.00% 100.00%
Enemy/Bubble Bubble::exeReady() +472 0.00% 100.00%
Enemy/Bubble Bubble::exeWait() +436 0.00% 100.00%
Enemy/Bubble Bubble::revertTargetQuatInHackJump(sead::Quat<float>*, sead::Quat<float>*) +408 0.00% 100.00%
Enemy/Bubble Bubble::checkEffectPos() +396 0.00% 100.00%
Enemy/Bubble Bubble::headUp() +368 0.00% 100.00%
Enemy/Bubble Bubble::updateCollider() +364 0.00% 100.00%
Enemy/Bubble Bubble::tryShiftContinuousJump() +360 0.00% 100.00%
Enemy/Bubble Bubble::updateCollisionPartsMove() +352 0.00% 100.00%
Enemy/Bubble Bubble::shiftSink() +332 0.00% 100.00%

...and 105 more new matches

πŸ“ˆ 2 improvements in unmatched functions
Unit Function Bytes Before After
Enemy/Bubble Bubble::exeHackJump() +680 0.00% 25.00%
Enemy/Bubble Bubble::accelStick() +353 0.00% 25.00%

german77 avatar Sep 19 '25 20:09 german77

Report for 1.0 (0db3e9a - b9b235a)

πŸ“ˆ Matched code: 9.61% (+0.24%, +30516 bytes)

βœ… 134 new matches
Unit Function Bytes Before After
Enemy/Bubble Bubble::receiveMsg(al::SensorMsg const*, al::HitSensor*, al::HitSensor*) +2592 0.00% 100.00%
Enemy/Bubble Bubble::control() +1816 0.00% 100.00%
Enemy/Bubble Bubble::constrainLavaDomain() +1652 0.00% 100.00%
Enemy/Bubble Bubble::init(al::ActorInitInfo const&) +1640 0.00% 100.00%
Enemy/Bubble Bubble::updateHackOnGround() +1348 0.00% 100.00%
Enemy/Bubble Bubble::attackSensor(al::HitSensor*, al::HitSensor*) +1048 0.00% 100.00%
Enemy/Bubble Bubble::makeDisplayQuatInHackJump(sead::Quat<float> const&, sead::Quat<float> const&, sead::Quat<float> const&, bool) +916 0.00% 100.00%
Enemy/Bubble Bubble::exeHackMove() +772 0.00% 100.00%
Enemy/Bubble Bubble::exeHackInLauncher() +676 0.00% 100.00%
Enemy/Bubble Bubble::tryShiftLand() +660 0.00% 100.00%
Enemy/Bubble Bubble::exeUp() +600 0.00% 100.00%
Enemy/Bubble Bubble::tryBoundMoveWall() +600 0.00% 100.00%
Enemy/Bubble Bubble::exeDown() +584 0.00% 100.00%
Enemy/Bubble Bubble::endHackCommon() +572 0.00% 100.00%
Enemy/Bubble Bubble::updateLavaWave() +564 0.00% 100.00%
Enemy/Bubble Bubble::faceToMoveVec() +536 0.00% 100.00%
Enemy/Bubble Bubble::Bubble(char const*) +528 0.00% 100.00%
Enemy/Bubble Bubble::Bubble(char const*) +516 0.00% 100.00%
Enemy/Bubble Bubble::recalcClippingInfo() +508 0.00% 100.00%
Enemy/Bubble Bubble::exeHackLand() +484 0.00% 100.00%
Enemy/Bubble Bubble::exeReady() +472 0.00% 100.00%
Enemy/Bubble Bubble::exeWait() +436 0.00% 100.00%
Enemy/Bubble Bubble::revertTargetQuatInHackJump(sead::Quat<float>*, sead::Quat<float>*) +408 0.00% 100.00%
Enemy/Bubble Bubble::checkEffectPos() +396 0.00% 100.00%
Enemy/Bubble Bubble::headUp() +368 0.00% 100.00%
Enemy/Bubble Bubble::updateCollider() +364 0.00% 100.00%
Enemy/Bubble Bubble::tryShiftContinuousJump() +360 0.00% 100.00%
Enemy/Bubble Bubble::updateCollisionPartsMove() +352 0.00% 100.00%
Enemy/Bubble Bubble::shiftSink() +332 0.00% 100.00%
Enemy/Bubble Bubble::exeWaitHackFall() +332 0.00% 100.00%

...and 104 more new matches

πŸ“ˆ 3 improvements in unmatched functions
Unit Function Bytes Before After
Enemy/Bubble Bubble::exeHackJump() +680 0.00% 25.00%
Enemy/Bubble Bubble::accelStick() +353 0.00% 25.00%
Enemy/Bubble Bubble::exeHackResetPos() +265 0.00% 25.00%

decomp-dev[bot] avatar Sep 19 '25 20:09 decomp-dev[bot]

The first one matches with an asm("") hack in multiple variants: https://decomp.me/scratch/t7ZYY It is a different function than what you wrote in the description though πŸ€”

MonsterDruide1 avatar Sep 24 '25 21:09 MonsterDruide1

tryBoundMoveWall: https://decomp.me/scratch/flkzW

MonsterDruide1 avatar Sep 24 '25 21:09 MonsterDruide1

For the next one, it's somehow the memory of quat2 being reused for quat3, but I can't figure it out today.

MonsterDruide1 avatar Sep 24 '25 22:09 MonsterDruide1

Last 4 decomp.me's are broken, can you re-upload those?

MonsterDruide1 avatar Sep 25 '25 11:09 MonsterDruide1

Decompme links are reuploaded

german77 avatar Sep 25 '25 15:09 german77

This one is probably an inline function: https://decomp.me/scratch/hcTEn

MonsterDruide1 avatar Sep 26 '25 09:09 MonsterDruide1

Next one: https://decomp.me/scratch/Zu3fo

MonsterDruide1 avatar Sep 26 '25 09:09 MonsterDruide1

The other three are pretty large mismatches, can you try to minimize those further yourself or have you already tried with seemingly no result?

MonsterDruide1 avatar Sep 26 '25 09:09 MonsterDruide1

I can retry to implement them from scratch again, all 3 are difficult to follow. "exeHackResetPos" has unreachable code that I can't see on ghidra this code is called on the else condition of normalize.

On a side note I'm starting to notice a pattern in broken quat functions and I think is due to this. Vector3 the know good one since is used everywhere uses setMul, quat doesn't even have setMul in the header. I will try to fix sead but seems out of the reach of this PR since I will need to verify both decomp projects still match

    friend Quat operator*(const Quat& a, T t)
    {
        auto result = a;
        result *= t;
        return result;
    }
    friend Vector3 operator*(const Mtx33& m, const Vector3& a)
    {
        Vector3 o;
        o.setMul(m, a);
        return o;
    }

german77 avatar Sep 26 '25 17:09 german77

I fixed most of the hard math's and branching on accelStick at the cost of some logic errors but the match jumped from 80 to ~~97%~~ I will keep trying on my own https://decomp.me/scratch/ACufd

Improved up to 99.33%. There's an inline that breaks pretty much everything besides that the rest is correct.

german77 avatar Oct 07 '25 17:10 german77

Significant improvements in exeHackJump https://decomp.me/scratch/q4PQG from 77% to 90% but these require the fixes of https://github.com/open-ead/sead/pull/216 so I can't commit those ones yet in this PR. The rest seems to be some weird vector operation and stack alignment issues.

german77 avatar Oct 08 '25 18:10 german77

accelStick: note the functional difference due to the wrong jump at 2d8 / 4a0c. To fix that one, insert stickAccel.set(0.0f,0.0f,0.0f); in the early if (mIsPlayerCaptured), which however introduces new mismatches.

My best attempt: https://decomp.me/scratch/UUKsu (note that not only the mul things are wrong, but it also swapped operands at the very last add instruction) Another one: https://decomp.me/scratch/ASmoM

MonsterDruide1 avatar Oct 17 '25 22:10 MonsterDruide1

exeHackJump:

  • 1.9198622f = sead::Mathf::deg2rad(110.0f)
  • fix the stack issues by removing frontDir2 and re-using frontDir instead

Decomp.me is down, so I can't check my solution, but here's what I have at the moment:

al::addVelocity(this, -verticalVec);
f32 fVar14 = frontDir.dot(verticalVec);
sead::Vector3f x;
x = (verticalVec - frontDir * fVar14) * 0.98f;
f32 fVar16 = frontDir.dot(hackerMoveVec2);
fVar16=sead::Mathf::clamp(fVar16,0.0f,1.0f);
x += frontDir * sead::Mathf::max(fVar14 * 0.92f + cosntB * fVar16, fVar14);

al::addVelocity(this, x);
bVar1 = false;

What's the current state on the last one, did you manage to improve that one further?

MonsterDruide1 avatar Oct 17 '25 22:10 MonsterDruide1

Got the second one improved by moving around random stuff (without looking at the original, so might also be a false improvement): https://decomp.me/scratch/P9h4T

MonsterDruide1 avatar Oct 18 '25 14:10 MonsterDruide1

The third one calculates the .length() twice - I'm not able to reproduce it yet, can you replace the visible/existing calculation with a normalize(f32 target_length) as we already theorized somewhere else?

MonsterDruide1 avatar Oct 18 '25 14:10 MonsterDruide1

I forgot to update the decompme link but it does use length twice https://decomp.me/scratch/hccNN normalize2(&trans,trans.length()/180.0f);

german77 avatar Oct 18 '25 16:10 german77

Improvement! https://decomp.me/scratch/7bYZR Just some stack stuff remaining. What's the current state on the other mismatches?

MonsterDruide1 avatar Oct 23 '25 18:10 MonsterDruide1

Not much I focused lately on other long lasting issues like KaronWing and ParameterBase. I updated the PR decompme links to point to the correct decompme

AccelStick has more appropriate names although I might replace the code with logically correct instead of higher matching % exeHackJump has improved considerably. Basically waiting for sead quat fixes to be merged so I can replace all operations and attempt to fix it again.

german77 avatar Oct 23 '25 19:10 german77

Alright, then let's put it in the freezer for now: Blocked by https://github.com/open-ead/sead/pull/221

MonsterDruide1 avatar Oct 23 '25 20:10 MonsterDruide1

exeHackResetPos is finally fixed. Same change fixed some stack issues in exeHackJump but flawed math is still pretty much the issue there I haven't figured out what is doing. No updates with accelStick

The code no longer contains random inlines from sead and math util.

german77 avatar Nov 05 '25 03:11 german77