Moon Dancer
Moon Dancer is a from-scratch native port of Michael Jackson's Moonwalker for Windows, Linux, and Android.
- Type: PC port
- Game: Michael Jackson's Moonwalker
- Runs on Windows and Android
- By sergiomanzur
- Latest release v0.9.1b, 2026-11-24
- Source: https://github.com/sergiomanzur/MoonDancer
README
Moon Dancer
v0.9.1b — a from-scratch, native Windows/Linux/macOS/Android runtime for
Michael Jackson's Moonwalker (Sega System 18, 1990), built from the user's
own mwalk.zip ROM set. It is not a MAME front end: the board's 68000, memory
mapper, video hardware, I/O chip and sound board are implemented in portable
C/C++ and the game's FD1094-encrypted program is executed by the native
runtime.
mwalk.exe -> System 18 machine model
|- FD1094 68000 (trace-guided static C translation)
|- 315-5195 memory mapper
|- 315-5296 I/O chip
|- System 16B tilemaps + text layer + 16B sprites
|- 315-5313 VDP (register/DMA/VRAM model; renderer WIP)
|- Z80 sound CPU + 2 x YM3438 (ymfm)
`- 8751 protection/sound MCU (real 8051 program)


Quick start
- Own the arcade ROM set (
mwalk.zip) — this project ships no game data (see ROM setup). - Build the runtime:
cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Releasethencmake --build build(Linux/macOS: drop the-G Ninja/compiler flags — see Building). - Run
build\mwalk_launcher.exe(or./build/mwalk_launcher), BROWSE to yourmwalk.zip, press START GAME. - In game:
5inserts a coin,1starts; full layout under Controls.
What's new in 0.9.1b
Moon Dancer is now on Android — the full launcher + game in one app, with the same settings, cheats and controller panels as the desktop build:
- On-screen touch controls with icons that show exactly what they do (fist = punch, rising figure = jump, sparkles = magic, coin slot, 1P START) — switchable between a D-pad and a floating joystick in SETTINGS, hideable from the launcher or the in-game overlay (a corner MENU button and the Android Back key always get you back in).
- ROM import via the Android system file picker; a private build
script (
package_android_private.ps1) can bake your ownmwalk.zipinto a personal APK that is never to be published. - Full gamepad support — including the handheld's built-in controls.
- Fixed on every platform: NVRAM never actually loaded. The saved image was restored before the CPU reset cleared work RAM, so every launch silently started clean. Credits/bookkeeping now persist across restarts and force-stops, verified byte-for-byte against the MAME oracle. (High scores are volatile by the game's own design — MAME resets them identically.)
- Gamepad menu navigation across the launcher and every in-game panel, including D-pad/stick-adjustable volume and scanline sliders — no mouse needed anywhere.
- In-UI archive browser (controller and touch navigable) as the non-Windows picker; Windows keeps its native dialog.
- Performance: the Android native core builds optimized (
-O3) and paces at the board's native 57.23 Hz with ~70% frame headroom on a Retroid Pocket 6.
What's new in 0.9.0b
The first public beta. Accuracy fixes — every one verified against the MAME oracle (frame-identical tile/text RAM, lockstep CPU self-tests, audio envelope correlation):
- Sprite renderer now matches MAME's
sega_sys16bdevice exactly: transparent pixels consume a screen column, so zoomed sprites no longer shear, wobble, or lose their left half. - Widescreen map margins mirror the quadrant the level loader actually streams — the foreign-map slabs that appeared past the original 320-column window are gone.
- Interpreter branch patcher preserves branch lengths (a byte branch was patched as a word branch, shifting the CPU into mid-instruction and crashing after the monkey room).
- Widescreen culling is applied at all eight visibility sites on both CPU paths (translated and interpreter), so objects no longer flicker between alive and culled in the expanded view.
- Core board fixes: read-modify-write helpers no longer advance
(An)+/-(An)twice, and 16-bit writes to the 315-5195 mapper window decode as a single low-byte register write. The vblank palette queue drains every frame — 60,000-frame attract and 30,000-frame gameplay runs complete with zero interpreter fallbacks, zero illegal opcodes and zero watchdog resets. - RF5C68 PCM model fixed (bank shift, 10 MHz clock, output level): the dance-magic song plays, envelope-matched against MAME.
- Keyboard focus: the launcher used to hide itself before spawning the game, so Windows denied the game window keyboard focus (pads kept working because they are polled). The launcher now grants foreground rights and the game claims focus on startup.
Features added in this release:
- Launcher music — a procedurally generated synthwave loop (Am–F–C–G,
kick/sub bass/arp/pad/hat layers, LFO filter pump) with a MUSIC toggle
that persists in
settings.ini. No audio assets, no new dependencies. - Sound on by default with a live SOUND toggle;
--audio/MW_AUDIOremain force-on overrides. - Video options: shader presets OFF / SCANLINES / CRT with an intensity slider (computed per emulated scanline, so effects stay crisp at any window size) and window-resolution presets.
- Cheat menu (in-game F1): infinite lives, invincibility, infinite dance magic, free credits — global, session-only, live-toggleable.
- Three simultaneous game controllers with per-player keyboard and pad remapping (press-to-capture), GUID-based assignment that survives replug/reorder, and a reserved-slot display.
- Widescreen display modes (16:9 / 16:10 / 21:9) active from boot, with attract screens still presented in 4:3.
Launcher
The recommended way to play is mwalk_launcher.exe:
- BROWSE opens a native archive picker for your
mwalk.zip(you can also drag the archive onto the launcher). - START GAME launches
mwalk.exedirectly from the selected ZIP. The archive is extracted to a per-user cache, so there is no manual ROM setup. - SETTINGS opens the shared neon overlay (SETTINGS and CONTROLLERS panels) and reopens whichever panel was used last. The same overlay is available inside the game with F1, which adds a CHEATS panel.
- QUIT exits the launcher.
START saves any pending settings and then runs mwalk.exe from the selected
archive. Sound and all key/pad bindings reach the game through
settings.ini, so no extra launch arguments are involved.
The launcher uses launcher_background.jfif, bundled Audiowide/Rajdhani
fonts, high-DPI rendering, and the same design language as the in-game
settings panel — plus a generated synthwave soundtrack (MUSIC ON/OFF
button, persisted in settings.ini; it pauses while the game runs and
resumes when you come back). It remembers your archive, shows live
controller state, and shares settings with the game. Settings are stored in
%APPDATA%\MoonwalkerRecomp\Moonwalker\settings.ini on Windows, or the
SDL preference directory on other platforms.
Settings and video options
The overlay is shared by the launcher (SETTINGS) and the game (F1):
- AUDIO -- MASTER VOLUME plus a SOUND toggle. Sound is on by default
(
sound_on=1) and the toggle applies live: the SDL audio device opens or closes without a restart, and the choice is saved. The legacy--audioflag andMW_AUDIOenvironment variable still force sound on for a session. - DISPLAY -- 4:3 ORIGINAL / 16:9 / 16:10 / 21:9 (see below).
- VIDEO -- FULLSCREEN; SHADER preset OFF / SCANLINES / CRT with SCANLINE INTENSITY (0-100%); RESOLUTION presets 1280x720, 1600x900, 1920x1080 and 2560x1440, applied immediately when the game is running (in fullscreen the desktop size wins); and INTEGER SCALING. Shader presets run in source space, so every emulated line gets exactly one scanline at any window size: OFF is a byte-exact no-op, SCANLINES darkens alternate lines, CRT adds a vertical aperture grille.
- INTERFACE -- SHOW FPS.
- CONTROLLERS -- the gamepad panel described below.
Widescreen display modes
Open SETTINGS in the launcher or press F1 in the game and choose a DISPLAY mode:
- 4:3 ORIGINAL -- the original 320x224 framing and original culling. This mode is pixel-identical to the classic presentation.
- 16:9, 16:10, 21:9 -- the expanded field of view. The renderer builds a 560x224 world centered on the original 320x224 view and crops it symmetrically to the selected aspect ratio. The image is never stretched; extra world is revealed on the left and right.
Widescreen keeps the original view centered in the new frame. The expanded sprite visibility checks stay active from boot, including during the intro, so cutscene script state cannot change when gameplay starts. Attract and boot screens are still presented in 4:3 by cropping the center of the same 560-wide game view. In the few map areas the original level loader never streams beyond its 320-column window (only reachable in the outer 21:9 margin), the renderer mirrors the nearest loaded tile columns instead of exposing a black hole.
Current status
Working:
- ROM verification and FD1094 decryption in Python (
tools/mwalk.py) and native C (src/fd1094.c). - Full boot sequence through all copyright/notice screens.
- Attract mode/title screen with the isometric city background, logo, HUD, player panels and sprites.
- Native 320x224 framebuffer with the board's four-layer priority scheme
(background tilemap, foreground tilemap, text, System 16B sprites). The
sprite renderer matches MAME's
sega_sys16bdevice exactly, verified against an independent re-implementation: transparent pixels consume a screen column, so zoomed sprites no longer shear or wobble. - Keyboard input for 1–3 players, plus up to three SDL game controllers (auto-assigned to 1P/2P/3P, with remappable directions and buttons); coins, starts and service; coin/start flow reaches actual gameplay.
- Coin/start flow verified against MAME: the service-port coin edge is
latched, credits increment at
$E000, the start press consumes a credit, and the post-start mode byte$E036matches MAME (0x18). Tile RAM and text RAM are byte-identical at frame 1200 with the same inputs. - NVRAM persistence: work RAM is the board's 16 KiB NVRAM (settings,
bookkeeping). The SDL build loads/saves
nvram/mwalk/nvramunder the host data directory — the executable's folder in a portable desktop build, the app's files directory on Android — not relative to the shell's working directory.--nvram FILEoverrides the path and--no-nvramdisables every write, including the Android periodic flush (a running game rewrites the image every 30 s; backgrounding and a clean exit save immediately — see the Android section for the exact force-kill contract). Credits are battery-backed and survive a relaunch, as on the board. The high-score table is volatile — the game rebuilds its factory table at every cold boot; see the Android section for the board-oracle evidence. - Fixed a 68000 recompiler bug where register bit operations (
BSET,BCLR,BCHG,BTST Dn,Dn) were emitted as byte operations instead of 32-bit operations. This was corrupting the palette shadow buffer during fades. Compiled vs Musashi at frame 1200 is now 4 bytes (2 dead stack); palette RAM is identical. With a fresh NVRAM and aligned MAME frame callbacks, tile/text RAM is byte-identical and the rendered frames are pixel-identical at the sampled frames (0, 1, 100, 947, 1200, 1210, 1250). The remaining work-RAM difference is ~73-83 bytes of scratch/stack and live animation cells. - 57.23 Hz frame pacing and a resizable SDL2 window.
- Full 8751 MCU execution (MIT emu8051 core) on its mapper bus, including the vblank IRQ4 generator, protection mailbox and sound FIFO.
- Sound board: Z80 + two YM3438 (ymfm) with music and FM effects; ymfm
timers and the YM IRQ line are wired to the Z80. The RF5C68 PCM device is
modelled but Moonwalker's sound program does not currently write to it.
FM/PCM synthesis and the SDL audio device are on by default
(
sound_on=1); the audible path was verified against the MAME oracle (dance-magic WAV envelope correlation, attract/gameplay replay runs with no errors). With sound switched off the Z80 runs in a muted fast mode so the protection MCU's vblank handshake stays alive. - Static recompilation: every reachable
(FD1094 state, PC)pair is lifted to C, grouped into linked basic blocks, and dispatched through sorted tables. The current translation has 32,392 instruction blocks and 12,106 basic blocks, including a ROM-wide direct-control-flow sweep of the code image (0x000000-0x20FFFF). - Instruction-level and block-level lockstep self-tests run the translated core and Musashi side by side from reset for 1,000,000 instructions, comparing registers, SR, FD1094 state, RAM and exact per-instruction / per-block cycle counts.
- Coverage-guided expansion records missing blocks from randomized and audio-enabled runs, merges them, regenerates and repeats until convergence. The verified gameplay and long attract paths run without illegal-opcode recoveries; any remaining untranslated exception-handler entries fall back to Musashi and do not stop the game.
- Deterministic input replay and canonical frame hashing (
--record-input,--replay,--hash-file) give byte-reproducible regression runs. Stack scratch is excluded from the semantic hash while the full hash remains available for debugging.
Not finished yet:
- Core correctness fixes, cross-checked against the MAME oracle: the lifted
read-modify-write helpers no longer advance
(An)+/-(An)twice, and 16-bit writes to the 315-5195 mapper window now decode as a single low-byte register write (MAMEumask16(0x00ff)). The vblank palette queue drains every frame; 60,000-frame attract and 30,000-frame gameplay runs complete with zero interpreter fallbacks, zero illegal opcodes and zero watchdog resets. The invalid-PC and palette-fade watchdogs remain as zero-cost safety nets. - The VDP enable gate (315-5296 CNT2) and the plane renderer are wired and verified in the tested scenes. The title/intro scenes keep the VDP planes blank; gameplay fills VDP VRAM and renders matching backgrounds. The VDP sprite attribute table is all zero in the tested gameplay frame, so the sprite path is not exercised; the window plane is not visibly different.
- The ROM sweep covers direct control flow in the code image; a function
reached only through an unobserved computed jump/call can still fall back
to Musashi.
src/generated_game.cis derived from your ROM and is intentionally excluded from the repository; the compiled translation is linked into the binary you build, so keep binaries built from your ROMs to yourself. - Demo-mode P1 input values are bit-identical at the game's read points, but the intro task transition is still 4 frames out of phase: MAME switches to the gameplay task while both port CPU paths remain on the intro task. This is an input-pipeline/task-order difference in the board model, not a translated-68000 error. Sampled non-demo frames are pixel-identical.
Building
Requirements:
- CMake 3.20+
- A C11 and C++17 compiler (GCC/Clang; MSVC also works for the runtime)
- SDL2 2.0 development files (the Windows build uses the MinGW package in
third_party/sdl2_dl/SDL2-2.30.11) - Python 3 for the ROM tools (only needed to inspect/verify the ROM)
Windows (MinGW GCC + Ninja):
cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release
cmake --build build
.\build\mwalk_launcher.exe
To launch directly from an archive:
.\build\mwalk.exe --zip mwalk.zip
The game still accepts --rom-dir roms for an already-extracted set.
To produce a portable Windows folder/ZIP (no ROM data included):
package_windows.bat
Linux:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
./build/mwalk --rom-dir roms
macOS: the same CMake flow, using the SDL2 framework/package from Homebrew or the official SDL2 DMG.
Android: the machine, FD1094, video and audio modules are portable C/C++;
the SDL2 front end maps directly to SDL_main/SDLActivity. The Gradle
project lives in android/; see Android for the build, install
and controls.
Android
The Android port is one app, com.moondancer.recomp: the neon launcher and the
game run in the same process, on SDLActivity's SDL thread. It targets
arm64-v8a, landscape, Android 8.0 (API 26) or newer; the reference device is
the Retroid Pocket 6 (Android 13).
Requirements
- Your own
mwalk.zip— the app ships no game data. - A 64-bit ARM device with Android 8.0+.
- To build: Android SDK 34 and NDK 26.2 (the versions pinned in
android/app/build.gradle), the repository's Gradle wrapper, and SDL2 sources fetched once withpython tools/fetch_sdl2_source.py.
Build and install (public, ROM-free)
cd android
.\gradlew.bat :app:assembleDebug
The artifact is android\app\build\outputs\apk\debug\app-debug.apk.
Sideload it (from android/) with
adb install -r app/build/outputs/apk/debug/app-debug.apk, or copy the APK to
the device and open it. Launch Moon Dancer.
The variant stays debug deliberately: it installs without a keystore, while
the native code is pinned to -O3 (see Performance). A
release-signed build would need key management this project does not provide.
The public APK contains no ROM data — only the app code, fonts and
background — but like mwalk.exe it does contain the translated game code
built from your ROM, so keep it to yourself.
Importing the ROM
The launcher opens with NO ARCHIVE SELECTED; tap BROWSE. Android's
system document picker opens and you pick your mwalk.zip. The archive is
copied to the app's private files/mwalk.zip, announced to the launcher, and
the card changes to READY // ARCHIVE SELECTED. A failed or cancelled import
never destroys the archive already there. START GAME runs the game
in-process (the launcher window is destroyed first because the activity has
one surface); quitting the game from the in-game overlay recreates the
launcher. On later launches the saved archive is found automatically.
Controls
Touch controls drive player 1; gamepads work exactly as on desktop (up to three, with per-player rebinding and GUID-based slots).
- Left half — JOYSTICK by default: a floating stick that anchors where
your thumb lands, with a visible dead-zone. Switch to DPAD (fixed cross,
four-way plus corner diagonals) in SETTINGS → CONTROLLERS. The choice is
saved in
settings.ini. - Right half — PUNCH, JUMP and MAGIC round icons (B1/B2/B3).
- Bottom centre — COIN and 1P START chips; each tap is one press (no auto-repeat while held).
- Top right — MENU (pause bars) is always available, even with the touch layer hidden, and opens/closes the same overlay as F1.
- BACK is trapped by SDL instead of finishing the activity: in game it toggles the overlay (never quits); in the launcher it closes the archive browser or settings panel, and only then exits the app.
- The overlay's QUIT GAME returns to the launcher; the launcher's QUIT exits the app. RESET GAME, cheats, SOUND, DISPLAY (4:3/16:9/16:10/21:9), shader and volume work as on desktop; the window-resolution presets are hidden because the activity surface owns the size.
- TOUCH ON/OFF is on the launcher card and the overlay; hiding the layer keeps MENU visible so there is always a way back.
The app launches immersive: the