Skip to content

Conversation

@malvarezcastillo
Copy link
Contributor

@malvarezcastillo malvarezcastillo commented Feb 11, 2026

No description provided.

@decomp-dev
Copy link

decomp-dev bot commented Feb 11, 2026

Report for GALE01 (f54c713 - 6ef7325)

📈 Matched code: 53.19% (+0.05%, +1788 bytes)

✅ 7 new matches
Unit Item Bytes Before After
main/sysdolphin/baselib/particle hsd_80395970 +55 79.44% 100.00%
main/sysdolphin/baselib/particle hsd_8039D71C +37 94.68% 100.00%
main/sysdolphin/baselib/particle hsd_80398F0C +30 76.78% 100.00%
main/sysdolphin/baselib/particle hsd_80393E68 +19 86.86% 100.00%
main/sysdolphin/baselib/particle hsd_803956D8 +13 94.62% 100.00%
main/sysdolphin/baselib/particle hsd_8039EE24 +6 98.57% 100.00%
main/melee/it/items/itseakchain fn_802BB574 +1 99.82% 100.00%
💔 1 broken match
Unit Item Bytes Before After
main/sysdolphin/baselib/particle fn_80392CD8 -4 100.00% 99.02%
📈 49 improvements in unmatched items
Unit Item Bytes Before After
main/sysdolphin/baselib/particle hsd_8039930C +14341 0.00% 93.95%
main/sysdolphin/baselib/particle hsd_8039DAD4 +4267 0.00% 86.32%
main/sysdolphin/baselib/particle hsd_80394F48 +1434 0.00% 92.89%
main/sysdolphin/baselib/particle hsd_8039F05C +1327 0.00% 80.55%
main/sysdolphin/baselib/particle .bss +1193 79.48% 90.11%
main/sysdolphin/baselib/particle fn_80397814 +1167 0.00% 82.02%
main/sysdolphin/baselib/particle hsd_80393440 +922 0.00% 90.11%
main/sysdolphin/baselib/particle hsd_8039254C +897 0.00% 89.78%
main/sysdolphin/baselib/particle hsd_803962A8 +879 0.00% 86.53%
main/sysdolphin/baselib/particle DrawASCII +840 0.00% 90.59%
main/sysdolphin/baselib/particle hsd_80391AC8 +837 0.00% 98.73%
main/sysdolphin/baselib/particle hsd_80398C04 +773 0.00% 99.64%
main/sysdolphin/baselib/particle hsd_80395D88 +757 0.00% 80.89%
main/sysdolphin/baselib/particle hsd_80392E80 +746 0.00% 92.85%
main/sysdolphin/baselib/particle Exception_ReportCodeline +730 0.00% 99.81%
main/sysdolphin/baselib/particle hsd_80395A78 +721 0.00% 92.03%
main/sysdolphin/baselib/particle psInitDataBankLocate +687 0.00% 75.74%
main/sysdolphin/baselib/particle fn_80392A3C +588 0.00% 89.63%
main/sysdolphin/baselib/particle hsd_80396A20 +573 0.00% 95.60%
main/sysdolphin/baselib/particle hsd_80398F8C +558 0.00% 95.03%
main/sysdolphin/baselib/particle hsd_80394668 +547 0.00% 73.53%
main/sysdolphin/baselib/particle hsd_80391F28 +546 0.00% 88.12%
main/sysdolphin/baselib/particle hsd_80396E40 +516 0.00% 77.71%
main/sysdolphin/baselib/particle hsd_80397110 +495 0.00% 80.88%
main/sysdolphin/baselib/particle hsd_803966A0 +439 0.00% 96.49%
main/sysdolphin/baselib/particle hsd_80396C78 +439 0.00% 96.49%
main/sysdolphin/baselib/particle fn_80397374 +420 0.00% 98.13%
main/sysdolphin/baselib/particle hsd_803975D4 +417 0.00% 72.43%
main/sysdolphin/baselib/particle hsd_80393844 +410 0.00% 91.62%
main/sysdolphin/baselib/particle hsd_80396884 +330 0.00% 80.22%

...and 19 more improvements in unmatched items

@malvarezcastillo malvarezcastillo changed the title [WIP] Misc matches Decompile hsd_8039930C particle bytecode interpreter (93.95%) Feb 11, 2026
@malvarezcastillo malvarezcastillo changed the title Decompile hsd_8039930C particle bytecode interpreter (93.95%) Decompile all particle.c functions: 61/119 at 100%, 0 stubs remaining Feb 12, 2026
@malvarezcastillo malvarezcastillo changed the title Decompile all particle.c functions: 61/119 at 100%, 0 stubs remaining particle.c: decompile 35 stubs, push 5 to 100%, improve 52 functions Feb 12, 2026
@malvarezcastillo
Copy link
Contributor Author

