Skip to content

Correct NPC animation distance and refine collision and event code - #201

Merged
Mrkol merged 6 commits into
doldecomp:mainfrom
KakarottoCake:decomp-npc-all
Sep 28, 2026
Merged

Mrkol merged 6 commits into
doldecomp:mainfrom
KakarottoCake:decomp-npc-all

Conversation

@KakarottoCake

@KakarottoCake KakarottoCake commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Audited all 23 mario/NPC units against GMSJ01. This PR changes six NPC files:

  • Correct getAnmOffDist_: check animation kinds MAD and 0x17 and select distance 0 or 1 for the corresponding nerve state. The old code treated every nonzero kind as a match and selected the wrong distance branch.
  • Fix graph timers: pass wander bounds to MsRandI in the right order and use graph wait bounds in TNerveNPCGraphWait. Cache NPC type across two nerve callbacks.
  • Correct changeNerveProc_ talk and pollution conditions using retail control flow. Its fuzzy match goes 84.40% -> 84.55%.
  • Make evFireStartDemoCamera exact using SMSGetMarDirector(). Reuse the sunflower position for camera and shine creation.
  • Move npcRecoverFromSinking's result next to its use, and match the multiplication and horizontal displacement order in setVariableDamageRadius_.

NPC exact functions: 248/332 -> 249/332. Fuzzy: NpcChange 96.43% -> 96.45%, NpcNerve 99.09% -> 99.43%, NpcEvent 95.05% -> 95.29%, NpcAnm 99.58% -> 99.61%, NpcCollision 98.89% -> 98.97%. NpcBase 88.52% -> 88.24% because the corrected weak helper is still inlined into perform. Moving it out of line changed weak linkage and failed symbol order, so that attempt was reverted. No stack padding or dummy code was added.

Checked: native configure, bare ninja (mario.dol: OK), ninja changes_all, review-lint.py --strict (0 actionable findings), clang-format --dry-run --Werror, and check-changed-symbol-order.py (0 regressions).

@decomp-dev

decomp-dev Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Report for GMSJ01 (b7bed68 - f506557)

📈 Matched code: 41.89% (+0.05%, +1960 bytes)
📈 Matched data: 63.11% (+0.03%, +196 bytes)

✅ 11 new matches
Unit Item Bytes Before After
mario/GC2D/Guide __sinit_Guide_cpp +764 0.00% 100.00%
mario/GC2D/Guide TGuide::checkPoint(int, int) +308 0.00% 100.00%
mario/GC2D/Guide TGuide::TGuide(const char*) +232 0.00% 100.00%
mario/GC2D/Guide .bss +184 0.00% 100.00%
mario/GC2D/Guide TGuide::~TGuide() +116 0.00% 100.00%
mario/GC2D/Guide SMS_getShineID(unsigned long, unsigned long, bool) +92 0.00% 100.00%
mario/GC2D/Guide TGuide::setup(JKRMemArchive*) +92 0.00% 100.00%
mario/GC2D/Guide TGuide::startMoveCursor() +20 0.00% 100.00%
mario/NPC/NpcEvent evFireStartDemoCamera(TSpcTypedInterp<TEventWatcher>*, unsigned long) +18 94.93% 100.00%
mario/GC2D/Guide .sbss +8 0.00% 100.00%
mario/GC2D/Guide .ctors +4 0.00% 100.00%
📈 19 improvements in unmatched items
Unit Item Bytes Before After
mario/GC2D/Guide TGuide::load(JSUMemoryInputStream&) +2498 0.00% 97.45%
mario/GC2D/Guide .rodata +334 0.00% 95.14%
mario/GC2D/Guide .data +159 0.00% 76.47%
mario/GC2D/Guide .sdata2 +124 0.00% 70.59%
mario/NPC/NpcNerve TNerveNPCTurnToMario::execute(TSpineBase<TLiveActor>*) const +13 98.38% 99.87%
mario/NPC/NpcNerve TNerveNPCWaitMarioApproach::execute(TSpineBase<TLiveActor>*) const +12 97.13% 99.90%
mario/NPC/NpcEvent TNpcEvent::reviveOneSunflower() +6 80.78% 82.35%
mario/NPC/NpcAnm TBaseNPC::npcRecoverFromSinking() +5 95.06% 96.22%
mario/GC2D/Guide TGuide::resetObjects() +4 0.00% 0.44%
mario/GC2D/Guide TGuide::resetScore() +4 0.00% 0.17%
mario/GC2D/Guide TGuide::placeMario() +4 0.00% 0.67%
mario/GC2D/Guide TGuide::appearGuidePane(int) +4 0.00% 0.42%
mario/NPC/NpcChange TBaseNPC::changeNerveProc_() +3 84.40% 84.55%
mario/GC2D/Guide TGuide::linkSelect() +3 0.00% 0.13%
mario/GC2D/Guide TGuide::changeBotStatus(int) +3 0.00% 0.25%
mario/GC2D/Guide TGuide::perform(unsigned long, JDrama::TGraphics*) +3 0.00% 0.22%
mario/NPC/NpcCollision TBaseNPC::setVariableDamageRadius_() +1 97.00% 97.62%
mario/NPC/NpcNerve TNerveNPCGraphWander::execute(TSpineBase<TLiveActor>*) const 0 97.59% 97.60%
mario/NPC/NpcNerve TNerveNPCGraphWait::execute(TSpineBase<TLiveActor>*) const 0 99.43% 99.45%
📉 1 regression in an unmatched item
Unit Item Bytes Before After
mario/NPC/NpcBase TBaseNPC::perform(unsigned long, JDrama::TGraphics*) -26 63.58% 62.30%

