Cpu

Struct Cpu 

Source
pub struct Cpu {
    pub reg_a: u8,
    pub reg_b: u8,
    pub reg_c: u8,
    pub reg_d: u8,
    pub reg_e: u8,
    pub reg_h: u8,
    pub reg_l: u8,
    pub reg_sp: u16,
    pub reg_pc: u16,
    /* private fields */
}

Fields§

§reg_a: u8§reg_b: u8§reg_c: u8§reg_d: u8§reg_e: u8§reg_h: u8§reg_l: u8§reg_sp: u16§reg_pc: u16

Implementations§

Source§

impl Cpu

Source

pub fn new(config: GameBoyConfig) -> Self

Source

pub fn new_without_boot_rom(config: GameBoyConfig, is_cart_cgb: bool) -> Self

create a new cpu, with states that match the ones the CPU would have if the boot-rom would run (default values for registers)

Source

pub fn next_instruction<P: CpuBusProvider>( &mut self, bus: &mut P, ) -> Result<CpuState, RunError>

Source§

impl Cpu

Source

pub fn stack_push<P: CpuBusProvider>(&mut self, data: u16, bus: &mut P)

Source

pub fn stack_pop<P: CpuBusProvider>(&mut self, bus: &mut P) -> u16

Trait Implementations§

Source§

impl Default for Cpu

Source§

fn default() -> Cpu

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

impl Savable for Cpu

Source§

fn save<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

fn load<R: Read>(&mut self, reader: &mut R) -> Result<()>

Source§

fn save_size(&self) -> Result<u64>

The size of the object if saved now, note that this might change, for example due to the length of string objects or data inside the object.

Auto Trait Implementations§

§

impl Freeze for Cpu

§

impl RefUnwindSafe for Cpu

§

impl Send for Cpu

§

impl Sync for Cpu

§

impl Unpin for Cpu

§

impl UnwindSafe for Cpu

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.