[][src]Struct emulator_6502::MOS6502

pub struct MOS6502 { /* fields omitted */ }

Struct representation of the MOS 6502 processor

Usage Example

This example is not tested
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(())
}

Methods

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 Default for MOS6502[src]

impl PartialEq<MOS6502> for MOS6502[src]

impl Debug for MOS6502[src]

Auto Trait Implementations

impl Send for MOS6502

impl Sync for MOS6502

impl Unpin for MOS6502

impl UnwindSafe for MOS6502

impl RefUnwindSafe for MOS6502

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]