Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
April 13, 2023 13:23
April 13, 2023 13:23
April 13, 2023 13:23
April 13, 2023 13:23
April 13, 2023 13:23
April 13, 2023 13:23
April 23, 2023 13:15
April 13, 2023 13:29
April 13, 2023 13:23
March 13, 2023 00:37
September 27, 2022 21:30
February 19, 2023 21:28
September 27, 2022 21:30
April 13, 2023 13:23
March 13, 2023 00:37
March 13, 2023 00:49
March 13, 2023 00:37
February 19, 2023 21:28
February 19, 2023 21:28

πŸ₯” Potatis

smbsmb3 bbdr

  • /mos6502 - Generic CPU emulator. Passes all tests, including illegal ops. (No BCD mode).
  • /nes - A very incomplete NES emulator.
  • /nes-sdl - Native target using SDL.
  • /nes-wasm - Browser target using WASM.
  • /nes-cloud - NES-as-a-service. Clientless cloud gaming with netcat and terminal rendering.
  • /nes-embedded - Embedded target for RP-2040 (Raspberry Pi Pico).
  • /nes-android - Android target using JNI.


let load_base = 0x2000;
let mem = Memory::load(&program[..], load_base);
let cpu = Cpu::new(mem);
let mut machine = Mos6502::new(cpu);

loop {
  println!("{}", machine); // Prints nestest-like output


let mut debugger = machine.debugger();
debugger.verbose(true); // Trace, dumps disassembled instructions to stdout
debugger.watch_memory_range(0x6004..=0x6104, |mem| {
  // Invoked when memory in range changes


Supported mappers:

  • NROM (mapper 0)
  • MMC1 (mapper 1)
  • UxROM (mapper 2)
  • CNROM (mapper 3)
  • MMC3 (mapper 4)
impl nes::HostPlatform for MyHost {
  fn render(&mut self, frame: &RenderFrame) {
    // frame.pixels() == 256 * 240 * 3 RGB array

  fn poll_events(&mut self, joypad: &mut Joypad) {
    // pump events and forward to joypad

let cart = Cartridge::blow_dust("path/to/rom.nes")?;
let mut nes = Nes::insert(cart, MyHost::new());

loop {
  println!("{:?}", nes); // Complete nestest formatted output


cargo run --release path/to/rom.nes

cargo run -- --help for options


  1. cd nes-wasm
  2. wasm-pack build --release --target web
  3. npm install
  4. npm run dev

Try it here:


Cloud gaming is the next big thing. Obviously, Potatis needs to support it as well. No client needed, only a terminal and netcat.


stty -icanon && nc 4444

stty -icanon disables input buffering for your terminal, sending input directly to netcat. You can also connect without it but then you'd have to press ENTER after each key press.

Bring your own ROM

stty -icanon && cat zelda.nes - | nc 4444


  • Sixel (port 6666) is recommended if your terminal supports it. iTerm2 does.
  • Unicode color (port 5555) works by using the unicode character β–€ "Upper half block", U+2580 to draw the screen. Since the lower part of the character is transparent, ANSI color codes can be used to simultaneously draw two horizontal lines by setting the block's foreground and background color. Unfortunately the resulting frame is still too large to fit in a normal terminal window, so when using this mode you have to decrease your terminal's font size a lot.
  • ASCII (port 7777). No color, no unicode, just ASCII by calculating luminance for each RGB pixel. Same here, you have to decrease your terminal's font size a lot to see the whole picture.


It also runs on a RP-Pico with only 264kB available RAM! Without any optimizations it started out at ~0.5 FPS. But after some overclocking, and offloading the display rendering to the second CPU core, it now runs at a steady 5 FPS.

Total heap usage, single-core: 135kB
Total heap usage, multi-core: 243kB (2x frame buffers)


The second Pico on the picture is wired up as a SWD debugger/flasher. The display is a ST7789 by Adafruit.

cd nes-embedded
ROM=/path/to/rom.nes cargo run --release

If you don't have a debug-probe setup, change the runner in .cargo/config to use a normal elf2uf2.


  1. Download Android NDK and rustup target add [target]
  2. Configure your target(s) in ~/.cargo/config with the linker(s) provided by the Android NDK
linker = "$NDK_PATH/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android33-clang"

linker = "$NDK_PATH/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi30-clang"

linker = "$NDK_PATH/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android30-clang"
  1. cd nes-android && ./ release

Note: only targets arm64-v8a (aarch64-linux-android).


Run all unit and integration tests (for all crates):

cargo test


  • More mappers
  • APU

Key mappings

Up, left, down, right: WASD B: K A: L Select: SPACE Start: ENTER Reset: R