An open API service indexing awesome lists of open source software.

https://github.com/firobe/nes-ml

NES emulator in OCaml
https://github.com/firobe/nes-ml

emulator nes ocaml

Last synced: about 1 month ago
JSON representation

NES emulator in OCaml

Awesome Lists containing this project

README

        

# nes-ml


Mario Bros
Metal Gear
Prince of Persia

A NES emulator from scratch in OCaml (and with sound). Still in development (see [development status](#development-status)).

![CI](https://github.com/Firobe/nes-ml/actions/workflows/build.yml/badge.svg)

## Build & Install

Assuming you have `opam` installed with an existing switch, either:
- add a pin to this repo:
> `opam pin add nes-ml https://github.com/Firobe/nes-ml.git`

- or clone and run
> `opam install .`

This will fetch the libraries (two of them are unreleased and will need pins), build and install the emulator.
The executable name is `nes-ml`.

Note: I recommend using a build with `flambda` activated for more performance.

## Usage

Use : `nes-ml PATH_TO_ROM`

See `nes-ml --help` for a list of useful options

### Controls (hard-coded)

| Function | Keyboard key |
| --- | --- |
| A button | S |
| B button | D |
| Left arrow | ← |
| Right arrow | → |
| Up arrow | ↑ |
| Down arrow | ↓ |
| Start | ⏎ (return) |
| Select | ⌫ (backspace) |
| Toggle GUI | Escape |
| Save state in slot `N` | `N` |
| Load state from slot `N` | Shift+`N` |
| Toggle debugging windows | Home |

Note that the `N` for save states must be 1, 2 or 3.

## Development status

- **Cycle-accurate CPU** (see [`6502-ml`](https://github.com/Firobe/6502-ml))
- **Cycle-accurate PPU** (graphics) (with rough edges)
- Partially implemented cycle-accurate **APU** (sound) (with rough edges)
- Multiple **save states**
- Implemented mappers: 0, 2
- Barebones GUI (with debugging windows showing the internal PPU state)
- Movie (input log) recording and replaying (in custom format with subframe precision)
- Ability to record video (lossless `mp4`) of runs with ffmpeg
- Headless mode for automatic tests

## Next steps

- Implement mappers 1, 4

## Based on

- separate CPU library: [`6502-ml`](https://github.com/Firobe/6502-ml)
- fixed-size int literals: [`stdint-literals`](https://github.com/Firobe/ocaml-stdint-literals)