Skip to content

Work on most of the remaining functions needed for vs mode - #3267

Draft
MarkMcCaskey wants to merge 31 commits into
doldecomp:masterfrom
MarkMcCaskey:match-vs-if-hsd
Draft

Work on most of the remaining functions needed for vs mode#3267
MarkMcCaskey wants to merge 31 commits into
doldecomp:masterfrom
MarkMcCaskey:match-vs-if-hsd

Conversation

@MarkMcCaskey

@MarkMcCaskey MarkMcCaskey commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

We need:
hsd_8039F05C, ifStock_802FAEC4, ifStatus_802F61FC, ifStatus_802F5EC0, ifStatus_802F4EDC, ifStock_802F98E8, ftCo_800A75DC, ftCo_800C2600, psDispParticles (off limits for this PR), hsd_8039DAD4, hsd_8039930C, lbColl_80006E58

I'm working on psdisp in #3250

I'm taking 3 100% matches and some partial matches from #3223

This PR also links ftCo_0D95 and tyfigupon just as a drive-by clean up

Passing the four HUD-colour lookups straight into gm_80160854 instead of
staging them in u8 locals removes the last differing rows.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
@MarkMcCaskey MarkMcCaskey added the ai-assisted Utilizes a LLM to do the heavy lifting label Aug 30, 2026
MarkMcCaskey and others added 2 commits August 30, 2026 13:12
The three `int[1]` counter arrays were standing in for loop bodies that the
original had in helpers: hoisting the two slot-clearing loops into one
`ifStock_ClearGObjSlots` and the stock-GObj creation plus the multi-man block
into `ifStock_CreateStockGObjs` gives the target's 0x30 frame and register
assignment. `ifStock_802FA5BC` still has to stay out of line, so the
file-scope `dont_inline` pragma becomes the `_noinline` wrapper idiom already
used elsewhere in the tree.

`ifStock_804A1ACC.x108` holds the proc GObj, so it is typed `HSD_GObj*`
rather than `int`; `ifStock_804A1774.x108` is a real int and is unchanged.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
Both the joint load and the digit-JObj lookup come from inline helpers in the
original: each site bills its own stack slot, which accounts for the 0x18 ->
0x10 pad and moves the whole r26-r30 band onto the target's assignment.
`tobj` is declared ahead of the loop counter to finish the ordering.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
@decomp-dev

decomp-dev Bot commented Aug 30, 2026

Copy link
Copy Markdown

Report for GALE01 (57cb953 - 0f5ce17)

📈 Matched code: 92.92% (+0.19%, +7560 bytes)
📈 Linked code: 77.20% (+0.67%, +25992 bytes)
📈 Matched data: 96.76% (+0.03%, +384 bytes)
📈 Linked data: 81.10% (+0.23%, +2808 bytes)

✅ 8 new matches
Unit Item Bytes Before After
main/sysdolphin/baselib/generator hsd_8039F05C +45 97.32% 100.00%
main/melee/if/ifstatus ifStatus_802F4EDC +18 99.47% 100.00%
main/sysdolphin/baselib/generator .sdata2 +11 90.20% 100.00%
main/melee/if/ifstatus ifStatus_802F5EC0 +9 98.87% 100.00%
main/melee/if/ifstatus ifStatus_802F61FC +4 99.51% 100.00%
main/melee/if/ifstock ifStock_802FAEC4 +2 99.89% 100.00%
main/sysdolphin/baselib/generator extab +2 99.11% 100.00%
main/sysdolphin/baselib/generator extabindex +1 99.40% 100.00%
📈 6 improvements in unmatched items
Unit Item Bytes Before After
main/sysdolphin/baselib/generator hsd_8039DAD4 +59 98.38% 99.57%
main/melee/if/ifstock ifStock_802F98E8 +23 97.09% 98.48%
main/melee/lb/lbcollision lbColl_80006E58 +20 97.29% 98.13%
main/sysdolphin/baselib/particle .sbss +19 47.37% 94.74%
main/melee/ft/ftafterimage ftCo_800C2600 +3 97.23% 97.34%
main/sysdolphin/baselib/particle hsd_8039930C +1 94.87% 94.87%

MarkMcCaskey and others added 25 commits August 30, 2026 13:27
97.01% -> 99.95%. The command-list entry is re-read through the global at
every field instead of being pooled into a local `HSD_PSCmdList***`, which is
what the target's reload-per-store shape asks for; `psTexGroupArray` is
addressed by name rather than by subtracting 0x30C from that pointer; and the
rect case writes the scale matrix's diagonal (xx/yy/zz) rather than
xx/zx/zy — the target's store offsets confirm the diagonal.

