pub struct State<S: AddressSpace> {}
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>
impl<S: AddressSpace> State<S>
pub fn new(address_space: S) -> Self
pub fn get_af(&self) -> u16
pub fn get_bc(&self) -> u16
pub fn get_de(&self) -> u16
pub fn get_hl(&self) -> u16
pub fn set_af(&mut self, value: u16)
pub fn set_bc(&mut self, value: u16)
pub fn set_de(&mut self, value: u16)
pub fn set_hl(&mut self, value: u16)
pub fn get_r8_by_id(&mut self, id: u8) -> u8
pub fn set_r8_by_id(&mut self, id: u8, value: u8)
Sourcepub fn read(&self, address: u16) -> u8
pub fn read(&self, address: u16) -> u8
Passthrough for self.address_space.read()
.
Sourcepub fn write(&mut self, address: u16, value: u8)
pub fn write(&mut self, address: u16, value: u8)
Passthrough for self.address_space.write()
.
Sourcepub fn tick(&mut self) -> TickResult
pub fn tick(&mut self) -> TickResult
Steps the CPU forward by one instruction.
self.cycles_elapsed
is updated accordingly.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more