HLE: PlayStation button prompts from the user's copy, served at read time with opt-in VICTORY_FILE_PATCH #3399

Open
anoyarou wants to merge 3 commits from upstream-pr/3399 into main
anoyarou commented 2026-11-26 22:18:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by anoyarou on 2026-11-26T22:18:40Z.


Summary

The Xbox build ships only Xbox button art. This adds a way to get PlayStation prompts without storing anything of the title in the repository. It covers the glyph part of #187; the SDL3 backend and controller detection in that issue are not part of this PR.

There are two commits, and the first is useful without the second:

  1. DirectStorage: VICTORY_FILE_PATCH serves byte ranges of the title's files from other files at read time. Nothing on disk changes. A list names, per line, <file name> <offset> <BLAKE3 of the original range> <file with the new bytes>. A range is patched only when the opened file's name matches and its bytes there still hash as listed, so another version of the game is left alone. The patches are loaded when the file is opened and applied in read_into, so every DirectStorage read of the file gets them.
  2. Tools: victory glyphs builds the patches from the user's own copy and writes the list into the cache folder:
    • Prompts in the HUD and menus: A/B/X/Y become cross, circle, square and triangle, LB/LT/RB/RT become L1/L2/R1/R2, and View becomes the touchpad. Only the label shapes in the title's prompt movie are replaced, inside the title's own button frames; every symbol, name and script of the movie stays as it is. Menu (the same icon as Options), the sticks and the D-pad are unchanged.
    • Settings controller picture (optional, --xelu): the Xbox controller on the controls screen becomes a DualSense, from Xelu's PS5 line art, which the user downloads.
victory glyphs [--game <folder>] [--xelu <folder with PS5_Diagram.png and PS5_Diagram_Simple.png>] [--out <folder>]
set VICTORY_FILE_PATCH=<the patches.txt it prints>

How it works

  • Finding the files without offsets in the repo. The command scans the user's archive for the zlib entry that inflates to the prompt movie, and the Settings texture file for the stream that inflates to a 1024x512 BC7 texture.
  • Rebuilding in place. The archive's table of contents is encrypted and is not touched, so an entry must keep its offset and its sizes. The rebuilt movie keeps the original's length (zeros after its End tag), and its zlib stream keeps the original stream's exact length. The game reads exactly that many bytes. The stream is zopfli for the start of the data, then stored blocks to fill the rest (victory_formats::zlib_exact, which has its own small inflater to find where the last block starts).
  • Settings picture. BC7 mode 6 (our encoder, victory_formats::bc7), tiled 64 KiB D with the existing texture::Layout. The menu draws the texture at about 0.75 of its width, so the picture is drawn wider to come out in proportion.
  • New modules. victory_formats::{swf, zlib_exact, bc7}, victory_game::{prompt_glyphs, settings_diagram}, apps/victory/src/glyphs.rs, and docs/playstation-prompts.md.

Assets and licences

  • Nothing of the title is stored. Everything derived from the user's copy goes to the cache folder (ensure_outside_repo). cargo xtask policy passes.
  • One string to flag. The command recognises the prompt movie by the suffix its button symbols are exported under, one string constant in prompt_glyphs.rs. I treated it like a name we look up, as with hooks. Please say if you would rather not have it under the asset policy; finding the movie by its structure instead is possible.
  • Prompt symbols are from Kenney's Input Prompts (CC0 1.0). The path data of the 9 symbols used (about 3.5 KB) is built in, with credit.
  • The Settings picture is from Xelu's Free Controller & Key Prompts (CC0). It is not in the repository; the user downloads it. The PS logo is left out.
  • New dependencies: zopfli (Apache-2.0, pure Rust) and png (MIT/Apache-2.0, pure Rust).
  • PlayStation and DualSense are trademarks of Sony Interactive Entertainment. They are named only in the docs credits.

