// SPDX-License-Identifier: MIT //! The machine rows: every difference between the 5200 models is a field with its source. //! //! Source keys are those of docs/start-here.md. A field nobody documents carries //! "unknown: default" in its source and the value the board uses meanwhile. //! //! Evidence tags (family methodology): MEASURED, DIE, TEST ROM, DOC, OBSERVED, //! FITTED, HYPOTHESIS. Acid5200 is tagged TEST ROM with the caveat that its //! author states hardware passes but no recorded 5200 run exists (U7). //! //! A transcription of a5200-python's `machine.py` (at cf82d44). Rust-forced differences: the //! frozen dataclasses are structs built by `const` functions; `MACHINES` is a lookup function //! (`machine_by_name`) over the two rows; the `@property` values are methods; the //! `pokey_seed` is an `Option` (pokey-rust's `power_on` takes one). // MEASURED (SHA-1 of the dumps held here); DOC [AHRM] F.2 lists the same hashes. pub const BIOS_4PORT_SHA1: &str = "6ad7a1e8c9fad486fbec9498cb48bf5bc3adc530"; // CO19156 pub const BIOS_REVA_SHA1: &str = "1d2a3f00109d75d2d79fecb565775eb95b7d04d5"; // CO19156A /// `BIOS_NAMES` as a function: the name for a BIOS SHA-1. pub fn bios_name(sha1: &str) -> Option<&'static str> { match sha1 { BIOS_4PORT_SHA1 => Some("CO19156 (4-port)"), BIOS_REVA_SHA1 => Some("CO19156A (revision A)"), _ => None, } } /// Power-on parameters (U8): nothing documents them; each is a labelled default. /// /// HYPOTHESIS for every field: a probe ROM on a real console reading RAM, /// VCOUNT and POKEY's RANDOM at the first instruction would settle them. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct PowerOn { pub ram_fill: u8, // HYPOTHESIS: [AHRM] 2.3 says RAM contents are undefined; default 0 pub line: u32, // HYPOTHESIS: ANTIC's vertical counter ([AHRM] 4.1 fn 11: varies); default 0 pub cycle: u32, // HYPOTHESIS: ANTIC's horizontal counter, undocumented; default 0 pub pokey_seed: Option, // None = pokey-python's all-zero power-on (its B1.8, a choice) } impl PowerOn { pub const fn default() -> Self { PowerOn { ram_fill: 0x00, line: 0, cycle: 0, pokey_seed: None, } } } #[derive(Clone, Copy, Debug, PartialEq)] pub struct Machine { pub name: &'static str, pub description: &'static str, pub bios_sha1: &'static str, pub ports: usize, // DOC: controller ports ([FSM]; [FAQ] 4.8) pub pots_upper_grounded: bool, // DOC: POT4-POT7 tied to ground ([FAQ] 4.10 item 2) pub trig3_wired_to_trig1: bool, // DOC: early 2-port boards ([FAQ] 4.10 item 1) pub consol_bit1_selects_ports_34: bool, // DOC: CONSOL bit 1 needs ports 3-4 ([AHRM] 13.3) pub crystal_hz: f64, // DOC: [FSM] parts list Y1 (C2, open decision 6) // DOC: crystal / 2 ([FSM] Figure 1-6); HYPOTHESIS until the oscillator sheet is read (U1) pub cpu_divider: u32, pub lines: u32, // DOC: NTSC ANTIC ([AHRM] 4.2 Table 6); TEST ROM antic_* timing pub cycles_per_line: u32, // DOC: [AHRM] 4.2; [HM] II; TEST ROM cpu_timing pub pal_gtia: bool, // DOC: no PAL 5200 was made ([FAQ] 4.8); a chip field only pub f000_mirror: bool, // HYPOTHESIS (C8): $F000-$F7FF reads the 2K BIOS again; a probe // ROM reading $F000 on a console settles it pub power_on: PowerOn, pub sources: &'static [&'static str], } impl Machine { pub fn cycle_hz(&self) -> f64 { self.crystal_hz / self.cpu_divider as f64 } pub fn cycles_per_frame(&self) -> u64 { (self.lines * self.cycles_per_line) as u64 } pub fn frame_hz(&self) -> f64 { self.cycle_hz() / self.cycles_per_frame() as f64 } } pub const A5200: Machine = Machine { name: "a5200", description: "Atari 5200 SuperSystem, 4-port board (1982), BIOS CO19156", bios_sha1: BIOS_4PORT_SHA1, ports: 4, pots_upper_grounded: false, trig3_wired_to_trig1: false, consol_bit1_selects_ports_34: true, crystal_hz: 3_579_575.0, cpu_divider: 2, lines: 262, cycles_per_line: 114, pal_gtia: false, f000_mirror: true, power_on: PowerOn::default(), sources: &["[FSM] 4-port parts list", "[AHRM] 13", "[BUCH]"], }; pub const A5200_2PORT: Machine = Machine { name: "a5200_2port", description: "Atari 5200 SuperSystem, 2-port board (1983), BIOS CO19156A", bios_sha1: BIOS_REVA_SHA1, ports: 2, pots_upper_grounded: true, trig3_wired_to_trig1: false, // after the factory modification ([FAQ] 4.10 item 1) consol_bit1_selects_ports_34: false, crystal_hz: 3_579_575.0, cpu_divider: 2, lines: 262, cycles_per_line: 114, pal_gtia: false, f000_mirror: true, power_on: PowerOn::default(), sources: &["[FSM] 2-port parts list", "[FAQ] 4.8, 4.10", "[AHRM] F.2"], }; /// `MACHINES[name]`. pub fn machine_by_name(name: &str) -> Option { [A5200, A5200_2PORT].into_iter().find(|m| m.name == name) }