//! The README's "Notes on the reference": behaviour of pcenginecd-python v0.1.0 that reads as //! unintended, transcribed as it is (the gate runs through it). `scripts/reference_notes.py` //! prints the same numbers from the reference. mod common; use common::{disc_audio_then_data, Host, MASTER_HZ}; use pcenginecd_rust::unit::CdUnit; /// Master clocks from a SEL write to the command phase, looked for every 12 clocks. fn sel_to_command(prepare: fn(&mut Host)) -> i64 { let mut h = Host::new(CdUnit::new(Some(disc_audio_then_data(400, 20)))); prepare(&mut h); h.advance(MASTER_HZ); // a second passes: `advance` is the board's catch_up h.select(); let began = h.t; while h.read(0x1FF800, h.t) & 0xF8 != 0xD0 { h.t += 12; h.advance(0); } h.t - began } /// Note 1. The drive's clock stands still between events: `catch_up` runs the bus (and moves /// `bus.now`) only when an event is due or none is pending, so while the end of a CD audio /// track waits in the future, the timer a SEL write starts counts from the last time the bus /// happened to run, and the command phase comes at once. #[test] fn the_drives_clock_stands_still_while_an_event_waits() { assert_eq!(sel_to_command(|_| {}), 75_000); // ScsiSwitches::sel_to_command_phase let music = |h: &mut Host| { h.command(&[0xD8, 1, 0x01, 0, 0, 0, 0, 0, 0, 0x80]); // AUDIO START: track 1 (5.3 s) h.finish(); }; assert_eq!(sel_to_command(music), 0); }