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

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§

PlayPosition
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.
SectorPollError
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_irqDeprecated
Moved to Cd::acknowledge_irq.
bcd_to_bin
Convert a BCD byte back to binary. Inverse of bin_to_bcd for well-formed input; nibbles above 9 are not normalised (the drive never emits them).
bin_to_bcd
Convert binary 0..=99 to BCD for CD-ROM command parameters.
discard_responseDeprecated
Moved to Cd::discard_response.
dispatch_commandDeprecated
Moved to Cd::dispatch_command.
irq_flag_valueDeprecated
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_sectorDeprecated
Moved to Cd::poll_data_sector.
restore_irq_outputDeprecated
Moved to Cd::restore_irq_output.
try_commandDeprecated
Moved to Cd::try_command.
try_muteDeprecated
Moved to Cd::try_mute.
try_pauseDeprecated
Moved to Cd::try_pause.
try_pause_until_completeDeprecated
Moved to Cd::try_pause_until_complete.
try_play_positionDeprecated
Moved to Cd::try_play_position.
try_play_trackDeprecated
Moved to Cd::try_play_track.
try_set_modeDeprecated
Moved to Cd::try_set_mode.
try_set_target_lbaDeprecated
Moved to Cd::try_set_target_lba.
try_start_readingDeprecated
Moved to Cd::try_start_reading.
try_statusDeprecated
Moved to Cd::try_status.
try_unmuteDeprecated
Moved to Cd::try_unmute.