svc-cf2-decomp

svc-cf2-decomp is a native PC port of SNK vs. Capcom: Card Fighters 2 Expand Edition for Windows, Linux and macOS with English and Korean translations and an upscaling renderer.

README

English | 日本語 | 한국어

svc-cf2-decomp

A native PC version of SNK vs. Capcom: Card Fighters 2 Expand Edition (Neo Geo Pocket Color, SNK, 2001) for Windows, Linux and macOS, built from your own cartridge image.

Story scene in Joyful Park, in English Card battle, in English

The game's TLCS-900/H machine code is translated into C++ (static recompilation, committed in src/recompiled/) and compiled into a normal program, cf2. It plays like the original, with included English and Korean translations, an upscaling renderer (2x to 8x), saves, gamepad support and an in-game settings menu. Parts of the game are being rewritten as readable C++, each part checked against the original code.

This repository and its downloads contain no ROM, BIOS or game assets: the graphics, text, music and sound come from your own cartridge image, which cf2 reads when it runs. The game's code is included, recompiled to C++ (src/recompiled/).

Download and play

No compiler needed. Download the package for your system from the Releases page: Windows (x64), macOS (Apple silicon) or Linux (x64, arm64). Builds of every commit are also attached to each run on the Actions tab. Unpack it and start bin/cf2 (bin\cf2.exe on Windows). On macOS the program is not signed: first run xattr -dr com.apple.quarantine . in the unpacked folder. Then drop your ROM (below) on the window, or press O to choose it. The package's README.txt has the rest.

What you need

  • The cartridge image: SNK vs. Capcom - Card Fighters 2 - Expand Edition (Japan), a .ngc file of 2,097,152 bytes. Check it with python3 tools/rominfo.py rom/<file>.ngc:

    CRC32CCBCFDA7
    SHA-12c4fc8594f8ba2bf39e62fe8bcb79fc2df5a83b6

    Put it in rom/ (git-ignored). No BIOS is needed: the console's BIOS is emulated.

  • To build from source: a C++20 compiler, CMake 3.20+ (3.24+ to download SDL3 automatically), Python 3 for the checks and tools (Pillow and numpy only for the art tools).

  • SDL3 for the game window. If it is not installed, CMake downloads and builds it.

Build and play

The build compiles the game's recompiled code from src/recompiled/ (about 29 MB of C++, a few minutes the first time). No ROM is needed to build, only to play. With -DCF2_ROM="rom/<your rom>.ngc" the build regenerates that code from the ROM instead and checks it against src/recompiled/ (needed only after changing config/ or src/game/hooks.txt; see docs/building.md).

macOS (Homebrew):

brew install cmake sdl3
cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/homebrew
cmake --build build -j8
./build/cf2

Linux (Ubuntu 24.04; other distributions: the same packages by their names):

sudo apt-get install build-essential cmake ninja-build python3 libasound2-dev libpulse-dev \
  libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxtst-dev \
  libxkbcommon-dev libwayland-dev libegl-dev libgl-dev
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/cf2

Windows (MSYS2, tested on real Windows): install MSYS2 in C:\msys64, put the ROM in rom\, then double-click tools\windows\build.cmd. It installs CMake and Ninja into MSYS2 if needed, builds, runs the checks and puts the game in work\cf2-windows\bin\cf2.exe (log: work\build-win.log). Visual Studio 2022 and cross-builds from Linux or macOS are described in docs/building.md (CI builds and tests with MSVC on every push, without the ROM; the game itself is not yet built with MSVC).

Install (optional): cmake --install build --prefix <folder> gives <folder>/bin/cf2 plus the language files, picture packs and fonts in <folder>/share/cf2/. Running build/cf2 straight from the build folder works too.

Playing
./build/cf2                                   # the ROM path is remembered after the first run
./build/cf2 --lang lang/en.json --scale 4     # English (lang/ko.json: Korean)
./build/cf2 --scale 4 --filter epx --edges    # smoothed 4x picture
  • Keys: arrows, Z = A, X = B, Enter = Option, F1 or Esc = menu, Tab = fast-forward, F11 = fullscreen. Gamepads work and can be rebound.
  • The menu (F1) changes language, scale, filter, volume, packs and key bindings. Settings are saved in cf2.ini, saves in saves/CCBCFDA7.sav in the per-user folder (cf2 --paths shows where). Saves are written safely, so a crash never corrupts them.
  • Translations: English and Korean are included, both the text (lang/en.json, lang/ko.json) and the lettering drawn as pictures (lang/gfx/en/, lang/gfx/ko/). At --scale 2 or more the text uses a sharper 16-pixel font. A name typed in Japanese in an old save stays in kana.
  • Picture: --scale N (1-8), --filter none|nearest|epx (epx smooths edges), --edges (also smooths where layers meet), --hires PACK (upscaled art made with the tools below).

Everything about playing (all options, the settings file, save locations per OS, troubleshooting): docs/playing.md. Everything about building (options, per-OS details, cross builds): docs/building.md.

Checking that a build is right

(cd build && ctest)                           # unit tests; no ROM needed
./build/cf2-verify --rom "rom/<your rom>.ngc" --frames 47400 --input tests/inputs/story_duel.txt
./build/cf2-hires-check --rom "rom/<your rom>.ngc" --input tests/inputs/story_duel.txt --check cycle --frames 3000
  • cf2-verify runs the recompiled game and an interpreter of the original code side by side through a recorded story-and-duel session and compares every frame. It must print LOCKSTEP OK.
  • cf2-hires-check --check cycle checks that the upscaling renderer draws exactly the original picture with the nearest filter (0 pixels may differ).
  • cf2-gamecheck --rom ROM --input tests/inputs/story_duel.txt --game all --poison plays the game with every readable rewritten routine in place of the original code and checks that the game stays the same, tick by tick.

