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

@ -12,6 +12,11 @@ Harness_Init version: v0.4.0-15-g31afabc
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
- Faithfully reproduce the original gameplay from Carmageddon 1

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:
CARM95:
filename: carm95.exe
filename: CARM95.EXE
source_root: src
hash:
sha256: c6040203856b71e6a22d2a29053a1eadd1a2ab41bce97b6031d745079bc07bdf
@ -147,4 +147,3 @@ targets:
"BrQsort",
"BrFileRead",
]

View File

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