Skip to content

overlay: SN cc1 from source, walloper beam and more level code in C, hero names - #248

Open
mateuszklysz wants to merge 41 commits into
mainfrom
decomp/c-exact-99
Open

mateuszklysz wants to merge 41 commits into
mainfrom
decomp/c-exact-99

Conversation

@mateuszklysz

@mateuszklysz mateuszklysz commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

SN cc1 from source

The level units in OVERLAY_SN_UNITS no longer use SN's cc1.exe. They use the same compiler built from source:

  • scripts/build-sn-compiler.py builds gcc-2.95.2 with the R5900 back end of the EE archive, four patches from patches/sce-991111b/ and the seven in patches/sn-2.95.2/. setup.sh runs it (about 30 s).
  • overlay-sn runs SN's preprocessor, then this cc1. SN's driver and Ps2EeAs stay.
  • Without 0062 (the gcc-2.95.3 reload fix), the output equals cc1.exe on all 180 units. Each SN patch is needed: leaving one out changes 3 to 49 units. patches/sn-2.95.2/README.md has the details.
  • The retail level code has 0062 too. With it, FUN_L05_0030de90 (electric_gate) and FUN_L10_002dcc58 (platform) match and move to C.

Level code in C

  • walloper: build_beam_and_arc_points and draw_scrolling_ribbon_colored.
  • pyrocitor_update, the hero item slot pose update FUN_L00_0020f580, reveal_map_around_position and the nanotech ball suction tube update.
  • link_and_update_all_mobys and update_visible_resident_objects.

Near-miss drafts

  • FUN_L00_002648e0 stays in asm. Retail leaves both delay slots around the update call empty; C here always fills one.
  • FUN_L08_002f5e58 (draw_flickering_mesh_effect, commando grid), the suction tube ring loop, render_vendor_buy_label_pass, update_mpeg_frame_size, sceCdInit and _getRef0 drafts are closer to retail.

Names

  • Hero and pad fields: 333 unkXXX fields in Hero, HeroMotion, HeroItemSlot, HeroEase, HeroManipulator, HeroHealth and PadState, named from their uses.
  • 97 level functions and 23 boot functions, named from what they do. Names with level tags, hex runs or invented enemy names are left out.
  • padless-asm.py now also finds a function defined under its C name with __asm__("FUN_..."). Before, renaming such a function moved a late .extern and changed the unit's size.

make elf, make overlays, make check and check-cleanup.py pass.

@mateuszklysz mateuszklysz added the enhancement New feature or request label Oct 24, 2026 — with Claude
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Decompilation progress

C_EXACT Change Matched bytes Functions C_FUZZY
All code 99.47 % +0.54 pp 3,529,076 / 3,547,932 B (+19,072 B) 4,229 / 4,244 (+8) 99.53 %
Boot executable 99.03 % — 351,068 / 354,504 B (—) 1,224 / 1,230 (—) 99.65 %
Game 99.65 % — 272,508 / 273,476 B (—) 906 / 909 (—) 99.97 %
SDK 96.95 % — 78,560 / 81,028 B (—) 318 / 321 (—) 98.55 %
Level overlays 99.52 % +0.60 pp 3,178,008 / 3,193,428 B (+19,072 B) 3,005 / 3,014 (+8) 99.52 %
Shared level code 99.22 % +1.53 pp 1,121,708 / 1,130,492 B (+17,256 B) 1,576 / 1,583 (+6) 99.22 %
Per-level code 99.68 % +0.09 pp 2,056,300 / 2,062,936 B (+1,816 B) 1,429 / 1,431 (+2) 99.68 %
Data in C Change Matched bytes
All data 43.58 % — 5,418,333 / 12,433,372 B (—)
Boot executable 2.32 % — 16,238 / 699,136 B (—)
Level overlays 46.04 % — 5,402,095 / 11,734,236 B (—)
8 newly matched functions (19,072 B)
Function Address Size Unit
FUN_L00_002b94d0 0x002b94d0 5,280 B shared/gameplay/entities/walloper
FUN_L00_002ddf60 0x002ddf60 4,220 B shared/gameplay/entities/nanotech_ball
FUN_L00_002b77f0 0x002b77f0 2,624 B shared/gameplay/entities/devastator
FUN_L00_0020f580 0x0020f580 1,828 B shared/gameplay/hero/hero_check_damage
FUN_L00_002484e0 0x002484e0 1,808 B shared/ui/map/002484e0
FUN_L00_002be078 0x002be078 1,496 B shared/gameplay/entities/walloper
FUN_L10_002dcc58 0x002dcc58 948 B level_10/gameplay/entities/platform
FUN_L05_0030de90 0x0030de90 868 B level_05/gameplay/entities/electric_gate

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

