feat(libSceCesCs): report the JIS X 0213 level of a cell as the console does #10751

Merged
rooklz merged 2 commits from upstream-pr/10751 into main 2026-11-04 04:48:47 +00:00
rooklz commented 2026-10-24 21:12:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-24T21:12:46Z.


What

sceCesJisGetLevel threw. It now reports the JIS X 0213 level of a plane, row and cell, as a PS5 does: int sceCesJisGetLevel(uint8_t plane, uint8_t row, uint8_t cell, uint32_t* level). The signature comes from the console module's disassembly (libSceCesCs.sprx, NID hQeUMTVgPHU).

I measured it on a PS5 with a homebrew payload that loads the console's libSceCesCs.sprx and calls it for every plane 0-3, row 0-255 and cell 0-255. On the console:

  • level 1 and 2 are the JIS X 0208 cells of rows 1-47 and 48-84, 3 is the rest of plane 1, and 4 is plane 2;
  • a cell JIS X 0213 leaves empty answers 0x805C0020 with its level; the 25 cells that need two code points count as assigned;
  • a plane other than 1 or 2, or a row or cell outside 1-94, answers 0x805C0015 and stores level 0;
  • a null level pointer answers 0x805C0001.

The function uses the JIS X 0213 tables of #10426. A native build of it matches the console for all 262144 inputs.

Tested

  • guest_ces_jis2004 sweeps every plane, row and cell, hashing result and level, and checks the hash of the console's sweep (0xD41EFACB, 11233 assigned cells), plus spot cases for each level, empty cells, the out-of-range answer and a null pointer. The other guest_ces* tests pass.
  • macOS (Apple clang 21, x86-64): all eight guest_ces* sources pass against this Export.cpp.
  • Hosted Linux runner, head 27ef055d64 (verify run on my fork; Ubuntu 24.04, GCC, Release, lavapipe): every guest_ces* test passes; its one failure, agc_driver_sgpr_pattern_fill_keys, is main's on that runner.
  • check_conventions.py passes.

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 (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #10426
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4999209069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10751). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-24T21:12:46Z. --- ### What `sceCesJisGetLevel` threw. It now reports the JIS X 0213 level of a plane, row and cell, as a PS5 does: `int sceCesJisGetLevel(uint8_t plane, uint8_t row, uint8_t cell, uint32_t* level)`. The signature comes from the console module's disassembly (`libSceCesCs.sprx`, NID `hQeUMTVgPHU`). I measured it on a PS5 with a homebrew payload that loads the console's `libSceCesCs.sprx` and calls it for every plane 0-3, row 0-255 and cell 0-255. On the console: - level 1 and 2 are the JIS X 0208 cells of rows 1-47 and 48-84, 3 is the rest of plane 1, and 4 is plane 2; - a cell JIS X 0213 leaves empty answers `0x805C0020` with its level; the 25 cells that need two code points count as assigned; - a plane other than 1 or 2, or a row or cell outside 1-94, answers `0x805C0015` and stores level 0; - a null level pointer answers `0x805C0001`. The function uses the JIS X 0213 tables of #10426. A native build of it matches the console for all 262144 inputs. ### Tested - `guest_ces_jis2004` sweeps every plane, row and cell, hashing result and level, and checks the hash of the console's sweep (`0xD41EFACB`, 11233 assigned cells), plus spot cases for each level, empty cells, the out-of-range answer and a null pointer. The other `guest_ces*` tests pass. - macOS (Apple clang 21, x86-64): all eight `guest_ces*` sources pass against this `Export.cpp`. - Hosted Linux runner, head `27ef055d64` ([verify run on my fork](https://github.com/rooklz/AnyPS5/actions/runs/40129813453); Ubuntu 24.04, GCC, Release, lavapipe): every `guest_ces*` test passes; its one failure, `agc_driver_sgpr_pattern_fill_keys`, is `main`'s on that runner. - `check_conventions.py` passes. ### 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 (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #10426 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-24 21:44:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T21:44:40Z.

Review: APPROVED


