CpuBus

Struct CpuBus 

Source
pub struct CpuBus { /* private fields */ }
Expand description

NES Bus

http://wiki.nesdev.com/w/index.php/CPU_memory_map

|—————–| $FFFF |—————–| | PRG-ROM | | | |—————–| $8000 |—————–| | PRG-RAM or SRAM | | PRG-RAM or SRAM | |—————–| $6000 |—————–| | Expansion | | Expansion | | Modules | | Modules | |—————–| $4020 |—————–| | APU/Input | | | | Registers | | | |- - - - - - - - -| $4000 | | | PPU Mirrors | | I/O Registers | | $2000-$2007 | | | |- - - - - - - - -| $2008 | | | PPU Registers | | | |—————–| $2000 |—————–| | WRAM Mirrors | | | | $0000-$07FF | | | |- - - - - - - - -| $0800 | | | WRAM | | 2K Internal | |- - - - - - - - -| $0200 | Work RAM | | Stack | | | |- - - - - - - - -| $0100 | | | Zero Page | | | |—————–| $0000 |—————–|

Implementations§

Source§

impl CpuBus

Source

pub fn new(ram_state: RamState) -> Self

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: Player) -> &Joypad

Source

pub fn joypad_mut(&mut self, slot: Player) -> &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 fn load_prg_rom(&mut self, prg_rom: Vec<u8>)

Source

pub fn load_prg_ram(&mut self, prg_ram: Vec<u8>)

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, code: String) -> Result<()>

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, code: &str)

Source

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

Source

pub fn clear_audio_samples(&mut self)

Source

pub const fn nmi_pending(&self) -> bool

Source

pub fn irqs_pending(&self) -> Irq

Source

pub fn dmc_dma(&mut self) -> bool

Source

pub const fn dmc_dma_addr(&self) -> u16

Source

pub fn load_dmc_buffer(&mut self, val: u8)

Source

pub const fn oam_dma(&self) -> bool

Source

pub const fn oam_dma_addr(&self) -> u16

Source

pub fn oam_dma_finish(&mut self)

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 const fn four_player(&self) -> FourPlayer

Source

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

Trait Implementations§

Source§

impl Clock for CpuBus

Source§

fn clock(&mut self) -> usize

Source§

fn clock_to(&mut self, clock: u64)

Source§

impl Clone for CpuBus

Source§

fn clone(&self) -> CpuBus

Returns a duplicate 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 CpuBus

Source§

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

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

impl Default for CpuBus

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CpuBus

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 CpuBus

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 CpuBus

Source§

fn region(&self) -> NesRegion

Source§

fn set_region(&mut self, region: NesRegion)

Source§

impl Reset for CpuBus

Source§

fn reset(&mut self, kind: ResetKind)

Source§

impl Serialize for CpuBus

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 Freeze for CpuBus

§

impl RefUnwindSafe for CpuBus

§

impl Send for CpuBus

§

impl Sync for CpuBus

§

impl Unpin for CpuBus

§

impl UnwindSafe for CpuBus

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.
Source§

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