Skip to content

feat(libSceFont): build the graphics region and fill descriptors as the console does - #9722

Merged
adriadam10 merged 5 commits into
boykopovar:mainfrom
hypermoist:feat/font-graphics-fill-descriptors
Oct 25, 2026
Merged

adriadam10 merged 5 commits into
boykopovar:mainfrom
hypermoist:feat/font-graphics-fill-descriptors

Conversation

@hypermoist

@hypermoist hypermoist commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

libSceFont's graphics fill descriptors threw: the region, fill-method, fill-plot and fill-rates initialisers and setters. They only check their arguments and fill a structure the caller owns, so they don't need the graphics device or service. sceFontSetGraphicsErrorCallback (Vj-F8HBqi00), which every one of them reports through, was missing.

This PR implements the 11 calls and the setter in a new src/Graphics.cpp. Their exported entry points stay where the stubs were, in the existing export block of Unimplemented.cpp, and call into it, so no new visibility pragma is needed. They follow the decrypted PS5 13.60 libSceFont.sprx (0x1fe80 to 0x20523, read from disassembly, not measured on a console):

Calls Behaviour
RegionInit, RegionInitCircular, RegionInitRoundish Write the 32-byte region with tag 0xF60. Corner flags are 0xF for a rectangle, 0xFF for a circle, and the caller's for a roundish region. A circle stores its bounding box. A roundish radius may not exceed half the width or height, and the inner radius may not exceed a non-zero outer one.
FillMethodInit Accepts modes 0x00 to 0x50 in steps of 0x10 and types 1 to 7 or 12. Writes tag 0xF01B and zeroes the reserved bytes.
FillPlotInit Validates a real region (tag, radii against half the smaller side) and maps it to {x, y, x + width, y + height}. Null and -1 are accepted without a region. A rejected region clears only the plot's tag, before returning 0x80460087.
FillPlotSetLayout, FillRatesSetLayout Accept six layout selectors and two nibbles from {0, 1, 2, 4}. The plot keeps the combined value; the rates object clears its layout and keeps only the flag.
FillRatesInit Zeroes the object before it validates the fill and the effect, as the console does.
FillRatesInit, FillRatesSetFillEffect Accept fill pointers -1 to 2 as they are, and others whose first byte is 0x10 to 0x50. Accept effects 0 to 5, 8, 9 and 16. The firmware maps each effect through a table in which each accepted effect maps to itself, so the code stores the effect directly.
FillPlotSetMapping, FillRatesSetMapping Store four floats unchecked and mark the mapping in the flags byte.

Every failure calls the error callback, if one is set, with the code it returns:

  • 0x80460002 for parameters, which is the existing SCE_FONT_ERROR_INVALID_PARAMETER;
  • 0x80460086 for a fill;
  • 0x80460087 for a region;
  • 0x80460088 for a fill plot;
  • 0x80460089 for fill rates.

The last four have no public names, so the source names them after what they reject. Comparisons keep the console's NaN results: a NaN size passes the region calls, but a NaN radius is rejected by FillPlotInit.

The four structures move unchanged from Unimplemented.cpp into include/FontGraphics.hpp so that both files can use them. The debt entry now says that these calls follow the firmware. What the layout selectors, mappings, corner flags and effects mean is still unknown, because the Setup* and Update* calls that read these descriptors still throw.

Not included: the Structure* calls. They need a graphics device, its pool and mutex.

The code is written from the observed behaviour; nothing from the module is copied.

Tested

New guest_font_graphics test. It checks:

  • every success layout byte by byte, and every error code with the callback receiving it;
  • the zero-before-validate and clear-only-the-tag paths;
  • the sentinel fills and regions, the NaN cases and the unchecked high bits of the layout argument;
  • that clearing the callback stops the calls.

On main the setter does not exist and the other 11 calls throw.

  • Linux (CachyOS, GCC, Release): guest_font_graphics, guest_font and guest_font_writing_line pass.
  • Windows build: cross-built with MinGW-w64 GCC 16.2 and run under Wine 11.19; guest_font_graphics passes.
  • Not run: a title.
  • After merging main a701f9f (2db8ab2): guest_font_graphics passes on Linux and on Windows (WinLibs GCC 15.2.0, Release, under Wine), with the NID-patched libSceFont.prx built on both.