Reviewed exact head 27ef055d6402c1b376395d40a647cbfd978e6879 and its incremental 62-line change over declared prerequisite #10426. The level calculation distinguishes the JIS X 0208 ranges from the remaining plane-1 cells and plane 2; assignment status includes the 25 multi-code-point cells, and invalid plane/row/cell handling writes level zero when the output pointer is available. The exhaustive 0..3 by 0..255 by 0..255 hash and targeted cases match the reported PS5 sweep. I verified the JIS X 0213 source table permits use/modification/distribution, checked conventions and diff whitespace, and syntax-compiled the exact PR Export.cpp and GuestCesJis2004.cpp successfully. The current hosted product jobs are skipped; I did not run the exhaustive runtime sweep locally. Merge remains dependent on #10426.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640145294 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10751#pullrequestreview-5640145294). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T21:44:40Z. **Review:** APPROVED --- Reviewed exact head 27ef055d6402c1b376395d40a647cbfd978e6879 and its incremental 62-line change over declared prerequisite #10426. The level calculation distinguishes the JIS X 0208 ranges from the remaining plane-1 cells and plane 2; assignment status includes the 25 multi-code-point cells, and invalid plane/row/cell handling writes level zero when the output pointer is available. The exhaustive 0..3 by 0..255 by 0..255 hash and targeted cases match the reported PS5 sweep. I verified the JIS X 0213 source table permits use/modification/distribution, checked conventions and diff whitespace, and syntax-compiled the exact PR Export.cpp and GuestCesJis2004.cpp successfully. The current hosted product jobs are skipped; I did not run the exhaustive runtime sweep locally. Merge remains dependent on #10426.
MarcZX10 commented 2026-10-24 23:57:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T23:57:09Z.

Review: APPROVED


Reviewed the new sceCesJisGetLevel implementation and its exhaustive test against the prerequisite EUC-JIS-2004/Shift_JIS-2004 profile work in #10426. The bounds checks happen before table indexing, invalid coordinates zero the output when present, and valid coordinates return the level independently of whether the cell is assigned. The level classification and assignment test cover plane 2, JIS X 0208 rows, the remaining plane-1 rows, and the 25 two-code-point cells.

I independently compiled this head's Export.cpp and GuestCesJis2004.cpp with GCC 12/C++20, linked the focused test directly, and ran it successfully (exit 0). That exercises the full 4 × 256 × 256 coordinate sweep and expected hash/count, along with the profile round trips. git diff --check upstream/main...head is clean.

I could not run the full CMake target in this checkout because the other third-party git submodules are not initialized; the hosted product-build jobs are also path-skipped. The PR records the author's Linux and Windows test runs and the PS5 sweep used for the expected results. I did not independently reproduce the console measurement. With that limitation recorded, I found no blocking issue in this change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640667546 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10751#pullrequestreview-5640667546). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T23:57:09Z. **Review:** APPROVED --- Reviewed the new `sceCesJisGetLevel` implementation and its exhaustive test against the prerequisite EUC-JIS-2004/Shift_JIS-2004 profile work in #10426. The bounds checks happen before table indexing, invalid coordinates zero the output when present, and valid coordinates return the level independently of whether the cell is assigned. The level classification and assignment test cover plane 2, JIS X 0208 rows, the remaining plane-1 rows, and the 25 two-code-point cells. I independently compiled this head's `Export.cpp` and `GuestCesJis2004.cpp` with GCC 12/C++20, linked the focused test directly, and ran it successfully (exit 0). That exercises the full 4 × 256 × 256 coordinate sweep and expected hash/count, along with the profile round trips. `git diff --check upstream/main...head` is clean. I could not run the full CMake target in this checkout because the other third-party git submodules are not initialized; the hosted product-build jobs are also path-skipped. The PR records the author's Linux and Windows test runs and the PS5 sweep used for the expected results. I did not independently reproduce the console measurement. With that limitation recorded, I found no blocking issue in this change.
MarcZX10 commented 2026-10-25 04:53:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:53:13Z.

Review: CHANGES_REQUESTED


Requesting a fix for the assigned two-code-point JIS X 0213 cells described in the inline comment. The current tests explicitly expect valid standard mappings to fail in both directions.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641612358 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10751#pullrequestreview-5641612358). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T04:53:13Z. **Review:** CHANGES_REQUESTED --- Requesting a fix for the assigned two-code-point JIS X 0213 cells described in the inline comment. The current tests explicitly expect valid standard mappings to fail in both directions.
MarcZX10 commented 2026-10-29 06:13:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:13:49Z.

