Reverse engineering the 1997 game "Carmageddon"
Go to file
Anonymous Maarten ee032df264
Fix MSVC tests + add mingw support (#65)
* Include windows.h before imagehlp.h

This fixes a long list of undefined type errors when building with mingw (on Linux).

* Remove matherr function

This function is provided by the c library.

* Use GetFileAttributesA to filter files

dirent->d_type is not available in all implementation.
Posix only mandates the fields d_name and d_ino.

* Use FindOpenGL.cmake to get the opengl library

Mingw has no libGL.so, but has libopengl32.a. Use the CMake module to abstract this away.

* harness needs to link to dbghelp

This fixes undefined references to:
__imp_SymInitialize, __imp_SymGetModuleBase64,
__imp_SymFunctionTableAccess64, __imp_StackWalk64 and __imp_SymCleanup.

* Don't add -g to compile options.

CMAKE_BUILD_TYPE=(Debug|RelWithDebInfo) takes care of this

* Set test file name before running tests in suite.

This causes the message to contain the correct file name where an assertion failed/succeeded.

* Use wrapper to sleep for number on seconds in tests

sleep on Windows expects milliseconds.
sleep on Posix expects seconds.

* Use char* instead of void*

MSVC complained that it couldn't determine the size of void

* Don't test state of removed resource after deletion when building Debug

When building in Debug configuration, the compiler may mark deleted memory ranges with some value.
Therefore, we cannot expect deleted memory to remain unchanged.
(MSVC in Debug mode does this)

* Use helper to get system temporary folder.

Using /tmp on Windows failed hard.

* Header containing sse3 intrinsics is pmmintrin.h

See https://github.com/recp/cglm/pull/234

* Add errno.h include for ENOTSUP

* Fix test_utility_GetALineWithNoPossibleService: avoid strcpy of uninitialized s

Found by running the tests with CMAKE_BUILD_TYPE=Debug with MSVC

* Add mingw@Linux and mingw@Windows jobs to github workflow

* Rename build-windows.ps1 script to build-msvc.ps1.

Also bump the versions of SDL2 and ninja, used in this script.

* Run tests in github jobs running on Windows

Co-authored-by: Dethrace Engineering Laboratory <78985374+dethrace-labs@users.noreply.github.com>
2022-01-20 13:17:10 +13:00
.github Fix MSVC tests + add mingw support (#65) 2022-01-20 13:17:10 +13:00
cmake Initial CMake based build system implementation. 2021-03-12 15:49:29 +00:00
docs Car control and physics attempt #1 (#57) 2021-09-08 13:19:08 +12:00
lib Fix MSVC tests + add mingw support (#65) 2022-01-20 13:17:10 +13:00
src Fix MSVC tests + add mingw support (#65) 2022-01-20 13:17:10 +13:00
test Fix MSVC tests + add mingw support (#65) 2022-01-20 13:17:10 +13:00
tools Feature/groove animations (#59) 2021-09-14 12:00:21 +12:00
.clang-format BrV1dbBeginWrapper_Float call tree (#19) 2020-01-10 14:59:43 -08:00
.gitignore Initial CMake based build system implementation. 2021-03-12 15:49:29 +00:00
CMakeLists.txt Rendering our first 3d scene! (#52) 2021-07-17 07:08:06 +12:00
LICENSE Create LICENSE 2019-11-18 11:42:18 -08:00
NOTES.md Feature/groove animations (#59) 2021-09-14 12:00:21 +12:00
README.md Update README.md 2021-09-10 06:30:44 +12:00
SCRATCH Car control and physics attempt #1 (#57) 2021-09-08 13:19:08 +12:00

README.md

Dethrace

Workflow

Discord Chat Channel Discord Chat Channel

Dethrace is an attempt to learn how the 1997 driving/mayhem game Carmageddon works behind the scenes and run it on modern systems.

Introduction

In 2014, Watcom debugging symbols for an earlier internal build were discovered on the Carmageddon Splat Pack expansion CD release. The symbols unfortunately did not match any known released executable, meaning they were interesting but not immediately usable to reverse engineer the game.

This is what it looked like from the Watcom debugger - the names of all the methods were present but the code location they were pointing to was junk:

watcom-debugger

CrayzKirk from the Carmageddon community then picked it up and did the painstaking work of manually matching up functions and data structures in the DOS executable to the debugging symbols.

After months of work, we are slowly replacing the original assembly code with equivalent C code.

Dependencies

SDL2

The easiest way to install SDL is via your favorite package manager.

OSX:

brew install SDL2

Linux:

apt-get install libsdl2-dev

Root content directory

Dethrace does not ship with any game content. You'll need access to the data from the original game. If you don't have an original CD then you can buy Carmageddon from GoG.com.

Point Dethrace at the Carmageddon install directory:

export DETHRACE_ROOT_DIR=/path/to/carmageddon

Build

Dethrace uses cmake for generating build files.

To generate the build files (generally only required once):

mkdir build
cd build
cmake ..

On cmake has generated the build files for your platform, run the build. For example:

make

Run

After building, build/dethrace is created

./dethrace [args]

Run tests

A subset of tests do not require DETHRACE_ROOT_DIR. They run via Github actions when code is committed to this repo. This allows us to keep nice and clean and avoid storing any potentially legally problematic resouces in our repo.

The majority of tests do require DETHRACE_ROOT_DIR.

To run the full test suite, you must have a copy of the original Splat Pack data.

export DETHRACE_ROOT_DIR=/path/to/carmageddon_splat_pack

To run

make test

To run a single test

DETHRACE_TEST_ARGS="-n test_name" make test

Changelog

From the beginning until release

Credits

  • CrayzKirk (manually matching up functions and data structures in the executable to the debugging symbols)
  • The developer at Stainless Software who left an old debugging .SYM file on the Splat Pack CD ;)

Dethrace is released to the Public Domain. The documentation and function provided by Dethrace may only be utilized with assets provided by ownership of Carmageddon.

The source code in this repository is for non-commerical use only. If you use the source code you may not charge others for access to it or any derivative work thereof.

Dethrace and any of its' maintainers are in no way associated with or endorsed by SCi, Stainless Software or THQ Nordic.