Skip to content

PS5: native homebrew title, and a packed ROM cache for it - #410

Open
Darkatek7 wants to merge 2 commits into
UNDERdecoded:mainfrom
Darkatek7:ps5-port
Open

Darkatek7 wants to merge 2 commits into
UNDERdecoded:mainfrom
Darkatek7:ps5-port

Conversation

@Darkatek7

Copy link
Copy Markdown

Runs the game on a jailbroken PS5 as its own homebrew title (PPSA42002, registered by ShadowMountPlus). Experimental, and there is no release asset yet.

What's in it

  • Runtime (ports/ps5/, scripts/build_ps5.sh, scripts/ps5/):
    • LÖVE 11.5 on the ps5-opengl SDK (Mesa on AGC, GL 4.6 core), SDL with ScePad / SceAudioOut, and LuaJIT with FFI.
    • Built in WSL and deployed over FTP. Details are in ports/ps5/BUILD.md.
  • Console fixes the runtime needed:
    • lstat returns EPERM, so it is wrapped onto stat.
    • The system readdir returns nothing under /data, so a getdents-based directory API replaces it.
    • LuaJIT's os.clock ran 7812× too fast, because Sony's clock() counts microseconds.
    • PhysFS created 0700 folders that ftpsrv cannot enter, so they are now created open to everyone (patch 0002 plus a chmod in the launcher).
    • A relative io.open fails with EINVAL there, so the ROM queue passes the real path.
  • Game side:
    • Platform.isPS5 and a TV-console profile: pad only, no file picker, update notice only, FTP hints.
    • 1080p fullscreen.
    • A README section.
  • Packed ROM cache (src/import/CachePack.lua, CacheFs, the import worker):
    • On the PS5 a Platinum import took 44 minutes. Creating each of the ~18,400 files on /data costs about 11 ms, and after that a create stalls for 0.5–0.9 s about once a second. Appending the same bytes to one file took 8 s.
    • So on the PS5 (or anywhere with POKEPORT_PACKED_CACHE=1) the import writes each version's generated trees into one store-only zip, <prefix>rom-cache.zip, and the game reads it through PhysFS.
    • Loose files still win over the archive, so mods and runtime writes keep working.
    • Every other platform keeps writing loose files exactly as before.
  • Translation: the worker reads a packed cache through the archive's mount. The online hub still only offers games that have a loose cache.

Testing

  • PS5 (FW 13.00, etaHEN):
    • A Platinum re-import takes about 54 s instead of 44 min.
    • The pack was downloaded and checked: 18,432 entries, all CRCs correct.
    • Played from the pack: intro and title screen, a new game into the overworld, a stair warp, outdoors, a save, then quitting and Continue.
  • Desktop with POKEPORT_PACKED_CACHE=1:
    • The pack is byte-identical to a loose import (same 18,432 files, no differences).
    • The scripted boot reaches the overworld with screenshots identical to the loose boot.
    • An import killed midway is not reported ready.
    • Re-importing over an existing pack works.
  • Checks:
    • New: tools/cache_pack_check.lua, 77/77 (CRC, round trip, in-progress reads, the 65,534-entry limit, overflow to loose files, loose wins, abort, clear).
    • Existing ones pass: nds_import_verification_check, tools/translation/check.lua, gen4_cache_wiring_check, and the Switch path, launcher and import-recovery checks.

Known gaps

  • No battle has been played on the console yet, and audio is unverified by ear.
  • Re-importing a version in the same session after walking its overworld is refused with "restart the game and import again". Gen 4 ground keeps range-file handles on the archive open after leaving the game.

The game now runs on a jailbroken PS5 as its own title (PPSA42002, loaded by
ShadowMountPlus): LOVE 11.5 on the ps5-opengl SDK (Mesa on AGC, GL 4.6 core),
SDL with ScePad / SceAudioOut, LuaJIT with FFI. scripts/build_ps5.sh builds
the runtime in WSL and deploys over FTP; ports/ps5/BUILD.md has the details.

Runtime fixes the console needed: lstat answers EPERM (wrapped onto stat),
the system readdir returns nothing under /data (getdents-based dir API),
LuaJIT's os.clock ran 7812x fast (Sony clock() counts microseconds), and
PhysFS made 0700 folders that ftpsrv cannot enter (patch 0002 + launcher
chmod). A relative io.open is EINVAL there, so the ROM queue passes the
real path.

Game side: Platform.isPS5, a TV-console profile (pad only, no picker,
notify-only updates, FTP hints), and 1080p fullscreen.

PACKED CACHE. Creating ~18,400 files on /data took 44 minutes for a
Platinum import (each create ~11 ms, then 0.5-0.9 s stalls about once a
second); the same bytes appended to one file took 8 s. On the PS5 (or with
POKEPORT_PACKED_CACHE=1) the import now writes each version's generated
trees into one store-only zip, <prefix>rom-cache.zip, and the game reads it
through PhysFS; loose files still win over the archive. Measured on the
console: re-import ~54 s, pack verified (18,432 entries, CRCs ok), title,
overworld, warps, save and reload all from the pack. Other platforms keep
writing loose files exactly as before.

The translation worker reads a packed cache through the archive's mount.
The online hub still only offers games with a loose cache.

tools/cache_pack_check.lua: 77 checks (CRC, round trip, in-progress reads,
65,534-entry limit, overflow to loose, loose wins, abort, clear).
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