# New Dawn: Combat Mission Shock Force 2, statically recompiled to Rust New Dawn runs the original 2007 *Combat Mission: Shock Force 2* executable (32-bit x86, Direct3D-era OpenGL) as **generated Rust on x64**, and draws it with a new **WGPU renderer** while the original game logic, UI and simulation run unchanged. It is a static recompiler, a Windows/OpenGL/audio runtime and a modern renderer, built so that every step can be measured against the original. > **You need your own installed copy of the game.** This repository contains > no game files, no game code and no generated code. The recompiler reads your > installed executable at build time, and the renderer loads art from your > installation. Not affiliated with or endorsed by Battlefront.com. ## What it does * **Static recompilation.** `recomp-gen` decodes the PE (iced-x86) and translates all 25,470 guest functions, plus ~2,000 extra entry points found at run time, into Rust that compiles for x64. Code the translator can't handle falls back to an embedded Unicorn x86 emulator, call by call. * **Runtime.** `recomp-rt` supplies what the game expects from Windows: guest memory and heap, the Win32/CRT/OpenGL/DirectSound imports, a captured OpenGL 1.x state machine, a software mixer with WinMM output, and a sampling profiler that attributes time to guest functions. * **New renderer.** The original's own UI is translated draw for draw, while the 3D battlefield is rebuilt in WGPU from the game's live state: terrain, buildings, vehicles with articulated parts, skinned soldiers driven by the original animation clips, effects, shadows and lighting matched to the original's light formula in display space. * **Exact record and replay.** Play sessions record every input, clock read and sound status the game sees; a replay reproduces the session bit for bit, with a simulation hash checked every 600 frames. * **Parity ledger.** Each replayed frame is scored against the original: actor positions and poses, vehicle parts, passengers, trees, buildings, lighting, textures, effects, audio, orders, selection, save/load and interface. `ledger-compare.py` turns that into ranked findings. ## Measured results * Exact replays of recorded play: 22/22 simulation hashes over a 10-minute Battle Five session, 3/3 on the A11 reference session. * Parity ledger on the A11 replay sampled every frame: actors, vehicle parts, passengers (24,081/24,081) and hatches exact; no errors. * HUD against the original renderer: 99.9% of HUD pixels identical (the rest is a blinking button and damage in the reference capture). * Orders land 0.15-0.43 m from the clicked ground point. * Live battles at 1920x1080 measured 106-110 fps mean on a laptop GPU (3,000-frame runs). Open items and the full measured history are in [`engine/docs/PARITY_HANDOFF.md`](engine/docs/PARITY_HANDOFF.md) and [`engine/RECOMP_STATUS.md`](engine/RECOMP_STATUS.md). ## How it was built Most of the code was written with AI coding agents (Claude Code and Codex) working under a written operating manual ([`AGENTS.md`](AGENTS.md)): profile before optimizing, prove each change with a measured check (replay hashes, ledger layers, captures), and log the evidence. The design, priorities and play-testing are the author's. ## Run it ```powershell cd engine cargo build --release --bin newdawn # the one binary: engine\target\release\newdawn.exe cd .. run-game.bat # launches it; logs under %LOCALAPPDATA%\NewDawn\logs ``` New Dawn prepares terrain and buildings while the original game loads a standalone scenario. The window title shows when battle data is loading and when the renderer is preparing the battlefield. - **F10** cycles the saved 3D resolution setting through 100%, 85% and 70%. The HUD stays at window resolution. - **F11** toggles borderless fullscreen. - **F12** saves a battlefield and HUD screenshot in `Pictures\New Dawn`. ## Layout ``` engine/ the Rust workspace (crates/), research data (target/recomp/), docs/ scripts/ recomp/ (checks, launcher, analysis) and research tools that built the symbol database AGENTS.md how to work here CLAUDE.md Claude-specific additions run-game.bat launcher ``` Three representations of the original are kept apart: * **Generated Rust lift**: the runtime. Produced by `recomp-gen` into `engine/target/recomp/generated-rs/`. Never committed. * **Generated C reference**: an opt-in backend used only for differential checks. Never committed. * **Ghidra pseudocode**: lossy, not compilable, indexed in a SQLite symbol database under `%LOCALAPPDATA%\CombatMissionNewDawnResearch\`. A reading aid. ## Documents | File | Contents | |---|---| | [`AGENTS.md`](AGENTS.md) | rules, fast workflow, pitfalls, repository map | | [`engine/docs/GUEST_FACTS.md`](engine/docs/GUEST_FACTS.md) | what has been recovered about the original (offsets, clips, packets, measurements) | | [`engine/docs/TOOLS.md`](engine/docs/TOOLS.md) | commands, checks with timings, profiling, capture and probe switches | | [`engine/docs/ROADMAP.md`](engine/docs/ROADMAP.md) | status, release gates, prioritized work, decisions already made | | [`engine/docs/VERIFY_AND_LIFT.md`](engine/docs/VERIFY_AND_LIFT.md) | the verify loop, fixtures, rewrites, the mechanical lift | | [`engine/RECOMP_STATUS.md`](engine/RECOMP_STATUS.md) | current state and the dated log of measured results | | [`engine/THIRD_PARTY_NOTICES.md`](engine/THIRD_PARTY_NOTICES.md) | locked dependency versions and their declared license identifiers | ## Research tools `scripts/*.java` (Ghidra exports), `build_symbol_database.py`, `search_symbols.py`, `name_decompilation.py` and the `recover_*`/`inspect_*` scripts rebuild and query the symbol database; `scripts/recomp/engine/*.py` analyse the lift (scope, structs, fixtures, frame comparison). They are research tools, not part of the product.