Skip to content

MoveBG: decompile MapObjRailBlock routines - #137

Open
KakarottoCake wants to merge 3 commits into
doldecomp:mainfrom
KakarottoCake:private-mwcc-mapobjrailblock
Open

MoveBG: decompile MapObjRailBlock routines#137
KakarottoCake wants to merge 3 commits into
doldecomp:mainfrom
KakarottoCake:private-mwcc-mapobjrailblock

Conversation

@KakarottoCake

@KakarottoCake KakarottoCake commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reconstruct TRailBlock::control using the project angle helpers.
  • Reconstruct TRollBlock::calcRootMatrix using JMASin/JMACos.
  • Correct TRailNode::mSpeed to the unsigned field type used by the target layout.

Matching

  • TRailBlock::control: 88.4%
  • TRollBlock::calcRootMatrix: 90.7%
  • MsWrap<float>(float, float, float): 100.0%

Verification

  • Compiled with the project MWCC 1.2.5 wrapper.
  • Ran tools/decomp-diff.py -u mario/MoveBG/MapObjRailBlock.
  • Passed clang-format 21 and git diff --check locally.
  • The private MWCC/MWCC-izer tooling was used for analysis only and is not included in this PR.

@decomp-dev

decomp-dev Bot commented Aug 11, 2026

Copy link
Copy Markdown

Report for GMSJ01 (411f124 - a17dacb)

📈 Matched code: 35.82% (+0.00%, +72 bytes)
📈 Matched data: 48.95% (+0.01%, +64 bytes)

✅ 2 new matches
Unit Item Bytes Before After
mario/MoveBG/MapObjRailBlock MsWrap<float>(float, float, float) +72 0.00% 100.00%
mario/MoveBG/MapObjRailBlock .sdata2 +11 83.33% 100.00%
📈 2 improvements in unmatched items
Unit Item Bytes Before After
mario/MoveBG/MapObjRailBlock TRailBlock::control() +1216 0.29% 88.40%
mario/MoveBG/MapObjRailBlock TRollBlock::calcRootMatrix() +283 1.27% 90.68%

Comment thread src/MoveBG/MapObjRailBlock.cpp Outdated
unk15C.x = railNode->mPitch;
unk15C.y = railNode->mYaw;
unk15C.z = railNode->mRoll;
unk150 = (unk15C.x

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is MsAngleDiff, use that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8b8607d: the three rotation deltas now use MsAngleDiff.

Comment thread src/MoveBG/MapObjRailBlock.cpp Outdated
while (angleX >= 360.0f)
angleX -= 360.0f;
while (angleX < 0.0f)
angleX += 360.0f;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is MsWrap, use it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8b8607d: the rotation normalization now uses MsWrap directly.

Comment thread src/MoveBG/MapObjRailBlock.cpp Outdated

s16 angle = unk138 * (65536.0f / 360.0f);
f32 sinV = jmaSinTable[(u16)angle >> jmaSinShift];
f32 cosV = jmaCosTable[(u16)angle >> jmaSinShift];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is JMACos

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8b8607d: the raw table accesses are now JMASin/JMACos.

Comment thread src/MoveBG/MapObjRailBlock.cpp Outdated
{
self->TRailMapObj::load(stream);
}
#pragma dont_inline off

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pragma hacks should not be used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8b8607d: the added pragma and helper shim were removed.

Comment thread src/MoveBG/MapObjRailBlock.cpp Outdated
col->setAllBGType(7);
col->setAllActor(this);
col->setAllData(unk154);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Manually inlining parent method is definitely not what the original code contained

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8b8607d: restored the TNormalLift::load call and removed the manually reproduced parent body; TWoodBlock::load is no longer changed by this PR.

@KakarottoCake
KakarottoCake force-pushed the private-mwcc-mapobjrailblock branch from d88fc1f to a17dacb Compare August 11, 2026 19:59
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