pcengine_rust/lib.rs
1//! A Rust PC Engine / TurboGrafx-16 board transcribed from
2//! [pcengine-python](https://github.com/alewman/pcengine-python) at `v0.1.0`
3//! (`bc9b976`) and proven equivalent to it: every CPU bus cycle, every frame's
4//! picture at the 9-bit palette value, every mixed audio sample.
5//!
6//! **This is the speed fork** (package `pcengine-rust-fast`, the same crate name and public
7//! API as pcengine-rust): the same board with shortcuts that are kept only while its traces
8//! stay identical to the base board's and a measurement shows they pay (README). A host
9//! reaches the board through `System` (`board_mut`, `step`, `run_frame`, `run_until`); one
10//! that drives a bare `Board` and changes it between bus callbacks calls `Board::touch`.
11//!
12//! Each module is the transcription of one `pcengine_python` module, with the
13//! same names, every named switch as a field with the reference's default, and
14//! the comments that cite a source carried over. Where Rust forced a
15//! difference, the module header says so.
16//!
17//! ```
18//! use pcengine_rust::board::{Board, BoardOptions};
19//! use pcengine_rust::cards::make_card;
20//! use pcengine_rust::pads::{Pad2, RUN};
21//! use pcengine_rust::system::System;
22//!
23//! let image = vec![0u8; 0x2000]; // a HuCard image (bring your own)
24//! let board = Board::new(BoardOptions {
25//! card: Some(make_card(&image).unwrap()),
26//! pad: Some(Box::new(Pad2::new())),
27//! ..BoardOptions::default()
28//! })
29//! .unwrap();
30//! let mut system = System::new(board);
31//! system.board_mut().set_pressed(0, RUN);
32//! system.run_frame();
33//! let _samples = system.board_mut().take_audio(); // 44.1 kHz stereo
34//! let _picture = system.board().capture.last_frame.as_ref(); // 242 rows of 9-bit values
35//! ```
36
37pub mod board;
38pub mod cards;
39pub mod cpu_io;
40pub mod fake_devices;
41pub mod hardware_page;
42pub mod machine;
43pub mod mixer;
44pub mod mt;
45pub mod pads;
46pub mod pagetable;
47pub mod psg;
48pub mod sockets;
49pub mod state;
50pub mod system;
51pub mod trace;
52pub mod vce;
53pub mod vdc;
54pub mod video;
55
56pub use huc6280;
57
58/// The README's example compiles and runs as a doctest.
59#[cfg(doctest)]
60#[doc = include_str!("../README.md")]
61struct ReadmeDoctests;