Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Module cd

Module cd 

Source
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§

SectorReader
Moved to psx_io::cd::reader. Kept at this path for one stage so psx_pack::cd::SectorReader still 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 so psx_pack::cd::SectorReader still resolves; a re-export cannot carry a deprecation. SectorReader::diagnostics cause 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 so psx_pack::cd::SectorReader still resolves; a re-export cannot carry a deprecation. SectorReader::diagnostics cause byte: the parameter FIFO never freed up.
DIAG_SITE_READ
Moved to psx_io::cd::reader. Kept at this path for one stage so psx_pack::cd::SectorReader still resolves; a re-export cannot carry a deprecation. SectorReader::diagnostics command byte standing in for a read_sector wait (ReadN is streaming; no command byte is in flight).
DIAG_TIMEOUT
Moved to psx_io::cd::reader. Kept at this path for one stage so psx_pack::cd::SectorReader still resolves; a re-export cannot carry a deprecation. SectorReader::diagnostics cause 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 place WORLD.PAK: the pack’s first sector, as an absolute data-track LBA. Mirrors psx_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_lba for chunk_id and return its entry (including byte_size and the FNV checksum the writer stored).
load_chunk
Stream chunk chunk_id from the pack at pack_lba into dst.
load_chunk_decompressed
load_chunk, then crate::decompress_hlzc_in_place on the result.