tools/check_conventions.py is clean. tools/pr_overlap.py could not compare two PRs that already conflict with main. #5209 adds a debt line three lines above the one this PR edits. #6044 moves the Font tests to core/libs/tests/media/ and registers them with add_library_test(media ...). Either landing order works. If #6044 lands first, I merge main, move GuestFontGraphics.cpp to tests/media/ and register it as add_library_test(media NAME guest_font_graphics COMMAND guest_font_graphics_tests). If this PR lands first, #6044 needs that one registration converted. I noted this on #6044. The other open libSceFont PRs touch other files.

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: none (landing order with test: organize library tests and label CTest suites #6044: either; whichever lands second converts the guest_font_graphics registration, see Overlap)
  • Fixes: none
  • Unblocks: none known; PPSA08427 and PPSA29340 import other sceFontGraphics* calls, not these
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK

…he console does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Progress report (f26434a → 9539761)

📈 System libraries: 48.89% (+0.09%, +12 implemented functions)

✅ 12 implemented
Library Name
libSceFont sceFontGraphicsFillMethodInit
libSceFont sceFontGraphicsFillPlotInit
libSceFont sceFontGraphicsFillPlotSetLayout
libSceFont sceFontGraphicsFillPlotSetMapping
libSceFont sceFontGraphicsFillRatesInit
libSceFont sceFontGraphicsFillRatesSetFillEffect
libSceFont sceFontGraphicsFillRatesSetLayout
libSceFont sceFontGraphicsFillRatesSetMapping
libSceFont sceFontGraphicsRegionInit
libSceFont sceFontGraphicsRegionInitCircular
libSceFont sceFontGraphicsRegionInitRoundish
libSceFont sceFontSetGraphicsErrorCallback

Changed libraries (implemented exports)

Library Before After Change
libSceFont 126/195 (64.62%) 138/196 (70.41%) +5.79 pp

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5209 docs/dev/debt/libSceFont.md
PR 8250 core/libs/prx/libSceFont/CMakeLists.txt
docs/dev/debt/libSceFont.md

@MarcZX10 MarcZX10 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The firmware-based descriptor behavior and boundary tests are well documented. This branch is also 13 commits behind current main; the tested base is cc0078595. If accepted later, update the branch and rerun the focused Font tests and overlap check. Keep the guest_font_graphics registration in the form required by #6044 if that PR lands first. Product Linux/Windows jobs are skipped on this head.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

@hypermoist

Copy link
Copy Markdown
Contributor Author

@MarcZX10 understood. I'll leave this on hold under #5239 until the queue is below the threshold or a maintainer makes an exception. When it resumes, I'll merge current main, rerun the Font tests and the overlap check, and keep the guest_font_graphics registration in #6044's form if that lands first.

@MarcZX10

Copy link
Copy Markdown
Contributor

Supplemental review of head 6116b70b04e71e5e367fff826dd91958f0deda6f: exact-head native and MinGW-w64 GCC C++20 syntax-only checks passed for Graphics.cpp, Unimplemented.cpp and GuestFontGraphics.cpp. I also built the exact Graphics.cpp implementation and GuestFontGraphics.cpp test with thin temporary export-forwarding shims under AddressSanitizer and UndefinedBehaviorSanitizer; all test assertions passed with no sanitizer report. git diff --check and conventions passed. This local harness is not the full project CTest or a console run; the Linux and Windows runtime results in the PR body remain author-reported. It does not change the existing request to refresh to current main and coordinate the #6044 test-registration order when the PR resumes.

@MarcZX10

MarcZX10 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course.

@hypermoist

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks for the sanitizer run, and for saying the hold wasn't needed.

  • Base. I merged current main (a701f9f) in 2db8ab2. On that merge I built guest_font_graphics_tests and the NID-patched libSceFont.prx, then ran ctest -R '^guest_font_graphics$'. It passes on Linux (GCC, Release) and on Windows (WinLibs GCC 15.2.0, Release, under Wine).
  • test: organize library tests and label CTest suites #6044. The description and checklist now give the landing order: Depends on: none, either order works, and whichever lands second converts the guest_font_graphics registration to add_library_test(media NAME guest_font_graphics COMMAND guest_font_graphics_tests) under tests/media/. I left the same note for test: organize library tests and label CTest suites #6044's author.

🤖 Generated with Claude Code

…odules

The firmware version comes from the SDK 0x13600007 recorded in each module's module-param segment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013XFS3FUfBtqCVfwmBrRQ6q
@hypermoist

Copy link
Copy Markdown
Contributor Author

Correction: I mislabelled the firmware. The decrypted modules I read are firmware 13.60, not 12.00 (each module's module-param segment records SDK 13.60). The behaviour described is unchanged; only the version label was wrong. I've updated the description and the debt entries in e48a2f3.

Assisted With AI: Yes But all test done locally on actual hardware

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
hypermoist and others added 2 commits October 25, 2026 12:06
…fill-descriptors

Kept main's Api.hpp struct definitions and dropped the duplicates from FontGraphics.hpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…library header

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@adriadam10 adriadam10 self-assigned this Oct 25, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 18:50

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit 34b882f into boykopovar:main Oct 25, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the argument validation order, error codes, tags and written bytes against the description, the sceFontSetGraphicsErrorCallback NID, the export pattern, the debt entry and that guest_font_graphics pins every layout byte and error code (the calls threw on main). Branch is already merged with current main; the earlier change request on the old head is met; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants