feat(ngs2): implement the firmware-recovered utility exports #12599

Merged
edubox merged 6 commits from upstream-pr/12599 into main 2026-10-30 19:35:58 +00:00
edubox commented 2026-10-28 22:25:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-10-28T22:25:26Z.


What

Implement four libSceNgs2 exports from the decrypted firmware 11.00 module:

  • sceNgs2SystemEnumHandles and sceNgs2SystemEnumRackHandles return the number of live systems or racks and fill up to the requested count. A null output with a nonzero count returns 0x804A0053; an unknown system returns 0x804A0230.
  • sceNgs2ParseWaveformUser reads offset 0 through the caller's read handler, takes the RIFF size from the header and parses the bytes with the existing waveform parser. A null handler returns 0x804A0408 and a null output 0x804A0053.
  • sceNgs2FftQuerySize follows the firmware table: lengths 8..12 select 64, 128, 256, 512 and 1024 samples, bit 1 of the flags halves the count, and the work size is 32 * count + 64. Invalid lengths and a null output return -1.

Evidence: in the firmware 11.00 libSceNgs2.prx, the enumerators are at 0xf270/0xf0d0, sceNgs2ParseWaveformUser at 0x10810, and sceNgs2FftQuerySize at 0x430 with its five-entry table at 0x30b30. The implementations live in System.cpp because that source is built into both the native test library and the guest library without changing the source list. The RIFF size is capped at 256 MiB so a malformed header cannot request an unbounded allocation.

sceNgs2FftInit and sceNgs2FftProcess still throw: their 7.3 KB AVX radix-8 kernel and packed input/output layout are not recovered, and no dump imports these NIDs. The debt entry records what is known.

Tested

Linux x86-64 (CachyOS), GCC 16.2.1, Release: ctest --test-dir build -R '^ngs2_' passes 30/30, including the new ngs2_parse and ngs2_handleerrors checks. check_conventions.py --base origin/main and git diff --check are clean. Windows CI will run on the new head.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5058665328 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12599). Originally posted by [edubox](https://github.com/edubox) on 2026-10-28T22:25:26Z. --- ### What Implement four `libSceNgs2` exports from the decrypted firmware 11.00 module: - `sceNgs2SystemEnumHandles` and `sceNgs2SystemEnumRackHandles` return the number of live systems or racks and fill up to the requested count. A null output with a nonzero count returns `0x804A0053`; an unknown system returns `0x804A0230`. - `sceNgs2ParseWaveformUser` reads offset 0 through the caller's read handler, takes the RIFF size from the header and parses the bytes with the existing waveform parser. A null handler returns `0x804A0408` and a null output `0x804A0053`. - `sceNgs2FftQuerySize` follows the firmware table: lengths 8..12 select 64, 128, 256, 512 and 1024 samples, bit 1 of the flags halves the count, and the work size is `32 * count + 64`. Invalid lengths and a null output return `-1`. Evidence: in the firmware 11.00 `libSceNgs2.prx`, the enumerators are at `0xf270`/`0xf0d0`, `sceNgs2ParseWaveformUser` at `0x10810`, and `sceNgs2FftQuerySize` at `0x430` with its five-entry table at `0x30b30`. The implementations live in `System.cpp` because that source is built into both the native test library and the guest library without changing the source list. The RIFF size is capped at 256 MiB so a malformed header cannot request an unbounded allocation. `sceNgs2FftInit` and `sceNgs2FftProcess` still throw: their 7.3 KB AVX radix-8 kernel and packed input/output layout are not recovered, and no dump imports these NIDs. The debt entry records what is known. ### Tested Linux x86-64 (CachyOS), GCC 16.2.1, Release: `ctest --test-dir build -R '^ngs2_'` passes 30/30, including the new `ngs2_parse` and `ngs2_handleerrors` checks. `check_conventions.py --base origin/main` and `git diff --check` are clean. Windows CI will run on the new head. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12599
No description provided.