Testing

  • Unit tests, on synthetic data our own code generates:
    • swf: shapes written and read back, shapes replaced, everything else byte for byte.
    • zlib_exact: our inflater reading zopfli and stored output, streams hitting exact lengths.
    • bc7: mode-6 round trips.
    • prompt_glyphs: a movie shaped like the title's, rebuilt.
    • settings_diagram: proportions, logo removal, finding and packing the stream.
    • file_patch: reads across and inside a range, a name that does not match, a hash that does not match, a bad line.
  • Under Wine (cross-built): all dstorage tests pass, the existing ones included.
  • On a real copy (local, Linux under Proton, RX 9070 XT): the command finds both files in about 5 s.
  • In game: the prompts show in the HUD and menus, and the Settings picture shows in proportion.
    • That was checked with the same two changes on a fork based on avatarmanz/VIctory-7900XTX. This branch is the same code adapted to main: read_into instead of the fork's read path, and miniz_oxide instead of zlib-rs.
    • On this branch's build, the patch list the command writes is byte-identical for the prompts. For the picture, the stream inflates to the same texture.
    • Not tried on a Windows host.

Limits

  • No live switching. The prompts are PlayStation for as long as the list is set; there is no controller detection.
  • Single source per screen. Only the prompt movie the scan finds, and the one Settings picture, are covered.
  • Measured squeeze. The 0.75 width factor of the Settings picture was measured on the controls screen; other screens using the texture, if any, are untested.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5517914578 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3399). Originally posted by [anoyarou](https://github.com/anoyarou) on 2026-11-26T22:18:40Z. --- ## Summary The Xbox build ships only Xbox button art. This adds a way to get PlayStation prompts without storing anything of the title in the repository. It covers the glyph part of #187; the SDL3 backend and controller detection in that issue are not part of this PR. There are two commits, and the first is useful without the second: 1. **DirectStorage: `VICTORY_FILE_PATCH`** serves byte ranges of the title's files from other files at read time. Nothing on disk changes. A list names, per line, `<file name> <offset> <BLAKE3 of the original range> <file with the new bytes>`. A range is patched only when the opened file's name matches and its bytes there still hash as listed, so another version of the game is left alone. The patches are loaded when the file is opened and applied in `read_into`, so every DirectStorage read of the file gets them. 2. **Tools: `victory glyphs`** builds the patches from the user's own copy and writes the list into the cache folder: - **Prompts in the HUD and menus:** A/B/X/Y become cross, circle, square and triangle, LB/LT/RB/RT become L1/L2/R1/R2, and View becomes the touchpad. Only the label shapes in the title's prompt movie are replaced, inside the title's own button frames; every symbol, name and script of the movie stays as it is. Menu (the same icon as Options), the sticks and the D-pad are unchanged. - **Settings controller picture (optional, `--xelu`):** the Xbox controller on the controls screen becomes a DualSense, from Xelu's PS5 line art, which the user downloads. ``` victory glyphs [--game <folder>] [--xelu <folder with PS5_Diagram.png and PS5_Diagram_Simple.png>] [--out <folder>] set VICTORY_FILE_PATCH=<the patches.txt it prints> ``` ## How it works - **Finding the files without offsets in the repo.** The command scans the user's archive for the zlib entry that inflates to the prompt movie, and the Settings texture file for the stream that inflates to a 1024x512 BC7 texture. - **Rebuilding in place.** The archive's table of contents is encrypted and is not touched, so an entry must keep its offset and its sizes. The rebuilt movie keeps the original's length (zeros after its `End` tag), and its zlib stream keeps the original stream's exact length. The game reads exactly that many bytes. The stream is zopfli for the start of the data, then stored blocks to fill the rest (`victory_formats::zlib_exact`, which has its own small inflater to find where the last block starts). - **Settings picture.** BC7 mode 6 (our encoder, `victory_formats::bc7`), tiled 64 KiB `D` with the existing `texture::Layout`. The menu draws the texture at about 0.75 of its width, so the picture is drawn wider to come out in proportion. - **New modules.** `victory_formats::{swf, zlib_exact, bc7}`, `victory_game::{prompt_glyphs, settings_diagram}`, `apps/victory/src/glyphs.rs`, and `docs/playstation-prompts.md`. ## Assets and licences - **Nothing of the title is stored.** Everything derived from the user's copy goes to the cache folder (`ensure_outside_repo`). `cargo xtask policy` passes. - **One string to flag.** The command recognises the prompt movie by the suffix its button symbols are exported under, one string constant in `prompt_glyphs.rs`. I treated it like a name we look up, as with hooks. Please say if you would rather not have it under the asset policy; finding the movie by its structure instead is possible. - **Prompt symbols** are from Kenney's [Input Prompts](https://kenney.nl/assets/input-prompts) (CC0 1.0). The path data of the 9 symbols used (about 3.5 KB) is built in, with credit. - **The Settings picture** is from Xelu's [Free Controller & Key Prompts](https://thoseawesomeguys.com/prompts/) (CC0). It is not in the repository; the user downloads it. The PS logo is left out. - **New dependencies:** `zopfli` (Apache-2.0, pure Rust) and `png` (MIT/Apache-2.0, pure Rust). - PlayStation and DualSense are trademarks of Sony Interactive Entertainment. They are named only in the docs credits. ## Testing - **Unit tests,** on synthetic data our own code generates: - `swf`: shapes written and read back, shapes replaced, everything else byte for byte. - `zlib_exact`: our inflater reading zopfli and stored output, streams hitting exact lengths. - `bc7`: mode-6 round trips. - `prompt_glyphs`: a movie shaped like the title's, rebuilt. - `settings_diagram`: proportions, logo removal, finding and packing the stream. - `file_patch`: reads across and inside a range, a name that does not match, a hash that does not match, a bad line. - **Under Wine (cross-built):** all `dstorage` tests pass, the existing ones included. - **On a real copy (local, Linux under Proton, RX 9070 XT):** the command finds both files in about 5 s. - **In game:** the prompts show in the HUD and menus, and the Settings picture shows in proportion. - That was checked with the same two changes on a fork based on avatarmanz/VIctory-7900XTX. This branch is the same code adapted to `main`: `read_into` instead of the fork's read path, and `miniz_oxide` instead of `zlib-rs`. - On this branch's build, the patch list the command writes is byte-identical for the prompts. For the picture, the stream inflates to the same texture. - Not tried on a Windows host. ## Limits - **No live switching.** The prompts are PlayStation for as long as the list is set; there is no controller detection. - **Single source per screen.** Only the prompt movie the scan finds, and the one Settings picture, are covered. - **Measured squeeze.** The 0.75 width factor of the Settings picture was measured on the controls screen; other screens using the texture, if any, are untested. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Jackster commented 2026-11-26 23:21:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T23:21:31Z.


Windows 11 — this one cannot be built in my environment, and I'd rather report that than a result:

  • cargo test -p victory-hle stops before compiling: the PR adds new crates.io dependencies (flate2, crc32fast, and fdeflate/zopfli through it), and this machine cannot fetch crates (schannel: AcquireCredentialsHandle failed: SEC_E_NO_CREDENTIALS). The error is failed to get \zopfli` as a dependency of package `victory-formats` … download failed`.
  • So there is no test result; the blocker is dependency fetching, not the patch.
  • Separately, its tests read button-prompt data from the user's own copy of the title, which the verification policy keeps out of tests and comments, so even with the dependencies a fully independent run would be limited.

If you can build it where crates are reachable, the useful check would be cargo test -p victory-hle -p victory-formats plus the patches_serve_their_range_when_the_file_matches path with a synthetic archive. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205473673 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3399#issuecomment-7205473673). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T23:21:31Z. --- Windows 11 — **this one cannot be built in my environment**, and I'd rather report that than a result: - `cargo test -p victory-hle` stops before compiling: the PR adds new crates.io dependencies (`flate2`, `crc32fast`, and `fdeflate`/`zopfli` through it), and this machine cannot fetch crates (`schannel: AcquireCredentialsHandle failed: SEC_E_NO_CREDENTIALS`). The error is `failed to get \`zopfli\` as a dependency of package \`victory-formats\` … download failed`. - So there is no test result; the blocker is dependency fetching, not the patch. - Separately, its tests read button-prompt data from the user's own copy of the title, which the verification policy keeps out of tests and comments, so even with the dependencies a fully independent run would be limited. If you can build it where crates are reachable, the useful check would be `cargo test -p victory-hle -p victory-formats` plus the `patches_serve_their_range_when_the_file_matches` path with a synthetic archive. AI-assisted.
anoyarou commented 2026-11-27 00:16:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by anoyarou on 2026-11-27T00:16:00Z.


Thanks for taking the time to try this on Windows 11, and for reporting the blocker instead of a guess.

The SEC_E_NO_CREDENTIALS error happens while crates are downloaded over TLS, before anything compiles. The only new direct dependencies are zopfli and png; flate2, crc32fast and fdeflate come in through png. All of them are pure Rust, so once crates.io can be reached, the build shouldn't need anything else.

About the test data: the tests don't need a copy of the title. They all run on data the tests generate themselves:

  • swf, zlib_exact and bc7 build their input in memory.
  • prompt_glyphs and settings_diagram build a small movie and texture shaped like the title's.
  • patches_serve_their_range_when_the_file_matches writes its own data.rpf, replacement bytes and patch list to a temp folder, then reads them back.

Only the victory glyphs command itself reads the user's copy, and no test uses that path.

To check this, I ran the tests again with no game data reachable: an empty environment, and for Wine a brand-new prefix.

  • cargo test -p victory-formats: 51 passed, 5 ignored. The ignored ones were already there before this PR: two benchmarks and three BCPack/XMA tests that need reference files outside the repository.
  • cargo test -p victory-game: 18 passed (prompt_glyphs, settings_diagram).
  • victory-hle, cross-built with cargo xwin test --target x86_64-pc-windows-msvc and run under Wine (not on a Windows host): 149 passed, 4 failed. All 17 dstorage tests passed, patches_serve_their_range_when_the_file_matches included. The 4 failures are in files this PR doesn't touch, and the same 4 fail the same way on main without the PR, so they look like Wine differences:
    • lifecycle::tests::a_title_window_is_shown_through_a_stand_in_that_always_answers
    • lifecycle::tests::showing_a_title_window_shows_its_stand_in
    • net::tests::only_loopback_is_reachable
    • xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied
  • The two victory-hle integration tests (fidelityfx, no_dll_planting) passed.

So on a machine that can reach crates.io, cargo test -p victory-formats -p victory-game -p victory-hle should be a complete check. I haven't run it on a Windows host yet, so a result from there would be very welcome, especially for those 4 tests.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206316492 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3399#issuecomment-7206316492). Originally posted by [anoyarou](https://github.com/anoyarou) on 2026-11-27T00:16:00Z. --- Thanks for taking the time to try this on Windows 11, and for reporting the blocker instead of a guess. The `SEC_E_NO_CREDENTIALS` error happens while crates are downloaded over TLS, before anything compiles. The only new direct dependencies are `zopfli` and `png`; `flate2`, `crc32fast` and `fdeflate` come in through `png`. All of them are pure Rust, so once crates.io can be reached, the build shouldn't need anything else. About the test data: the tests don't need a copy of the title. They all run on data the tests generate themselves: - `swf`, `zlib_exact` and `bc7` build their input in memory. - `prompt_glyphs` and `settings_diagram` build a small movie and texture shaped like the title's. - `patches_serve_their_range_when_the_file_matches` writes its own `data.rpf`, replacement bytes and patch list to a temp folder, then reads them back. Only the `victory glyphs` command itself reads the user's copy, and no test uses that path. To check this, I ran the tests again with no game data reachable: an empty environment, and for Wine a brand-new prefix. - `cargo test -p victory-formats`: 51 passed, 5 ignored. The ignored ones were already there before this PR: two benchmarks and three BCPack/XMA tests that need reference files outside the repository. - `cargo test -p victory-game`: 18 passed (`prompt_glyphs`, `settings_diagram`). - `victory-hle`, cross-built with `cargo xwin test --target x86_64-pc-windows-msvc` and run under Wine (not on a Windows host): 149 passed, 4 failed. All 17 `dstorage` tests passed, `patches_serve_their_range_when_the_file_matches` included. The 4 failures are in files this PR doesn't touch, and the same 4 fail the same way on `main` without the PR, so they look like Wine differences: - `lifecycle::tests::a_title_window_is_shown_through_a_stand_in_that_always_answers` - `lifecycle::tests::showing_a_title_window_shows_its_stand_in` - `net::tests::only_loopback_is_reachable` - `xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied` - The two `victory-hle` integration tests (`fidelityfx`, `no_dll_planting`) passed. So on a machine that can reach crates.io, `cargo test -p victory-formats -p victory-game -p victory-hle` should be a complete check. I haven't run it on a Windows host yet, so a result from there would be very welcome, especially for those 4 tests.
urattems commented 2026-11-30 10:19:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by urattems on 2026-11-30T10:19:10Z.


Tested on Windows 11 (RTX 5070, driver 621.14): the build works and the prompts show in game.

  • Builds and tests pass. Release build (MSVC, the pinned toolchain) is fine. The file_patch test passes, and so do the victory-formats and victory-game suites. The new crates.io dependencies download without problems here.
  • victory glyphs works first time. Run with no arguments against my own dump (title 1.0.2.1), it wrote patches.txt and the data.rpf range at 0x117d7000 (9644 bytes).
  • The patch applies in game. The log shows file patch: applies to this file path="…data.rpf" offset=293433344 len=9644. The start screen and in-game hints show PlayStation symbols (△ ✕ ◯ ▢, L2/R2) instead of Xbox letters. I've played several sessions with it on and seen no crashes or slowdowns from it.
  • The hash check works. When the patch path isn't passed, the stock Xbox prompts come back.

I also cherry-picked the three commits onto a downstream NVIDIA fork. Only dstorage.rs conflicted: the fork's File struct has extra fields, and the patches field slots in next to them. The mod lines in lib.rs and Cargo.lock also overlapped, and taking both sides fixed it.

Thanks for this. It makes a big difference with a DualSense.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7275428374 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3399#issuecomment-7275428374). Originally posted by [urattems](https://github.com/urattems) on 2026-11-30T10:19:10Z. --- Tested on Windows 11 (RTX 5070, driver 621.14): the build works and the prompts show in game. - **Builds and tests pass.** Release build (MSVC, the pinned toolchain) is fine. The `file_patch` test passes, and so do the `victory-formats` and `victory-game` suites. The new crates.io dependencies download without problems here. - **`victory glyphs` works first time.** Run with no arguments against my own dump (title 1.0.2.1), it wrote `patches.txt` and the `data.rpf` range at `0x117d7000` (9644 bytes). - **The patch applies in game.** The log shows `file patch: applies to this file path="…data.rpf" offset=293433344 len=9644`. The start screen and in-game hints show PlayStation symbols (△ ✕ ◯ ▢, L2/R2) instead of Xbox letters. I've played several sessions with it on and seen no crashes or slowdowns from it. - **The hash check works.** When the patch path isn't passed, the stock Xbox prompts come back. I also cherry-picked the three commits onto a downstream NVIDIA fork. Only `dstorage.rs` conflicted: the fork's `File` struct has extra fields, and the `patches` field slots in next to them. The `mod` lines in `lib.rs` and `Cargo.lock` also overlapped, and taking both sides fixed it. Thanks for this. It makes a big difference with a DualSense.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3399:upstream-pr/3399'
git switch 'upstream-pr/3399'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3399'
git switch 'upstream-pr/3399'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3399'
git switch 'upstream-pr/3399'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3399'
git switch 'main'
git merge --squash 'upstream-pr/3399'
git switch 'main'
git merge --ff-only 'upstream-pr/3399'
git switch 'main'
git merge 'upstream-pr/3399'
git push origin 'main'
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
Marvisak/VIctory!3399
No description provided.