Skip to content

feat: read dumps in place from the user's games folder, zips included (#110) - #111

Merged
OmarAglan merged 4 commits into
mainfrom
phase2/dump-in-place
Nov 29, 2026
Merged

OmarAglan merged 4 commits into
mainfrom
phase2/dump-in-place

Conversation

@OmarAglan

@OmarAglan OmarAglan commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #110

What changed

The app reads the user's dumps where they live on the phone, zipped or not, and never copies or extracts them (ADR 0019, ADR 0020).

  • Launcher: the copy-import (Import a file through the Storage Access Framework  #46, ImportCopy) is gone.
    • The user picks one games folder (ACTION_OPEN_DOCUMENT_TREE, with a lasting read grant) and adds their dumps and BIOS to it.
    • The launcher scans the folder and one level of subfolders. Every .cue file is a game, and so is every .zip that holds one; every 512 KiB file is a BIOS.
    • When there is one of a kind it is taken; with several, the user picks from Choose game or Choose BIOS. Play starts the PS1 runtime.
    • A lost grant, or a game or BIOS no longer in the folder, is forgotten with a message. Strings are in English and Arabic, with names bidi-wrapped.
  • Host: anqa_host_set_root_opener (anqa_host.h, not the plugin ABI) makes a read-only root whose files come from a callback.
    • The callback returns a whole fd, or a zip entry in one (stored or deflated).
    • phal checks paths first, refuses anything that isn't a readable regular file, and rejects entries that don't fit in their file.
    • Deflated entries are read at any offset by zip_entry.cpp: it inflates forward and keeps a seek point every 1 MiB (system zlib; ADR 0020 records the license).
  • Android: host/android/main.cpp sets the imports root's opener to DumpFiles.open over JNI.
    • DumpFiles.open maps ps1-bios.bin and ps1-disc.cue to the user's choices, and the CUE's BIN names to files beside it, exact match first, else a unique case-insensitive one.
    • ZipIndex reads a zip's central directory.
  • Runtime: unchanged. It still opens its files through phal only.
  • Build: the linux-aarch64 preset sets ANQA_ZLIB=OFF because Ubuntu has no arm64 cross zlib. Deflated entries then refuse to open with PHAL_ERR_UNSUPPORTED, and the test checks exactly that.
  • Docs: ADRs 0019 and 0020, a pointer in ADR 0014, PLAN.md, PROGRESS.md.

How it was tested

  • host_files_test:
    • opener roots: paths are refused before the callback runs, errors pass through, and directory, pipe and write-only fds are refused and closed;
    • zip entries: stored ones are clipped to their bytes; damaged ones are refused;
    • a 3 MiB deflated entry is read whole, in sector-sized out-of-order reads and from four threads at once;
    • a truncated stream fails instead of returning short data.
    • Breaking the seek points on purpose makes it fail.
  • JVM tests:
    • DumpNamesTest: name resolution and the folder scan;
    • ZipIndexTest: entries, a UTF-8 name, data offsets checked with Inflater, a long comment, non-zips.
  • Linux build and ctest --preset linux-debug: 45/47 pass in WSL. The two license-audit tests fail there only because WSL git can't read a worktree; from Windows, run.py and test_run.py pass.
  • ./gradlew :launcher:assembleDebug and :launcher:testDebugUnitTest pass.
  • On the S26 Ultra, with the owner's go-ahead to copy the files to the phone: Ridge Racer (USA).zip and SCPH1001 are in Download/AnqaGames.
    • The folder was picked, and the game and BIOS were found and chosen automatically.
    • The log shows ps1: disc ps1-disc.cue: 14 tracks, and the boot EXE runs at frame 581.
    • Nothing was added to app storage: files is 654 KB before and after.
    • Speed: the release APK (signed locally with the debug key) holds 120 Hz (p50 8.40 ms, p99 14.5 ms). The debug APK runs at about 13 fps because its code is unoptimized and the validation layer is on.

Checklist

  • Linked issue (one issue = one branch = one PR)
  • Tests added (unit test, golden frame hash, or both)
  • Build passes (cmake --build --preset linux-debug, ./gradlew :launcher:assembleDebug)
  • License audit passes (python3 tools/license_audit/run.py)
  • docs/PROGRESS.md updated
  • No game data, disc images, BIOS, firmware or generated game code committed
  • Before merge: Codex review read, /code-review run, every finding fixed or answered (CLAUDE.md Workflow)

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-28T13:06:57.074322Z
We couldn’t complete this review. Comment @codex review to try again.
39cd97a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

OmarAglan added a commit that referenced this pull request Nov 28, 2026
…nd record past a comment, one JNI class ref, scan failure message
@OmarAglan

Copy link
Copy Markdown
Contributor Author

/code-review (high) found 5 issues. All are fixed in 45533aa:

  • important: a forward read on a deflated entry ignored seek points between the current position and the target, so after a seek back it inflated everything up to the target. It now restarts from the nearest point when one lies in between.
  • nit: the zip end-record search could match the signature bytes inside an archive comment. A candidate must now have its comment run to the end of the file, and a test covers it.
  • nit: each main() made a new JNI global ref to DumpFiles. The class is now looked up once per process.
  • nit: it wasn't documented that the opener calls into Java and so must not be reached from a fiber. anqa_host.h now says so. The PS1 runtime opens imports in init.
  • nit: a failed folder scan told the user that the BIOS and games were missing. It now shows "can't open the games folder".

Still to do: the phone check on the S26 Ultra.

@OmarAglan
OmarAglan force-pushed the phase2/dump-in-place branch from 9c9febb to 7326c1b Compare November 28, 2026 16:13
@OmarAglan OmarAglan mentioned this pull request Nov 28, 2026
3 of 4 tasks
@OmarAglan
OmarAglan merged commit 934bc55 into main Nov 29, 2026
4 checks passed
OmarAglan added a commit that referenced this pull request Nov 29, 2026
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.

Read the PS1 dump and BIOS in place, without copying

1 participant