Struct emulatorr::core::cpu::CPU

source ·
pub struct CPU { /* private fields */ }

Implementations§

source§

impl CPU

Implement CPU’s core functionality

source

pub fn new(bus: Bus) -> Self

source

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

Write u8 value to u16 address

source

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

Read u8 value from u16 address

source

pub fn write_u16(&mut self, addr: u16, data: u16)

Write u16 data from u16 address (little endian)

source

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

Read u16 data from u16 address (little endian)

source

pub fn push(&mut self, data: u8)

Push u8 value to stack

source

pub fn push_u16(&mut self, data: u16)

Push u16 value to stack

source

pub fn pop(&mut self) -> u8

Pop u8 value off stack

source

pub fn pop_u16(&mut self) -> u16

Pop u16 value off stack (little endian)

source

pub fn get_flag(&mut self, f: Flags) -> bool

Return whether status register has specific Flag

source

pub fn set_flag(&mut self, f: Flags, v: bool)

Set Flag according to boolean

source

pub fn set_zero_negative_flags(&mut self, value: u8)

Set zero (Z) and negative (N) flags according to u8 value

source

pub fn reset(&mut self)

Reset CPU

source

pub fn clock(&mut self)

Start clock loop

source

pub fn advance(&mut self)

Advance CPU by 1 ‘step’ (=/= 1 clock cycle)

source§

impl CPU

Implement addressing modes

source

pub fn get_address(&mut self, mode: AddressingMode) -> u16

source§

impl CPU

Debugging/testing functions

source

pub fn load_program(&mut self, program: Vec<u8>)

Write program defined as Vec<u8> to memory

source

pub fn quick_start(&mut self, program: Vec<u8>)

Write program to memory, reset, and start clock

source

pub fn get_pc(&self) -> u16

source

pub fn get_sp(&self) -> u8

source

pub fn get_sr(&self) -> u8

source

pub fn get_a(&self) -> u8

source

pub fn get_x(&self) -> u8

source

pub fn get_y(&self) -> u8

source

pub fn get_opcode(&self) -> u8

source

pub fn get_state(&self) -> Vec<u16>

Return all registers as single Vec<u16>

source

pub fn get_memory(&self) -> [u8; 65536]

Get entirety of memory

source

pub fn custom( a: u8, x: u8, y: u8, sp: u8, pc: u16, sr: u8, opcode: u8, bus: Bus ) -> Self

Construct CPU with custom values

Auto Trait Implementations§

§

impl RefUnwindSafe for CPU

§

impl Send for CPU

§

impl Sync for CPU

§

impl Unpin for CPU

§

impl UnwindSafe for CPU

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.