Skip to content

overlay: match 22 level functions and define level buffers and tables in C - #181

Merged
mateuszklysz merged 46 commits into
mainfrom
decomp/exact-data-wave-2vfrft
Oct 15, 2026
Merged

mateuszklysz merged 46 commits into
mainfrom
decomp/exact-data-wave-2vfrft

Conversation

@mateuszklysz

@mateuszklysz mateuszklysz commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Before

These 22 level functions were still retail asm: FUN_L00_002cfcb8, FUN_L00_002d2158, FUN_L00_00257218, FUN_L00_00276908, FUN_L03_002c4718, FUN_L04_00295778, FUN_L05_00255208, FUN_L05_00304058, FUN_L05_0030c5b0, FUN_L06_002e8678, FUN_L06_002f7d78, FUN_L06_002f9a28, FUN_L06_00303748, FUN_L07_0030cf90, FUN_L08_002d3878, FUN_L10_002e01a8, FUN_L10_002e3a90, FUN_L10_002e8358, FUN_L10_002f5f18, FUN_L12_002e3098, FUN_L15_002cb4c8 and FUN_L15_002e5958. Many pending functions had weaker NON_MATCHING drafts than the closest candidates found. Many zero-filled buffers and constant tables were only reachable as asm labels. scripts/data-decls.py counted 720 labels that disagreed.

After

  • Exact functions. The 22 functions are exact C. Seven of them are ported from rac1-decomp, with the header that says so. The new ones have a short comment on what they do (health upgrade vendor, scene close, ammo pickup choice, bouncing spawner, sliding mover).
  • Readable names. Locals and parameters of the new functions are named by what they hold (moby, vars, target, start_color), not by register or letter. D_L03_00173F40 is typed as the CollisionHit it is.
  • Callee prototypes. Several callees declared void really return a value; declaring them int matched FUN_L10_002e8358 and FUN_L00_00276908 and brought eight drafts closer.
  • NON_MATCHING drafts. Pending functions carry their closest draft as the #else body (among them FUN_L00_002b49a8, ported from rac1-decomp, FUN_L07_00311eb8 at 2 words, FUN_L07_00314150 at 3 words and FUN_L12_002e72c0 at 4 words).
  • SN extern placement (configure.py). In an SN unit, a <name>_lui alias declared above the first sda declaration now places the .extern after the functions that read the alias, so those functions keep lui. This is documented in docs/code-cleanup.md.
  • Level data defined in C, every level that has it, with sizes from code evidence:
    • slot buffers (FUN_L00_0024f028)
    • effect, grid and debug text buffers
    • the beam ribbon point, UV and colour tables plus its quad tables (FUN_L00_002b3628)
    • the 1200-entry particle pool (FUN_L00_002d6f28)
    • the 200-entry table of FUN_L00_002df048
    • the sparkle arcs and their timers (FUN_L00_002bb558), typed as points
    • the camera state words of FUN_L00_001f6d70
  • Data labels. Labels the branch had split now share one type and name. data-decls.py reports 610, and KNOWN_CONFLICTS is lowered to match.

Verification

  • make elf ends with PASS: reconstructed boot ELF matches retail
  • make overlays ends with PASS (2844 functions, 17438 copies, 4229 level data objects)
  • make check passes
  • scripts/test_public_tools.py passes

FUN_L05_00304058, FUN_L00_002d2158, FUN_L10_002e01a8, FUN_L06_002f7d78,
FUN_L06_002f9a28 and FUN_L06_002e8678 now build from C and match retail.
FUN_L05_0030c5b0, FUN_L10_002f5f18 and FUN_L10_002e3a90 now build from C
and match retail.
Names LegRig.heading (0x6C), the turn target used while the rig is driven.
…e-2vfrft

# Conflicts:
#	src/overlays/l05/gameplay/entities/002d1688.c
#	src/overlays/l06/gameplay/entities/002b4770.c
#	src/overlays/l10/gameplay/vendor/002df270.c
#	src/overlays/shared/gameplay/entities/00297d10.c
#	src/overlays/shared/gameplay/entities/002cfcb8.c
Each draft replaces a tree draft that differed in more words or did not link; the matching build is unchanged.
@mateuszklysz mateuszklysz added the enhancement New feature or request label Oct 14, 2026 — with Claude
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Decompilation progress

