Skip to content

Search files in the configured disc image and add sceCdTrayReq - #267

Open
drakolordx7 wants to merge 1 commit into
ran-j:mainfrom
drakolordx7:fix/iop-cdvd-image-search-trayreq
Open

drakolordx7 wants to merge 1 commit into
ran-j:mainfrom
drakolordx7:fix/iop-cdvd-image-search-trayreq

Conversation

@drakolordx7

Copy link
Copy Markdown

With a disc image configured, the cdvdman emulation reads sectors from the image but resolved sceCdSearchFile against the virtual ISO9660 layout built from the host folder. The two assign different LSNs, so a guest that looks a file up and then reads it with sceCdRead (an IRX streaming from disc, for example) reads the wrong sectors, or the search fails when there is no host folder.

sceCdSearchFile now walks the image's own ISO9660 directory (primary volume descriptor, then the directory record of each path component, honouring sector padding and ;version suffixes) and returns that record's LSN, size and directory flag. Without an image, or if the image has no ISO9660 descriptor, the virtual layout is used as before.

Also implements sceCdTrayReq (cdvdman #14), previously an unhandled import: the tray never moves, so it stores a tray count of 0 and returns 1. (Killzone's PFILE_R.IRX calls it about 2.7k times per boot.)

Tests: new ps2_iop_emulator_tests case with an in-memory ISO9660 image (file in a subdirectory, missing file, sceCdTrayReq); the search part fails without the change. ps2xIOP ctest 4/4, gs_cache ctest 45/45 and ps2x_tests unchanged from main.

Behaviour change: with a valid image, a file that is not in the image now returns 0 instead of falling back to the host-folder layout.

Made by drakolord and assisted with Claude Code.

With a disc image configured (HostPathKind::CdImage), the cdvdman
emulation reads sectors from the image but resolved sceCdSearchFile
against the virtual ISO9660 layout built from the host folder. The two
assign different LSNs, so a guest that looks a file up and then reads it
through sceCdRead (an IRX streaming from disc, for example) read the
wrong sectors, or failed the search when there is no host folder.

Walk the image's own ISO9660 directory for sceCdSearchFile instead: read
the primary volume descriptor, then the directory record of each path
component (honouring the padding at sector ends and ;version suffixes),
and return the record's LSN, size and directory flag. If there is no
image or it has no ISO9660 volume descriptor, the virtual layout is used
as before. The result buffer writing is shared by both paths.

Also implement sceCdTrayReq (cdvdman ran-j#14), which was an unhandled import:
the tray never moves, so it stores a tray count of 0 and returns 1.
Killzone's PFILE_R.IRX calls it about 2.7k times per boot.

The new test runs a module that searches an in-memory ISO9660 image (file
in a subdirectory, file missing) and calls sceCdTrayReq; the search part
fails without the change.

Made by drakolord and assisted with Claude Code.
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