// SPDX-License-Identifier: MIT //! Milestone 7: the PAL and SECAM rows, and the TIA revision fields from ale-79's //! #699 tables (the reference's tests/test_revisions.py). The full judge is //! `a2600-gates serial CONSOLE`; the data tests here run one ROM per field when //! the reference's fetched references are present. mod common; use a2600::gates::{compare_table, default_system, serial_tables}; use a2600::machine::{ console_row, CONSOLE_ROWS, HOSTED_MACHINES, MACHINES, REFERENCE_TIA, TIA_REVISIONS, VCS_NTSC, VCS_PAL, VCS_SECAM, }; use a2600::tia::TIA; use common::reference_root; #[test] fn the_reference_rows_use_the_die_s_chip() { for machine in [VCS_NTSC, VCS_PAL, VCS_SECAM] { assert_eq!(machine.tia_revision, REFERENCE_TIA); } assert!(REFERENCE_TIA.merge_steps == 0x1F && REFERENCE_TIA.strobe_drops == 0); assert_eq!(TIA::default().revision, REFERENCE_TIA); } #[test] fn pal_and_secam_run_on_their_own_clocks() { assert_eq!(VCS_PAL.timing.colour_clock_hz, 3_546_894.0); assert_eq!(VCS_PAL.timing.cpu_hz().round(), 1_182_298.0); // nocash assert_ne!(VCS_SECAM.timing.name, VCS_PAL.timing.name); assert_eq!(VCS_NTSC.timing.cpu_hz().round(), 1_193_182.0); } #[test] fn a_secam_console_has_no_colour_switch() { assert_eq!(VCS_SECAM.switches & 0x08, 0); assert!(VCS_PAL.switches & 0x08 != 0 && VCS_NTSC.switches & 0x08 != 0); } #[test] fn seven_eight_hundred_rows_stay_out_of_the_2600_listing() { assert!(HOSTED_MACHINES .iter() .all(|h| MACHINES.iter().all(|m| m.name != h.name))); assert!(MACHINES.iter().all(|m| !m.name.contains("7800"))); assert!(HOSTED_MACHINES.iter().all(|m| !m.tia_clocks_cpu)); assert!(MACHINES.iter().all(|m| m.tia_clocks_cpu)); } #[test] fn every_console_row_names_a_revision_from_the_tables() { let names: Vec<&str> = CONSOLE_ROWS.iter().map(|(n, _)| *n).collect(); assert_eq!( names, [ "PAL_7800", "PAL_JR_84", "PAL_JR_91", "PAL_L6", "PAL_VADER", "SECAM_WOODY" ] ); for (_, row) in CONSOLE_ROWS { assert!(TIA_REVISIONS.contains(&row.tia_revision)); assert!(row.tia_revision.source.starts_with("TEST ROM") || row.tia_revision.source.starts_with("DIE")); } } #[test] fn the_serial_judge_counts_every_cell_and_finds_a_wrong_one() { let table = " HMP0 values\n01 8 7\n02 8 6\n"; let (m, t, _) = compare_table(table, table); assert_eq!((m, t), (8, 8)); let (matched, total, misses) = compare_table(&table.replace("8 6", "8 5"), table); assert_eq!((matched, total), (7, 8)); assert_eq!(misses, vec![(2, 2, Some("5".to_string()), "6".to_string())]); } #[test] fn a_console_row_matches_every_cell_of_its_table() { let root = reference_root(); if !root.join("reference/hardware/stella-issues/699-results.zip").exists() { return; // references not fetched } for (console, rom) in [ ("PAL_7800", "early_HMOVE"), // merge_steps ("PAL_L6", "HMOVE_RESPx_P0"), // strobe_drops, players ("PAL_VADER", "HMOVE_RESPx_M1"), // strobe_drops, missiles ("SECAM_WOODY", "HMOVE_RESPx_M1"), // the reference ] { let results = serial_tables( &root, console_row(console).unwrap(), console, Some(&[rom]), &default_system, ) .unwrap(); let (matched, total, misses) = &results[rom]; assert!( misses.is_empty() && matched == total, "{console} {rom}: {:?}", &misses[..misses.len().min(5)] ); } }