Nintendo Entertainment System (NES) emulator written in Rust 🦀.
Use the Nes
struct to create an emulator instance and interact with it using the following API:
pub fn new() -> Nes;
pub fn load_rom(&mut self, rom: &[u8]);
pub fn reset(&mut self);
pub fn clock(&mut self);
pub fn get_frame(&mut self) -> Option<[u8; SCREEN_WIDTH * SCREEN_HEIGHT * 3]>;
pub fn btn_down(&mut self, controller: u8, btn: Button);
pub fn btn_up(&mut self, controller: u8, btn: Button);
Basic usage:
use jc_nes::{Button, Nes, SCREEN_HEIGHT, SCREEN_WIDTH};
let mut nes = Nes::new();
nes.load_rom(&rom);
nes.reset();
loop {
nes.clock();
// Your draw code
if let Some(screen) = nes.get_frame() {
...
}
// Your event processing
match event {
... => nes.btn_down(1, Button::Up)
... => nes.btn_down(1, Button::B)
... => nes.btn_up(1, Button::A)
... => nes.btn_up(2, Button::Down)
...
}
}