Skip to content

overlay: move 48 level functions and 3 boot functions to C - #208

Merged
mateuszklysz merged 28 commits into
mainfrom
decomp/rac1-align-wave-nlcv0b
Oct 16, 2026
Merged

mateuszklysz merged 28 commits into
mainfrom
decomp/rac1-align-wave-nlcv0b

Conversation

@mateuszklysz

@mateuszklysz mateuszklysz commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Before

Many level functions that rac1-decomp has exact (its main and the open PR 88) were still INCLUDE_ASM here, and so were three boot functions.

After

  • 48 level functions move to C. They are ported from rac1-decomp and translated to the US level programs; OpenRAC's US map pairs the ones whose fingerprints differ. Each port needed its own fixes for US: data placement ($gp, lui, macro), callee prototypes and swapped symbol pairs. make overlays: 2852 -> 2900 functions in C.
  • Boot: render_capture_scrolling_text, vi_buf_restart_dma and sceDbcCreateSocket match.
  • The Hoven turret file is split at FUN_L12_003054b0, because the earlier functions reach D_L12_00161F00/04 through $gp and the later ones through lui.
  • Units whose functions all match on SN move to the SN route (00264e40, follow_camera_update).
  • The overlay compile check now accepts files that GNU as assembles only with or only without -G0.
  • Cleanup (docs/code-cleanup.md) on the ported code: each callee and global keeps the name and type the tree already uses, placement aliases end in _gp/_lui/_macro, and locals and fields are named by use instead of registers. Data label conflicts drop from 610 to 602.
  • README drops the port line, and the empty game/ folder is removed.

Verification

  • make elf ends with PASS: reconstructed boot ELF matches retail
  • make overlays ends with PASS (overlay changes)
  • scripts/check-cleanup.py: no new problems
  • make check passes

GNU as asserts (tc-mips.c:11454) on some bare symbol loads in a noreorder
delay slot: with -G0 on a Hoven unit with a new port, without it on two
others. obj/ only checks that a file compiles as written, so try -G0 first
and fall back to the default.
Ports of functions that rac1-decomp has exact (its main and the open
PR 88), translated to the US level programs and proved byte for byte:
30,524 bytes in 24 functions across shared code and levels 3, 6, 7, 8,
12, 13, 14, 15 and 18. make overlays: 2852 -> 2876 functions in C.

Hoven's 0x3064e8 reads the moby array through the unit's existing
.sdata alias; Blarg's 0x2feb40 uses the US help text id (5 lower).
13,532 bytes. What the first pass of the port missed:
- Rilgar's sharkigator update: two data symbols paired the wrong way
  round, and the dust table keeps rac1-decomp's section(.sdata) so its
  address is set late, as retail does;
- Fred's update: the moby's +0xBC byte, which the port had folded into
  another symbol;
- the bomb update: the float-to-int callee FUN_001fa6d0;
- four more ports that only needed rac1-decomp's NOT_SDA/MACRO_ADDR
  placement kept, with clashing declarations renamed in the port.
make overlays: 2876 -> 2883 functions in C.
Both bodies follow the rac1-decomp C for the same functions. The
capture glyph tables move into the vendor unit as C data.
FUN_L12_00303540 stores D_L12_00161F00/04 through $gp outside delay
slots, while FUN_L12_003054b0 and FUN_L12_003069d0 load them with lui.
One assembler pass cannot do both, so the functions from
FUN_L12_003054b0 on live in their own file. Both then match with the
rac1-decomp C (7068 bytes).
Two units whose functions all match on the SN route move there.
A dropped typedef, callee prototypes and data placement are fixed by
hand, and the hero position is written as the hero base + 0x80.
These functions are exact in rac1-decomp but their fingerprints differ
from the US ones; OpenRAC's US map pairs them (11 KB).
The sentrybot draft moves into the stub's #else block, where promote
expects it (2.9 KB).
The RPC buffer is an array (SDK globals are not small data), and the
header words are copied as pointers, which keeps their loads ahead of
the port and mode stores as in retail.
@mateuszklysz mateuszklysz added the enhancement New feature or request label Oct 16, 2026 — with Claude
@github-actions

Copy link
Copy Markdown

Decompilation progress

