// SPDX-License-Identifier: MIT //! A Rust WDC 65C816 core transcribed from //! [65816-python](https://github.com/alewman/65816-python) at `71092a4` and //! proven equivalent to it at every processor boundary. //! //! **Lineage:** 65816-python → **65816-rust** · //! fixes start in 65816-python and flow down by merges · [family //! charter](https://github.com/alewman/emulator-lineage/blob/main/docs/charter.md). //! "Matches the Python" is execution fidelity (this crate's proof); how well //! the Python matches the 5A22 and the W65C816S is the reference's //! docs/validation.md. //! //! Each module is the transcription of one `w65c816/*.py` module, with the //! same handler names, the same dispatch table and the hardware comments //! carried over: `core` (`_core.py`), `alu`, `loads`, `shifts`, `control`, //! `block`, [`dispatch`], `cpu`, [`state`], [`trace`] (with `debug.py`'s //! boundary kinds) and [`harness`]. The 65xx-family base (the reference's //! `CPUFrame`) is 6502-rust's [`sixfiveohtwo::frame`]. Where Rust forced a //! difference, the module header says so. //! //! ``` //! use w65c816::{Bus, Frame, Signals, W65C816}; //! //! struct Ram(Vec); //! impl Bus for Ram { //! fn read(&mut self, address: u32, _: &mut Frame, _: Signals) -> u8 { //! self.0[address as usize] //! } //! fn write(&mut self, address: u32, value: u8, _: &mut Frame, _: Signals) { //! self.0[address as usize] = value; //! } //! } //! //! let mut ram = Ram(vec![0; 1 << 24]); //! ram.0[0x0200] = 0xE8; // INX //! let mut cpu = W65C816::new(ram); //! cpu.pc = 0x0200; //! assert_eq!(cpu.step(), 2); // the opcode fetch and an IO cycle //! assert_eq!(cpu.x, 1); //! ``` mod alu; mod block; mod control; mod core; mod cpu; pub mod dispatch; pub mod harness; mod loads; mod shifts; pub mod state; pub mod trace; pub use crate::alu::{add, subtract}; pub use crate::control::{ request_abort, vector_emulation, vector_native, ABORT_LATCH, VECTOR_BRK, VECTOR_COP, VECTOR_RESET, }; pub use crate::core::{ nz16, nz8, Bus, Signals, C, D, DATA, I, IO, M, MLB, N, OPCODE, PROGRAM, V, VDA, VECTOR, VPA, VPB, W65C816, X, Z, }; pub use crate::state::CpuState; pub use sixfiveohtwo::frame::{Frame, Part, IRQ_LINE, NMI_LATCH, NO_POLL};