Expand description
The pack-table scan and chunk streaming, on top of the polled sector reader.
The CD controller has one driver, psx_io::cd: the Cd token, its
register steps, and SectorReader, the polled reader that sequences
SetMode, Setloc, ReadN and Pause the way the pack loader has run on
silicon. This module holds what the pack format adds: finding a chunk’s
table entry and copying its sectors into a caller’s buffer.
Everything that touches the drive is cfg(target_arch = "mips"); on the
host only the constants and the SectorReader re-export compile, so
cargo test keeps covering the pure pieces.
§What loading does to the machine
load_chunk and find_entry (guest only) bracket each read with
SectorReader::prepare and SectorReader::stop. Between the two,
I_MASK is VBlank-only (the reader polls the controller’s own IRQ flags,
so a CD-ROM CPU interrupt with no handler cannot storm). stop puts the
previous mask back, so a caller’s timer or controller interrupts survive a
chunk load. The reader needs the Cd token: SectorReader::with_cd.
No caching happens at this layer. hl-psx’s 512-entry table cache (skip re-scanning the header on every chunk load) is a game-side optimization: keep it in the game, keyed to its own pack, where the entry count and the RAM budget are known.
Structs§
- Sector
Reader - Moved to
psx_io::cd::reader. Kept at this path for one stage sopsx_pack::cd::SectorReaderstill resolves; a re-export cannot carry a deprecation. Blocking, polled CD-ROM sector reader.
Constants§
- DIAG_
CD_ ERROR - Moved to
psx_io::cd::reader. Kept at this path for one stage sopsx_pack::cd::SectorReaderstill resolves; a re-export cannot carry a deprecation.SectorReader::diagnosticscause byte: the drive raised INT5; the snapshot carries the error response’s status and error-code bytes. - DIAG_
PARAM_ STUCK - Moved to
psx_io::cd::reader. Kept at this path for one stage sopsx_pack::cd::SectorReaderstill resolves; a re-export cannot carry a deprecation.SectorReader::diagnosticscause byte: the parameter FIFO never freed up. - DIAG_
SITE_ READ - Moved to
psx_io::cd::reader. Kept at this path for one stage sopsx_pack::cd::SectorReaderstill resolves; a re-export cannot carry a deprecation.SectorReader::diagnosticscommand byte standing in for aread_sectorwait (ReadN is streaming; no command byte is in flight). - DIAG_
TIMEOUT - Moved to
psx_io::cd::reader. Kept at this path for one stage sopsx_pack::cd::SectorReaderstill resolves; a re-export cannot carry a deprecation.SectorReader::diagnosticscause byte: the wait spun out; the snapshot carries the raw status register and the last IRQ flag seen. - SECTOR_
WORDS - One CD sector’s user data in 32-bit words (
SECTOR_BYTES / 4). - WORLD_
PACK_ DEFAULT_ LBA - Where
mkisopsx/ the editor’s embedded Play placeWORLD.PAK: the pack’s first sector, as an absolute data-track LBA. Mirrorspsx_iso::WORLD_PACK_DEFAULT_START_LBA(the writer reserves a fixed boot area so runtime LBAs never depend on the boot EXE size); a host test in this crate asserts the two constants stay equal.
Functions§
- find_
entry - Scan the pack table at
pack_lbaforchunk_idand return its entry (includingbyte_sizeand the FNVchecksumthe writer stored). - load_
chunk - Stream chunk
chunk_idfrom the pack atpack_lbaintodst. - load_
chunk_ decompressed load_chunk, thencrate::decompress_hlzc_in_placeon the result.