Review: APPROVED


Re-checked — approved

The console measurements you supplied resolve my earlier concern about the assigned two-code-point JIS X 0213 cells. The evidence distinguishes these specific EUC-JIS-2004/Shift_JIS-2004 mappings from other valid two-code-point sequences that do round-trip, so the measured rejection is consistent with the implementation and pinned expectations. The PR description now records those console results; the current head contains no behavior change that would invalidate the prior implementation review.

I also confirmed prerequisite #10426 is merged, this PR records it as a dependency, and the current branch is mergeable. The author reports Windows tests on a merge with current main and the prior exhaustive sweep plus macOS test results; hosted Windows and policy checks pass, while Linux hosted CI is skipped. I did not rerun the exhaustive sweep locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693598438 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10751#pullrequestreview-5693598438). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T06:13:49Z. **Review:** APPROVED --- ## Re-checked — approved The console measurements you supplied resolve my earlier concern about the assigned two-code-point JIS X 0213 cells. The evidence distinguishes these specific EUC-JIS-2004/Shift_JIS-2004 mappings from other valid two-code-point sequences that do round-trip, so the measured rejection is consistent with the implementation and pinned expectations. The PR description now records those console results; the current head contains no behavior change that would invalidate the prior implementation review. I also confirmed prerequisite #10426 is merged, this PR records it as a dependency, and the current branch is mergeable. The author reports Windows tests on a merge with current main and the prior exhaustive sweep plus macOS test results; hosted Windows and policy checks pass, while Linux hosted CI is skipped. I did not rerun the exhaustive sweep locally.
MarcZX10 commented 2026-10-31 22:31:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T22:31:21Z.

Review: APPROVED


Re-checked — new head, looks good

The sceCesJisGetLevel implementation and its exhaustive test are unchanged from the previously approved head; the rebase only reconciles the pending-export count in the debt entry.

What I ran

Reviewed head 04112df6ff52bd2e12cc6eb14806daa1d87f1dc9 against base 1bc97b9527eaf6b56681cd3465bca67b75329161; the local merge preview against current main was clean and dependency #10426 is already in the base. Environment: Debian Linux x86_64, Python 3.11.2. I compared the exact implementation and test blocks with the previously approved head 0647217ecf16797ad496d6c3fe8e3a01e61cd636 and ran the no-build precheck.

python3 /marc/AnyPS5/tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 10751
gh api repos/boykopovar/AnyPS5/contents/core/libs/prx/libSceCesCs/Export.cpp?ref=04112df6ff52bd2e12cc6eb14806daa1d87f1dc9
gh api repos/boykopovar/AnyPS5/contents/core/libs/tests/GuestCesJis2004.cpp?ref=04112df6ff52bd2e12cc6eb14806daa1d87f1dc9

Results

Check Result
Diff check Passed.
Repository conventions Passed.
Dependency and merge preview Passed; #10426 is satisfied by base and the preview is clean.
Change since approved head The implementation and complete test file are unchanged; only rebase context and the debt-file pending-export count differ.
Hosted eligibility, library-portability, and report Passed on this head.
Hosted Linux and specialized product jobs Skipped.
Author-reported tests The author reports guest_ces_jis2004 and guest_ces_jis2004_module passed 2/2 on this head.
Precheck ABI/test-quality helpers Not executable from the extracted PR checkout because these workspace-only helper scripts are absent there; their status is not evidence of a PR defect.
Unedited output — conventions
All conventions checks passed.
Unedited output — merge preview
# PR stack check — fresh

Target: https://github.com/boykopovar/AnyPS5/pull/10751
Target branch tip: `1bc97b9527eaf6b56681cd3465bca67b75329161`
All heads unchanged: **True**
Dependency order: #10751

## Individual merge previews

- PR #10751: **clean** against current base; head `04112df6ff52bd2e12cc6eb14806daa1d87f1dc9`; changed paths: none reported

## Dependency relationships

- #10426 → #10751: **satisfied_by_base**; overlapping changed paths: none

## Limits

