Skip to content

decomp: promote _printf, select_world_object_resource_tables and _sceFs_Rcv_Intr (3100 B) - #177

Merged
mateuszklysz merged 3 commits into
lombyte-project:mainfrom
Sploters:decomp/three-exact-functions
Oct 14, 2026
Merged

mateuszklysz merged 3 commits into
lombyte-project:mainfrom
Sploters:decomp/three-exact-functions

Conversation

@Sploters

Copy link
Copy Markdown
Contributor

Before

_printf, select_world_object_resource_tables and _sceFs_Rcv_Intr were assembly-backed units built from their INCLUDE_ASM oracles. Their C bodies under #else were close but not exact.

After

Three units promoted to exact C (3100 B):

  • sdk/debug/printf_impl (_printf, 1516 B): the C body already matched in check-unit, but its format switch table was discarded at link time. Pinned at retail's jtbl_001527B0 (0x1527B0, file 0x53730) in RODATA_OVERLAYS, right after printfloat's literals.
  • textbin/world/data/select_world_object_resource_tables (684 B): the two hoisted %hi registers came out in s0/s4 swapped. Global alloc ranks them by refs/live length, then by pseudo number, which PRE assigns in GCSE hash order of the symbol string. Reading class_slot before taking the table base equalises the live lengths, and naming the table D_001B3200 without the asm-label prefix puts its %hi first in the hash order.
  • sdk/library/_sceFs_Rcv_Intr (900 B): the semaphore release loop compares the slot against ret (retail bne operand order). The slot table is read plainly so combine folds the sign extension, and the slot is released through a volatile store, which keeps it ahead of the branch instead of in its delay slot.

Verification

  • make elf ends with PASS: reconstructed boot ELF matches retail
  • make overlays ends with PASS (overlay changes): n/a, no overlay changes
  • make check passes (92 tests OK)

check-unit reports Object matches (promotable). The C body's format
switch emits its jump table in .rodata, so pin it at retail's
jtbl_001527B0 (0x1527B0, file 0x53730) in RODATA_OVERLAYS, right after
printfloat's literals; without the pin the linker discards it.

./verify-baseline.sh: PASS: reconstructed boot ELF matches retail
The two hoisted %hi registers (resident_class_slot_by_id, moby_class_resources)
came out in s0/s4 swapped. Global alloc ranks them by refs/live length and
then by pseudo number, which PRE assigns in GCSE hash order of the symbol
string. Reading class_slot before taking the table base equalises the live
lengths, and naming the table D_001B3200 without the asm-label prefix puts its
%hi first in the hash order, which gives retail's allocation.

./verify-baseline.sh: PASS: reconstructed boot ELF matches retail
The semaphore release loop compared ret against the slot (bne operands
reversed) and, with the slots read through a volatile table, the reversed
compare kept a separate sign-extension pseudo that took v0 from the
semaphore. Reading the table plainly lets combine fold the extension, and
releasing the slot through a volatile store keeps it ahead of the branch,
out of the delay slot, as in retail.

./verify-baseline.sh: PASS: reconstructed boot ELF matches retail
@mateuszklysz mateuszklysz added the enhancement New feature or request label Oct 14, 2026
@github-actions

Copy link
Copy Markdown

Decompilation progress

C_EXACT Change Matched bytes Functions C_FUZZY
All code 87.79 % +0.09 pp 3,113,144 / 3,546,268 B (+3,100 B) 3,967 / 4,233 (+3) 89.03 %
Boot executable 85.65 % +0.88 pp 302,216 / 352,840 B (+3,100 B) 1,163 / 1,219 (+3) 98.13 %
Game 84.51 % +0.25 pp 230,576 / 272,844 B (+684 B) 866 / 905 (+1) 98.40 %
SDK 89.55 % +3.02 pp 71,640 / 79,996 B (+2,416 B) 297 / 314 (+2) 97.21 %
Level overlays 88.02 % — 2,810,928 / 3,193,428 B (—) 2,804 / 3,014 (—) 88.02 %
Shared level code 79.95 % — 903,868 / 1,130,492 B (—) 1,438 / 1,583 (—) 79.95 %
Per-level code 92.44 % — 1,907,060 / 2,062,936 B (—) 1,366 / 1,431 (—) 92.44 %
3 newly matched functions (3,100 B)
Function Address Size Unit
_printf 0x0001ad20 1,516 B sdk/debug
_sceFs_Rcv_Intr 0x0001c4e8 900 B sdk/library
select_world_object_resource_tables 0x001059c0 684 B game/world/data

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

@decomp-dev

decomp-dev Bot commented Oct 14, 2026

Copy link
Copy Markdown

Report for SCUS_971.99 (34fd269 - 3c502e6)

📈 Matched code: 87.79% (+0.09%, +3100 bytes)
📈 Linked code: 87.79% (+0.09%, +3100 bytes)

✅ 3 new matches
Unit Item Bytes Before After
sdk/library _sceFs_Rcv_Intr +36 96.11% 100.00%
sdk/debug _printf +33 97.86% 100.00%
game/world/data select_world_object_resource_tables +1 99.94% 100.00%

@mateuszklysz
mateuszklysz merged commit ce39091 into lombyte-project:main Oct 14, 2026
3 checks passed
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