Report for GMSP01 (b7bed68 - f506557)

📈 Matched code: 40.96% (+0.05%, +1960 bytes)
📈 Matched data: 54.92% (+0.03%, +196 bytes)

✅ 11 new matches
Unit Item Bytes Before After
mario/GC2D/Guide __sinit_Guide_cpp +764 0.00% 100.00%
mario/GC2D/Guide TGuide::checkPoint(int, int) +308 0.00% 100.00%
mario/GC2D/Guide TGuide::TGuide(const char*) +232 0.00% 100.00%
mario/GC2D/Guide .bss +184 0.00% 100.00%
mario/GC2D/Guide TGuide::~TGuide() +116 0.00% 100.00%
mario/GC2D/Guide SMS_getShineID(unsigned long, unsigned long, bool) +92 0.00% 100.00%
mario/GC2D/Guide TGuide::setup(JKRMemArchive*) +92 0.00% 100.00%
mario/GC2D/Guide TGuide::startMoveCursor() +20 0.00% 100.00%
mario/NPC/NpcEvent evFireStartDemoCamera(TSpcTypedInterp<TEventWatcher>*, unsigned long) +18 94.93% 100.00%
mario/GC2D/Guide .sbss +8 0.00% 100.00%
mario/GC2D/Guide .ctors +4 0.00% 100.00%
📈 20 improvements in unmatched items
Unit Item Bytes Before After
mario/GC2D/Guide TGuide::load(JSUMemoryInputStream&) +2498 0.00% 97.44%
mario/GC2D/Guide .rodata +325 0.00% 94.50%
mario/GC2D/Guide .data +159 0.00% 76.47%
mario/GC2D/Guide .sdata2 +124 0.00% 70.59%
mario/NPC/NpcNerve TNerveNPCTurnToMario::execute(TSpineBase<TLiveActor>*) const +13 98.38% 99.87%
mario/NPC/NpcNerve TNerveNPCWaitMarioApproach::execute(TSpineBase<TLiveActor>*) const +12 97.13% 99.90%
mario/NPC/NpcEvent TNpcEvent::reviveOneSunflower() +6 80.78% 82.35%
mario/NPC/NpcAnm TBaseNPC::npcRecoverFromSinking() +5 95.06% 96.22%
mario/GC2D/Guide TGuide::resetObjects() +4 0.00% 0.44%
mario/GC2D/Guide TGuide::resetScore() +4 0.00% 0.17%
mario/GC2D/Guide TGuide::startMoveCursor2() +4 0.00% 1.10%
mario/GC2D/Guide TGuide::appearGuidePane(int) +4 0.00% 0.42%
mario/GC2D/Guide TGuide::linkSelect() +3 0.00% 0.13%
mario/GC2D/Guide TGuide::changeBotStatus(int) +3 0.00% 0.25%
mario/GC2D/Guide TGuide::placeMario() +3 0.00% 0.66%
mario/GC2D/Guide TGuide::perform(unsigned long, JDrama::TGraphics*) +3 0.00% 0.26%
mario/NPC/NpcChange TBaseNPC::changeNerveProc_() +3 84.40% 84.55%
mario/NPC/NpcCollision TBaseNPC::setVariableDamageRadius_() +1 97.00% 97.62%
mario/NPC/NpcNerve TNerveNPCGraphWander::execute(TSpineBase<TLiveActor>*) const 0 97.59% 97.60%
mario/NPC/NpcNerve TNerveNPCGraphWait::execute(TSpineBase<TLiveActor>*) const 0 99.43% 99.45%
📉 1 regression in an unmatched item
Unit Item Bytes Before After
mario/NPC/NpcBase TBaseNPC::perform(unsigned long, JDrama::TGraphics*) -26 63.58% 62.30%

Comment thread src/NPC/NpcChange.cpp Outdated
Comment thread src/NPC/NpcChange.cpp Outdated
Comment thread src/NPC/NpcEvent.cpp Outdated
@Mrkol
Mrkol merged commit a7a99b4 into doldecomp:main Sep 28, 2026
3 checks passed
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