[][src]Struct nescore::Nes

pub struct Nes { /* fields omitted */ }

Representation of the NES system

Implementations

impl Nes[src]

pub fn new() -> Self[src]

Instantiate a NES emulator instance

let nes = Nes::new();

pub fn entry(self, entry_addr: u16) -> Self[src]

Directly set the CPU entry point

let nes = Nes::default().entry(0xC000);

pub fn with_cart(self, cart: Cartridge) -> Self[src]

Builder function to allow inserting the cartridge

pub fn debug_mode(self, debug: bool) -> Self[src]

Builder function to set debug mode

let nes = Nes::default().debug_mode(true);

pub fn emulate_frame(&mut self) -> ([u8; 184320], Vec<Sample>)[src]

Run the emulator for a single frame

let mut nes = Nes::from(cart);
let (videobuffer, audiobuffer) = nes.emulate_frame();
  • videobuffer - A RGB8 frame buffer
  • audiobuffer - Raw APU output (This must be down sampled to host playback rate)

pub fn run_audio(&mut self, buffer_size: usize) -> Vec<f32>[src]

Run the NES emulator until it fills an audio buffer to the specified size

let samplebuffer = nes.run_audio(4096);

pub fn input(&mut self, btn: Button, pressed: bool)[src]

Apply a button input into the emulator

nes.input(Button::A, true);

pub fn controller_input(
    &mut self,
    controller: Controller,
    btn: Button,
    pressed: bool
)
[src]

Apply a button input to the emulator from the specified controller

// Send an `A` button press to input 1
nes.controller_input(Controller::Input1, Button::A, true);
// Send an `A` button press to input 2
nes.controller_input(Controller::Input2, Button::A, true);

pub fn run_until(&mut self, addr: u16)[src]

Run until the CPU's PC is at address addr

pub fn is_holding(&self) -> bool[src]

Check if the CPU is in an infinite loop state

pub fn insert(&mut self, cart: Cartridge)[src]

Load a cartridge

pub fn eject(self) -> Vec<u8>[src]

Eject the cartridge, returning the save state

let nes = Nes::default();
// This consumes the nes instance
let battery_ram = nes.eject();

pub fn get_program_counter(&self) -> u16[src]

Get the CPU's program counter

pub fn read_cpu_ram(&self, addr: u16) -> u8[src]

Read the byte, at the specified address, from CPU's internal RAM

pub fn read_ppu_memory(&self, addr: u16) -> u8[src]

Read directly from VRAM

pub fn read_tile(&self, nametable: u16, x: usize, y: usize) -> u8[src]

Read a tile from the current nametable

Trait Implementations

impl Default for Nes[src]

impl From<Cartridge> for Nes[src]

Auto Trait Implementations

impl !RefUnwindSafe for Nes

impl !Send for Nes

impl !Sync for Nes

impl Unpin for Nes

impl !UnwindSafe for Nes

Blanket Implementations

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

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

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

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

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

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.