Code Monkey home page Code Monkey logo

nestur's Introduction

nestur

Nestur is an NES emulator. There are plenty of full-featured emulators out there; this is primarily an educational project but it is usable. There may still be many bugs, but I'm probably not aware of them so please submit issues.

  • no use of unsafe
  • NTSC timing
  • supports mappers 0-4 which cover ~85% of games

The code aims to follow the explanations from the NES dev wiki where possible, especially in the PPU, and the comments quote from it often. Thanks to everyone who contributes to that wiki/forum, and to Michael Fogleman's NES and Scott Ferguson's Fergulator for getting me unstuck at several points.

Controls

 Button  |   Key
___________________
|   A    |    D   |
|   B    |    F   |
| Start  |  Enter |
| Select | R-Shift|
|   Up   |   Up   |
|  Down  |  Down  |
|  Left  |  Left  |
|  Right |  Right |
-------------------

F2: reset console
F5: save game state
F9: load most recent save state

If the game is called mygame.nes, the save state files will be called mygame-#.dat. To load any previous save state, drag and drop a .dat file onto the window.

Use

Double-click or run the executable from a terminal by itself to launch with instructions. Then click Ok and drag a (iNES/.nes) ROM file onto the window. Or, drag and drop a ROM file onto the executable to run it directly, or use the path to the ROM file as the first argument to the terminal command.

If the game uses battery-backed RAM (if it can save data when the console is turned off), a save file like rom_filename.sav will be created in the same folder as the ROM when the program is exited. When Nestur is run again, it will look for a file matching the ROM name, with a .sav extension instead of .nes.

Compilation

  1. Install Rust
  2. Have a C compiler
  3. Install CMake
    • Linux: sudo apt install cmake
    • Mac: install Homebrew and run brew install cmake
    • Windows
  4. cd nestur/ && cargo build --release (be sure to build/run with the release flag or it will run very slowly)
  5. The nestur executable or nestur.exe will be in nestur/target/release.

To do

  • support other controllers?

  • more mappers?

  • better save file organization?

Known problem games

  • None currently, please report any issues

Please also check out Cloaker and Flying Carpet!

nestur's People

Contributors

acalhoon avatar mahallon avatar spieglt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nestur's Issues

Emulation Timing Issues and Sprite Zero Hit Inaccuracies

Hi!

I spent some time last night diving into some nes test roms for my fuzzer, and uncovered the following small issues. With these issues fixed games like Mega Man reproduce much better (although there are still some NMI timing issues I have yet to look into)

Given https://github.com/christopherpow/nes-test-roms/tree/master/cpu_timing_test6 the following opcodes report inaccuracies:

  • JMP in ABS mode (1 cycle too long)
  • RTI (2 cycles too long)
  • STA in Indirect Indexed Mode (should be 6)
  • STA in Absolute Y mode (should be 5)

I've fixed this in my fuzzer by adding offsets to JMP and RTI, and adding a before_clock parameter to report a complete offset for STA in those 2 special cases (see: https://git.openprivacy.ca/sarah/nesfuzz/commit/f7110dcd50da9680d79d7253c436989818c39609) - but this is kinda hacky and you may or may not want to use a different approach.

Given https://github.com/christopherpow/nes-test-roms/tree/master/sprite_hit_tests_2005.10.05

  • 06.right_edge fails (Should always miss when X = 255) - can be fixed with a check in src/ppu/rendering.rs
  • 07.screen_bottom ( Should always miss when Y = 255) - this seems to be related to PPU timing issues.

Note: 09/10/11 will all fail until cpu cycle issues documented above are fixed.

Given https://github.com/christopherpow/nes-test-roms/tree/master/blargg_ppu_tests_2005.09.15b

  • cpu writes to 0x4014, OAMDATA should start at the address in OAMADDR and wrap rather than replace OAM entirely.

Attempt to subtract with overflow

Nice project! I found a problem and thought you might want this bug report. This is based on commit
ea70b59. I'm a little new to Rust so I can't help much with the diagnosis.

fps: 14
fps: 9
thread 'main' panicked at 'attempt to subtract with overflow', src/apu/square.rs:117:17
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:76
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:60
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1030
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:64
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:196
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:473
  11: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:380
  12: rust_begin_unwind
             at src/libstd/panicking.rs:307
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  14: core::panicking::panic
             at src/libcore/panicking.rs:49
  15: nestur::apu::square::Square::calculate_target_period
             at src/apu/square.rs:117
  16: nestur::apu::square::Square::write_timer_low
             at src/apu/square.rs:146
  17: nestur::apu::Apu::write_reg
             at src/apu/mod.rs:95
  18: nestur::cpu::Cpu::write
             at src/cpu/mod.rs:203
  19: nestur::cpu::opcodes::<impl nestur::cpu::Cpu>::stx
             at src/cpu/opcodes.rs:491
  20: nestur::cpu::Cpu::step
             at src/cpu/mod.rs:174
  21: nestur::main
             at src/main.rs:58
  22: std::rt::lang_start::{{closure}}
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/rt.rs:64
  23: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:49
  24: std::panicking::try::do_call
             at src/libstd/panicking.rs:292
  25: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  26: std::panicking::try
             at src/libstd/panicking.rs:271
  27: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  28: std::rt::lang_start_internal
             at src/libstd/rt.rs:48
  29: std::rt::lang_start
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/rt.rs:64
  30: main
  31: __libc_start_main
  32: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.