Struct Bus

Source
pub struct Bus {
    pub apu: Apu,
    pub genie_codes: HashMap<u16, GenieCode>,
    pub input: Input,
    pub open_bus: u8,
    pub ppu: Ppu,
    pub prg_ram_protect: bool,
    pub prg_ram: Memory<Vec<u8>>,
    pub prg_rom: Memory<Vec<u8>>,
    pub ram_state: RamState,
    pub region: NesRegion,
    pub wram: Memory<ConstSlice<u8, 0x0800>>,
}
Expand description

NES Bus

https://wiki.nesdev.org/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 |—————–|

Fields§

§apu: Apu§genie_codes: HashMap<u16, GenieCode>§input: Input§open_bus: u8§ppu: Ppu§prg_ram_protect: bool§prg_ram: Memory<Vec<u8>>§prg_rom: Memory<Vec<u8>>§ram_state: RamState§region: NesRegion§wram: Memory<ConstSlice<u8, 0x0800>>

Implementations§

Source§

impl Bus

Source

pub fn new(region: NesRegion, ram_state: RamState) -> Self

Source

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

Source

pub fn unload_cart(&mut self)

Source

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

Source

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

Source

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

Source

pub fn add_genie_code(&mut self, genie_code: GenieCode)

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)

Remove a Game Genie code.

Source

pub fn clear_genie_codes(&mut self)

Remove all Game Genie codes.

Source

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

Source

pub fn clear_audio_samples(&mut self)

Trait Implementations§

Source§

impl Clock for Bus

Source§

fn clock(&mut self) -> u64

Clock component a single time, returning the number of cycles clocked.
Source§

impl ClockTo for Bus

Source§

fn clock_to(&mut self, clock: u64) -> u64

Clock component to the given master cycle, returning the number of cycles clocked.
Source§

impl Clone for Bus

Source§

fn clone(&self) -> Bus

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 Bus

Source§

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

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

impl Default for Bus

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Bus

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 Read for Bus

Source§

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

Read from the given address.
Source§

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

Peek from the given address.
Source§

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

Read two bytes from the given address.
Source§

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

Peek two bytes from the given address.
Source§

impl Regional for Bus

Source§

fn region(&self) -> NesRegion

Return the current region.
Source§

fn set_region(&mut self, region: NesRegion)

Set the region.
Source§

impl Reset for Bus

Source§

fn reset(&mut self, kind: ResetKind)

Reset the component given the ResetKind.
Source§

impl Serialize for Bus

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

impl Sram for Bus

Source§

fn save(&self, path: impl AsRef<Path>) -> Result<()>

Save RAM to a given path.
Source§

fn load(&mut self, path: impl AsRef<Path>) -> Result<()>

Load save RAM from a given path.
Source§

impl Write for Bus

Source§

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

Write value to the given address.
Source§

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

Write valuetwo bytes to the given address.

Auto Trait Implementations§

§

impl Freeze for Bus

§

impl !RefUnwindSafe for Bus

§

impl Send for Bus

§

impl Sync for Bus

§

impl Unpin for Bus

§

impl !UnwindSafe for Bus

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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