Expand description
CD-DA playback helpers: a start-handshake state machine and an audio-anchored clock.
Both are extractions of code that at least three projects grew
independently (gh-psx, the magikarp example, the engine’s private
CddaPlayer), and both encode silicon findings that are expensive to
rediscover:
- Starting CD-DA after the no-BIOS fast boot needs the drive PRIMED:
SetMode -> Demute -> Play, with a GetStat drain AFTER each command
(a GetStat immediately before a command wedges the controller
instead), a cold-drive delay before the first command, and retry
pacing between attempts.
PlaybackStarteris that machine. - A song clock read from the vblank counter drifts off the audio (the
display and the CD run on different oscillators), while GetlocP alone
is jittery and coarse (75 Hz).
PlaybackClockanchors on GetlocP and interpolates with ticks, with a deadband, spike confirmation, and monotonic output.
Both are poll-driven: call them once per frame/tick with your tick counter. Neither takes an interrupt or blocks beyond the bounded command spins.
Structs§
- EndDetector
- Track-end detection that survives real drive behaviour.
- Playback
Clock - Audio-anchored song clock: GetlocP anchor + tick interpolation.
- Playback
Starter - Poll-driven CD-DA start handshake (SetMode -> Demute -> Play).
Constants§
- COLD_
DRIVE_ DELAY_ TICKS - Ticks to wait before the very first command: hammering CD commands while the drive is still cold from boot can wedge it (observed on silicon).
- DEFAULT_
COMMAND_ SPINS - Per-command response spin budget. Generous; the drive answers far sooner.