Skip to content

MarioMove decompilation (23/68 matching, goto-free)#89

Draft
ryanbevins wants to merge 11 commits intodoldecomp:mainfrom
ryanbevins:MarioMove
Draft

MarioMove decompilation (23/68 matching, goto-free)#89
ryanbevins wants to merge 11 commits intodoldecomp:mainfrom
ryanbevins:MarioMove

Conversation

@ryanbevins
Copy link
Contributor

@ryanbevins ryanbevins commented Mar 7, 2026

Summary

Decompilation of src/Player/MarioMove.cpp — Mario's movement, physics, and state machine logic.

  • 23/68 functions matching (MATCH), 4 additional at 100.0%
  • 27/68 functions effectively matching code
  • All goto statements removed — structured control flow only
  • Most remaining functions are 89-99% with only systemic compiler differences

Matching functions (23 MATCH + 4 at 100.0%)

Function Status Size
__sinit MATCH 764
getJumpAccelControl MATCH 28
isUnderWater MATCH 72
isWallInFront MATCH 104
getRidingMtx MATCH 124
isForceSlip MATCH 168
flowMove MATCH 88
windMove MATCH 52
onYoshi (both) MATCH 72 + 28
addVelocity MATCH 36
considerRotateJumpStart MATCH 140
canBendBody MATCH 64
setPlayerVelocity MATCH 96
checkRoofPlane MATCH 60
changePlayerDropping MATCH 88
checkAllMotions MATCH 304
dirtyLimitCheck MATCH 44
startForceJumpSound MATCH 224
getDmgMapCode MATCH 120
stateMachine MATCH 228
calcGroundMtx MATCH 440
thinkSand MATCH 156
checkPlayerAround 100.0% 116
checkGraffitoSlip 100.0% 644
thinkDirty 100.0% 428
checkPlayerAction 100.0% 108

Near-matching functions (95%+)

Most near-matches are blocked by systemic MWCC stack frame inflation — the original compiler allocates 16-40 extra bytes on the stack from inline virtual destructor expansion. All instructions match perfectly except stack offsets.

  • getJumpSlideControl 99.8%, canSquat 99.9%, setNormalAttackArea 99.7%, checkThrowObject 99.8%, checkStickRotate 99.8%, checkGroundPlane 99.8%, getOffYoshi 99.9%, makeHistory 97.7%, checkWallPlane 98.7%

Goto removal

All goto statements have been replaced with structured control flow using flag variables and nested if/else. Functions affected: thinkWaterSurface, thinkSituation, getSlideStopCatch, getSlideStopNormal, canSlipJump, isSlipStart, checkSink, changePlayerTriJump, changePlayerJumping, checkController, checkRideMovement, checkCurrentPlane, thinkParams. Some functions dropped a few percentage points from this conversion (e.g. slip functions went from MATCH to ~96%) since the original code used goto-based shared return blocks.

Known blockers for remaining functions

  • Stack frame inflation: MWCC inline expansion of virtual destructors adds phantom stack space. Affects ~30 functions.
  • Shared return block pattern: Multiple conditions branching to a single return block. Structured code can't replicate this without gotos.
  • isMarioThrough inlining: The compiler inlines TBGCheckData::isMarioThrough() at call sites while the original calls it as a function. Blocks isMarioThrough (0%) and checkWet (64.7%).
  • Register allocation: GPR/FPR numbering differences not controllable from C.

Header changes

  • include/Player/MarioMain.hpp — TMario member access and method declarations
  • include/Player/Watergun.hpp — TWaterGun field types
  • include/Player/Yoshi.hpp — TYoshi method signatures
  • include/Camera/Camera.hpp — Camera method declaration
  • include/MSound/MSound.hpp — MSoundSE declarations

🤖 Generated with Claude Code

Decompile TMario movement functions including:
- addVelocity, windMove, flowMove, setPlayerVelocity
- stateMachine, checkAllMotions, considerRotateJumpStart
- changePlayerDropping, canBendBody, dirtyLimitCheck
- checkRoofPlane, thinkSand, isForceSlip, isUnderWater
- getJumpAccelControl

Also includes partial matches for checkPlayerAction,
checkPlayerAround, onYoshi, isFrontSlip, isWallInFront,
getJumpSlideControl, and others.

