Expand description
CD-ROM drive: commands, responses, sector polling, CD-DA playback in
audio, XA-ADPCM music in xa and polled data-sector reads in
reader.
One driver owns the controller: the Cd token. Every command and
register step is a method taking &mut Cd, so the borrow checker sees a
second driver that tries to program the controller while one is mid-command.
xa::Player and reader::SectorReader hold the token while they exist
and give it back with release.
The controller exposes four byte registers selected by the low two
bits of the index register at [psx_hw::cd::reg::INDEX]. Register addresses, command bytes
and status bits live in [psx_hw::cd].
Modules§
- audio
- CD-DA playback helpers: a start-handshake state machine and an audio-anchored clock.
- reader
- Polled CD-ROM data-sector reads: seek, stream and pop 2048-byte sectors.
- xa
- XA-ADPCM music: stream one channel of an interleaved XA file through the drive’s own decoder to the SPU’s CD input.
Structs§
- Play
Position - Decoded CdlGetlocP reply. The relative MSF (
relative_*) is elapsed time into the current track, independent of the pregap, which makes it the source of truth for a music/song clock. The absolute MSF (absolute_*) is the raw disc position. - Response
- Fixed-size command response.
- Sector
Poll Error - A drive error reported while polling for the next streamed sector.
Enums§
- CdError
- Why a CD command produced no response.
Constants§
- DEFAULT_
COMMAND_ SPINS - Poll budget the blocking commands give the controller for each wait (a parameter slot, then the acknowledge). Generous: the controller frees a slot and acknowledges within microseconds to milliseconds, so this is a hang guard, not a latency.
Functions§
- acknowledge_
irq Deprecated - Moved to
Cd::acknowledge_irq. - bcd_
to_ bin - Convert a BCD byte back to binary. Inverse of
bin_to_bcdfor well-formed input; nibbles above 9 are not normalised (the drive never emits them). - bin_
to_ bcd - Convert binary
0..=99to BCD for CD-ROM command parameters. - discard_
response Deprecated - Moved to
Cd::discard_response. - dispatch_
command Deprecated - Moved to
Cd::dispatch_command. - irq_
flag_ value Deprecated - Moved to
Cd::irq_flag_value. - lba_
to_ bcd_ msf - Data-track LBA to the absolute BCD
[minute, second, frame]Setloc takes. LBA 0 is 00:02:00: the 150-sector lead-in puts it two seconds in. Minutes clamp at 99. - poll_
data_ sector Deprecated - Moved to
Cd::poll_data_sector. - restore_
irq_ output Deprecated - Moved to
Cd::restore_irq_output. - try_
command Deprecated - Moved to
Cd::try_command. - try_
mute Deprecated - Moved to
Cd::try_mute. - try_
pause Deprecated - Moved to
Cd::try_pause. - try_
pause_ until_ complete Deprecated - Moved to
Cd::try_pause_until_complete. - try_
play_ position Deprecated - Moved to
Cd::try_play_position. - try_
play_ track Deprecated - Moved to
Cd::try_play_track. - try_
set_ mode Deprecated - Moved to
Cd::try_set_mode. - try_
set_ target_ lba Deprecated - Moved to
Cd::try_set_target_lba. - try_
start_ reading Deprecated - Moved to
Cd::try_start_reading. - try_
status Deprecated - Moved to
Cd::try_status. - try_
unmute Deprecated - Moved to
Cd::try_unmute.