Struct emulator_6502::MOS6502 [−][src]
Struct representation of the MOS 6502 processor
Usage Example
fn main() -> Result<()>{ let mut ram = BasicRam{ ram: Box::new([0; u16::max_value() as usize + 1]) }; //Load a program into memory... let mut file = File::open("C:/some_6502_program.bin")?; let mut buffer = Vec::new(); file.read_to_end(&mut buffer)?; //Copy it into the BasicRam ram.load_program(0x0400, &mut buffer); let mut cpu = MOS6502::new(); //Create a new emulator instance cpu.set_program_counter(0x0400); //Set the program counter to the first byte of the program in memory cpu.cycle(&mut ram); // The emulator can execute cycles individually, for systems that require precise timing... cpu.execute_instruction(&mut ram); // or instruction by instruction for a coarser approach Ok(()) }
Implementations
impl MOS6502
[src]
pub fn new() -> Self
[src]
Creates a new MOS6502 emulation with the program counter at 0x0400
pub fn new_start(start: u16) -> Self
[src]
Creates a new MOS6502 emulation with the program counter at the provided start address
pub fn new_reset_position(interface: &mut dyn Interface6502) -> Self
[src]
Creates a new MOS6502 emulation with the program counter at the address read from the reset vector (0xfffa-0xfffb).
This is the standard method used for determining where the program starts on most systems
pub fn set_program_counter(&mut self, program_counter: u16)
[src]
Force the program counter to a specific address
pub fn cycle(&mut self, interface: &mut dyn Interface6502)
[src]
Runs a processor cycle, mutably borrows the reading and writing interface for the duration
pub fn execute_instruction(&mut self, interface: &mut dyn Interface6502)
[src]
Runs as many processor cycles as it takes to complete the instruction at the program counter
pub fn interrupt_request(&mut self)
[src]
Request that an interrupt occurs after the current instruction completes
pub fn non_maskable_interrupt_request(&mut self)
[src]
Request that an interrupt occurs after the current instruction completes, even if the interrupt disabled flag is set
pub fn reset(&mut self, interface: &mut dyn Interface6502)
[src]
Resets the 6502 to a known state
Trait Implementations
impl Clone for MOS6502
[src]
impl Debug for MOS6502
[src]
impl Default for MOS6502
[src]
impl PartialEq<MOS6502> for MOS6502
[src]
impl StructuralPartialEq for MOS6502
[src]
Auto Trait Implementations
impl RefUnwindSafe for MOS6502
[src]
impl Send for MOS6502
[src]
impl Sync for MOS6502
[src]
impl Unpin for MOS6502
[src]
impl UnwindSafe for MOS6502
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,