Struct State

Source
pub struct State<S: AddressSpace> {
Show 13 fields pub a: u8, pub f: Flags, pub b: u8, pub c: u8, pub d: u8, pub e: u8, pub h: u8, pub l: u8, pub pc: u16, pub sp: u16, pub ime: bool, pub cycles_elapsed: usize, pub address_space: S,
}
Expand description

The CPU’s state, which is what gets ticked.

Fields§

§a: u8§f: Flags§b: u8§c: u8§d: u8§e: u8§h: u8§l: u8§pc: u16§sp: u16§ime: bool§cycles_elapsed: usize

Total number of M-Cycles that have passed during this CPU’s life.

§address_space: S

The address space the CPU is communicating with.

Implementations§

Source§

impl<S: AddressSpace> State<S>

Source

pub fn new(address_space: S) -> Self

Source

pub fn get_af(&self) -> u16

Source

pub fn get_bc(&self) -> u16

Source

pub fn get_de(&self) -> u16

Source

pub fn get_hl(&self) -> u16

Source

pub fn set_af(&mut self, value: u16)

Source

pub fn set_bc(&mut self, value: u16)

Source

pub fn set_de(&mut self, value: u16)

Source

pub fn set_hl(&mut self, value: u16)

Source

pub fn get_r8_by_id(&mut self, id: u8) -> u8

Source

pub fn set_r8_by_id(&mut self, id: u8, value: u8)

Source

pub fn read(&self, address: u16) -> u8

Passthrough for self.address_space.read().

Source

pub fn write(&mut self, address: u16, value: u8)

Passthrough for self.address_space.write().

Source

pub fn tick(&mut self) -> TickResult

Steps the CPU forward by one instruction. self.cycles_elapsed is updated accordingly.

Trait Implementations§

Source§

impl<S: AddressSpace> Display for State<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for State<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for State<S>
where S: RefUnwindSafe,

§

impl<S> Send for State<S>
where S: Send,

§

impl<S> Sync for State<S>
where S: Sync,

§

impl<S> Unpin for State<S>
where S: Unpin,

§

impl<S> UnwindSafe for State<S>
where S: UnwindSafe,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.