adds docker container msvc 420 files

This commit is contained in:
Dethrace Labs 2025-07-28 12:06:09 +12:00
parent 9a49ff8c76
commit fbfcaca66b
7 changed files with 120 additions and 11 deletions

View File

@ -5,13 +5,18 @@ questions or concerns, please ask in #dethrace channel on our [Discord chat](htt
## Reporting bugs ## Reporting bugs
To report a bug, ensure you have a GitHub account. Search the issues page to see if the bug has already been reported. To report a bug, ensure you have a GitHub account. Search the issues page to see if the bug has already been reported.
If not, create a new issue and write the steps to reproduce. A screenshot or a video can often be useful. If not, create a new issue and write the steps to reproduce. A screenshot or a video can often be useful.
Please state which architecture and version of the game you are running, e.g. Please state which architecture and version of the game you are running, e.g.
``` ```
Harness_Init version: v0.4.0-15-g31afabc Harness_Init version: v0.4.0-15-g31afabc
Windows (x86-64) Windows (x86-64)
``` ```
## Binary accuracy
We aims to be as accurate as possible, matching the recompiled instructions to the original machine code as much as possible. The goal is to provide a workable codebase that can be modified, improved, and ported to other platforms later on. We are using [reccmp](https://github.com/isledecomp/reccmp?tab=readme-ov-file) to diff the recompiled code with the original Windows 95 code.
See: [docker](https://github.com/dethrace-labs/dethrace/blob/main/docker/README.md)
## Project goals ## Project goals
- Faithfully reproduce the original gameplay from Carmageddon 1 - Faithfully reproduce the original gameplay from Carmageddon 1
@ -42,7 +47,7 @@ By contributing your code, you agree to license your contribution under [GPL v3]
Join us in the #dethrace channel on our [Discord chat](https://discord.gg/f5StsuP). We'd love to talk! Join us in the #dethrace channel on our [Discord chat](https://discord.gg/f5StsuP). We'd love to talk!
## Code style ## Code style
We expect code to be formatted with our [clang-format](https://github.com/dethrace-labs/dethrace/blob/main/.clang-format) style. We expect code to be formatted with our [clang-format](https://github.com/dethrace-labs/dethrace/blob/main/.clang-format) style.
We recommend to configure your IDE to run clang-format on save. Heres how to enable it in Visual Studio Code for example: We recommend to configure your IDE to run clang-format on save. Heres how to enable it in Visual Studio Code for example:
![image](https://user-images.githubusercontent.com/78985374/200776372-8d5ec29d-8f39-4970-be69-7cc2abaf724d.png) ![image](https://user-images.githubusercontent.com/78985374/200776372-8d5ec29d-8f39-4970-be69-7cc2abaf724d.png)
@ -66,7 +71,7 @@ float velocity;
``` ```
## Inline BRender functions ## Inline BRender functions
Please use the [inline BRender functions](https://github.com/dethrace-labs/dethrace/blob/main/src/BRSRC13/include/brender/br_inline_funcs.h) where possible. Please use the [inline BRender functions](https://github.com/dethrace-labs/dethrace/blob/main/src/BRSRC13/include/brender/br_inline_funcs.h) where possible.
Instead of Instead of
```c ```c
@ -75,13 +80,13 @@ vector_a->v[1] = vector_b->v[1] * 6.0f;
vector_a->v[2] = vector_b->v[2] * 6.0f; vector_a->v[2] = vector_b->v[2] * 6.0f;
``` ```
it should look like it should look like
```c ```c
BrVector3Scale(&vector_a, &vector_b, 6.0f); BrVector3Scale(&vector_a, &vector_b, 6.0f);
``` ```
## Magic values ## Magic values
Many "magic" values are already defined as enums from the code-gen. Many "magic" values are already defined as enums from the code-gen.
Before adding something like `#define DEPTH_EFFECT_WATER 1`, look at [dr_types.h](https://github.com/dethrace-labs/dethrace/blob/main/src/DETHRACE/dr_types.h) and try to find the existing enum. For example: Before adding something like `#define DEPTH_EFFECT_WATER 1`, look at [dr_types.h](https://github.com/dethrace-labs/dethrace/blob/main/src/DETHRACE/dr_types.h) and try to find the existing enum. For example:
@ -98,7 +103,7 @@ typedef enum tSpec_vol_depth_effect {
In this case, can just replace the "1" with `eSpec_dep_water`. In this case, can just replace the "1" with `eSpec_dep_water`.
## Modern platform code ## Modern platform code
If you need to add new code to interface with modern platforms or cross-platform (for example, audio, rendering, get system time), please add this code into `src/harness`. `harness` contains only new code written by the dethrace project, and its goal is to provide a simple cross-platform interface to `BRSRC13` and `DETHRACE`. We want to keep the code in `BRSRC13` and `DETHRACE` as faithful to the original as possible, and not be polluted with extra modern code or dependencies. Instead, that code goes into `harness`. If you need to add new code to interface with modern platforms or cross-platform (for example, audio, rendering, get system time), please add this code into `src/harness`. `harness` contains only new code written by the dethrace project, and its goal is to provide a simple cross-platform interface to `BRSRC13` and `DETHRACE`. We want to keep the code in `BRSRC13` and `DETHRACE` as faithful to the original as possible, and not be polluted with extra modern code or dependencies. Instead, that code goes into `harness`.
Why is it called `harness`? Good question! It contains the _real_ `main` function, so harness starts up first, reads the command line, configures a few things, then calls into the _original_ main function in `src/DETHRACE`. The original game calls harness functions for platform services like audio and display. In this way, it acts like a harness for the original game engine. Why is it called `harness`? Good question! It contains the _real_ `main` function, so harness starts up first, reads the command line, configures a few things, then calls into the _original_ main function in `src/DETHRACE`. The original game calls harness functions for platform services like audio and display. In this way, it acts like a harness for the original game engine.
@ -111,7 +116,7 @@ Tests were written to cover some basic functionality at the start of the project
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. 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`. 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. To run the full test suite, you must have a copy of the original *Splat Pack* data.
@ -119,7 +124,7 @@ To run the full test suite, you must have a copy of the original *Splat Pack* da
export DETHRACE_ROOT_DIR=/path/to/carmageddon_splat_pack export DETHRACE_ROOT_DIR=/path/to/carmageddon_splat_pack
``` ```
To run To run
```sh ```sh
./dethrace_test ./dethrace_test

42
docker/Dockerfile Normal file
View File

@ -0,0 +1,42 @@
FROM docker.io/library/debian:stable-slim
# Gather dependencies
RUN dpkg --add-architecture i386
RUN apt-get update -y
RUN apt-get install git wine wine64 wine32 wget unzip pip -y
ENV WINEPREFIX=/wineprefix
# Silence debug warnings in wine (creates noise during compile)
ENV WINEDEBUG="-all"
COPY set-env.reg /tmp/set-env.reg
# Create and initialize Wine prefix
RUN mkdir -p $WINEPREFIX && \
wineboot --init && \
# wait for wineboot to finish
wineserver -w && \
wine regedit /S /tmp/set-env.reg && \
# wait for regedit to finish
wineserver -w
# Install MSVC 4.20 and CMake for Windows
RUN git clone https://github.com/itsmattkc/MSVC420 $WINEPREFIX/drive_c/msvc
# Install CMake for Windows
RUN wget --quiet https://github.com/Kitware/CMake/releases/download/v3.26.6/cmake-3.26.6-windows-i386.zip
RUN unzip -q cmake-3.26.6-windows-i386.zip -d $WINEPREFIX/drive_c
RUN mv $WINEPREFIX/drive_c/cmake-3.26.6-windows-i386 $WINEPREFIX/drive_c/cmake
RUN rm cmake-3.26.6-windows-i386.zip
# Install Ninja for Windows
RUN wget --quiet https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-win.zip
RUN unzip -q ninja-win.zip -d $WINEPREFIX/drive_c/ninja
RUN rm ninja-win.zip
# Install reccmp
RUN pip install --break-system-packages git+https://github.com/isledecomp/reccmp
# Set up entrypoint script to perform the build
COPY entrypoint.sh entrypoint.sh
ENTRYPOINT [ "./entrypoint.sh" ]

32
docker/README.md Normal file
View File

@ -0,0 +1,32 @@
# Docker container for running cross-platform MSVC 4.20
To run MSVC 4.20 outside of a non-Windows environment, you can use a Docker image and [Wine](https://www.winehq.org/)
## Build container image
```sh
docker buildx build --platform linux/amd64 -t msvc420-wine .
```
## Running the container
When running this container, you must pass
1. `CMAKE_FLAGS="-G Ninja -DCMAKE_BUILD_TYPE=Debug -DMSVC_42_FOR_RECCMP=on".
2. Path to the top-level dethrace directory (for example `/code/dethrace`).
3. Path to a msvc420-specific build directory (for example `/code/dethrace/build-msvc420`). This directory must exist but can start off empty. Note that this build directory _cannot be_ the same as your "regular" build directory.
4. Path to a directory with a copy of the original CARM95.EXE file (for example `/games/carma`). CARM95.EXE must match sha256 `c6040203856b71e6a22d2a29053a1eadd1a2ab41bce97b6031d745079bc07bdf`.
### Generating an HTML diff
This is the primary flow for making a change to the code, recompiling it with MSVC, then viewing the diff.
After running, a `diff.html` file will be created in the build-msvc420 directory.
```sh
docker run --platform linux/amd64 \
-e CMAKE_FLAGS="-G Ninja -DCMAKE_BUILD_TYPE=Debug -DMSVC_42_FOR_RECCMP=on" \
-v <PATH_TO_DETHRACE_DIR>:/source \
-v <PATH_TO_DETHRACE_BUILD_DIR>:/build \
-v <PATH_TO_CARMA_DIR>:/orginal:ro \
msvc420-wine -- \
reccmp-reccmp --target CARM95 --silent --html diff.html
```

22
docker/entrypoint.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e
export WINEPREFIX=/wineprefix
# Configure build with CMake
wine cmake -B build source $CMAKE_FLAGS
# Build
wine cmake --build build -- -j1
# Update path to original binary
cd /source
reccmp-project detect --search-path /original
# Fix up wine paths to underlying linux paths so we can run reccmp outside of wine
cd /build
sed -i 's/Z://g' reccmp-build.yml
if [ "$#" -gt 0 ]; then
exec "$@"
fi

8
docker/set-env.reg Normal file
View File

@ -0,0 +1,8 @@
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Environment]
"INCLUDE"="C:\\msvc\\include;C:\\msvc\\mfc\\include"
"LIB"="C:\\msvc\\lib;C:\\msvc\\mfc\\lib"
"TMP"="Z:\\build"
"TEMP"="Z:\\build"
"PATH"="C:\\msvc\\bin;C:\\msvc\\bin\\winnt;C:\\cmake\\bin;C:\\windows\\system32;C:\\ninja"

View File

@ -1,6 +1,6 @@
targets: targets:
CARM95: CARM95:
filename: carm95.exe filename: CARM95.EXE
source_root: src source_root: src
hash: hash:
sha256: c6040203856b71e6a22d2a29053a1eadd1a2ab41bce97b6031d745079bc07bdf sha256: c6040203856b71e6a22d2a29053a1eadd1a2ab41bce97b6031d745079bc07bdf
@ -147,4 +147,3 @@ targets:
"BrQsort", "BrQsort",
"BrFileRead", "BrFileRead",
] ]

View File

@ -185,8 +185,9 @@ else()
endif() endif()
# Create our main game binary. # Create our main game binary.
if (MSVC_42_FOR_RECCMP) if(MSVC_42_FOR_RECCMP)
add_executable(dethrace WIN32) add_executable(dethrace WIN32)
set_target_properties(dethrace PROPERTIES OUTPUT_NAME "CARM95")
target_link_options(dethrace PRIVATE /INCREMENTAL:NO /subsystem:windows /ENTRY:mainCRTStartup) target_link_options(dethrace PRIVATE /INCREMENTAL:NO /subsystem:windows /ENTRY:mainCRTStartup)
reccmp_add_target(dethrace ID CARM95) reccmp_add_target(dethrace ID CARM95)
reccmp_configure() reccmp_configure()