Skip to content

About

Mega Man 2 (NES) recompiled to native PC: 240 Hz smooth motion, no flicker, gentle flashes, calm water and clouds. Needs your own ROM.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Mega Man 2 Recompiled

A native PC port of Mega Man 2 (NES, USA), built with NESRecomp. The game's own 6502 code is recompiled to C and runs natively, cycle-accurate, at the speed of the real console, with additions the NES could never do:

  • 120 / 180 / 240 pictures a second. In-between pictures for high-refresh and FreeSync / G-Sync monitors, drawn at 4x resolution so things can move a quarter of a NES pixel at a time.
  • Smooth scrolling. Mega Man walks 1.375 pixels a frame, which the NES shows as an uneven 1, 2, 1, 1, 2 step; here the scenery glides at an even speed. Camera easing (Gentle) lets it speed up and slow down instead of jumping from standing still to full speed in one frame.
  • Smooth screen changes. Climbing a ladder to the next screen or walking through a boss door scrolls evenly, and the half-drawn rows the NES leaves at the screen's edge while it scrolls (the "garbled grass" going up a ladder) are replaced by the clean rows from a moment before.
  • Character glide. Mega Man, the enemies, their shots and the items glide between the game's positions instead of hopping in uneven steps.
  • No sprite flicker. Every sprite is drawn every frame (the NES can only draw 8 per line), so the crowded rooms and bosses don't blink.
  • Gentler flashes. The white whole-screen flashes (a Wily boss exploding, the castle map, choosing a stage) become a soft, steady glow.
  • Calm water and clouds. Bubble Man's waterfalls and Air Man's clouds cycle a band of bright white through their colours; here they flow in soft, close colours, or can be held still.
  • An edge crop hides the NES's scrolling garbage, an in-game settings menu, save states with pictures, and a note for your current password in the launcher.

Everything above changes only the picture; the game itself runs exactly as on a NES, slowdown included. Each feature can be switched off in the menu.

You need your own ROM. This repository contains no game data. You must supply a dump of Mega Man 2 (USA) (SHA-1 2290d8d839a303219e9327ea1451c5eea430f53d); the program checks it is the right one before it runs.

Download

Get the latest version from the Releases page:

  • Windows: MegaMan2Recomp-Windows-x64.zip. Extract it, double-click mm2recomp.exe.
  • Linux: MegaMan2Recomp-x86_64.AppImage. Mark it executable (right-click, Properties, Permissions, or chmod +x), then double-click it.

The first time, the game asks for your ROM and checks it. No building needed.

Recommended settings

High-refresh monitor? Set Pictures per second to 240 (or 180) and turn VSync Off (with FreeSync/G-Sync). VSync starts On, which suits 60 Hz monitors but makes the extra pictures stutter.

The game starts with these already on, except two you set yourself: Pictures per second starts at 60, because only high-refresh monitors benefit from more, and the game opens in a window (press F11 for fullscreen). In game, press Escape (or the right shoulder button) for the menu:

Menu Setting Recommended
Smooth motion Pictures per second 240 or 180 on a 240 Hz FreeSync/G-Sync monitor; your monitor's rate or lower otherwise; 60 (off) on a 60 Hz monitor
Smooth motion Camera easing Gentle (Quick for the game's instant starts)
Smooth motion Character glide On
Smooth motion Second core On
Smooth motion Colour cycling Smooth
Picture Screen flashes Steady glow (Soft, No flash, or As the game)
Picture Water & clouds Calm (Still holds them still; As the game)
Picture No sprite flicker On
Picture Edge crop Standard
Graphics VSync Off with FreeSync/G-Sync; On without
Display Fullscreen On (F11 toggles)

Settings are saved in config.ini beside the program.

Troubleshooting

  • Stutter at 120/180/240: check that VSync is Off and your monitor's FreeSync/G-Sync (on KDE: Adaptive sync Always) is on, and that Second core is On. Close busy programs. On Linux the game keeps its two busy threads on separate CPU cores by itself (CYC_PIN=0 turns that off); on Windows, try 180 if 240 isn't steady.
  • The controller stops responding: a controller that was connected for a long time can stop sending input: unplug it and plug it back in.
  • The sound comes out of a PS4 controller: a wired PS4 controller is also a sound card. Pick your speakers in your system's sound settings (Linux: set the controller's audio profile to Off).
  • Windows SmartScreen warns about an unknown publisher: More info, then Run anyway.
  • The AppImage won't start on an older Linux: install FUSE 2 (sudo apt install libfuse2) or run it with --appimage-extract-and-run.
  • Wrong ROM: the game only accepts the USA release; other dumps are refused before the game starts.

