Skip to content

overlay: three Veldin 2 functions - #172

Merged
mateuszklysz merged 3 commits into
lombyte-project:mainfrom
conor-sometimes:overlay/veldin2-batch
Oct 13, 2026
Merged

mateuszklysz merged 3 commits into
lombyte-project:mainfrom
conor-sometimes:overlay/veldin2-batch

Conversation

@conor-sometimes

Copy link
Copy Markdown
Contributor

Before

Three pending Veldin 2 (level 18) functions.

Function Bytes
FUN_L18_002d82c0 sinking platform update 1104
FUN_L18_002fc100 sentry update 988
FUN_L18_002f0390 glow trail draw callback 816

After

All three are exact (2,908 bytes). One commit per function, each gated, and the branch gated again on current main (#171).

Things worth a look

  • FUN_L18_002d82c0 is ported from rac1-decomp's nonmatching draft (nonmatching/l18_veldin2/func_L18_002D96B0.c), with the usual Ported from comment, then finished here: case 3 keeps the scaled rate in its own variable (reusing t swapped the multiply's operands), and case 5 gets its own ratio and writes each gravity arm out in full, which gives retail's shared tail and registers.
  • FUN_L18_002fc100 needed no file split. Retail reads D_L18_0015F5C4 / D_L18_0015F5CC only in branch delay slots, where the assembler (nomacro) can't expand a lui+lw and goes through $gp without a known size. So both stay plain externs with no sda attribute, and the other functions in the file keep their lui accesses. The rest ports the old exact draft onto decomp: recover names for functions, globals and struct fields #165's names (glow_color, collision, hit_slot); its extern is now (struct Moby *), with a cast at the FUN_L18_002fbb98 call site.
  • FUN_L18_002f0390 follows upstream's FUN_L18_002f1fd8 (struct GeometryQuad quads[16], plain for loops). The moby search is a goto loop, like the matched FUN_L16_002ceca8, which keeps the *p reload inside the loop for the branch delay slot; the draw loop gets its own counter; the colour argument is i + 1 - (j >> 1).

Verification

  • make elf ends with PASS: reconstructed boot ELF matches retail
  • make overlays ends with PASS: all 2782 overlay functions in C match retail, with their 17232 copies in other places
  • make check passes

FUN_L18_002d82c0, from the rac1-decomp draft (ported from rac1-decomp).
Case 3 writes its scaled rate to a new variable and case 5 uses its own
ratio variable with each gravity arm spelled out in full, which cross-jumps
into retail's shared tail.
FUN_L18_002f0390 in exact C. The moby search is a goto loop (no loop
notes, so the *p reload stays in the loop as retail), and the draw loop
uses its own counter so it gets a separate register from the build loop.
FUN_L18_002fc100 in exact C. D_L18_0015F5C4 and D_L18_0015F5CC stay
plain externs: retail reads them only in branch delay slots, where the
assembler (nomacro) goes through $gp anyway, so no sda declaration is
needed and the lui accesses in the rest of the file stay as they are.
@decomp-dev

decomp-dev Bot commented Oct 13, 2026

Copy link
Copy Markdown

Report for SCUS_971.99 (e934c0a - b936470)

📈 Matched code: 86.63% (+0.08%, +2908 bytes)
📈 Linked code: 86.63% (+0.08%, +2908 bytes)

✅ 3 new matches
Unit Item Bytes Before After
level_18/gameplay/entities/002a7220 FUN_L18_002d82c0 +1104 0.00% 100.00%
level_18/gameplay/vendor/002f88e8 FUN_L18_002fc100 +988 0.00% 100.00%
level_18/gameplay/vendor/002efb88 FUN_L18_002f0390 +816 0.00% 100.00%

@github-actions

Copy link
Copy Markdown

Decompilation progress

C_EXACT Change Matched bytes Functions C_FUZZY
All code 86.63 % +0.08 pp 3,072,156 / 3,546,268 B (+2,908 B) 3,936 / 4,233 (+3) 87.96 %
Boot executable 84.73 % — 298,968 / 352,840 B (—) 1,159 / 1,219 (—) 98.11 %
Game 84.26 % — 229,892 / 272,844 B (—) 865 / 905 (—) 98.40 %
SDK 86.35 % — 69,076 / 79,996 B (—) 294 / 314 (—) 97.12 %
Level overlays 86.84 % +0.09 pp 2,773,188 / 3,193,428 B (+2,908 B) 2,777 / 3,014 (+3) 86.84 %
Shared level code 78.82 % — 891,052 / 1,130,492 B (—) 1,428 / 1,583 (—) 78.82 %
Per-level code 91.24 % +0.14 pp 1,882,136 / 2,062,936 B (+2,908 B) 1,349 / 1,431 (+3) 91.24 %
3 newly matched functions (2,908 B)
Function Address Size Unit
FUN_L18_002d82c0 0x002d82c0 1,104 B level_18/gameplay/entities/002a7220
FUN_L18_002fc100 0x002fc100 988 B level_18/gameplay/vendor/002f88e8
FUN_L18_002f0390 0x002f0390 816 B level_18/gameplay/vendor/002efb88

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

@mateuszklysz mateuszklysz added the enhancement New feature or request label Oct 13, 2026
@mateuszklysz
mateuszklysz merged commit f745654 into lombyte-project:main Oct 13, 2026
3 checks passed
@conor-sometimes
conor-sometimes deleted the overlay/veldin2-batch branch October 13, 2026 17:03
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.

2 participants