C_EXACT Change Matched bytes Functions C_FUZZY
All code 92.16 % +2.07 pp 3,270,024 / 3,548,100 B (+73,536 B) 4,077 / 4,246 (+51) 93.36 %
Boot executable 86.26 % +0.44 pp 305,940 / 354,672 B (+1,552 B) 1,182 / 1,232 (+3) 98.26 %
Game 85.10 % +0.49 pp 232,860 / 273,636 B (+1,352 B) 876 / 912 (+2) 98.49 %
SDK 90.18 % +0.25 pp 73,080 / 81,036 B (+200 B) 306 / 320 (+1) 97.49 %
Level overlays 92.82 % +2.25 pp 2,964,084 / 3,193,428 B (+71,984 B) 2,895 / 3,014 (+48) 92.82 %
Shared level code 86.65 % +3.45 pp 979,540 / 1,130,492 B (+39,056 B) 1,490 / 1,583 (+32) 86.65 %
Per-level code 96.20 % +1.60 pp 1,984,544 / 2,062,936 B (+32,928 B) 1,405 / 1,431 (+16) 96.20 %
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 (—)
51 newly matched functions (73,536 B)
Function Address Size Unit
FUN_L05_00301f48 0x00301f48 5,188 B level_05/gameplay/entities/sharkigator
FUN_L15_0029d6c0 0x0029d6c0 4,920 B shared/gameplay/entities/sentrybot
FUN_L10_002e4a88 0x002e4a88 3,804 B level_10/gameplay/entities/screamer
FUN_L12_003054b0 0x003054b0 3,740 B level_12/gameplay/entities/003054b0
FUN_L05_00304320 0x00304320 3,672 B level_05/gameplay/entities/sharkigator
FUN_L12_003069d0 0x003069d0 3,328 B level_12/gameplay/entities/003054b0
FUN_L00_002d3a10 0x002d3a10 3,068 B shared/gameplay/entities/veldin_ship
FUN_L00_002cd1f0 0x002cd1f0 2,764 B shared/gameplay/entities/bomb
FUN_L00_002dbf28 0x002dbf28 2,576 B shared/gameplay/entities/nanotech_ball
FUN_L00_0025c698 0x0025c698 2,136 B shared/math/vectors/0025c230
FUN_L15_002a6e68 0x002a6e68 1,980 B shared/gameplay/entities/sentrybot
FUN_L08_002d5d08 0x002d5d08 1,860 B level_08/gameplay/entities/bomb
FUN_L08_002d23f0 0x002d23f0 1,792 B level_08/gameplay/entities/bomb
FUN_L01_002eec68 0x002eec68 1,768 B shared/gameplay/entities/novalis_elevator
FUN_L07_0030d4d8 0x0030d4d8 1,748 B level_07/gameplay/entities/taxi_platform
FUN_L06_002f2c28 0x002f2c28 1,732 B shared/gameplay/entities/gadgebot_spawn_container
FUN_L06_003049f8 0x003049f8 1,544 B level_06/gameplay/entities/fred
FUN_L13_00306300 0x00306300 1,480 B level_13/gameplay/entities/rocket
FUN_L06_002feb40 0x002feb40 1,472 B shared/gameplay/entities/blarg_space_commando
FUN_L14_002b2928 0x002b2928 1,452 B shared/gameplay/entities/plasmabot
FUN_L00_002bc3b0 0x002bc3b0 1,076 B shared/gameplay/entities/walloper
FUN_L00_0020f160 0x0020f160 1,056 B shared/gameplay/hero/hero_check_damage
FUN_L00_002d2670 0x002d2670 1,052 B shared/gameplay/entities/veldin_ship
FUN_L07_0030dcf0 0x0030dcf0 1,008 B level_07/gameplay/entities/taxi_platform
FUN_L00_002dd8e8 0x002dd8e8 948 B shared/gameplay/entities/nanotech_ball
FUN_L18_002ea1f8 0x002ea1f8 924 B level_18/gameplay/entities/rocket
FUN_L02_00264e70 0x00264e70 860 B shared/gameplay/entities/00264e40
FUN_L00_0029ff58 0x0029ff58 852 B shared/gameplay/entities/0029f990
FUN_L11_00310cf8 0x00310cf8 848 B shared/gameplay/entities/thruster_pack_lock
FUN_L12_003064e8 0x003064e8 832 B level_12/gameplay/entities/003054b0
vi_buf_restart_dma 0x0013d200 824 B game/video/decoder
FUN_L08_002de528 0x002de528 800 B level_08/gameplay/entities/bomb
FUN_L00_00206e00 0x00206e00 720 B shared/gameplay/hero/hero_idle_sequence
FUN_L00_00275aa0 0x00275aa0 712 B shared/rendering/002712b8
FUN_L05_00254358 0x00254358 688 B shared/ui/help/00237488
FUN_L00_002a96f8 0x002a96f8 688 B shared/gameplay/entities/camera_object
FUN_L00_0020a9e8 0x0020a9e8 684 B shared/gameplay/hero/hero_idle_sequence
FUN_L00_00237840 0x00237840 680 B shared/ui/text/002377b8
FUN_L00_002ddcb8 0x002ddcb8 680 B shared/gameplay/entities/nanotech_ball
FUN_L08_002e2250 0x002e2250 664 B level_08/gameplay/entities/bolt_thief
… and 11 more

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

@mateuszklysz mateuszklysz changed the title overlay: align level functions with rac1-decomp overlay: move 48 level functions and 3 boot functions to C Oct 16, 2026
@mateuszklysz
mateuszklysz marked this pull request as ready for review October 16, 2026 17:56
@mateuszklysz
mateuszklysz merged commit 1517473 into main Oct 16, 2026
5 checks passed
@mateuszklysz
mateuszklysz deleted the decomp/rac1-align-wave-nlcv0b branch October 16, 2026 18:00
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