Header fixes: correct return types for getJumpAccelControl,
getJumpSlideControl, getWallAngle, isWallInFront,
isForceSlip, checkAllMotions, canBendBody, checkStickRotate,
isFrontSlip, checkRoofPlane, isUnderWater, onYoshi, and
various jump/swim/wait/move/spec main functions.
@decomp-dev
Copy link

decomp-dev bot commented Mar 7, 2026

Report for GMSJ01 (924dbc4 - 7df9114)

📈 Matched code: 27.60% (+0.10%, +3500 bytes)
📈 Matched data: 30.90% (+0.07%, +436 bytes)

✅ 27 new matches
Unit Item Bytes Before After
mario/Player/MarioMove __sinit_MarioMove_cpp +764 0.00% 100.00%
mario/Player/MarioMove TMario::calcGroundMtx(const JGeometry::TVec3<float>&) +440 0.00% 100.00%
mario/Player/MarioMove TMario::checkAllMotions() +304 0.00% 100.00%
mario/Player/MarioMove .sdata2 +232 0.00% 100.00%
mario/Player/MarioMove TMario::stateMachine() +228 0.00% 100.00%
mario/Player/MarioMove MSound::startForceJumpSound(Vec*, unsigned long, float, unsigned long) +224 0.00% 100.00%
mario/Player/MarioMove .bss +184 0.00% 100.00%
mario/Player/MarioMove TMario::isForceSlip() +168 0.00% 100.00%
mario/Player/MarioMove TMario::thinkSand() +156 0.00% 100.00%
mario/Player/MarioMove TMario::considerRotateJumpStart() +140 0.00% 100.00%
mario/Player/MarioMove TMario::getRidingMtx(float(*)[4]) +124 0.00% 100.00%
mario/Player/MarioMove TMario::getDmgMapCode(int) const +120 0.00% 100.00%
mario/Player/MarioMove TMario::isWallInFront() const +104 0.00% 100.00%
mario/Player/MarioMove TMario::setPlayerVelocity(float) +96 0.00% 100.00%
mario/Player/MarioMove TMario::flowMove(const JGeometry::TVec3<float>&) +88 0.00% 100.00%
mario/Player/MarioMove TMario::changePlayerDropping(unsigned long, unsigned long) +88 0.00% 100.00%
mario/Player/MarioMove TMario::isUnderWater() const +72 0.00% 100.00%
mario/Player/MarioMove TMario::onYoshi() const +72 0.00% 100.00%
mario/Player/MarioMove TMario::canBendBody() +64 0.00% 100.00%
mario/Player/MarioMove TMario::checkRoofPlane(const Vec&, float, const TBGCheckData**) +60 0.00% 100.00%
mario/Player/MarioMove TMario::windMove(const JGeometry::TVec3<float>&) +52 0.00% 100.00%
mario/Player/MarioMove TMario::dirtyLimitCheck() +44 0.00% 100.00%
mario/Player/MarioMove TMario::addVelocity(float) +36 0.00% 100.00%
mario/Player/MarioMove TMario::getJumpAccelControl() const +28 0.00% 100.00%
mario/Player/MarioMove TYoshi::onYoshi() +28 0.00% 100.00%
mario/Player/MarioMove .rodata +16 0.00% 100.00%
mario/Player/MarioMove .ctors +4 0.00% 100.00%
📈 47 improvements in unmatched items
Unit Item Bytes Before After
mario/Player/MarioMove TMario::checkController(JDrama::TGraphics*) +2997 0.00% 86.52%
mario/Player/MarioMove TMario::setStatusToJumping(unsigned long, unsigned long) +2136 0.00% 73.56%
mario/Player/MarioMove TMario::checkCurrentPlane() +2053 0.00% 74.72%
mario/Player/MarioMove TMario::thinkWaterSurface() +1965 0.00% 89.82%
mario/Player/MarioMove TMario::thinkSituation() +1426 0.00% 93.10%
mario/Player/MarioMove TMario::checkGraffito() +1142 0.00% 76.39%
mario/Player/MarioMove TMario::playerControl(JDrama::TGraphics*) +1141 0.00% 95.45%
mario/Player/MarioMove TMario::gunExec() +810 0.00% 73.91%
mario/Player/MarioMove TMario::checkSink() +714 0.00% 89.80%
mario/Player/MarioMove TMario::changePlayerJumping(unsigned long, unsigned long) +711 0.00% 95.11%
mario/Player/MarioMove TMario::changePlayerTriJump() +699 0.00% 95.04%
mario/Player/MarioMove TMario::thinkParams() +687 0.00% 89.07%
mario/Player/MarioMove TMario::checkGraffitoSlip() +643 0.00% 99.97%
mario/Player/MarioMove TMario::checkGraffitoFire() +588 0.00% 91.88%
mario/Player/MarioMove TMario::moveRequest(const JGeometry::TVec3<float>&) +464 0.00% 71.20%
mario/Player/MarioMove TMario::thinkDirty() +427 0.00% 99.95%
mario/Player/MarioMove TMario::checkGraffitoElec() +421 0.00% 95.73%
mario/Player/MarioMove TMario::changePlayerStatus(unsigned long, unsigned long, bool) +416 0.00% 90.62%
mario/Player/MarioMove TMario::checkStickRotate(int*) +399 0.00% 99.81%
mario/Player/MarioMove TMario::throwMario(const JGeometry::TVec3<float>&, float) +398 0.00% 95.69%
mario/Player/MarioMove TMario::canSlipJump() +396 0.00% 96.26%
mario/Player/MarioMove TMario::thinkYoshiHeadCollision() +380 0.00% 83.46%
mario/Player/MarioMove TMario::checkRideMovement() +371 0.00% 51.64%
mario/Player/MarioMove TMario::getSlideStopCatch() +368 0.00% 95.99%
mario/Player/MarioMove TMario::getSlideStopNormal() +360 0.00% 95.90%
mario/Player/MarioMove TMario::isSlipStart() +352 0.00% 95.82%
mario/Player/MarioMove TMario::checkWet() +336 0.00% 64.74%
mario/Player/MarioMove TMario::thinkHeight() +308 0.00% 92.92%
mario/Player/MarioMove TMario::checkWallPlane(Vec*, float, float) +307 0.00% 98.65%
mario/Player/MarioMove TMario::makeHistory() +293 0.00% 97.72%

