Overview

A CD image (.bin) is a flat run of sectors, addressed by LBA (logical block address - the sector number, counting from the start of the disc). "Mode2/2352" names the sector flavour PlayStation discs use: mode 2 of the CD-ROM XA standard, stored as full 2352-byte raw sectors rather than pre-stripped 2048-byte ones. Reading a file therefore means knowing which LBA it starts at and peeling the 2048 user-data bytes out of each sector.

Implementation: crates/iso/src/raw.rs.

Sector layout

Bytes Meaning
0..12 Sync pattern 00 FF FF FF FF FF FF FF FF FF FF 00
12..16 Header (M:S:F address + mode byte)
16..24 Subheader (file/channel/submode/coding)
24..2072 User data (2048 bytes)
2072..2352 EDC + ECC error correction

The iso crate's RawDisc::read_sector(lba) returns just the 2048-byte user data slice. read_user_data(lba, count, buf) reads a contiguous run.

const SECTOR_SIZE: usize = 2352;
const USER_DATA_OFFSET: usize = 24;
const USER_DATA_SIZE: usize = 2048;

ISO9660 walk

On top of the sector layer sits ISO9660, the standard CD filesystem - it's what turns "sector 16" into named files and directories. Implementation: crates/iso/src/iso9660.rs. The layout is textbook:

  • Primary Volume Descriptor at LBA 16.
  • Root directory record at PVD offset 156.
  • Each directory record begins with a length byte; records pad to even lengths.

The walker is iterative (not recursive) and yields stable-sorted file paths. The Legend of Legaia (USA) disc produces 45 files:

CDNAME.TXT  DMY.DAT  PROT.DAT  SCUS_942.54  SYSTEM.CNF
MOV/MV1.STR ... MV6.STR
XA/XA1.XA  ... XA21.XA

Almost everything interesting lives in just a few of these. PROT.DAT is the main asset archive - nearly every texture, model, script, and sound bank in the game is one of its numbered entries; see PROT.DAT TOC. SCUS_942.54 is the game's main executable. CDNAME.TXT is a developer-left name map for the archive's entries. MOV/MV*.STR are PSX MDEC video streams (the movies; delegate to public decoders like jPSXdec). XA/XA*.XA are XA-ADPCM streaming audio; crates/xa decodes the format spec but the on-disc files use a non-standard interleave. Reverse-engineering instructions: tooling/ghidra.md.

See also