These have passed on macOS (Apple silicon), Linux (x86-64 and arm64), Windows under Wine, and real Windows (MSYS2).

How it works

LayerWhereWhat it is
Machine modelsrc/cpu/, src/ngpc/The console: MAME's TLCS-900/H CPU core, timers and DMA, the video chip (K2GE), Z80 sound CPU and PSG, cartridge flash, and a BIOS stand-in written for this project. Matches the Mednafen emulator frame for frame.
Static recompilersrc/recomp/, src/recomp_rt/cf2-recomp translates the ROM's 3,800 routines into C++ at build time, using the interpreter's own opcode tables so the behaviour is identical. 99.6% of instructions run natively.
Readable game codesrc/game/Hand-written C++ for systems understood so far (text, dialogue, menus, cursor, name entry, card lists and viewers, task scheduler), replacing ROM routines one at a time. On by default with a translation, or with --readable.
Translationssrc/game/l10n*, lang/, tools/l10n/Any language from a language file: fonts, line breaking, layout overrides, typed names, text drawn as pictures.
Upscalingsrc/hires/, tools/hires/Redraws each frame at N x from a per-line record of the video chip. Filters, upscaled art packs and hi-res text.
Player appsrc/apps/cf2/SDL3 window, settings, input, saves, timing.
Botsrc/bot/A duel bot that reads the game's RAM and plays through the story; used to record test sessions and measure text.

Approach, phases and decisions: docs/plan.md. Everything learned about the ROM, with evidence: docs/findings.md.

Tools for studying and changing the game

Every tool reads your ROM and writes only to work/ (git-ignored).

TaskCommand or folderDocs
Check the ROM, see what the English fan patch changes (used only as a map)tools/rominfo.py, tools/ips_peek.pydocs/findings.md
Extract the font, text, card data, card art and screenstools/extract/{font,text,cards,tiles,screens}.pydocs/formats.md
Disassemble in Ghidra (TLCS-900/H module, function list)tools/ghidra/run_analysis.shdocs/environment.md, docs/notes-disassembly.md
Run the emulator headless (frames, RAM dumps, traces, coverage, bot)build/ngpc-run --helpdocs/notes-machine.md, docs/notes-coverage.md
Recorded play sessionstests/inputs/ (mkscript.py, bot recordings)tests/inputs/README.md
Check readable code against the ROMcf2-fntest, cf2-gamecheck, tools/game/verify_all.sh, tools/game/mutate.pydocs/notes-game.md
Translate: export, check, merge, pseudo-locale, done testtools/l10n/docs/l10n.md, docs/done-test.md
Picture text: inventory, override packs, translated picture packstools/gfx/, tools/gfx/lang/docs/text-graphics.md
Upscaled art packs: export, upscale (built-in or your own upscaler), buildtools/hires/docs/upscale.md
Duel botbuild/ngpc-run --bot story, tools/bot/docs/notes-duel.md

Repository layout

src/            the program: cpu/ ngpc/ recomp/ recomp_rt/ game/ gfx/ hires/ bot/ apps/
tools/          Python and shell tools (see the table above)
tests/          unit tests and tests/inputs/ (recorded sessions)
lang/           language files (en, ko, samples) and their picture packs (lang/gfx/)
translations/   glossaries, translation briefs and notes for English and Korean
config/         facts about the ROM: function list, character table, BIOS calls
third_party/    vendored code and fonts, each with its license
docs/           guides and evidence logs
cmake/, .github/  build helpers and CI
rom/, work/, build/   your ROM, tool output, build output (all git-ignored)

What is in git

Committed: our code, documentation, facts about the ROM (addresses, formats, hashes, the function list), recorded input sessions, and our English and Korean translations with their picture packs. Never committed: the ROM, a BIOS, the fan translation patch, the Japanese text, extracted assets, generated code, saves, and upscaled art packs. Licenses of vendored code and fonts are in each third_party/<name>/ folder.

Status and known limits

  • Plays through the whole story; tested by the bot to the ending, and by hand on Windows.
  • Readable code covers the text and menu systems and the card screens; duel rules and AI are still the recompiled original.
  • Link-cable play (VS. NET) is not emulated.
  • Not yet tested: the game built with MSVC (CI builds and tests everything else with it), Linux on a real desktop, real gamepads on macOS and Linux.
  • Details: docs/plan.md (status per phase) and the open issues in each docs/notes-*.md.

Docs

  • docs/playing.md, docs/building.md: for players and builders.
  • docs/plan.md, docs/findings.md: approach, decisions, status, the evidence log.
  • docs/l10n.md, docs/text-graphics.md, docs/done-test.md, translations/: for translators.
  • docs/upscale.md: the upscaling renderer and art packs.
  • docs/formats.md: text, cards, graphics and RAM formats.
  • docs/research.md, docs/environment.md: sources, licenses, tool setup.
  • docs/notes-*.md: evidence logs per area.

Credits

MAME's TLCS-900/H, TMP95C061 and T6W28 code (BSD-3), superzazu's Z80 core (MIT), stb_image (public domain / MIT), and fonts converted from Galmuri by Lee Minseo (SIL OFL). The emulators ares and Mednafen were used as references, and Sonic-Pocket showed that static recompilation of a Neo Geo Pocket Color game works. SNK vs. Capcom: Card Fighters 2 is © SNK 2001, © MOTO KIKAKU, © CAPCOM CO., LTD. 2001; this project is not affiliated with them.