Skip to content

Full readability pass: every first-party function named, typed and documented - #5

Merged
Raikaru merged 67 commits into
mainfrom
readability/full-pass
Oct 20, 2026
Merged

Raikaru merged 67 commits into
mainfrom
readability/full-pass

Conversation

@Raikaru

@Raikaru Raikaru commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Second readability pass. Every matched first-party function now passes tools/recovery_quality.py on all three axes. Matching is unchanged: 6860/6860 first-party MATCH, 8101 C functions linked, both retail SHA-1s OK at every commit.

Matched first-party functions (6,860) Before After
Named (no func_/FUN_ placeholder) 6,759 (98.5%) 6,860 (100%)
Typed (no raw *(T *)(p + off), no generated locals) 5,172 (75.4%) 6,860 (100%)
Documented 6,323 (92.2%) 6,860 (100%)
Raw cast-and-offset accesses in scored bodies 14,261 0
Raw accesses in unscored static/inline helpers 86 0
File-local static inline helper definitions 1,276 260

What changed

  • Typing. Accesses were typed one at a time (access-site cast, typed local, array/stride, then layout extension by splitting padding). An access that changes codegen in every typed form is written MEMBER(type, base, Struct, member) / MEMBER_OFFSET(Struct, member) from the new include/member_access.h. These are the same byte-offset expressions, but the offset comes from the real layout, so the member is named. Each such site is measured. The former layout exceptions (linker interior aliases, interleaved tables, variable-length records) are typed now too: aliases as typed externs, tables as arrays of column structs, records as header plus flexible tail.
  • Layouts. Shared headers were only extended with same-size unions and padding splits, and every includer was re-verified for each change. One deliberate growth: BtlPacket is now its allocation-proven 0x90 bytes. Consolidated to one definition each: FclCombineWork (was also FclCombineMenu), BtlFormationState, ScrScriptWork (three private copies), SdkListState, GDataEntry, ResrcRecord, EvtEffectTable, BtlAiCommandWork (was also BtlTargetRecord) and EffGeometryBlock.
  • Helpers. Deleted 769 unused static inline helper copies. In the 500 that were still used, every call site was tried as plain C. A wrapper stays only where plain C is measured to change codegen. Order wrappers now live once in include/operand_order_internal.h (operandOrder*), offset-first address sums in include/byte_address_internal.h (byteAddressAdd). No helper name contains an address or digits.
  • Names. All remaining placeholders are named in the Atlus style. No-op callbacks are spelled <prefix><Role>Noop.
  • Scorer. recovery_quality.py used to miss definitions behind long pragma blocks or after a same-name prototype, which left two functions unscored. It now scores all 6,860. Regression tests added.
  • Docs. docs/STYLE.md covers MEMBER and the helper convention. docs/architecture.md section 13 no longer describes these systems as unnamed.

Closes #4. Model and MdlFileModel describe the same object with different extents (0x2FC/0x310/0x320) across 39 includers; merging them is left for a follow-up.

Verification

Each commit was gated on: whole-tree tools/verify.py (6860/6860 first-party MATCH), tools/build.py (8101 linked, both SHA-1s), no new decomp_lint.py errors in changed files, and the unit tests. The two libubsan-dependent field-movement tests can't run on the integration host.