`ptclref_804D0E5C` is typed `HSD_PSCmdList**` to match how both this function
and the target use it, so the 32 casts that spelling would otherwise need go
away. particle.c's four index-remap sites keep their old reading with a cast
and are byte-identical.

The only rows left are the bound check's relocation: the target reads the
array symbols.txt calls `psCmdListArray`, not `psNumCmdList`.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
99.47% -> 99.93%. The colour update, the digit animation setup, and the
stored-translation read come from inline helpers; splitting them out gives the
target's call and frame shape. The two branch-local `GXColor`s copied into the
shared one are load-bearing — writing the shared local directly costs 16
points.

Two rows remain: one callee-saved web (r28 vs r24) and the staged colour's
stack slot (0x14 vs 0x40).

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
97.23% -> 97.34%. The vertex buffer holds 152 entries, not 151 plus a
PAD_STACK, which puts the staging slots at the target's displacements.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
95.39% -> 98.78%. The per-player user data is reached by walking a
`struct IfStockData*` cursor the way ifStock_802F7EFC already does in this
file, and the state struct is re-mentioned in full at each use rather than
staged in `r26`. The embedded `+=` in the first store is load-bearing:
splitting it into a typed pointer plus a store costs 3 points, and a typed
`ifStock_804A1378_x204*` costs 2.9.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
98.38% -> 99.51%. The velocity magnitude is `sqrtf`, not a hand-expanded
Newton-Raphson; the JObj matrix is `gen->jobj->mtx` rather than a raw +0x44
byte offset; and the matrix-column normalise block stages through the same
local as the velocity output, which is what the target's frame shows.

Remaining rows are stack-slot ordering for three staging floats.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
97.29% -> 97.77%, mostly by reordering the segment-dot and length-squared
accumulations to the target's operand order and by moving three float decls.

Also drops a hack: the 1.0 used across the parameter-clamp branches was being
read out of the global `lbColl_804D7A08` to keep it in a callee-saved
register. A plain `1.0F` gives the same code, so the global read and the
comment explaining it are gone.

Source taken from doldecomp#3223.

Co-authored-by: Ford Lascari <ford.lascari@gmail.com>
Both objects already matched byte-for-byte in code and data but were still
declared Linkable. Includes the `ninja apply` symbols.txt canonicalization.

Linked 76.53% -> 76.95% (1058 -> 1060 files).

`grgreens` is in the same state per objdiff but changes the DOL when flipped,
so it stays Linkable.
99.93% -> 99.96%, from the captured frame layout rather than source guessing.

The target stages the three GXColors at 0x38/0x40/0x60, high in the frame and
interleaved with 4EDC's own locals. Colours declared inside the inline are
expansion temps and always land at the bottom of the frame (0x10/0x14/0x18) --
no statement position or PAD_STACK value moves them, because inline temps are
created after every declaration in the caller. So the three GXColors have to
be 4EDC's own declarations, and the inline takes them by pointer to keep the
web boundary that gives the colour-apply block its register assignment
(hoisting the block body instead costs 42 rows).

With the colours owned by the caller, PAD_STACK(64) becomes three explicitly
sized holes: 28/4/28 reproduces the target's frame exactly (0xf8, colours at
0x38/0x40/0x60), where the single 64-byte pad cannot -- the target's dead
space is fragmented and no contiguous 64-byte run fits it.

Six rows remain: one callee-saved web on the HUD lookup, and one commutative
fadds pair.
Two rows left. The digit-init helper's Hundreds JObj was landing in r28
because its web selects one step before the Tens web, which is the one that
claims r24; naming the three JObjs separately renumbers them so the Tens web
selects first and both end on r24, as the target has it. coloring_model
confirmed the swap reaches the full 34/34 colouring before it was tried.
`ptclref_804D0E5C` is now typed `HSD_PSCmdList**`, so the four
`(HSD_PSCmdList*)` casts in efLib_Cb_PtclAppSRTHook are redundant and
clang-tidy's readability-redundant-casting fails the build on them
(WarningsAsErrors). eflib.o is byte-identical without them.
Use a full-lifetime scalar carrier to place the digit-offset accumulator in MWCC's lowering-object register band. Compensate its four-byte home in the existing pad and preserve the target final add ordering with a double-negative spelling.
Seed the retail literal-pool order behind MUST_MATCH, mark ifstatus.c Matching, and apply the linked ELF's canonical symbols. The full main.dol checksum and dtk symbol diff both pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Utilizes a LLM to do the heavy lifting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant