Struct tetanes::cpu::Cpu

source ·
pub struct Cpu { /* private fields */ }
Expand description

The Central Processing Unit status and registers

Implementations§

source§

impl Cpu

CPU Addressing Modes

The 6502 can address 64KB from 0x0000 - 0xFFFF. The high byte is usually the page and the low byte the offset into the page. There are 256 total pages of 256 bytes.

source

pub const INSTRUCTIONS: [Instr; 256] = _

source§

impl Cpu

source

pub fn new(bus: CpuBus) -> Self

source

pub const fn region_clock_rate(region: NesRegion) -> f32

source

pub const fn clock_rate(&self) -> f32

source

pub const fn cycle(&self) -> usize

source

pub const fn pc(&self) -> u16

source

pub const fn sp(&self) -> u8

source

pub const fn a(&self) -> u8

source

pub const fn x(&self) -> u8

source

pub const fn y(&self) -> u8

source

pub const fn status(&self) -> Status

source

pub const fn corrupted(&self) -> bool

source

pub fn disasm(&self) -> &str

source

pub const fn ppu(&self) -> &Ppu

source

pub fn ppu_mut(&mut self) -> &mut Ppu

source

pub const fn apu(&self) -> &Apu

source

pub fn apu_mut(&mut self) -> &mut Apu

source

pub const fn mapper(&self) -> &Mapper

source

pub fn mapper_mut(&mut self) -> &mut Mapper

source

pub const fn joypad(&self, slot: Slot) -> &Joypad

source

pub fn joypad_mut(&mut self, slot: Slot) -> &mut Joypad

source

pub fn connect_zapper(&mut self, enabled: bool)

source

pub const fn zapper(&self) -> &Zapper

source

pub fn zapper_mut(&mut self) -> &mut Zapper

source

pub fn load_cart(&mut self, cart: Cart)

source

pub const fn cart_battery_backed(&self) -> bool

source

pub fn sram(&self) -> &[u8]

source

pub fn load_sram(&mut self, sram: Vec<u8>)

source

pub fn wram(&self) -> &[u8]

source

pub fn add_genie_code(&mut self, genie_code: String) -> NesResult<()>

Add a Game Genie code to override memory reads/writes.

Errors

Errors if genie code is invalid.

source

pub fn remove_genie_code(&mut self, genie_code: &str)

source

pub const fn ppu_cycle(&self) -> u32

source

pub const fn ppu_scanline(&self) -> u32

source

pub fn frame_buffer(&self) -> &[u16]

source

pub const fn frame_number(&self) -> u32

source

pub const fn audio_channel_enabled(&self, channel: Channel) -> bool

source

pub fn toggle_audio_channel(&mut self, channel: Channel)

source

pub fn audio_samples(&self) -> &[f32]

source

pub fn clear_audio_samples(&mut self)

source

pub const fn four_player(&self) -> FourPlayer

source

pub fn set_four_player(&mut self, four_player: FourPlayer)

source

pub fn set_cycle_accurate(&mut self, enabled: bool)

source

pub fn irq(&mut self)

source

pub fn peek_stack(&self) -> u8

source

pub fn peek_stack_u16(&self) -> u16

source

pub fn read_u16(&mut self, addr: u16) -> u16

source

pub fn peek_u16(&self, addr: u16) -> u16

source

pub fn disassemble(&mut self, pc: &mut u16)

source

pub fn trace_instr(&mut self)

source§

impl Cpu

source

pub fn clock_inspect<F>(&mut self, inspect: F) -> usize
where F: FnMut(&mut Cpu),

Trait Implementations§

source§

impl Clock for Cpu

source§

fn clock(&mut self) -> usize

Runs the CPU one instruction

source§

fn clock_to(&mut self, _clocks: u64)

source§

impl Clone for Cpu

source§

fn clone(&self) -> Cpu

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Cpu

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Cpu

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Mem for Cpu

source§

fn read(&mut self, addr: u16, access: Access) -> u8

source§

fn peek(&self, addr: u16, access: Access) -> u8

source§

fn write(&mut self, addr: u16, val: u8, access: Access)

source§

fn read_u16(&mut self, addr: u16, access: Access) -> u16

source§

fn peek_u16(&self, addr: u16, access: Access) -> u16

source§

fn write_u16(&mut self, addr: u16, val: u16, access: Access)

source§

impl Regional for Cpu

source§

fn region(&self) -> NesRegion

source§

fn set_region(&mut self, region: NesRegion)

source§

impl Reset for Cpu

source§

fn reset(&mut self, kind: Kind)

Resets the CPU

Updates the PC, SP, and Status values to defined constants.

These operations take the CPU 7 cycles.

source§

impl Serialize for Cpu

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Cpu

§

impl Send for Cpu

§

impl Sync for Cpu

§

impl Unpin for Cpu

§

impl UnwindSafe for Cpu

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,