Skip to content

overlay: decompile 17 more level functions and give globals one name each - #211

Merged
mateuszklysz merged 34 commits into
mainfrom
decomp/exact-data-wave-ubrq5f
Oct 17, 2026
Merged

mateuszklysz merged 34 commits into
mainfrom
decomp/exact-data-wave-ubrq5f

Conversation

@mateuszklysz

@mateuszklysz mateuszklysz commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Before

These 17 overlay functions were still retail asm (INCLUDE_ASM): FUN_L00_00236268, FUN_L00_002382a0, FUN_L00_002464a8, FUN_L00_002995d0, FUN_L00_002c1ad0, FUN_L00_002caf70, FUN_L00_002d09b8, FUN_L07_0030f5f0, FUN_L08_002dabf0, FUN_L08_002e3870, FUN_L10_002be858, FUN_L12_00306828, FUN_L13_00307e98, FUN_L14_002b17d8, FUN_L14_00301de8, FUN_L15_001ff938, FUN_L15_002ed068. Several drafts (walloper reset, snagglebeast, sound update) were further from retail. Many ported units gave one data label several names or types (address-suffixed aliases, short X; *(float *)&X casts), and some carried copies of shared types (Vec4_p, WalkerData_p, a second struct Moby).

After

  • All 17 functions are C and match retail. Their locals, params and fields are named by use (for example waypoint, anchor, spring_turn stiffness and damping, map scale_x/scale_y), and redundant casts are gone.
  • The walloper, snagglebeast and sound update NON_MATCHING drafts are closer to retail.
  • Each touched global has one name and one type. Header names are used where a header has them (weapon_ammo_counts, item_text_variant, big_head_cheat_enabled, level_mobys, item_defs, coll_hit, ...); the rest use the plain label or a _gp/_lui/_macro placement alias. Globals declared as short and read through *(float *)& or *(int *)& now have their real float/int type in 31 files.
  • Duplicate port types are replaced by the file's or header's own types (Vec4, WalkerData, WalkerPath, Rec_30D8E8, HudElem, struct Moby).
  • Every rename and retype was proven by compiling the unit before and after (game cc1, and SN for SN units, default and -DNON_MATCHING) and checking that the code stays the same.
  • The names main added in batch 18 are kept. KNOWN_CONFLICTS is lowered from 602 to 600.

Verification

  • make elf ends with PASS: reconstructed boot ELF matches retail
  • make overlays ends with PASS (all 2918 overlay functions, 4340 level data objects)
  • make check passes (108 tests; scripts/check-cleanup.py: no new problems)

FUN_L00_002caf70, FUN_L00_002464a8, FUN_L10_002be858, FUN_L07_0030f5f0
and FUN_L08_002e3870 now match retail.
FUN_L14_002b17d8 (plasmabot), FUN_L08_002dabf0 and FUN_L13_00307e98 now
match retail.
FUN_L00_002382a0 (quick select), FUN_L00_00236268 and FUN_L15_001ff938
come from rac1-decomp ports with their data re-paired against the
listing; FUN_L12_00306828 too. FUN_L00_002d09b8 (break_crate) finishes
the draft. shared/ui/help/001ff938.c moves to the SN units.
FUN_L15_002ed068 (giant clank pad) and FUN_L00_002995d0 (movie load setup
and GS image upload) now match.
FUN_L00_002c1ad0 (2488 bytes, 19 levels) now matches.
Plain and macro declarations for the globals the reset reads keep the
sda .extern from turning later lui loads into gp loads.
Aliases with port suffixes become the plain label, the header name or
the boot function name where the asm stays the same; parameters named
after registers get names from their use.
…e-ubrq5f

# Conflicts:
#	src/assembly/textbin/audio/voices/sound_update.c
#	src/overlays/l08/gameplay/entities/bomb.c
#	src/overlays/shared/gameplay/entities/plasmabot.c
#	src/overlays/shared/rendering/00245c28.c
#	src/overlays/shared/ui/help/001ff938.c
Ported aliases take the header or main declaration of their label, with a
cast at the use where the port read it as another type. Also names the map
archive state fields from the main draft and the L08 bomb throw locals.
@mateuszklysz mateuszklysz added the enhancement New feature or request label Oct 17, 2026 — with Claude
@github-actions

Copy link
Copy Markdown

Decompilation progress

C_EXACT Change Matched bytes Functions C_FUZZY
All code 93.36 % +1.06 pp 3,312,600 / 3,548,100 B (+37,604 B) 4,095 / 4,246 (+17) 94.56 %
Boot executable 86.26 % — 305,940 / 354,672 B (—) 1,182 / 1,232 (—) 98.26 %
Game 85.10 % — 232,860 / 273,636 B (—) 876 / 912 (—) 98.49 %
SDK 90.18 % — 73,080 / 81,036 B (—) 306 / 320 (—) 97.49 %
Level overlays 94.15 % +1.18 pp 3,006,660 / 3,193,428 B (+37,604 B) 2,913 / 3,014 (+17) 94.15 %
Shared level code 88.11 % +1.46 pp 996,020 / 1,130,492 B (+16,480 B) 1,501 / 1,583 (+11) 88.11 %
Per-level code 97.46 % +1.02 pp 2,010,640 / 2,062,936 B (+21,124 B) 1,412 / 1,431 (+6) 97.46 %
Data in C Change Matched bytes
All data 42.81 % — 5,322,477 / 12,433,372 B (—)
Boot executable 2.29 % — 16,042 / 699,136 B (—)
Level overlays 45.22 % — 5,306,435 / 11,734,236 B (—)
17 newly matched functions (37,604 B)
Function Address Size Unit
FUN_L07_0030f5f0 0x0030f5f0 6,140 B level_07/gameplay/entities/taxi_platform
FUN_L08_002e3870 0x002e3870 5,448 B level_08/gameplay/entities/bolt_thief
FUN_L13_00307e98 0x00307e98 3,700 B level_13/gameplay/entities/rocket
FUN_L14_002b17d8 0x002b17d8 3,620 B shared/gameplay/entities/plasmabot
FUN_L08_002dabf0 0x002dabf0 3,480 B level_08/gameplay/entities/bomb
FUN_L00_002d09b8 0x002d09b8 2,664 B shared/gameplay/entities/veldin_ship
FUN_L00_002c1ad0 0x002c1ad0 2,488 B shared/gameplay/entities/trespasser
FUN_L00_002382a0 0x002382a0 2,164 B shared/ui/text/002377b8
FUN_L10_002be858 0x002be858 1,936 B level_10/gameplay/entities/platform
FUN_L00_002caf70 0x002caf70 1,188 B shared/gameplay/entities/bomb
FUN_L15_001ff938 0x001ff938 1,060 B shared/ui/help/001ff938
FUN_L00_002464a8 0x002464a8 1,040 B shared/rendering/00245c28
FUN_L15_002ed068 0x002ed068 816 B shared/gameplay/entities/underwater_ring
FUN_L00_002995d0 0x002995d0 504 B shared/gameplay/entities/00295100
FUN_L00_00236268 0x00236268 492 B shared/ui/hud/hud_keep_visible
FUN_L14_00301de8 0x00301de8 444 B shared/gameplay/vendor/003015d0
FUN_L12_00306828 0x00306828 420 B level_12/gameplay/entities/003054b0

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

@mateuszklysz
mateuszklysz merged commit d893976 into main Oct 17, 2026
4 checks passed
@mateuszklysz
mateuszklysz deleted the decomp/exact-data-wave-ubrq5f branch October 17, 2026 08:32
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