@mateuszklysz
mateuszklysz marked this pull request as draft October 24, 2026 05:34
The exact forms needed inline asm for the update call, which PLAYBOOK
section 0 and the cleanup guide do not allow.
@mateuszklysz mateuszklysz changed the title overlay: moby update loops in C overlay: near-miss drafts for the moby update loops and electric_gate Oct 24, 2026
FUN_L08_002f5e58 draft moves from 609 to 148 differing words on the SN route.
The M671 debug strings name 0x70/0x74 as texture w/h counts; the commando grid
draft shares the flicker mesh pvars and now uses the same names and the
point light slots instead of sound names.
# Conflicts:
#	src/overlays/l08/gameplay/entities/commando.c
The slot position at 0x10 is now a PointLight field, so the commando grid
draft uses the same global and type as update_flickering_mesh_effect.
@mateuszklysz mateuszklysz changed the title overlay: near-miss drafts for the moby update loops and electric_gate overlay: near-miss drafts for the moby update loops, electric_gate and the commando grid Oct 24, 2026
SN's cc1.exe is GCC 2.95.2 with the Cygnus R5900 back end. Rebuild it
from gcc-2.95.2 plus patches/sn-2.95.2: without the 2.95.3 reload fix
(sce-991111b 0062) it gives the same .s as cc1.exe for all 180 units.
With it, FUN_L05_0030de90 and FUN_L10_002dcc58 match and move to C.
@mateuszklysz mateuszklysz changed the title overlay: near-miss drafts for the moby update loops, electric_gate and the commando grid overlay: SN cc1 from source, electric_gate and platform in C Oct 24, 2026
@mateuszklysz
mateuszklysz marked this pull request as ready for review October 24, 2026 14:52
@mateuszklysz
mateuszklysz marked this pull request as draft October 24, 2026 14:55
The point count comes after the three floats in the parameter list, as in
rac1-decomp; that order alone gives retail's register choice, so the
zero-term Fakematch and the temp block go.
hero.joint_matrices holds the 9 joint world matrices at 0xAC0 and
item_defs rows name the joint an item follows (0x0C).
The beam rotation globals are floats everywhere, the two arc timer
tables are .sdata short arrays in devastator too, and the arc points
use one name. The walloper draft declares the particle spawn with the
argument order other callers use.
Beam and side points are addressed from the beam array per segment,
the arc counter is declared first and unused locals are gone. The
NON_MATCHING body is now 3 rows from retail (was 18).
The loop counter row is declared last and a marked fakematch block sizes
the gcse hash table, so the frame slots of x - 16 and row + 1 land in
retail order.
The tube ring loop indexes the ring grid as rows of 20 points, the form
the snagglebeast rope update uses for its own rings.
The sda .extern hoist looked for a function definition only under its
asm label. A function renamed to a C name with __asm__("FUN_...") was
not found, so a late .extern moved and the unit grew.
Names come from what each function does, checked against our code.
Also finishes the hero field renames in the level copies.
@mateuszklysz mateuszklysz changed the title overlay: SN cc1 from source, electric_gate and platform in C overlay: SN cc1 from source, walloper beam and more level code in C, hero names Oct 26, 2026
@mateuszklysz
mateuszklysz marked this pull request as ready for review October 26, 2026 10:53

This branch has not been deployed

No deployments
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