Building

Only needed if you want to change the code. You need Git, CMake 3.20+, a C/C++ compiler, Python 3.11+ and SDL2.

Linux (Arch/CachyOS: sudo pacman -S git cmake ninja sdl2 python; Debian/Ubuntu: sudo apt install git cmake ninja-build build-essential libsdl2-dev python3):

git clone --recursive https://github.com/gabbycat4/MegaMan2Recomp.git
cd MegaMan2Recomp
cp /path/to/your/rom.nes megaman2.nes
cmake -S . -B build-play -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-play --parallel
./build-play/mm2recomp megaman2.nes

--recursive also downloads the engine and the menu (they are submodules). If you cloned without it, run git submodule update --init --recursive. The first configure takes a while: it builds the recompiler and translates the game.

Controls

Keyboard and controllers are rebindable in the launcher's Controls page.

Escape / right shoulder Menu
F7 Save states
F8 Rewind (off by default; turn on in the menu)
F11 Fullscreen
Tab Fast forward
F12 Screenshot

Command line

Many menu settings also have an option for one run (it does not change config.ini): --present-rate N, --camera-easing 0|1, --char-glide 0|1, --emu-thread 0|1, --screen-shake 0|1, --no-sprite-limit 0|1, --sprite-order 0|1, --overscan T,B,L,R. --plain 1 shows the engine's own picture for comparing. Developer logs: --scroll-log FILE, --oam-log FILE, --ppu-log FILE; CYC_PACING_LOG=FILE for picture timing, MM2_PERF_LOG=FILE for this project's drawing times and self-check.

How it works

The NESRecomp engine runs the recompiled game cycle by cycle. This project adds a presentation layer (src/mm2_extras.c) through the engine's HOST_EXTRAS interface:

  • each frame the screen is split into scroll bands from the PPU's per-line scroll; the playfield follows an eased copy of the game's camera and is redrawn from the background alone at its smoothed position. During vertical screen changes the rows the game is still rewriting come from the last frames that showed them cleanly;
  • sprites are matched frame to frame (by tile, flips and palette, then by position when a character changes its picture) and grouped into characters; Mega Man's pieces are never grouped with anything else;
  • flashes and colour cycling are read from the palette each frame. The water and clouds are found by their palette entry (nametable, attribute and pattern at each line's scroll), never by colour, so the same white elsewhere stays white;
  • a self-check compares the redrawn picture with the NES's own every frame and shows the NES's picture whenever they differ;
  • with a picture rate above 60, the next NES frame runs on a second core while the in-between pictures are shown, so they stay evenly spaced.

notes.txt has the measurements behind each feature, and tools/mm2_harness.c replays the smoothing on recorded play without a window, which is how the changes were checked.

Help wanted

Emulating one NES frame takes about 9 ms on a Ryzen 7 2700, which is why the second core is needed above 60. Optimizations in the engine are welcome.

Credits and licences

  • NESRecomp and recomp-ui by Matthew Stanley; their own licences apply (see the nesrecomp and recomp-ui folders). The engine submodule points at a fork with window additions (in-between pictures, the second-core option and its thread placement, display-sized windows, a VSync menu row).
  • This project's code is licensed under the PolyForm Noncommercial License 1.0.0 (LICENSE): free to use, share and change; not to be sold.
  • Mega Man is © Capcom. This project is not affiliated with Capcom and includes none of the game.

About

Mega Man 2 (NES) recompiled to native PC: 240 Hz smooth motion, no flicker, gentle flashes, calm water and clouds. Needs your own ROM.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages