Expand description
A Rust PC Engine / TurboGrafx-16 board transcribed from
pcengine-python at v0.1.0
(bc9b976) and proven equivalent to it: every CPU bus cycle, every frame’s
picture at the 9-bit palette value, every mixed audio sample.
Each module is the transcription of one pcengine_python module, with the
same names, every named switch as a field with the reference’s default, and
the comments that cite a source carried over. Where Rust forced a
difference, the module header says so.
use pcengine_rust::board::{Board, BoardOptions};
use pcengine_rust::cards::make_card;
use pcengine_rust::pads::{Pad2, RUN};
use pcengine_rust::system::System;
let image = vec![0u8; 0x2000]; // a HuCard image (bring your own)
let board = Board::new(BoardOptions {
card: Some(make_card(&image).unwrap()),
pad: Some(Box::new(Pad2::new())),
..BoardOptions::default()
})
.unwrap();
let mut system = System::new(board);
system.board_mut().set_pressed(0, RUN);
system.run_frame();
let _samples = system.board_mut().take_audio(); // 44.1 kHz stereo
let _picture = system.board().capture.last_frame.as_ref(); // 242 rows of 9-bit valuesRe-exports§
pub use huc6280;
Modules§
- board
- The board: one timeline in master clocks, the page table, and the devices around the CPU
(
board.py). - cards
- HuCards: the standard ROM card, Street Fighter II’, Populous and Tennokoe (
cards.py). - cpu_io
- The HuC6280’s on-die peripherals that are not the CPU: timer, $1400 interrupt
controller, I/O port and the I/O buffer (
cpu_io/__init__.py; Aubrey’s rule: in the board, behind a module boundary). - fake_
devices - Test devices for the sockets (the reference’s docs/sockets.md): every trait is exercised without any add-on.
- hardware_
page - The hardware page, bank $FF ($1FE000-$1FFFFF), as 32 pages of 256 bytes (
hardware_page.py). - machine
- The machine table and the clock constants every module shares
(
machine.py). - mixer
- The audio mixer: sums the board’s audio sources (socket 9) into one stereo stream
(
mixer.py). - mt
- Python’s
random.Random(seed)for an integer seed, as far as the reference’spower_on_seeduses it: the Mersenne Twister MT19937 seeded byinit_by_arrayover the seed’s 32-bit words, andgetrandbits(k)for k <= 32 (the top k bits of one output). - pads
- The pads: 2-button, 6-button and the 5-player multitap (the mouse is not modelled: U12)
(
pads.py). - pagetable
- One decode for every bus master: the 8192-entry page table (
pagetable.py). - psg
- The HuC6280 PSG (
psg/): board-owned; Aubrey’s rule: it may move out if a second consumer ever wants it, never be copied. - sockets
- The sockets: narrow traits an add-on crate implements to plug into this
board (
sockets.py; the reference’s docs/sockets.md). - state
- Save states (
state.py): the whole console between two instructions, as bytes, and back. - system
- The machine as a whole: a board, a CPU on it, and frame-by-frame running (
system.py). - trace
- The lockstep gate’s side of this board: per-frame digests of everything the gate compares,
in the spelling
scripts/pce_trace.pywrites for the reference. - vce
- The HuC6260 VCE: colour table, control register, dot clock, frame length (
vce.py). - vdc
- The HuC6270 VDC (
vdc/): instances, no module state. - video
- The frame/line clock and the picture capture (
video.py).