PORTCLUB
Port nativo

Stunts (Stunts Engine)

Port nativo de Stunts (Stunts Engine) para PC.

Stunts (Stunts Engine)

Port nativo basado en su ficha de origen.

README del repositorio

Stunts Engine

A modern C reimplementation of the classic 4D Sports Driving / Stunts (1990) racing game engine, building on the reverse-engineering work of the Restunts project.

Targets modern operating systems, and 32-bit protected-mode DOS via DJGPP (see docs/dos.md).

How

Here is how this Stunts porting and replica project was started:

I wanted to port the old DOS game Stunts that I liked as a kid, customizable tracks and crazy crashes!! I check online and found out about the Restunts project, which had already done much of the reverse-engineering groundwork... and decided that it feal achievable to port this game to modern hardware using Copilot.

At the start of the porting it was just ok-ish; The testing at this stage ran entirely inside DOSBox on Linux, it was slow, recompiling with a DOS BORLAND/TASM toolchain and running the result inside DOSBox. The initial porting from "ASM to C" goals was very minimal; That the game audio should still be heard and that it could reach the main menu (no game crashing). After many retries to port the code properly to C (Copilot was doing stupid "workaround" code and not properly porting and investigating). In the end I was able to get a very broken but still running game that loaded ressources and run with almost no assembly code remaining.

Now I decided to drop DOS support entirely, It was time to move to modern hardware which I expected it will help a lot better for debugging and testing.

Move from DOS to Modern Linux

The initial move to a Linux/GCC build was quick using SDL as the backend. After getting the game to start, a lot of work was needed to port to modern hardware, dealing with a lot of 16-bit to 64-bit arch issues (The ASAN build preset helped a lot). Fixing resource loading at first, then video output to SDL, and finally display the in-game main menu. Then I moved to getting a working game. Using Copilot I started comparing the original ASM code to the ported C code and fixing mismatches. Again a long process of back and forth, but still much faster than doing it manually. Having C code alongside the original ASM allowed Copilot to make good progress by directly comparing the two.

Current port state

Yes the code is generated in major part with Copilot but I reviewed and update code as needed to a more usable and modern source code. But still the code is a weird mix of a lot old logics code with hardcoded values and "ASM like" C functions, Many globals and some new modern refactor SDL3 logics. But now with this foundation it is easy to debug and doing refactor and clean-up as needed.

The game is playable with most of the features fully implemented.

Enhancements

The goal is to preserve the original gameplay and visuals while adding improvements and updating the engine for modern hardware. For example, the game now runs at a proper 30 fps and the draw distance is significantly greater than the original.

Repository Layout

include/        Public header files
src/            C source files (engine, rendering, audio, menus, physics …)
library/
  adplug/       Git submodule – OPL2 FM emulator (auto-cloned on first build)
  sdl3-windows/ SDL3 MinGW dev archive (auto-downloaded for Windows builds)
ressources/     Game resource files (see "Game Resources" below)
docs/           Design documents and the original game manual
cmake/          CMake toolchain files (MinGW and DJGPP cross-compilation)
clean_repo.sh   Script to remove all build artifacts and downloaded deps

Prerequisites

Linux

sudo apt-get install build-essential cmake libsdl3-dev git
ToolMinimum version
GCC or Clangany modern version
CMake3.16
SDL3 dev headers3.x
Gitany

Windows (cross-compile from Linux)

Install the Linux prerequisites above, then add MinGW-w64:

sudo apt-get install mingw-w64

The SDL3 Windows development archive is downloaded automatically by CMake on the first configure run. No manual SDL3 setup is needed.

DOS (cross-compile from Linux)

Install the Linux prerequisites above, then a DJGPP cross-compiler, so that i586-pc-msdosdjgpp-gcc is on PATH (see https://github.com/andrewwutw/build-djgpp).

SDL3 is fetched and built from source by CMake on the first configure run. To run the result you also need a DPMI host, CWSDPMI.EXE, from https://sandmann.dotster.com/cwsdpmi/.


Game Resources

The engine requires the original Stunts game data files to run. These are not included in this repository for copyright reasons.

Copy the following files from a legitimate copy of the game into the ressources/ directory before building:

PatternDescription
*.RESCar and UI resource archives
*.P3S3-D shape files
*.PVSPre-rendered scene / menu artwork
*.PREOpponent preset data
*.TRK / *.HIGTrack layouts and high-score tables
*.KMSMusic song files
*.VCEVoice / sound data
*.SFXSound effects
*.FNTBitmap fonts
DEFAULT.RPLDefault replay

Building

git clone --recurse-submodules https://github.com/user/stuntsengine.git
cd stuntsengine

Linux

# Debug
cmake --preset linux-debug
cmake --build --preset linux-debug

# Release
cmake --preset linux-release
cmake --build --preset linux-release

Windows (cross-compile from Linux)

cmake --preset windows-x64
cmake --build --preset windows-x64

SDL3 is downloaded automatically on the first configure run. The output (stunts.exe + SDL3.dll) can be copied directly to a Windows machine.

DOS (cross-compile from Linux)

Needs a DJGPP cross-compiler (i586-pc-msdosdjgpp-gcc) on PATH.

cmake --preset dos
cmake --build --preset dos

SDL3 is fetched and built from source on the first configure run. The output build_cmake_dos/stunts.exe needs a DPMI host (CWSDPMI.EXE) beside it at runtime, plus the game data. See docs/dos.md.

All presets

PresetPlatformType
linux-debugLinuxDebug
linux-releaseLinuxRelease, optimised
linux-asanLinuxDebug + AddressSanitizer
windows-x64Windows (MinGW)Release
dosDOS 32-bit (DJGPP)Release

GitHub Releases

GitHub Actions release builds are defined in .github/workflows/release.yml.

  • Pushing a tag matching v* builds Linux and Windows release artifacts and publishes them to a GitHub release.
  • Running the workflow manually with workflow_dispatch builds the same artifacts and uploads them to the workflow run.
  • The Windows artifact is produced with the existing windows-x64 MinGW cross-compile preset on Ubuntu, matching the documented local build flow.

CMake options

OptionDefaultDescription
STUNTS_ASANOFFEnable AddressSanitizer
STUNTS_FM_EMULATIONON (OFF on DOS)Synthesize FM in software (Nuked-OPL3) instead of driving the OPL at port 388h. Forced ON off DOS.

Cleaning

clean_repo.sh removes all generated and downloaded content:

./clean_repo.sh             # remove build dirs, SDL3 package, submodule content
./clean_repo.sh --archive   # same + create ../stuntsengine-clean.tar.gz

Acknowledgements

  • Restunts – the original reverse-engineering project
  • Stunts Wiki – community documentation

Comentarios (0)

Inicia sesión para dejar un comentario.

Sé el primero en comentar sobre este juego.