...and 17 more improvements in unmatched items

📉 1 regression in an unmatched item
Unit Item Bytes Before After
mario/Player/MarioDraw MarioHeadCtrl(J3DNode*, int) -22 79.44% 77.50%

Revert TMario::onYoshi() back to BOOL, TYoshi::onYoshi() back to
bool, and TMario::isWallInFront() back to bool to match upstream
declarations. These changes affected register allocation at call
sites in MarioDraw, MarioCollision, WaterGun, and MarioAutodemo.
Add canSquat, thinkDirty, getOffYoshi, checkEnforceJump, checkReturn,
getRidingMtx implementations. Fix onYoshi return type (bool), canSquat
return type (BOOL), isFrontSlip angle type, startForceJumpSound
declaration. Add includes for Watergun, LiveActor, MtxUtil, MSound,
MapData.
@ryanbevins ryanbevins changed the title MarioMove decompilation (15/68 matching) WIP: MarioMove decompilation (15/68 matching) Mar 7, 2026
ryanbevins and others added 7 commits March 7, 2026 23:24
Changing onYoshi() from BOOL to bool broke SMS_IsMarioOnYoshi (100% →
69.23%) and caused 12 regressions across MarioDraw, MarioCollision,
WaterGun, and MarioAutodemo.
…, thinkYoshiHeadCollision 83.5%)

- checkGraffitoSlip: signed comparison fix + block reorder → 100%
- thinkParams: manual inline getDmgMapCode switch + s32 type fix → 93.3%
- thinkYoshiHeadCollision: precompute JMASSin/Cos table index → 83.5%
- Revert all goto-based control flow hacks
- Clean up checkController goto to if/else
@ryanbevins ryanbevins changed the title WIP: MarioMove decompilation (15/68 matching) MarioMove decompilation (27/68 matching) Mar 10, 2026
Replace goto-based control flow with structured if/else and flag
variables across 12 functions: thinkWaterSurface, thinkSituation,
getSlideStopCatch, getSlideStopNormal, canSlipJump, isSlipStart,
and checkSink.
@ryanbevins ryanbevins changed the title MarioMove decompilation (27/68 matching) MarioMove decompilation (23/68 matching, goto-free) Mar 10, 2026
@ryanbevins ryanbevins marked this pull request as draft March 11, 2026 18:04
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