Repository navigation
Releases
v.04.0: Speed and the Vita
v0.4.0: Speed, and System Shock 2 on the PS Vita
Tools only, as always: no game code and no executables are included. You build everything from your own copy of System Shock 2 (NewDark 2.48). The default output is unchanged; everything new for speed is opt-in.
PS Vita backend (new)
port/backends/vita/: the recompiled game on a homebrew-enabled PS Vita (vitaGL). It boots and plays on real hardware, level changes and saves included, at about 15-21 fps exploring and 6-8 fps in heavy firefights. The game's own code on one CPU core is the limit; rendering, file access and sound run on the other cores.- Built with the same
port/build.pyplus the vitasdk toolchain; instructions in[port/backends/vita/README.md](https://github.com/Owloeb/NewDarkRecompiled/blob/v0.4.0/port/backends/vita/README.md). Measurements, what helped and what didn't:[PERF.md](https://github.com/Owloeb/NewDarkRecompiled/blob/v0.4.0/port/backends/vita/PERF.md). - A file layer for the memory card: read windows and read-ahead, written files kept in memory until closed, a 24 MB cache for the sound archives, and a hang watchdog that forces a core dump.
Faster generated code (port/build.py --cache-regs, opt-in)
- Guest registers live in C locals instead of the CPU struct. Indirect calls and imports are held to the calling convention, a new proof (
lift_preserve.py) works out which registers each function preserves, and the x87 stack moves into C locals too (lift_x87.py, about 1.5x on float-heavy code). Indirect calls go through a per-thread cache of recent targets. - Verified at run time with
--abi-check: every call that relies on an assumption checks it and logs any violation. Full play sessions on Linux and the Vita reported none. There are new tests with negative controls (harness/abi_test/run.sh) and random-program fuzzing (csmith_fuzz.py, integer and floating point). How it works:[docs/RECOMPILER.md](https://github.com/Owloeb/NewDarkRecompiled/blob/v0.4.0/docs/RECOMPILER.md#register-caching---cache-regs).
Portable host
- Render thread: the renderer can run on its own core, together with the Direct3D per-vertex work (transform, lighting, fog), at most one frame behind the game. On by default on the Vita;
SS2PORT_RENDER_THREAD=1on the desktop. Ports now implement one extra call,plat_gfx_deferred. - Fast paths (
--fastpaths): native C for the hottest engine functions: string and key hashes, the hash-table lookups behind object queries,_ftol/_ftol2and a bitmap copy. Each one is checked against the game's own instructions in an x86 emulator (port/tests/fastpaths/check.py). - Buffered file writes: level changes were slow under WSL because every small write went straight to disk. They're now fast.
- File reads no longer hold the guest lock, so other guest threads keep running during slow I/O.
- Sampling profiler:
--prof, plustools/fnprof.pyto summarise it. --guest-backedfor platforms without lazy memory commit, and--symbolsfor named crash reports.
Naming the engine
- Play-session recorder (
host/build_win.py --record) andtools/suggest_names.py: play the game and get a work list of which functions run for which activity. - The engine's console command table is harvested automatically (106 commands,
tools/annotate.py); hand-verified key handlers and the AI message factories are insymbols/manual.sym.
Documentation
- Reorganised around what you want to do.
[docs/FLAGS.md](https://github.com/Owloeb/NewDarkRecompiled/blob/v0.4.0/docs/FLAGS.md)lists every build option, command-line flag, environment variable, switch file and tool in one place.
Tests
- Conformance: 509 checks headless, 536 with pixel-exact rendering (also with the render thread on), plain and
--cache-regswith--abi-check. - New suites: render-thread stress test (600,000 random calls, ThreadSanitizer), Vita sound cache, fast paths against the game's own code, and
--cache-regsend to end.
Full changelog: [v0.3.0...v0.4.0](v0.3.0...v0.4.0)
v0.3.0: Portable Host (To Linux, and Beyond!)
v0.3.0: Portable Host (To Linux, and Beyond!)
- New
port/: a platform layer that runs the recompiled game with no Windows and no x86 CPU. Win32, the C runtime, Direct3D 9, DirectSound and DirectInput are implemented on top of one small interface,port/include/plat.h. A port to a new platform writes a backend for that interface and nothing else. - Backends included: POSIX, Windows (development and test target), SDL2 (OpenGL 2.1 and OpenGL ES 2.0), and a headless one.
- One-command build:
python3 port/build.py "<SS2.exe>". See the Linux quick start inport/README.md. - Plays through Rickenbacker and Body of the Many on Linux (WSL) and as a 64-bit Windows build. Experimental: mouselook on native Linux is untested (WSLg cannot capture the pointer).
- Known gaps: shaders and cube/volume textures (the game falls back to fixed-function; screen-distortion and blur effects are missing), C++ exceptions,
fmsel.dllon the portable host. - READMEs restructured; recompiler notes moved to
docs/RECOMPILER.md.
v0.2.0: Built-in portable cutscene decoder in place of ffmpeg.dll
v0.2.0: all .osms recompiled, built in cutscene decoder
- Cutscenes are decoded by a built-in portable C decoder (video/). lgvid.dll runs unchanged on top of it. The decoder reads AVI files with Indeo 5 video and PCM audio, which is everything the game ships.
- ffmpeg.dll is no longer loaded. This removes the heap-corruption workaround and its leaks.
- darkrecomp_native_ffmpeg.txt next to the exe brings back the original ffmpeg.dll, for cutscene mods in other formats.
- The Indeo 5 decoder in video/ffmpeg/ is FFmpeg's, unmodified and LGPL 2.1. Everything else stays MIT.
- Since v0.1.0, allobjs.osm, Squirrel.osm, lgvid.dll and fmsel.dll are all recompiled too, and the build names about a third of the functions from your own exe.
v0.1.0
First experimental release: tools only. This is for people who want to try it or poke at it. Expect rough edges.
What you get
The recompiler, the Windows host and a one-command build script. No game code and no exe are included: you generate everything from your own copy of System Shock 2 (NewDark 2.48).
Try it (Windows, PowerShell)
python -m pip install pefile capstone ziglang
python host\build_win.py "C:\path\to\System Shock 2\SS2.exe" --install
First build takes about 20 minutes. Then run ss2_native.exe from your System Shock 2 folder instead of SS2.exe. See the README for details and the optional switch files.
State of things
- Playable on a flat screen: menus, character creation, level changes, save/load, HUD, audio, input, fullscreen, cutscenes.
- Cutscenes rely on a workaround for invalid frees inside the original
ffmpeg.dll(root cause not yet understood). - The original Looking Glass DLLs and
.osmscripts still run natively. - Windows only; tested with NewDark 2.48 on one NVIDIA machine, so reports from other setups are very welcome.
Goal
A VR version of System Shock 2 (OpenXR) built on the recompiled engine. VR code is not in this release.
If it crashes, ss2_native.log (next to the exe) contains a crash report; attach it to an issue.