MEMBER(type, base, Struct, member) expands to *(type *)(base + offsetof) with the offset from the proven layout. Measured on k_fldEvent.c: replacing eight *(s32 *)(p + 0x144) reads keeps 26/26 MATCH; casting the base to u8 * first does not, hence the verbatim-base rule. STYLE.md documents when to use it.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
… duplicate RenderWare layouts (#4)

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…nt-misc units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…nd polygon units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
… mc.c optimizer pragmas

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…ne GDataEntry (#4)

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
… and h_* wrappers

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…erimage packs (partial)

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…and HBN units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…ecord and scene resources (#4)

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…model/resources and boot sequence units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…d SDK wrapper units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
… resource-cache, scene-draw, shadow and clump units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…mitive units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…moted collision-tree helpers

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…its; canonical ScrScriptWork

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…lk and card-effect units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…el and model-effect units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…ect units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
fldFilterBeginTransition (0x00161460) and datSetClearCount (0x00110470) already carried canonical names; the definitions kept FUN_ spellings that apply_symbol_names does not rewrite.

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…election, fade and formation units

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…types

function_bodies searched a fixed 12-line window after each marker, so a definition behind a long measured pragma block went unscored, and a same-name prototype could be taken as the body. Search up to the next marker and skip declarations. All 6860 first-party matches are now scored.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
… store helper

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…yout exceptions

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…ut exceptions; one byte-address helper

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…ccesses

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…n operand_order_internal.h

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
…sona helpers

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
STYLE.md documents where measured operand-order wrappers live (operand_order_internal.h, byte_address_internal.h) and that unused helper copies are deleted. architecture.md section 13 no longer claims the listed systems are unnamed: every matched first-party function is named, typed and documented; the remaining gaps are untraced behaviour in this document.
…k definitions

First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
First-party 6860/6860 MATCH; 8101 C functions linked; both retail SHA-1s OK.
@Raikaru
Raikaru deployed to p4-proprietary October 20, 2026 19:59 — with GitHub Actions Active
@Raikaru
Raikaru deployed to p4-proprietary October 20, 2026 19:59 — with GitHub Actions Active
@decomp-dev

decomp-dev Bot commented Oct 20, 2026

Copy link
Copy Markdown

Report for SLUS_217.82 (73510e7 - a462c4b)

✅ 111 new matches
Unit Item Bytes Before After
Graphics/Model/mdlEffect_inferred_004adb50 mdlEffectUpdateModelChildTransforms +816 0.00% 100.00%
promoted/code1_0038:third_party rpCollTreeCreate +384 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetDefeatMsgCode +368 0.00% 100.00%
h_sfdply hsfdInitWorker +336 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetUnableToRecoverMsgCode +176 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetAilmentOnsetMsgCode +176 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetDownMsgCode +176 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetCriticalMsgCode +176 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetWeaknessMsgCode +176 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetSelfDownMsgCode +176 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetAffinityHitMsgCode +176 0.00% 100.00%
Battle/btlTarget_inferred_001f42a0 btlActionGetLowHpMsgCode +176 0.00% 100.00%
h_sfdply hsfdSuspendWorker +128 0.00% 100.00%
Kosaka/Field/k_fldFilter fldFilterBeginTransition +112 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendRecordBound +112 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendClear +112 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendStyledParameter +112 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendDrawLists +112 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendOpeningStep +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendActiveStep +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendClosingStep +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendRelease +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendChoiceMeasure +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendChoiceBuilt +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendChoiceOpeningStep +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendChoiceActiveStep +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendChoiceClosingStep +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendRowTransitionEnter +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendRowTransitionActive +96 0.00% 100.00%
itfMesManager_inferred_0027b7c0 itfMesWindowSendRowTransitionLeave +96 0.00% 100.00%

...and 81 more new matches

🥀 111 broken matches
Unit Item Bytes Before After
Graphics/Model/mdlEffect_inferred_004adb50 func_004adb50 -816 100.00% 0.00%
promoted/code1_0038:third_party func_0038f990 -384 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4ce0 -368 100.00% 0.00%
h_sfdply func_00466680 -336 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4380 -176 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4550 -176 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4600 -176 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f46b0 -176 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4760 -176 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4ad0 -176 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4b80 -176 100.00% 0.00%
Battle/btlTarget_inferred_001f42a0 func_001f4c30 -176 100.00% 0.00%
h_sfdply func_00466580 -128 100.00% 0.00%
Kosaka/Field/k_fldFilter FUN_00161460 -112 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027b7c0 -112 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027b830 -112 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027b8a0 -112 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027b910 -112 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027b980 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027b9e0 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027ba40 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027baa0 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027bb60 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027bbc0 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027bc20 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027bc80 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027bce0 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027bd40 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027bda0 -96 100.00% 0.00%
itfMesManager_inferred_0027b7c0 func_0027be00 -96 100.00% 0.00%

...and 81 more broken matches

@Raikaru
Raikaru merged commit 108806e into main Oct 20, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
p4-proprietary — a462c4b8 Deployed Oct 20, 2026 by Raikaru via Proprietary build and verify #2704
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.

Consolidate duplicate layouts introduced by the readability pass

1 participant