Merge previews apply each exact PR head independently to the current base. A dependency head that is absent from its dependent is reported separately from merge conflicts; file overlap is only a signal and does not prove a conflict. This tool does not build, resolve conflicts, publish comments, or update branches.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

  • I did not compile or run the C++ tests on this rebase. The implementation and test contents are identical to the previously approved head, and the author reports both focused tests passed on this head.
  • Hosted Windows was still queued; hosted Linux and specialized product jobs were skipped. I did not repeat the PS5 measurement.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725278723 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10751#pullrequestreview-5725278723). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T22:31:21Z. **Review:** APPROVED --- # Re-checked — new head, looks good The `sceCesJisGetLevel` implementation and its exhaustive test are unchanged from the previously approved head; the rebase only reconciles the pending-export count in the debt entry. ## What I ran Reviewed head `04112df6ff52bd2e12cc6eb14806daa1d87f1dc9` against base `1bc97b9527eaf6b56681cd3465bca67b75329161`; the local merge preview against current `main` was clean and dependency #10426 is already in the base. Environment: Debian Linux x86_64, Python 3.11.2. I compared the exact implementation and test blocks with the previously approved head `0647217ecf16797ad496d6c3fe8e3a01e61cd636` and ran the no-build precheck. ```sh python3 /marc/AnyPS5/tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 10751 gh api repos/boykopovar/AnyPS5/contents/core/libs/prx/libSceCesCs/Export.cpp?ref=04112df6ff52bd2e12cc6eb14806daa1d87f1dc9 gh api repos/boykopovar/AnyPS5/contents/core/libs/tests/GuestCesJis2004.cpp?ref=04112df6ff52bd2e12cc6eb14806daa1d87f1dc9 ``` ## Results | Check | Result | |---|---| | Diff check | Passed. | | Repository conventions | Passed. | | Dependency and merge preview | Passed; #10426 is satisfied by base and the preview is clean. | | Change since approved head | The implementation and complete test file are unchanged; only rebase context and the debt-file pending-export count differ. | | Hosted eligibility, library-portability, and report | Passed on this head. | | Hosted Linux and specialized product jobs | Skipped. | | Author-reported tests | The author reports `guest_ces_jis2004` and `guest_ces_jis2004_module` passed 2/2 on this head. | | Precheck ABI/test-quality helpers | Not executable from the extracted PR checkout because these workspace-only helper scripts are absent there; their status is not evidence of a PR defect. | <details><summary>Unedited output — conventions</summary> ```text All conventions checks passed. ``` </details> <details><summary>Unedited output — merge preview</summary> ```text # PR stack check — fresh Target: https://github.com/boykopovar/AnyPS5/pull/10751 Target branch tip: `1bc97b9527eaf6b56681cd3465bca67b75329161` All heads unchanged: **True** Dependency order: #10751 ## Individual merge previews - PR #10751: **clean** against current base; head `04112df6ff52bd2e12cc6eb14806daa1d87f1dc9`; changed paths: none reported ## Dependency relationships - #10426 → #10751: **satisfied_by_base**; overlapping changed paths: none ## Limits Merge previews apply each exact PR head independently to the current base. A dependency head that is absent from its dependent is reported separately from merge conflicts; file overlap is only a signal and does not prove a conflict. This tool does not build, resolve conflicts, publish comments, or update branches. ``` </details> ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [Implementation at the rechecked head](https://github.com/boykopovar/AnyPS5/blob/04112df6ff52bd2e12cc6eb14806daa1d87f1dc9/core/libs/prx/libSceCesCs/Export.cpp#L809-L822) - [Export validation and result handling at the rechecked head](https://github.com/boykopovar/AnyPS5/blob/04112df6ff52bd2e12cc6eb14806daa1d87f1dc9/core/libs/prx/libSceCesCs/Export.cpp#L2185-L2193) - [Exhaustive test and targeted boundary assertions at the rechecked head](https://github.com/boykopovar/AnyPS5/blob/04112df6ff52bd2e12cc6eb14806daa1d87f1dc9/core/libs/tests/GuestCesJis2004.cpp#L147-L172) ## Not verified - I did not compile or run the C++ tests on this rebase. The implementation and test contents are identical to the previously approved head, and the author reports both focused tests passed on this head. - Hosted Windows was still queued; hosted Linux and specialized product jobs were skipped. I did not repeat the PS5 measurement.
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!10751
No description provided.