malvarezcastillo commented Feb 12, 2026

fn_80392CD8 regression: 100% → 99.02%

The fn_80392CD8 code is byte-identical to the target — all 85 instructions match. The 99.02% comes from .data section offset differences in the .o file.

Root cause: On master, fn_80392CD8's string literals (the MCC error messages) were the first data in the .data section (offset 0x000). The compiler loaded the base via lis/addi and used mr r5, r31 (offset 0) for the first string. This PR decompiles functions that appear before fn_80392CD8 in the source (fn_80392A3C, DrawASCII, hsd_803921B8, etc.) — their string literals and jump tables now precede fn_80392CD8's data in .data, pushing the error strings to offset 0x84.

The compiler then generates addi r5, r31, 0x84 instead of mr r5, r31 for the first switch case — one different opcode. All other switch case offsets shift by the same 0x84 delta.

Why it's unfixable: mwcc places .data items in source order. The only fix would be either (a) reverting the new function implementations or (b) decompiling the entire particle.c TU so the full .data layout matches the target. Neither is practical. The regression will resolve naturally as more of the TU gets decompiled.

@ribbanya
Copy link
Collaborator

The regression will resolve naturally as more of the TU gets decompiled.

This conclusion is correct.

@malvarezcastillo
Copy link
Contributor Author

(still working on steering Claude to add more stuff to this PR within the particle.c scope, WIP)

@malvarezcastillo
Copy link
Contributor Author

@ribbanya I rebased this branch and your commit (619eb5c "Remove unused label and format code") got dropped in the process because it conflicted extensively with the match improvement commits that were being developed concurrently. To make up for it, I've re-applied the formatting changes in a new commit (886871c4c):

  • Ran git clang-format on particle.c
  • Reordered includes alphabetically (dolphin/pad.h before dolphin/vi.h, MSL/trigf.h moved after MetroTRK/ppc_reg.h)
  • Applied the same header line-wrapping fixes to particle.h

The loop_end: label you removed was already absent in our version. The sphere_random: and sphere_common: labels are still referenced by goto statements so they were kept.

Sorry for the force push — the formatting commit touched 1666 lines which made rebasing impractical.

@malvarezcastillo
Copy link
Contributor Author

Update: particle.c analysis complete — all remaining non-100% functions are at their ceiling

I systematically analyzed all 57 non-100% functions in particle.c by comparing target vs compiled assembly instruction-by-instruction. Every single one has byte-identical instructions — the match percentage gaps are entirely due to relocation metadata differences that cannot be fixed in C source.

The two relocation patterns causing the gaps:

  1. .bss.0 symbol naming: mwcc uses section-relative BSS relocations (.bss.0) for same-TU definitions, while the target uses named symbols (e.g., hsd_804CF810). This affects most functions that reference BSS globals.

  2. .data string literal ordering: String literals appear in a different order in the compiled .data section vs target, causing relocation offset mismatches for string references. This is a file-level ordering issue, not per-function.

Bottom line: No further C source improvements are possible for particle.c. The 91.45% .text match represents 100% instruction-level accuracy. All remaining percentage gaps are tooling artifacts from objdiff's relocation scoring.

Final stats vs master:

  • 7 NEW 100% matches
  • 51 improved functions
  • .text section: 22.57% → 91.45%
  • +1788 bytes matched code

Also pushed review fixes: normalized TODO comment format, updated all stale match percentages, and added explanatory comments.

@malvarezcastillo malvarezcastillo marked this pull request as ready for review February 13, 2026 07:56
Decompile all remaining stubbed functions in particle.c including the
large hsd_8039930C particle bytecode interpreter. Fix BSS variable
sizes (psstructs.h array bounds 64->65), improve match percentages
across 52 functions, and push 7 functions to 100% match.

All remaining non-100% functions have byte-identical instructions;
match percentage gaps are purely relocation metadata differences
(.bss.0 symbol naming and .data string ordering).

.text section: 22.57% -> 91.45% (+1788 bytes matched)
@malvarezcastillo
Copy link
Contributor Author

Bonus: Claude interpreted my ssh session kill sequence as confirmation to file an issue in objdiff

encounter/objdiff#333

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