C_EXACT Change Matched bytes Functions C_FUZZY
All code 89.61 % +1.16 pp 3,177,844 / 3,546,268 B (+41,008 B) 4,002 / 4,233 (+22) 90.85 %
Boot executable 85.65 % — 302,216 / 352,840 B (—) 1,163 / 1,219 (—) 98.13 %
Game 84.51 % — 230,576 / 272,844 B (—) 866 / 905 (—) 98.40 %
SDK 89.55 % — 71,640 / 79,996 B (—) 297 / 314 (—) 97.21 %
Level overlays 90.05 % +1.28 pp 2,875,628 / 3,193,428 B (+41,008 B) 2,839 / 3,014 (+22) 90.05 %
Shared level code 82.33 % +1.70 pp 930,784 / 1,130,492 B (+19,192 B) 1,454 / 1,583 (+12) 82.33 %
Per-level code 94.28 % +1.06 pp 1,944,844 / 2,062,936 B (+21,816 B) 1,385 / 1,431 (+10) 94.28 %
Data in C Change Matched bytes
All data 42.77 % +10.46 pp 5,317,823 / 12,433,372 B (+1,300,264 B)
Boot executable 2.16 % — 15,091 / 699,136 B (—)
Level overlays 45.19 % +11.08 pp 5,302,732 / 11,734,236 B (+1,300,264 B)
22 newly matched functions (41,008 B)
Function Address Size Unit
FUN_L10_002e01a8 0x002e01a8 5,652 B level_10/gameplay/vendor/002df270
FUN_L06_002f7d78 0x002f7d78 5,228 B level_06/gameplay/entities/002b4770
FUN_L06_002f9a28 0x002f9a28 3,992 B level_06/gameplay/entities/002b4770
FUN_L06_002e8678 0x002e8678 3,704 B shared/gameplay/entities/00297d10
FUN_L03_002c4718 0x002c4718 2,304 B shared/gameplay/entities/00291918
FUN_L00_002cfcb8 0x002cfcb8 2,176 B shared/gameplay/entities/002cfcb8
FUN_L10_002f5f18 0x002f5f18 1,756 B shared/gameplay/vendor/002e3de8
FUN_L05_00255208 0x00255208 1,664 B shared/ui/help/00237488
FUN_L04_00295778 0x00295778 1,644 B level_04/runtime/dma/002922d0
FUN_L15_002cb4c8 0x002cb4c8 1,520 B shared/gameplay/entities/00278fd8
FUN_L00_002d2158 0x002d2158 1,300 B shared/gameplay/entities/002cfcb8
FUN_L15_002e5958 0x002e5958 1,300 B shared/gameplay/vendor/002e5958
FUN_L08_002d3878 0x002d3878 1,276 B shared/gameplay/entities/002937a0
FUN_L07_0030cf90 0x0030cf90 1,168 B level_07/gameplay/entities/002cd2b0
FUN_L06_00303748 0x00303748 1,056 B level_06/gameplay/entities/002fd1a0
FUN_L12_002e3098 0x002e3098 900 B level_12/gameplay/entities/002bf140
FUN_L05_0030c5b0 0x0030c5b0 888 B shared/gameplay/entities/002b3840
FUN_L10_002e3a90 0x002e3a90 856 B level_10/gameplay/vendor/002df270
FUN_L05_00304058 0x00304058 712 B level_05/gameplay/entities/002d1688
FUN_L00_00276908 0x00276908 708 B shared/audio/voices/00276368
FUN_L10_002e8358 0x002e8358 608 B level_10/gameplay/vendor/002df270
FUN_L00_00257218 0x00257218 596 B shared/rendering/00250df8

Compared with main (ae03241). C_FUZZY uses main's last measurement.

@mateuszklysz
mateuszklysz marked this pull request as draft October 15, 2026 02:08
@lombyte-project lombyte-project deleted a comment from decomp-dev Bot Oct 15, 2026
@mateuszklysz mateuszklysz changed the title overlay: match 17 level functions and define level buffers and tables in C overlay: match 20 level functions and define level buffers and tables in C Oct 15, 2026
@mateuszklysz mateuszklysz changed the title overlay: match 20 level functions and define level buffers and tables in C overlay: match 22 level functions and define level buffers and tables in C Oct 15, 2026
@mateuszklysz
mateuszklysz marked this pull request as ready for review October 15, 2026 08:59
…new code

Aliases that carried another address in their name now use the known name or the right label; coll_hit in L03 was the hit point, font_print_right_2382a0 is font_print_center. Fields and locals with clear use get names.
@mateuszklysz
mateuszklysz merged commit ac357ab into main Oct 15, 2026
3 checks passed
@mateuszklysz
mateuszklysz deleted the decomp/exact-data-wave-2vfrft branch October 15, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant