pub struct Nes { /* private fields */ }Expand description
Representation of the NES system
Implementations§
Source§impl Nes
impl Nes
Sourcepub fn entry(self, entry_addr: u16) -> Self
pub fn entry(self, entry_addr: u16) -> Self
Directly set the CPU entry point
let nes = Nes::default().entry(0xC000);Sourcepub fn with_cart(self, cart: Cartridge) -> Self
pub fn with_cart(self, cart: Cartridge) -> Self
Builder function to allow inserting the cartridge
Sourcepub fn debug_mode(self, debug: bool) -> Self
pub fn debug_mode(self, debug: bool) -> Self
Builder function to set debug mode
let nes = Nes::default().debug_mode(true);Sourcepub fn emulate_frame(&mut self) -> ([u8; 184320], Vec<Sample>)
pub fn emulate_frame(&mut self) -> ([u8; 184320], Vec<Sample>)
Run the emulator for a single frame
let mut nes = Nes::from(cart);
let (videobuffer, audiobuffer) = nes.emulate_frame();videobuffer- A RGB8 frame bufferaudiobuffer- Raw APU output (This must be down sampled to host playback rate)
Sourcepub fn run_audio(&mut self, buffer_size: usize) -> Vec<f32>
pub fn run_audio(&mut self, buffer_size: usize) -> Vec<f32>
Run the NES emulator until it fills an audio buffer to the specified size
let samplebuffer = nes.run_audio(4096);Sourcepub fn input(&mut self, btn: Button, pressed: bool)
pub fn input(&mut self, btn: Button, pressed: bool)
Apply a button input into the emulator
nes.input(Button::A, true);Sourcepub fn controller_input(
&mut self,
controller: Controller,
btn: Button,
pressed: bool,
)
pub fn controller_input( &mut self, controller: Controller, btn: Button, pressed: bool, )
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);Sourcepub fn is_holding(&self) -> bool
pub fn is_holding(&self) -> bool
Check if the CPU is in an infinite loop state
Sourcepub fn eject(self) -> Vec<u8> ⓘ
pub fn eject(self) -> Vec<u8> ⓘ
Eject the cartridge, returning the save state
let nes = Nes::default();
// This consumes the nes instance
let battery_ram = nes.eject();Sourcepub fn get_program_counter(&self) -> u16
pub fn get_program_counter(&self) -> u16
Get the CPU’s program counter
Sourcepub fn read_cpu_ram(&self, addr: u16) -> u8
pub fn read_cpu_ram(&self, addr: u16) -> u8
Read the byte, at the specified address, from CPU’s internal RAM
Sourcepub fn read_ppu_memory(&self, addr: u16) -> u8
pub fn read_ppu_memory(&self, addr: u16) -> u8
Read directly from VRAM
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Nes
impl !RefUnwindSafe for Nes
impl !Send for Nes
impl !Sync for Nes
impl Unpin for Nes
impl !UnwindSafe for Nes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more