Skip to content

feat(libSceJxr): implement the BitIOInfo bit reader helpers - #1

Open
Jawschamp wants to merge 2 commits into
preview-base/jxr-bit-readerfrom
feat/jxr-bit-reader
Open

Jawschamp wants to merge 2 commits into
preview-base/jxr-bit-readerfrom
feat/jxr-bit-reader

Conversation

@Jawschamp

Copy link
Copy Markdown
Owner

What

Implements peekBit16, flushBit16, getBit16, getBool16, getBit16s and getBit32 (libSceJxr NIDs dNGYFo5f1xw, yCAh+u4aq4E, -W7g+KymzGw, Wt5X6GvjCf4, 8BfHQcmjyGk and 4XveBXc4t2c) over the BitIOInfo layout already used by readIS and writeIS, following the non-ARM bit reader in the pinned jxrlib strcodec.c. They threw NotImplemented_nid_no_patch as parameterless placeholders before; those and their declarations are replaced by real prototypes, and docs/dev/debt/libSceJxr.md goes from 132 to 126 additional exports.

  • The accumulator is a big-endian 32-bit window loaded from the current byte, advanced by bitsUsed >> 3 bytes and wrapped with the iMask pointer mask, exactly as FLUSHBIT16 does. getBit16s flushes only the magnitude width when the peeked value is below 2, and getBit32 splits widths above 16.
  • Where the reference asserts or has undefined behaviour, std::invalid_argument is thrown and the state is left unchanged: a null state, a width of 0 or above 16 for peekBit16 and getBit16, above 16 for flushBit16, 16 or more for getBit16s, 0 or above 32 for getBit32, and a null window after a flush. This is listed in the debt doc with pinned source links. The prototypes are inferred from the shared names; nothing was measured on a PS5.
  • New guest test guest_jxr_bit_reader checks hand-computed values and ring wrap-around, then runs 256,000 random operations against the natively built vendored jxrlib on identical state and compares results and all 48 bytes of state after every step. It also checks the rejected arguments.

Tested

Linux x86_64, GCC 14.2 (g++ extracted from Debian trixie packages), -DBUILD_TESTING=ON, full configure with all submodules. Hardware and titles: not tested.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Implement peekBit16, flushBit16, getBit16, getBool16, getBit16s and
getBit32 over the BitIOInfo layout used by readIS and writeIS, following
the pinned jxrlib reference. A differential test compares them with the
vendored reference.
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Progress report (b2a4784 → 85cc880)

📈 System libraries: 26.27% (+0.02%, +6 implemented functions)

✅ 6 implemented
Library Name
libSceJxr flushBit16_nid_postfix
libSceJxr getBit16_nid_postfix
libSceJxr getBit16s_nid_postfix
libSceJxr getBit32_nid_postfix
libSceJxr getBool16_nid_postfix
libSceJxr peekBit16_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libSceJxr 4/136 (2.94%) 10/136 (7.35%) +4.41%

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant