Skip to content

Nintendo Entertainment System (NES) emulator in Rust 🦀

License

Notifications You must be signed in to change notification settings

joao-conde/jc-nes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nintendo Entertainment System (NES) emulator

Nintendo Entertainment System (NES) emulator written in Rust 🦀.

API Reference

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)
    ...
  }
}

About

Nintendo Entertainment System (NES) emulator in Rust 🦀

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Languages