Skip to content

GC2D/SelectShine2: reconstruct the unit, match 9 of 13 functions - #240

Closed
rendable wants to merge 2 commits into
doldecomp:mainfrom
rendable:select-shine
Closed

rendable wants to merge 2 commits into
doldecomp:mainfrom
rendable:select-shine

Conversation

@rendable

Copy link
Copy Markdown

Fills in the previously empty SelectShine2.cpp and rewrites the header stub.
Nine functions match exactly; four are close but not byte-exact yet.

Function status (GMSP01):

  • 100%: ~TSelectShine, startClose, startIncrease, startDecrease,
    TSelectShineManager ctor and dtor, __sinit, TVec2::sub, TVec3::set
  • TSelectShine::TSelectShine 99.8%, TSelectShine::move 96.7%,
    TSelectShineManager::initData 96.2%, TSelectShineManager::perform 92.5%
  • TSelectShine::makeNewPosition is an empty stub; only its size (0x2c) is
    known from the map.

Header changes:

  • Fields named by offset. The old TOptionRumbleUnit* mRumbleOption[8] was
    wrong; it is now TSelectShine* mShines[8]. SelectMenu.cpp is updated at
    its 5 use sites (mShines[...]->mIsSpinning).
  • Added TSelectShineManager::getPosition, getAngle and cCenter.

Decisions worth a look. These are guesses to reach the target's codegen, and
none of the names are confirmed against the original source:

  • getShinePosition and getShineAngle are fabricated inline wrappers. They add
    one inline layer so JMASSin/JMASCos and TVec3::set / TVec2::sub stay
    out-of-line calls in perform, as in the target. See the new tip in
    docs/AGENT_MATCHING_TIPS.md.
  • bezier() in move() is a fabricated inline; each of the four y segments is
    a quadratic Bezier.
  • startIncrease and startDecrease declare two unused TVec3 locals to
    reproduce the target's 0x18 extra stack bytes.
  • getAngle uses fabsf: fabs on the atan2f result promoted the math to double,
    which the target does not do.
  • move() can read y uninitialized when unk28 >= 4.0f, and initData
    dereferences mShines[mCurrent] without a null check. Both follow the target.

Remaining mismatches: register order in move, extra TVec3 copies and larger
stack frames in initData and perform.

docs/AGENT_MATCHING_TIPS.md: adds a section on small functions staying calls
when nested more than three inline levels deep. This is flagged "Needs human
review" as AGENTS.md asks; it may not generalize, and the section can be
dropped without affecting the code.

Checks:

  • Full ninja build passes for GMSP01.
  • clang-format 21 (same version as CI) is clean on all changed files.
  • validate-symbol-order passes for GC2D/SelectShine2.

Note: open PR #189 also edits SelectMenu.cpp and still uses mRumbleOption, so
whichever lands second will need to reconcile the rename.

Generated with Claude Code

rendable and others added 2 commits September 30, 2026 11:05
A small function that would normally inline stays a call once it is nested
more than three inline levels deep. Found while matching GC2D/SelectShine2.
Flagged for human review: the rule may not generalize.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fills in the empty SelectShine2.cpp and rewrites the header stub. Matching:
~TSelectShine, startClose, startIncrease, startDecrease, the manager ctor and
dtor, __sinit, TVec2::sub and TVec3::set. Close: TSelectShine ctor (99.8%),
move (96.7%), initData (96.2%), perform (92.5%). makeNewPosition is an empty
stub; only its size is known.

Header fields are named by offset; the old mRumbleOption[8] was wrong and is
now mShines[8], with SelectMenu.cpp updated to match. getShinePosition,
getShineAngle and bezier are fabricated inline layers, and startIncrease and
startDecrease pad their stack frames with unused TVec3 locals.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Mrkol

Mrkol commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

AI PRs not polished by a programmer are not generally accepted.

@Mrkol Mrkol closed this Oct 1, 2026
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