Skip to main content

Bus

Struct Bus 

Source
pub struct Bus {
    pub tia: Tia,
    pub riot: Riot,
    pub board: Option<Cartridge>,
    pub open_bus: u8,
    pub write_log: WriteLog,
}
Expand description

The main system bus for Rusty2600, holding the chips.

Fields§

§tia: Tia

The TIA video/audio chip.

§riot: Riot

The RIOT RAM/Timer/IO chip.

§board: Option<Cartridge>

The cartridge board (mapper).

§open_bus: u8

Open bus value (last driven value).

§write_log: WriteLog

The debugger’s optional write log — see WriteLog.

Implementations§

Source§

impl Bus

Source

pub fn new() -> Self

Source

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

Side-effect-free read, for debugger/tooling use only: a real cpu_read can trigger bankswitch hotspots, RIOT’s INTIM read-clears-underflow-flag behavior, and cart snoop_read side effects, none of which a memory-viewer peek should ever cause. Reads via a full clone of self (cheap relative to a UI refresh cadence, and correctly avoids the unsafe-free crate’s inability to alias a &mut for a “no-op” read) so the real system state is untouched.

For more than a byte or two, prefer Self::peek_range — it clones self ONCE and reads every byte from that one clone, instead of paying a full Bus clone (TIA + RIOT + the cart’s ROM/RAM) per byte.

Source

pub fn peek_range(&self, base: u16, len: u16) -> Vec<u8>

Side-effect-free read of len consecutive addresses starting at base (wrapping at 16 bits), for a debugger memory viewer or a disassembly window. Clones self once, then reads every byte from that single clone — any bankswitch hotspot triggered by reading byte N is visible to byte N+1’s read (an honest reflection of “whatever the bank state currently is,” same caveat any bank-switched-system memory viewer has), but the REAL system is never touched.

Source

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

Source

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

Trait Implementations§

Source§

impl AudioBus for Bus

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

Source§

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

Source§

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

§

fn tick_cycle(&mut self)

Advance the rest of the system (TIA/RIOT/cart) by exactly one CPU cycle’s worth of real time. Called once per bus access the CPU makes, so a multi-cycle instruction advances the world cycle-by-cycle instead of all at once — this is what keeps the CPU’s notion of elapsed time in lockstep with the TIA’s color clock. Default no-op for buses that don’t model timing (flat-RAM test harnesses, the Klaus functional-test bus).
§

fn rdy_stall(&self) -> bool

Whether the bus is holding RDY low (the WSYNC beam-stall). The CPU spins on [Self::tick_cycle] while this is true instead of performing its next access. Default false for buses with no such concept.
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() -> Bus

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

Auto Trait Implementations§

§

impl Freeze for Bus

§

impl RefUnwindSafe for Bus

§

impl Send for Bus

§

impl Sync for Bus

§

impl Unpin for Bus

§

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